/* Activate: Yeslick, When Davaeorn Is Dead */
IF %BGT_VAR%
AreaCheck("%CloakwoodMines_L4%")
Dead("davaeorn")
Global("X#YWDID","GLOBAL",0)
InParty(Myself)
!StateCheck(Myself,CD_STATE_NOTVALID)
InMyArea(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY])
THEN
RESPONSE #100
SetGlobal("X#YWDID","GLOBAL",1)
END

/* Initiate:  Yeslick, When Davaeorn Is Dead */
IF %BGT_VAR%
Global("X#YWDID","GLOBAL",1)
InParty(Myself)
!StateCheck(Myself,CD_STATE_NOTVALID)
InMyArea(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID)
THEN
RESPONSE #100
PlaySong(0)
PlaySound("yesli99")
StartDialogueNoSet(Player1)
END

/* Activate: Yeslick, As The Party Reach The Upper Level Of The Cloakwood Mine, and the slaves have not been freed) */
IF %BGT_VAR%
AreaCheck("%CloakwoodMines_L1%")
Global("X#YeslickLiturgy","GLOBAL",0)
Global("FLOODED","GLOBAL",0)
Global("FREESLAV","GLOBAL",0)
Global("X#YeslickPartyFreeSlaves","GLOBAL",0)
InParty(Myself)
!StateCheck(Myself,CD_STATE_NOTVALID)
InMyArea(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY])
THEN
RESPONSE #100
SetGlobal("X#YeslickPartyFreeSlaves","GLOBAL",1)
END

/* Initiate: Yeslick, As The Party Reach The Upper Level Of The Cloakwood Mine, and the slaves have not been freed) */
IF %BGT_VAR%
Global("X#YeslickPartyFreeSlaves","GLOBAL",1)
InParty(Myself)
!StateCheck(Myself,CD_STATE_NOTVALID)
InMyArea(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID)
THEN
RESPONSE #100
PlaySong(0)
PlaySound("yesli99")
StartDialogueNoSet(Player1)
END

/* Activate: if Yeslick remained in the party, slaves not freed, the mine has not been flooded then set a timer - in a day */
IF %BGT_VAR%
Global("X#YeslickLiturgy","GLOBAL",0)
Global("X#YeslickPartyFreeSlaves","GLOBAL",2)
Global("X#YeslickReminderFlood","GLOBAL",0)
Global("FLOODED","GLOBAL",0)
Global("FREESLAV","GLOBAL",0)
GlobalTimerExpired("X#YeslickReminderFloodTime","GLOBAL")
InParty(Myself)
!StateCheck(Myself,CD_STATE_NOTVALID)
InMyArea(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID)
THEN
RESPONSE #100
SetGlobal("X#YeslickReminderFlood","GLOBAL",1)
END

/* Initiate: if Yeslick remained in the party, slaves not freed, the mine has not been flooded then set a timer - in a day */
IF %BGT_VAR%
Global("X#YeslickReminderFlood","GLOBAL",1)
InParty(Myself)
!StateCheck(Myself,CD_STATE_NOTVALID)
InMyArea(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID)
THEN
RESPONSE #100
PlaySong(0)
PlaySound("yesli99")
StartDialogueNoSet(Player1)
END

/* Activate: Second (final) warning 2 days timer */
IF %BGT_VAR%
Global("X#YeslickLiturgy","GLOBAL",0)
Global("X#YeslickReminderFlood","GLOBAL",2)
GlobalTimerExpired("X#YeslickReminderFlood2","GLOBAL")
Global("FLOODED","GLOBAL",0)
Global("FREESLAV","GLOBAL",0)
InParty(Myself)
!StateCheck(Myself,CD_STATE_NOTVALID)
InMyArea(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY])
THEN
RESPONSE #100
SetGlobal("X#YeslickReminderFlood","GLOBAL",3)
END

/* Initiate: Second (final) warning 2 days timer */
IF %BGT_VAR%
Global("X#YeslickReminderFlood","GLOBAL",3)
InParty(Myself)
!StateCheck(Myself,CD_STATE_NOTVALID)
InMyArea(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID)
THEN
RESPONSE #100
PlaySong(0)
PlaySound("yesli99")
StartDialogueNoSet(Player1)
END

/* Activate: Yeslick, If the party flood the mine without freeing the slaves */
IF %BGT_VAR%
Global("X#YeslickLiturgy","GLOBAL",0)
Global("FLOODED","GLOBAL",1)
Global("FREESLAV","GLOBAL",0)
Global("X#YITPFTMWFTS","GLOBAL",0)
InParty(Myself)
!StateCheck(Myself,CD_STATE_NOTVALID)
InMyArea(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY])
THEN
RESPONSE #100
SetGlobal("X#YITPFTMWFTS","GLOBAL",1)
END

/* Initiate: Yeslick, If the party flood the mine without freeing the slaves */
IF %BGT_VAR%
Global("X#YITPFTMWFTS","GLOBAL",1)
InParty(Myself)
!StateCheck(Myself,CD_STATE_NOTVALID)
InMyArea(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID)
THEN
RESPONSE #100
PlaySong(0)
PlaySound("yesli99")
StartDialogueNoSet(Player1)
END

/* Activate: Yeslick, As The Party Reach The Upper Level Of The Cloakwood Mine, and the slaves have been freed, but mine not flooded */
IF %BGT_VAR%
Global("X#YeslickLiturgy","GLOBAL",0)
AreaCheck("%CloakwoodMines%")
Global("FLOODED","GLOBAL",0)
Global("FREESLAV","GLOBAL",1)
Global("X#YeslickDemandsFlooding","GLOBAL",0)
InParty(Myself)
!StateCheck(Myself,CD_STATE_NOTVALID)
InMyArea(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY])
THEN
RESPONSE #100
SetGlobal("X#YeslickDemandsFlooding","GLOBAL",1)
END

/* Initiate: Yeslick, As The Party Reach The Upper Level Of The Cloakwood Mine, and the slaves have been freed, but mine not flooded */
IF %BGT_VAR%
Global("X#YeslickDemandsFlooding","GLOBAL",1)
InParty(Myself)
!StateCheck(Myself,CD_STATE_NOTVALID)
InMyArea(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID)
THEN
RESPONSE #100
PlaySong(0)
PlaySound("yesli99")
StartDialogueNoSet(Player1)
END

/* Yeslick, saved slaves, if remains in the party, then set a timer - in a day, if the mine has not been flooded */
IF %BGT_VAR%
Global("X#YeslickLiturgy","GLOBAL",0)
Global("X#YeslickDemandsFlooding","GLOBAL",2)
Global("FLOODED","GLOBAL",0)
Global("FREESLAV","GLOBAL",1)
GlobalTimerExpired("X#YeslickFloodTime","GLOBAL")
InParty(Myself)
!StateCheck(Myself,CD_STATE_NOTVALID)
InMyArea(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY])
THEN
RESPONSE #100
SetGlobal("X#YeslickDemandsFlooding","GLOBAL",3)
END

/* Initiate Yeslick, saved slaves, if remains in the party, then set a timer - in a day, if the mine has not been flooded */
IF %BGT_VAR%
Global("X#YeslickDemandsFlooding","GLOBAL",3)
InParty(Myself)
!StateCheck(Myself,CD_STATE_NOTVALID)
InMyArea(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID)
THEN
RESPONSE #100
PlaySong(0)
PlaySound("yesli99")
StartDialogueNoSet(Player1)
END

/* Four more days after previous conv */
IF %BGT_VAR%
Global("X#YeslickLiturgy","GLOBAL",0)
Global("FLOODED","GLOBAL",0)
Global("FREESLAV","GLOBAL",1)
Global("X#YeslickDemandsFlooding","GLOBAL",4)
GlobalTimerExpired("X#YeslickFloodTime2","GLOBAL")
InParty(Myself)
!StateCheck(Myself,CD_STATE_NOTVALID)
InMyArea(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY])
THEN
RESPONSE #100
SetGlobal("X#YeslickDemandsFlooding","GLOBAL",5)
END

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

/* Activate: Flooded Mine, freed slaves */
IF %BGT_VAR%
AreaCheck("%CloakwoodMines%")
Global("X#YeslickLiturgy","GLOBAL",0)
GlobalGT("FREESLAV","GLOBAL",0)
GlobalGT("FLOODED","GLOBAL",0)
InParty(Myself)
!StateCheck(Myself,CD_STATE_NOTVALID)
InMyArea(Player1)
CombatCounter(0)
!See([ENEMY])
THEN
RESPONSE #100
SetGlobal("X#YeslickLiturgy","GLOBAL",1)
END

/* Initiate: Flooded Mine, freed slaves */
IF %BGT_VAR%
Global("X#YeslickLiturgy","GLOBAL",1)
InParty(Myself)
!StateCheck(Myself,CD_STATE_NOTVALID)
InMyArea(Player1)
CombatCounter(0)
!See([ENEMY])
THEN
RESPONSE #100
PlaySong(0)
PlaySound("yesli99")
StartDialogueNoSet(Player1)
END

/* Activate: Yeslick, upon coming to Baldur's Gate for the first time */
IF %BGT_VAR%
AreaCheck("%EBaldursGate%")
Global("X#YUCTBGFTFT","GLOBAL",0)
InParty(Myself)
!StateCheck(Myself,CD_STATE_NOTVALID)
InMyArea(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID)
THEN
RESPONSE #100
SetGlobal("X#YUCTBGFTFT","GLOBAL",1)
END

/* Initiate: Yeslick, upon coming to Baldur's Gate for the first time */
IF %BGT_VAR%
Global("X#YUCTBGFTFT","GLOBAL",1)
InParty(Myself)
!StateCheck(Myself,CD_STATE_NOTVALID)
InMyArea(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID)
THEN
RESPONSE #100
PlaySong(0)
PlaySound("yesli99")
StartDialogueNoSet(Player1)
END

/* In Candlekeep library, Yeslick leaves party activate combat */
IF %BGT_VAR%
AreaCheck("%Candlekeep_Library_L3%")
Global("X#IRWAS","GLOBAL",1)
THEN
RESPONSE #100
SetGlobal("X#IRWAS","GLOBAL",2)
ActionOverride("yeslick",Attack("rieltar"))
ActionOverride("rieltar",Attack("yeslick"))
ActionOverride("brunos",Attack("yeslick"))
ActionOverride("tuth",Attack("yeslick"))
ActionOverride("kestor",Attack("yeslick"))
END

/* In Candlekeep library, Yeslick leaves party activate combat */
IF %BGT_VAR%
AreaCheck("%Candlekeep_Library_L3%")
Global("X#IRWAS","GLOBAL",4)
THEN
RESPONSE #100
SetGlobal("X#IRWAS","GLOBAL",5)
ActionOverride("yeslick",Attack("rieltar"))
ActionOverride("rieltar",Attack("yeslick"))
ActionOverride("brunos",Attack("yeslick"))
ActionOverride("tuth",Attack("yeslick"))
ActionOverride("kestor",Attack("yeslick"))
END

/* In Candlekeep library, Yeslick does not leave party activate combat */
IF %BGT_VAR%
AreaCheck("%Candlekeep_Library_L3%")
Global("X#YWMRFTFT","GLOBAL",1)
Global("X#YRACTH","GLOBAL",1)
THEN
RESPONSE #100
SetGlobal("X#YRACTH","GLOBAL",2)
ActionOverride("rieltar",Enemy())
ActionOverride("brunos",Enemy())
ActionOverride("tuth",Enemy())
ActionOverride("kestor",Enemy())
END

/* Activate: Yeslick, killed Rieltar, Brunos, Tuth, Kestor */
IF %BGT_VAR%
AreaCheck("%Candlekeep_Library_L3%")
GlobalGT("X#IRWAS","GLOBAL",1)
Global("X#YKRBTK","GLOBAL",0)
Dead("rieltar")
Dead("brunos")
Dead("tuth")
Dead("Kestor")
InParty(Myself)
!StateCheck(Myself,CD_STATE_NOTVALID)
InMyArea(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID)
THEN
RESPONSE #100
SetGlobal("X#YKRBTK","GLOBAL",1)
END

/* Initiate: Yeslick, killed Rieltar, Brunos, Tuth, Kestor */
IF %BGT_VAR%
Global("X#YKRBTK","GLOBAL",1)
InParty(Myself)
!StateCheck(Myself,CD_STATE_NOTVALID)
InMyArea(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID)
THEN
RESPONSE #100
PlaySong(0)
PlaySound("yesli99")
StartDialogueNoSet(Player1)
END

IF %BGT_VAR%
Global("X#YRACTH","GLOBAL",2)
Dead("rieltar")
Dead("brunos")
Dead("tuth")
Dead("kestor")
InParty(Myself)
!StateCheck(Myself,CD_STATE_NOTVALID)
InMyArea(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY])
THEN
RESPONSE #100
SetGlobal("X#YRACTH","GLOBAL",3)
END

/* Initiate */
IF %BGT_VAR%
Global("X#YRACTH","GLOBAL",3)
InParty(Myself)
!StateCheck(Myself,CD_STATE_NOTVALID)
InMyArea(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID)
THEN
RESPONSE #100
PlaySong(0)
PlaySound("yesli99")
StartDialogueNoSet(Player1)
END

/* Activate: Yeslick Chapter 7 */
IF %BGT_VAR%
InParty(Myself)
!StateCheck(Myself,CD_STATE_NOTVALID)
InMyArea(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY])
Global("X#YChapter7","GLOBAL",0)
Global("Chapter","GLOBAL",%tutu_chapter_7%)
THEN
RESPONSE #100
SetGlobal("X#YChapter7","GLOBAL",1)
END

/* Initiate: Yeslick Chapter 7 */
IF %BGT_VAR%
Global("X#YChapter7","GLOBAL",1)
InParty(Myself)
!StateCheck(Myself,CD_STATE_NOTVALID)
InMyArea(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID)
THEN
RESPONSE #100
PlaySong(0)
PlaySound("yesli99")
StartDialogueNoSet(Player1)
END

/* Activate: Yeslick, When in the lower levels of Durlag's Tower */
IF %BGT_VAR%
AreaCheck("%DurlagsTower_D4%")
Global("X#YWITLLODT","GLOBAL",0)
InParty(Myself)
!StateCheck(Myself,CD_STATE_NOTVALID)
InMyArea(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY])
THEN
RESPONSE #100
SetGlobal("X#YWITLLODT","GLOBAL",1)
END

/* Initiate: Yeslick, When in the lower levels of Durlag's Tower */
IF %BGT_VAR%
Global("X#YWITLLODT","GLOBAL",1)
InParty(Myself)
!StateCheck(Myself,CD_STATE_NOTVALID)
InMyArea(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID)
THEN
RESPONSE #100
PlaySong(0)
PlaySound("yesli99")
StartDialogueNoSet(Player1)
END
