Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

Solving the level

I’v been stuck at the below level for over 2 weeks. Is there any option to unlock it for me? Or advise on the solution?

Thanks for your help.


Welcome to the forums @StaszekPiano, this is a family-friendly place where coders can share bugs, ask for help on any CodeCombat level (don’t forget to post your code correctly), or just hang out with other coders. But before you post more, please check out the guidelines (if you haven’t already): this topic.
Have a great time! :partying_face: (@enPointe77 is slow (no offense) xD)

Could you please post your code? :slight_smile:


I welcomed, what? 4 people yesterday? Lol, the competition.


And which level is this?

1 Like

I have notifications on for each category. :grin:


Stick Shift in Game Design 2.


This is my code:

# Now you can create a custom goal for your game
# using the game.addManualGoal(description) method!

# Spawn a few scouts, a boss, and a maze.
game.spawnXY("scout", 60, 58)
game.spawnXY("scout", 28, 29)
game.spawnXY("scout", 61, 24)
ogre = game.spawnXY("ogre-f", 60, 12)

# Spawn and configure the hero.
hero = game.spawnPlayerXY("captain", 12, 56)
hero.maxHealth = 550
hero.maxSpeed = 10
hero.attackDamage = 150

# Spawn a munchkin generator.
generator = game.spawnXY("generator", 41, 13)
generator.spawnDelay = 5
generator.spawnType = "munchkin"

# Survive goal.
game.spawnXY("potion-medium", 28, 12)

# addManualGoal adds an incomplete goal with a description
# The description will be shown to players.
# NOTE that we save it in a variable called scoutGoal
#scoutGoal = game.addManualGoal("Defeat all scouts")
# Use addManualGoal to add a goal to defeat the boss
# Save it in a variable called bossGoal
bossGoal = game.addManualGoal("Defeat the boss")
#bossGoal = game.addManualGoal("Defeat the Boss")

game.setActionFor("scout", "spawn", onSpawn)
game.setActionFor("ogre", "spawn", onSpawn)
game.setActionFor("scout", "defeat", onDefeat)
game.setActionFor("ogre", "defeat", onDefeat)
game.setActionFor("munchin", "defeat", onDefeat)

# Enemy Behavior
def onSpawn(event):
    unit =
    while True:
        enemy = unit.findNearestEnemy()
        if enemy:

while True:
    enemy = hero.findNearestEnemy()
    if enemy:

# Count how many scouts are defeated.
scoutsDefeated = 0

hero.say("to jest test mowienia")

# Update our manual goals whenever an enemy is defeated.
# This is an example of an algorithm using if-statements.
def onDefeat(event):
    unit =
    if unit.type == "scout":
        scoutsDefeated = scoutsDefeated + 1
        hero.say("Scout down!, a licznik skautów to: " + scoutsDefeated)

    if scoutsDefeated >= 1:
        # Use setGoalState to mark scoutGoal complete.
        #game.setGoalState(scoutGoal, True)
        hero.say("All Scouts down!")

    if unit.type == "ogre":
        # Use game.setGoalState to mark bossGoal complete.
        # Don't forget about the second parameter.
        hero.say("OOOOOOOOO Defeated the big boss!")
        hero.say("Stan celu gry: " + bossGoal.success)

# Assign the onDefeat handler to the ogres" "defeat"
# NOTE that munchkins don't count toward success!
#game.setActionFor("scout", "defeat", onDefeat)
#game.setActionFor("ogre", "defeat", onDefeat)

1 Like

Wait, the text seems a bit like Polish… do you speak Polish? (I know this is off-topic)

Try replacing this with hero.say("Stan celu gry: success") and see if it works then.

Yes, it’s Polish.

To mój język ojczysty :slight_smile:

It’s still not working :frowning:

The result is:
Win the game - OK
Add a Manual Goal to Defeat the Boss - FAILED


:smiley: Nice to see someone from Poland again. (I’m Polish too) But I can’t write in Polish. :frowning: I can only speak. (and read a bit)

Hmmmmm. I’ll try playing the level with your code and see what’s wrong.

Try un-commenting this line #game.spawnMaze(5)

1 Like

I’m afraid it’s still the same.
My reasoning is that it should be ok - when I apply my solution it says “Defeat the boss” in the goals section on the right. However after the playback of my solution is finished the message is as I wrote above:

Win the game - OK
Add a Manual Goal to Defeat the Boss - FAILED

So did I add the manual goal or not? I don’t get it :frowning:


I think it’s a bug. @bryukh?

I think here is the problem, the first manual goal is commented, try uncommenting it, it should work

Yes, I didn’t notice that line.

1 Like

You were right! I completed the level. My assumption (which was wrong) was that if I remove the scout goal I don’t have to worry about it. I uncommented it and got it working.

Thank you very much for your help!


No problem, and don’t forget to mark the solution :slightly_smiling_face:

1 Like