IF
        !Detect([ENEMY])
        !InActiveArea(Myself)
THEN
	RESPONSE #100
                DestroySelf()
END

IF
        Global("RUMAGECRSTART","LOCALS",0)
        Detect([ENEMY])
THEN
	RESPONSE #100
                SetGlobal("RUMAGECRSTART","LOCALS",1)
                DisplayStringHead(Myself,@117)
                ReallyForceSpell(Myself,WIZARD_DEATH_SPELL)
                Continue()
END

IF
        Global("RUMAGECRMAGICPROTECTION","LOCALS",0)
THEN
	RESPONSE #100
                SetGlobal("RUMAGECRMAGICPROTECTION","LOCALS",1)
                CreateItem("rumascr7",1,0,0)
                UseItem("rumascr7",Myself)
                Continue()
END

IF
        !GlobalTimerNotExpired("RUMAGECRTriggerT","LOCALS")
THEN
	RESPONSE #100
                SetGlobalTimer("RUMAGECRTriggerT","LOCALS",60)
                DisplayStringHead(Myself,@79)
                ApplySpell(Myself,WIZARD_MIRROR_IMAGE)
                ApplySpell(Myself,WIZARD_NON_DETECTION)
                ApplySpell(Myself,WIZARD_STONE_SKIN)
                ApplySpell(Myself,WIZARD_PROTECTION_FROM_MAGIC_WEAPONS)
                ApplySpell(Myself,WIZARD_SPELL_IMMUNITY_DIVINATION)
                Wait(6)
                Continue()
END

IF
        !GlobalTimerNotExpired("RUMAGECRContingencyT","LOCALS")
THEN
	RESPONSE #100
                SetGlobalTimer("RUMAGECRContingencyT","LOCALS",60)
                DisplayStringHead(Myself,@80)
                ApplySpell(Myself,WIZARD_PROTECTION_FROM_FIRE)
                ApplySpell(Myself,WIZARD_PROTECTION_FROM_COLD)
                ApplySpell(Myself,WIZARD_FIRE_SHIELD_RED)
                ApplySpell(Myself,WIZARD_IMPROVED_INVISIBILITY)
                ApplySpell(Myself,WIZARD_MISLEAD)
                Wait(6)
                Continue()
END

IF
        !GlobalTimerNotExpired("RUMAGECRSequencerT","LOCALS")
THEN
	RESPONSE #100
                SetGlobalTimer("RUMAGECRSequencerT","LOCALS",60)
                DisplayStringHead(Myself,@81)
                ApplySpell(Myself,WIZARD_SPELL_IMMUNITY_ABJURATION)
                ApplySpell(Myself,WIZARD_SPELL_SHIELD)
                ApplySpell(Myself,WIZARD_PROTECTION_FROM_MAGIC_WEAPONS)
                ApplySpell(Myself,WIZARD_TRUE_SIGHT)
                ApplySpell(Myself,WIZARD_SIMULACRUM)
                Wait(6)
                Continue()
END

IF
	See([ENEMY])
        !GlobalTimerNotExpired("RUMAGECRMORDENT","LOCALS")
THEN
	RESPONSE #100
                SetGlobalTimer("RUMAGECRMORDENT","LOCALS",120)
                DisplayStringHead(Myself,@118)
                ReallyForceSpellRES("SPWI923",Myself)
                ReallyForceSpellRES("SPWI923",Myself)
                ReallyForceSpellRES("SPWI923",Myself)
                ReallyForceSpellRES("SPWI923",Myself)
                ReallyForceSpellRES("SPWI923",Myself)
                Wait(6)
                Continue()
END

IF
	Detect([ANYONE])
        Name("rukmage1",LastSeenBy(Myself))
        InMyGroup(LastSeenBy(Myself))
        !HasItem("rumcheck",LastSeenBy(Myself))
THEN
	RESPONSE #100
                GiveItemCreate("rumcheck",LastSeenBy(Myself),1,0,0)

                ActionOverride(LastSeenBy(Myself),ChangeAIScript("RUMAGEMN",OVERRIDE))
                Continue()
END

IF
	Detect("PLANGOOD")
        InMyGroup(LastSeenBy(Myself))
        !HasItem("BLAKBLAD",LastSeenBy(Myself))
THEN
	RESPONSE #100
                ReallyForceSpellRES("RUMAGEPB",LastSeenBy(Myself))
                ActionOverride(LastSeenBy(Myself),ChangeAIScript("RUMAGESC",OVERRIDE))
END

IF
	See([ENEMY])
        CheckStatLT(LastSeenBy(Myself), 50, RESISTMAGIC)
        HPLT(LastSeenBy(Myself), 60)
	!InMyGroup(LastSeenBy(Myself))
THEN
	RESPONSE #100
                ForceSpell(LastSeenBy(Myself),WIZARD_POWER_WORD_KILL)
END

IF
	See([ENEMY])
        CheckStatLT(LastSeenBy(Myself), 50, RESISTMAGIC)
        CheckStatGT(LastSeenBy(Myself), 10, SAVEVSDEATH)
	!InMyGroup(LastSeenBy(Myself))
THEN
	RESPONSE #100
                ForceSpell(LastSeenBy(Myself),WIZARD_WAIL_OF_THE_BANSHEE)
END

IF
        CheckStatGT(Myself, 99, RESISTFIRE)
	See([ENEMY])
        CheckStatLT(LastSeenBy(Myself), 50, RESISTMAGIC)
        CheckStatLT(LastSeenBy(Myself), 50, RESISTFIRE)
        !GlobalTimerNotExpired("RUMAGECRCLOUDT","LOCALS")
	!InMyGroup(LastSeenBy(Myself))
THEN
	RESPONSE #100
                SetGlobalTimer("RUMAGECRCLOUDT","LOCALS",60)
                ForceSpell(LastSeenBy(Myself),WIZARD_INCENDIARY_CLOUD)
                Continue()
END

IF
	See([ENEMY])
        CheckStatLT(LastSeenBy(Myself), 70, RESISTFIRE)
	!InMyGroup(LastSeenBy(Myself))
THEN
	RESPONSE #100
                ForceSpellRES("SPWI922",LastSeenBy(Myself))
                Continue()
END

IF
	See([ENEMY])
        CheckStatLT(LastSeenBy(Myself), 50, RESISTMAGIC)
        CheckStatLT(LastSeenBy(Myself), 50, MAGICDAMAGERESISTANCE)
	!InMyGroup(LastSeenBy(Myself))
THEN
	RESPONSE #100
                ForceSpell(LastSeenBy(Myself),WIZARD_ABI_DALZIMS_HORRID_WILTING)
                Continue()
END

IF
	See([ENEMY])
        CheckStatGT(LastSeenBy(Myself), 30, RESISTMAGIC)
	!InMyGroup(LastSeenBy(Myself))
THEN
	RESPONSE #100
                ForceSpell(LastSeenBy(Myself),WIZARD_LOWER_RESISTANCE)
                ReallyForceSpell(LastSeenBy(Myself),WIZARD_LOWER_RESISTANCE)
                ReallyForceSpell(LastSeenBy(Myself),WIZARD_LOWER_RESISTANCE)
                Continue()
END

IF
	See([ENEMY])
        CheckStatLT(LastSeenBy(Myself), 10, SAVEVSDEATH)
	!InMyGroup(LastSeenBy(Myself))
THEN
	RESPONSE #100
                ForceSpell(LastSeenBy(Myself),WIZARD_GREATER_MALISON)
                ReallyForceSpell(LastSeenBy(Myself),WIZARD_GREATER_MALISON)
                ReallyForceSpell(LastSeenBy(Myself),WIZARD_GREATER_MALISON)
                Continue()
END

IF
        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)
	!InMyGroup(LastSeenBy(Myself))
THEN
	RESPONSE #100
                ForceSpell(LastSeenBy(Myself),WIZARD_DISPEL_MAGIC)
                Continue()
END

IF
        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)
	!InMyGroup(LastSeenBy(Myself))
THEN
	RESPONSE #100
                ForceSpell(LastSeenBy(Myself),WIZARD_SPELL_STRIKE)
                ReallyForceSpell(LastSeenBy(Myself),WIZARD_BREACH)
END

IF
        !Detect([ENEMY])
        !Range([PC],10)

        InActiveArea(Myself)
THEN
	RESPONSE #100
                RandomWalk()
END