Convenient Enemy


#1

I dont want to post all my code but ill explain it.

for x in range(8, 73, 16):
    hero.moveXY(x, 22)
    # Peasants know whom to summon.
    peasant = hero.findNearest(hero.findFriends())
    message = peasant.message
    if message:
        # Words are seaparated by whitespaces.
        words = message.split(" ")
        # "words" is an array of words from the "message".
        # Get the last word. It's the required unit type.

Right below this point in the code which is the first loop. I had to add the hero.say method inorder to get him to stop moving. If I didnt have the method he would fly by the second red X and not even summon a unit. Unless im doing this wrong I personally dont see how else to finish this without the hero.say method. I also ran into the problem where when the unit is summoned and my hero drags the unit half way across to the next red X. It mainly happens on just the first unit. The code still works but just wanted to point that out.


#2

Just covert this javascript to python ok!
var type = words[words.length - 1]; // Summon the required unit type. hero.summon(type);