// At rest, Xan's hitpoints low, city, outdoors, bonded or romance
IF
Global("O#XanSoAWoundedRom","GLOBAL",0)
InParty(Myself)
!StateCheck(Player1,CD_STATE_NOTVALID)
!StateCheck(Myself,CD_STATE_NOTVALID)
GlobalLT("Chapter","GLOBAL",4)
HPPercentLT("O#Xan",80)
OR(2)
Global("O#XanRomanceActive","GLOBAL",1)
Global("O#XanRomanceActive","GLOBAL",2)
OR(2)
GlobalGT("O#XanBondedTalk","GLOBAL",18)
GlobalGT("O#XanLoveTalk","GLOBAL",18)
AreaType(OUTDOOR)
AreaType(CITY)
THEN
RESPONSE #100
SetGlobal("O#XanSoAWoundedRom","GLOBAL",1)
StartDialogueNoSet(Player1)
END

// At rest, post Bodhi's death, bonded path, not a dungeon
IF
Global("O#XanSoABodhiBath","GLOBAL",0)
InParty(Myself)
!StateCheck(Player1,CD_STATE_NOTVALID)
!StateCheck(Myself,CD_STATE_NOTVALID)
Dead("C6Bodhi")
GlobalLT("Chapter","GLOBAL",7)
Global("O#XanRomanceActive","GLOBAL",2)
Global("O#XanBondedPathAlive","GLOBAL",2)
!AreaType(DUNGEON)
THEN
RESPONSE #100
SetGlobal("O#XanSoABodhiBath","GLOBAL",1)
StartDialogueNoSet(Player1)
END

// Bonded, sequential: reuniting talk and birthday talk
IF
Global("O#XanRomanceActive","GLOBAL",2)
Global("O#XanBondedTalk","GLOBAL",0)
InParty(Myself)
!StateCheck(Player1,CD_STATE_NOTVALID)
!StateCheck(Myself,CD_STATE_NOTVALID)
THEN
RESPONSE #100
SetGlobal("O#XanBondedTalk","GLOBAL",2)
PlaySong(0)
PlaySound("O#XAN")
Interact(Player1)
END

IF
Global("O#XanBondedTalk","GLOBAL",13)
InParty(Myself)
!StateCheck(Player1,CD_STATE_NOTVALID)
!StateCheck(Myself,CD_STATE_NOTVALID)
Global("O#XanRomanceActive","GLOBAL",2)
!AreaType(DUNGEON)
THEN
RESPONSE #100
SetGlobal("O#XanBondedTalk","GLOBAL",14)
PlaySong(0)
PlaySound("O#XAN")
Interact(Player1)
END

// Friend talks, consequential
IF
Global("O#XanET2","GLOBAL",0)
InParty(Myself)
!StateCheck(Player1,CD_STATE_NOTVALID)
!StateCheck(Myself,CD_STATE_NOTVALID)
Global("O#XanFriendship","GLOBAL",1) 
GlobalLT("Chapter","GLOBAL",4)
OR(7)
AreaCheck("AR0020")
AreaCheck("AR0300")
AreaCheck("AR0400")
AreaCheck("AR0500")
AreaCheck("AR0700")
AreaCheck("AR0900")
AreaCheck("AR1000")
THEN
RESPONSE #100
SetGlobal("O#XanET2","GLOBAL",1)
Interact(Player1)
END

IF
Global("O#XanET12","GLOBAL",0) 
InParty(Myself)
Global("O#XanFriendship","GLOBAL",1)
GlobalGT("Chapter","GLOBAL",5)
THEN
RESPONSE #100
SetGlobal("O#XanET12","GLOBAL",1)
Interact(Player1)
END

// Bonded talks, consequential
IF
Global("O#XanST2","GLOBAL",0)
InParty(Myself)
!StateCheck(Player1,CD_STATE_NOTVALID)
!StateCheck(Myself,CD_STATE_NOTVALID)
Global("O#XanRomanceActive","GLOBAL",2)
!Global("Chapter","GLOBAL",6)
OR(10)
AreaCheck("AR0509")
AreaCheck("AR0021")
AreaCheck("AR0406")
AreaCheck("AR0313")
AreaCheck("AR0704")
AreaCheck("AR0709")
AreaCheck("AR0513")
AreaCheck("AR1602")
AreaCheck("AR1105")
AreaCheck("AR2010")
GlobalGT("O#XanBondedTalk","GLOBAL",7)
THEN
RESPONSE #100
SetGlobal("O#XanST2","GLOBAL",1)
PlaySong(0)
PlaySound("O#XAN")
Interact(Player1)
END

IF
Global("O#XanST3","GLOBAL",0)
InParty(Myself)
!StateCheck(Player1,CD_STATE_NOTVALID)
!StateCheck(Myself,CD_STATE_NOTVALID)
Global("O#XanRomanceActive","GLOBAL",2)
AreaType(DUNGEON)
GlobalGT("O#XanBondedTalk","GLOBAL",7)
THEN
RESPONSE #100
SetGlobal("O#XanST3","GLOBAL",1)
PlaySong(0)
PlaySound("O#XAN")
Interact(Player1)
END

IF
Global("O#XanST11","GLOBAL",0)
InParty(Myself)
!StateCheck(Player1,CD_STATE_NOTVALID)
!StateCheck(Myself,CD_STATE_NOTVALID)
Global("O#XanRomanceActive","GLOBAL",2)
Global("PlayerLooksLikeDrow","GLOBAL",1)
THEN
RESPONSE #100
SetGlobal("O#XanST11","GLOBAL",1)
PlaySong(0)
PlaySound("O#XAN")
Interact(Player1)
END

IF
Global("O#XanST12","GLOBAL",0)
InParty(Myself)
!StateCheck(Player1,CD_STATE_NOTVALID)
!StateCheck(Myself,CD_STATE_NOTVALID)
Global("O#XanRomanceActive","GLOBAL",2)
Global("Chapter","GLOBAL",6)
!Dead("C6Bodhi")
GlobalGT("O#XanBondedTalk","GLOBAL",16)
!AreaType(DUNGEON)
THEN
RESPONSE #100
SetGlobal("O#XanST12","GLOBAL",1)
PlaySong(0)
PlaySound("O#XAN")
Interact(Player1)
END

// Romance talks, consequential
IF
Global("O#XanRT2","GLOBAL",0)
InParty(Myself)
!StateCheck(Player1,CD_STATE_NOTVALID)
!StateCheck(Myself,CD_STATE_NOTVALID)
Global("O#XanRomanceActive","GLOBAL",1)
GlobalLT("O#XanLoveTalk","GLOBAL",18)
AreaType(OUTDOOR)
TimeOfDay(NIGHT)
THEN
RESPONSE #100
SetGlobal("O#XanRT2","GLOBAL",1)
PlaySong(0)
PlaySound("O#XAN")
Interact(Player1)
END

IF
Global("O#XanRT3","GLOBAL",0)
InParty(Myself)
!StateCheck(Player1,CD_STATE_NOTVALID)
!StateCheck(Myself,CD_STATE_NOTVALID)
Global("O#XanRomanceActive","GLOBAL",1)
GlobalLT("O#XanLoveTalk","GLOBAL",18)
AreaType(DUNGEON)
THEN
RESPONSE #100
SetGlobal("O#XanRT3","GLOBAL",1)
PlaySong(0)
PlaySound("O#XAN")
Interact(Player1)
END

IF
Global("O#XanRT4","GLOBAL",0)
InParty(Myself)
!StateCheck(Player1,CD_STATE_NOTVALID)
!StateCheck(Myself,CD_STATE_NOTVALID)
Global("O#XanRomanceActive","GLOBAL",1)
GlobalGT("O#XanLoveTalk","GLOBAL",18)
AreaType(OUTDOOR)
!AreaType(CITY)
THEN
RESPONSE #100
SetGlobal("O#XanRT4","GLOBAL",1)
PlaySong(0)
PlaySound("O#XAN")
Interact(Player1)
END

IF
Global("O#XanRT5","GLOBAL",0)
InParty(Myself)
!StateCheck(Player1,CD_STATE_NOTVALID)
!StateCheck(Myself,CD_STATE_NOTVALID)
Global("O#XanRomanceActive","GLOBAL",1)
GlobalGT("O#XanLoveTalk","GLOBAL",18)
AreaType(DUNGEON)
THEN
RESPONSE #100
SetGlobal("O#XanRT5","GLOBAL",1)
PlaySong(0)
PlaySound("O#XAN")
Interact(Player1)
END

IF
Global("O#XanRT6","GLOBAL",0)
InParty(Myself)
!StateCheck(Player1,CD_STATE_NOTVALID)
!StateCheck(Myself,CD_STATE_NOTVALID)
Global("O#XanRomanceActive","GLOBAL",1)
GlobalGT("O#XanLoveTalk","GLOBAL",18)
OR(10)
AreaCheck("AR0509")
AreaCheck("AR0021")
AreaCheck("AR0406")
AreaCheck("AR0313")
AreaCheck("AR0704")
AreaCheck("AR0709")
AreaCheck("AR0513")
AreaCheck("AR1602")
AreaCheck("AR1105")
AreaCheck("AR2010")
THEN
RESPONSE #100
SetGlobal("O#XanRT6","GLOBAL",1)
PlaySong(0)
PlaySound("O#XAN")
Interact(Player1)
END