while True:
friends = hero.findFriends()
for friend in friends:
witch = friend.findNearest(friend.findByType('witch'))
ogre = friend.findNearest(friend.findByType('ogre'))
if friend.id is "paladin":
paladin = friend
if friend.id is "archer":
archer = friend
if friend.id is "soldier":
soldier = friend
if witch:
target = witch
elif ogre:
target = ogre
else:
target = friend.findNearestEnemy()
if witch:
hero.command(archer, "attack", witch)
if paladin:
hero.command(paladin, "defend", archer)
if ogre:
hero.command(soldier, "attack", ogre)
These are lines 20 to 43 of my code, and my archers only target the things near them. I’m trying to do different tactics for my units, but they keep targeting only the nearest. Why are they doing this?
as it turned out the code i left out was the reason why i wasn’t getting it done. I had my hero jump into the catapults, then shield a bunch, but it was outside the while true loop. I fixed it now.