/* CONTENTS */
/* Dream timer */
/* PC talks */
///* PC talk timer */
///* PC talks 1, 2, 5 */
///* PC talk 3 */
///* PC talk 4 */
/* (after slaughtering Xzar’s superiors upstairs in Sorcerous Sundries */

/* Dream timer */
IF %BGT_VAR%
InParty(Myself)
Global("X#DreamTimerStarted","GLOBAL",0)
THEN
RESPONSE #100
RealSetGlobalTimer("X#DreamTalk","GLOBAL",180)
SetGlobal("X#DreamTimerStarted","GLOBAL",1)
END

/* PC talks */
///* PC talk timer */
IF %BGT_VAR%
InParty(Myself)
Global("X#XaPCTimerStarted","GLOBAL",0)
THEN
RESPONSE #100
RealSetGlobalTimer("X#XaFriendTalkTime","GLOBAL",1800)
SetGlobal("X#XaPCTimerStarted","GLOBAL",1)
END

///* PC talks 1, 2, 5 */
IF %BGT_VAR%
RealGlobalTimerExpired("X#XaFriendTalkTime","GLOBAL")
InParty(Myself)
CombatCounter(0)
!See([ENEMY])
!StateCheck(Player1,CD_STATE_NOTVALID)
!StateCheck(Myself,CD_STATE_NOTVALID)
See(Player1)
OR(3)
Global("X#XaFriendTalk","GLOBAL",0)
Global("X#XaFriendTalk","GLOBAL",2)
Global("X#XaFriendTalk","GLOBAL",8)
THEN
RESPONSE #100
IncrementGlobal("X#XaFriendTalk","GLOBAL",1)
END

IF %BGT_VAR%
InParty(Myself)
CombatCounter(0)
!See([ENEMY])
!StateCheck(Player1,CD_STATE_NOTVALID)
!StateCheck(Myself,CD_STATE_NOTVALID)
See(Player1)
OR(3)
Global("X#XaFriendTalk","GLOBAL",1)
Global("X#XaFriendTalk","GLOBAL",3)
Global("X#XaFriendTalk","GLOBAL",9)
THEN
RESPONSE #100
PlaySong(0)
PlaySound("xannn99")
StartDialogueNoSet(Player1)
END

///* PC talk 3 */
IF %BGT_VAR%
RealGlobalTimerExpired("X#XaFriendTalkTime","GLOBAL")
Global("X#XaFriendTalk","GLOBAL",4)
InParty(Myself)
!StateCheck(Myself,CD_STATE_NOTVALID)
See(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY])
AreaType(DUNGEON)
THEN
RESPONSE #100
IncrementGlobal("X#XaFriendTalk","GLOBAL",1)
END

IF %BGT_VAR%
Global("X#XaFriendTalk","GLOBAL",5)
InParty(Myself)
CombatCounter(0)
!See([ENEMY])
!StateCheck(Player1,CD_STATE_NOTVALID)
!StateCheck(Myself,CD_STATE_NOTVALID)
See(Player1)
THEN
RESPONSE #100
PlaySong(0)
PlaySound("xannn99")
StartDialogueNoSet(Player1)
END

///* PC talk 4 */
IF %BGT_VAR%
RealGlobalTimerExpired("X#XaFriendTalkTime","GLOBAL")
Global("X#XaFriendTalk","GLOBAL",6)
InParty(Myself)
!StateCheck(Myself,CD_STATE_NOTVALID)
See(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY])
AreaType(FOREST)
TimeOfDay(NIGHT)
THEN
RESPONSE #100
IncrementGlobal("X#XaFriendTalk","GLOBAL",1)
END

IF %BGT_VAR%
Global("X#XaFriendTalk","GLOBAL",7)
CombatCounter(0)
!See([ENEMY])
!StateCheck(Player1,CD_STATE_NOTVALID)
!StateCheck(Myself,CD_STATE_NOTVALID)
InMyArea(Player1)
THEN
RESPONSE #100
PlaySong(0)
PlaySound("xannn99")
StartDialogueNoSet(Player1)
END

/* (after slaughtering Xzar’s superiors upstairs in Sorcerous Sundries */
IF %BGT_VAR%
AreaCheck("%EBaldursGate_SorcerousSundries_L2%")
InParty("xzar")
InParty("montaron")
Dead("niemain")
Dead("oulam")
Dead("wheber")
Dead("william")
Global("X#XAXZ2","LOCALS",0)
InParty(Myself)
CombatCounter(0)
InMyArea("xzar")
InMyArea("montaron")
!StateCheck("xzar",CD_STATE_NOTVALID)
!StateCheck(Myself,CD_STATE_NOTVALID)
THEN
RESPONSE #100
SetGlobal("X#XAXZ2","LOCALS",1)
END

IF %BGT_VAR%
Global("X#XAXZ2","LOCALS",1)
InParty(Myself)
CombatCounter(0)
InMyArea("xzar")
InMyArea("montaron")
!StateCheck("xzar",CD_STATE_NOTVALID)
!StateCheck(Myself,CD_STATE_NOTVALID)
THEN
RESPONSE #100
StartDialogueNoSet("xzar")
END
