Try to write if (hero.gold >25 and enemy and enemy.target and enemy.target == hero) or (hero.gold >25 and enemy and enemy.target and enemy.target == peasant)
You need to check if the enemy has the target and also if you write like you wrote, it will mean “If hero gold >25 and enemy and enemy.target == hero or nothing and enemy.target == peasant”. That;s why you need to write everything again after the or.
# Your goal is to collect coins / gems.
# This level is repeatable. If you win, the difficulty and rewards will increase.
# If you fail, you have to wait a day to resubmit.
# This level is an optional challenge level. You don't need to beat it to continue the campaign!
'''
def collect():
peasants = hero.findByType("peasant")
for peasant in peasants:
if peasant and peasant.team == hero.team:
item = peasant.findNearestItem()
if item:
hero.command(peasant, "move", item.pos)
hero.cast("summon-burl")
hero.cast("summon-undead")
burl = hero.findByType("burl")[0]
hero.cast("sacrifice", burl, hero)
while True:
enemy = hero.findNearestEnemy()
burls = hero.findByType("burl")
undeads = hero.findByType("skeleton")
collect()
for burl in burls:
if burl and hero.canCast("sacrifice", burl):
hero.cast("sacrifice", burl, hero)
if enemy:
if hero.canCast("devour", enemy):
hero.cast("devour", enemy)
elif hero.canCast("poison-cloud", enemy):
hero.cast("poison-cloud", enemy)
elif hero.canCast("chain-lightning", enemy):
hero.cast("chain-lightning", enemy)
elif hero.canCast("drain-life", enemy):
hero.cast("drain-life", enemy)
elif hero.canCast("fear", enemy):
hero.cast("fear", enemy)
elif enemy.target == hero and hero.isReady("shape-shift"):
pet.shapeShift()
hero.attack(enemy)
if hero.isReady("summon-burl"):
hero.cast("summon-burl")
if hero.isReady("summon-undead"):
hero.cast("summon-undead")
'''
'''
def findStrongestEnemy():
strongest = None
strongestHealth = 0
enemies = hero.findEnemies()
for enemy in enemies:
if enemy.health > strongestHealth:
strongestHealth = enemy.health
strongest = enemy
return strongest
def onSpawn():
while True:
pet.moveXY(76, 107)
pet.shapeShift()
def collect():
peasants = hero.findByType("peasant")
for peasant in peasants:
if peasant and peasant.team == hero.team:
item = peasant.findNearestItem()
if item:
hero.command(peasant, "move", item.pos)
hero.cast("summon-burl")
hero.cast("summon-undead")
burl = hero.findByType("burl")[0]
hero.cast("sacrifice", burl, hero)
pet.on("spawn", onSpawn)
while True:
enemy = hero.findNearestEnemy()
enemies = hero.findEnemies()
burls = hero.findByType("burl")
undeads = hero.findByType("skeleton")
collect()
for undead in undeads:
if undead and hero.canCast("sacrifice", undead):
hero.cast("sacrifice", undead, hero)
for burl in burls:
if burl and hero.canCast("sacrifice", burl):
hero.cast("sacrifice", burl, hero)
if enemy:
if hero.canCast("devour", findStrongestEnemy()):
hero.cast("devour",findStrongestEnemy())
elif hero.canCast("poison-cloud", findStrongestEnemy()):
hero.cast("poison-cloud", findStrongestEnemy())
elif hero.canCast("chain-lightning", findStrongestEnemy()):
hero.cast("chain-lightning", findStrongestEnemy())
elif hero.canCast("drain-life", findStrongestEnemy()):
hero.cast("drain-life", findStrongestEnemy())
elif hero.canCast("fear", findStrongestEnemy()):
hero.cast("fear", findStrongestEnemy())
hero.attack(findStrongestEnemy())
if hero.isReady("summon-burl"):
hero.cast("summon-burl")
if hero.isReady("summon-undead"):
hero.cast("summon-undead")
for dead in hero.findCorpses():
if dead and hero.distanceTo(dead) < 20 and hero.canCast("raise-dead"):
hero.cast("raise-dead")
else:
if dead and hero.canCast("raise-dead"):
hero.move(dead.pos)
hero.cast("raise-dead")
peasants = hero.findByType("peasant")
for peasant in peasants:
if hero.gold >= 25 and enemy:
hero.command(peasant, "buildXY","decoy", peasant.pos.x, peasant.pos.y)
'''
# Your goal is to collect coins / gems.
# This level is repeatable. If you win, the difficulty and rewards will increase.
# If you fail, you have to wait a day to resubmit.
# This level is an optional challenge level. You don't need to beat it to continue the campaign!
'''
def collect():
peasants = hero.findByType("peasant")
for peasant in peasants:
if peasant and peasant.team == hero.team:
item = peasant.findNearestItem()
if item:
hero.command(peasant, "move", item.pos)
hero.cast("summon-burl")
hero.cast("summon-undead")
burl = hero.findByType("burl")[0]
hero.cast("sacrifice", burl, hero)
while True:
enemy = hero.findNearestEnemy()
burls = hero.findByType("burl")
undeads = hero.findByType("skeleton")
collect()
for burl in burls:
if burl and hero.canCast("sacrifice", burl):
hero.cast("sacrifice", burl, hero)
if enemy:
if hero.canCast("devour", enemy):
hero.cast("devour", enemy)
elif hero.canCast("poison-cloud", enemy):
hero.cast("poison-cloud", enemy)
elif hero.canCast("chain-lightning", enemy):
hero.cast("chain-lightning", enemy)
elif hero.canCast("drain-life", enemy):
hero.cast("drain-life", enemy)
elif hero.canCast("fear", enemy):
hero.cast("fear", enemy)
elif enemy.target == hero and hero.isReady("shape-shift"):
pet.shapeShift()
hero.attack(enemy)
if hero.isReady("summon-burl"):
hero.cast("summon-burl")
if hero.isReady("summon-undead"):
hero.cast("summon-undead")
'''
# Your goal is to collect coins / gems.
# This level is repeatable. If you win, the difficulty and rewards will increase.
# If you fail, you have to wait a day to resubmit.
# This level is an optional challenge level. You don't need to beat it to continue the campaign!
'''
def collect():
peasants = hero.findByType("peasant")
for peasant in peasants:
if peasant and peasant.team == hero.team:
item = peasant.findNearestItem()
if item:
hero.command(peasant, "move", item.pos)
hero.cast("summon-burl")
hero.cast("summon-undead")
burl = hero.findByType("burl")[0]
hero.cast("sacrifice", burl, hero)
while True:
enemy = hero.findNearestEnemy()
burls = hero.findByType("burl")
undeads = hero.findByType("skeleton")
collect()
for burl in burls:
if burl and hero.canCast("sacrifice", burl):
hero.cast("sacrifice", burl, hero)
if enemy:
if hero.canCast("devour", enemy):
hero.cast("devour", enemy)
elif hero.canCast("poison-cloud", enemy):
hero.cast("poison-cloud", enemy)
elif hero.canCast("chain-lightning", enemy):
hero.cast("chain-lightning", enemy)
elif hero.canCast("drain-life", enemy):
hero.cast("drain-life", enemy)
elif hero.canCast("fear", enemy):
hero.cast("fear", enemy)
elif enemy.target == hero and hero.isReady("shape-shift"):
pet.shapeShift()
hero.attack(enemy)
if hero.isReady("summon-burl"):
hero.cast("summon-burl")
if hero.isReady("summon-undead"):
hero.cast("summon-undead")
'''
'''
def findStrongestEnemy():
strongest = None
strongestHealth = 0
enemies = hero.findEnemies()
for enemy in enemies:
if enemy.health > strongestHealth:
strongestHealth = enemy.health
strongest = enemy
return strongest
def onSpawn():
while True:
pet.moveXY(76, 107)
pet.shapeShift()
def collect():
peasants = hero.findByType("peasant")
for peasant in peasants:
if peasant and peasant.team == hero.team:
item = peasant.findNearestItem()
if item:
hero.command(peasant, "move", item.pos)
hero.cast("summon-burl")
hero.cast("summon-undead")
burl = hero.findByType("burl")[0]
hero.cast("sacrifice", burl, hero)
pet.on("spawn", onSpawn)
while True:
enemy = hero.findNearestEnemy()
enemies = hero.findEnemies()
burls = hero.findByType("burl")
undeads = hero.findByType("skeleton")
collect()
for undead in undeads:
if undead and hero.canCast("sacrifice", undead):
hero.cast("sacrifice", undead, hero)
for burl in burls:
if burl and hero.canCast("sacrifice", burl):
hero.cast("sacrifice", burl, hero)
if enemy:
if hero.canCast("devour", findStrongestEnemy()):
hero.cast("devour",findStrongestEnemy())
elif hero.canCast("poison-cloud", findStrongestEnemy()):
hero.cast("poison-cloud", findStrongestEnemy())
elif hero.canCast("chain-lightning", findStrongestEnemy()):
hero.cast("chain-lightning", findStrongestEnemy())
elif hero.canCast("drain-life", findStrongestEnemy()):
hero.cast("drain-life", findStrongestEnemy())
elif hero.canCast("fear", findStrongestEnemy()):
hero.cast("fear", findStrongestEnemy())
hero.attack(findStrongestEnemy())
if hero.isReady("summon-burl"):
hero.cast("summon-burl")
if hero.isReady("summon-undead"):
hero.cast("summon-undead")
for dead in hero.findCorpses():
if dead and hero.distanceTo(dead) < 20 and hero.canCast("raise-dead"):
hero.cast("raise-dead")
else:
if dead and hero.canCast("raise-dead"):
hero.move(dead.pos)
hero.cast("raise-dead")
peasants = hero.findByType("peasant")
for peasant in peasants:
if hero.gold >= 25 and enemy:
hero.command(peasant, "buildXY","decoy", peasant.pos.x, peasant.pos.y)
'''
# Your goal is to collect coins / gems.
# This level is repeatable. If you win, the difficulty and rewards will increase.
# If you fail, you have to wait a day to resubmit.
# This level is an optional challenge level. You don't need to beat it to continue the campaign!
'''
def collect():
peasants = hero.findByType("peasant")
for peasant in peasants:
if peasant and peasant.team == hero.team:
item = peasant.findNearestItem()
if item:
hero.command(peasant, "move", item.pos)
hero.cast("summon-burl")
hero.cast("summon-undead")
burl = hero.findByType("burl")[0]
hero.cast("sacrifice", burl, hero)
while True:
enemy = hero.findNearestEnemy()
burls = hero.findByType("burl")
undeads = hero.findByType("skeleton")
collect()
for burl in burls:
if burl and hero.canCast("sacrifice", burl):
hero.cast("sacrifice", burl, hero)
if enemy:
if hero.canCast("devour", enemy):
hero.cast("devour", enemy)
elif hero.canCast("poison-cloud", enemy):
hero.cast("poison-cloud", enemy)
elif hero.canCast("chain-lightning", enemy):
hero.cast("chain-lightning", enemy)
elif hero.canCast("drain-life", enemy):
hero.cast("drain-life", enemy)
elif hero.canCast("fear", enemy):
hero.cast("fear", enemy)
elif enemy.target == hero and hero.isReady("shape-shift"):
pet.shapeShift()
hero.attack(enemy)
if hero.isReady("summon-burl"):
hero.cast("summon-burl")
if hero.isReady("summon-undead"):
hero.cast("summon-undead")
'''
def findStrongestEnemy():
strongest = None
strongestHealth = 0
enemies = hero.findEnemies()
for enemy in enemies:
if enemy.health > strongestHealth:
strongestHealth = enemy.health
strongest = enemy
return strongest
def onSpawn():
while True:
pet.moveXY(76, 107)
pet.shapeShift()
def collect():
peasants = hero.findByType("peasant")
for peasant in peasants:
if peasant and peasant.team == hero.team:
item = peasant.findNearestItem()
if item:
hero.command(peasant, "move", item.pos)
hero.cast("summon-burl")
hero.cast("summon-undead")
burl = hero.findByType("burl")[0]
hero.cast("sacrifice", burl, hero)
pet.on("spawn", onSpawn)
while True:
enemy = hero.findNearestEnemy()
enemies = hero.findEnemies()
burls = hero.findByType("burl")
undeads = hero.findByType("skeleton")
collect()
for undead in undeads:
if undead and hero.canCast("sacrifice", undead):
hero.cast("sacrifice", undead, hero)
for burl in burls:
if burl and hero.canCast("sacrifice", burl):
hero.cast("sacrifice", burl, hero)
if enemy:
if hero.canCast("devour", findStrongestEnemy()):
hero.cast("devour",findStrongestEnemy())
elif hero.canCast("poison-cloud", findStrongestEnemy()):
hero.cast("poison-cloud", findStrongestEnemy())
elif hero.canCast("chain-lightning", findStrongestEnemy()):
hero.cast("chain-lightning", findStrongestEnemy())
elif hero.canCast("drain-life", findStrongestEnemy()):
hero.cast("drain-life", findStrongestEnemy())
elif hero.canCast("fear", findStrongestEnemy()):
hero.cast("fear", findStrongestEnemy())
hero.attack(findStrongestEnemy())
if hero.isReady("summon-burl"):
hero.cast("summon-burl")
if hero.isReady("summon-undead"):
hero.cast("summon-undead")
for dead in hero.findCorpses():
if dead and hero.distanceTo(dead) < 20 and hero.canCast("raise-dead"):
hero.cast("raise-dead")
else:
if dead and hero.canCast("raise-dead"):
hero.move(dead.pos)
hero.cast("raise-dead")
peasants = hero.findByType("peasant")
for peasant in peasants:
if (hero.gold >= 25 and enemy and enemy.target and enemy.target == hero) or (hero.gold >= 25 and enemy and enemy.target and enemy.target == peasant):
hero.command(peasant, "buildXY","decoy", peasant.pos.x, peasant.pos.y)
Is there an error in the code? If not, you might need to change your strategy a little bit.
maybe try making all these if statements instead of elifs cuz this way the enemy doesnt receive only one of these but rather as much as available
# Your goal is to collect coins / gems.
# This level is repeatable. If you win, the difficulty and rewards will increase.
# If you fail, you have to wait a day to resubmit.
# This level is an optional challenge level. You don't need to beat it to continue the campaign!
'''
def collect():
peasants = hero.findByType("peasant")
for peasant in peasants:
if peasant and peasant.team == hero.team:
item = peasant.findNearestItem()
if item:
hero.command(peasant, "move", item.pos)
hero.cast("summon-burl")
hero.cast("summon-undead")
burl = hero.findByType("burl")[0]
hero.cast("sacrifice", burl, hero)
while True:
enemy = hero.findNearestEnemy()
burls = hero.findByType("burl")
undeads = hero.findByType("skeleton")
collect()
for burl in burls:
if burl and hero.canCast("sacrifice", burl):
hero.cast("sacrifice", burl, hero)
if enemy:
if hero.canCast("devour", enemy):
hero.cast("devour", enemy)
elif hero.canCast("poison-cloud", enemy):
hero.cast("poison-cloud", enemy)
elif hero.canCast("chain-lightning", enemy):
hero.cast("chain-lightning", enemy)
elif hero.canCast("drain-life", enemy):
hero.cast("drain-life", enemy)
elif hero.canCast("fear", enemy):
hero.cast("fear", enemy)
elif enemy.target == hero and hero.isReady("shape-shift"):
pet.shapeShift()
hero.attack(enemy)
if hero.isReady("summon-burl"):
hero.cast("summon-burl")
if hero.isReady("summon-undead"):
hero.cast("summon-undead")
'''
'''
def findStrongestEnemy():
strongest = None
strongestHealth = 0
enemies = hero.findEnemies()
for enemy in enemies:
if enemy.health > strongestHealth:
strongestHealth = enemy.health
strongest = enemy
return strongest
def onSpawn():
while True:
pet.moveXY(76, 107)
pet.shapeShift()
def collect():
peasants = hero.findByType("peasant")
for peasant in peasants:
if peasant and peasant.team == hero.team:
item = peasant.findNearestItem()
if item:
hero.command(peasant, "move", item.pos)
hero.cast("summon-burl")
hero.cast("summon-undead")
burl = hero.findByType("burl")[0]
hero.cast("sacrifice", burl, hero)
pet.on("spawn", onSpawn)
while True:
enemy = hero.findNearestEnemy()
enemies = hero.findEnemies()
burls = hero.findByType("burl")
undeads = hero.findByType("skeleton")
collect()
for undead in undeads:
if undead and hero.canCast("sacrifice", undead):
hero.cast("sacrifice", undead, hero)
for burl in burls:
if burl and hero.canCast("sacrifice", burl):
hero.cast("sacrifice", burl, hero)
if enemy:
if hero.canCast("devour", findStrongestEnemy()):
hero.cast("devour",findStrongestEnemy())
elif hero.canCast("poison-cloud", findStrongestEnemy()):
hero.cast("poison-cloud", findStrongestEnemy())
elif hero.canCast("chain-lightning", findStrongestEnemy()):
hero.cast("chain-lightning", findStrongestEnemy())
elif hero.canCast("drain-life", findStrongestEnemy()):
hero.cast("drain-life", findStrongestEnemy())
elif hero.canCast("fear", findStrongestEnemy()):
hero.cast("fear", findStrongestEnemy())
hero.attack(findStrongestEnemy())
if hero.isReady("summon-burl"):
hero.cast("summon-burl")
if hero.isReady("summon-undead"):
hero.cast("summon-undead")
for dead in hero.findCorpses():
if dead and hero.distanceTo(dead) < 20 and hero.canCast("raise-dead"):
hero.cast("raise-dead")
else:
if dead and hero.canCast("raise-dead"):
hero.move(dead.pos)
hero.cast("raise-dead")
peasants = hero.findByType("peasant")
for peasant in peasants:
if hero.gold >= 25 and enemy:
hero.command(peasant, "buildXY","decoy", peasant.pos.x, peasant.pos.y)
'''
# Your goal is to collect coins / gems.
# This level is repeatable. If you win, the difficulty and rewards will increase.
# If you fail, you have to wait a day to resubmit.
# This level is an optional challenge level. You don't need to beat it to continue the campaign!
'''
def collect():
peasants = hero.findByType("peasant")
for peasant in peasants:
if peasant and peasant.team == hero.team:
item = peasant.findNearestItem()
if item:
hero.command(peasant, "move", item.pos)
hero.cast("summon-burl")
hero.cast("summon-undead")
burl = hero.findByType("burl")[0]
hero.cast("sacrifice", burl, hero)
while True:
enemy = hero.findNearestEnemy()
burls = hero.findByType("burl")
undeads = hero.findByType("skeleton")
collect()
for burl in burls:
if burl and hero.canCast("sacrifice", burl):
hero.cast("sacrifice", burl, hero)
if enemy:
if hero.canCast("devour", enemy):
hero.cast("devour", enemy)
elif hero.canCast("poison-cloud", enemy):
hero.cast("poison-cloud", enemy)
elif hero.canCast("chain-lightning", enemy):
hero.cast("chain-lightning", enemy)
elif hero.canCast("drain-life", enemy):
hero.cast("drain-life", enemy)
elif hero.canCast("fear", enemy):
hero.cast("fear", enemy)
elif enemy.target == hero and hero.isReady("shape-shift"):
pet.shapeShift()
hero.attack(enemy)
if hero.isReady("summon-burl"):
hero.cast("summon-burl")
if hero.isReady("summon-undead"):
hero.cast("summon-undead")
'''
# Your goal is to collect coins / gems.
# This level is repeatable. If you win, the difficulty and rewards will increase.
# If you fail, you have to wait a day to resubmit.
# This level is an optional challenge level. You don't need to beat it to continue the campaign!
'''
def collect():
peasants = hero.findByType("peasant")
for peasant in peasants:
if peasant and peasant.team == hero.team:
item = peasant.findNearestItem()
if item:
hero.command(peasant, "move", item.pos)
hero.cast("summon-burl")
hero.cast("summon-undead")
burl = hero.findByType("burl")[0]
hero.cast("sacrifice", burl, hero)
while True:
enemy = hero.findNearestEnemy()
burls = hero.findByType("burl")
undeads = hero.findByType("skeleton")
collect()
for burl in burls:
if burl and hero.canCast("sacrifice", burl):
hero.cast("sacrifice", burl, hero)
if enemy:
if hero.canCast("devour", enemy):
hero.cast("devour", enemy)
elif hero.canCast("poison-cloud", enemy):
hero.cast("poison-cloud", enemy)
elif hero.canCast("chain-lightning", enemy):
hero.cast("chain-lightning", enemy)
elif hero.canCast("drain-life", enemy):
hero.cast("drain-life", enemy)
elif hero.canCast("fear", enemy):
hero.cast("fear", enemy)
elif enemy.target == hero and hero.isReady("shape-shift"):
pet.shapeShift()
hero.attack(enemy)
if hero.isReady("summon-burl"):
hero.cast("summon-burl")
if hero.isReady("summon-undead"):
hero.cast("summon-undead")
'''
'''
def findStrongestEnemy():
strongest = None
strongestHealth = 0
enemies = hero.findEnemies()
for enemy in enemies:
if enemy.health > strongestHealth:
strongestHealth = enemy.health
strongest = enemy
return strongest
def onSpawn():
while True:
pet.moveXY(76, 107)
pet.shapeShift()
def collect():
peasants = hero.findByType("peasant")
for peasant in peasants:
if peasant and peasant.team == hero.team:
item = peasant.findNearestItem()
if item:
hero.command(peasant, "move", item.pos)
hero.cast("summon-burl")
hero.cast("summon-undead")
burl = hero.findByType("burl")[0]
hero.cast("sacrifice", burl, hero)
pet.on("spawn", onSpawn)
while True:
enemy = hero.findNearestEnemy()
enemies = hero.findEnemies()
burls = hero.findByType("burl")
undeads = hero.findByType("skeleton")
collect()
for undead in undeads:
if undead and hero.canCast("sacrifice", undead):
hero.cast("sacrifice", undead, hero)
for burl in burls:
if burl and hero.canCast("sacrifice", burl):
hero.cast("sacrifice", burl, hero)
if enemy:
if hero.canCast("devour", findStrongestEnemy()):
hero.cast("devour",findStrongestEnemy())
elif hero.canCast("poison-cloud", findStrongestEnemy()):
hero.cast("poison-cloud", findStrongestEnemy())
elif hero.canCast("chain-lightning", findStrongestEnemy()):
hero.cast("chain-lightning", findStrongestEnemy())
elif hero.canCast("drain-life", findStrongestEnemy()):
hero.cast("drain-life", findStrongestEnemy())
elif hero.canCast("fear", findStrongestEnemy()):
hero.cast("fear", findStrongestEnemy())
hero.attack(findStrongestEnemy())
if hero.isReady("summon-burl"):
hero.cast("summon-burl")
if hero.isReady("summon-undead"):
hero.cast("summon-undead")
for dead in hero.findCorpses():
if dead and hero.distanceTo(dead) < 20 and hero.canCast("raise-dead"):
hero.cast("raise-dead")
else:
if dead and hero.canCast("raise-dead"):
hero.move(dead.pos)
hero.cast("raise-dead")
peasants = hero.findByType("peasant")
for peasant in peasants:
if hero.gold >= 25 and enemy:
hero.command(peasant, "buildXY","decoy", peasant.pos.x, peasant.pos.y)
'''
# Your goal is to collect coins / gems.
# This level is repeatable. If you win, the difficulty and rewards will increase.
# If you fail, you have to wait a day to resubmit.
# This level is an optional challenge level. You don't need to beat it to continue the campaign!
'''
def collect():
peasants = hero.findByType("peasant")
for peasant in peasants:
if peasant and peasant.team == hero.team:
item = peasant.findNearestItem()
if item:
hero.command(peasant, "move", item.pos)
hero.cast("summon-burl")
hero.cast("summon-undead")
burl = hero.findByType("burl")[0]
hero.cast("sacrifice", burl, hero)
while True:
enemy = hero.findNearestEnemy()
burls = hero.findByType("burl")
undeads = hero.findByType("skeleton")
collect()
for burl in burls:
if burl and hero.canCast("sacrifice", burl):
hero.cast("sacrifice", burl, hero)
if enemy:
if hero.canCast("devour", enemy):
hero.cast("devour", enemy)
elif hero.canCast("poison-cloud", enemy):
hero.cast("poison-cloud", enemy)
elif hero.canCast("chain-lightning", enemy):
hero.cast("chain-lightning", enemy)
elif hero.canCast("drain-life", enemy):
hero.cast("drain-life", enemy)
elif hero.canCast("fear", enemy):
hero.cast("fear", enemy)
elif enemy.target == hero and hero.isReady("shape-shift"):
pet.shapeShift()
hero.attack(enemy)
if hero.isReady("summon-burl"):
hero.cast("summon-burl")
if hero.isReady("summon-undead"):
hero.cast("summon-undead")
'''
def findStrongestEnemy():
strongest = None
strongestHealth = 0
enemies = hero.findEnemies()
for enemy in enemies:
if enemy.health > strongestHealth:
strongestHealth = enemy.health
strongest = enemy
return strongest
def onSpawn():
while True:
pet.moveXY(76, 107)
pet.shapeShift()
def collect():
peasants = hero.findByType("peasant")
for peasant in peasants:
if peasant and peasant.team == hero.team:
item = peasant.findNearestItem()
if item:
hero.command(peasant, "move", item.pos)
hero.cast("summon-burl")
hero.cast("summon-undead")
burl = hero.findByType("burl")[0]
hero.cast("sacrifice", burl, hero)
pet.on("spawn", onSpawn)
while True:
enemy = hero.findNearestEnemy()
enemies = hero.findEnemies()
burls = hero.findByType("burl")
undeads = hero.findByType("skeleton")
collect()
for undead in undeads:
if undead and hero.canCast("sacrifice", undead):
hero.cast("sacrifice", undead, hero)
for burl in burls:
if burl and hero.canCast("sacrifice", burl):
hero.cast("sacrifice", burl, hero)
if enemy:
if hero.canCast("devour", findStrongestEnemy()):
hero.cast("devour",findStrongestEnemy())
if hero.canCast("poison-cloud", findStrongestEnemy()):
hero.cast("poison-cloud", findStrongestEnemy())
if hero.canCast("chain-lightning", findStrongestEnemy()):
hero.cast("chain-lightning", findStrongestEnemy())
if hero.canCast("drain-life", findStrongestEnemy()):
hero.cast("drain-life", findStrongestEnemy())
if hero.canCast("fear", findStrongestEnemy()):
hero.cast("fear", findStrongestEnemy())
else:
hero.attack(findStrongestEnemy())
if hero.isReady("summon-burl"):
hero.cast("summon-burl")
if hero.isReady("summon-undead"):
hero.cast("summon-undead")
for dead in hero.findCorpses():
if dead and hero.distanceTo(dead) < 20 and hero.canCast("raise-dead"):
hero.cast("raise-dead")
else:
if dead and hero.canCast("raise-dead"):
hero.move(dead.pos)
hero.cast("raise-dead")
peasants = hero.findByType("peasant")
for peasant in peasants:
if (hero.gold >= 25 and enemy and enemy.target and enemy.target == hero) or (hero.gold >= 25 and enemy and enemy.target and enemy.target == peasant):
hero.command(peasant, "buildXY","decoy", peasant.pos.x, peasant.pos.y)
Is anybody there? pls help!!
Try to attack and cast on the nearest enemy, using the distance of your range and spells (so your hero won’t be moving and getting attacked while moving).
Try to command your peasant to find the best item (the best nearest item) so their moving will be more effective.
Also, delete the decoys code. It’s not effective because your peasants stop when build it, plus ogres don’t see the decoys.
# Your goal is to collect coins / gems.
# This level is repeatable. If you win, the difficulty and rewards will increase.
# If you fail, you have to wait a day to resubmit.
# This level is an optional challenge level. You don't need to beat it to continue the campaign!
'''
def collect():
peasants = hero.findByType("peasant")
for peasant in peasants:
if peasant and peasant.team == hero.team:
item = peasant.findNearestItem()
if item:
hero.command(peasant, "move", item.pos)
hero.cast("summon-burl")
hero.cast("summon-undead")
burl = hero.findByType("burl")[0]
hero.cast("sacrifice", burl, hero)
while True:
enemy = hero.findNearestEnemy()
burls = hero.findByType("burl")
undeads = hero.findByType("skeleton")
collect()
for burl in burls:
if burl and hero.canCast("sacrifice", burl):
hero.cast("sacrifice", burl, hero)
if enemy:
if hero.canCast("devour", enemy):
hero.cast("devour", enemy)
elif hero.canCast("poison-cloud", enemy):
hero.cast("poison-cloud", enemy)
elif hero.canCast("chain-lightning", enemy):
hero.cast("chain-lightning", enemy)
elif hero.canCast("drain-life", enemy):
hero.cast("drain-life", enemy)
elif hero.canCast("fear", enemy):
hero.cast("fear", enemy)
elif enemy.target == hero and hero.isReady("shape-shift"):
pet.shapeShift()
hero.attack(enemy)
if hero.isReady("summon-burl"):
hero.cast("summon-burl")
if hero.isReady("summon-undead"):
hero.cast("summon-undead")
'''
'''
def findStrongestEnemy():
strongest = None
strongestHealth = 0
enemies = hero.findEnemies()
for enemy in enemies:
if enemy.health > strongestHealth:
strongestHealth = enemy.health
strongest = enemy
return strongest
def onSpawn():
while True:
pet.moveXY(76, 107)
pet.shapeShift()
def collect():
peasants = hero.findByType("peasant")
for peasant in peasants:
if peasant and peasant.team == hero.team:
item = peasant.findNearestItem()
if item:
hero.command(peasant, "move", item.pos)
hero.cast("summon-burl")
hero.cast("summon-undead")
burl = hero.findByType("burl")[0]
hero.cast("sacrifice", burl, hero)
pet.on("spawn", onSpawn)
while True:
enemy = hero.findNearestEnemy()
enemies = hero.findEnemies()
burls = hero.findByType("burl")
undeads = hero.findByType("skeleton")
collect()
for undead in undeads:
if undead and hero.canCast("sacrifice", undead):
hero.cast("sacrifice", undead, hero)
for burl in burls:
if burl and hero.canCast("sacrifice", burl):
hero.cast("sacrifice", burl, hero)
if enemy:
if hero.canCast("devour", findStrongestEnemy()):
hero.cast("devour",findStrongestEnemy())
elif hero.canCast("poison-cloud", findStrongestEnemy()):
hero.cast("poison-cloud", findStrongestEnemy())
elif hero.canCast("chain-lightning", findStrongestEnemy()):
hero.cast("chain-lightning", findStrongestEnemy())
elif hero.canCast("drain-life", findStrongestEnemy()):
hero.cast("drain-life", findStrongestEnemy())
elif hero.canCast("fear", findStrongestEnemy()):
hero.cast("fear", findStrongestEnemy())
hero.attack(findStrongestEnemy())
if hero.isReady("summon-burl"):
hero.cast("summon-burl")
if hero.isReady("summon-undead"):
hero.cast("summon-undead")
for dead in hero.findCorpses():
if dead and hero.distanceTo(dead) < 20 and hero.canCast("raise-dead"):
hero.cast("raise-dead")
else:
if dead and hero.canCast("raise-dead"):
hero.move(dead.pos)
hero.cast("raise-dead")
peasants = hero.findByType("peasant")
for peasant in peasants:
if hero.gold >= 25 and enemy:
hero.command(peasant, "buildXY","decoy", peasant.pos.x, peasant.pos.y)
'''
# Your goal is to collect coins / gems.
# This level is repeatable. If you win, the difficulty and rewards will increase.
# If you fail, you have to wait a day to resubmit.
# This level is an optional challenge level. You don't need to beat it to continue the campaign!
'''
def collect():
peasants = hero.findByType("peasant")
for peasant in peasants:
if peasant and peasant.team == hero.team:
item = peasant.findNearestItem()
if item:
hero.command(peasant, "move", item.pos)
hero.cast("summon-burl")
hero.cast("summon-undead")
burl = hero.findByType("burl")[0]
hero.cast("sacrifice", burl, hero)
while True:
enemy = hero.findNearestEnemy()
burls = hero.findByType("burl")
undeads = hero.findByType("skeleton")
collect()
for burl in burls:
if burl and hero.canCast("sacrifice", burl):
hero.cast("sacrifice", burl, hero)
if enemy:
if hero.canCast("devour", enemy):
hero.cast("devour", enemy)
elif hero.canCast("poison-cloud", enemy):
hero.cast("poison-cloud", enemy)
elif hero.canCast("chain-lightning", enemy):
hero.cast("chain-lightning", enemy)
elif hero.canCast("drain-life", enemy):
hero.cast("drain-life", enemy)
elif hero.canCast("fear", enemy):
hero.cast("fear", enemy)
elif enemy.target == hero and hero.isReady("shape-shift"):
pet.shapeShift()
hero.attack(enemy)
if hero.isReady("summon-burl"):
hero.cast("summon-burl")
if hero.isReady("summon-undead"):
hero.cast("summon-undead")
'''
# Your goal is to collect coins / gems.
# This level is repeatable. If you win, the difficulty and rewards will increase.
# If you fail, you have to wait a day to resubmit.
# This level is an optional challenge level. You don't need to beat it to continue the campaign!
'''
def collect():
peasants = hero.findByType("peasant")
for peasant in peasants:
if peasant and peasant.team == hero.team:
item = peasant.findNearestItem()
if item:
hero.command(peasant, "move", item.pos)
hero.cast("summon-burl")
hero.cast("summon-undead")
burl = hero.findByType("burl")[0]
hero.cast("sacrifice", burl, hero)
while True:
enemy = hero.findNearestEnemy()
burls = hero.findByType("burl")
undeads = hero.findByType("skeleton")
collect()
for burl in burls:
if burl and hero.canCast("sacrifice", burl):
hero.cast("sacrifice", burl, hero)
if enemy:
if hero.canCast("devour", enemy):
hero.cast("devour", enemy)
elif hero.canCast("poison-cloud", enemy):
hero.cast("poison-cloud", enemy)
elif hero.canCast("chain-lightning", enemy):
hero.cast("chain-lightning", enemy)
elif hero.canCast("drain-life", enemy):
hero.cast("drain-life", enemy)
elif hero.canCast("fear", enemy):
hero.cast("fear", enemy)
elif enemy.target == hero and hero.isReady("shape-shift"):
pet.shapeShift()
hero.attack(enemy)
if hero.isReady("summon-burl"):
hero.cast("summon-burl")
if hero.isReady("summon-undead"):
hero.cast("summon-undead")
'''
'''
def findStrongestEnemy():
strongest = None
strongestHealth = 0
enemies = hero.findEnemies()
for enemy in enemies:
if enemy.health > strongestHealth:
strongestHealth = enemy.health
strongest = enemy
return strongest
def onSpawn():
while True:
pet.moveXY(76, 107)
pet.shapeShift()
def collect():
peasants = hero.findByType("peasant")
for peasant in peasants:
if peasant and peasant.team == hero.team:
item = peasant.findNearestItem()
if item:
hero.command(peasant, "move", item.pos)
hero.cast("summon-burl")
hero.cast("summon-undead")
burl = hero.findByType("burl")[0]
hero.cast("sacrifice", burl, hero)
pet.on("spawn", onSpawn)
while True:
enemy = hero.findNearestEnemy()
enemies = hero.findEnemies()
burls = hero.findByType("burl")
undeads = hero.findByType("skeleton")
collect()
for undead in undeads:
if undead and hero.canCast("sacrifice", undead):
hero.cast("sacrifice", undead, hero)
for burl in burls:
if burl and hero.canCast("sacrifice", burl):
hero.cast("sacrifice", burl, hero)
if enemy:
if hero.canCast("devour", findStrongestEnemy()):
hero.cast("devour",findStrongestEnemy())
elif hero.canCast("poison-cloud", findStrongestEnemy()):
hero.cast("poison-cloud", findStrongestEnemy())
elif hero.canCast("chain-lightning", findStrongestEnemy()):
hero.cast("chain-lightning", findStrongestEnemy())
elif hero.canCast("drain-life", findStrongestEnemy()):
hero.cast("drain-life", findStrongestEnemy())
elif hero.canCast("fear", findStrongestEnemy()):
hero.cast("fear", findStrongestEnemy())
hero.attack(findStrongestEnemy())
if hero.isReady("summon-burl"):
hero.cast("summon-burl")
if hero.isReady("summon-undead"):
hero.cast("summon-undead")
for dead in hero.findCorpses():
if dead and hero.distanceTo(dead) < 20 and hero.canCast("raise-dead"):
hero.cast("raise-dead")
else:
if dead and hero.canCast("raise-dead"):
hero.move(dead.pos)
hero.cast("raise-dead")
peasants = hero.findByType("peasant")
for peasant in peasants:
if hero.gold >= 25 and enemy:
hero.command(peasant, "buildXY","decoy", peasant.pos.x, peasant.pos.y)
'''
# Your goal is to collect coins / gems.
# This level is repeatable. If you win, the difficulty and rewards will increase.
# If you fail, you have to wait a day to resubmit.
# This level is an optional challenge level. You don't need to beat it to continue the campaign!
'''
def collect():
peasants = hero.findByType("peasant")
for peasant in peasants:
if peasant and peasant.team == hero.team:
item = peasant.findNearestItem()
if item:
hero.command(peasant, "move", item.pos)
hero.cast("summon-burl")
hero.cast("summon-undead")
burl = hero.findByType("burl")[0]
hero.cast("sacrifice", burl, hero)
while True:
enemy = hero.findNearestEnemy()
burls = hero.findByType("burl")
undeads = hero.findByType("skeleton")
collect()
for burl in burls:
if burl and hero.canCast("sacrifice", burl):
hero.cast("sacrifice", burl, hero)
if enemy:
if hero.canCast("devour", enemy):
hero.cast("devour", enemy)
elif hero.canCast("poison-cloud", enemy):
hero.cast("poison-cloud", enemy)
elif hero.canCast("chain-lightning", enemy):
hero.cast("chain-lightning", enemy)
elif hero.canCast("drain-life", enemy):
hero.cast("drain-life", enemy)
elif hero.canCast("fear", enemy):
hero.cast("fear", enemy)
elif enemy.target == hero and hero.isReady("shape-shift"):
pet.shapeShift()
hero.attack(enemy)
if hero.isReady("summon-burl"):
hero.cast("summon-burl")
if hero.isReady("summon-undead"):
hero.cast("summon-undead")
'''
def findStrongestEnemy():
strongest = None
strongestHealth = 0
enemies = hero.findEnemies()
for enemy in enemies:
if enemy.health > strongestHealth:
strongestHealth = enemy.health
strongest = enemy
return strongest
def collectCoins():
pass
def onSpawn():
while True:
pet.moveXY(76, 107)
pet.shapeShift()
def collect():
peasants = hero.findByType("peasant")
items = hero.findItems()
far = None
farDist = 0
maxValue = 0
bestItem = None
for item in items:
d = hero.distanceTo(item)
if item.value > farDist:
far = item.pos
farDist = item.value
if item.value / d > maxValue:
maxValue = item.value / d
bestItem = item
if bestItem:
for peasant in peasants:
if peasant and peasant.team == hero.team:
hero.command(peasant, "move", bestItem.pos)
hero.cast("summon-burl")
hero.cast("summon-undead")
burl = hero.findByType("burl")[0]
hero.cast("sacrifice", burl, hero)
pet.on("spawn", onSpawn)
while True:
enemy = hero.findNearestEnemy()
enemies = hero.findEnemies()
burls = hero.findByType("burl")
undeads = hero.findByType("skeleton")
collect()
for burl in burls:
if burl and hero.canCast("sacrifice", burl):
hero.cast("sacrifice", burl, hero)
if enemy:
if hero.canCast("devour", enemy):
hero.cast("devour",enemy)
if hero.canCast("poison-cloud", findStrongestEnemy()):
hero.cast("poison-cloud", enemy)
if hero.canCast("chain-lightning", findStrongestEnemy()):
hero.cast("chain-lightning", enemy)
if hero.canCast("drain-life", findStrongestEnemy()):
hero.cast("drain-life", enemy)
if hero.canCast("fear", findStrongestEnemy()):
hero.cast("fear", enemy)
else:
hero.attack(enemy)
if hero.isReady("summon-burl"):
hero.cast("summon-burl")
if hero.isReady("summon-undead"):
hero.cast("summon-undead")
for dead in hero.findCorpses():
if dead and hero.distanceTo(dead) < 20 and hero.canCast("raise-dead"):
hero.cast("raise-dead")
else:
if dead and hero.canCast("raise-dead"):
hero.move(dead.pos)
hero.cast("raise-dead")
It says ‘Ran out of time’
Well, at least your hero doesn’t die.
Nothing, they just revive it and it goes to the enemy position since it has not attack.
Well, I just change my code a little bit :
# Your goal is to collect coins / gems.
# This level is repeatable. If you win, the difficulty and rewards will increase.
# If you fail, you have to wait a day to resubmit.
# This level is an optional challenge level. You don't need to beat it to continue the campaign!
'''
def collect():
peasants = hero.findByType("peasant")
for peasant in peasants:
if peasant and peasant.team == hero.team:
item = peasant.findNearestItem()
if item:
hero.command(peasant, "move", item.pos)
hero.cast("summon-burl")
hero.cast("summon-undead")
burl = hero.findByType("burl")[0]
hero.cast("sacrifice", burl, hero)
while True:
enemy = hero.findNearestEnemy()
burls = hero.findByType("burl")
undeads = hero.findByType("skeleton")
collect()
for burl in burls:
if burl and hero.canCast("sacrifice", burl):
hero.cast("sacrifice", burl, hero)
if enemy:
if hero.canCast("devour", enemy):
hero.cast("devour", enemy)
elif hero.canCast("poison-cloud", enemy):
hero.cast("poison-cloud", enemy)
elif hero.canCast("chain-lightning", enemy):
hero.cast("chain-lightning", enemy)
elif hero.canCast("drain-life", enemy):
hero.cast("drain-life", enemy)
elif hero.canCast("fear", enemy):
hero.cast("fear", enemy)
elif enemy.target == hero and hero.isReady("shape-shift"):
pet.shapeShift()
hero.attack(enemy)
if hero.isReady("summon-burl"):
hero.cast("summon-burl")
if hero.isReady("summon-undead"):
hero.cast("summon-undead")
'''
'''
def findStrongestEnemy():
strongest = None
strongestHealth = 0
enemies = hero.findEnemies()
for enemy in enemies:
if enemy.health > strongestHealth:
strongestHealth = enemy.health
strongest = enemy
return strongest
def onSpawn():
while True:
pet.moveXY(76, 107)
pet.shapeShift()
def collect():
peasants = hero.findByType("peasant")
for peasant in peasants:
if peasant and peasant.team == hero.team:
item = peasant.findNearestItem()
if item:
hero.command(peasant, "move", item.pos)
hero.cast("summon-burl")
hero.cast("summon-undead")
burl = hero.findByType("burl")[0]
hero.cast("sacrifice", burl, hero)
pet.on("spawn", onSpawn)
while True:
enemy = hero.findNearestEnemy()
enemies = hero.findEnemies()
burls = hero.findByType("burl")
undeads = hero.findByType("skeleton")
collect()
for undead in undeads:
if undead and hero.canCast("sacrifice", undead):
hero.cast("sacrifice", undead, hero)
for burl in burls:
if burl and hero.canCast("sacrifice", burl):
hero.cast("sacrifice", burl, hero)
if enemy:
if hero.canCast("devour", findStrongestEnemy()):
hero.cast("devour",findStrongestEnemy())
elif hero.canCast("poison-cloud", findStrongestEnemy()):
hero.cast("poison-cloud", findStrongestEnemy())
elif hero.canCast("chain-lightning", findStrongestEnemy()):
hero.cast("chain-lightning", findStrongestEnemy())
elif hero.canCast("drain-life", findStrongestEnemy()):
hero.cast("drain-life", findStrongestEnemy())
elif hero.canCast("fear", findStrongestEnemy()):
hero.cast("fear", findStrongestEnemy())
hero.attack(findStrongestEnemy())
if hero.isReady("summon-burl"):
hero.cast("summon-burl")
if hero.isReady("summon-undead"):
hero.cast("summon-undead")
for dead in hero.findCorpses():
if dead and hero.distanceTo(dead) < 20 and hero.canCast("raise-dead"):
hero.cast("raise-dead")
else:
if dead and hero.canCast("raise-dead"):
hero.move(dead.pos)
hero.cast("raise-dead")
peasants = hero.findByType("peasant")
for peasant in peasants:
if hero.gold >= 25 and enemy:
hero.command(peasant, "buildXY","decoy", peasant.pos.x, peasant.pos.y)
'''
# Your goal is to collect coins / gems.
# This level is repeatable. If you win, the difficulty and rewards will increase.
# If you fail, you have to wait a day to resubmit.
# This level is an optional challenge level. You don't need to beat it to continue the campaign!
'''
def collect():
peasants = hero.findByType("peasant")
for peasant in peasants:
if peasant and peasant.team == hero.team:
item = peasant.findNearestItem()
if item:
hero.command(peasant, "move", item.pos)
hero.cast("summon-burl")
hero.cast("summon-undead")
burl = hero.findByType("burl")[0]
hero.cast("sacrifice", burl, hero)
while True:
enemy = hero.findNearestEnemy()
burls = hero.findByType("burl")
undeads = hero.findByType("skeleton")
collect()
for burl in burls:
if burl and hero.canCast("sacrifice", burl):
hero.cast("sacrifice", burl, hero)
if enemy:
if hero.canCast("devour", enemy):
hero.cast("devour", enemy)
elif hero.canCast("poison-cloud", enemy):
hero.cast("poison-cloud", enemy)
elif hero.canCast("chain-lightning", enemy):
hero.cast("chain-lightning", enemy)
elif hero.canCast("drain-life", enemy):
hero.cast("drain-life", enemy)
elif hero.canCast("fear", enemy):
hero.cast("fear", enemy)
elif enemy.target == hero and hero.isReady("shape-shift"):
pet.shapeShift()
hero.attack(enemy)
if hero.isReady("summon-burl"):
hero.cast("summon-burl")
if hero.isReady("summon-undead"):
hero.cast("summon-undead")
'''
# Your goal is to collect coins / gems.
# This level is repeatable. If you win, the difficulty and rewards will increase.
# If you fail, you have to wait a day to resubmit.
# This level is an optional challenge level. You don't need to beat it to continue the campaign!
'''
def collect():
peasants = hero.findByType("peasant")
for peasant in peasants:
if peasant and peasant.team == hero.team:
item = peasant.findNearestItem()
if item:
hero.command(peasant, "move", item.pos)
hero.cast("summon-burl")
hero.cast("summon-undead")
burl = hero.findByType("burl")[0]
hero.cast("sacrifice", burl, hero)
while True:
enemy = hero.findNearestEnemy()
burls = hero.findByType("burl")
undeads = hero.findByType("skeleton")
collect()
for burl in burls:
if burl and hero.canCast("sacrifice", burl):
hero.cast("sacrifice", burl, hero)
if enemy:
if hero.canCast("devour", enemy):
hero.cast("devour", enemy)
elif hero.canCast("poison-cloud", enemy):
hero.cast("poison-cloud", enemy)
elif hero.canCast("chain-lightning", enemy):
hero.cast("chain-lightning", enemy)
elif hero.canCast("drain-life", enemy):
hero.cast("drain-life", enemy)
elif hero.canCast("fear", enemy):
hero.cast("fear", enemy)
elif enemy.target == hero and hero.isReady("shape-shift"):
pet.shapeShift()
hero.attack(enemy)
if hero.isReady("summon-burl"):
hero.cast("summon-burl")
if hero.isReady("summon-undead"):
hero.cast("summon-undead")
'''
'''
def findStrongestEnemy():
strongest = None
strongestHealth = 0
enemies = hero.findEnemies()
for enemy in enemies:
if enemy.health > strongestHealth:
strongestHealth = enemy.health
strongest = enemy
return strongest
def onSpawn():
while True:
pet.moveXY(76, 107)
pet.shapeShift()
def collect():
peasants = hero.findByType("peasant")
for peasant in peasants:
if peasant and peasant.team == hero.team:
item = peasant.findNearestItem()
if item:
hero.command(peasant, "move", item.pos)
hero.cast("summon-burl")
hero.cast("summon-undead")
burl = hero.findByType("burl")[0]
hero.cast("sacrifice", burl, hero)
pet.on("spawn", onSpawn)
while True:
enemy = hero.findNearestEnemy()
enemies = hero.findEnemies()
burls = hero.findByType("burl")
undeads = hero.findByType("skeleton")
collect()
for undead in undeads:
if undead and hero.canCast("sacrifice", undead):
hero.cast("sacrifice", undead, hero)
for burl in burls:
if burl and hero.canCast("sacrifice", burl):
hero.cast("sacrifice", burl, hero)
if enemy:
if hero.canCast("devour", findStrongestEnemy()):
hero.cast("devour",findStrongestEnemy())
elif hero.canCast("poison-cloud", findStrongestEnemy()):
hero.cast("poison-cloud", findStrongestEnemy())
elif hero.canCast("chain-lightning", findStrongestEnemy()):
hero.cast("chain-lightning", findStrongestEnemy())
elif hero.canCast("drain-life", findStrongestEnemy()):
hero.cast("drain-life", findStrongestEnemy())
elif hero.canCast("fear", findStrongestEnemy()):
hero.cast("fear", findStrongestEnemy())
hero.attack(findStrongestEnemy())
if hero.isReady("summon-burl"):
hero.cast("summon-burl")
if hero.isReady("summon-undead"):
hero.cast("summon-undead")
for dead in hero.findCorpses():
if dead and hero.distanceTo(dead) < 20 and hero.canCast("raise-dead"):
hero.cast("raise-dead")
else:
if dead and hero.canCast("raise-dead"):
hero.move(dead.pos)
hero.cast("raise-dead")
peasants = hero.findByType("peasant")
for peasant in peasants:
if hero.gold >= 25 and enemy:
hero.command(peasant, "buildXY","decoy", peasant.pos.x, peasant.pos.y)
'''
# Your goal is to collect coins / gems.
# This level is repeatable. If you win, the difficulty and rewards will increase.
# If you fail, you have to wait a day to resubmit.
# This level is an optional challenge level. You don't need to beat it to continue the campaign!
'''
def collect():
peasants = hero.findByType("peasant")
for peasant in peasants:
if peasant and peasant.team == hero.team:
item = peasant.findNearestItem()
if item:
hero.command(peasant, "move", item.pos)
hero.cast("summon-burl")
hero.cast("summon-undead")
burl = hero.findByType("burl")[0]
hero.cast("sacrifice", burl, hero)
while True:
enemy = hero.findNearestEnemy()
burls = hero.findByType("burl")
undeads = hero.findByType("skeleton")
collect()
for burl in burls:
if burl and hero.canCast("sacrifice", burl):
hero.cast("sacrifice", burl, hero)
if enemy:
if hero.canCast("devour", enemy):
hero.cast("devour", enemy)
elif hero.canCast("poison-cloud", enemy):
hero.cast("poison-cloud", enemy)
elif hero.canCast("chain-lightning", enemy):
hero.cast("chain-lightning", enemy)
elif hero.canCast("drain-life", enemy):
hero.cast("drain-life", enemy)
elif hero.canCast("fear", enemy):
hero.cast("fear", enemy)
elif enemy.target == hero and hero.isReady("shape-shift"):
pet.shapeShift()
hero.attack(enemy)
if hero.isReady("summon-burl"):
hero.cast("summon-burl")
if hero.isReady("summon-undead"):
hero.cast("summon-undead")
'''
def findStrongestEnemy():
strongest = None
strongestHealth = 0
enemies = hero.findEnemies()
for enemy in enemies:
if enemy.health > strongestHealth:
strongestHealth = enemy.health
strongest = enemy
return strongest
def collectCoins():
pass
def onSpawn():
while True:
pet.moveXY(76, 107)
pet.shapeShift()
def collect():
peasants = hero.findByType("peasant")
items = hero.findItems()
far = None
farDist = 0
maxValue = 0
bestItem = None
for item in items:
d = hero.distanceTo(item)
if item.value > farDist:
far = item.pos
farDist = item.value
if item.value / d > maxValue:
maxValue = item.value / d
bestItem = item
if bestItem:
for peasant in peasants:
if peasant and peasant.team == hero.team:
hero.command(peasant, "move", bestItem.pos)
else:
item = peasant.findNearestItem()
if item:
hero.command(peasant, "move", item.pos)
hero.cast("summon-burl")
hero.cast("summon-undead")
burl = hero.findByType("burl")[0]
hero.cast("sacrifice", burl, hero)
pet.on("spawn", onSpawn)
while True:
enemy = hero.findNearestEnemy()
enemies = hero.findEnemies()
burls = hero.findByType("burl")
undeads = hero.findByType("skeleton")
collect()
for burl in burls:
if burl and hero.canCast("sacrifice", burl):
hero.cast("sacrifice", burl, hero)
if enemy:
if hero.canCast("devour", enemy):
hero.cast("devour",enemy)
if hero.canCast("poison-cloud", findStrongestEnemy()):
hero.cast("poison-cloud", enemy)
if hero.canCast("chain-lightning", findStrongestEnemy()):
hero.cast("chain-lightning", enemy)
if hero.canCast("drain-life", findStrongestEnemy()):
hero.cast("drain-life", enemy)
if hero.canCast("fear", findStrongestEnemy()):
hero.cast("fear", enemy)
else:
hero.attack(enemy)
if hero.isReady("summon-burl"):
hero.cast("summon-burl")
if hero.isReady("summon-undead"):
hero.cast("summon-undead")
for dead in hero.findCorpses():
if dead and hero.distanceTo(dead) < 20 and hero.canCast("raise-dead"):
hero.cast("raise-dead")
else:
if dead and hero.canCast("raise-dead"):
hero.move(dead.pos)
hero.cast("raise-dead")
It says ‘Ran out of time’ again
Hello, is anybody there??
Yes, don’t worry, we are always here. I just don’t know what to do else if your peasants can’t get the 256 coins. Maybe, you should change something in their commands, but what? I don’t know.
By the way, it should be peasant’s distance to the item.
# Your goal is to collect coins / gems.
# This level is repeatable. If you win, the difficulty and rewards will increase.
# If you fail, you have to wait a day to resubmit.
# This level is an optional challenge level. You don't need to beat it to continue the campaign!
'''
def collect():
peasants = hero.findByType("peasant")
for peasant in peasants:
if peasant and peasant.team == hero.team:
item = peasant.findNearestItem()
if item:
hero.command(peasant, "move", item.pos)
hero.cast("summon-burl")
hero.cast("summon-undead")
burl = hero.findByType("burl")[0]
hero.cast("sacrifice", burl, hero)
while True:
enemy = hero.findNearestEnemy()
burls = hero.findByType("burl")
undeads = hero.findByType("skeleton")
collect()
for burl in burls:
if burl and hero.canCast("sacrifice", burl):
hero.cast("sacrifice", burl, hero)
if enemy:
if hero.canCast("devour", enemy):
hero.cast("devour", enemy)
elif hero.canCast("poison-cloud", enemy):
hero.cast("poison-cloud", enemy)
elif hero.canCast("chain-lightning", enemy):
hero.cast("chain-lightning", enemy)
elif hero.canCast("drain-life", enemy):
hero.cast("drain-life", enemy)
elif hero.canCast("fear", enemy):
hero.cast("fear", enemy)
elif enemy.target == hero and hero.isReady("shape-shift"):
pet.shapeShift()
hero.attack(enemy)
if hero.isReady("summon-burl"):
hero.cast("summon-burl")
if hero.isReady("summon-undead"):
hero.cast("summon-undead")
'''
'''
def findStrongestEnemy():
strongest = None
strongestHealth = 0
enemies = hero.findEnemies()
for enemy in enemies:
if enemy.health > strongestHealth:
strongestHealth = enemy.health
strongest = enemy
return strongest
def onSpawn():
while True:
pet.moveXY(76, 107)
pet.shapeShift()
def collect():
peasants = hero.findByType("peasant")
for peasant in peasants:
if peasant and peasant.team == hero.team:
item = peasant.findNearestItem()
if item:
hero.command(peasant, "move", item.pos)
hero.cast("summon-burl")
hero.cast("summon-undead")
burl = hero.findByType("burl")[0]
hero.cast("sacrifice", burl, hero)
pet.on("spawn", onSpawn)
while True:
enemy = hero.findNearestEnemy()
enemies = hero.findEnemies()
burls = hero.findByType("burl")
undeads = hero.findByType("skeleton")
collect()
for undead in undeads:
if undead and hero.canCast("sacrifice", undead):
hero.cast("sacrifice", undead, hero)
for burl in burls:
if burl and hero.canCast("sacrifice", burl):
hero.cast("sacrifice", burl, hero)
if enemy:
if hero.canCast("devour", findStrongestEnemy()):
hero.cast("devour",findStrongestEnemy())
elif hero.canCast("poison-cloud", findStrongestEnemy()):
hero.cast("poison-cloud", findStrongestEnemy())
elif hero.canCast("chain-lightning", findStrongestEnemy()):
hero.cast("chain-lightning", findStrongestEnemy())
elif hero.canCast("drain-life", findStrongestEnemy()):
hero.cast("drain-life", findStrongestEnemy())
elif hero.canCast("fear", findStrongestEnemy()):
hero.cast("fear", findStrongestEnemy())
hero.attack(findStrongestEnemy())
if hero.isReady("summon-burl"):
hero.cast("summon-burl")
if hero.isReady("summon-undead"):
hero.cast("summon-undead")
for dead in hero.findCorpses():
if dead and hero.distanceTo(dead) < 20 and hero.canCast("raise-dead"):
hero.cast("raise-dead")
else:
if dead and hero.canCast("raise-dead"):
hero.move(dead.pos)
hero.cast("raise-dead")
peasants = hero.findByType("peasant")
for peasant in peasants:
if hero.gold >= 25 and enemy:
hero.command(peasant, "buildXY","decoy", peasant.pos.x, peasant.pos.y)
'''
# Your goal is to collect coins / gems.
# This level is repeatable. If you win, the difficulty and rewards will increase.
# If you fail, you have to wait a day to resubmit.
# This level is an optional challenge level. You don't need to beat it to continue the campaign!
'''
def collect():
peasants = hero.findByType("peasant")
for peasant in peasants:
if peasant and peasant.team == hero.team:
item = peasant.findNearestItem()
if item:
hero.command(peasant, "move", item.pos)
hero.cast("summon-burl")
hero.cast("summon-undead")
burl = hero.findByType("burl")[0]
hero.cast("sacrifice", burl, hero)
while True:
enemy = hero.findNearestEnemy()
burls = hero.findByType("burl")
undeads = hero.findByType("skeleton")
collect()
for burl in burls:
if burl and hero.canCast("sacrifice", burl):
hero.cast("sacrifice", burl, hero)
if enemy:
if hero.canCast("devour", enemy):
hero.cast("devour", enemy)
elif hero.canCast("poison-cloud", enemy):
hero.cast("poison-cloud", enemy)
elif hero.canCast("chain-lightning", enemy):
hero.cast("chain-lightning", enemy)
elif hero.canCast("drain-life", enemy):
hero.cast("drain-life", enemy)
elif hero.canCast("fear", enemy):
hero.cast("fear", enemy)
elif enemy.target == hero and hero.isReady("shape-shift"):
pet.shapeShift()
hero.attack(enemy)
if hero.isReady("summon-burl"):
hero.cast("summon-burl")
if hero.isReady("summon-undead"):
hero.cast("summon-undead")
'''
# Your goal is to collect coins / gems.
# This level is repeatable. If you win, the difficulty and rewards will increase.
# If you fail, you have to wait a day to resubmit.
# This level is an optional challenge level. You don't need to beat it to continue the campaign!
'''
def collect():
peasants = hero.findByType("peasant")
for peasant in peasants:
if peasant and peasant.team == hero.team:
item = peasant.findNearestItem()
if item:
hero.command(peasant, "move", item.pos)
hero.cast("summon-burl")
hero.cast("summon-undead")
burl = hero.findByType("burl")[0]
hero.cast("sacrifice", burl, hero)
while True:
enemy = hero.findNearestEnemy()
burls = hero.findByType("burl")
undeads = hero.findByType("skeleton")
collect()
for burl in burls:
if burl and hero.canCast("sacrifice", burl):
hero.cast("sacrifice", burl, hero)
if enemy:
if hero.canCast("devour", enemy):
hero.cast("devour", enemy)
elif hero.canCast("poison-cloud", enemy):
hero.cast("poison-cloud", enemy)
elif hero.canCast("chain-lightning", enemy):
hero.cast("chain-lightning", enemy)
elif hero.canCast("drain-life", enemy):
hero.cast("drain-life", enemy)
elif hero.canCast("fear", enemy):
hero.cast("fear", enemy)
elif enemy.target == hero and hero.isReady("shape-shift"):
pet.shapeShift()
hero.attack(enemy)
if hero.isReady("summon-burl"):
hero.cast("summon-burl")
if hero.isReady("summon-undead"):
hero.cast("summon-undead")
'''
'''
def findStrongestEnemy():
strongest = None
strongestHealth = 0
enemies = hero.findEnemies()
for enemy in enemies:
if enemy.health > strongestHealth:
strongestHealth = enemy.health
strongest = enemy
return strongest
def onSpawn():
while True:
pet.moveXY(76, 107)
pet.shapeShift()
def collect():
peasants = hero.findByType("peasant")
for peasant in peasants:
if peasant and peasant.team == hero.team:
item = peasant.findNearestItem()
if item:
hero.command(peasant, "move", item.pos)
hero.cast("summon-burl")
hero.cast("summon-undead")
burl = hero.findByType("burl")[0]
hero.cast("sacrifice", burl, hero)
pet.on("spawn", onSpawn)
while True:
enemy = hero.findNearestEnemy()
enemies = hero.findEnemies()
burls = hero.findByType("burl")
undeads = hero.findByType("skeleton")
collect()
for undead in undeads:
if undead and hero.canCast("sacrifice", undead):
hero.cast("sacrifice", undead, hero)
for burl in burls:
if burl and hero.canCast("sacrifice", burl):
hero.cast("sacrifice", burl, hero)
if enemy:
if hero.canCast("devour", findStrongestEnemy()):
hero.cast("devour",findStrongestEnemy())
elif hero.canCast("poison-cloud", findStrongestEnemy()):
hero.cast("poison-cloud", findStrongestEnemy())
elif hero.canCast("chain-lightning", findStrongestEnemy()):
hero.cast("chain-lightning", findStrongestEnemy())
elif hero.canCast("drain-life", findStrongestEnemy()):
hero.cast("drain-life", findStrongestEnemy())
elif hero.canCast("fear", findStrongestEnemy()):
hero.cast("fear", findStrongestEnemy())
hero.attack(findStrongestEnemy())
if hero.isReady("summon-burl"):
hero.cast("summon-burl")
if hero.isReady("summon-undead"):
hero.cast("summon-undead")
for dead in hero.findCorpses():
if dead and hero.distanceTo(dead) < 20 and hero.canCast("raise-dead"):
hero.cast("raise-dead")
else:
if dead and hero.canCast("raise-dead"):
hero.move(dead.pos)
hero.cast("raise-dead")
peasants = hero.findByType("peasant")
for peasant in peasants:
if hero.gold >= 25 and enemy:
hero.command(peasant, "buildXY","decoy", peasant.pos.x, peasant.pos.y)
'''
# Your goal is to collect coins / gems.
# This level is repeatable. If you win, the difficulty and rewards will increase.
# If you fail, you have to wait a day to resubmit.
# This level is an optional challenge level. You don't need to beat it to continue the campaign!
'''
def collect():
peasants = hero.findByType("peasant")
for peasant in peasants:
if peasant and peasant.team == hero.team:
item = peasant.findNearestItem()
if item:
hero.command(peasant, "move", item.pos)
hero.cast("summon-burl")
hero.cast("summon-undead")
burl = hero.findByType("burl")[0]
hero.cast("sacrifice", burl, hero)
while True:
enemy = hero.findNearestEnemy()
burls = hero.findByType("burl")
undeads = hero.findByType("skeleton")
collect()
for burl in burls:
if burl and hero.canCast("sacrifice", burl):
hero.cast("sacrifice", burl, hero)
if enemy:
if hero.canCast("devour", enemy):
hero.cast("devour", enemy)
elif hero.canCast("poison-cloud", enemy):
hero.cast("poison-cloud", enemy)
elif hero.canCast("chain-lightning", enemy):
hero.cast("chain-lightning", enemy)
elif hero.canCast("drain-life", enemy):
hero.cast("drain-life", enemy)
elif hero.canCast("fear", enemy):
hero.cast("fear", enemy)
elif enemy.target == hero and hero.isReady("shape-shift"):
pet.shapeShift()
hero.attack(enemy)
if hero.isReady("summon-burl"):
hero.cast("summon-burl")
if hero.isReady("summon-undead"):
hero.cast("summon-undead")
'''
def findStrongestEnemy():
strongest = None
strongestHealth = 0
enemies = hero.findEnemies()
for enemy in enemies:
if enemy.health > strongestHealth:
strongestHealth = enemy.health
strongest = enemy
return strongest
def collectCoins():
pass
def onSpawn():
while True:
pet.moveXY(76, 107)
pet.shapeShift()
def collect():
peasants = hero.findByType("peasant")
items = hero.findItems()
far = None
farDist = 0
maxValue = 0
bestItem = None
for item in items:
for peasant in peasants:
d = peasant.distanceTo(item)
if item.value > farDist:
far = item.pos
farDist = item.value
if item.value / d > maxValue:
maxValue = item.value / d
bestItem = item
if bestItem:
for peasant in peasants:
if peasant and peasant.team == hero.team:
hero.command(peasant, "move", bestItem.pos)
else:
item = peasant.findNearestItem()
if item:
hero.command(peasant, "move", item.pos)
hero.cast("summon-burl")
hero.cast("summon-undead")
burl = hero.findByType("burl")[0]
hero.cast("sacrifice", burl, hero)
pet.on("spawn", onSpawn)
while True:
enemy = hero.findNearestEnemy()
enemies = hero.findEnemies()
burls = hero.findByType("burl")
undeads = hero.findByType("skeleton")
collect()
for burl in burls:
if burl and hero.canCast("sacrifice", burl):
hero.cast("sacrifice", burl, hero)
if enemy:
if hero.canCast("devour", enemy):
hero.cast("devour",enemy)
if hero.canCast("poison-cloud", findStrongestEnemy()):
hero.cast("poison-cloud", enemy)
if hero.canCast("chain-lightning", findStrongestEnemy()):
hero.cast("chain-lightning", enemy)
if hero.canCast("drain-life", findStrongestEnemy()):
hero.cast("drain-life", enemy)
if hero.canCast("fear", findStrongestEnemy()):
hero.cast("fear", enemy)
else:
hero.attack(enemy)
if hero.isReady("summon-burl"):
hero.cast("summon-burl")
if hero.isReady("summon-undead"):
hero.cast("summon-undead")
for dead in hero.findCorpses():
if dead and hero.distanceTo(dead) < 20 and hero.canCast("raise-dead"):
hero.cast("raise-dead")
else:
if dead and hero.canCast("raise-dead"):
hero.move(dead.pos)
hero.cast("raise-dead")
@moonwatcher348 @PeterPalov @Aya @FrostByte @riticmaster908
Try calculating which path has the most coins on it, and please don’t @ everyone
Is this all the code or did you paste it several times?
It’s all the code I think, the things in 3 quotes are like comments