// Wood grid in goblin jail to be broken by player.

ON INIT {
 SET_PLATFORM ON
 SETNAME [description_trapdoor]
 SET_SHADOW OFF
 SET MATERIAL WOOD
 LOADANIM ACTION1 "jail_wood_break"
 SET §broken 0
 SET §talk 0
 SET §norepeat 0				// Used to check speach frequency
 SET §speaking 0				// Used to know if player is already speaking
 SET_CONTROLLED_ZONE TRAP_JAIL
 ACCEPT
}

ON RELOAD {
 IF (§broken == 1) DESTROY SELF 
 ACCEPT
}

ON HIT {
 IF (§broken == 1) ACCEPT
 UNSET_CONTROLLED_ZONE TRAP_JAIL
// SENDEVENT TADA4 PLAYER ""	// Too much noise
 PLAYANIM ACTION1
 COLLISION OFF
 SET_INTERACTIVITY NONE
 SET §broken 1
 SENDEVENT CUSTOM HUMAN_BASE_0028 "DOOR_OPEN"
 SENDEVENT CUSTOM LIGHT_DOOR_0074 "BROKEN"
 TIMERbreak -m 1 500 GOTO HIDE
 ACCEPT
}

ON CONTROLLEDZONE_ENTER {
 IF (§talk == 0) ACCEPT
 IF (^$PARAM1 != PLAYER) ACCEPT
 TIMERpouet 1 1 HALO -f
 HALO -ocs 0.5 0.5 1 60
 SET §talk 1
 PLAY "system"
 UNSET_CONTROLLED_ZONE TRAP_JAIL
 TIMERbob -m 1 500 HEROSAY [system_tutorial_7]
 QUEST [system_tutorial_7]
 ACCEPT
}

ON ACTION {
  IF (§speaking == 1) ACCEPT
  SET §speaking 1
  IF (§norepeat > 4) SET §norepeat 0
  IF (§norepeat > 0) {
    INC §norepeat 1
    ACCEPT
  }
 INC §norepeat 1
 SPEAK -p [player_wontopen] SET §speaking 0
 ACCEPT
}

ON CUSTOM {
 IF (^$PARAM1 == "TALK") SET §talk 1
 ACCEPT
}

>>HIDE
 SENDEVENT -ri ACTIVATE_PHYSICS 500 "" 
 ADD_XP 904
 OBJECT_HIDE SELF ON
 UNSET_CONTROLLED_ZONE TRAP_JAIL
 DESTROY ME
 ACCEPT