IF
	Heard([ANYONE],ALERT)
        InMyGroup(LastHeardBy(Myself))
	Allegiance(Myself,NEUTRAL)
THEN
	RESPONSE #100
                Shout(ALERT)
                Enemy()
END

IF
        AttackedBy([GOODCUTOFF],DEFAULT)
	Allegiance(Myself,NEUTRAL)
THEN
	RESPONSE #100
                Shout(ALERT)
                Enemy()
END

IF
	See(NearestEnemyOf(Myself))
        !GlobalTimerNotExpired("protimer1","LOCALS")
THEN
	RESPONSE #100
                DisplayStringHead(Myself,@30)
                SetGlobalTimer("protimer1","LOCALS",30)
                ApplySpell(Myself,CLERIC_DEFENSIVE_HARMONY)
                Continue()
END

IF
	See(NearestEnemyOf(Myself))
        !GlobalTimerNotExpired("protimer2","LOCALS")
THEN
	RESPONSE #100
                SetGlobalTimer("protimer2","LOCALS",30)
                ApplySpell(Myself,CLERIC_CHANT)
                Continue()
END

IF
	See(NearestEnemyOf(Myself))
        !GlobalTimerNotExpired("protimer3","LOCALS")
THEN
	RESPONSE #100
                SetGlobalTimer("protimer3","LOCALS",30)
                ApplySpell(Myself,CLERIC_BLESS)
                Continue()
END

IF
	See(NearestEnemyOf(Myself))
        !GlobalTimerNotExpired("protimer4","LOCALS")
THEN
	RESPONSE #100
                SetGlobalTimer("protimer4","LOCALS",60)
                ForceSpell(Myself,CLERIC_SANCTUARY)
                Continue()
END

IF
	See(NearestEnemyOf(Myself))
        !GlobalTimerNotExpired("protimer5","LOCALS")
THEN
	RESPONSE #100
                SetGlobalTimer("protimer5","LOCALS",60)
                ForceSpell(Myself,CLERIC_SHIELD_OF_THE_ARCHONS)
                Continue()
END

IF
	See(NearestEnemyOf(Myself))
        !GlobalTimerNotExpired("protimer6","LOCALS")
THEN
	RESPONSE #100
                SetGlobalTimer("protimer6","LOCALS",60)
                ApplySpell(Myself,CLERIC_ARMOR_OF_FAITH)
                Continue()
END

IF
	See(NearestEnemyOf(Myself))
        !GlobalTimerNotExpired("protimer7","LOCALS")
THEN
	RESPONSE #100
                SetGlobalTimer("protimer7","LOCALS",60)
                ForceSpell(Myself,CLERIC_PROTECTION_FROM_FIRE)
                Continue()
END

IF
	See(NearestEnemyOf(Myself))
        !GlobalTimerNotExpired("protimer8","LOCALS")
THEN
	RESPONSE #100
                SetGlobalTimer("protimer8","LOCALS",60)
                ForceSpell(Myself,CLERIC_PROTECTION_FROM_LIGHTNING)
                Continue()
END

IF
	See(NearestEnemyOf(Myself))
        !GlobalTimerNotExpired("protimer9","LOCALS")
THEN
	RESPONSE #100
                SetGlobalTimer("protimer9","LOCALS",60)
                ApplySpell(Myself,CLERIC_FREE_ACTION)
                Continue()
END

IF
	Heard([ANYONE],153)
	OR(2)
		HPPercentLT(SecondNearestMyGroupOfType,80)
		HPPercentLT(ThirdNearestMyGroupOfType,80)
        InMyGroup(LastHeardBy(Myself))
THEN
	RESPONSE #100
                DisplayStringHead(Myself,@31)
		ForceSpell(LastHeardBy(Myself),CLERIC_MASS_CURE)
END

IF
	Heard([ANYONE],153)
        InMyGroup(LastHeardBy(Myself))
THEN
	RESPONSE #100
                DisplayStringHead(Myself,@31)
		ForceSpell(LastHeardBy(Myself),CLERIC_CURE_CRITICAL_WOUNDS)
END

IF
        HPPercentLT(Myself,30)
        !GlobalTimerNotExpired("heal","LOCALS")
THEN
	RESPONSE #100
                DisplayStringHead(Myself,@31)
                SetGlobalTimer("heal","LOCALS",24)
		ForceSpell(Myself,CLERIC_HEAL)
END

IF
        !GlobalTimerNotExpired("skin","LOCALS")
	See(NearestEnemyOf(Myself))
        CheckStat(Myself,0,STONESKINS)
THEN
	RESPONSE #100
                SetGlobalTimer("skin","LOCALS",48)
                DisplayStringHead(Myself,@32)
		ForceSpell(Myself,CLERIC_IRONSKIN)
END

IF
        !GlobalTimerNotExpired("dispel","LOCALS")
        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
                SetGlobalTimer("dispel","LOCALS",18)
                DisplayStringHead(Myself,@33)
		ForceSpell(LastSeenBy(Myself),CLERIC_DISPEL_MAGIC)
END

IF
        !GlobalTimerNotExpired("clean","LOCALS")
        OR(5)
        SpellCast([ANYONE],WIZARD_CLOUDKILL)
        SpellCast([ANYONE],WIZARD_DEATH_FOG)
        SpellCast([ANYONE],WIZARD_INCENDIARY_CLOUD)
        SpellCast([ANYONE],CLERIC_STORM_OF_VENGEANCE)
        SpellCast([ANYONE],CLERIC_FIRE_STORM)

THEN
	RESPONSE #100
                SetGlobalTimer("clean","LOCALS",30)
                DisplayStringHead(Myself,@34)
		ForceSpell(Myself,CLERIC_ZONE_OF_SWEET_AIR)
END

IF
        !GlobalTimerNotExpired("styleTimer","LOCALS")
        OR(2)
        Global("stylemagic","LOCALS",1)
        Global("stylephysi","LOCALS",1)
THEN
	RESPONSE #100
                SetGlobal("stylemagic","LOCALS",0)
                SetGlobal("stylephysi","LOCALS",0)
                Continue()
END

IF
	See([ENEMY])
        Global("stylemagic","LOCALS",0)
        !Global("stylephysi","LOCALS",1)
        CheckStatLT(LastSeenBy(Myself),50,RESISTMAGIC)
	!InMyGroup(LastSeenBy(Myself))
THEN
	RESPONSE #100
                SetGlobalTimer("styleTimer","LOCALS",12)
                SetGlobal("stylemagic","LOCALS",1)
                DisplayStringHead(Myself,@35)
                Continue()
END

IF
	See(NearestEnemyOf(Myself))
        Global("stylephysi","LOCALS",0)
        !Global("stylemagic","LOCALS",1)
THEN
	RESPONSE #100
                SetGlobalTimer("styleTimer","LOCALS",12)
                SetGlobal("stylephysi","LOCALS",1)
                DisplayStringHead(Myself,@36)
                Continue()
END

IF
	See([ENEMY])
        Global("stylemagic","LOCALS",1)
        !StateCheck(LastSeenBy(Myself), STATE_HELPLESS)
        CheckStatLT(LastSeenBy(Myself),100,RESISTMAGIC)
        !HasBounceEffects(LastSeenBy(Myself))
        !HasImmunityEffects(LastSeenBy(Myself))
	!InMyGroup(LastSeenBy(Myself))
        !Allegiance(LastSeenBy(Myself),EVILCUTOFF)
THEN
	RESPONSE #100
		ForceSpell(LastSeenBy(Myself),CLERIC_HOLD_PERSON)
                Continue()
END

IF
	See([ENEMY])
        Global("stylemagic","LOCALS",1)
        CheckStatLT(LastSeenBy(Myself),100,RESISTMAGIC)
        !HasBounceEffects(LastSeenBy(Myself))
        !HasImmunityEffects(LastSeenBy(Myself))
	!InMyGroup(LastSeenBy(Myself))
        !Allegiance(LastSeenBy(Myself),EVILCUTOFF)
THEN
	RESPONSE #100
		ForceSpell(LastSeenBy(Myself),CLERIC_RIGID_THINKING)
                Continue()
END

IF
	See([ENEMY])
        Global("stylemagic","LOCALS",1)
        CheckStatLT(LastSeenBy(Myself),100,RESISTFIRE)
        CheckStatLT(LastSeenBy(Myself),100,RESISTMAGIC)
        !HasBounceEffects(LastSeenBy(Myself))
        !HasImmunityEffects(LastSeenBy(Myself))
        !Allegiance(LastSeenBy(Myself),EVILCUTOFF)
	!InMyGroup(LastSeenBy(Myself))
THEN
	RESPONSE #100
		ForceSpell(LastSeenBy(Myself),CLERIC_FLAME_STRIKE)
                Continue()
END

IF
	See([ENEMY])
        AreaType(OUTDOOR)
        Global("stylemagic","LOCALS",1)
        CheckStatLT(LastSeenBy(Myself),100,RESISTELECTRICITY)
        CheckStatLT(LastSeenBy(Myself),100,RESISTMAGIC)
        !HasBounceEffects(LastSeenBy(Myself))
        !HasImmunityEffects(LastSeenBy(Myself))
        !Allegiance(LastSeenBy(Myself),EVILCUTOFF)
	!InMyGroup(LastSeenBy(Myself))
THEN
	RESPONSE #100
		ForceSpell(LastSeenBy(Myself),CLERIC_CALL_LIGHTNING)
                Continue()
END

IF
	See([ENEMY])
        Global("stylemagic","LOCALS",1)
        CheckStatLT(LastSeenBy(Myself),100,RESISTELECTRICITY)
        !HasBounceEffects(LastSeenBy(Myself))
        !HasImmunityEffects(LastSeenBy(Myself))
        !Allegiance(LastSeenBy(Myself),EVILCUTOFF)
	!InMyGroup(LastSeenBy(Myself))
THEN
	RESPONSE #100
		ForceSpell(LastSeenBy(Myself),CLERIC_BOLT_OF_GLORY)
END

IF
	See(NearestEnemyOf(Myself))
        Global("stylephysi","LOCALS",1)
        !GlobalTimerNotExpired("sfighttimer","LOCALS")     
THEN
	RESPONSE #100
                SetGlobalTimer("sfighttimer","LOCALS",50)
		ForceSpell(Myself,CLERIC_REGENERATE)
		ForceSpell(Myself,CLERIC_DRAW_UPON_HOLY_MIGHT)
END

IF
	See([ENEMY])
        HPPercentGT(LastSeenBy(Myself),10)
        !CheckStat(LastSeenBy(Myself),4,WIZARD_PROTECTION_FROM_MAGIC_WEAPONS)
	!InMyGroup(LastSeenBy(Myself))
        Global("stylephysi","LOCALS",1)
        !HasItem("HARM",Myself)
THEN
	RESPONSE #100
                ForceSpell(Myself,CLERIC_HARM)
		AttackReevaluate(LastSeenBy(Myself),30)
                Continue()            
END

IF
	See(NearestEnemyOf(Myself))
        !HasItem("HARM",Myself)
        Global("stylephysi","LOCALS",1)
THEN
	RESPONSE #100
                EquipMostDamagingMelee()     
END

IF
	See([ENEMY])
        ActionListEmpty()
        !GlobalTimerNotExpired("SummonDeva","LOCALS")
THEN
	RESPONSE #100
                SetGlobalTimer("SummonDeva","LOCALS",78)
                ForceSpell(Myself,CLERIC_SUMMON_FALLEN_DEVA) 
END

IF
	See([ENEMY])
        ActionListEmpty()
        NumCreatureLT("SKELWASU",31)
THEN
	RESPONSE #100
                ForceSpell(Myself,CLERIC_ANIMATE_DEAD)       
END

IF
    Global("RukrakiaMageCome","GLOBAL",12)
THEN
    RESPONSE #100
        DestroySelf()
END
