while True:
paladins = []
enemies = hero.findNearestEnemy()
greenFlag = hero.findFlag("green")
blackFlag = hero.findFlag("black")
violetFlag = hero.findFlag("violet")
if violetFlag:
friends = hero.findFriends()
if friends:
for friend in friends:
if friend:
hero.command(friend, "move", violetFlag.pos)
if greenFlag:
hero.pickUpFlag(greenFlag)
if blackFlag:
hero.pickUpFlag(blackFlag)
hero.attack(enemy)
if hero.canCast("invisibility", hero):
hero.cast("invisibility", hero)
friends = hero.findFriends()
for enemy in hero.findEnemies():
friends = hero.findFriends()
for friend in friends:
e = friend.findNearestEnemy()
if e:
hero.command(friend, "attack", e)
fire = hero.findNearestEnemy()
if fire:
while fire.health > 0:
if hero.canCast("invisibility", hero):
hero.cast("invisibility", hero)
hero.attack(fire)
hero.shield()
if fire.type == "tower":
pass
if hero.gold > hero.costOf("soldier"):
hero.summon("soldier")
if hero.health < 3000:
for friend in friends:
if friend and friend.type == "paladin":
if friend.canCast("heal"):
hero.command(friend, "cast", "heal" , hero)
while True:
paladins = []
enemies = hero.findNearestEnemy()
greenFlag = hero.findFlag("green")
blackFlag = hero.findFlag("black")
violetFlag = hero.findFlag("violet")
if violetFlag:
friends = hero.findFriends()
if friends:
for friend in friends:
if friend:
hero.command(friend, "move", violetFlag.pos)
if greenFlag:
hero.pickUpFlag(greenFlag)
if blackFlag:
hero.pickUpFlag(blackFlag)
hero.attack(enemy)
if hero.canCast("invisibility", hero):
hero.cast("invisibility", hero)
friends = hero.findFriends()
for enemy in hero.findEnemies():
friends = hero.findFriends()
for friend in friends:
e = friend.findNearestEnemy()
if e:
hero.command(friend, "attack", e)
fire = hero.findNearestEnemy()
if fire:
if fire.type == "thrower":
hero.findFriends()
if friend.type == "archer":
hero.command(friend, "attack", target)
if fire.type == "beam-tower":
if hero.canCast("chain-lightning", target):
hero.cast("chain-lightning", target)
hero.attack(enemy)
pass
if hero.gold > hero.costOf("archer"):
hero.summon("archer")
if hero.health < 3000:
for friend in friends:
if friend and friend.type == "paladin":
if friend.canCast("heal"):
hero.command(friend, "cast", "heal" , hero)
Yeah, the problem is here. You have to write target = hero.findNearestEnemy()
Also, you have to write friends = hero.findFriends(), and then you have to write for, and only in it command your friends.
while True:
paladins = []
enemies = hero.findNearestEnemy()
greenFlag = hero.findFlag("green")
blackFlag = hero.findFlag("black")
violetFlag = hero.findFlag("violet")
if violetFlag:
friends = hero.findFriends()
if friends:
for friend in friends:
if friend:
hero.command(friend, "move", violetFlag.pos)
if greenFlag:
hero.pickUpFlag(greenFlag)
if blackFlag:
hero.pickUpFlag(blackFlag)
hero.attack(enemy)
if hero.canCast("invisibility", hero):
hero.cast("invisibility", hero)
friends = hero.findFriends()
for enemy in hero.findEnemies():
friends = hero.findFriends()
for friend in friends:
e = friend.findNearestEnemy()
if e:
hero.command(friend, "attack", e)
fire = hero.findNearestEnemy()
if fire:
if fire.type == "thrower":
pass
while fire.health > 0:
if hero.canCast("invisibility", hero):
hero.cast("invisibility", hero)
hero.attack(fire)
hero.shield()
if fire.type == "beam-tower":
hero.command("archer", "attack", "beam-tower")
if hero.gold > hero.costOf("archer"):
hero.summon("archer")
if hero.health < 3000:
for friend in friends:
if friend and friend.type == "paladin":
if friend.canCast("heal"):
hero.command(friend, "cast", "heal" , hero)