[SOLVED] Help! Restless Dead [Python]

I haven’t been here for most of the topic but I’m pretty sure you don’t need a defend line in your function. I would also define summon and command (for the soldiers) separately (as in two functions).

2 Likes

Did you put black or green flags because you if it doesn’t move to that position its probably you placed the wrong flag.

1 Like

Yes, I did use it. (2020202)

I put black flags as it said in the function.

I know you did but you might’ve placed green or pink flags, and did you change your code if you did can you repost it :slight_smile:.

I placed down black flags, I’m pretty sure.

This is my current code, sorry for responding so late, school started and they gave us a lot of homework.

def findFlags():
    flag = hero.findFlag("black")
    if flag:
        hero.moveXY(flag.pos.x, flag.pos.y)
        hero.pickUpFlag(flag)


def commandSoldiers():
    if hero.gold >= hero.costOf("soldier"):
        hero.summon("soldier")
    for friend in hero.findFriends():
        if friend.type == "soldier":
            enemy = friend.findNearestEnemy()
            if enemy:
                hero.command(friend, "attack", enemy)
            else:
                hero.command(friend, "defend", {'x':63, 'y':57})

def collectCoins(): 
    coin = hero.findNearestItem()
    if coin:
        hero.move(coin.pos)


enemyuser = hero.findNearestEnemy()
if enemyuser:
    
    if hero.isReady("throw"):
        hero.throw(enemyuser)
    else:
        hero.attack(enemyuser)


while True:
    collectCoins()
    commandSoldiers()
    enemyuser = hero.findNearestEnemy()
    if enemyuser:
        if hero.distanceTo(enemyuser) > 10:
            hero.move(enemyuser.pos)
        if hero.isReady("throw"):
            hero.throw(enemyuser)
        else:
            hero.attack(enemyuser)
    

You didn’t call the findFlags() command in the while true loop so that explain why you can’t move the flag.
Suggestion:
I tried the code using Nalfar and I passed the level. It’s not a good idea to let the soldiers move into the Graveyard because thats where the skeleton king summon his minions, try deleting the else line in commandSoldiers().

I also passed the level with Anya and this is the gear I used

Ok, thank you guys for the support!
Lydia

@Lydia_Song does that mean you’ve passed the level?

1 Like

NOpe! :rofl: :rofl: :rofl: :rofl: :rofl: :rofl:

`def findFlags():
    flag = hero.findFlag("black")
    if flag:
        hero.moveXY(flag.pos.x, flag.pos.y)
        hero.pickUpFlag(flag)


def commandSoldiers():
    if hero.gold >= hero.costOf("soldier"):
        hero.summon("soldier")
    for friend in hero.findFriends():
        if friend.type == "soldier":
            enemy = friend.findNearestEnemy()
            if enemy:
                hero.command(friend, "attack", enemy)
           

def collectCoins(): 
    coin = hero.findNearestItem()
    if coin:
        hero.move(coin.pos)


enemyuser = hero.findNearestEnemy()
if enemyuser:
    if hero.isReady("cleave"):
        hero.cleave(enemyuser)
    if hero.isReady("throw"):
        hero.bash(enemyuser)
    else:
        hero.attack(enemyuser)


while True:
    findFlags()
    collectCoins()
    commandSoldiers()
    enemyuser = hero.findNearestEnemy()
    if enemyuser:
        if hero.isReady("cleave"):
            hero.cleave(enemyuser)
        if hero.isReady("bash"):
            hero.bash(enemyuser)
        else:
            hero.attack(enemyuser)
    `

So… all you guys passed the level with this code? That means my armor is trash. :rofl: :rofl: :rofl:

1 Like

That is quite likely. Using your code, but with Anya at 3510 HP, I was also able to pass.

I think you know what is wrong…

1 Like

Lol, i forgot to switch back to bash. I keep switching from ranger and warrior, so…

Can I see your equipment?


Keep in mind though, I came back to this level after some time so was much better equipped.

1 Like

Ok, thank you. I think I’ll come back to this one after I have enough gems to buy a better sword.

I think that would be a good idea. Your code is certainly viable.

1 Like