# This level is supposed to be VERY hard! You may need a great strategy and or gear to complete it!
# Find and defeat the yeti then gather its essence for the ritual.
# You might want to gather the coins the yeti leaves behind, you'll need them to summon an army
# Stand at the summoning stone (red x) to begin summoning
# Now you just have to survive the undead hoard
def beginning():
while True:
item = hero.findNearestItem()
enemy = hero.findNearestEnemy()
if item:
hero.moveXY(item.pos.x, item.pos.y)
if enemy:
hero.attack(enemy)
if hero.gold > 270:
break
pass
def summon():
while True:
if hero.gold > hero.costOf("soldier"):
hero.summon("soldier")
if hero.gold < hero.costOf("soldier"):
break
def army():
friends = hero.findFriends()
for friend in friends:
enemies = friend.findEnemies()
for enemy in enemies:
if enemy:
hero.command(friend, "attack", enemy)
if not friend:
break
def bye():
enemies = hero.findEnemies()
for enemy in enemies:
if enemy and hero.isReady("devour"):
hero.devour(enemy)
elif enemy:
hero.attack(enemy)
hero.moveXY(51, 37)
beginning()
hero.moveXY(19, 40)
summon()
while True:
army()
bye()
Been stuck a while on this. For some reason my hero after attacking then always starts moving away to one side but I am not sure why; any ideas?! Thanks in advance
can anybody help me on this level? here is my code.
# This level is supposed to be VERY hard! You may need a great strategy and or gear to complete it!
# Find and defeat the yeti then gather its essence for the ritual.
# You might want to gather the coins the yeti leaves behind, you'll need them to summon an army
# Stand at the summoning stone (red x) to begin summoning
# Now you just have to survive the undead hoard
def beginning():
while True:
item = hero.findNearestItem()
enemy = hero.findNearestEnemy()
friend = hero.findFriends()
if item:
hero.moveXY(item.pos.x, item.pos.y)
if enemy:
if hero.canCast("haste", hero):
hero.cast("haste", hero)
if hero.canCast("slow", enemy):
hero.cast("slow", enemy)
if hero.canCast("lightning-bolt", enemy):
hero.cast("lightning-bolt", enemy)
if hero.isReady("shockwave"):
hero.cast("shockwave", enemy)
if hero.isReady("chain-lightning"):
hero.cast("chain-lightning", enemy)
if hero.isReady("devour"):
hero.devour(enemy)
if hero.canCast("earthskin", hero):
hero.cast("earthskin", hero)
if hero.gold > 380:
break
pass
def summon():
while True:
if hero.gold > hero.costOf("soldier"):
hero.summon("soldier")
if hero.gold < hero.costOf("soldier"):
break
def army():
friends = hero.findFriends()
for friend in friends:
enemies = friend.findEnemies()
for enemy in enemies:
if enemy:
hero.command(friend, "move", enemy.pos)
hero.command(friend, "attack", enemy)
if not friend:
break
def moveItPeople():
enemy = hero.findNearestEnemy()
for friend in hero.findFriends():
hero.command(friend, "move", {'x': enemy.pos.x, 'y': enemy.pos.y})
def bye():
enemy = hero.findNearestEnemy()
enemies = hero.findEnemies()
friends = hero.findFriends()
soldier = hero.findNearest("soldier")
for enemy in enemies:
if enemy:
if hero.canCast("slow", enemy):
hero.cast("slow", enemy)
if hero.canCast("lightning-bolt", enemy):
hero.cast("lightning-bolt", enemy)
if hero.isReady("shockwave"):
hero.cast("shockwave", enemy)
if hero.isReady("chain-lightning"):
hero.cast("chain-lightning", enemy)
if hero.isReady("devour"):
hero.devour(enemy)
if hero.canCast("earthskin", hero):
hero.cast("earthskin", hero)
if hero.isReady("soul-link"):
hero.cast("soul-link", hero, enemy)
else:
hero.attack(enemy)
for friend in hero.findFriends():
hero.cast("haste", friend)
hero.cast("swap", friend)
hero.moveXY(51, 37)
beginning()
hero.moveXY(19, 40)
summon()
hero.moveXY(49, 42)
hero.wait(2)
hero.moveXY(19, 40)
while True:
moveItPeople()
army()
bye()
I’ve spotted a bit which might be causing the problem. It’s an inefficient use of a for loop. Here:
Do you want your friends to attack all the enemies one by one? Attacking each of them only once?
I think it would be “better” to command the friend to attack their nearest enemy.
Danny
Can you show me your code again? and what do you mean by stop attacking right in the middle because if the code is wrong they shouldn’t be attacking at all.
# This level is supposed to be VERY hard! You may need a great strategy and or gear to complete it!
# Find and defeat the yeti then gather its essence for the ritual.
# You might want to gather the coins the yeti leaves behind, you'll need them to summon an army
# Stand at the summoning stone (red x) to begin summoning
# Now you just have to survive the undead hoard
def beginning():
while True:
item = hero.findNearestItem()
enemy = hero.findNearestEnemy()
friend = hero.findFriends()
if item:
hero.moveXY(item.pos.x, item.pos.y)
if enemy:
if hero.canCast("haste", hero):
hero.cast("haste", hero)
if hero.canCast("slow", enemy):
hero.cast("slow", enemy)
if hero.canCast("lightning-bolt", enemy):
hero.cast("lightning-bolt", enemy)
if hero.isReady("shockwave"):
hero.cast("shockwave", enemy)
if hero.isReady("chain-lightning"):
hero.cast("chain-lightning", enemy)
if hero.isReady("devour"):
hero.devour(enemy)
if hero.canCast("earthskin", hero):
hero.cast("earthskin", hero)
if hero.gold > 380:
break
pass
def summon():
while True:
if hero.gold > hero.costOf("soldier"):
hero.summon("soldier")
if hero.gold < hero.costOf("soldier"):
break
def army():
friends = hero.findFriends()
for friend in friends:
enemy = friend.findNearestEnemy()
for enemy in friend.findEnemies():
if enemy:
hero.command(friend, "move", enemy.pos)
hero.command(friend, "attack", enemy)
if not friend:
break
def bye():
enemy = hero.findNearestEnemy()
enemies = hero.findEnemies()
friends = hero.findFriends()
soldier = hero.findNearest("soldier")
for enemy in enemies:
if enemy:
if hero.canCast("slow", enemy):
hero.cast("slow", enemy)
if hero.canCast("lightning-bolt", enemy):
hero.cast("lightning-bolt", enemy)
if hero.isReady("shockwave"):
hero.cast("shockwave", enemy)
if hero.isReady("chain-lightning"):
hero.cast("chain-lightning", enemy)
if hero.isReady("devour"):
hero.devour(enemy)
if hero.canCast("earthskin", hero):
hero.cast("earthskin", hero)
if hero.isReady("soul-link"):
hero.cast("soul-link", hero, enemy)
else:
hero.attack(enemy)
if enemy and pet.isReady("charm"):
hero.attack(enemy)
hero.attack(enemy)
pet.charm(enemy)
for friend in hero.findFriends():
hero.cast("haste", friend)
hero.cast("swap", friend)
hero.moveXY(51, 37)
beginning()
hero.moveXY(19, 40)
summon()
while True:
enemy = hero.findNearestEnemy()
if not enemy:
for friend in hero.findFriends():
hero.command(friend, "move", {'x': 48, 'y': 40})
else:
break
while True:
if hero.gold >= hero.costOf("soldier"):
hero.summon("soldier")
army()
bye()
Your hero isn’t attacking because you’re trying to soul link yourself with an enemy. It can only be done with friends. Also even if you could you wouldn’t want to, because it shares the damage dealt to one of you with the other.
This could be simplified a lot.
Why use a for loop inside another one? It’s very innefficient as your soldiers will be running around from enemy to enemy as they try to kill them in the right order. Just use their nearest enemy. Also the rest of the code is unnecessary. Attack automatically moves to the enemy’s position.
Danny
Actually, if you break at that point with the current code it will exit the enemy for loop, not the friend for loop. And because that friend is dead anyway it doesn’t matter. This is the correct usage of break (I still think the code should be changed to what I said for tactical reasons).
Danny
At the time I was the first to respond to mratranslate but deleted the post because it contained a link to my level session
As a tip for any level without a default code:
Make a plan and break it into pieces
Choose a free hero (for complex ones you have more opportunities for mistakes)
Solve the problem step by step
Swap the hero with your favorite if the code is OK
In the specific case possible scenario:
Challenge the Yeti and defeat it
(Yeti = hero.findByType(“yeti-cub”)[0] - yeti cub: I feel bad about it!)
Collect all the coins
Go to the altar
Go to the entrance of the enemy camp and summon friends
In general, keep your hero on the front line so that your army inflicts as much damage as possible