// Polsius in tavern

ON INIT {
 SETNAME [description_polsius]
 SET £friend "TAVERN"
 SET §cangive 0
 SET §cant_talk 0		// Used to check if Tizzy is talking.
 SET §drinking 0		// Used to know if npc is drinking and player cannot talk to him.
 ACCEPT
}

ON INITEND {
 INVENTORY ADDMULTI "JEWELRY\\GOLD_COIN\\GOLD_COIN" 6
 TWEAK head "goblin_nohelm"
 TWEAK SKIN "npc_Goblin_base_body" "npc_Goblin_polsius"
 LOADANIM ACTION2 "Goblin_normal_sit_cyclem"
 LOADANIM ACTION3 "human_normal_drink_cycle2"
 LOADANIM -p ACTION1 "human_normal_sit_cycle"
 SET §reflection_mode 0
 SET §enemy 0
 PHYSICAL OFF
 SETWEAPON Dagger_iron
 SET_NPC_STAT damages 10
 SENDEVENT -ir DURABILITY 100 "41"
 IF (#DEBUG == 1) ACCEPT
 OBJECT_HIDE -m SELF ON
 ACCEPT
}

ON RELOAD {
 SETNAME [description_polsius]
  IF (#POLSIUS_TAVERN == 2) ACCEPT
  IF (#PLAYER_ON_QUEST > 3) {
    DETACH MUG_FULL_0003 SELF
    SET £attached_object "NONE"
    DESTROY MUG_FULL_0003
    SET §reflection_mode 1
    PHYSICAL ON
    BEHAVIOR MOVE_TO
    SETTARGET MARKER_0197
    ACCEPT
  }
  IF (#POLSIUS_TAVERN == 1) {
    OBJECT_HIDE -m SELF OFF
    OBJECT_HIDE MUG_FULL_0003 OFF
    ATTACH MUG_FULL_0003 "BEER_ATTACH" SELF "left_attach"
    SET £attached_object "MUG_FULL_0003"
    PLAYANIM -l ACTION2
    SET §frozen 1
    TIMERdrink -i 0 30 GOTO DRINK
    ACCEPT
  }
 ACCEPT
}

ON REACHEDTARGET {
  IF (^TARGET == MARKER_0197) {
    OBJECT_HIDE SELF ON
    TIMERdestroy 1 5 DESTROY ME
    ACCEPT
  }
 ACCEPT
}

ON CHAT {
  IF (§drinking == 1) {
    SPEAK -p [player_not_now] NOP
    ACCEPT
  }
  IF (§cant_talk == 1) ACCEPT
  IF (^SPEAKING == 1) ACCEPT
  IF (§chatpos == 3) {
    SPEAK [Polsius_misc_tavern] NOP
    ACCEPT
  }
  IF (#need_form == 1) {
    IF (#POLSIUS_SIGNED == 0) {
      IF (§chatpos == 0) {
        GOTO DIALOGUE1 
        ACCEPT
      }
      IF (§chatpos == 1) {
        SPEAK [Polsius_blank_insist] NOP
        ACCEPT
      }
     ACCEPT
    }
   GOTO DIALOGUE2   
   ACCEPT
  }
 GOTO DIALOGUE2
 ACCEPT
}

ON CUSTOM {
 IF (^$PARAM1 == "TALK_OFF") SET §cant_talk 1
 IF (^$PARAM1 == "TALK_ON") SET §cant_talk 0
 ACCEPT
}

ON DIE {
 SET #POLSIUS_TAVERN 2
 ACCEPT
}

ON COMBINE {
  IF (§drinking == 1) {
    SPEAK -p [player_not_now] NOP
    ACCEPT
  }
  IF (§cant_talk == 1) ACCEPT
  IF (§cangive == 0) ACCEPT
  IF (^$PARAM1 ISCLASS "blank_form") {
    SET_PLAYER_CONTROLS OFF
    PLAYER_INTERFACE -s HIDE
    CINEMASCOPE -s ON
    DESTROY ~^$PARAM1~
    SPEAK [Polsius_sign_form] GOTO AFTER_SIGNED 
    ACCEPT
  }
 ACCEPT
}

>>AFTER_SIGNED 
 PLAY "system"
 INVENTORY PLAYERADD "\\QUEST_ITEM\\SIGNED_FORM\SIGNED_FORM"
 HEROSAY [system_object_received]
 SET #POLSIUS_SIGNED 1
 SET #need_form 2
 PLAYER_INTERFACE -s SHOW
 CINEMASCOPE -s OFF
 SET_PLAYER_CONTROLS ON
 ACCEPT

>>DRINK
 IF (^SPEAKING == 1) ACCEPT
 SET §drinking 1
 PLAYANIM -2e ACTION3 GOTO DRINK2
 ACCEPT

>>DRINK2
 SET §drinking 0
 PLAYANIM -2e NONE PLAYANIM -l ACTION2
 ACCEPT

>>DIALOGUE1
 TELEPORT -p MARKER_0290
 TIMERlookat -m 1 10 PLAYERLOOKAT ME
 SET_PLAYER_CONTROLS OFF
 PLAYER_INTERFACE -s HIDE
 CINEMASCOPE -s ON
 SENDEVENT ACTIVATE CAMERA_0143 ""
 SET #SHUT_UP 1
 SPEAK -p [player_can_you_sign] GOTO DIALOGUE1_2
 ACCEPT

>>DIALOGUE1_2
 SET §cangive 1
 CAMERAACTIVATE NONE
 SPEAK [Polsius_give_me_blank] GOTO DIALOGUE1_3
 ACCEPT

>>DIALOGUE1_3
 PLAYER_INTERFACE -s SHOW
 CINEMASCOPE -s OFF
 SET_PLAYER_CONTROLS ON
 SET #SHUT_UP 0
 SET §chatpos 1
 ACCEPT

>>DIALOGUE2
 TELEPORT -p MARKER_0740
 PLAYANIM -pl ACTION1
 TIMERlookat -m 1 10 PLAYERLOOKAT ME
 SET_PLAYER_CONTROLS OFF
 PLAYER_INTERFACE -s HIDE
 CINEMASCOPE -s ON
 SENDEVENT CUSTOM CAMERA_0143 "GO"
 SET #SHUT_UP 1
 SPEAK -p [Player_polsius_explain1] GOTO DIALOGUE2_2
 ACCEPT

>>DIALOGUE2_2
 CAMERAACTIVATE NONE
 SPEAK -c SIDE_L PLAYER 5 5 90 90 0 [Polsius_explain1] GOTO DIALOGUE2_3
 ACCEPT

>>DIALOGUE2_3
 SPEAK -pc SIDE_R SELF 5 5 60 60 5 [Player_polsius_explain2] GOTO DIALOGUE2_4
 ACCEPT

>>DIALOGUE2_4
 SPEAK -c SIDE_L PLAYER 5 100 90 90 0 [polsius_explain2] GOTO DIALOGUE2_5
 ACCEPT

>>DIALOGUE2_5
 SPEAK -pc ZOOM 180 150 180 150 200 200 [Player_polsius_explain3] GOTO DIALOGUE2_6
 ACCEPT

>>DIALOGUE2_6
 SPEAK -c ZOOM 170 120 170 160 130 130 [Polsius_explain3] GOTO DIALOGUE2_7
 ACCEPT

>>DIALOGUE2_7
 SET #SHUT_UP 0
 PLAYER_INTERFACE -s SHOW
 CINEMASCOPE -s OFF
 SET_PLAYER_CONTROLS ON
 TELEPORT -p MARKER_0290
 PLAYANIM -p WAIT
 SET §chatpos 3
 ACCEPT