ON INIT {
 SET Łtype "human_ylside"
 SET Łkey_carried "KEY_BASE_0008"
 SET §firsttime 0
 SET §guessing 0
 SET §noattack 0				// Used to check if npc attacks when player open door without password
 SET §underattack 0			// Used to check if guards attack npc
 ACCEPT
}

ON INITEND {
 SET §enemy 0
 SET_EVENT HEAR OFF
 SET_CONTROLLED_ZONE YLSIDE_ATTACK
 SETNAME [description_human_male]
 ACCEPT
}

ON RELOAD {
  IF (#PLAYER_ON_QUEST > 3) DESTROY SELF
  IF (§underattack == 1) {
    SENDEVENT TARGET_DEATH HUMAN_BASE_0072 ""
    SENDEVENT TARGET_DEATH HUMAN_BASE_0073 ""
    SENDEVENT TARGET_DEATH HUMAN_BASE_0074 ""
    SENDEVENT TARGET_DEATH HUMAN_BASE_0075 ""
    SENDEVENT TARGET_DEATH HUMAN_BASE_0076 ""
    SENDEVENT TARGET_DEATH HUMAN_BASE_0077 ""
    DESTROY SELF
    ACCEPT
  }
 ACCEPT
}

ON CONTROLLEDZONE_ENTER {
  IF (§enemy == 1) ACCEPT
  IF (^$PARAM1 != PLAYER) ACCEPT
  IF (§noattack == 1) {
     UNSET_CONTROLLED_ZONE YLSIDE_ATTACK
     ACCEPT
  }
 SET §enemy 1
 SENDEVENT ATTACK_PLAYER SELF ""
 UNSET_CONTROLLED_ZONE YLSIDE_ATTACK
 ACCEPT
}

ON CUSTOM {
  IF (^$PARAM1 == "KNOCK") {
    SET_PLAYER_CONTROLS OFF
    TELEPORT -p MARKER_0885
    TIMERlook -m 1 10 PLAYERLOOKAT LAMP_HUMAN_SNAKE2_0001
    SPEAK [ylside_password] GOTO DIALOGUE
    ACCEPT
  }
  IF (^$PARAM1 == "GUESSING") {
    SET §guessing 1
    ACCEPT
  }
  IF (^$PARAM1 == "UNDER_ATTACK") {
    SET §underattack 1
    ACCEPT
  }
 ACCEPT
}

>>DIALOGUE
  IF (#PLAYER_KNOWS_PASSWORD == 1) {
    SET §noattack 1
    SPEAK -p [Player_password] SENDEVENT CUSTOM LIGHT_DOOR_0073 "OPEN"
    MAPMARKER -r [addmarker_secret_temple]
    SET #PLAYER_KNOWS_PASSWORD 2
    TIMERcontrols 1 3 SET_PLAYER_CONTROLS ON
    ACCEPT
  }
  IF (§guessing == 1) {
	SPEAK -p [Player_password_fake] SET_PLAYER_CONTROLS ON
    ACCEPT
  }
  IF (§firsttime == 0) {
    SPEAK -p [player_wouldyouopen] SET_PLAYER_CONTROLS ON
    SENDEVENT CUSTOM HUMAN_BASE_0097 "PLAYER_CURIOUS_ABOUT_DOOR"
    SET §firsttime 1
    ACCEPT
  }
  IF (§firsttime == 1) {
	SPEAK -p [Player_not_this_way] SET_PLAYER_CONTROLS ON
    ACCEPT
  }
 ACCEPT