while true:
enemy = hero.findNearestEnemy()
if enemy and enemy.type = "brawler" and hero.isReady("invisibility")
hero.cast(invisibility, self)
hero.attack(enemy)
if enemy:
hero.attack(enemy)
enemy = hero.findNearestEnemy()
friends = hero.findfriends()
for friend in friends:
if hero.gold > hero.costOf(âsoldierâ):
hero.summon(âsoldierâ)
hero.command(friend, âattackâ, enemy)
The summoning part should be out of the for loop, and there should be an if friend statement, or there would be an error, like attacking enemy without using if enemy first.
@Eric_Tang, your code doesnât work. My hero doesnât do anything. Code:
friends = hero.findFriends()
for friend in friends:
if hero.gold > hero.costOf("soldier"):
hero.summon("soldier")
hero.command(friend, "attack", enemy)