# Solving the level

**URL:** <https://discourse.codecombat.com/t/solving-the-level/30892>\
**Category:** Level Help\
**Created:** [October 9, 2021, 4:09pm UTC](https://discourse.codecombat.com/t/solving-the-level/30892 "2021-10-09T16:09:11Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![StaszekPiano](https://avatars.discourse-cdn.com/v4/letter/s/3be4f8/32.png) [@StaszekPiano](https://discourse.codecombat.com/u/StaszekPiano)\
**Post date:** [October 9, 2021, 4:09pm UTC](https://discourse.codecombat.com/t/solving-the-level/30892/1 "2021-10-09T16:09:11Z")

</div>

Hi,  
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?

[https://codecombat.com/play/level/stick-shift?](https://codecombat.com/play/level/stick-shift?)

Thanks for your help.

S.

---

<div class="post-metadata">

**Author:** ![moonwatcher348](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/moonwatcher348/32/24126_2.png) [@moonwatcher348](https://discourse.codecombat.com/u/moonwatcher348)\
**Post date:** [October 9, 2021, 4:13pm UTC](https://discourse.codecombat.com/t/solving-the-level/30892/2 "2021-10-09T16:13:05Z")

</div>

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](https://discourse.codecombat.com/t/essentials-how-to-post-format-your-code-correctly/15521)), or just hang out with other coders. But before you post more, please check out the guidelines (if you haven’t already): [this topic](https://discourse.codecombat.com/t/this-topic/15601).  
Have a great time! 🥳 (@enPointe77 is slow (no offense) xD)

Could you please post your code? 🙂

---

<div class="post-metadata">

**Author:** ![enPointe77](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/enpointe77/32/43632_2.png) [@enPointe77](https://discourse.codecombat.com/u/enPointe77)\
**Post date:** [October 9, 2021, 4:14pm UTC](https://discourse.codecombat.com/t/solving-the-level/30892/3 "2021-10-09T16:14:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![enPointe77](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/enpointe77/32/43632_2.png) [@enPointe77](https://discourse.codecombat.com/u/enPointe77)\
**Post date:** [October 9, 2021, 4:14pm UTC](https://discourse.codecombat.com/t/solving-the-level/30892/4 "2021-10-09T16:14:33Z")

</div>

And which level is this?

---

<div class="post-metadata">

**Author:** ![moonwatcher348](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/moonwatcher348/32/24126_2.png) [@moonwatcher348](https://discourse.codecombat.com/u/moonwatcher348)\
**Post date:** [October 9, 2021, 4:14pm UTC](https://discourse.codecombat.com/t/solving-the-level/30892/5 "2021-10-09T16:14:44Z")

</div>

I have notifications on for each category. 😁

---

<div class="post-metadata">

**Author:** ![moonwatcher348](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/moonwatcher348/32/24126_2.png) [@moonwatcher348](https://discourse.codecombat.com/u/moonwatcher348)\
**Post date:** [October 9, 2021, 4:15pm UTC](https://discourse.codecombat.com/t/solving-the-level/30892/6 "2021-10-09T16:15:02Z")

</div>

Stick Shift in Game Design 2.

---

<div class="post-metadata">

**Author:** ![StaszekPiano](https://avatars.discourse-cdn.com/v4/letter/s/3be4f8/32.png) [@StaszekPiano](https://discourse.codecombat.com/u/StaszekPiano)\
**Post date:** [October 9, 2021, 4:49pm UTC](https://discourse.codecombat.com/t/solving-the-level/30892/7 "2021-10-09T16:49:06Z")

</div>

This is my code:

```python
# 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.spawnMaze(5)
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.addSurviveGoal()
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 = event.target
    while True:
        enemy = unit.findNearestEnemy()
        if enemy:
            unit.attack(enemy)

while True:
    enemy = hero.findNearestEnemy()
    if enemy:
        hero.attack(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 = event.target
    hero.say("TRUP!!!")
    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!")
        game.setGoalState(bossGoal,True)
        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)

```

---

<div class="post-metadata">

**Author:** ![moonwatcher348](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/moonwatcher348/32/24126_2.png) [@moonwatcher348](https://discourse.codecombat.com/u/moonwatcher348)\
**Post date:** [October 9, 2021, 4:51pm UTC](https://discourse.codecombat.com/t/solving-the-level/30892/8 "2021-10-09T16:51:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![moonwatcher348](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/moonwatcher348/32/24126_2.png) [@moonwatcher348](https://discourse.codecombat.com/u/moonwatcher348)\
**Post date:** [October 9, 2021, 4:53pm UTC](https://discourse.codecombat.com/t/solving-the-level/30892/9 "2021-10-09T16:53:04Z")

</div>

> [@StaszekPiano](#):
>
> `hero.say("Stan celu gry: " + bossGoal.success)`

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

---

<div class="post-metadata">

**Author:** ![StaszekPiano](https://avatars.discourse-cdn.com/v4/letter/s/3be4f8/32.png) [@StaszekPiano](https://discourse.codecombat.com/u/StaszekPiano)\
**Post date:** [October 9, 2021, 5:27pm UTC](https://discourse.codecombat.com/t/solving-the-level/30892/10 "2021-10-09T17:27:34Z")

</div>

Yes, it’s Polish.

To mój język ojczysty 🙂

---

<div class="post-metadata">

**Author:** ![StaszekPiano](https://avatars.discourse-cdn.com/v4/letter/s/3be4f8/32.png) [@StaszekPiano](https://discourse.codecombat.com/u/StaszekPiano)\
**Post date:** [October 9, 2021, 5:30pm UTC](https://discourse.codecombat.com/t/solving-the-level/30892/11 "2021-10-09T17:30:05Z")

</div>

> [@moonwatcher348](#):
>
> “Stan celu gry: success”

It’s still not working ☹

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

S.

---

<div class="post-metadata">

**Author:** ![moonwatcher348](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/moonwatcher348/32/24126_2.png) [@moonwatcher348](https://discourse.codecombat.com/u/moonwatcher348)\
**Post date:** [October 9, 2021, 5:44pm UTC](https://discourse.codecombat.com/t/solving-the-level/30892/12 "2021-10-09T17:44:46Z")

</div>

> [@StaszekPiano](#):
>
> Yes, it’s Polish.

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

---

<div class="post-metadata">

**Author:** ![moonwatcher348](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/moonwatcher348/32/24126_2.png) [@moonwatcher348](https://discourse.codecombat.com/u/moonwatcher348)\
**Post date:** [October 9, 2021, 5:45pm UTC](https://discourse.codecombat.com/t/solving-the-level/30892/13 "2021-10-09T17:45:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![moonwatcher348](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/moonwatcher348/32/24126_2.png) [@moonwatcher348](https://discourse.codecombat.com/u/moonwatcher348)\
**Post date:** [October 9, 2021, 5:48pm UTC](https://discourse.codecombat.com/t/solving-the-level/30892/14 "2021-10-09T17:48:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![StaszekPiano](https://avatars.discourse-cdn.com/v4/letter/s/3be4f8/32.png) [@StaszekPiano](https://discourse.codecombat.com/u/StaszekPiano)\
**Post date:** [October 10, 2021, 12:21pm UTC](https://discourse.codecombat.com/t/solving-the-level/30892/15 "2021-10-10T12:21:28Z")

</div>

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 ☹

S.

---

<div class="post-metadata">

**Author:** ![moonwatcher348](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/moonwatcher348/32/24126_2.png) [@moonwatcher348](https://discourse.codecombat.com/u/moonwatcher348)\
**Post date:** [October 10, 2021, 12:44pm UTC](https://discourse.codecombat.com/t/solving-the-level/30892/16 "2021-10-10T12:44:39Z")

</div>

I think it’s a bug. @bryukh?

---

<div class="post-metadata">

**Author:** ![Aya](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/aya/32/42680_2.png) [@Aya](https://discourse.codecombat.com/u/Aya)\
**Post date:** [October 10, 2021, 12:58pm UTC](https://discourse.codecombat.com/t/solving-the-level/30892/17 "2021-10-10T12:58:37Z")

</div>

> [@StaszekPiano](#):
>
> ```python
> #scoutGoal = game.addManualGoal("Defeat all scouts")
> 
> ```

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

---

<div class="post-metadata">

**Author:** ![moonwatcher348](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/moonwatcher348/32/24126_2.png) [@moonwatcher348](https://discourse.codecombat.com/u/moonwatcher348)\
**Post date:** [October 10, 2021, 1:02pm UTC](https://discourse.codecombat.com/t/solving-the-level/30892/18 "2021-10-10T13:02:08Z")

</div>

Yes, I didn’t notice that line.

---

<div class="post-metadata">

**Author:** ![StaszekPiano](https://avatars.discourse-cdn.com/v4/letter/s/3be4f8/32.png) [@StaszekPiano](https://discourse.codecombat.com/u/StaszekPiano)\
**Post date:** [October 10, 2021, 7:11pm UTC](https://discourse.codecombat.com/t/solving-the-level/30892/19 "2021-10-10T19:11:38Z")

</div>

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!  
S.

---

<div class="post-metadata">

**Author:** ![Aya](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/aya/32/42680_2.png) [@Aya](https://discourse.codecombat.com/u/Aya)\
**Post date:** [October 11, 2021, 6:22am UTC](https://discourse.codecombat.com/t/solving-the-level/30892/20 "2021-10-11T06:22:21Z")

</div>

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

[Next page](https://discourse.codecombat.com/t/solving-the-level/30892.md?page=2)
