Deadly Dungeon Rescue Help?!


#1

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

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");


#3

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.


#4

WHOOHOO I beat the level Deadly Dungeon Rescue!!!


#5

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


#6

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


#7

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


#8

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.


Deadly Dungeon Rescue doors?
#9

Door is your enemy :smile:

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

#10

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.


#11

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


#12

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


#13
    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.


#14

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") {.


#15

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


#16

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


#17

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?


#18

That sounds like a problem with your code…


#19

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…


#20

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?