Restless dead - it's restless

# 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

1 Like

Thank you for suggesting it. It helped. A little bit. The soldiers stop attacking right in the middle of the battle.

1 Like

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.

2 Likes

HELP PLEASE

hero.moveXY(51, 39)
enemy = hero.findNearestEnemy()
hero.attack(enemy)

hero.moveXY(19, 40)
while True:
    
    if enemy:
        friend  = hero.findNearestFriend()
        hero.command(friend, "move", enemy.pos)
        hero.command(friend, "attack", enemy) 
        if not friend:
            break


PLEASE

Can you show me equipment?

Andrei

But what happens after you kill one (the first) enemy and you need to fight another one?

Andrei

1 Like

I use this to kill the yeti

Yeah but your also going to need hero.attack(enemy) after because without this line you can’t defeat the general.

I made adjustments, but here is is.

# 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()

Okay, my soldiers attack now, but my hero doesn’t.

Whats the problem. (20 chars)

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

3 Likes

This probably breaks the loop and your soldiers will stop attacking. Change this.

1 Like

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

3 Likes

Oh I didn’t know that. Any more problems @jaden_the_best?

1 Like

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:

  1. Make a plan and break it into pieces
  2. Choose a free hero (for complex ones you have more opportunities for mistakes)
  3. Solve the problem step by step
  4. Swap the hero with your favorite if the code is OK

In the specific case possible scenario:

  1. Challenge the Yeti and defeat it
    (Yeti = hero.findByType(“yeti-cub”)[0] - yeti cub: I feel bad about it!)
  2. Collect all the coins
  3. Go to the altar
  4. Go to the entrance of the enemy camp and summon friends
  5. In general, keep your hero on the front line so that your army inflicts as much damage as possible
  6. Win

possible level solution:
restless-dead

5 Likes

@xython How do you only summon male archers I’m kinda curious.

3 Likes

In some levels theyre female, in other - male, I think.

2 Likes