here is my code:
def efficiency(item):
return item.value / hd(item)
def fd(x):
friend.distanceTo(x)
def hd(x):
hero.distanceTo(x)
def fm(x):
hero.command(friend, "move", x)
def fa(x):
hero.command(friend, "attack", x)
def c20():
a = 0
x = 0
while x < len(corpses):
corpse = corpses[x]
if corpse and hd(corpse) <= 20:
a += 1
x += 1
if a >= 4:
return True
break
def e20():
a = 0
x = 0
for enemy in enemies:
enemy = enemies[x]
if hd(enemy) <= 20:
a += 1
x += 1
if a >= 4:
return True
break
def bestItem(items):
a = 0
besty = None
x = 0
while x < len(items):
item = items[x]
if a < efficiency(item):
besty = item
a = efficiency(item)
x += 1
return besty
def xxx(enemies):
a = 0
b = None
x = 0
while x < len(enemies):
enemy = enemies[x]
if a < enemy.maxHealth:
a = enemy.maxHealth
b = enemy
x += 1
return b
def skills():
if hero.canCast("fear", leader) and hd(leader) <= 50 and leader.maxHealth > 200:
hero.cast("fear", leader)
if c and hero.canCast("raise-dead", c) and hd(c) <= 20 and c20():
hero.cast("raise-dead", c)
if hero.isReady("mana-blast") and hd(enemy) < 20 and e20():
hero.manaBlast(enemy)
if hero.isReady("reset-cooldown") and not hero.canCast("raise-dead"):
hero.resetCooldown("raise-dead")
elif hero.health < 1000 and hero.canCast("drain-life", enemy) and hero.distanceTo(enemy) <= 17 and hd(enemy) > 10:
hero.cast("drain-life", enemy)
while True:
enemies = hero.findEnemies()
leader = xxx(enemies)
t = hero.team
a = hero.findFriends()
corpses = hero.findCorpses()
c = hero.findNearest(corpses)
y = hero.findNearest(a)
items = hero.findItems()
coin = bestItem(items)
hero.move(coin.pos)
enemy = hero.findNearestEnemy()
if hero.canCast("goldstorm"):
hero.cast("goldstorm")
if enemy and enemy.type != "yeti" and enemy.type != "cage" and hd(enemy) < 40:
skills()
if hero.gold >= 50:
hero.summon("griffin-rider")
for friend in a:
fx = friend.findNearestEnemy()
if fx and friend and friend.team == t:
if fd(fx) > 35 or fd(fx) < 20 and hd(fx) >= 20 or fx.type == "cage":
fm(hero.pos)
elif fd(fx) <= 35:
fa(fx)
Level: Zero Sum
I just changed this last part of the code which is irrelevant:
for friend in a:
fx = friend.findNearestEnemy()
if fx and friend and friend.team == t:
if fd(fx) > 35 or fd(fx) < 20 and hd(fx) >= 20 or fx.type == "cage":
fm(hero.pos)
elif fd(fx) <= 35:
fa(fx)
And then, it started to say that error in picture. Why and what is the solution? Thanks.