YES, I finally figured it out. The documentation for troop_get_upgrade_troop is wrong. Instead of 0 for random, 1 for first node, and 2 for second node it is 0 for first node and 1 for second node. I wondered why in the original module system the uses contained :rand_no variable for the value. It is because there is no 0 for random. This needs to be fixed in the documentation, but I do not know who to notify.