/* Extend Tiax's script with this */
/* Cue as the PC exits the Blade and Stars tavern, but only after securing Belgin's safety from the bounty hunters by killing them or convincing them to go home */

IF %BGT_VAR%
Global("X#TiaxQuest","GLOBAL",5)
Global("X#BelginPlacement","GLOBAL",8)
Global("X#TiaxQuestCyric","GLOBAL",0)
THEN
RESPONSE #100
SetGlobal("X#TiaxQuestCyric","GLOBAL",1)
END

IF %BGT_VAR%
Global("X#TiaxQuestCyric","GLOBAL",1)
!AreaCheck("%SEBaldursGate_Blade&Stars_L3%")
!AreaCheck("%SEBaldursGate_Blade&Stars_L2%")
!AreaCheck("%SEBaldursGate_Blade&Stars_L1%")
InParty(Myself)
InMyArea(Player1)
!StateCheck(Myself,CD_STATE_NOTVALID)
!StateCheck(Player1,CD_STATE_NOTVALID)
THEN
RESPONSE #100
StartDialogueNoSet(Myself)
END

IF %BGT_VAR%
Global("X#TiaxQuest","GLOBAL",5)
Global("X#BelginPlacement","GLOBAL",8)
!Dead("x#belgin")
InParty(Myself)
InMyArea(Player1)
!StateCheck(Myself,CD_STATE_NOTVALID)
!StateCheck(Player1,CD_STATE_NOTVALID)
Global("X#TiaxQuestComplain","GLOBAL",0)
GlobalTimerExpired("X#TiaxQuestTime7","GLOBAL")
THEN
RESPONSE #100
SetGlobal("X#TiaxQuestComplain","GLOBAL",1)
StartDialogueNoSet(Myself)
END

IF %BGT_VAR%
Global("X#TiaxQuestComplain","GLOBAL",1)
InParty(Myself)
InMyArea(Player1)
!StateCheck(Myself,CD_STATE_NOTVALID)
!StateCheck(Player1,CD_STATE_NOTVALID)
THEN
RESPONSE #100
StartDialogueNoSet(Myself)
END

/* Quit the party prep */
IF %BGT_VAR%
Global("X#TiaxQuest","GLOBAL",5)
Global("X#BelginPlacement","GLOBAL",8)
!Dead("x#belgin")
InParty(Myself)
InMyArea(Player1)
!StateCheck(Myself,CD_STATE_NOTVALID)
!StateCheck(Player1,CD_STATE_NOTVALID)
Global("X#TiaxQuestComplain","GLOBAL",2)
GlobalTimerExpired("X#TiaxQuestTime5","GLOBAL")
THEN
RESPONSE #100
SetGlobal("X#TiaxQuestComplain","GLOBAL",3)
END

/* Quit the party talk */
IF %BGT_VAR%
Global("X#TiaxQuestComplain","GLOBAL",3)
!Dead("x#belgin")
InParty(Myself)
InMyArea(Player1)
!StateCheck(Myself,CD_STATE_NOTVALID)
!StateCheck(Player1,CD_STATE_NOTVALID)
THEN
RESPONSE #100
StartDialogueNoSet(Myself)
END

IF %BGT_VAR%
Global("X#TiaxQuestTiaxQuits","GLOBAL",1)
THEN
RESPONSE #100
SetGlobal("X#TiaxQuestTiaxQuits","GLOBAL",2)
ChangeAIScript("",DEFAULT)
SetLeavePartyDialogFile()
LeaveParty()
EscapeArea()
END

/* The party let Belgin go in Tiax' presence. Bad party! */
IF %BGT_VAR%
Global("X#TiaxQuestComplain","GLOBAL",7)
GlobalGT("X#TiaxQuest","GLOBAL",5)
!Dead("x#belgin")
!InMyArea("x#belgin")
InParty(Myself)
InMyArea(Player1)
!StateCheck(Myself,CD_STATE_NOTVALID)
!StateCheck(Player1,CD_STATE_NOTVALID)
THEN
RESPONSE #100
StartDialogueNoSet(Myself)
END