// Initiate dialogue
IF
Global("O#XanSummoned","GLOBAL",1)
THEN
RESPONSE #100
StartDialogueNoSet(Player1)
Wait(1)
END 

// Yaga-Shura army reaction
IF
Global("O#XanYagaArmyTalk1","GLOBAL",0)
AreaCheck("AR5203")
Global("O#XanRomanceActive","GLOBAL",2)
InParty(Myself)
!Dead("yaga01")
See(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID) 
!StateCheck(Myself,CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY])
THEN
RESPONSE #100
SetGlobal("O#XanYagaArmyTalk1","GLOBAL",1)
END

IF
Global("O#XanYagaArmyTalk1","GLOBAL",1)
InParty(Myself)
!StateCheck(Player1,CD_STATE_NOTVALID) 
!StateCheck(Myself,CD_STATE_NOTVALID)
See(Player1)
THEN
RESPONSE #100
StartDialogueNoSet(Player1)
END

// Physical talk 3
IF 
Global("O#XanToBPhysical1","GLOBAL",3)
InParty(Myself)
!StateCheck(Player1,CD_STATE_NOTVALID)
!StateCheck(Myself,CD_STATE_NOTVALID)
THEN
RESPONSE #100
SetGlobal("O#XanToBPhysical1","GLOBAL",4)
END

IF 
Global("O#XanToBPhysical1","GLOBAL",4)
InParty(Myself)
!StateCheck(Player1,CD_STATE_NOTVALID)
!StateCheck(Myself,CD_STATE_NOTVALID)
See(Player1)
THEN
RESPONSE #100
StartDialogueNoSet(Player1)
END

// Quest talks
IF 
InParty(Myself)
Global("O#XanToBFirstPartDone","GLOBAL",1)
THEN
RESPONSE #100
SetGlobal("O#XanToBFirstPartDone","GLOBAL",2)
SetGlobalTimer("O#XanQuestMetAgainTimer","GLOBAL",ONE_DAY)
END

IF 
InParty(Myself)
GlobalTimerExpired("O#XanQuestMetAgainTimer","GLOBAL")
!Global("Chapter","GLOBAL",10)
See(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID)
!StateCheck(Myself,CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY])
Global("O#XanToBFirstPartDone","GLOBAL",2)
THEN
RESPONSE #100
SetGlobal("O#XanToBFirstPartDone","GLOBAL",3)
END

IF 
Global("O#XanToBFirstPartDone","GLOBAL",3)
InParty(Myself)
!StateCheck(Player1,CD_STATE_NOTVALID)
!StateCheck(Myself,CD_STATE_NOTVALID)
See(Player1)
THEN
RESPONSE #100
StartDialogueNoSet(Player1)
END

IF 
Global("O#XanToBFirstPartDone","GLOBAL",6)
Global("O#XanToBQuestComplete1","GLOBAL",1)
InParty(Myself)
See(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID) 
!StateCheck(Myself,CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY])
Dead("O#Khalid")
THEN
RESPONSE #100
SetGlobal("O#XanToBQuestComplete1","GLOBAL",2)
END

IF 
Global("O#XanToBQuestComplete1","GLOBAL",2)
InParty(Myself)
!StateCheck(Player1,CD_STATE_NOTVALID) 
!StateCheck(Myself,CD_STATE_NOTVALID)
See(Player1)
THEN
RESPONSE #100
StartDialogueNoSet(Player1)
END

IF
Global("O#XanPCTransported","GLOBAL",1)
AreaCheck("AR5506")
InParty(Myself)
See(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID) 
!StateCheck(Myself,CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY])
THEN
RESPONSE #100
SetGlobal("O#XanPCTransported","GLOBAL",2)
END

IF 
Global("O#XanPCTransported","GLOBAL",2)
InParty(Myself)
!StateCheck(Player1,CD_STATE_NOTVALID) 
!StateCheck(Myself,CD_STATE_NOTVALID)
See(Player1)
THEN
RESPONSE #100
StartDialogueNoSet(Player1)
END

// Friend talks
IF 
InParty(Myself)
Global("O#XanFriendship","GLOBAL",1)
Global("O#XanComTalk","GLOBAL",0)
THEN
RESPONSE #100
RealSetGlobalTimer("O#XanToBFriendTimer","GLOBAL",500)
SetGlobal("O#XanComTalk","GLOBAL",1)
END

IF
RealGlobalTimerExpired("O#XanToBFriendTimer","GLOBAL")
InParty(Myself)
Global("O#XanFriendship","GLOBAL",1)
!AreaType(DUNGEON)
!Global("Chapter","GLOBAL",10)
See(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID) 
!StateCheck(Myself,CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY])
OR(4)
Global("O#XanComTalk","GLOBAL",1)
Global("O#XanComTalk","GLOBAL",3)
Global("O#XanComTalk","GLOBAL",5)
Global("O#XanComTalk","GLOBAL",7)
THEN
RESPONSE #100
IncrementGlobal("O#XanComTalk","GLOBAL",1)
END

IF
RealGlobalTimerExpired("O#XanToBFriendTimer","GLOBAL")
InParty(Myself)
See(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID) 
!StateCheck(Myself,CD_STATE_NOTVALID)
OR(4)
Global("O#XanComTalk","GLOBAL",2)
Global("O#XanComTalk","GLOBAL",4)
Global("O#XanComTalk","GLOBAL",6)
Global("O#XanComTalk","GLOBAL",8)
THEN
RESPONSE #100
Interact(Player1)
END

IF
Global("O#XanComTalk","GLOBAL",9)
InParty(Myself)
Global("O#XanFriendship","GLOBAL",1)
See(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID) 
!StateCheck(Myself,CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY])
Dead("CHALRV01")
THEN
RESPONSE #100
SetGlobal("O#XanComTalk","GLOBAL",10)
END

IF
Global("O#XanComTalk","GLOBAL",10)
InParty(Myself)
See(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID) 
!StateCheck(Myself,CD_STATE_NOTVALID)
THEN
RESPONSE #100
Interact(Player1)
END

// Romance talks
IF 
Global("O#XanRT15","GLOBAL",2)
Global("O#XanUnTalk","GLOBAL",0)
InParty(Myself)
THEN
RESPONSE #100
RealSetGlobalTimer("O#XanToBRomanceTimer","GLOBAL",500)
SetGlobal("O#XanUnTalk","GLOBAL",1)
END

IF
RealGlobalTimerExpired("O#XanToBRomanceTimer","GLOBAL")
InParty(Myself)
Global("O#XanRT15","GLOBAL",2)
!AreaType(DUNGEON)
!Global("Chapter","GLOBAL",10)
See(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID) 
!StateCheck(Myself,CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY])
Global("O#XanUnTalk","GLOBAL",1)
THEN
RESPONSE #100
SetGlobal("O#XanUnTalk","GLOBAL",2)
END

IF 
Global("O#XanUnTalk","GLOBAL",3)
InParty(Myself)
PartyRested()
CombatCounter(0)
!See([ENEMY])
Global("O#XanRomanceActive","GLOBAL",2)
!AreaType(DUNGEON)
!StateCheck(Player1,CD_STATE_NOTVALID) 
!StateCheck(Myself,CD_STATE_NOTVALID)
THEN
RESPONSE #100
SetGlobal("O#XanUnTalk","GLOBAL",4)
END

IF
RealGlobalTimerExpired("O#XanToBRomanceTimer","GLOBAL")
OR(2)
Global("O#XanUnTalk","GLOBAL",5)
Global("O#XanUnTalk","GLOBAL",7)
InParty(Myself)
Global("O#XanRomanceActive","GLOBAL",2)
!AreaType(DUNGEON)
!Global("Chapter","GLOBAL",10)
See(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID) 
!StateCheck(Myself,CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY])
THEN
RESPONSE #100
IncrementGlobal("O#XanUnTalk","GLOBAL",1)
END

IF
Global("O#XanUnTalk","GLOBAL",9)
InParty(Myself)
Global("O#XanRomanceActive","GLOBAL",2)
See(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID) 
!StateCheck(Myself,CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY])
Dead("CHALRV01")
THEN
RESPONSE #100
SetGlobal("O#XanUnTalk","GLOBAL",10)
END

IF
Global("O#XanUnTalk","GLOBAL",10)
InParty(Myself)
See(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID) 
!StateCheck(Myself,CD_STATE_NOTVALID)
THEN
RESPONSE #100
PlaySong(0)
PlaySound("O#XAN")
Interact(Player1)
END

IF
RealGlobalTimerExpired("O#XanToBRomanceTimer","GLOBAL")
InParty(Myself)
See(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID) 
!StateCheck(Myself,CD_STATE_NOTVALID)
OR(4)
Global("O#XanUnTalk","GLOBAL",2)
Global("O#XanUnTalk","GLOBAL",4)
Global("O#XanUnTalk","GLOBAL",6)
Global("O#XanUnTalk","GLOBAL",8)
THEN
RESPONSE #100
PlaySong(0)
PlaySound("O#XAN")
Interact(Player1)
END

// Bonded talks
IF 
Global("O#XanBondedPathAlive","GLOBAL",2)
Global("O#XanRomanceActive","GLOBAL",2)
Global("O#XanBonTalk","GLOBAL",0)
InParty(Myself)
AreaCheck("AR4500")
THEN
RESPONSE #100
SetGlobal("O#XanBonTalk","GLOBAL",1)
END

IF
!RealGlobalTimerNotExpired("O#XanToBBondedTimer","GLOBAL")
Global("O#XanRomanceActive","GLOBAL",2)
Global("O#XanBondedPathAlive","GLOBAL",2)
OR(10)
Global("O#XanBonTalk","GLOBAL",1)
Global("O#XanBonTalk","GLOBAL",3)
Global("O#XanBonTalk","GLOBAL",5)
Global("O#XanBonTalk","GLOBAL",7)
Global("O#XanBonTalk","GLOBAL",9)
Global("O#XanBonTalk","GLOBAL",11)
Global("O#XanBonTalk","GLOBAL",13)
Global("O#XanBonTalk","GLOBAL",15)
Global("O#XanBonTalk","GLOBAL",17)
Global("O#XanBonTalk","GLOBAL",19)
InParty(Myself)
Global("O#XanRomanceActive","GLOBAL",2)
!AreaType(DUNGEON)
!Global("Chapter","GLOBAL",10)
See(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID) 
!StateCheck(Myself,CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY])
THEN
RESPONSE #100
IncrementGlobal("O#XanBonTalk","GLOBAL",1)
END

IF
!RealGlobalTimerNotExpired("O#XanToBBondedTimer","GLOBAL")
InParty(Myself)
See(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID) 
!StateCheck(Myself,CD_STATE_NOTVALID)
OR(10)
Global("O#XanBonTalk","GLOBAL",2)
Global("O#XanBonTalk","GLOBAL",4)
Global("O#XanBonTalk","GLOBAL",6)
Global("O#XanBonTalk","GLOBAL",8)
Global("O#XanBonTalk","GLOBAL",10)
Global("O#XanBonTalk","GLOBAL",12)
Global("O#XanBonTalk","GLOBAL",14)
Global("O#XanBonTalk","GLOBAL",16)
Global("O#XanBonTalk","GLOBAL",18)
Global("O#XanBonTalk","GLOBAL",20)
THEN
RESPONSE #100
PlaySong(0)
PlaySound("O#XAN")
StartDialogueNoSet(Player1)
END

// Cyric's bonded talk
IF
Global("O#XanBondedTalkGods","GLOBAL",0)
InParty(Myself)
GlobalGT("BeginChallenge4","GLOBAL",3)
Global("O#XanRomanceActive","GLOBAL",2)
Global("O#XanBondedPathAlive","GLOBAL",2)
THEN
RESPONSE #100
RealSetGlobalTimer("O#XanBondedTalkGodsTimer","GLOBAL",50)
SetGlobal("O#XanBondedTalkGods","GLOBAL",1)
END

IF
Global("O#XanBondedTalkGods","GLOBAL",1)
InParty(Myself)
RealGlobalTimerExpired("O#XanBondedTalkGodsTimer","GLOBAL")
Global("O#XanRomanceActive","GLOBAL",2)
Global("O#XanBondedPathAlive","GLOBAL",2)
See(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID) 
!StateCheck(Myself,CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY]) 
THEN
RESPONSE #100
SetGlobal("O#XanBondedTalkGods","GLOBAL",2)
END

IF
Global("O#XanBondedTalkGods","GLOBAL",2)
InParty(Myself)
See(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID) 
!StateCheck(Myself,CD_STATE_NOTVALID)
THEN
RESPONSE #100
PlaySong(0)
PlaySound("O#XAN")
StartDialogueNoSet(Player1)
END

// Nightmare talk, romance and bonded
IF
OR(2)
GlobalGT("O#XanUnTalk","GLOBAL",8)
GlobalGT("O#XanBonTalk","GLOBAL",8)
Global("O#XanToBNightmare1","GLOBAL",0)
InParty(Myself)
PartyRested()
Global("O#XanRomanceActive","GLOBAL",2)
See(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID) 
!StateCheck(Myself,CD_STATE_NOTVALID)
THEN
RESPONSE #100
SetGlobal("O#XanToBNightmare1","GLOBAL",1)
END

IF
Global("O#XanToBNightmare1","GLOBAL",1)
InParty(Myself)
See(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID) 
!StateCheck(Myself,CD_STATE_NOTVALID)
THEN
RESPONSE #100
PlaySong(0)
PlaySound("O#XAN")
Interact(Player1)
END

// Corellon's vision talk
IF
PartyRested()
Global("O#XanTalkCorellon","GLOBAL",0)
GlobalGT("BeginChallenge4","GLOBAL",3)
OR(2)
Global("O#XanBondedTalkGods","GLOBAL",3)
!Global("O#XanBondedPathAlive","GLOBAL",2)
InParty(Myself)
See(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID) 
!StateCheck(Myself,CD_STATE_NOTVALID)
THEN
RESPONSE #100
SetGlobal("O#XanTalkCorellon","GLOBAL",2)
END

IF
Global("O#XanTalkCorellon","GLOBAL",2)
InParty(Myself)
See(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID) 
!StateCheck(Myself,CD_STATE_NOTVALID)
THEN
RESPONSE #100
StartDialogueNoSet(Player1)
END

// Ravager bonded talk
IF
Global("O#XanBondedTalkFinale","GLOBAL",0)
InParty(Myself)
Global("O#XanRomanceActive","GLOBAL",2)
Global("O#XanBondedPathAlive","GLOBAL",2)
See(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID) 
!StateCheck(Myself,CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY])
Dead("CHALRV01")
THEN
RESPONSE #100
SetGlobal("O#XanBondedTalkFinale","GLOBAL",1)
END

IF
Global("O#XanBondedTalkFinale","GLOBAL",1)
InParty(Myself)
See(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID) 
!StateCheck(Myself,CD_STATE_NOTVALID)
THEN
RESPONSE #100
PlaySong(0)
PlaySound("O#XAN")
StartDialogueNoSet(Player1)
END

// Other talks
IF
Global("O#XanOtherTalk1","GLOBAL",0)
InParty(Myself)
Dead("yaga01")
AreaCheck("AR5203")
See(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID) 
!StateCheck(Myself,CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY])
THEN
RESPONSE #100
SetGlobal("O#XanOtherTalk1","GLOBAL",1)
END

IF
Global("O#XanOtherTalk1","GLOBAL",1)
InParty(Myself)
See(Player1)
AreaCheck("AR5203")
!StateCheck(Player1,CD_STATE_NOTVALID) 
!StateCheck(Myself,CD_STATE_NOTVALID)
THEN
RESPONSE #100
Interact(Player1)
END

IF
Global("O#XanOtherTalk2","GLOBAL",0)
InParty(Myself)
Dead("Bazdra02")
AreaCheck("AR6000")
See(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID) 
!StateCheck(Myself,CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY])
THEN
RESPONSE #100
SetGlobal("O#XanOtherTalk2","GLOBAL",1)
END

IF
Global("O#XanOtherTalk2","GLOBAL",1)
InParty(Myself)
See(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID) 
!StateCheck(Myself,CD_STATE_NOTVALID)
THEN
RESPONSE #100
Interact(Player1)
END

IF
Global("O#XanOtherTalk3","GLOBAL",0)
InParty(Myself)
Dead("amtgen01")
AreaCheck("AR6300")
See(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID) 
!StateCheck(Myself,CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY])
THEN
RESPONSE #100
SetGlobal("O#XanOtherTalk3","GLOBAL",1)
END

IF
Global("O#XanOtherTalk3","GLOBAL",1)
InParty(Myself)
See(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID) 
!StateCheck(Myself,CD_STATE_NOTVALID)
THEN
RESPONSE #100
Interact(Player1)
END

IF
Global("O#XanOtherTalk4","GLOBAL",0)
InParty(Myself)
AreaCheck("AR5500")
THEN
RESPONSE #100
RealSetGlobalTimer("O#XanOT4TT","GLOBAL",200)
SetGlobal("O#XanOtherTalk4","GLOBAL",1)
END

IF
Global("O#XanOtherTalk4","GLOBAL",1)
InParty(Myself)
OR(2)
!Dead("Sendai")
!Dead("Abazigal1")
RealGlobalTimerExpired("O#XanOT4TT","GLOBAL")
See(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID) 
!StateCheck(Myself,CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY])
THEN
RESPONSE #100
SetGlobal("O#XanOtherTalk4","GLOBAL",2)
END

IF
Global("O#XanOtherTalk4","GLOBAL",2)
InParty(Myself)
See(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID) 
!StateCheck(Myself,CD_STATE_NOTVALID)
THEN
RESPONSE #100
Interact(Player1)
END

IF
Global("O#XanOtherTalk5","GLOBAL",0)
InParty(Myself)
Dead("Sendai")
Dead("Abazigal1")
!AreaCheck("AR4500")
!AreaType(DUNGEON)
See(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID) 
!StateCheck(Myself,CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY])
THEN
RESPONSE #100
SetGlobal("O#XanOtherTalk5","GLOBAL",1)
END

IF
Global("O#XanOtherTalk5","GLOBAL",1)
InParty(Myself)
See(Player1)
!AreaCheck("AR4500")
!StateCheck(Player1,CD_STATE_NOTVALID) 
!StateCheck(Myself,CD_STATE_NOTVALID)
THEN
RESPONSE #100
Interact(Player1)
END

// Gorion Wraith
IF
Global("O#XanGW","GLOBAL",0)
Global("O#XanLovedOne","GLOBAL",6)
InParty(Myself)
See(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID) 
!StateCheck(Myself,CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY])
GlobalGT("WraithPunish","GLOBAL",0) 
THEN
RESPONSE #100
SetGlobal("O#XanGW","GLOBAL",1)
END

IF
Global("O#XanGW","GLOBAL",1)
InParty(Myself)
See(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID) 
!StateCheck(Myself,CD_STATE_NOTVALID)
THEN
RESPONSE #100
Interact(Player1)
END

// Watcher's Keep
IF
Global("O#XanKeepEntered","GLOBAL",0)
AreaCheck("AR3000") 
Global("OpenDungeonDoor5","GLOBAL",0)
InParty(Myself)
See(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID) 
!StateCheck(Myself,CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY])
THEN
RESPONSE #100
SetGlobal("O#XanKeepEntered","GLOBAL",1)
END

IF
Global("O#XanKeepEntered","GLOBAL",1)
InParty(Myself)
See(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID) 
!StateCheck(Myself,CD_STATE_NOTVALID)
THEN
RESPONSE #100
Interact(Player1)
END

IF
Global("O#XanDemogorgonIsDead","GLOBAL",0)
Global("DemogorgonIsDead","GLOBAL",1)
Global("O#XanSpokeToDemogorgon","GLOBAL",1)
InParty(Myself)
See(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID) 
!StateCheck(Myself,CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY])
AreaCheck("AR3000")
THEN
RESPONSE #100
SetGlobal("O#XanDemogorgonIsDead","GLOBAL",1)
END

IF
Global("O#XanDemogorgonIsDead","GLOBAL",1)
InParty(Myself)
See(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID) 
!StateCheck(Myself,CD_STATE_NOTVALID)
THEN
RESPONSE #100
Interact(Player1)
END

IF
Global("O#XanDemilichSaladrex","GLOBAL",0)
InParty(Myself)
See(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID) 
!StateCheck(Myself,CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY])
Global("O#XanRomanceActive","GLOBAL",2)
OR(3)
AreaCheck("AR3018")
AreaCheck("AR3022")
AreaCheck("AR3027")
OR(2)
Dead("GorSal")
Dead("demilich")
THEN
RESPONSE #100
SetGlobal("O#XanDemilichSaladrex","GLOBAL",1)
END

IF
Global("O#XanDemilichSaladrex","GLOBAL",1)
InParty(Myself)
See(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID) 
!StateCheck(Myself,CD_STATE_NOTVALID)
THEN
RESPONSE #100
PlaySong(0)
PlaySound("O#XAN")
Interact(Player1)
END

// Xan-initiated flirts
IF
Global("O#XanToBFlirtsCheck","GLOBAL",0)
InParty(Myself)
Global("O#XanRomanceActive","GLOBAL",2)
THEN
RESPONSE #100
RealSetGlobalTimer("O#XanToBFlirtTimer","GLOBAL",1111)
SetGlobal("O#XanToBFlirtsCheck","GLOBAL",1)
END

IF
RealGlobalTimerExpired("O#XanToBFlirtTimer","GLOBAL")
InParty(Myself)
Global("O#XanToBFlirtsDisabled","GLOBAL",0)
Global("O#XanToBFlirtsStarted","GLOBAL",0)
Global("O#XanRomanceActive","GLOBAL",2)
OR(2)
Global("Chapter","GLOBAL",8)
Global("Chapter","GLOBAL",9)
See(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID) 
!StateCheck(Myself,CD_STATE_NOTVALID)
CombatCounter(0)
!See([ENEMY]) 
THEN
RESPONSE #100
IncrementGlobal("O#XanToBFlirtCounter","GLOBAL",1)
SetGlobal("O#XanToBFlirtsStarted","GLOBAL",1)
END

IF
Global("O#XanToBFlirtsStarted","GLOBAL",1)
InParty(Myself)
!StateCheck(Player1,CD_STATE_NOTVALID) 
!StateCheck(Myself,CD_STATE_NOTVALID)
See(Player1)
THEN
RESPONSE #100
StartDialogueNoSet(Player1)
END

// Xan-Anomen script kill
IF 
Global("O#XanWonAnomenToB","GLOBAL",0)
Global("O#XanRomanceActive","GLOBAL",2)
OR(2)
Global("AnomenRomanceActive","GLOBAL",1)
Global("AnomenRomanceActive","GLOBAL",2)
THEN
RESPONSE #100
SetGlobal("O#XanWonAnomenToB","GLOBAL",1)
SetGlobal("AnomenRomanceActive","GLOBAL",3)
END

//Setting normal biography
IF
Global("O#XanToBNormalBiography","GLOBAL",0)
InParty(Myself)
Global("O#XanSummoned","GLOBAL",0) 
THEN
RESPONSE #100
SetGlobal("O#XanToBNormalBiography","GLOBAL",1)
SetPlayerSound(Myself,@55,EXISTANCE5)
END

// Hotkey fixer
IF
HotKey(K)
THEN
RESPONSE #100
StartCutSceneMode()
StartCutScene("O#XanF3")
END