// Boss, the Head Warden

ON INIT {
 SET §zuk_dead 0						// Used to check if Zuk is dead
 SET §little_gob_dead 0					// Used to check if little gob is dead
 SET §reflection_mode 0
 SET £type "goblin_lord"
 SET £key_carried "KEY_BASE_0005portcullis"
 ACCEPT
}

ON INITEND {
 SET_NPC_STAT damages 18
 SET_NPC_STAT aimtime 800
 SET_NPC_STAT life 20
 SET_NPC_STAT damages 8
 SETWEAPON SHORT_SWORD
 SENDEVENT -ir DURABILITY 100 "51"
 SET £youmad []
 SET_CONTROLLED_ZONE ZUK_ZONE
 BEHAVIOR FRIENDLY
 SETTARGET GOBLIN_BASE_0010
 INVENTORY ADD "JEWELRY\\GOLD_COIN\\GOLD_COIN"
 ACCEPT
}

ON GAME_READY {
 SET_NPC_STAT armor_class 10
 SET_NPC_STAT absorb 15
 ACCEPT
} 

ON LOAD {
 USE_MESH "goblin_lord\goblin_lord.teo"
 ACCEPT
}

ON RELOAD {
 SET §enemy 1
 IF (§little_gob_dead == 0) SPEAK [GoblinLord_not_cleaner] SENDEVENT CUSTOM GOBLIN_BASE_0010 "THREAT"
 ACCEPT
}

ON DIE {
IF (#BOSS_ZUK == 1) ADD_XP 70
ACCEPT
}

ON REACHEDTARGET {
  IF (^TARGET == MARKER_0400) {
    IF (§targ == 1) ACCEPT //means that he is attacking the lord
    IF (§zuk_dead == 1) {
      BEHAVIOR FRIENDLY
      SETTARGET GOBLIN_BASE_0049
      SENDEVENT LOOK_FOR SELF ""
      ACCEPT
    }
    SET §targ 1
    BEHAVIOR FRIENDLY
    SETTARGET GOBLIN_BASE_0049
    SENDEVENT CUSTOM GOBLIN_BASE_0049 "LISTEN"
	SET_XP_VALUE 0
	SET #BOSS_ZUK 1
	SETNAME [description_boss]
    SPEAK -a [GoblinLord_zuk_insult] SENDEVENT CUSTOM GOBLIN_BASE_0049 "ACCUSED"
    ACCEPT
  }
 ACCEPT
}

ON CUSTOM {
  IF (§fighting_mode != 0) ACCEPT
  IF (§looking_for != 0) ACCEPT
  IF (^$PARAM1 == "TRASH_TALK" ) {
    IF (^TARGET == GOBLIN_BASE_0049) ACCEPT
    SPEAK [GoblinLord_not_cleaner] SENDEVENT CUSTOM GOBLIN_BASE_0010 "THREAT"
    ACCEPT
  }
  IF (^$PARAM1 == "LOOK" ) {
    BEHAVIOR MOVE_TO
    SETTARGET MARKER_0400
    SPEAK [GoblinLord_irritated_about_zuk] SENDEVENT CUSTOM GOBLIN_BASE_0010 "COMON"
    ACCEPT
  }
  IF (^$PARAM1 == "MOANAGAIN") {
    SET_CONTROLLED_ZONE ZUK_ZONE
    ACCEPT
  }
  IF (^$PARAM1 == "BOSS_ATTACK") {
    SPEAK [GoblinLord_zuk_attack] NOP
    TIMERpunch 1 2 GOTO PUNCH
    ACCEPT
   }
  IF (^$PARAM1 == "ZUK_DEAD") {
    SET §zuk_dead 1
    ACCEPT
  }
  IF (^$PARAM1 == "LITTLE_GOB_DEAD") {
    SET §little_gob_dead 1
    ACCEPT
  }
 ACCEPT
}

ON CONTROLLEDZONE_ENTER {
 IF (^$PARAM1 != PLAYER) ACCEPT
 IF (§fighting_mode != 0) ACCEPT
 IF (§looking_for != 0) ACCEPT
 UNSET_CONTROLLED_ZONE ZUK_ZONE
 SPEAK [GoblinLord_bum] SENDEVENT CUSTOM GOBLIN_BASE_0010 "WARNING"
 ACCEPT
}

ON TARGET_DEATH {
  IF (^$PARAM1 != PLAYER) {
    SETGROUP -r £friend
    SET £friend "goblin"
    SETGROUP £friend
    BEHAVIOR GO_HOME
    SETTARGET PLAYER
    ACCEPT
  }
 ACCEPT
}

>>PUNCH
 SENDEVENT CUSTOM GOBLIN_BASE_0049 "LORD_ATTACK"
 SETGROUP -r £friend
 SET £friend "BOSS"
 SETGROUP £friend
 WEAPON ON
 ADD_XP 300
 TIMERds 1 1 BEHAVIOR -f MOVE_TO SETTARGET GOBLIN_BASE_0049
 ACCEPT