# Help cages game dev 2

**URL:** <https://discourse.codecombat.com/t/help-cages-game-dev-2/16562>\
**Category:** Uncategorized\
**Created:** [November 27, 2018, 1:14am UTC](https://discourse.codecombat.com/t/help-cages-game-dev-2/16562 "2018-11-27T01:14:13Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![ducky](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ducky/32/9364_2.png) [@ducky](https://discourse.codecombat.com/u/ducky)\
**Post date:** [November 27, 2018, 1:14am UTC](https://discourse.codecombat.com/t/help-cages-game-dev-2/16562/1 "2018-11-27T01:14:13Z")

</div>

Help! I can’t do this level because it says “Defeat is not defined”\/\/\/\/\/\/\/\/

```python
# Learn the difference between destroy and defeat.

# Spawn the enemies.
ogre1 = game.spawnXY("ogre", 12, 18)
ogre1.behavior = "AttacksNearest"
ogre2 = game.spawnXY("ogre", 68, 50)
ogre2.behavior = "AttacksNearest"

munchkinGenerator = game.spawnXY("generator", 12, 50)
munchkinGenerator.spawnAI = "Scampers"
munchkinGenerator.spawnType = "munchkin"

scoutGenerator = game.spawnXY("generator", 68, 12)
scoutGenerator.spawnAI = "Scampers"
scoutGenerator.spawnType = "scout"

# The fences which we will destroy later.
leftFence = game.spawnXY("fence", 26, 14)
rightFence = game.spawnXY("fence", 54 , 50)

player = game.spawnPlayerXY("raider", 40, 34)
player.maxSpeed = 55
player.attackDamage = 60

# The global game counters.
game.scoutsSpawned = 0
game.munchkinsSpawned = 0
game.bossesDefeated = 0
ui.track(game, "scoutsSpawned")
ui.track(game, "munchkinsSpawned")
ui.track(game, "bossesDefeated")

bossesGoal = game.addManualGoal("Defeat 2 big ogres.")

def onSpawn(event):
    unit = event.target
    if unit.type == "scout":
        game.scoutsSpawned += 1
    if game.scoutsSpawned >= 3:
        # Defeat scoutGenerator with the defeat() method.
        defeat(scoutGenerator)
        # Destroy rightFence with the destroy() method.
        destroy(rightFence)
        pass
    if unit.type == "munchkin":
        game.munchkinsSpawned += 1
    if game.munchkinsSpawned >= 2:
        # Defeat munchkinGenerator.
        defeat(muchkinGenerator)
        # Destroy the leftFence.
        destroy(leftFence )
        pass

def onDefeat(event):
    unit = event.target
    if unit.type == "ogre":
        # Increase the game.bossesDefeated counter by 1:
        game.bossesDefeated += 1

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

while True:
    if game.bossesDefeated >= 2:
        game.setGoalState(bossesGoal, True)

```

---

<div class="post-metadata">

**Author:** ![Archion](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/archion/32/26234_2.png) [@Archion](https://discourse.codecombat.com/u/Archion)\
**Post date:** [November 27, 2018, 3:58pm UTC](https://discourse.codecombat.com/t/help-cages-game-dev-2/16562/2 "2018-11-27T15:58:16Z")

</div>

You have to do it like this @ducky  
scoutGenerator.destroy()  
and  
rightFence.destroy()  
You have to name the thing before the dot then you put the action afterwards. Its very similar to Hero.attack()

---

<div class="post-metadata">

**Author:** ![ducky](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ducky/32/9364_2.png) [@ducky](https://discourse.codecombat.com/u/ducky)\
**Post date:** [November 28, 2018, 9:27pm UTC](https://discourse.codecombat.com/t/help-cages-game-dev-2/16562/3 "2018-11-28T21:27:42Z")

</div>

Thank you for your help, but it still has the same message - except it has no idea what munchkinGenerator is.

---

<div class="post-metadata">

**Author:** ![Amira\_Saadi](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/amira_saadi/32/19105_2.png) [@Amira\_Saadi](https://discourse.codecombat.com/u/Amira_Saadi)\
**Post date:** [January 22, 2021, 6:21am UTC](https://discourse.codecombat.com/t/help-cages-game-dev-2/16562/4 "2021-01-22T06:21:25Z")

</div>

is it different for javascript? cause I notice there are hashtags which means that this is python, and the defeat() isn’t working for me, should I try destroy?

---

<div class="post-metadata">

**Author:** ![CodingCombat103](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/codingcombat103/32/20895_2.png) [@CodingCombat103](https://discourse.codecombat.com/u/CodingCombat103)\
**Post date:** [March 7, 2021, 9:44pm UTC](https://discourse.codecombat.com/t/help-cages-game-dev-2/16562/6 "2021-03-07T21:44:22Z")

</div>

same with me @ducky!

---

<div class="post-metadata">

**Author:** ![CodingCombat103](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/codingcombat103/32/20895_2.png) [@CodingCombat103](https://discourse.codecombat.com/u/CodingCombat103)\
**Post date:** [March 7, 2021, 9:56pm UTC](https://discourse.codecombat.com/t/help-cages-game-dev-2/16562/7 "2021-03-07T21:56:53Z")

</div>

It says as one of the goals you should defeat 2 generators so do I do munchkinGenerator.defeat???

---

<div class="post-metadata">

**Author:** ![CodingCombat103](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/codingcombat103/32/20895_2.png) [@CodingCombat103](https://discourse.codecombat.com/u/CodingCombat103)\
**Post date:** [March 24, 2021, 4:24pm UTC](https://discourse.codecombat.com/t/help-cages-game-dev-2/16562/8 "2021-03-24T16:24:21Z")

</div>

hi this is my code

 ![image](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/3X/c/d/cdca9e0ed1c9e99b6ebd967d93e51210d7a69cc2.jpeg)

---

<div class="post-metadata">

**Author:** ![CodingCombat103](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/codingcombat103/32/20895_2.png) [@CodingCombat103](https://discourse.codecombat.com/u/CodingCombat103)\
**Post date:** [March 24, 2021, 4:36pm UTC](https://discourse.codecombat.com/t/help-cages-game-dev-2/16562/10 "2021-03-24T16:36:05Z")

</div>

right here @ducky you have to change the "defeat(scoutGenerator), destroy(rightFence),defeat(munchkinGenerator), and destroy(leftFence) into scoutGenerator.defeat(),rightFence.destroy(),munckinGenerator.defeat(), and leftFence.destroy() to complete the level

> [@ducky](#):
>
> ```python
> def onSpawn(event):
> unit = event.target
> if unit.type == "scout":
> game.scoutsSpawned += 1
> if game.scoutsSpawned >= 3:
> # Defeat scoutGenerator with the defeat() method.
> defeat(scoutGenerator)
> # Destroy rightFence with the destroy() method.
> destroy(rightFence)
> pass
> if unit.type == "munchkin":
> game.munchkinsSpawned += 1
> if game.munchkinsSpawned >= 2:
> # Defeat munchkinGenerator.
> defeat(muchkinGenerator)
> # Destroy the leftFence.
> destroy(leftFence )
> pass
> 
> ```

---

<div class="post-metadata">

**Author:** ![Eric\_Tang](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/eric_tang/32/15310_2.png) [@Eric\_Tang](https://discourse.codecombat.com/u/Eric_Tang)\
**Post date:** [March 25, 2021, 1:14am UTC](https://discourse.codecombat.com/t/help-cages-game-dev-2/16562/11 "2021-03-25T01:14:59Z")

</div>

Hi. Ducky is not active anymore so your just wasting a post.

---

<div class="post-metadata">

**Author:** ![CodingCombat103](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/codingcombat103/32/20895_2.png) [@CodingCombat103](https://discourse.codecombat.com/u/CodingCombat103)\
**Post date:** [March 25, 2021, 9:35pm UTC](https://discourse.codecombat.com/t/help-cages-game-dev-2/16562/12 "2021-03-25T21:35:29Z")

</div>

oh really@Eric\_Tang?

---

<div class="post-metadata">

**Author:** ![CodingCombat103](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/codingcombat103/32/20895_2.png) [@CodingCombat103](https://discourse.codecombat.com/u/CodingCombat103)\
**Post date:** [March 25, 2021, 9:35pm UTC](https://discourse.codecombat.com/t/help-cages-game-dev-2/16562/13 "2021-03-25T21:35:56Z")

</div>

does that mean he is not in the forum anymore?

---

<div class="post-metadata">

**Author:** ![Eric\_Tang](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/eric_tang/32/15310_2.png) [@Eric\_Tang](https://discourse.codecombat.com/u/Eric_Tang)\
**Post date:** [March 25, 2021, 10:54pm UTC](https://discourse.codecombat.com/t/help-cages-game-dev-2/16562/14 "2021-03-25T22:54:04Z")

</div>

Well . . . Yes and no. Yes he does not come on the forum anymore but no, his account is not deleted.

---

<div class="post-metadata">

**Author:** ![CodingCombat103](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/codingcombat103/32/20895_2.png) [@CodingCombat103](https://discourse.codecombat.com/u/CodingCombat103)\
**Post date:** [March 25, 2021, 10:55pm UTC](https://discourse.codecombat.com/t/help-cages-game-dev-2/16562/15 "2021-03-25T22:55:02Z")

</div>

ok thanks for the tip(Is that actually a tip IDK but I gues it is
