[SOLVED] Restless Dead Level Help

I am stuck with Restless Dead. I am getting too overwhelmed by skeletons. Help would be very much appreciated.

Hi @FalconX11_312, if you need help with a level please post your code, formatted as it says here:

Danny

Here

def collect():
    coins = hero.findItems()
    coin = hero.findNearest(coins)
    if coin:
        hero.move(coin.pos)

def summon():
    if hero.gold > hero.costOf("soldier"):
        hero.summon("soldier")

def command():
    soldiers = hero.findFriends()
    for i in range(len(soldiers)):
        soldier = soldiers[i]
        hero.command(soldier, "move", {"x": 31, "y": 40})
        enemts = hero.findEnemies()
        enemt = hero.findNearest(enemts)
        if enemt:
            hero.command(soldier, "attack", enemt)
        

        
while True:
    flag = hero.findFlag()
    if flag:
        hero.pickUpFlag(flag)
        enemies = hero.findEnemies()
        enemy = hero.findNearest(enemies)
        if enemy:
            if hero.isReady("bash"):
                hero.bash(enemy)
            else:
                hero.attack(enemy)
        collect()
        summon()
        command()
        

Hi,
you’ll probably want to start by moving the code you have inside the if flag statement, outside of it (except hero.pickUp(flag). Otherwise you’ll only do those things when there’s a flag.
Apart from that I’m afraid it’s just tactics. You may have to experiment.
I’ll give you something to start:
To stop you’re soldiers standing still while you pick up a flag, you can put:

while hero.distanceTo(... > x:
    hero.move(...
hero.pickUpFlag()

You can move close, then pick it up.
Danny

Hi @Deadpool198. I don’t understand what you mean.

What I meant in the second bit is a way of moving to a flag without interrupting commanding your soldiers. hero.pickUpFlag() uses a moveXY() which doesn’t let you do anything else while it’s happening. Unlike move() which allows other stuff to happen at the same time.
The code is basically:

while distanceTo(flag) > 3:
    hero.move(flag.pos)
hero.pickUpFlag()

Danny

Also, by moving everything inside the if flag: statement, the hero doesn’t attack the yeti.

Please could you post your current code.
Thanks
Danny

while True:
    flag = hero.findFlag()
    if flag:
        distance = hero.distanceTo(flag)
        while distance < 5:
            hero.move(flag.pos)
    enemies = hero.findEnemies()
    enemy = hero.findNearest(enemies)
    while enemy and enemy.health <= 150:
        command()
        if hero.isReady("bash"):
            hero.bash(enemy)
        else:
            hero.attack(enemy)
        collect()
        summon()
    

Can you please send us your entire code (with the command(), summon() and collect() functions defined)?

Andrei

def collect():
    coins = hero.findItems()
    coin = hero.findNearest(coins)
    if coin:
        hero.move(coin.pos)

def summon():
    if hero.gold > hero.costOf("soldier"):
        hero.summon("soldier")

def command():
    soldiers = hero.findFriends()
    for i in range(len(soldiers)):
        soldier = soldiers[i]
        hero.command(soldier, "move", {"x": 31, "y": 40})
        enemts = hero.findEnemies()
        enemt = hero.findNearest(enemts)
        if enemt:
            hero.command(soldier, "attack", enemt)
        

        
while True:
    flag = hero.findFlag()
    if flag:
        distance = hero.distanceTo(flag)
        while distance < 5:
            hero.move(flag.pos)
    enemies = hero.findEnemies()
    enemy = hero.findNearest(enemies)
    while enemy and enemy.health <= 150:
        command()
        if hero.isReady("bash"):
            hero.bash(enemy)
        else:
            hero.attack(enemy)
        collect()
        summon()

Do you think there might be something wrong with the functions?

Try to call this funcion after the line with the while True loop.

Andrei

Try to put this in an else for this if statement

After this, try to update the variabile distance.

Andrei

To start with, he doesn’t attack the yeti.
Also, here is the function command():

def command():
    soldiers = hero.findFriends()
    for i in range(len(soldiers)):
        soldier = soldiers[i]
        enemts = hero.findEnemies()
        enemt = hero.findNearest(enemts)
        if enemt:
            hero.command(soldier, "attack", enemt)
            hero.command(soldier, "move", {"x": 31, "y": 40})

and this is what I did to update distance:

if flag:
        distance = hero.distanceTo(flag)
        while distance < 5:
            hero.move(flag.pos)
            distance = hero.distanceTo(flag)

Was it right?

Put before this an else.

Andrei

I have to go to bed now. @Deadpool198 and @dedreous will help you out more with this level while I am asleep.

Andrei

Hi @dedreous. My hero does not move to the flag. Here is my code.

def collect():
    coins = hero.findItems()
    coin = hero.findNearest(coins)
    if coin:
        hero.move(coin.pos)

def summon():
    if hero.gold > hero.costOf("soldier"):
        hero.summon("soldier")

def command():
    soldiers = hero.findFriends()
    for i in range(len(soldiers)):
        soldier = soldiers[i]
        hero.command(soldier, "move", {"x": 31, "y": 40})
        enemts = hero.findEnemies()
        enemt = hero.findNearest(enemts)
        if enemt:
            hero.command(soldier, "attack", enemt)
        

        
while True:
    summon()
    flag = hero.findFlag()
    if flag:
        distance = hero.distanceTo(flag)
        while distance < 5:
            hero.move(flag.pos)
    enemies = hero.findEnemies()
    enemy = hero.findNearest(enemies)
    while enemy and enemy.health <= 150:
        command()
        if hero.isReady("bash"):
            hero.bash(enemy)
        else:
            hero.attack(enemy)
        collect()
        

I have to go now. See you tomorrow @dedreous.

        while distance < 5:
            hero.move(flag.pos)

You hero will only move to the flag while he is less than distance 5 away. Is that what you mean?

1 Like