IF
	Die()
THEN
	RESPONSE #100
		CreateVisualEffectObject("SPUNHOLY",Myself)
                ChangeAIScript("PLANGOOD",OVERRIDE)
		DestroySelf()
END

IF
	HPPercentLT(Myself,25)
	Global("DevaHeal","LOCALS",0)
THEN
	RESPONSE #100
		ForceSpellRES("devaheal",Myself) // ¿ÏÄ¡
		SetGlobal("DevaHeal","LOCALS",1)
END

IF
	HaveSpell(CLERIC_INSECT_PLAGUE)
        !GlobalTimerNotExpired("RUMAGESCINSECT","LOCALS")
	See([ENEMY])
        !InMyGroup(LastSeenBy(Myself))
THEN
	RESPONSE #100
                SetGlobalTimer("RUMAGESCINSECT","LOCALS",32)
		ForceSpell(LastSeenBy(Myself),CLERIC_INSECT_PLAGUE)
END

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

IF
	HaveSpell(CLERIC_LESSER_RESTORATION)
	See([ANYONE])
	CheckStatGT(LastSeenBy(Myself),0,LEVELDRAIN)
        InMyGroup(LastSeenBy(Myself))
THEN
	RESPONSE #100
		ForceSpell(LastSeenBy(Myself),CLERIC_LESSER_RESTORATION)
END

IF
	HaveSpell(CLERIC_NEUTRALIZE_POISON)
	See([ANYONE])
        InMyGroup(LastSeenBy(Myself))
	StateCheck(LastSeenBy(Myself),STATE_POISONED)
THEN
	RESPONSE #100
		ForceSpell(LastSeenBy(Myself),CLERIC_NEUTRALIZE_POISON)
END

IF
	HaveSpell(CLERIC_REMOVE_FEAR)
	See([ANYONE])
        InMyGroup(LastSeenBy(Myself))
	StateCheck(LastSeenBy(Myself),STATE_PANIC)
THEN
	RESPONSE #100
		ForceSpell(LastSeenBy(Myself),CLERIC_REMOVE_FEAR)
END

IF
	HaveSpell(CLERIC_CURE_DISEASE)
	See([ANYONE])
        InMyGroup(LastSeenBy(Myself))
	StateCheck(LastSeenBy(Myself),STATE_DISEASED)
THEN
	RESPONSE #100
		ForceSpell(LastSeenBy(Myself),CLERIC_CURE_DISEASE)
END

IF
	HPPercentLT(MostDamagedOf(Myself),25)
	See([ANYONE])
	!StateCheck(MostDamagedOf(Myself),STATE_INVISIBLE)
	HaveSpell(CLERIC_HEAL)
        InMyGroup(LastSeenBy(Myself))
THEN
	RESPONSE #100
		ForceSpell(MostDamagedOf(Myself),CLERIC_HEAL)
END

IF
	HaveSpell(CLERIC_DISPEL_MAGIC)
	See([ANYONE])
	OR(2)
		StateCheck(LastSeenBy(Myself),STATE_CHARMED)
		StateCheck(LastSeenBy(Myself),STATE_CONFUSED)
        InMyGroup(LastSeenBy(Myself))
THEN
	RESPONSE #100
		ForceSpell(LastSeenBy(Myself),CLERIC_DISPEL_MAGIC)
END

IF
        See([ENEMY])
	HaveSpell(CLERIC_DISPEL_MAGIC)
        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
                Spell(LastSeenBy(Myself),CLERIC_DISPEL_MAGIC)
END