IF
      Die()
THEN
      RESPONSE #100
	  ReallyForceSpellDeadRES("ru_stna2",Myself)
END

IF
        Global("RU_STAGE_OVER","GLOBAL",1)
THEN
	RESPONSE #100
                ReallyForceSpellRES("ru_disap",Myself)
                Wait(2)
                DestroySelf()
END

IF
	See([ENEMY])
	Global("Prep","LOCALS",0)
THEN
	RESPONSE #100
		ApplySpell(Myself,WIZARD_STONE_SKIN)
		ApplySpell(Myself,WIZARD_ABSOLUTE_IMMUNITY)
		ApplySpell(Myself,WIZARD_SPELL_SHIELD)
		ApplySpell(Myself,WIZARD_SPELL_TRAP)
		ApplySpell(Myself,WIZARD_PROTECTION_FROM_ENERGY)
		SetGlobal("Prep","LOCALS",1)
END

IF
	See(NearestEnemyOf(Myself))
	TookDamage()
	Global("Contingency","LOCALS",0)
THEN
	RESPONSE #100
		DisplayString(Myself,40252) // 위기대비 - 마법적 무기에서 보호
		DisplayString(Myself,325) // 위기 대비 - 주문 반사
		DisplayString(Myself,326) // 위기 대비 - 미스리드
		ApplySpell(Myself,WIZARD_ABSOLUTE_IMMUNITY)
		ApplySpell(Myself,WIZARD_SPELL_TURNING)
		ApplySpell(Myself,WIZARD_MISLEAD)
		ApplySpell(Myself,WIZARD_SPELL_SHIELD)
		SetGlobal("Contingency","LOCALS",1)
END

IF
	See(NearestEnemyOf(Myself))
	TookDamage()
	Global("Contingency","LOCALS",1)
THEN
	RESPONSE #100
		DisplayString(Myself,40252) // 위기대비 - 마법적 무기에서 보호
		ApplySpell(Myself,WIZARD_STONE_SKIN)
		SetGlobal("Contingency","LOCALS",2)
END

IF
	See(NearestEnemyOf(Myself))
	Global("SpellTrigger","LOCALS",0)
THEN
	RESPONSE #100
		DisplayString(Myself,39968) // 주문 트리거 - 발동
		ReallyForceSpell(Myself,WIZARD_FIRE_SHIELD_RED)
		ReallyForceSpell(Myself,WIZARD_FIRE_SHIELD_BLUE)
		DisplayString(Myself,40245) // 주문 트리거 - 무적의 구체
		ReallyForceSpell(Myself,WIZARD_GLOBE_OF_INVULNERABILITY)
		DisplayString(Myself,328) // 주문 트리거 - 미스리드
		ReallyForceSpell(Myself,WIZARD_MISLEAD)
		SetGlobal("SpellTrigger","LOCALS",1)
END

IF
	See(NearestEnemyOf(Myself))
	Global("TimeStop","LOCALS",0)
THEN
	RESPONSE #100
		SetGlobal("TimeStop","LOCALS",1)
		Spell(Myself,WIZARD_TIME_STOP)
END

IF
	See(NearestEnemyOf(Myself))
	Global("TimeStop","LOCALS",1)
THEN
	RESPONSE #100
		SetGlobal("TimeStop","LOCALS",2)
		Spell(NearestEnemyOf(Myself),WIZARD_WAIL_OF_THE_BANSHEE)
		Spell(NearestEnemyOf(Myself),WIZARD_ABI_DALZIMS_HORRID_WILTING)
		Spell(NearestEnemyOf(Myself),WIZARD_MAZE)
		ForceSpell(Myself,WIZARD_ABSOLUTE_IMMUNITY)
END

IF
	!See(NearestEnemyOf(Myself))
	Delay(10)
	Global("TRUE_SIGHT","LOCALS",0)
THEN
	RESPONSE #100
                SetGlobal("TRUE_SIGHT","LOCALS",1)
		ForceSpell(Myself,WIZARD_TRUE_SIGHT)
END

IF
	See(NearestEnemyOf(Myself))
	StateCheck(Myself,STATE_SILENCED)
	HaveSpell(WIZARD_VOCALIZE)
THEN
	RESPONSE #100
		Spell(Myself,WIZARD_VOCALIZE)
END

IF
	See([ENEMY.0.0.0.0.SUMMONED])
	HaveSpell(WIZARD_DEATH_SPELL)
	Global("CastDeath","LOCALS",0)
THEN
	RESPONSE #100
		Spell(LastSeenBy(Myself),WIZARD_DEATH_SPELL)
		SetGlobal("CastDeath","LOCALS",1)
END

IF
	See([ENEMY.0.0.LONG_BOW])
	Global("SpellTrigger","LOCALS",1)
THEN
	RESPONSE #100
		DisplayString(Myself,39969) // 마법 저장기 - 발동
		ReallyForceSpell(LastSeenBy(Myself),WIZARD_SPELL_STRIKE)
		ReallyForceSpell(LastSeenBy(Myself),WIZARD_POWER_WORD_KILL)
		ReallyForceSpell(LastSeenBy(Myself),WIZARD_ICE_STORM)
		SetGlobal("SpellTrigger","LOCALS",2)
END

IF
	See(NearestEnemyOf(Myself))
	HaveSpell(WIZARD_PRISMATIC_SPRAY)
THEN
	RESPONSE #100
		Spell(Player6,WIZARD_PRISMATIC_SPRAY)
	RESPONSE #50
		Continue()
END

IF
	See(NearestEnemyOf(Myself))
	Global("TimeStop","LOCALS",2)
THEN
	RESPONSE #100
		SetGlobal("TimeStop","LOCALS",3)
		Spell(Myself,WIZARD_TIME_STOP)
END

IF
	See(NearestEnemyOf(Myself))
	Global("TimeStop","LOCALS",3)
THEN
	RESPONSE #100
		SetGlobal("TimeStop","LOCALS",4)
		Spell(NearestEnemyOf(Myself),WIZARD_MAZE)
		Spell(SecondNearestEnemyOf(Myself),WIZARD_MAZE)
END

IF
	See(NearestEnemyOf(Myself))
	Global("Absolute","LOCALS",0)
THEN
	RESPONSE #100
		SetGlobal("Absolute","LOCALS",1)
		ForceSpell(Myself,WIZARD_ABSOLUTE_IMMUNITY)
END

IF
	See(NearestEnemyOf(Myself))
	HaveSpell(WIZARD_ABI_DALZIMS_HORRID_WILTING)
THEN
	RESPONSE #100
		Spell(NearestEnemyOf(Myself),WIZARD_ABI_DALZIMS_HORRID_WILTING)
	RESPONSE #50
		Continue()
END

IF
	See(NearestEnemyOf(Myself))
	HPLT(LastSeenBy(Myself),60)
	HaveSpell(WIZARD_POWER_WORD_KILL)
THEN
	RESPONSE #100
		Spell(LastSeenBy(Myself),WIZARD_POWER_WORD_KILL)
END

IF
	See(SecondNearestEnemyOf(Myself))
	HPLT(LastSeenBy(Myself),60)
	HaveSpell(WIZARD_POWER_WORD_KILL)
THEN
	RESPONSE #100
		Spell(LastSeenBy(Myself),WIZARD_POWER_WORD_KILL)
END

IF
	See(ThirdNearestEnemyOf(Myself))
	HPLT(LastSeenBy(Myself),60)
	HaveSpell(WIZARD_POWER_WORD_KILL)
THEN
	RESPONSE #100
		Spell(LastSeenBy(Myself),WIZARD_POWER_WORD_KILL)
END

IF
	See(FourthNearestEnemyOf(Myself))
	HPLT(LastSeenBy(Myself),60)
	HaveSpell(WIZARD_POWER_WORD_KILL)
THEN
	RESPONSE #100
		Spell(LastSeenBy(Myself),WIZARD_POWER_WORD_KILL)
END

IF
	See(FifthNearestEnemyOf(Myself))
	HPLT(LastSeenBy(Myself),60)
	HaveSpell(WIZARD_POWER_WORD_KILL)
THEN
	RESPONSE #100
		Spell(LastSeenBy(Myself),WIZARD_POWER_WORD_KILL)
END

IF
	See(SixthNearestEnemyOf(Myself))
	HPLT(LastSeenBy(Myself),60)
	HaveSpell(WIZARD_POWER_WORD_KILL)
THEN
	RESPONSE #100
		Spell(LastSeenBy(Myself),WIZARD_POWER_WORD_KILL)
END

IF
	See(SeventhNearestEnemyOf(Myself))
	HPLT(LastSeenBy(Myself),60)
	HaveSpell(WIZARD_POWER_WORD_KILL)
THEN
	RESPONSE #100
		Spell(LastSeenBy(Myself),WIZARD_POWER_WORD_KILL)
END

IF
	See(EighthNearestEnemyOf(Myself))
	HPLT(LastSeenBy(Myself),60)
	HaveSpell(WIZARD_POWER_WORD_KILL)
THEN
	RESPONSE #100
		Spell(LastSeenBy(Myself),WIZARD_POWER_WORD_KILL)
END

IF
	See(NinthNearestEnemyOf(Myself))
	HPLT(LastSeenBy(Myself),60)
	HaveSpell(WIZARD_POWER_WORD_KILL)
THEN
	RESPONSE #100
		Spell(LastSeenBy(Myself),WIZARD_POWER_WORD_KILL)
END

IF
	See(TenthNearestEnemyOf(Myself))
	HPLT(LastSeenBy(Myself),60)
	HaveSpell(WIZARD_POWER_WORD_KILL)
THEN
	RESPONSE #100
		Spell(LastSeenBy(Myself),WIZARD_POWER_WORD_KILL)
END

IF
	See(NearestEnemyOf(Myself))
	HaveSpell(WIZARD_SUN_FIRE)
THEN
	RESPONSE #100
		Spell(LastSeenBy(Myself),WIZARD_SUN_FIRE)
	RESPONSE #50
		Continue()
END

IF
	See(NearestEnemyOf(Myself))
	HaveSpell(WIZARD_POWER_WORD_STUN)
THEN
	RESPONSE #100
		Spell(LastSeenBy(Myself),WIZARD_POWER_WORD_STUN)
	RESPONSE #50
		Continue()
END

IF
	See(NearestEnemyOf(Myself))
	HaveSpell(WIZARD_MAZE)
THEN
	RESPONSE #100
		Spell(NearestEnemyOf(Myself),WIZARD_MAZE)
	RESPONSE #50
		Continue()
END

IF
	See(NearestEnemyOf(Myself))
	HaveSpell(WIZARD_CONE_OF_COLD)
THEN
	RESPONSE #100
		Spell(LastSeenBy(Myself),WIZARD_CONE_OF_COLD)
	RESPONSE #50
		Continue()
END

IF
	See(NearestEnemyOf(Myself))
	HaveSpell(WIZARD_FLAME_ARROW)
THEN
	RESPONSE #100
		Spell(LastSeenBy(Myself),WIZARD_FLAME_ARROW)
	RESPONSE #50
		Continue()
END

IF
	See(NearestEnemyOf(Myself))
	HaveSpell(WIZARD_MELF_ACID_ARROW)
THEN
	RESPONSE #100
		Spell(LastSeenBy(Myself),WIZARD_MELF_ACID_ARROW)
	RESPONSE #50
		Continue()
END

IF
	See(NearestEnemyOf(Myself))
THEN
	RESPONSE #100
		ForceSpell(NearestEnemyOf(Myself),WIZARD_MAGIC_MISSILE)
END

