//We have Mithril Ring in Inventory
IF
InParty("Xzar")
PartyHasItem("X#XZMIRI")
Global("X#XzarMithrilRing","GLOBAL",0)
THEN
RESPONSE #100
SetGlobal("X#XzarMithrilRing","GLOBAL",1)
StartDialogueNoSet(Player1)
END

//Intro of Cutscene for Dryad
IF
InParty("Xzar")
AreaCheck("AR4200")
Global("X#XzarDryad","GLOBAL",4)
THEN
RESPONSE #100
ClearAllActions()
SetGlobal("X#XZDR1","GLOBAL",1)
StartCutSceneMode()
StartCutScene("X#XZDR1")
END


IF
InParty("Xzar")
AreaCheck("AR4200")
Global("X#XzarDryad","GLOBAL",6)
THEN
RESPONSE #100
SetGlobal("X#XzarDryad","GLOBAL",7)
SetGlobalTimer("X#XzarDruidAttack","GLOBAL",22000)
END

//Forest Spirits's Summon
IF
InParty("Xzar")
AreaCheck("AR4200")
Global("X#SummonForest","GLOBAL",1)
Dead("cdryad")
THEN
RESPONSE #100
SetGlobal("X#SummonForest","GLOBAL",2)
StartDialogueNoSet(Player1)
END

IF
InParty("Xzar")
AreaCheck("AR4200")
Global("X#SummonForest","GLOBAL",3)
THEN
RESPONSE #100
SetGlobal("X#SummonForest","GLOBAL",4)
CreateCreature("X#XZFSP1",[-1.-1],0)
CreateCreature("X#XZFSP2",[-1.-1],0)
CreateCreature("X#XZFSP3",[-1.-1],0)
MoveGlobalObject("XZFSPIRIT1","cdryad")
ActionOverride("XZFSPIRIT1",Dialogue(Player1))
END

IF
InParty("Xzar")
AreaCheck("AR4200")
Global("X#SummonForest","GLOBAL",5)
THEN
RESPONSE #100
SetGlobal("X#SummonForest","GLOBAL",6)
StartDialogueNoSet(Player1)
END

//Druid's Summon
IF
Global("X#XzarDryad","GLOBAL",7)
InParty(Myself)
GlobalTimerExpired("X#XzarDruidAttack","GLOBAL")
Global("X#XzarDruidsExist","GLOBAL",0)
   AreaType(FOREST)
   !Exists("Storm")
   !Exists("Blackberry")
   !Exists("Zosya")
  THEN
   RESPONSE #100
   SetGlobal("X#XzarDruidsExist","GLOBAL",1)
   CreateCreatureObjectOffScreen("X#BLACK",Myself,0,0,0)
   CreateCreatureObjectOffScreen("X#STORM",Myself,0,0,0)
   CreateCreatureObjectOffScreen("X#ZOSYA",Myself,0,0,0)
END

//Xzar nags about the ring

//nag one
IF
See([ENEMY])
InParty(Myself)
Global("X#XzarNags","GLOBAL",1)
GlobalTimerExpired("X#XzarRingNag","GLOBAL")
PartyHasItem("X#XZDRIA") 
THEN
RESPONSE #100
SetGlobal("X#XzarNags","GLOBAL",2)
StartDialogueNoSet(Player1)
END

//nag two
IF
InParty(Myself)
Global("X#XzarNags","GLOBAL",3)
RealGlobalTimerExpired("X#XzarRingNag2","GLOBAL")
PartyHasItem("X#XZDRIA")
THEN
RESPONSE #100
SetGlobal("X#XzarNags","GLOBAL",4)
StartDialogueNoSet(Player1)
END

//Xzar Charms Montaron
IF
!AreaCheck("AR7703")
InParty(Myself)
OR(2)
Global("XzarCharmMontaron","GLOBAL",0)
Global("XzarCharmMontaron","GLOBAL",4)
PartyHasItem("X#XZRING")
THEN
RESPONSE #100
GiveItem("X#XZRING","xzar")
DisplayStringHead(Myself,~Xzar toys feverishly with his new ring. Without warning, he slips it on his finger and begins to gesticulate wildly.~)
IncrementGlobal("XzarCharmMontaron","GLOBAL",1)
StartDialogueNoSet(Player1)
END

IF
InParty(Myself)
Global("XzarCharmMontaron","GLOBAL",6)
THEN
RESPONSE #100
IncrementGlobal("XzarCharmMontaron","GLOBAL",1)
StartDialogueNoSet(Player1)
END

//Intro of Cutscene
IF
InParty("Xzar")
Global("XzarCharmMontaron","GLOBAL",2)
THEN
RESPONSE #100
ClearAllActions()
SetGlobal("XzarCharmMontaron","GLOBAL",3)
StartCutSceneMode()
StartCutScene("X#XZDR2")
END

//Setting Up Xzar's Nags after making the ring

IF
InParty("Xzar")
PartyHasItem("X#XZRING")
GlobalLT("X#XzarNags","GLOBAL",5)
THEN
RESPONSE #100
SetGlobalTimer("X#XzarNagsTime","GLOBAL",3600)
SetGlobal("X#XzarNags","GLOBAL",5)
END

IF
InParty("Xzar")
GlobalTimerExpired("X#XzarNagsTime","GLOBAL")
PartyHasItem("X#XZRING")
OR(2)
Global("X#XzarNags","GLOBAL",5)
Global("X#XzarNags","GLOBAL",7)
!HasItemEquiped("X#XZRING","xzar")
THEN
RESPONSE #100
IncrementGlobal("X#XzarNags","GLOBAL",1)
StartDialogueNoSet(Player1)
END

//Cutscene with Guards
IF
PartyHasItem("X#XZRING")
AreaType(CITY)
AreaType(OUTDOOR)
InParty("Xzar")
Global("X#XzarNags","GLOBAL",9)
!HasItemEquiped("X#XZRING","xzar")
GlobalTimerExpired("X#XzarGuards","GLOBAL")
THEN
RESPONSE #100
SetGlobal("X#XzarNags","GLOBAL",10)
ClearAllActions()
StartCutSceneMode()
StartCutScene("X#XZDR3")
END

//Timer for Xzar Abandoning the ring

IF
GlobalTimerExpired("X#XzarNagsTime","GLOBAL")
InParty("Xzar")
PartyHasItem("X#XZRING")
HasItemEquiped("X#XZRING","xzar")
GlobalLT("X#XzarNags","GLOBAL",14)
THEN
RESPONSE #100
SetGlobal("X#XzarNags","GLOBAL",14)
SetGlobalTimer("X#XzarRingFinale","GLOBAL",SEVEN_DAYS)
END

IF
InParty("Xzar")
PartyHasItem("X#XZRING")
HasItemEquiped("X#XZRING","xzar")
Global("X#XzarNags","GLOBAL",14)
GlobalTimerExpired("X#XzarRingFinale","GLOBAL")
Died([ANYTHING])
THEN
RESPONSE #100
SetGlobal("X#XzarNags","GLOBAL",15)
StartDialogueNoSet(Player1)
END



