IF
        HPPercentLT(Myself,30)
        !GlobalTimerNotExpired("HEAL_1","LOCALS")
        GlobalLT("HEAL1_INCRE","LOCALS",5)
THEN
	RESPONSE #100
		DisplayStringHead(Myself,46150)
                IncrementGlobal("HEAL1_INCRE","LOCALS",1)
                SetGlobalTimer("HEAL_1","LOCALS",6)
                CreateItem("POTN55",1,0,0)
                UseItem("POTN55",Myself)
                Continue()
END

IF
        OR(2)
          StateCheck(NearestEnemyOf(Myself),STATE_INVISIBLE)
          StateCheck(NearestEnemyOf(Myself),STATE_IMPROVEDINVISIBILITY)
        GlobalLT("WTR","LOCALS",4)
        !GlobalTimerNotExpired("TRUESIGHT","LOCALS")
THEN
	RESPONSE #100
                IncrementGlobal("WTR","LOCALS",1)
                SetGlobalTimer("TRUESIGHT","LOCALS",30)
                ReallyForceSpell(Myself,WIZARD_TRUE_SIGHT)
END

IF
        See([ENEMY])
        CheckStatGT(LastSeenBy(Myself), 100, RESISTMAGIC)
        GlobalLT("WLR","LOCALS",3)
        !Allegiance(LastSeenBy(Myself),EVILCUTOFF)
	!InMyGroup(LastSeenBy(Myself))
THEN
	RESPONSE #100
                IncrementGlobal("WLR","LOCALS",1)
                ReallyForceSpell(LastSeenBy(Myself),WIZARD_LOWER_RESISTANCE)
END

IF
        See(NearestEnemyOf(Myself))
        GlobalLT("WPMW","LOCALS",3)
        CheckStat(Myself,0,WIZARD_PROTECTION_FROM_MAGIC_WEAPONS)
THEN
	RESPONSE #100
                IncrementGlobal("WPMW","LOCALS",1)
                ReallyForceSpell(Myself,WIZARD_PROTECTION_FROM_MAGIC_WEAPONS)
END

IF
        See(NearestEnemyOf(Myself))
        GlobalLT("WST","LOCALS",3)
        !CheckStatGT(Myself, 0, STONESKINS)
THEN
	RESPONSE #100
                IncrementGlobal("WST","LOCALS",1)
                ReallyForceSpell(Myself,WIZARD_STONE_SKIN)
END

IF
        See([ENEMY])
        CheckStatLT(LastSeenBy(Myself), 10, SAVEVSDEATH)
        GlobalLT("WGM","LOCALS",3)
	!InMyGroup(LastSeenBy(Myself))
THEN
	RESPONSE #100
                IncrementGlobal("WGM","LOCALS",1)
                ReallyForceSpell(LastSeenBy(Myself),WIZARD_GREATER_MALISON)
END

IF
        RandomNum(3,1)
	See(NearestEnemyOf(Myself))
        Range(LastSeenBy(Myself),3)
        !InMyGroup(LastSeenBy(Myself))
        !Allegiance(LastSeenBy(Myself),EVILCUTOFF)
THEN
	RESPONSE #100
                DisplayStringHead(Myself,@153) // 겁화유성검!
                ReallyForceSpellRES("ru_maxs1",LastSeenBy(Myself))
                FaceObject(LastSeenBy(Myself))
                SwingOnce()
                Wait(2)
                Continue()
END

IF
        RandomNum(3,2)
	See(NearestEnemyOf(Myself))
        Range(LastSeenBy(Myself),3)
        !InMyGroup(LastSeenBy(Myself))
        !Allegiance(LastSeenBy(Myself),EVILCUTOFF)
THEN
	RESPONSE #100
                DisplayStringHead(Myself,@154) // 빙설유성검!
                ReallyForceSpellRES("ru_maxs2",LastSeenBy(Myself))
                FaceObject(LastSeenBy(Myself))
                SwingOnce()
                Wait(2)
                Continue()
END

IF
        RandomNum(3,3)
	See(NearestEnemyOf(Myself))
        Range(LastSeenBy(Myself),3)
        !InMyGroup(LastSeenBy(Myself))
        !Allegiance(LastSeenBy(Myself),EVILCUTOFF)
THEN
	RESPONSE #100
                DisplayStringHead(Myself,@155) // 비살검!
                ReallyForceSpellRES("ru_maxs3",LastSeenBy(Myself))
                FaceObject(LastSeenBy(Myself))
                SwingOnce()
                Wait(2)
                Continue()
END

IF
        See([ENEMY])
        OR(13)
          StateCheck(LastSeenBy(Myself), STATE_INVISIBLE)
          StateCheck(LastSeenBy(Myself), STATE_IMPROVEDINVISIBILITY)
          StateCheck(LastSeenBy(Myself), STATE_MIRRORIMAGE)
          StateCheck(LastSeenBy(Myself), STATE_HASTED)
	  HasBounceEffects(LastSeenBy(Myself))
	  HasImmunityEffects(LastSeenBy(Myself))
	  CheckStatGT(LastSeenBy(Myself),0,WIZARD_PROTECTION_FROM_MAGIC_WEAPONS)
	  CheckStatGT(LastSeenBy(Myself),0,WIZARD_PROTECTION_FROM_MAGIC_ENERGY)
	  CheckStatGT(LastSeenBy(Myself),0,WIZARD_MISLEAD)
	  CheckStatGT(LastSeenBy(Myself),0,WIZARD_TENSERS_TRANSFORMATION)
	  CheckStatGT(LastSeenBy(Myself),0,WIZARD_PROTECTION_FROM_ENERGY)
          CheckStatGT(LastSeenBy(Myself),0,STONESKINS)
          CheckStatGT(LastSeenBy(Myself),0,IMPROVEDHASTE)
        GlobalLT("PENE","LOCALS",10)
        !Allegiance(LastSeenBy(Myself),EVILCUTOFF)
	!InMyGroup(LastSeenBy(Myself))
THEN
	RESPONSE #25
                IncrementGlobal("PENE","LOCALS",1)
                ForceSpell(LastSeenBy(Myself),WIZARD_WARDING_WHIP)
                Continue()
	RESPONSE #25
                IncrementGlobal("PENE","LOCALS",1)
                ForceSpell(LastSeenBy(Myself),WIZARD_BREACH)
                Continue()
	RESPONSE #25
                IncrementGlobal("PENE","LOCALS",1)
                ForceSpell(LastSeenBy(Myself),WIZARD_SECRET_WORD)
                Continue()
	RESPONSE #25
                IncrementGlobal("PENE","LOCALS",1)
                ForceSpell(LastSeenBy(Myself),WIZARD_DISPEL_MAGIC)
                Continue()
END

IF
	See(NearestEnemyOf(Myself))
        Range(LastSeenBy(Myself),2)
        !CheckStat(LastSeenBy(Myself),4,WIZARD_PROTECTION_FROM_MAGIC_WEAPONS)
        !InMyGroup(LastSeenBy(Myself))
        !Allegiance(LastSeenBy(Myself),EVILCUTOFF)
THEN
	RESPONSE #100
                ReallyForceSpellRES("SPCL901",Myself)
                AttackReevaluate(LastSeenBy(Myself),30)
END

IF
        OR(3)
          Global("RangeJudge","LOCALS",1)
          Global("RangeJudge","LOCALS",2)
          Global("RangeJudge","LOCALS",3)
THEN
	RESPONSE #100
                SetGlobal("RangeJudge","LOCALS",0)
                Continue()
END

IF
	See(NearestEnemyOf(Myself))
	See(SecondNearestEnemyOf(Myself))
	See(ThirdNearestEnemyOf(Myself))
        !Range(ThirdNearestEnemyOf(Myself),3)
THEN
	RESPONSE #100
                SetGlobal("RangeJudge","LOCALS",1)
                Continue()
END

IF
	See(NearestEnemyOf(Myself))
	See(SecondNearestEnemyOf(Myself))
        !Range(SecondNearestEnemyOf(Myself),2)
THEN
	RESPONSE #100
                SetGlobal("RangeJudge","LOCALS",2)
                Continue()
END

IF
	See(NearestEnemyOf(Myself))
        !Range(NearestEnemyOf(Myself),2)
THEN
	RESPONSE #100
                SetGlobal("RangeJudge","LOCALS",3)
                Continue()
END

IF
        Global("RangeJudge","LOCALS",3)
	See(NearestEnemyOf(Myself))
THEN
	RESPONSE #50
                SetGlobal("RangeJudge","LOCALS",0)
                DisplayStringHead(Myself,@156) // 하아!
                FaceObject(NearestEnemyOf(Myself))
                ReallyForceSpellRES("ru_maxit",NearestEnemyOf(Myself))
                SwingOnce()
	RESPONSE #50
                SetGlobal("RangeJudge","LOCALS",0)
                MoveToObject(NearestEnemyOf(Myself))
END

IF
        Global("RangeJudge","LOCALS",2)
	See(NearestEnemyOf(Myself))
	See(SecondNearestEnemyOf(Myself))
THEN
	RESPONSE #50
                SetGlobal("RangeJudge","LOCALS",0)
                DisplayStringHead(Myself,@156) // 하아!
                FaceObject(SecondNearestEnemyOf(Myself))
                ReallyForceSpellRES("ru_maxit",NearestEnemyOf(Myself))
                ReallyForceSpellRES("ru_maxit",SecondNearestEnemyOf(Myself))
                SwingOnce()
	RESPONSE #50
                SetGlobal("RangeJudge","LOCALS",0)
                MoveToObject(SecondNearestEnemyOf(Myself))
END

IF
        Global("RangeJudge","LOCALS",1)
	See(NearestEnemyOf(Myself))
	See(SecondNearestEnemyOf(Myself))
	See(ThirdNearestEnemyOf(Myself))
THEN
	RESPONSE #50
                SetGlobal("RangeJudge","LOCALS",0)
                DisplayStringHead(Myself,@156) // 하아!
                FaceObject(ThirdNearestEnemyOf(Myself))
                ReallyForceSpellRES("ru_maxit",NearestEnemyOf(Myself))
                ReallyForceSpellRES("ru_maxit",SecondNearestEnemyOf(Myself))
                ReallyForceSpellRES("ru_maxit",ThirdNearestEnemyOf(Myself))
                SwingOnce()
	RESPONSE #50
                SetGlobal("RangeJudge","LOCALS",0)
                MoveToObject(ThirdNearestEnemyOf(Myself))
END

IF
	!InActiveArea(Myself)
        OR(6)
          GlobalGT("WPMW","LOCALS",0)
          GlobalGT("WGM","LOCALS",0)
          GlobalGT("WST","LOCALS",0)
          GlobalGT("WLR","LOCALS",0)
          GlobalGT("WTR","LOCALS",0)
          GlobalGT("PENE","LOCALS",0)
THEN
	RESPONSE #100
          SetGlobal("WPMW","LOCALS",0)
          SetGlobal("WGM","LOCALS",0)
          SetGlobal("WST","LOCALS",0)
          SetGlobal("WLR","LOCALS",0)
          SetGlobal("WTR","LOCALS",0)
          SetGlobal("PENE","LOCALS",0)
END