/* Script file for Ajantis Romance */
/* Romance Match */
/* For romance, Player1 has to be non evil female human, half-human, elf or halfling. For thieves, romance will start but stopped by Ajantis */

IF %BGT_VAR%
 Global("X#AjantisRomanceMatch","GLOBAL",0)
 Gender(Player1,FEMALE)
 ReputationGT(Player1,10)
 OR(4)
 Alignment(Player1,MASK_GOOD)
 Alignment(Player1,LAWFUL_NEUTRAL)
 Alignment(Player1,NEUTRAL)
 Class(Player1,DRUID_ALL)
 OR(4)
 Race(Player1,HUMAN)
 Race(Player1,HALF_ELF)
 Race(Player1,HALFLING)
 Race(Player1,ELF)
 !HasItemEquiped("%tutu_var%BELT05",Player1) //girdle of gender bender
 !HasItemEquiped("%tutu_var%HELM02",Player1) //helmet of alignment
THEN
 RESPONSE #100
 SetGlobal("X#AjantisRomanceMatch","GLOBAL",1)
END

/* Activate: girdle of gender bender on PC */
IF %BGT_VAR%
InParty(Myself)
InMyArea(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY])
HasItemEquiped("%tutu_var%BELT05",Player1) 
Global("X#AjantisRomanceMatch","GLOBAL",1)
OR(2)
Global("X#AjantisRomanceActive","GLOBAL",1)
Global("X#AjantisRomanceActive","GLOBAL",2)
Global("X#AjantisRomPCGirdle","GLOBAL",0)
THEN
RESPONSE #100
SetGlobal("X#AjantisRomPCGirdle","GLOBAL",1)
END

/* Initiate: girdle of gender bender on PC*/
IF %BGT_VAR%
InParty(Myself)
InMyArea(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY])
HasItemEquiped("%tutu_var%BELT05",Player1) 
Global("X#AjantisRomanceMatch","GLOBAL",1)
OR(2)
Global("X#AjantisRomanceActive","GLOBAL",1)
Global("X#AjantisRomanceActive","GLOBAL",2)
Global("X#AjantisRomPCGirdle","GLOBAL",1)
THEN
RESPONSE #100
StartDialogueNoSet(Player1)
END

/* additional scriptblock in Ajantis' script for the romance case, to shut down the romance in case of an hostile leave */
IF
!InParty(Myself)
Allegiance(Myself,ENEMY)
!Global("X#AjantisRomanceActive","GLOBAL",0)
!Global("X#AjantisRomanceActive","GLOBAL",3)
THEN
RESPONSE #100
SetGlobal("X#AjantisRomanceActive","GLOBAL",3)
END

/* Ajantis won't flirt with bonded woman ->also stops romance */
/* If Coran sleeps with PC, Ajantis in the party, Ajantis would never resume the romance */
IF %BGT_VAR%
 GlobalGT("P#CoranLover","GLOBAL",0)
 Global("X#AjantisRomanceMatch","GLOBAL",1)
 InParty(Myself)
 InParty("Coran")
 !Global("P#CoranRomanceInactive","GLOBAL",1)
 Global("X#AjantisCoranNeverResumes","GLOBAL",0)
THEN
 RESPONSE #100
 SetGlobal("X#AjantisCoranNeverResumes","GLOBAL",1)
 SetGlobal("X#AjantisRomanceActive","GLOBAL",3)
 SetGlobal("X#AjantisRomanceInactiveOtherRom","GLOBAL",3) //no PID resuming
END

/* Otherwise Coran's romance would be inactive and no extra kill checks are needed */

/* If Xan sleeps with the PC, Ajantis in the party, Ajantis would never resume the romance */
IF %BGT_VAR%
 Global("X#AjantisRomanceMatch","GLOBAL",1)
 InParty(Myself)
 InParty("Xan")
 GlobalGT("X#XanLover","GLOBAL",0)
 !Global("X#XARomanceInactive","GLOBAL",1)
 Global("X#AjantisXanNeverResumes","GLOBAL",0)
THEN
 RESPONSE #100
 SetGlobal("X#AjantisXanNeverResumes","GLOBAL",1)
 SetGlobal("X#AjantisRomanceActive","GLOBAL",3)
 SetGlobal("X#AjantisRomanceInactiveOtherRom","GLOBAL",3) //no PID resuming
END

/* Ajantis-Xan regular kill check, romance may yet be resumed */
IF %BGT_VAR%
 Global("X#AjantisRomanceMatch","GLOBAL",1)
 InParty(Myself)
 InParty("Xan")
 !Global("X#AjantisRomanceActive","GLOBAL",3)
 !Global("X#XARomanceInactive","GLOBAL",1)
 Global("X#XARomanceActive","GLOBAL",2)
THEN
 RESPONSE #100
 SetGlobal("X#AjantisRomanceActive","GLOBAL",3)
 SetGlobal("X#AjantisRomanceInactiveOtherRom","GLOBAL",1)
END

/* RomanceTimer will be set the first time Ajantis joins the group */
IF %BGT_VAR%
 Global("X#AjantisRomanceJoin","GLOBAL",0)
 Global("X#AjantisRomanceMatch","GLOBAL",1)
 InParty(Myself)
THEN
 RESPONSE #100
 SetGlobal("X#AjantisRomanceJoin","GLOBAL",1)
 SetGlobal("X#AjantisRomanceActive","GLOBAL",1)
 SetGlobal("X#AjantisLoveTalk","GLOBAL",1)
 RealSetGlobalTimer("X#AjantisRomance","GLOBAL",500) //Starts everything; short timer
END

/* setting RomanceActive to 3 if Bhaalknow happens for marriage proposal */
IF %BGT_VAR%
 InParty(Myself)
 Global("X#AjantisRomanceActive","GLOBAL",1)
 GlobalGT("X#AjantisKnowBhaalTalkNoRom","GLOBAL",0)
THEN
 RESPONSE #100
 SetGlobal("X#AjantisRomanceActive","GLOBAL",3)
 SetGlobal("X#AjantisRomanceBhaal","GLOBAL",1)
END

/* wait with dragon talk (for nighttalk 3) */
IF %BGT_VAR%
 InParty(Myself)
 Global("X#AjantisRomanceActive","GLOBAL",2)
 OR(2)
 Global("X#AjantisRomanceIntimacy","GLOBAL",1)
 Global("X#AjantisRomanceWantsInt","GLOBAL",2)
 Global("X#AjantisRomanceWaitLT","GLOBAL",0)
THEN
 RESPONSE #100
 SetGlobal("X#AjantisRomanceWaitLT","GLOBAL",1)
END

/* Bhaalcycle */
/* Ajantis Bhaal talk - starts cycle */
IF %BGT_VAR%
 InParty(Myself)
 CombatCounter(0)
 !See([ENEMY])
 !StateCheck(Player1,CD_STATE_NOTVALID)
 !StateCheck(Myself,CD_STATE_NOTVALID)
 Global("X#AjantisRomanceActive","GLOBAL",2)
 OR(2)
 Global("P#KnowBhaal","GLOBAL",1)
 Global("X#AjTamokoKnowBhaal","GLOBAL",1)
 Global("X#AjantisKnowBhaalTalk","GLOBAL",0)
THEN
 RESPONSE #100
 SetGlobal("X#AjantisKnowBhaalTalk","GLOBAL",1)
END

IF %BGT_VAR%
 Global("X#AjantisKnowBhaalTalk","GLOBAL",1)
 InParty(Myself)
 !StateCheck(Player1,CD_STATE_NOTVALID)
 !StateCheck(Myself,CD_STATE_NOTVALID)
THEN
 RESPONSE #100
 PlaySong(0)
 PlaySound("ajrom")
RealSetGlobalTimer("X#AjantisRomBhaalCycle","GLOBAL",600)
 StartDialogueNoSet(Player1)
END

IF %BGT_VAR%
 InParty(Myself)
 RealGlobalTimerExpired("X#AjantisRomBhaalCycle","GLOBAL")
 Global("X#AjantisRomanceActive","GLOBAL",2)
 !StateCheck(Player1,CD_STATE_NOTVALID)
 !StateCheck(Myself,CD_STATE_NOTVALID)
 !Detect([ENEMY])
 See(Player1)
 CombatCounter(0)
 OR(3)
 Global("X#AjantisKnowBhaalTalk","GLOBAL",2)
 Global("X#AjantisKnowBhaalTalk","GLOBAL",4)
 Global("X#AjantisKnowBhaalTalk","GLOBAL",6)
THEN
 RESPONSE #100
 IncrementGlobal("X#AjantisKnowBhaalTalk","GLOBAL",1)
END

IF %BGT_VAR%
 InParty(Myself)
 RealGlobalTimerExpired("X#AjantisRomBhaalCycle","GLOBAL")
 !StateCheck(Player1,CD_STATE_NOTVALID)
 !StateCheck(Myself,CD_STATE_NOTVALID)
 OR(3)
 Global("X#AjantisKnowBhaalTalk","GLOBAL",3)
 Global("X#AjantisKnowBhaalTalk","GLOBAL",5)
 Global("X#AjantisKnowBhaalTalk","GLOBAL",7)
THEN
 RESPONSE #100
RealSetGlobalTimer("X#AjantisRomBhaalCycle","GLOBAL",600)
 StartDialogueNoSet(Player1)
END

/* Open up Globals */
IF %BGT_VAR%
 InParty(Myself)
 RealGlobalTimerExpired("X#AjantisRomance","GLOBAL")
 !Global("X#AjantisRomanceActive","GLOBAL",3)
 Global("X#AjantisRomanceMatch","GLOBAL",1)
 !Global("X#AjantisCoranChallenge","GLOBAL",1)
 !Detect([ENEMY])
 See(Player1)
 !StateCheck(Player1,CD_STATE_NOTVALID)
 !StateCheck(Myself,CD_STATE_NOTVALID)
 CombatCounter(0)
 OR(10)
 Global("X#AjantisLoveTalk","GLOBAL",1)
 Global("X#AjantisLoveTalk","GLOBAL",3)
 Global("X#AjantisLoveTalk","GLOBAL",5)
 Global("X#AjantisLoveTalk","GLOBAL",7)
 Global("X#AjantisLoveTalk","GLOBAL",9)
 Global("X#AjantisLoveTalk","GLOBAL",11)
 Global("X#AjantisLoveTalk","GLOBAL",13)
 Global("X#AjantisLoveTalk","GLOBAL",15)
 Global("X#AjantisLoveTalk","GLOBAL",17)
 Global("X#AjantisLoveTalk","GLOBAL",19) //21: with weather change
THEN
 RESPONSE #100
 IncrementGlobal("X#AjantisLoveTalk","GLOBAL",1)
END

/* looking at the stars... Weather change (no weather) */
IF %BGT_VAR%
 InParty(Myself)
 RealGlobalTimerExpired("X#AjantisRomance","GLOBAL")
 !Global("X#AjantisRomanceActive","GLOBAL",3)
 Global("X#AjantisRomanceMatch","GLOBAL",1)
 !Global("X#AjantisCoranChallenge","GLOBAL",1)
 !Detect([ENEMY])
 See(Player1)
 !StateCheck(Player1,STATE_SLEEPING)
 CombatCounter(0)
 Global("X#AjantisLoveTalk","GLOBAL",21)
 Global("X#AjantisRomanceWeatherChange1","GLOBAL",0)
 TimeOfDay(NIGHT)
 !AreaType(DUNGEON)
 OR(3)
 AreaType(OUTDOOR)
 AreaType(WEATHER)
 AreaType(FOREST)
THEN
 RESPONSE #100
 SetGlobal("X#AjantisRomanceWeatherChange1","GLOBAL",1)
 Weather(NOWEATHER)
 SetGlobalTimer("X#AjantisRomanceWeatherTimer1","GLOBAL",5)
 MoveToObject(Player1)
END

/* looking at the stars: Talk triggering */
IF %BGT_VAR%
 InParty(Myself)
 RealGlobalTimerExpired("X#AjantisRomance","GLOBAL")
 !Global("X#AjantisRomanceActive","GLOBAL",3)
 Global("X#AjantisRomanceMatch","GLOBAL",1)
 !Global("X#AjantisCoranChallenge","GLOBAL",1)
 See(Player1)
 !StateCheck(Player1,STATE_SLEEPING)
 CombatCounter(0)
 TimeOfDay(NIGHT)
 !AreaType(DUNGEON)
 OR(3)
 AreaType(OUTDOOR)
 AreaType(WEATHER)
 AreaType(FOREST)
 Global("X#AjantisRomanceWeatherChange1","GLOBAL",1)
 GlobalTimerExpired("X#AjantisRomanceWeatherTimer1","GLOBAL")
 Global("X#AjantisLoveTalk","GLOBAL",21)
THEN
 RESPONSE #100
 SetGlobal("X#AjantisRomanceWeatherChange1","GLOBAL",2)
 IncrementGlobal("X#AjantisLoveTalk","GLOBAL",1)
END

/* Morning talk after Lovetalk "stars", only for "X#AjantisRomanceStars"=1 */
IF %BGT_VAR%
 InParty(Myself)
 CombatCounter(0)
 See(Player1)
 PartyRested()
 Global("X#AjantisRomanceStars","GLOBAL",1)
 Global("X#AjantisRomanceActive","GLOBAL",1)
 !StateCheck(Player1,CD_STATE_NOTVALID)
 !StateCheck(Myself,CD_STATE_NOTVALID)
THEN
 RESPONSE #100
 SetGlobal("X#AjantisRomanceStars","GLOBAL",2)
END

IF %BGT_VAR%
 Global("X#AjantisRomanceStars","GLOBAL",2)
 InParty(Myself)
 !StateCheck(Player1,CD_STATE_NOTVALID)
 !StateCheck(Myself,CD_STATE_NOTVALID)
THEN
 RESPONSE #100
 PlaySong(0)
 PlaySound("ajrom")
 StartDialogueNoSet(Player1)
END

/* if rep < 16 for LT 22: Ajantis gives hint that rep should increase. */
IF %BGT_VAR%
 InParty(Myself)
 CombatCounter(0)
 See(Player1)
 !StateCheck(Player1,CD_STATE_NOTVALID)
 !StateCheck(Myself,CD_STATE_NOTVALID)
 !Global("X#AjantisRomanceActive","GLOBAL",3)
 Global("X#AjantisRomanceRepFell","GLOBAL",0)
 ReputationLT(Player1,16)
 ReputationGT(Player1,11)
 GlobalGT("X#AjantisLoveTalk","GLOBAL",22)
 GlobalLT("X#AjantisLoveTalk","GLOBAL",32)
 Global("X#AjantisRomanceNeedMoreRep","GLOBAL",0)
THEN
 RESPONSE #100
 SetGlobal("X#AjantisRomanceNeedMoreRep","GLOBAL",1)
END

IF %BGT_VAR%
 Global("X#AjantisRomanceNeedMoreRep","GLOBAL",1)
 InParty(Myself)
 !StateCheck(Player1,CD_STATE_NOTVALID)
 !StateCheck(Myself,CD_STATE_NOTVALID)
THEN
 RESPONSE #100
 StartDialogueNoSet(Player1)
END

/* from LT 24: only for rep>= 16 */
IF %BGT_VAR%
 InParty(Myself)
 RealGlobalTimerExpired("X#AjantisRomance","GLOBAL")
 !Global("X#AjantisRomanceActive","GLOBAL",3)
 !Global("X#AjantisCoranChallenge","GLOBAL",1)
 !Detect([ENEMY])
 See(Player1)
 ReputationGT(Player1,15)
 !StateCheck(Player1,CD_STATE_NOTVALID)
 !StateCheck(Myself,CD_STATE_NOTVALID)
 CombatCounter(0)
 OR(3)
 Global("X#AjantisLoveTalk","GLOBAL",23)
 Global("X#AjantisLoveTalk","GLOBAL",25) //27: outdoor, look below for script block
 Global("X#AjantisLoveTalk","GLOBAL",29) //32: Messenger
THEN
 RESPONSE #100
 IncrementGlobal("X#AjantisLoveTalk","GLOBAL",1)
END

/* LT28: flower talk, outdoor */
IF %BGT_VAR%
 InParty(Myself)
 CombatCounter(0)
 See(Player1)
 RealGlobalTimerExpired("X#AjantisRomance","GLOBAL")
 !Global("X#AjantisRomanceActive","GLOBAL",3)
 !Global("X#AjantisCoranChallenge","GLOBAL",1)
 !Detect([ENEMY])
 ReputationGT(Player1,15)
 !StateCheck(Player1,CD_STATE_NOTVALID)
 !StateCheck(Myself,CD_STATE_NOTVALID)
 Global("X#AjantisLoveTalk","GLOBAL",27)
 OR(2)
 AreaType(OUTDOOR)
 AreaType(FOREST)
 TimeOfDay(DAY)
THEN
 RESPONSE #100
 IncrementGlobal("X#AjantisLoveTalk","GLOBAL",1)
END

/* messenger, appears in city areas. (LT 32) */
IF %BGT_VAR%
 InParty(Myself)
 RealGlobalTimerExpired("X#AjantisRomance","GLOBAL")
 !Global("X#AjantisRomanceActive","GLOBAL",3)
 !Global("X#AjantisCoranChallenge","GLOBAL",1)
 Global("X#AjantisKnowBhaalTalk","GLOBAL",0)
 Global("P#KnowBhaal","GLOBAL",0)
 !Detect([ENEMY])
 See(Player1)
 ReputationGT(Player1,15)
 !StateCheck(Player1,CD_STATE_NOTVALID)
 !StateCheck(Myself,CD_STATE_NOTVALID)
 CombatCounter(0)
 Global("X#AjantisLoveTalk","GLOBAL",31)
 AreaType(OUTDOOR)
 !HasItemEquiped("%tutu_var%BELT05",Player1) //girdle of gender bender
 !HasItemEquiped("%tutu_var%HELM02",Player1) //helmet of alignment change
 !HasItemEquiped("%tutu_var%BELT05",Myself) //girdle of gender bender
 !HasItemEquiped("%tutu_var%HELM02",Myself) //helmet of alignment change
 OR(14)
 AreaCheck("%NWBaldursGate%") //North-Western District of Baldur's Gate
 AreaCheck("%NBaldursGate%") //Northern District of Baldur's Gate
 AreaCheck("%NEBaldursGate%") //North-Eastern District of Baldur's Gate
 AreaCheck("%WBaldursGate%") //Western District of Baldur's Gate
 AreaCheck("%CentralBaldursGate%") //Center District of Baldur's Gate
 AreaCheck("%EBaldursGate%") //Eastern District of Baldur's Gate
 AreaCheck("%UlgothsBeard%") //Village of Ulgoth's Beard
 AreaCheck("%SWBaldursGate%") //South-Western District of Baldur's Gate
 AreaCheck("%BaldursGateDocks%") //Southern District of Baldur's Gate
 AreaCheck("%SEBaldursGate%") //South-East District of Baldur's Gate
 AreaCheck("%FriendlyArmInn%") //Friendly Arm Inn
 AreaCheck("%Beregost%") //Beregost
 AreaCheck("%Nashkel%") //Nashkell
 AreaCheck("%NashkelCarnival%") //Carnival
THEN
 RESPONSE #100
 IncrementGlobal("X#AjantisLoveTalk","GLOBAL",2)
 SetGlobal("X#AjantisHasRing","GLOBAL",1)
 CreateCreatureObjectOffScreen("X#AJDOUG",Myself,0,0,0) //Douglas
END

/* restart of romance cycle after accepted marriage proposal (to gain some time before the next LT fires) */
IF %BGT_VAR%
 InParty(Myself)
 Global("X#AjantisHasRing","GLOBAL",4)
 Global("X#AjantisRomanceActive","GLOBAL",2) //after accepted marriage proposal
 Global("X#AjantisLoveTalk","GLOBAL",33)
 OR(2)
 Global("X#AjantisKnowBhaalTalk","GLOBAL",0)
 Global("X#AjantisKnowBhaalTalk","GLOBAL",8)
THEN
 RESPONSE #100
 SetGlobal("X#AjantisHasRing","GLOBAL",5)
 RealSetGlobalTimer("X#AjantisRomance","GLOBAL",AJROM_TIMER)
END

/* if rep < 16 for LT > 32 Ajantis complaints */
IF %BGT_VAR%
 InParty(Myself)
 Global("X#AjantisRomanceActive","GLOBAL",2)
 Global("X#AjantisRomanceMatch","GLOBAL",1)
 See(Player1)
 !StateCheck(Player1,CD_STATE_NOTVALID)
 !StateCheck(Myself,CD_STATE_NOTVALID)
 CombatCounter(0)
 ReputationLT(Player1,16)
 GlobalGT("X#AjantisLoveTalk","GLOBAL",32)
 Global("X#AjantisRomanceLostRep","GLOBAL",0)
THEN
 RESPONSE #100
 SetGlobal("X#AjantisRomanceLostRep","GLOBAL",1)
END

IF %BGT_VAR%
 InParty(Myself)
 !StateCheck(Player1,CD_STATE_NOTVALID)
 !StateCheck(Myself,CD_STATE_NOTVALID)
Global("X#AjantisRomanceLostRep","GLOBAL",1)
THEN
 RESPONSE #100
 StartDialogueNoSet(Player1)
END

/* LTs after marriage proposal */
IF %BGT_VAR%
 InParty(Myself)
 RealGlobalTimerExpired("X#AjantisRomance","GLOBAL")
 Global("X#AjantisHasRing","GLOBAL",5)
 Global("X#AjantisRomanceActive","GLOBAL",2)
 !Detect([ENEMY])
 See(Player1)
 ReputationGT(Player1,15)
 !StateCheck(Player1,CD_STATE_NOTVALID)
 !StateCheck(Myself,CD_STATE_NOTVALID)
 CombatCounter(0)
 Global("X#AjantisLoveTalk","GLOBAL",33) //LT present
 OR(2)
 Global("X#AjantisKnowBhaalTalk","GLOBAL",0)
 Global("X#AjantisKnowBhaalTalk","GLOBAL",8)
THEN
 RESPONSE #100
 IncrementGlobal("X#AjantisLoveTalk","GLOBAL",1)
END

IF %BGT_VAR%
 InParty(Myself)
 RealGlobalTimerExpired("X#AjantisRomance","GLOBAL")
 Global("X#AjantisRomanceActive","GLOBAL",2)
 !Detect([ENEMY])
 See(Player1)
 ReputationGT(Player1,15)
 !StateCheck(Player1,CD_STATE_NOTVALID)
 !StateCheck(Myself,CD_STATE_NOTVALID)
 CombatCounter(0)
 OR(2)
 Global("X#AjantisKnowBhaalTalk","GLOBAL",0)
 Global("X#AjantisKnowBhaalTalk","GLOBAL",8)
 OR(2)//35: with weather change, 37: D.BAF
 Global("X#AjantisLoveTalk","GLOBAL",39)
 Global("X#AjantisLoveTalk","GLOBAL",41)
THEN
 RESPONSE #100
 IncrementGlobal("X#AjantisLoveTalk","GLOBAL",1)
END

/* night talk 1... Weather change (no weather) */
IF %BGT_VAR%
 InParty(Myself)
 CombatCounter(0)
 See(Player1)
 RealGlobalTimerExpired("X#AjantisRomance","GLOBAL")
 Global("X#AjantisRomanceActive","GLOBAL",2)
 !Detect([ENEMY])
 ReputationGT(Player1,15)
 !StateCheck(Player1,STATE_SLEEPING)
 Global("X#AjantisLoveTalk","GLOBAL",35)
 Global("X#AjantisRomanceWChangeN1","GLOBAL",0)
 TimeOfDay(NIGHT)
 !AreaType(DUNGEON)
 OR(3)
 AreaType(OUTDOOR)
 AreaType(WEATHER)
 AreaType(FOREST)
 OR(2)
 Global("X#AjantisKnowBhaalTalk","GLOBAL",0)
 Global("X#AjantisKnowBhaalTalk","GLOBAL",8)
THEN
 RESPONSE #100
 SetGlobal("X#AjantisRomanceWChangeN1","GLOBAL",1)
 Weather(NOWEATHER)
 SetGlobalTimer("X#AjantisRomanceWChangeNT1","GLOBAL",5)
 MoveToObject(Player1)
END

/* night talk 1... Talk triggering */
IF %BGT_VAR%
 InParty(Myself)
 CombatCounter(0)
 See(Player1)
 RealGlobalTimerExpired("X#AjantisRomance","GLOBAL")
 Global("X#AjantisRomanceActive","GLOBAL",2)
 ReputationGT(Player1,15)
 !StateCheck(Player1,CD_STATE_NOTVALID)
 !StateCheck(Myself,CD_STATE_NOTVALID)
 TimeOfDay(NIGHT)
 !AreaType(DUNGEON)
 OR(3)
 AreaType(OUTDOOR)
 AreaType(WEATHER)
 AreaType(FOREST)
 Global("X#AjantisRomanceWChangeN1","GLOBAL",1)
 GlobalTimerExpired("X#AjantisRomanceWChangeNT1","GLOBAL")
 Global("X#AjantisLoveTalk","GLOBAL",35)
 OR(2)
 Global("X#AjantisKnowBhaalTalk","GLOBAL",0)
 Global("X#AjantisKnowBhaalTalk","GLOBAL",8)
THEN
 RESPONSE #100
 SetGlobal("X#AjantisRomanceWChangeN1","GLOBAL",2)
 IncrementGlobal("X#AjantisLoveTalk","GLOBAL",1)
END

/* Dragon talk (only for Coran challenge) */
IF %BGT_VAR%
 InParty(Myself)
 See(Player1)
 ReputationGT(Player1,15)
 CombatCounter(0)
 !Detect([ENEMY])
 !Detect([EVILBUTBLUE])
 !StateCheck(Player1,CD_STATE_NOTVALID)
 !StateCheck(Myself,CD_STATE_NOTVALID)
 RealGlobalTimerExpired("X#AjantisRomance","GLOBAL")
 Global("X#AjantisRomanceActive","GLOBAL",2)
 OR(2)
 Global("X#AjantisKnowBhaalTalk","GLOBAL",0)
 Global("X#AjantisKnowBhaalTalk","GLOBAL",8)
 Global("X#AjantisCoChalDragon","GLOBAL",1)
 Global("X#AjantisLoveTalk","GLOBAL",43)
 !Global("X#AjantisRomanceWaitLT","GLOBAL",1)
 Global("X#AjantisRomanceDragonTalk","GLOBAL",0)
THEN
 RESPONSE #100
 SetGlobal("X#AjantisRomanceDragonTalk","GLOBAL",1)
END

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

/* triggering */
IF %BGT_VAR%
 RealGlobalTimerExpired("X#AjantisRomance","GLOBAL")
 InParty(Myself)
 !StateCheck(Player1,CD_STATE_NOTVALID)
 !StateCheck(Myself,CD_STATE_NOTVALID)
 OR(20)
 Global("X#AjantisLoveTalk","GLOBAL",2)
 Global("X#AjantisLoveTalk","GLOBAL",4)
 Global("X#AjantisLoveTalk","GLOBAL",6)
 Global("X#AjantisLoveTalk","GLOBAL",8)
 Global("X#AjantisLoveTalk","GLOBAL",10)
 Global("X#AjantisLoveTalk","GLOBAL",12)
 Global("X#AjantisLoveTalk","GLOBAL",14)
 Global("X#AjantisLoveTalk","GLOBAL",16)
 Global("X#AjantisLoveTalk","GLOBAL",18)
 Global("X#AjantisLoveTalk","GLOBAL",20)
 Global("X#AjantisLoveTalk","GLOBAL",22)
 Global("X#AjantisLoveTalk","GLOBAL",24)
 Global("X#AjantisLoveTalk","GLOBAL",26)
 Global("X#AjantisLoveTalk","GLOBAL",28)
 Global("X#AjantisLoveTalk","GLOBAL",30)
 Global("X#AjantisLoveTalk","GLOBAL",34)
 Global("X#AjantisLoveTalk","GLOBAL",36)
 Global("X#AjantisLoveTalk","GLOBAL",38)
 Global("X#AjantisLoveTalk","GLOBAL",40)
 Global("X#AjantisLoveTalk","GLOBAL",42)
THEN
 RESPONSE #100
 PlaySong(0)
 PlaySound("ajrom")
RealSetGlobalTimer("X#AjantisRomance","GLOBAL",AJROM_TIMER)
 StartDialogueNoSet(Player1)
END

/* morning talk after first intimacy (night talk2) */
IF %BGT_VAR%
 InParty(Myself)
 CombatCounter(0)
 See(Player1)
 Global("X#AjantisRomanceActive","GLOBAL",2)
 !StateCheck(Player1,CD_STATE_NOTVALID)
 !StateCheck(Myself,CD_STATE_NOTVALID)
 Global("X#AjantisRomanceIntimacy","GLOBAL",1)
 Global("X#AjantisRomanceIntimacy1Morning","GLOBAL",0)
THEN
RESPONSE #100
 SetGlobal("X#AjantisRomanceIntimacy1Morning","GLOBAL",1)
END

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

/* morning talk after second intimacy */
IF %BGT_VAR%
 InParty(Myself)
 See(Player1)
 CombatCounter(0)
 Global("X#AjantisRomanceActive","GLOBAL",2)
 !StateCheck(Player1,CD_STATE_NOTVALID)
 !StateCheck(Myself,CD_STATE_NOTVALID)
 Global("X#AjantisRomanceIntimacy2Morning","GLOBAL",0)
 !Global("X#AjantisRomanceWantsInt","GLOBAL",2)
 OR(2)
 Global("X#AjantisRomanceMakeLove2","GLOBAL",1)
 Global("X#AjantisRomanceNoMakeLove2","GLOBAL",1)
THEN
 RESPONSE #100
 SetGlobal("X#AjantisRomanceIntimacy2Morning","GLOBAL",1)
END

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

IF %BGT_VAR%
 !InParty(Myself)
 Global("%bgdreams%","GLOBAL",%bgdream2%)
 Global("X#AjantisDream1Without","GLOBAL",0)
 Global("X#AjantisRomanceMatch","GLOBAL",1)
THEN
 RESPONSE #100
 SetGlobal("X#AjantisDream1Without","GLOBAL",1)
END

IF %BGT_VAR%
 !InParty(Myself)
 Global("%bgdreams%","GLOBAL",%bgdream3%)
 Global("X#AjantisDream2Without","GLOBAL",0)
 Global("X#AjantisRomanceMatch","GLOBAL",1)
THEN
 RESPONSE #100
 SetGlobal("X#AjantisDream2Without","GLOBAL",1)
END

IF %BGT_VAR%
 !InParty(Myself)
 Global("%bgdreams%","GLOBAL",%bgdream5%)
 Global("X#AjantisDream4Without","GLOBAL",0)
 Global("X#AjantisRomanceMatch","GLOBAL",1)
THEN
 RESPONSE #100
 SetGlobal("X#AjantisDream4Without","GLOBAL",1)
END

/* Dream talks */
IF %BGT_VAR%
 InParty(Myself)
 CombatCounter(0)
 See(Player1)
 !See([ENEMY])
 !StateCheck(Player1,CD_STATE_NOTVALID)
 !StateCheck(Myself,CD_STATE_NOTVALID)
 See(Player1)
 Global("%bgdreams%","GLOBAL",%bgdream2%)
 Global("X#AjantisRomanceDream1","GLOBAL",0)
 !Global("X#AjantisRomanceActive","GLOBAL",3)
 Global("X#AjantisRomanceMatch","GLOBAL",1)
 Global("X#AjantisDream1Without","GLOBAL",0)
THEN
 RESPONSE #100
 SetGlobal("X#AjantisRomanceDream1","GLOBAL",1)
END

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

IF %BGT_VAR%
 InParty(Myself)
 CombatCounter(0)
 !See([ENEMY])
 !StateCheck(Player1,CD_STATE_NOTVALID)
 !StateCheck(Myself,CD_STATE_NOTVALID)
 See(Player1)
 Global("%bgdreams%","GLOBAL",%bgdream3%)
 Global("X#AjantisRomanceDream2","GLOBAL",0)
 !Global("X#AjantisRomanceActive","GLOBAL",3)
 Global("X#AjantisRomanceMatch","GLOBAL",1)
 Global("X#AjantisDream2Without","GLOBAL",0)
 See(Player1)
THEN
 RESPONSE #100
 SetGlobal("X#AjantisRomanceDream2","GLOBAL",1)
END

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

IF %BGT_VAR%
 InParty(Myself)
 CombatCounter(0)
 !See([ENEMY])
 !StateCheck(Player1,CD_STATE_NOTVALID)
 !StateCheck(Myself,CD_STATE_NOTVALID)
 See(Player1)
 Global("%bgdreams%","GLOBAL",%bgdream5%)
 Global("X#AjantisRomanceDream4","GLOBAL",0)
 !Global("X#AjantisRomanceActive","GLOBAL",3)
 Global("X#AjantisRomanceMatch","GLOBAL",1)
 Global("X#AjantisDream4Without","GLOBAL",0)
 See(Player1)
THEN
 RESPONSE #100
 SetGlobal("X#AjantisRomanceDream4","GLOBAL",1)
END

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

/* Last LT before end fight */
IF %BGT_VAR%
 Global("X#AjantisLastLoveTalk","GLOBAL",0)
 InParty(Myself)
 See(Player1)
 CombatCounter(0)
 OR(2)
 AreaCheck("%Undercity%") //city ruins
 AreaCheck("%Undercity_TempleofBhaal%") //temple of Bhaal
 Global("X#AjantisKnowBhaalTalk","GLOBAL",8) //after Bhaaltalk cycle
 Global("X#AjantisRomanceActive","GLOBAL",2)
 !StateCheck(Player1,CD_STATE_NOTVALID)
 !StateCheck(Myself,CD_STATE_NOTVALID)
THEN
 RESPONSE #100
 SetGlobal("X#AjantisLastLoveTalk","GLOBAL",1)
 SetGlobal("X#AjantisLoveTalk","GLOBAL",45)
END

IF %BGT_VAR%
 Global("X#AjantisLastLoveTalk","GLOBAL",1)
 Global("X#AjantisLoveTalk","GLOBAL",45)
 InParty(Myself)
 !StateCheck(Player1,CD_STATE_NOTVALID)
 !StateCheck(Myself,CD_STATE_NOTVALID)
THEN
 RESPONSE #100
 PlaySong(0)
 PlaySound("ajrom")
 StartDialogueNoSet(Player1)
END

/* Durlyle conflict */
/* Ajantis.baf - If "X#AjantisRomanceDurDirect" = 1, or "X#AjantisRomanceDurSweety" = 1 */
IF %BGT_VAR%
 InParty(Myself)
 CombatCounter(0)
 See(Player1)
 !StateCheck(Player1,CD_STATE_NOTVALID)
 !StateCheck(Myself,CD_STATE_NOTVALID)
 Global("X#AjantisRomanceMatch","GLOBAL",1)
 !Global("X#AjantisRomanceActive","GLOBAL",3)
 Global("X#AjantisRomanceDurSweety","GLOBAL",1)
THEN
 RESPONSE #100
 SetGlobal("X#AjantisRomanceDurSweety","GLOBAL",2)
END

IF %BGT_VAR%
 Global("X#AjantisRomanceDurSweety","GLOBAL",2)
 InParty(Myself)
 !StateCheck(Player1,CD_STATE_NOTVALID)
 !StateCheck(Myself,CD_STATE_NOTVALID)
THEN
 RESPONSE #100
 PlaySong(0)
 PlaySound("ajrom")
 StartDialogueNoSet(Player1)
END

IF %BGT_VAR%
 InParty(Myself)
 CombatCounter(0)
 See(Player1)
 !StateCheck(Player1,CD_STATE_NOTVALID)
 !StateCheck(Myself,CD_STATE_NOTVALID)
 Global("X#AjantisRomanceMatch","GLOBAL",1)
 !Global("X#AjantisRomanceActive","GLOBAL",3)
 Global("X#AjantisRomanceDurDirect","GLOBAL",1)
THEN
 RESPONSE #100
 SetGlobal("X#AjantisRomanceDurDirect","GLOBAL",2)
END

IF %BGT_VAR%
 Global("X#AjantisRomanceDurDirect","GLOBAL",2)
 InParty(Myself)
 !StateCheck(Player1,CD_STATE_NOTVALID)
 !StateCheck(Myself,CD_STATE_NOTVALID)
THEN
 RESPONSE #100
 PlaySong(0)
 PlaySound("ajrom")
 StartDialogueNoSet(Player1)
END

/* Gorion talk if PC didn't talk about Gorion in first LT */
IF %BGT_VAR%
 Global("X#AjantisRomanceNoGorion","GLOBAL",1)
 InParty(Myself)
 Global("X#AjantisRomanceMatch","GLOBAL",1)
 !Global("X#AjantisRomanceActive","GLOBAL",3)
THEN
 RESPONSE #100
 SetGlobal("X#AjantisRomanceNoGorion","GLOBAL",2)
 RealSetGlobalTimer("X#AjantisRomanceGorionTimer","GLOBAL",500) //Separate Short Timer
END

IF %BGT_VAR%
 RealGlobalTimerExpired("X#AjantisRomanceGorionTimer","GLOBAL")
 InParty(Myself)
 CombatCounter(0)
 See(Player1)
 !StateCheck(Player1,CD_STATE_NOTVALID)
 !StateCheck(Myself,CD_STATE_NOTVALID)
 Global("X#AjantisRomanceMatch","GLOBAL",1)
 !Global("X#AjantisRomanceActive","GLOBAL",3)
 Global("X#AjantisRomanceNoGorion","GLOBAL",2)
 PartyRested()
THEN
 RESPONSE #100
 SetGlobal("X#AjantisRomanceNoGorion","GLOBAL",3)
END

IF %BGT_VAR%
 Global("X#AjantisRomanceNoGorion","GLOBAL",3)
 InParty(Myself)
 !StateCheck(Player1,CD_STATE_NOTVALID)
 !StateCheck(Myself,CD_STATE_NOTVALID)
THEN
 RESPONSE #100
 PlaySong(0)
 PlaySound("ajrom")
 StartDialogueNoSet(Player1)
END

IF %BGT_VAR%
 InParty(Myself)
 CombatCounter(0)
 See(Player1)
 !StateCheck(Player1,CD_STATE_NOTVALID)
 !StateCheck(Myself,CD_STATE_NOTVALID)
 GlobalGT("X#AjantisRomanceBadDecision","GLOBAL",4)
 Global("X#AjantisRomanceTooManyBD","GLOBAL",0)
THEN
 RESPONSE #100
 SetGlobal("X#AjantisRomanceTooManyBD","GLOBAL",1)
END

IF %BGT_VAR%
 Global("X#AjantisRomanceTooManyBD","GLOBAL",1)
 InParty(Myself)
 !StateCheck(Player1,CD_STATE_NOTVALID)
 !StateCheck(Myself,CD_STATE_NOTVALID)
THEN
 RESPONSE #100
 StartDialogueNoSet(Player1)
END

IF %BGT_VAR%
 InParty(Myself)
 CombatCounter(0)
 See(Player1)
 !StateCheck(Player1,CD_STATE_NOTVALID)
 !StateCheck(Myself,CD_STATE_NOTVALID)
 GlobalGT("X#AjantisRomanceBadDecision","GLOBAL",7)
 Global("X#AjantisRomanceTooManyBD","GLOBAL",2)
 Global("X#AjantisRomanceActive","GLOBAL",2)
THEN
 RESPONSE #100
 SetGlobal("X#AjantisRomanceTooManyBD","GLOBAL",3)
END

IF %BGT_VAR%
 Global("X#AjantisRomanceTooManyBD","GLOBAL",3)
 InParty(Myself)
 !StateCheck(Player1,CD_STATE_NOTVALID)
 !StateCheck(Myself,CD_STATE_NOTVALID)
THEN
 RESPONSE #100
 StartDialogueNoSet(Player1)
END
