Can you use a self.say(friendEnemy.id) to determine what target are you finding. If you do not have see through wall glasses you will not find the witch.
To kill the catapults you must run towards them and run back. The brawlers will come after you and they will be killed by the catapult fire when you run back.
Try to fix this part first, because if your hero dies you can’t test the code for your troops.
Also do not use moveXY - it makes your code wait. until your hero actually reaches the given point.
During this time you cannot do anything else, you cannot command your troops => your troops will die.
Use instead move - it instruct the hero to move towards a point, put it does not wait.
my friends will not go to the exit after all the enemies are killed, what is wrong with my code?
(I am using omarn with speed ring and boots of leaping and burl staff and 1000 HP)
exit = Vector(78, 40)
def commandFriends():
friends = self.findFriends()
enemies = self.findEnemies()
greatestEnemyHealth = 0
enemy = None
for Lenemy in enemies:
if Lenemy.health > greatestEnemyHealth and Lenemy.type != "witch" and Lenemy.pos.y > 35:
greatestEnemyHealth = Lenemy.health
enemy = Lenemy
for friend in friends:
witch = friend.findNearest(self.findByType("witch"))
if friend.type = "paladin":
if witch:
self.command(friend, "attack", witch)
elif enemy:
self.command(friend, "attack", enemy)
elif enemy:
self.command(friend, "attack", enemy)
else:
self.command(friend, "move", exit)
def helpFriends():
ogre = self.findNearest(self.findByType("ogre"))
self.moveXY(25, 22)
if ogre:
self.attack(ogre)
commandFriends()
self.moveXY(48, 15)
self.cast("drain-life", self.findNearest(self.findEnemies()))
commandFriends()
helpFriends()
commandFriends()
while self.findNearest(self.findByType("catapult")):
self.moveXY(69, 16)
commandFriends()
helpFriends()
commandFriends()
self.moveXY(78, 14)
loop:
commandFriends()