/* CONTENTS */
/* Dream timer */

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

/* Imoen talk */
IF %BGT_VAR%
InParty("%IMOEN_DV%")
Global("X#YEIM1","LOCALS",1)
Global("X#YEIM2","LOCALS",0)
InParty(Myself)
CombatCounter(0)
!See([ENEMY])
RealGlobalTimerExpired("X#DreamTalk","GLOBAL")
InMyArea("%IMOEN_DV%")
!StateCheck(Myself,CD_STATE_NOTVALID)
!StateCheck("%IMOEN_DV%",CD_STATE_NOTVALID)
THEN
RESPONSE #100
SetGlobal("X#YEIM2","LOCALS",1)
RealSetGlobalTimer("X#DreamTalk","GLOBAL",180)
END

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


/* Yeslick talks to PC in the mines %CloakwoodMines_L3% */
IF %BGT_VAR%
InParty(Myself)
Global("X#YEPC1","LOCALS",0)
AreaCheck("%CloakwoodMines_L3%")
THEN
RESPONSE #100
SetGlobal("X#YEPC1","LOCALS",1)
END

IF %BGT_VAR%
Global("X#YEPC1","LOCALS",1)
AreaCheck("%CloakwoodMines_L3%")
InParty(Myself)
CombatCounter(0)
!See([ENEMY])
See(Player1)
!StateCheck(Myself,CD_STATE_NOTVALID)
!StateCheck(Player1,CD_STATE_NOTVALID)
THEN
RESPONSE #100
SetGlobal("X#YEPC1","LOCALS",2)
END

IF %BGT_VAR%
Global("X#YEPC1","LOCALS",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("yesli99")
StartDialogueNoSet(Player1)
END

/* Yeslick speaks after guards killed in %CloakwoodMines_L3% */
IF %BGT_VAR%
InParty(Myself)
Global("X#YEPC2","LOCALS",0)
Dead("iron11")
THEN
RESPONSE #100
SetGlobal("X#YEPC2","LOCALS",1)
END

IF %BGT_VAR%
Global("X#YEPC2","LOCALS",1)
InParty(Myself)
CombatCounter(0)
!See([ENEMY])
See(Player1)
!StateCheck(Myself,CD_STATE_NOTVALID)
!StateCheck(Player1,CD_STATE_NOTVALID)
THEN
RESPONSE #100
SetGlobal("X#YEPC2","LOCALS",2)
END

IF %BGT_VAR%
InParty(Myself)
CombatCounter(0)
!See([ENEMY])
Global("X#YEPC2","LOCALS",2)
See(Player1)
!StateCheck(Myself,CD_STATE_NOTVALID)
!StateCheck(Player1,CD_STATE_NOTVALID)
THEN
RESPONSE #100
PlaySong(0)
PlaySound("yesli99")
StartDialogNoSet(Player1)
END

/* Yeslick speaks after flooding mines and outdoors */
IF %BGT_VAR%
InParty(Myself)
CombatCounter(0)
!See([ENEMY])
Global("X#YEPC5","LOCALS",0)
AreaCheck("%CloakwoodMines%")
OR(2)
Global("FLOODED","GLOBAL",1)
Global("FLOODED","GLOBAL",2)
See(Player1)
THEN
RESPONSE #100
SetGlobal("X#YEPC5","LOCALS",1)
END

IF %BGT_VAR%
Global("X#YEPC5","LOCALS",1)
InParty(Myself)
CombatCounter(0)
!See([ENEMY])
AreaCheck("%CloakwoodMines%")
See(Player1)
!StateCheck(Myself,CD_STATE_NOTVALID)
!StateCheck(Player1,CD_STATE_NOTVALID)
THEN
RESPONSE #100
SetGlobal("X#YEPC5","LOCALS",2)
END

IF %BGT_VAR%
Global("X#YEPC5","LOCALS",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("yesli99")
StartDialogNoSet(Player1)
END


/* Yeslick chats with Coran wyvern map */
IF %BGT_VAR%
AreaCheck("%CloakwoodWyverns%")
InParty(Myself)
Global("X#YECO2","LOCALS",0)
InParty("coran")
THEN
RESPONSE #100
SetGlobal("X#YECO2","LOCALS",1)
END

IF %BGT_VAR%
AreaCheck("%CloakwoodWyverns%")
Global("X#YECO2","LOCALS",1)
InParty("coran")
InParty(Myself)
CombatCounter(0)
!See([ENEMY])
!StateCheck(Myself,CD_STATE_NOTVALID)
!StateCheck("coran",CD_STATE_NOTVALID)
THEN
RESPONSE #100
SetGlobal("X#YECO2","LOCALS",2)
END

IF %BGT_VAR%
Global("X#YECO2","LOCALS",2)
InParty("coran")
InParty(Myself)
CombatCounter(0)
!See([ENEMY])
!StateCheck(Myself,CD_STATE_NOTVALID)
!StateCheck("coran",CD_STATE_NOTVALID)
THEN
RESPONSE #100
StartDialogNoSet("coran")
END

/* Setup for Kagain/Yeslick */
IF %BGT_VAR%
GlobalTimerExpired("X#YEKATIME","GLOBAL")
InParty("kagain")
Global("X#YEKA3","GLOBAL",1)
Global("X#YEKA4","GLOBAL",0)
InParty(Myself)
CombatCounter(0)
!See([ENEMY])
RealGlobalTimerExpired("X#DreamTalk","GLOBAL")
!StateCheck(Myself,CD_STATE_NOTVALID)
!StateCheck("kagain",CD_STATE_NOTVALID)
THEN
RESPONSE #100
SetGlobal("X#YEKA4","GLOBAL",1)
RealSetGlobalTimer("X#DreamTalk","GLOBAL",180)
END

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

/* Kagain/Yeslick Fight if Yeslick Wins */
IF %BGT_VAR%
Dead("kagain")
Global("X#YeKaFight","GLOBAL",1)
InParty(Myself)
CombatCounter(0)
!See([ENEMY])
See(Player1)
!StateCheck(Myself,CD_STATE_NOTVALID)
THEN
RESPONSE #100
PlaySong(0)
PlaySound("yesli99")
StartDialogueNoSet(Player1)
END
