# Editing the Level Code

**URL:** <https://discourse.codecombat.com/t/editing-the-level-code/11948>\
**Category:** Artisan\
**Created:** [July 12, 2017, 6:45pm UTC](https://discourse.codecombat.com/t/editing-the-level-code/11948 "2017-07-12T18:45:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![\_TD\_RodYT](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/_td_rodyt/32/6285_2.png) [@\_TD\_RodYT](https://discourse.codecombat.com/u/_TD_RodYT)\
**Post date:** [July 12, 2017, 6:45pm UTC](https://discourse.codecombat.com/t/editing-the-level-code/11948/1 "2017-07-12T18:45:02Z")

</div>

I’m creating my own level with the level editor.

I have asked this question before, but I’m still confused.

What part of the code should I change and what should I change it to?

Here’s what I want to do:

- Make the Ogres passive until hero attacks it
- Make the Ogre drop a gold key upon death
- Make another Ogre kill the hero upon death
- Randomly generate which ogre will kill the hero and which one will drop the key
- Assign the ogre a special Id

---

<div class="post-metadata">

**Author:** ![Serg](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/serg/32/3260_2.png) [@Serg](https://discourse.codecombat.com/u/Serg)\
**Post date:** [July 12, 2017, 8:36pm UTC](https://discourse.codecombat.com/t/editing-the-level-code/11948/2 "2017-07-12T20:36:06Z")

</div>

We have a thing called a “Referee” which looks like a well. Add that to your level and navigate to it’s components (double-click on it) and go to the “misc.Referee” component. Inside the Referee’s misc.Referee component click the [+] and add “extraCode”. Now, finally, inside that extraCode you can add these custom functionality. Note that this is in CoffeeScript, not JavaScript/Python/Lua

`setUpLevel` happens once before the level starts.  
`onFirstFrame` happens during the first frame of the level.  
`chooseAction` happens every frame of the level.
