Deadly Dungeon Rescue Help?!

The player has made this level almost impossible because you cannot do if(enemy.type == "Vault Door 1")
and if statements are just useless.

2 Likes

By the player I assume you mean Sotonin, who created the level.

If if-statesments are one thing not, than useless (sounds better in german).
Without if-statesments, we could only write static code, which does every time the same thing. if-statesments allow us react to different situations.


Despite from that, maybe the error is on your side. Maybe there simply is no enemy.type == "Vault Door 1". Remember the first levels where you killed ogres? You attacked them by name!.

Try this.attack("Vault Door 1");

2 Likes

Vault Door 1 is not it’s type, it’s the name.

If you insist on using type, the type for all the doors is simply “door”. nothing impossible about it. You just need to get creative and debug stuff. You can easily find out anything’s type by having your hero say enemy.type. That simple.

2 Likes

WHOOHOO I beat the level Deadly Dungeon Rescue!!!

1 Like

congrats! :slight_smile: i hope it presented a challenge and overcoming it was satisfying

2 Likes

look here. This is ending… But for those of you who need help can come

1 Like

The say command is a great debugging tool. Definitely something people may overlook.

2 Likes

What is the exact syntax for the say command to return the name of an item like a door or chest? I can’t find it in my panel.

1 Like

Door is your enemy :smile:

self.moveXY(150, 28)
enemy=self.findNearest(self.findEnemies())
self.attack(enemy)
self.attack(enemy)
1 Like

On this level “chests” aren’t actual objects . . . so you have to use a flag or the x,y location of the image on the map.

doors are enemies, so:

enemy = <insert find enemy command here>
if enemy:
    self.say(enemy)

That will actually say the name of any enemy.

doors are of type door, so:

if enemy.type == "door":
    self.say(enemy)

will only “say” if the enemy is a door

But as juraj suggests, you don’t need to know its name if you’re happy/safe attacking whatever is closest.

2 Likes

When i complete this level i hasnt any problem with identify doors as the enemy without naming. i think you can atack it without enemy.type naming

1 Like

You can just make your guy not attack munchkins, since the guards are munchkins.

1 Like
    if (enemy) {
        if (enemy != "munchkin") {
            this.attack(enemy);
        }
    }

My hero still killed the guard, so not attacking Munchkins doesn’t solve failing the mission with kills.

1 Like

Well, enemy returns the name of the nearest enemy, I assume, and as far as I know, there is no ogre named “munchkin.” Try if (enemy.type != "munchkin") {.

1 Like

Perhaps there is more than 1 type? I have to check and see.

1 Like

Chests are type “chest” and called “Treasure Chest 1” / “Treasure Chest 2” / “Treasure Chest 3” / “Treasure Chest 4” by name

1 Like

I have another problem: after cracking one chest (any of four) hero don’t want to do anything more. What’s wrong? Is it just me?

1 Like

That sounds like a problem with your code…

1 Like

Tried different ways. Action stops even with:

self.moveXY(150, 28)
enemy=self.findNearest(self.findEnemies())
self.attack("Vault Door 1")
self.attack("Vault Door 1")
self.attack("Treasure Chest 1")
self.attack("Treasure Chest 2")

and chest 2 never was attacked, hero didn’t any step more…

PS and yes, I’m already know, that there is no need to crack chest, but…

1 Like

I don’t see you telling the hero to do anything after:

self.attack(“Treasure Chest 2”)

so why do you expect that it will?

1 Like