/* CONTENTS */
/* Dream timer */
/* Talk with Viconia */

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

/* Talk with Viconia */
IF %BGT_VAR%
InParty(Myself)
Global("X#AjPCTimerStarted","GLOBAL",0)
THEN
RESPONSE #100
RealSetGlobalTimer("X#AjFriendTalkTime","GLOBAL",1800)
SetGlobal("X#AjPCTimerStarted","GLOBAL",1)
END

IF %BGT_VAR%
RealGlobalTimerExpired("X#AjFriendTalkTime","GLOBAL")
InParty("viconia")
Global("X#AjVI2","LOCALS",1)
Global("X#AjFriendTalk","GLOBAL",0)
InParty(Myself)
CombatCounter(0)
!See([ENEMY])
InMyArea("viconia")
!StateCheck("viconia",CD_STATE_NOTVALID)
!StateCheck(Myself,CD_STATE_NOTVALID)
THEN
RESPONSE #100
IncrementGlobal("X#AjFriendTalk","GLOBAL",1)
END

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

/* for ADDAIL Phase1 */
IF %BGT_VAR%
InParty(Myself)
Class(Player1,PALADIN)
Global("X#AjPalTimerStarted","GLOBAL",0)
THEN
RESPONSE #100
RealSetGlobalTimer("X#AjPaladinTalkTime","GLOBAL",600)
SetGlobal("X#AjPalTimerStarted","GLOBAL",1)
END

/* Ajantis AjPaladinFriendTalk */
IF %BGT_VAR%
RealGlobalTimerExpired("X#AjPaladinTalkTime","GLOBAL")
Global("X#AjPaladinFriendTalk","GLOBAL",0)
InParty(Myself)
CombatCounter(0)
!See([ENEMY])
!StateCheck(Player1,CD_STATE_NOTVALID)
!StateCheck(Myself,CD_STATE_NOTVALID)
THEN
RESPONSE #100
IncrementGlobal("X#AjPaladinFriendTalk","GLOBAL",1)
END

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

/* Ajantis Central Baldur's Gate */
IF %BGT_VAR%
AreaCheck("%CentralBaldursGate%")
Global("X#AjWalls","GLOBAL",0)
InParty(Myself)
CombatCounter(0)
!See([ENEMY])
!StateCheck(Player1,CD_STATE_NOTVALID)
!StateCheck(Myself,CD_STATE_NOTVALID)
THEN
RESPONSE #100
SetGlobal("X#AjWalls","GLOBAL",1)
END

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

/* Ajantis ShieldTalk */
IF %BGT_VAR%
RealGlobalTimerExpired("X#AjantisShield","GLOBAL")
Global("X#AjShieldFriendTalk","GLOBAL",0)
InParty(Myself)
CombatCounter(0)
!See([ENEMY])
!StateCheck(Player1,CD_STATE_NOTVALID)
!StateCheck(Myself,CD_STATE_NOTVALID)
THEN
RESPONSE #100
IncrementGlobal("X#AjShieldFriendTalk","GLOBAL",1)
END

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

/* getting rid of Safana's box */
IF %BGT_VAR%
InParty(Myself)
HasItem("X#SABOX",Myself)
OR(2)
GlobalTimerExpired("X#AjanDestroyBoxT","GLOBAL")
!InParty("safana")
Global("X#AjanDestroyBox","GLOBAL",0)
THEN
RESPONSE #100
DestroyItem("X#SABOX")
SetGlobal("X#AjanDestroyBox","GLOBAL",1)
END

/* starting timer for "Safana's box" Ajantis LT */
IF %BGT_VAR%
InParty(Myself)
HasItem("X#SABOX","ajantis")
Global("X#AjanSafanasBox","GLOBAL",0)
Global("X#AjantisRomanceMatch","GLOBAL",1)
OR(2)
Global("X#AjantisRomanceActive","GLOBAL",1)
Global("X#AjantisRomanceActive","GLOBAL",2)
THEN
RESPONSE #100
SetGlobal("X#AjanSafanasBox","GLOBAL",1)
RealSetGlobalTimer("X#AjanSafanasBoxT","GLOBAL",800)
END

/* setting "Safana's box" Ajantis LT */
IF %BGT_VAR%
InParty(Myself)
CombatCounter(0)
InMyArea(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID)
!StateCheck(Myself,CD_STATE_NOTVALID)
HasItem("X#SABOX","ajantis")
Global("X#AjanSafanasBox","GLOBAL",1)
Global("X#AjantisRomanceMatch","GLOBAL",1)
OR(2)
Global("X#AjantisRomanceActive","GLOBAL",1)
Global("X#AjantisRomanceActive","GLOBAL",2)
RealGlobalTimerExpired("X#AjanSafanasBoxT","GLOBAL")
THEN
RESPONSE #100
SetGlobal("X#AjanSafanasBox","GLOBAL",2)
END

/* initiating "Safana's box" Ajantis LT */
IF %BGT_VAR%
Global("X#AjanSafanasBox","GLOBAL",2)
InParty(Myself)
!StateCheck(Player1,CD_STATE_NOTVALID)
!StateCheck(Myself,CD_STATE_NOTVALID)
OR(2)
Global("X#AjantisRomanceActive","GLOBAL",1)
Global("X#AjantisRomanceActive","GLOBAL",2)
THEN
RESPONSE #100
PlaySong(0)
PlaySound("ajrom")
StartDialogueNoSet(Player1)
END

/* Set Variable: Ajantis has BG1NPC Family Shield */
IF %BGT_VAR%
Global("X#AjantisHasShield","GLOBAL",0)
PartyHasItem("X#AJSHLD")
InParty(Myself)
THEN
RESPONSE #100
SetGlobal("X#AjantisHasShield","GLOBAL",1)
END

/*set variable to 0 if shield was only shortly gone */
IF %BGT_VAR%
Global("X#AjantisShieldGone","GLOBAL",1)
PartyHasItem("X#AJSHLD")
!RealGlobalTimerExpired("X#AjantisShieldGoneT","GLOBAL")
InParty(Myself)
THEN
RESPONSE #100
SetGlobal("X#AjantisShieldGone","GLOBAL",0)
END

/*set shield timer when shield is gone */
IF %BGT_VAR%
Global("X#AjantisShieldGone","GLOBAL",0)
Global("X#AjantisHasShield","GLOBAL",1) //only triggers if Ajantis had the shield
!PartyHasItem("X#AJSHLD")
InParty(Myself)
THEN
RESPONSE #100
SetGlobal("X#AjantisShieldGone","GLOBAL",1)
RealSetGlobalTimer("X#AjantisShieldGoneT","GLOBAL",300)
END

/* Activate: Ajantis Shield Removed talk */
IF %BGT_VAR%
Global("X#AjantisShieldGone","GLOBAL",1)
Global("X#AjantisHasShield","GLOBAL",1) //only triggers if Ajantis had the shield
RealGlobalTimerExpired("X#AjantisShieldGoneT","GLOBAL") //triggers after some amount of time
!PartyHasItem("X#AJSHLD")
InParty(Myself)
!StateCheck(Myself,CD_STATE_NOTVALID)
InMyArea(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY])
THEN
RESPONSE #100
SetGlobal("X#AjantisShieldGone","GLOBAL",2)
END

/* Initiate:  Ajantis Shield Removed talk */
IF %BGT_VAR%
Global("X#AjantisShieldGone","GLOBAL",2)
!PartyHasItem("X#AJSHLD")
InParty(Myself)
!StateCheck(Myself,CD_STATE_NOTVALID)
InMyArea(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY])
THEN
RESPONSE #100
PlaySong(0)
PlaySound("ajant99")
StartDialogueNoSet(Player1)
END

/* Activate: Ajantis Shield Returned talk */
IF %BGT_VAR%
Global("X#AjantisShieldGone","GLOBAL",3)
PartyHasItem("X#AJSHLD")
InParty(Myself)
!StateCheck(Myself,CD_STATE_NOTVALID)
InMyArea(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY])
THEN
RESPONSE #100
SetGlobal("X#AjantisShieldGone","GLOBAL",4)
END

/* Initiate:  Ajantis Shield Returned talk */
IF %BGT_VAR%
Global("X#AjantisShieldGone","GLOBAL",4)
!PartyHasItem("X#AJSHLD")
InParty(Myself)
!StateCheck(Myself,CD_STATE_NOTVALID)
InMyArea(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY])
THEN
RESPONSE #100
PlaySong(0)
PlaySound("ajant99")
StartDialogueNoSet(Player1)
END