/* CONTENTS */
/* Dream timer */
/* PC talks */
///* start the timer */
///* PC talks */
/* Killed Mendas */
/* Xzar talks to Yeslick just after flooding mines */
/* killed the lich called davaeron 3 version of the talk */

/* 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

///* start the timer */
IF %BGT_VAR%
InParty(Myself)
Global("X#XzPCTimerStarted","GLOBAL",0)
THEN
RESPONSE #100
RealSetGlobalTimer("X#XzFriendTalkTime","GLOBAL",6000)
SetGlobal("X#XzPCTimerStarted","GLOBAL",1)
END

///* PC talks */
IF %BGT_VAR%
RealGlobalTimerExpired("X#XzFriendTalkTime","GLOBAL")
GlobalGT("%bgdreams%","GLOBAL",1)
InParty(Myself)
CombatCounter(0)
!See([ENEMY])
InMyArea(Player1)
!StateCheck(Myself,CD_STATE_NOTVALID)
!StateCheck(Player1,CD_STATE_NOTVALID)
OR(2)
Global("X#XzFriendTalk","GLOBAL",0)
Global("X#XzFriendTalk","GLOBAL",2)
THEN
RESPONSE #100
IncrementGlobal("X#XzFriendTalk","GLOBAL",1)
END

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

IF %BGT_VAR%
InParty(Myself)
InMyArea(Player1)
!StateCheck(Myself,CD_STATE_NOTVALID)
!StateCheck(Player1,CD_STATE_NOTVALID)
Gender(Player1,FEMALE)
Global("X#XzFriendTalk","GLOBAL",3)
THEN
RESPONSE #100
PlaySong(0)
PlaySound("xzar99")
StartDialogueNoSet(Player1)
END

/* Killed Mendas */
IF %BGT_VAR%
Dead("mendas3")
AreaCheck("%UlgothsBeard_MendasHouse%")
Global("X#XzarMendas","GLOBAL",0)
InParty(Myself)
CombatCounter(0)
!See([ENEMY])
InMyArea(Player1)
!StateCheck(Myself,CD_STATE_NOTVALID)
!StateCheck(Player1,CD_STATE_NOTVALID)
THEN
RESPONSE #100
SetGlobal("X#XzarMendas","GLOBAL",1)
END

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

/* Xzar talks to Yeslick just after flooding mines */
IF %BGT_VAR%
InParty("yeslick")
AreaCheck("%CloakwoodMines%")
Global("X#XZYE1","LOCALS",0)
InParty(Myself)
InMyArea("yeslick")
OR(2)
Global("FLOODED","GLOBAL",1)
Global("FLOODED","GLOBAL",2)
!StateCheck("yeslick",CD_STATE_NOTVALID)
!StateCheck(Myself,CD_STATE_NOTVALID)
THEN
RESPONSE #100
SetGlobal("X#XZYE1","LOCALS",1)
END

IF %BGT_VAR%
Global("X#XZYE1","LOCALS",1)
InParty("yeslick")
InParty(Myself)
InMyArea("yeslick")
CombatCounter(0)
!See([ENEMY])
!StateCheck("yeslick",CD_STATE_NOTVALID)
!StateCheck(Myself,CD_STATE_NOTVALID)
THEN
RESPONSE #100
PlaySong(0)
PlaySound("xzar99")
StartDialogueNoSet(Player1)
END

/* killed the lich called davaeron 3 version of the talk */
IF %BGT_VAR%
Dead("davaeorn")
InParty("%IMOEN_DV%")
Global("X#XZIM3","GLOBAL",0)
!InParty("jaheira")
!InParty("khalid")
InParty(Myself)
CombatCounter(0)
!See([ENEMY])
InMyArea("%IMOEN_DV%")
!StateCheck("%IMOEN_DV%",CD_STATE_NOTVALID)
!StateCheck(Myself,CD_STATE_NOTVALID)
THEN
RESPONSE #100
SetGlobal("X#XZIM3","GLOBAL",1)
END

IF %BGT_VAR%
InParty("%IMOEN_DV%")
Global("X#XZIM3","GLOBAL",1)
InParty(Myself)
CombatCounter(0)
!See([ENEMY])
InMyArea("%IMOEN_DV%")
!StateCheck("%IMOEN_DV%",CD_STATE_NOTVALID)
!StateCheck(Myself,CD_STATE_NOTVALID)
THEN
RESPONSE #100
StartDialogueNoSet("%IMOEN_DV%")
END

/* Davaeron Death Responses by Jaheira, Khalid alive */
IF %BGT_VAR%
InParty("jaheira")
InParty("khalid")
Dead("davaeorn")
Global("X#XZJA2","GLOBAL",0)
InMyArea("jaheira")
InMyArea("khalid")
InParty(Myself)
CombatCounter(0)
!See([ENEMY])
!StateCheck("jaheira",CD_STATE_NOTVALID)
!StateCheck("khalid",CD_STATE_NOTVALID)
!StateCheck(Myself,CD_STATE_NOTVALID)
THEN
RESPONSE #100
SetGlobal("X#XZJA2","GLOBAL",1)
END

IF %BGT_VAR%
InParty("jaheira")
InParty(Myself)
Global("X#XZJA2","GLOBAL",1)
CombatCounter(0)
!See([ENEMY])
!StateCheck("jaheira",CD_STATE_NOTVALID)
!StateCheck(Myself,CD_STATE_NOTVALID)
THEN
RESPONSE #100
StartDialogueNoSet("jaheira")
END

/* Davaeron Death Responses by Jaheira, Khalid dead */

IF %BGT_VAR%
InParty("jaheira")
Dead("khalid")
Dead("davaeorn")
Global("X#XZJA3","GLOBAL",0)
InParty(Myself)
CombatCounter(0)
!See([ENEMY])
!StateCheck("jaheira",CD_STATE_NOTVALID)
!StateCheck(Myself,CD_STATE_NOTVALID)
THEN
RESPONSE #100
SetGlobal("X#XZJA3","GLOBAL",1)
END

IF %BGT_VAR%
InParty("jaheira")
Global("X#XZJA3","GLOBAL",1)
InParty(Myself)
CombatCounter(0)
!See([ENEMY])
!StateCheck("jaheira",CD_STATE_NOTVALID)
!StateCheck(Myself,CD_STATE_NOTVALID)
THEN
RESPONSE #100
StartDialogueNoSet("jaheira")
END