/* CONTENTS */
/* Dream timer */
/* PC talks */
///* Setting the timer */
///* PC talk 1 */
///* PC talk 2 - requires Imoen */
/* Viconia/Kivan Fight to Death */

/* 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 */
///* Setting the timer */
IF %BGT_VAR%
InParty(Myself)
Global("X#ViPCTimerStarted","GLOBAL",0)
THEN
RESPONSE #100
RealSetGlobalTimer("X#ViFriendTalkTime","GLOBAL",1800)
SetGlobal("X#ViPCTimerStarted","GLOBAL",1)
END

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

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

///* PC talk 2 - requires Imoen */
IF %BGT_VAR%
RealGlobalTimerExpired("X#ViFriendTalkTime","GLOBAL")
InParty("%IMOEN_DV%")
Global("X#ViFriendTalk","GLOBAL",2)
InParty(Myself)
CombatCounter(0)
!See([ENEMY])
!StateCheck(Myself,CD_STATE_NOTVALID)
!StateCheck(Player1,CD_STATE_NOTVALID)
!StateCheck("%IMOEN_DV%",CD_STATE_NOTVALID)
See(Player1)
See("%IMOEN_DV%")
THEN
RESPONSE #100
IncrementGlobal("X#ViFriendTalk","GLOBAL",1)
END

IF %BGT_VAR%
RealGlobalTimerExpired("X#ViFriendTalkTime","GLOBAL")
InParty("%IMOEN_DV%")
Global("X#ViFriendTalk","GLOBAL",3)
InParty(Myself)
CombatCounter(0)
!See([ENEMY])
!StateCheck(Myself,CD_STATE_NOTVALID)
!StateCheck(Player1,CD_STATE_NOTVALID)
!StateCheck("%IMOEN_DV%",CD_STATE_NOTVALID)
See(Player1)
See("%IMOEN_DV%")
THEN
RESPONSE #100
PlaySong(0)
PlaySound("vicon99")
StartDialogueNoSet(Player1)
END

/* Viconia/Kivan Fight to Death */
IF %BGT_VAR%
Dead("kivan")
Global("P#KiViFi","GLOBAL",1)
InParty(Myself)
CombatCounter(0)
!See([ENEMY])
See(Player1)
!StateCheck(Myself,CD_STATE_NOTVALID)
!StateCheck(Player1,CD_STATE_NOTVALID)
THEN
RESPONSE #100
SetGlobal("P#KiViFi","GLOBAL",2)
END

IF %BGT_VAR%
Global("P#KiViFi","GLOBAL",2)
InParty(Myself)
CombatCounter(0)
!See([ENEMY])
See(Player1)
!StateCheck(Myself,CD_STATE_NOTVALID)
!StateCheck(Player1,CD_STATE_NOTVALID)
THEN
RESPONSE #100
PlaySong(0)
PlaySound("vicon99")
StartDialogueNoSet(Player1)
END
