IF 
Global("O#XanMoonbladeExtinguished","GLOBAL",3)
InParty(Myself)
Global("O#XanValygarToBME","GLOBAL",0)
THEN
RESPONSE #100
RealSetGlobalTimer("O#XanValygarMETimer","GLOBAL",500)
SetGlobal("O#XanValygarToBME","GLOBAL",1)
END

IF
RealGlobalTimerExpired("O#XanValygarMETimer","GLOBAL")
InParty(Myself)
!Global("O#XanValygarMEShut","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(2)
Global("O#XanValygarToBME","GLOBAL",1)
Global("O#XanValygarToBME","GLOBAL",3)
THEN
RESPONSE #100
IncrementGlobal("O#XanValygarToBME","GLOBAL",1)
END

IF
RealGlobalTimerExpired("O#XanValygarMETimer","GLOBAL")
GlobalLT("O#XanValygarToBME","GLOBAL",19)
InParty(Myself)
!Global("O#XanValygarMEShut","GLOBAL",1)
GlobalGT("O#XanDreamTalk1","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(7)
Global("O#XanValygarToBME","GLOBAL",5)
Global("O#XanValygarToBME","GLOBAL",7)
Global("O#XanValygarToBME","GLOBAL",9)
Global("O#XanValygarToBME","GLOBAL",11)
Global("O#XanValygarToBME","GLOBAL",13)
Global("O#XanValygarToBME","GLOBAL",15)
Global("O#XanValygarToBME","GLOBAL",17)
THEN
RESPONSE #100
IncrementGlobal("O#XanValygarToBME","GLOBAL",1)
END

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

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

IF
GlobalLT("O#XanValygarToBME","GLOBAL",19)
RealGlobalTimerExpired("O#XanValygarMETimer","GLOBAL")
InParty(Myself)
!Global("O#XanValygarMEShut","GLOBAL",1)
See(Player1)
!StateCheck(Player1,CD_STATE_NOTVALID) 
!StateCheck(Myself,CD_STATE_NOTVALID)
OR(9)
Global("O#XanValygarToBME","GLOBAL",2)
Global("O#XanValygarToBME","GLOBAL",4)
Global("O#XanValygarToBME","GLOBAL",6)
Global("O#XanValygarToBME","GLOBAL",8)
Global("O#XanValygarToBME","GLOBAL",10)
Global("O#XanValygarToBME","GLOBAL",12)
Global("O#XanValygarToBME","GLOBAL",14)
Global("O#XanValygarToBME","GLOBAL",16)
Global("O#XanValygarToBME","GLOBAL",18)
THEN
RESPONSE #100
Interact(Player1)
END