Deadly Dungeon Rescue

I really need help on this level.

I’m sorry, but you need to be more specific. Help us help you. :smile:

What part don’t you understand? What is causing you problems? What is not working like you think it should? include code you are trying? (Three ``` backticks alone on the line before and after code so it formats correctly.) Do you have the correct equipment for the code you are trying? If you get all the way to the prisoner and it seems that he won’t follow you (leave the room then he will).

loop:
flag = self.findFlag()
enemy = self.findNearestEnemy()
item = self.findNearestItem()

if flag:
    self.pickUpFlag(flag)
elif enemy:
    self.attack(enemy)
    self.shield()

click out of it. kill the doors only.

This will not work!
If at any time a munchkin comes in your vision range and is closer than a door, your hero will attack it and there will be no way to stop it from doing so. The easiest is to use two different flags. One simply moves the character, the other one causes it to attack right after the hero picked up the flag (not before).

Remember that if the enemy type is a munchkin, leave it alone. Otherwise, attack! Turn this into code.

1 Like