[Adventurer] Jailbreak

The Game Development 2 level Jailbreak is ready for playtesting!

This level introduces game.addDefeatGoal(x), where x is the amount of enemies that must be defeated to win the game.

2 Likes

This is cool, except I misread the example and set the defeat goal to 5, then killed 5 enemies, but didn’t get success. Is it possible to have the requirement be to add a defeat goal that is at least 4? Then someone could add success as killing all 9 of the ogres?

I was also hoping that my soldiers in the middle room would help me fight, but they just stand there.

But, all told, the level works as it is written.

1 Like

I didn’t find any problems completing this level with default goal (defeat 4 enemies)

@dwhittaker I liked your idea and experimented with modifying @Catsync’s level

Try: https://codecombat.com/play/level/jailbreak-with-bonus and let me know what you think?

-HW

I didn’t have any issues with the level either. However when I add the code to defeat all of the ogres an odd error comes up:

1 Like

I do everything that it asks for and try to add a while loop that hunts for the enemy but its not running properly don’t know why

you make cool levels can some one help me find the web to make levels?

(i have subscribed)

@MTEYRA

This link is for the level editor where you can make your own levels.

2 Likes

oh… I should click mouse.
it’s strange. But my hero just staying when enemies attacking him.

// The player only needs to defeat some of the enemies.
game.spawnPlayerXY("guardian", 62, 25);

// Use game.addDefeatGoal(X) to allow the player to win
// after defeating X enemies! (In this case, X should be 4)
game.addDefeatGoal(4);

Necesito ayuda por favor, no sé cual es el código que debo usar para que mi guardian ataque.

game.addDefeatGoal(4);

def attackEnemies(event):
guardian = event.target
while True:
if enemy:
enemy = “guardian”.findNearstEnemy()
guardian.attack(enemy)

Hola y bienvenidos al foro!

En futuras publicaciones, asegúrese de formatear correctamente su código. Puede aprender cómo hacer esto aquí: [Essentials] How To Post/Format Your Code Correctly

¿Cuál es el nombre del nivel en el que estás trabajando?

English

Howdy and welcome to the forum!

In future posts, please be sure to properly format your code. You can learn how to do this here: [Essentials] How To Post/Format Your Code Correctly

What is the name of the level you are working on?

How do I set an action for the player?
I went with var hero=game.spawnPlayerXY("guardian", 62, 25); but why doesn’t the code below work?

game.spawnPlayerXY("guardian", 62, 25);
game.addDefeatGoal(4);
function attackInSight(event){
    while(true){
        var unit = event.target;
        var enemy=unit.findNearestEnemy();
        if (enemy){
            unit.attack(enemy);
        } else {
            unit.moveXY(unit.pos.x, (unit.pos.y+10));
        }
    }
}
game.setActionFor("guardian", "spawn", attackInSight);

Can anyone please help?

You can assign a variable name to a player…this allows you to set attributes like speed, max damage, etc. To ‘command’ the player, you start the game and then click on the objects within. Click a munchkin to go and kill it, click a gem to go pick it up and so on.

Thank you! I did not see any prompts about that inside the level…
What I did was to save the player to a variable, so in a while-true loop “player” looks for nearest enemy and attacks it if one is in sight. Otherwise “player” moves to a postion where he is likely to be spotted by other enemies.

1 Like