/* set romance match */
IF %BGT_VAR%
Global("P#BranMatch","GLOBAL",0)
Gender(Player1,MALE)
InParty(Myself)
!Global("X#DynaheirRomanceActive","GLOBAL",2)
!Alignment(Player1,MASK_EVIL)
OR(4)
Race(Player1,HUMAN)
Race(Player1,ELF)
Race(Player1,HALF_ELF)
Race(Player1,HALFORC)
ReputationGT(Player1,9)
CheckStatGT(Player1,9,STR)
CheckStatGT(Player1,9,CON)
!HasItemEquiped("%tutu_var%BELT05",Player1) //girdle of gender bender
THEN
RESPONSE #100
SetGlobal("P#BranMatch","GLOBAL",1)
END

/* Set Romance Break If Dynaheir is at 2 */
IF %BGT_VAR%
Global("P#BranwenRomanceActive","GLOBAL",1)
InParty(Myself)
InParty("dynaheir")
!Global("X#DynaheirRomanceInactive","GLOBAL",1)
Global("X#DynaheirRomanceActive","GLOBAL",2)
THEN
RESPONSE #100
SetGlobal("P#BranwenRomanceActive","GLOBAL",3)
SetGlobal("P#BranRomCutByOther","GLOBAL",1)
END

IF %BGT_VAR%
Global("P#BranwenRomanceActive","GLOBAL",2)
InParty("dynaheir")
InParty(Myself)
!Global("X#DynaheirRomanceInactive","GLOBAL",1)
Global("X#DynaheirRomanceActive","GLOBAL",1)
THEN
RESPONSE #100
SetGlobal("X#DynaheirRomanceInactive","GLOBAL",1)
SetGlobal("X#DynaRomCutByOther","GLOBAL",1)
END

/* Shar-Teel's interest */
IF %BGT_VAR%
InParty("branwen")
InParty("sharteel")
OR(2)
Global("P#BranwenRomanceActive","GLOBAL",1)
Global("P#BranwenRomanceActive","GLOBAL",2)
OR(2)
Global("X#SharInterest","GLOBAL",1)
Global("X#SharInterest","GLOBAL",2)
ReputationLT(Player1,10)
THEN
RESPONSE #100
SetGlobal("P#BranwenRomanceActive","GLOBAL",3)
END

IF %BGT_VAR% 
InParty("branwen")
InParty("sharteel")
OR(2)
Global("P#BranwenRomanceActive","GLOBAL",1)
Global("P#BranwenRomanceActive","GLOBAL",2)
OR(2)
Global("X#SharInterest","GLOBAL",1)
Global("X#SharInterest","GLOBAL",2)
ReputationGT(Player1,9)
THEN
RESPONSE #100
SetGlobal("X#SharInterest","GLOBAL",3)
END

/* LoveTalks - Branwen RA = 1 */
IF %BGT_VAR%
InParty(Myself)
Global("P#BranMatch","GLOBAL",1)
Global("P#BranwenRomanceActive","GLOBAL",0)
Global("P#BRLoveTalk","GLOBAL",0)
GlobalGT("P#BrFriendTalk","GLOBAL",1)
THEN
RESPONSE #100
RealSetGlobalTimer("P#BRLoveTalkTime","GLOBAL",BRROM_TIMER)
SetGlobal("P#BRLoveTalk","GLOBAL",1)
SetGlobal("P#BranwenRomanceActive","GLOBAL",1)
END

IF %BGT_VAR%
InParty(Myself)
CombatCounter(0)
!See([ENEMY])
!StateCheck(Player1,CD_STATE_NOTVALID)
!StateCheck(Myself,CD_STATE_NOTVALID)
See(Player1)
RealGlobalTimerExpired("P#BRLoveTalkTime","GLOBAL")
Global("P#BranwenRomanceActive","GLOBAL",1)
!AreaType(DUNGEON)
OR(8)
Global("P#BRLoveTalk","GLOBAL",1)
Global("P#BRLoveTalk","GLOBAL",3)
Global("P#BRLoveTalk","GLOBAL",5)
Global("P#BRLoveTalk","GLOBAL",7)
Global("P#BRLoveTalk","GLOBAL",9)
Global("P#BRLoveTalk","GLOBAL",11)
Global("P#BRLoveTalk","GLOBAL",19)
Global("P#BRLoveTalk","GLOBAL",23)
THEN
RESPONSE #100
IncrementGlobal("P#BRLoveTalk","GLOBAL",1)
END

IF %BGT_VAR%
InParty(Myself)
RealGlobalTimerExpired("P#BRLoveTalkTime","GLOBAL")
!StateCheck(Player1,CD_STATE_NOTVALID)
!StateCheck(Myself,CD_STATE_NOTVALID)
OR(20)
Global("P#BRLoveTalk","GLOBAL",2)
Global("P#BRLoveTalk","GLOBAL",4)
Global("P#BRLoveTalk","GLOBAL",6)
Global("P#BRLoveTalk","GLOBAL",8)
Global("P#BRLoveTalk","GLOBAL",10)
Global("P#BRLoveTalk","GLOBAL",12)
Global("P#BRLoveTalk","GLOBAL",14)
Global("P#BRLoveTalk","GLOBAL",16)
Global("P#BRLoveTalk","GLOBAL",18)
Global("P#BRLoveTalk","GLOBAL",20)
Global("P#BRLoveTalk","GLOBAL",22)
Global("P#BRLoveTalk","GLOBAL",24)
Global("P#BRLoveTalk","GLOBAL",26)
Global("P#BRLoveTalk","GLOBAL",28)
Global("P#BRLoveTalk","GLOBAL",30)
Global("P#BRLoveTalk","GLOBAL",32)
Global("P#BRLoveTalk","GLOBAL",34)
Global("P#BRLoveTalk","GLOBAL",36)
Global("P#BRLoveTalk","GLOBAL",38)
Global("P#BRLoveTalk","GLOBAL",40)
THEN
RESPONSE #100
PlaySong(0)
PlaySound("brrom")
StartDialogueNoSet(Player1)
END

/* Love Talk 8 (PC < 99 percent HPPercent) */
IF %BGT_VAR%
Global("P#BranwenRomanceActive","GLOBAL",1)
Global("P#BRLoveTalk","GLOBAL",15)
!AreaType(DUNGEON)
InParty(Myself)
CombatCounter(0)
!See([ENEMY])
HPPercentLT(Player1,99)
!StateCheck(Player1,CD_STATE_NOTVALID)
!StateCheck(Myself,CD_STATE_NOTVALID)
See(Player1)
THEN
RESPONSE #100
IncrementGlobal("P#BRLoveTalk","GLOBAL",1)
END

/* Love Talk 11 */
IF %BGT_VAR%
InParty(Myself)
RealGlobalTimerExpired("P#BRLoveTalkTime","GLOBAL")
Global("P#BRLoveTalk","GLOBAL",21)
CombatCounter(0)
!See([ENEMY])
!StateCheck(Player1,CD_STATE_NOTVALID)
!StateCheck(Myself,CD_STATE_NOTVALID)
See(Player1)
Global("P#BranwenRomanceActive","GLOBAL",1)
AreaType(OUTDOOR)
THEN
RESPONSE #100
IncrementGlobal("P#BRLoveTalk","GLOBAL",1)
END

/* Romance Active = 2 */
IF %BGT_VAR%
RealGlobalTimerExpired("P#BRLoveTalkTime","GLOBAL")
OR(3)
Global("P#BRLoveTalk","GLOBAL",29)
Global("P#BRLoveTalk","GLOBAL",33)
Global("P#BRLoveTalk","GLOBAL",37)
InParty(Myself)
CombatCounter(0)
!See([ENEMY])
!StateCheck(Player1,CD_STATE_NOTVALID)
!StateCheck(Myself,CD_STATE_NOTVALID)
See(Player1)
Global("P#BranwenRomanceActive","GLOBAL",2)
!AreaType(DUNGEON)
THEN
RESPONSE #100
IncrementGlobal("P#BRLoveTalk","GLOBAL",1)
END

/* At Waking, Morning After 13 */
IF %BGT_VAR%
Global("P#BRLoveTalk","GLOBAL",27)
InParty(Myself)
!StateCheck(Player1,CD_STATE_NOTVALID)
!StateCheck(Myself,CD_STATE_NOTVALID)
Global("P#BranwenRomanceActive","GLOBAL",2)
THEN
RESPONSE #100
IncrementGlobal("P#BRLoveTalk","GLOBAL",1)
END

/* Break Up Talk */
IF %BGT_VAR%
Global("P#BRLoveTalk","GLOBAL",39)
InParty(Myself)
CombatCounter(0)
!See([ENEMY])
RealGlobalTimerExpired("P#BRLoveTalkTime","GLOBAL")
!StateCheck(Player1,CD_STATE_NOTVALID)
!StateCheck(Myself,CD_STATE_NOTVALID)
See(Player1)
Global("Chapter","GLOBAL",%tutu_chapter_7%)
Global("P#BranwenRomanceActive","GLOBAL",2)
!AreaType(DUNGEON)
THEN
RESPONSE #100
IncrementGlobal("P#BRLoveTalk","GLOBAL",1)
END

/* In Candlekeep, Chapter 6 */
IF %BGT_VAR%
Global("Chapter","GLOBAL",%tutu_chapter_6%)
Global("P#BranMatch","GLOBAL",1)
Global("P#BRLoveTalk1","GLOBAL",0)
AreaCheck("%Candlekeep_Ch6%")
InParty(Myself)
CombatCounter(0)
!See([ENEMY])
!StateCheck(Player1,CD_STATE_NOTVALID)
!StateCheck(Myself,CD_STATE_NOTVALID)
See(Player1)
THEN
RESPONSE #100
IncrementGlobal("P#BRLoveTalk1","GLOBAL",1)
END

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

/* Party Poisoned */
IF %BGT_VAR%
Global("P#BranMatch","GLOBAL",1)
Global("P#BRLoveTalk2","GLOBAL",0)
Global("X#BranwenLothander","GLOBAL",1)
InParty(Myself)
CombatCounter(0)
!See([ENEMY])
!StateCheck(Player1,CD_STATE_NOTVALID)
!StateCheck(Myself,CD_STATE_NOTVALID)
See(Player1)
THEN
RESPONSE #100
IncrementGlobal("P#BRLoveTalk2","GLOBAL",1)
END

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

/* Wake up after learning Bhaal */
IF %BGT_VAR%
Global("P#BranMatch","GLOBAL",1)
Global("P#BRLoveTalk3","GLOBAL",0)
Global("P#KnowBhaal","GLOBAL",1)
PartyRested()
InParty(Myself)
!StateCheck(Player1,CD_STATE_NOTVALID)
!StateCheck(Myself,CD_STATE_NOTVALID)
!AreaType(DUNGEON)
THEN
RESPONSE #100
IncrementGlobal("P#BRLoveTalk3","GLOBAL",1)
END

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

/* In the Undercity */
IF %BGT_VAR%
AreaCheck("%Undercity%")
Global("P#BranMatch","GLOBAL",1)
Global("P#BRLoveTalk4","GLOBAL",0)
InParty(Myself)
CombatCounter(0)
!See([ENEMY])
!StateCheck(Player1,CD_STATE_NOTVALID)
!StateCheck(Myself,CD_STATE_NOTVALID)
See(Player1)
THEN
RESPONSE #100
IncrementGlobal("P#BRLoveTalk4","GLOBAL",1)
END

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

/* Branwen's Repetitive Flirts */
/* Early in Romance */
IF %BGT_VAR%
GlobalGT("P#BRLoveTalk","GLOBAL",8)
GlobalLT("P#BRLoveTalk","GLOBAL",24)
Global("P#BranCheckFlirtEarly","GLOBAL",0)
InParty(Myself)
!Global("X#DisableBranFlirts","GLOBAL",1)
Global("P#BranwenRomanceActive","GLOBAL",1)
THEN
RESPONSE #100
RealSetGlobalTimer("P#BranFlirtEarlyTime","GLOBAL",300)
SetGlobal("P#BranCheckFlirtEarly","GLOBAL",1)
END

IF %BGT_VAR%
InParty(Myself)
RealGlobalTimerExpired("P#BranFlirtEarlyTime","GLOBAL")
Global("P#BranFlirtEarly","GLOBAL",0)
!Global("X#DisableBranFlirts","GLOBAL",1)
CombatCounter(0)
!See([ENEMY])
!StateCheck(Player1,CD_STATE_NOTVALID)
!StateCheck(Myself,CD_STATE_NOTVALID)
See(Player1)
Global("P#BranwenRomanceActive","GLOBAL",1)
!AreaType(DUNGEON)
THEN
RESPONSE #100
SetGlobal("P#BranFlirtEarly","GLOBAL",1)
END

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

/* Late in Romance */
IF %BGT_VAR%
!Global("X#DisableBranFlirts","GLOBAL",1)
Global("P#BranwenRomanceActive","GLOBAL",2)
GlobalGT("P#BRLoveTalk","GLOBAL",25)
GlobalLT("P#BRLoveTalk","GLOBAL",38)
Global("P#BranCheckFlirtLate","GLOBAL",0)
InParty(Myself)
THEN
RESPONSE #100
RealSetGlobalTimer("P#BranFlirtLateTime","GLOBAL",300)
SetGlobal("P#BranCheckFlirtLate","GLOBAL",1)
END

IF %BGT_VAR%
Global("P#BranFlirtLate","GLOBAL",0)
InParty(Myself)
RealGlobalTimerExpired("P#BranFlirtLateTime","GLOBAL")
!Global("X#DisableBranFlirts","GLOBAL",1)
CombatCounter(0)
!See([ENEMY])
!StateCheck(Player1,CD_STATE_NOTVALID)
!StateCheck(Myself,CD_STATE_NOTVALID)
See(Player1)
GlobalGT("P#BRLoveTalk","GLOBAL",25)
GlobalLT("P#BRLoveTalk","GLOBAL",38)
Global("P#BranwenRomanceActive","GLOBAL",2)
!AreaType(DUNGEON)
THEN
RESPONSE #100
SetGlobal("P#BranFlirtLate","GLOBAL",1)
END

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