For some reason, as it started, it said “success” but when I submitted it, it went lag mode.
Is this a bug or is my internet bad?
This is the code:
# Stay alive for two minutes.
# If you win, it gets harder (and more rewarding).
# If you lose, you must wait a day before you can resubmit.
# Reme
'''
while True:
friends = hero.findByType("peasant")
enemy = hero.findNearestEnemy()
flag = hero.findFlag()
if hero.isReady("heart-shield"):
hero.heartShield()
hero.shield()
hero.shield()
hero.shield()
hero.shield()
hero.shield()
hero.shield()
for friends in friends:
coin = friends.findNearestItem()
if coin:
hero.command(friends, "move", coin.pos)
if enemy and hero.canCast("chain-lightning"):
hero.cast("chain-lightning", enemy)
if hero.gold >= 20:
hero.summon("soldier")
if hero.isReady("flash"):
hero.flash()
if hero.canCast("earthskin"):
hero.cast("earthskin", hero)
'''
hero.cast("invisibility", hero)
hero.moveXY(77, 68)
hero.summon("soldier")
hero.summon("soldier")
hero.summon("soldier")
def findInRangeEnemies():
enemies = hero.findEnemies()
inRange = []
if enemies:
for enemy in enemies:
if enemy and hero.isPathClear(hero.pos, enemy.pos):
inRange.append(enemy)
return inRange
def findEnemy(units):
goodOne = None
goodOnes = []
for unit in units:
if unit.pos.x < 75 and unit.type != "sand-yak":
goodOnes.append(unit)
goodOne = hero.findNearest(goodOnes)
return goodOne
while True:
enemy = hero.findNearestEnemy()
if hero.canCast("summon-undead"):
hero.cast("summon-undead")
elif hero.gold >= hero.costOf("soldier"):
hero.summon("soldier")
friends = hero.findFriends()
soldiers = hero.findByType("soldier", friends)
skells = hero.findByType("skeleton", friends)
sacrifices = skells + soldiers
enemies = hero.findEnemies()
enemy = findEnemy(enemies)
lameEnemy = hero.findNearestEnemy()
nearest = hero.findNearest(sacrifices)
for sol in soldiers:
enemyS = sol.findNearestEnemy()
if enemyS:
hero.command(sol, "attack", enemyS)
if hero.canCast("raise-dead"):
hero.cast("raise-dead")
if enemy and hero.canCast("poison-cloud"):
hero.cast("poison-cloud", enemy)
if nearest and hero.canCast("sacrifice"):
hero.cast("sacrifice", nearest, hero)
if enemy and hero.canCast("chain-lightning"):
hero.cast("chain-lightning", enemy)
elif enemy and hero.canCast("lightning-bolt"):
hero.cast("lightning-bolt", enemy)
elif enemy:
hero.attack(enemy)
elif lameEnemy:
hero.attack(lameEnemy)
'''
hero.moveXY(45, 69)
hero.cast("invisibility", hero)
hero.moveXY(87, 71)
while True:
if hero.time > 1000:
break
inRangeEnemies = findInRangeEnemies()
if inRangeEnemies:
enemy = hero.findNearest(findInRangeEnemies())
soldiers = hero.findByType("soldier")
if hero.canCast("invisibility", hero):
hero.cast("invisibility", hero)
if hero.gold > hero.costOf("soldier"):
hero.summon("soldier")
for soldier in soldiers:
soldierE = soldier.findNearest(findInRangeEnemies())
if soldierE:
hero.command(soldier, "attack", soldierE)
if hero.isReady("heal") and hero.health <= hero.maxHealth - 200:
hero.heal(hero)
elif enemy:
if hero.canCast("chain-lightning", enemy):
hero.cast("chain-lightning", enemy)
elif hero.isReady("throw") and hero.distanceTo(enemy) < hero.throwRange:
if hero.distanceTo(enemy) >= 10:
hero.throw(enemy)
else:
continue
elif hero.distanceTo(enemy) < hero.attackRange:
hero.scattershot(enemy)
enemy = hero.findNearestEnemy()
hero.cast("shockwave", enemy)
hero.cast("invisibility", hero)
targets = hero.findByType("soldier")[0]
hero.cast("swap", targets)
hero.moveXY(67, 83)
hero.resetCooldown("swap")
hero.buildXY("soldier", 60, 86)
hero.cast("swap", soldier)
while True:
hero.cast("windstorm", hero)
enemy = hero.findNearestEnemy()
hero.cast("chain-lightning", enemy)
hero.moveXY(50, 69)
hero.moveXY(92, 69)
while True:
enemy = hero.findNearestEnemy()
friend = hero.findFriends()
if enemy:
hero.cast("drain-life", enemy)
if hero.canCast("summon-undead"):
hero.cast("summon-undead")
if hero.canCast("summon-burl"):
hero.cast("summon-burl")
if hero.canCast("poison-cloud",enemy):
hero.cast("poison-cloud", enemy)
hero.cast("raise-dead")
if hero.gold >= 35 and hero.isReady("drink"):
hero.drink("heal")
if hero.isReady("earthskin"):
hero.cast("earthskin", hero)
if hero.canCast("chain-lightning", enemy):
hero.cast("chain-lightning", enemy)
hero.drink("damage")
while True:
enemy = hero.findNearestEnemy()
if enemy:
hero.attack(enemy)
if hero.isReady("heal"):
hero.heal(hero)