IF
	InParty(Myself)
THEN
	RESPONSE #100
                DisplayStringHead(Myself,@126)
		CreateVisualEffectObject("SPUNHOLY",Myself)
                DestroyItem("rumashel")
                DestroyItem("rumaspla")
                DestroyItem("BRAC21")
                DestroyItem("AMUL20")
                DestroyItem("BELT03")
                DestroyItem("BOOT05")
                DestroyItem("RUMASTSW")
                DestroyItem("CLCK03")
                LeaveParty()
                ChangeAIScript("",DEFAULT)
		DestroySelf()
END

IF
        See(NearestEnemyOf(Myself))

        !GlobalTimerNotExpired("ImmuneTimer","LOCALS")
THEN
	RESPONSE #100
                SetGlobalTimer("ImmuneTimer","LOCALS",30)
                DisplayStringHead(Myself,@80)
                ApplySpell(Myself,WIZARD_SPELL_IMMUNITY_INVOCATION)
                ApplySpell(Myself,WIZARD_SPELL_IMMUNITY_ABJURATION)
                ApplySpell(Myself,WIZARD_SPELL_IMMUNITY_CONJURATION)
                ApplySpell(Myself,WIZARD_SPELL_SHIELD)
                ApplySpell(Myself,WIZARD_PROTECTION_FROM_MAGIC_WEAPONS)
END

IF
	See(NearestEnemyOf(Myself))
        HaveSpell(WIZARD_TIME_STOP)
        Global("NoTimeSt","LOCALS",0)
THEN
	RESPONSE #100
                Spell(NearestEnemyOf(Myself),WIZARD_TIME_STOP)
END

IF
	See(NearestEnemyOf(Myself))
        HPLT(Myself,90)
        !HP(Myself,1)
        Global("ArcheSpellStoreTwin","LOCALS",0)
THEN
	RESPONSE #100
                SetGlobal("ArcheSpellStoreTwin","LOCALS",1)
                DisplayStringHead(Myself,@92)
                ApplySpell(Myself,WIZARD_SPELL_IMMUNITY_INVOCATION)
                ApplySpell(Myself,WIZARD_SPELL_IMMUNITY_ABJURATION)
                ApplySpell(Myself,WIZARD_SPELL_IMMUNITY_CONJURATION)
                ApplySpell(Myself,WIZARD_SPELL_SHIELD)
                ApplySpell(Myself,WIZARD_PROTECTION_FROM_MAGIC_WEAPONS)
                ReallyForceSpell(NearestEnemyOf(Myself),WIZARD_ABI_DALZIMS_HORRID_WILTING)
                ReallyForceSpell(NearestEnemyOf(Myself),WIZARD_ABI_DALZIMS_HORRID_WILTING)
                ReallyForceSpell(NearestEnemyOf(Myself),WIZARD_ABI_DALZIMS_HORRID_WILTING)
                ReallyForceSpellRES("SPWI922",NearestEnemyOf(Myself))
                ReallyForceSpellRES("SPWI925",NearestEnemyOf(Myself))
END

IF
	See(NearestEnemyOf(Myself))
        HPLT(Myself,50)
        !HP(Myself,1)
        Global("ArcheTriggerTripple","LOCALS",0)
THEN
	RESPONSE #100
                SetGlobal("ArcheTriggerTripple","LOCALS",1)
                DisplayStringHead(Myself,@93)
                ApplySpell(Myself,WIZARD_TIME_STOP)
                ApplySpell(Myself,WIZARD_SPELL_IMMUNITY_INVOCATION)
                ApplySpell(Myself,WIZARD_SPELL_IMMUNITY_ABJURATION)
                ApplySpell(Myself,WIZARD_SPELL_IMMUNITY_CONJURATION)
                ApplySpell(Myself,WIZARD_SPELL_SHIELD)
                ApplySpell(Myself,WIZARD_PROTECTION_FROM_MAGIC_WEAPONS)
                ReallyForceSpell(Player1,WIZARD_LOWER_RESISTANCE)
                ReallyForceSpell(Player2,WIZARD_LOWER_RESISTANCE)
                ReallyForceSpell(Player3,WIZARD_LOWER_RESISTANCE)
                ReallyForceSpell(Player4,WIZARD_LOWER_RESISTANCE)
                ReallyForceSpell(Player5,WIZARD_LOWER_RESISTANCE)
                ReallyForceSpell(Player6,WIZARD_LOWER_RESISTANCE)
                ReallyForceSpell(Player1,WIZARD_GREATER_MALISON)
                ReallyForceSpell(Player2,WIZARD_GREATER_MALISON)
                ReallyForceSpell(Player3,WIZARD_GREATER_MALISON)
                ReallyForceSpell(Player4,WIZARD_GREATER_MALISON)
                ReallyForceSpell(Player5,WIZARD_GREATER_MALISON)
                ReallyForceSpell(Player6,WIZARD_GREATER_MALISON)
                ReallyForceSpell(Player1,WIZARD_SPELL_STRIKE)
                ReallyForceSpell(Player1,WIZARD_BREACH)
                ReallyForceSpell(Player2,WIZARD_SPELL_STRIKE)
                ReallyForceSpell(Player2,WIZARD_BREACH)
                ReallyForceSpell(Player3,WIZARD_SPELL_STRIKE)
                ReallyForceSpell(Player3,WIZARD_BREACH)
                ReallyForceSpell(Player4,WIZARD_SPELL_STRIKE)
                ReallyForceSpell(Player4,WIZARD_BREACH)
                ReallyForceSpell(Player5,WIZARD_SPELL_STRIKE)
                ReallyForceSpell(Player5,WIZARD_BREACH)
                ReallyForceSpell(Player6,WIZARD_SPELL_STRIKE)
                ReallyForceSpell(Player6,WIZARD_BREACH)
                ReallyForceSpell(NearestEnemyOf(Myself),WIZARD_INCENDIARY_CLOUD)
                ReallyForceSpell(NearestEnemyOf(Myself),WIZARD_ABI_DALZIMS_HORRID_WILTING)
                ReallyForceSpell(NearestEnemyOf(Myself),WIZARD_ABI_DALZIMS_HORRID_WILTING)
                ReallyForceSpellRES("SPWI922",NearestEnemyOf(Myself))
                ReallyForceSpellRES("SPWI925",NearestEnemyOf(Myself))
                Rest()
                SetGlobal("NoTimeSt","LOCALS",1)
END

IF
        See(NearestEnemyOf(Myself))
        HaveSpell(WIZARD_SPELL_TRAP)
        CheckStat(Myself, 0, WIZARD_SPELL_TRAP)
THEN
	RESPONSE #100
                Spell(Myself,WIZARD_SPELL_TRAP)
END

IF
        See(NearestEnemyOf(Myself))
        HaveSpell(WIZARD_PROTECTION_FROM_MAGIC_WEAPONS)
        !CheckStat(Myself,4,WIZARD_PROTECTION_FROM_MAGIC_WEAPONS)
THEN
	RESPONSE #100
                Spell(Myself,WIZARD_PROTECTION_FROM_MAGIC_WEAPONS)
                Continue()
END

IF
        HaveSpell(CLERIC_HEAL)
        HPLT(Myself, 50)
        !HP(Myself, 1)
        !Dead("rumaster")
        Global("ArcheTeleportEscape","LOCALS",0)
THEN
	RESPONSE #50
                SetGlobal("ArcheTeleportEscape","LOCALS",1)
                ReallyForceSpellPointRES("SPWI402",[664.394])
                Spell(Myself,CLERIC_HEAL)
	RESPONSE #50
                SetGlobal("ArcheTeleportEscape","LOCALS",2)
                ReallyForceSpellPointRES("SPWI402",[245.397])
                Spell(Myself,CLERIC_HEAL)
END

IF
        HaveSpell(CLERIC_HEAL)
        HPLT(Myself, 50)
        !HP(Myself, 1)
        !Dead("rumaster")
        Global("ArcheTeleportEscape","LOCALS",1)
THEN
	RESPONSE #50
                SetGlobal("ArcheTeleportEscape","LOCALS",0)
                ReallyForceSpellPointRES("SPWI402",[415.247])
                Spell(Myself,CLERIC_HEAL)
	RESPONSE #50
                SetGlobal("ArcheTeleportEscape","LOCALS",2)
                ReallyForceSpellPointRES("SPWI402",[245.397])
                Spell(Myself,CLERIC_HEAL)
END

IF
        HaveSpell(CLERIC_HEAL)
        HPLT(Myself, 50)
        !HP(Myself, 1)
        !Dead("rumaster")
        Global("ArcheTeleportEscape","LOCALS",2)
THEN
	RESPONSE #50
                SetGlobal("ArcheTeleportEscape","LOCALS",0)
                ReallyForceSpellPointRES("SPWI402",[415.247])
                Spell(Myself,CLERIC_HEAL)
	RESPONSE #50
                SetGlobal("ArcheTeleportEscape","LOCALS",1)
                ReallyForceSpellPointRES("SPWI402",[664.394])
                Spell(Myself,CLERIC_HEAL)
END

IF
        HaveSpell(CLERIC_CURE_CRITICAL_WOUNDS)
        HPLT(Myself, 120)
        !HP(Myself, 1)
        !Dead("rumaster")
        Global("ArcheTeleportEscape","LOCALS",0)
THEN
	RESPONSE #50
                SetGlobal("ArcheTeleportEscape","LOCALS",1)
                ReallyForceSpellPointRES("SPWI402",[664.394])
                Spell(Myself,CLERIC_CURE_CRITICAL_WOUNDS)
	RESPONSE #50
                SetGlobal("ArcheTeleportEscape","LOCALS",2)
                ReallyForceSpellPointRES("SPWI402",[245.397])
                Spell(Myself,CLERIC_CURE_CRITICAL_WOUNDS)
END

IF
        HaveSpell(CLERIC_CURE_CRITICAL_WOUNDS)
        HPLT(Myself, 120)
        !HP(Myself, 1)
        !Dead("rumaster")
        Global("ArcheTeleportEscape","LOCALS",1)
THEN
	RESPONSE #50
                SetGlobal("ArcheTeleportEscape","LOCALS",0)
                ReallyForceSpellPointRES("SPWI402",[415.247])
                Spell(Myself,CLERIC_CURE_CRITICAL_WOUNDS)
	RESPONSE #50
                SetGlobal("ArcheTeleportEscape","LOCALS",2)
                ReallyForceSpellPointRES("SPWI402",[245.397])
                Spell(Myself,CLERIC_CURE_CRITICAL_WOUNDS)
END

IF
        HaveSpell(CLERIC_CURE_CRITICAL_WOUNDS)
        HPLT(Myself, 120)
        !HP(Myself, 1)
        !Dead("rumaster")
        Global("ArcheTeleportEscape","LOCALS",2)
THEN
	RESPONSE #50
                SetGlobal("ArcheTeleportEscape","LOCALS",0)
                ReallyForceSpellPointRES("SPWI402",[415.247])
                Spell(Myself,CLERIC_CURE_CRITICAL_WOUNDS)
	RESPONSE #50
                SetGlobal("ArcheTeleportEscape","LOCALS",1)
                ReallyForceSpellPointRES("SPWI402",[664.394])
                Spell(Myself,CLERIC_CURE_CRITICAL_WOUNDS)
END

IF
        HaveSpell(CLERIC_CURE_SERIOUS_WOUNDS)
        HPLT(Myself, 160)
        !HP(Myself, 1)
        !Dead("rumaster")
        Global("ArcheTeleportEscape","LOCALS",0)
THEN
	RESPONSE #50
                SetGlobal("ArcheTeleportEscape","LOCALS",1)
                ReallyForceSpellPointRES("SPWI402",[664.394])
                Spell(Myself,CLERIC_CURE_SERIOUS_WOUNDS)
	RESPONSE #50
                SetGlobal("ArcheTeleportEscape","LOCALS",2)
                ReallyForceSpellPointRES("SPWI402",[245.397])
                Spell(Myself,CLERIC_CURE_SERIOUS_WOUNDS)
END

IF
        HaveSpell(CLERIC_CURE_SERIOUS_WOUNDS)
        HPLT(Myself, 160)
        !HP(Myself, 1)
        !Dead("rumaster")
        Global("ArcheTeleportEscape","LOCALS",1)
THEN
	RESPONSE #50
                SetGlobal("ArcheTeleportEscape","LOCALS",0)
                ReallyForceSpellPointRES("SPWI402",[415.247])
                Spell(Myself,CLERIC_CURE_SERIOUS_WOUNDS)
	RESPONSE #50
                SetGlobal("ArcheTeleportEscape","LOCALS",2)
                ReallyForceSpellPointRES("SPWI402",[245.397])
                Spell(Myself,CLERIC_CURE_SERIOUS_WOUNDS)
END

IF
        HaveSpell(CLERIC_CURE_SERIOUS_WOUNDS)
        HPLT(Myself, 160)
        !HP(Myself, 1)
        !Dead("rumaster")
        Global("ArcheTeleportEscape","LOCALS",2)
THEN
	RESPONSE #50
                SetGlobal("ArcheTeleportEscape","LOCALS",0)
                ReallyForceSpellPointRES("SPWI402",[415.247])
                Spell(Myself,CLERIC_CURE_SERIOUS_WOUNDS)
	RESPONSE #50
                SetGlobal("ArcheTeleportEscape","LOCALS",1)
                ReallyForceSpellPointRES("SPWI402",[664.394])
                Spell(Myself,CLERIC_CURE_SERIOUS_WOUNDS)
END

IF
        HaveSpell(CLERIC_CURE_MEDIUM_WOUNDS)
        HPLT(Myself, 200)
        !HP(Myself, 1)
        !Dead("rumaster")
        Global("ArcheTeleportEscape","LOCALS",0)
THEN
	RESPONSE #50
                SetGlobal("ArcheTeleportEscape","LOCALS",1)
                ReallyForceSpellPointRES("SPWI402",[664.394])
                Spell(Myself,CLERIC_CURE_MEDIUM_WOUNDS)
	RESPONSE #50
                SetGlobal("ArcheTeleportEscape","LOCALS",2)
                ReallyForceSpellPointRES("SPWI402",[245.397])
                Spell(Myself,CLERIC_CURE_MEDIUM_WOUNDS)
END

IF
        HaveSpell(CLERIC_CURE_MEDIUM_WOUNDS)
        HPLT(Myself, 200)
        !HP(Myself, 1)
        !Dead("rumaster")
        Global("ArcheTeleportEscape","LOCALS",1)
THEN
	RESPONSE #50
                SetGlobal("ArcheTeleportEscape","LOCALS",0)
                ReallyForceSpellPointRES("SPWI402",[415.247])
                Spell(Myself,CLERIC_CURE_MEDIUM_WOUNDS)
	RESPONSE #50
                SetGlobal("ArcheTeleportEscape","LOCALS",2)
                ReallyForceSpellPointRES("SPWI402",[245.397])
                Spell(Myself,CLERIC_CURE_MEDIUM_WOUNDS)
END

IF
        HaveSpell(CLERIC_CURE_MEDIUM_WOUNDS)
        HPLT(Myself, 200)
        !HP(Myself, 1)
        !Dead("rumaster")
        Global("ArcheTeleportEscape","LOCALS",2)
THEN
	RESPONSE #50
                SetGlobal("ArcheTeleportEscape","LOCALS",0)
                ReallyForceSpellPointRES("SPWI402",[415.247])
                Spell(Myself,CLERIC_CURE_MEDIUM_WOUNDS)
	RESPONSE #50
                SetGlobal("ArcheTeleportEscape","LOCALS",1)
                ReallyForceSpellPointRES("SPWI402",[664.394])
                Spell(Myself,CLERIC_CURE_MEDIUM_WOUNDS)
END

IF
        HaveSpell(WIZARD_WARDING_WHIP)
        Allegiance(LastSeenBy(Myself),PC)
        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)
THEN
	RESPONSE #100
                Spell(LastSeenBy(Myself),WIZARD_WARDING_WHIP)
                Continue()
END

IF
        HaveSpell(WIZARD_BREACH)
        Allegiance(LastSeenBy(Myself),PC)
        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)
THEN
	RESPONSE #100
                Spell(LastSeenBy(Myself),WIZARD_BREACH)
                Continue()
END

IF
        HaveSpell(WIZARD_SECRET_WORD)
        Allegiance(LastSeenBy(Myself),PC)
        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)
THEN
	RESPONSE #100
                Spell(LastSeenBy(Myself),WIZARD_SECRET_WORD)
                Continue()
END

IF
        Allegiance(LastSeenBy(Myself),PC)
        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)
THEN
	RESPONSE #100
                Spell(LastSeenBy(Myself),WIZARD_DISPEL_MAGIC)
                Continue()
END

IF
	HaveSpell(WIZARD_LOWER_RESISTANCE)
        See(NearestEnemyOf(Myself))
        CheckStatGT(NearestEnemyOf(Myself), 0, RESISTMAGIC)
THEN
	RESPONSE #100
                Spell(NearestEnemyOf(Myself),WIZARD_LOWER_RESISTANCE)
                Continue()
END

IF
	HaveSpell(WIZARD_GREATER_MALISON)
        See(NearestEnemyOf(Myself))
        CheckStatLT(NearestEnemyOf(Myself), 15, SAVEVSDEATH)
THEN
	RESPONSE #100
                Spell(NearestEnemyOf(Myself),WIZARD_GREATER_MALISON)
                Continue()
END

IF
        HaveSpell(WIZARD_IMPRISONMENT)
	See(StrongestOf(NearestEnemyOf(Myself)))
        Range(LastSeenBy(Myself),4)
	!InMyGroup(LastSeenBy(Myself))
THEN
	RESPONSE #30
                Spell(LastSeenBy(Myself),WIZARD_IMPRISONMENT)
                Continue()
END

IF
	See(StrongestOf(NearestEnemyOf(Myself)))
        HPLT(Myself, 150)
        HaveSpell(WIZARD_MAZE)
	!InMyGroup(LastSeenBy(Myself))
THEN
	RESPONSE #100
                Spell(LastSeenBy(Myself),WIZARD_MAZE)
END

IF
        HaveSpellRES("SPWI912")
        See([ENEMY])
        HPLT(LastSeenBy(Myself), 60)
	!InMyGroup(LastSeenBy(Myself))
THEN
	RESPONSE #100
                SpellRES("SPWI912",LastSeenBy(Myself))
END

IF
        HaveSpell(CLERIC_REGENERATE)
        HPLT(Myself,150)
        !CheckStatGT(Myself,0,CLERIC_REGENERATION)
THEN
	RESPONSE #100
                Spell(Myself,CLERIC_REGENERATE)
END

IF
        ActuallyInCombat()
        HaveSpell(WIZARD_STONE_SKIN)
        !CheckStatGT(Myself, 0, STONESKINS)
THEN
	RESPONSE #100
                Spell(Myself,WIZARD_STONE_SKIN)
END

IF
        ActuallyInCombat()
        HaveSpell(CLERIC_IRONSKIN)
        !CheckStatGT(Myself, 0, STONESKINS)
THEN
	RESPONSE #100
                Spell(Myself,CLERIC_IRONSKIN)
END

IF
        ActuallyInCombat()
	HaveSpell(WIZARD_MIRROR_IMAGE)
	!StateCheck(Myself,STATE_MIRRORIMAGE)
THEN
	RESPONSE #100
		Spell(Myself,WIZARD_MIRROR_IMAGE)
                Continue()
END

IF
        ActuallyInCombat()
        HaveSpell(CLERIC_ARMOR_OF_FAITH)
        !CheckStat(Myself,1,CLERIC_ARMOR_OF_FAITH)
THEN
	RESPONSE #100
                Spell(Myself,CLERIC_ARMOR_OF_FAITH)
                Continue()
END

IF
        ActuallyInCombat()
        HaveSpell(CLERIC_BLESS)
        !StateCheck(Myself,STATE_BLESS)
THEN
	RESPONSE #100
                Spell(Myself,CLERIC_BLESS)
                Continue()
END

IF
        ActuallyInCombat()
        HaveSpell(CLERIC_AID)
        !StateCheck(Myself,STATE_AID)
THEN
	RESPONSE #100
                Spell(Myself,CLERIC_AID)
                Continue()
END

IF
        ActuallyInCombat()
        HaveSpell(CLERIC_CHANT)
        !StateCheck(Myself,STATE_CHANT)
THEN
	RESPONSE #100
                Spell(Myself,CLERIC_CHANT)
                Continue()
END

IF
        See([ENEMY])
        HaveSpell(CLERIC_DEFENSIVE_HARMONY)
        !GlobalTimerNotExpired("DHarmony","LOCALS")
THEN
	RESPONSE #100
                SetGlobalTimer("DHarmony","LOCALS",36)
                Spell(Myself,CLERIC_DEFENSIVE_HARMONY)
                Continue()
END

IF
        See([ENEMY])
        HaveSpell(CLERIC_PROTECTION_FROM_FIRE)
        OR(2)
        CheckStatLT(Myself, 100, RESISTFIRE)
        CheckStatLT(Myself, 80, RESISTMAGICFIRE)
THEN
	RESPONSE #100
                Spell(Myself,CLERIC_PROTECTION_FROM_FIRE)
                Continue()
END

IF
        See([ENEMY])
        HaveSpell(CLERIC_PROTECTION_FROM_LIGHTNING)
        CheckStatLT(Myself, 100, RESISTELECTRICITY)
THEN
	RESPONSE #100
                Spell(Myself,CLERIC_PROTECTION_FROM_LIGHTNING)
                Continue()
END

IF
        HaveSpell(WIZARD_FIRE_SHIELD_BLUE)
        OR(2)
        CheckStatLT(Myself, 100, RESISTCOLD)
        CheckStatLT(Myself, 100, RESISTMAGICCOLD)
THEN
	RESPONSE #100
                Spell(Myself,WIZARD_FIRE_SHIELD_BLUE)
                Continue()
END

IF
        See([ENEMY])
        HaveSpell(WIZARD_SPELL_SHIELD)
        !CheckStat(Myself,1,WIZARD_SPELL_SHIELD)
THEN
	RESPONSE #100
                Spell(Myself,WIZARD_SPELL_SHIELD)
                Continue()
END

IF
        HaveSpell(WIZARD_DEATH_FOG)
        See([0.0.0.0.0.SUMMONED])
	!InMyGroup(LastSeenBy(Myself))
THEN
	RESPONSE #100
                Spell(LastSeenBy(Myself),WIZARD_DEATH_FOG)
                Continue()
END

IF
        HaveSpellRES("SPWI922")
        Allegiance(LastSeenBy(Myself),PC)
        CheckStatLT(LastSeenBy(Myself), 91, RESISTFIRE)
THEN
	RESPONSE #100
                SpellRES("SPWI922",LastSeenBy(Myself))
                Continue()
END

IF
        HaveSpell(WIZARD_INCENDIARY_CLOUD)
        CheckStatGT(Myself, 99, RESISTFIRE)
        Allegiance(LastSeenBy(Myself),PC)
        CheckStatLT(LastSeenBy(Myself), 76, RESISTFIRE)
        CheckStatLT(LastSeenBy(Myself), 76, RESISTMAGIC)
THEN
	RESPONSE #100
                Spell(LastSeenBy(Myself),WIZARD_INCENDIARY_CLOUD)
                Continue()
END

IF
        HaveSpell(WIZARD_ABI_DALZIMS_HORRID_WILTING)
        Allegiance(LastSeenBy(Myself),PC)
        CheckStatLT(LastSeenBy(Myself), 80, MAGICDAMAGERESISTANCE)
        CheckStatLT(LastSeenBy(Myself), 80, RESISTMAGIC)
THEN
	RESPONSE #100
                Spell(LastSeenBy(Myself),WIZARD_ABI_DALZIMS_HORRID_WILTING)
                Continue()
END

IF
        HaveSpellRES("SPPR722")
        Allegiance(LastSeenBy(Myself),PC)
        CheckStatLT(LastSeenBy(Myself), 80, RESISTMAGIC)
        OR(3)
        CheckStatLT(LastSeenBy(Myself), 80, RESISTFIRE)
        CheckStatLT(LastSeenBy(Myself), 80, RESISTELECTRICITY)
        CheckStatLT(LastSeenBy(Myself), 80, RESISTACID)
THEN
	RESPONSE #100
                SpellRES("SPPR722",LastSeenBy(Myself))
                Continue()
END

IF
        HaveSpellRES("SPPR720")
        Allegiance(LastSeenBy(Myself),PC)
        CheckStatLT(LastSeenBy(Myself), 80, RESISTCRUSHING)
THEN
	RESPONSE #100
                SpellRES("SPPR720",LastSeenBy(Myself))
                Continue()
END

IF
        HaveSpell(WIZARD_SKULL_TRAP)
        Allegiance(LastSeenBy(Myself),PC)
        CheckStatLT(LastSeenBy(Myself), 80, MAGICDAMAGERESISTANCE)
        CheckStatLT(LastSeenBy(Myself), 80, RESISTMAGIC)
THEN
	RESPONSE #100
                Spell(LastSeenBy(Myself),WIZARD_SKULL_TRAP)
                Continue()
END

IF
        HaveSpell(WIZARD_FLAME_ARROW)
        Allegiance(LastSeenBy(Myself),PC)
        CheckStatLT(LastSeenBy(Myself), 80, RESISTFIRE)
        CheckStatLT(LastSeenBy(Myself), 80, RESISTMAGIC)
THEN
	RESPONSE #100
                Spell(LastSeenBy(Myself),WIZARD_FLAME_ARROW)
                Continue()
END

IF
        HaveSpell(WIZARD_LIGHTNING_BOLT)
        Allegiance(LastSeenBy(Myself),PC)
        CheckStatLT(LastSeenBy(Myself), 80, RESISTELECTRICITY)
        CheckStatLT(LastSeenBy(Myself), 80, RESISTMAGIC)
THEN
	RESPONSE #100
                Spell(LastSeenBy(Myself),WIZARD_LIGHTNING_BOLT)
                Continue()
END

IF
        HaveSpell(CLERIC_FLAME_STRIKE)
        Allegiance(LastSeenBy(Myself),PC)
        CheckStatLT(LastSeenBy(Myself), 80, RESISTFIRE)
        CheckStatLT(LastSeenBy(Myself), 80, RESISTMAGIC)
THEN
	RESPONSE #100
                Spell(LastSeenBy(Myself),CLERIC_FLAME_STRIKE)
                Continue()
END

IF
        HaveSpell(WIZARD_IMPROVED_HASTE)
        OR(2)
        !StateCheck(Myself, STATE_HASTED)
        CheckStat(Myself,0,IMPROVEDHASTE)
THEN
	RESPONSE #100
                Spell(Myself,WIZARD_IMPROVED_HASTE)
                Continue()
END

IF
        HaveSpellRES("SPPR730")
THEN
	RESPONSE #100
                SpellRES("SPPR730",Myself)
                Continue()
END

IF
        HaveSpell(CLERIC_BLADE_BARRIER)
        !HaveSpellRES("SPPR725")
        CheckStat(Myself,0,CLERIC_BLADE_BARRIER)
THEN
	RESPONSE #100
                Spell(Myself,CLERIC_BLADE_BARRIER)
                Continue()
END

IF
        HaveSpellRES("SPPR725")
        CheckStat(Myself,0,CLERIC_BLADE_BARRIER)
THEN
	RESPONSE #100
                SpellRES("SPPR725",Myself)
                Continue()
END

IF
        HaveSpell(WIZARD_POWER_WORD_STUN)
        Allegiance(LastSeenBy(Myself),PC)
        HPLT(LastSeenBy(Myself), 90)
        CheckStatLT(LastSeenBy(Myself), 76, RESISTMAGIC)
	!StateCheck(LastSeenBy(Myself),STATE_STUNNED)
THEN
	RESPONSE #100
                Spell(LastSeenBy(Myself),WIZARD_POWER_WORD_STUN)
                Continue()
END

IF
        HaveSpellRES("SPCL914")
	Range(NearestEnemyOf(Myself),6)
        !CheckStat(LastSeenBy(Myself),4,WIZARD_PROTECTION_FROM_MAGIC_WEAPONS)
        !GlobalTimerNotExpired("ArcheProtectMWTimer","LOCALS")
THEN
	RESPONSE #100
                SetGlobalTimer("ArcheProtectMWTimer","LOCALS",30)
                SpellRES("SPCL914",Myself)
                Continue()
END

IF
        See(NearestEnemyOf(Myself))
        !CheckStat(LastSeenBy(Myself),4,WIZARD_PROTECTION_FROM_MAGIC_WEAPONS)
	!Range(LastSeenBy(Myself),6)
	!InMyGroup(LastSeenBy(Myself))
THEN
	RESPONSE #100
		ReallyForceSpell(LastSeenBy(Myself),PHASE_SPIDER_TELEPORT)
                Continue()
END

IF
        HaveSpellRES("SPCL901")
        See(NearestEnemyOf(Myself))
        !CheckStat(LastSeenBy(Myself),4,WIZARD_PROTECTION_FROM_MAGIC_WEAPONS)
	Range(LastSeenBy(Myself),6)
	!InMyGroup(LastSeenBy(Myself))
THEN
	RESPONSE #100
                SpellRES("SPCL901",Myself)
		AttackReevaluate(LastSeenBy(Myself),30)
END

IF
        !HaveSpellRES("SPCL901")
        See(NearestEnemyOf(Myself))
        !CheckStat(LastSeenBy(Myself),4,WIZARD_PROTECTION_FROM_MAGIC_WEAPONS)
	Range(LastSeenBy(Myself),6)
	!InMyGroup(LastSeenBy(Myself))
THEN
	RESPONSE #100
		AttackReevaluate(LastSeenBy(Myself),30)
END

IF
        ActuallyInCombat()
        !See(NearestEnemyOf(Myself))
        Global("ArcheTeleportEscape","LOCALS",0)
THEN
	RESPONSE #50
                SetGlobal("ArcheTeleportEscape","LOCALS",1)
                ReallyForceSpellPointRES("SPWI402",[664.394])
	RESPONSE #50
                SetGlobal("ArcheTeleportEscape","LOCALS",2)
                ReallyForceSpellPointRES("SPWI402",[245.397])
END

IF
        ActuallyInCombat()
        !See(NearestEnemyOf(Myself))
        Global("ArcheTeleportEscape","LOCALS",1)
THEN
	RESPONSE #50
                SetGlobal("ArcheTeleportEscape","LOCALS",0)
                ReallyForceSpellPointRES("SPWI402",[415.247])
	RESPONSE #50
                SetGlobal("ArcheTeleportEscape","LOCALS",2)
                ReallyForceSpellPointRES("SPWI402",[245.397])
END

IF
        ActuallyInCombat()
        !See(NearestEnemyOf(Myself))
        Global("ArcheTeleportEscape","LOCALS",2)
THEN
	RESPONSE #50
                SetGlobal("ArcheTeleportEscape","LOCALS",0)
                ReallyForceSpellPointRES("SPWI402",[415.247])
	RESPONSE #50
                SetGlobal("ArcheTeleportEscape","LOCALS",1)
                ReallyForceSpellPointRES("SPWI402",[664.394])
END