IF
  Allegiance(Myself,NEUTRAL)
  Global("D0JahShaz","GLOBAL",11)
THEN
  RESPONSE #100
    Enemy()
END

IF
  Global("D0JahShaz","GLOBAL",12)
THEN
  RESPONSE #100
    EscapeArea()
END

IF
  RandomNum(6,1)
  !GlobalTimerNotExpired("Cast","LOCALS")
  See(NearestEnemyOf(Myself))
  HaveSpell(CLERIC_BLESS)
  Global("bless","LOCALS",0)
  See(NearestMyGroupOfType)
THEN
  RESPONSE #100
    ReallyForceSpell(LastSeenBy(Myself),CLERIC_BLESS)
    SetGlobal("bless","LOCALS",1)
END

IF
  RandomNum(2,1)
  !GlobalTimerNotExpired("Cast","LOCALS")
  See(NearestEnemyOf(Myself))
  HaveSpell(CLERIC_MISCAST_MAGIC)
  OR(2)
    See(NearestEnemyOfType([0.0.0.LONG_BOW]))
    See(NearestEnemyOfType([0.0.0.CLERIC_ALL]))
THEN
  RESPONSE #100
    Spell(LastSeenBy(Myself),CLERIC_MISCAST_MAGIC)
END

IF
  RandomNumGT(5,3)
  !GlobalTimerNotExpired("Cast","LOCALS")
  See(NearestEnemyOf(Myself))
  CheckStatGT(Myself,2,ARMORCLASS)
  HaveSpell(CLERIC_DEFENSIVE_HARMONY)
  See(NearestMyGroupOfType)
THEN
  RESPONSE #100
    Spell(LastSeenBy(Myself),CLERIC_DEFENSIVE_HARMONY)
END

IF
  RandomNumGT(4,3)
  !GlobalTimerNotExpired("Cast","LOCALS")
  See(NearestEnemyOf(Myself))
  HaveSpell(CLERIC_CHARM_PERSON)
THEN
  RESPONSE #100
    Spell(NearestEnemyOf(Myself),CLERIC_CHARM_PERSON)
END

IF
  !GlobalTimerNotExpired("Cast","LOCALS")
  See(NearestEnemyOf(Myself))
  HaveSpell(CLERIC_REMOVE_PARALYSIS)
  See(NearestMyGroupOfType)
  StateCheck(LastSeenBy(Myself),STATE_STUNNED)
THEN
  RESPONSE #100
    Spell(LastSeenBy(Myself),CLERIC_REMOVE_PARALYSIS)
END

IF
  !GlobalTimerNotExpired("Cast","LOCALS")
  See(NearestEnemyOf(Myself))
  HaveSpell(CLERIC_FREE_ACTION)
  See(NearestMyGroupOfType)
  StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
THEN
  RESPONSE #100
    Spell(LastSeenBy(Myself),CLERIC_FREE_ACTION)
END

IF
  RandomNumGT(7,4)
  !GlobalTimerNotExpired("Cast","LOCALS")
  See(NearestEnemyOf(Myself))
  HaveSpell(CLERIC_SILENCE_15_FOOT)
  OR(2)
    See(NearestEnemyOfType([0.0.0.LONG_BOW]))
    See(NearestEnemyOfType([0.0.0.CLERIC_ALL]))
THEN
  RESPONSE #100
    Spell(LastSeenBy(Myself),CLERIC_SILENCE_15_FOOT)
END

IF
  !GlobalTimerNotExpired("Cast","LOCALS")
  See(NearestEnemyOf(Myself))
  See(NearestMyGroupOfType)
  HPPercentLT(LastSeenBy(Myself),60)
  HaveSpell(CLERIC_CURE_SERIOUS_WOUNDS)
THEN
  RESPONSE #100
    Spell(LastSeenBy(Myself),CLERIC_CURE_SERIOUS_WOUNDS)
END

IF
  !GlobalTimerNotExpired("Cast","LOCALS")
  See(NearestEnemyOf(Myself))
  See(NearestMyGroupOfType)
  HPPercentLT(LastSeenBy(Myself),60)
  HaveSpell(CLERIC_CURE_MEDIUM_WOUNDS)
THEN
  RESPONSE #100
    Spell(LastSeenBy(Myself),CLERIC_CURE_MEDIUM_WOUNDS)
END

IF
  !GlobalTimerNotExpired("Cast","LOCALS")
  See(NearestEnemyOf(Myself))
  See(NearestMyGroupOfType)
  HPPercentLT(LastSeenBy(Myself),80)
  HaveSpell(CLERIC_CURE_LIGHT_WOUNDS)
THEN
  RESPONSE #100
    Spell(LastSeenBy(Myself),CLERIC_CURE_LIGHT_WOUNDS)
END

IF
  !GlobalTimerNotExpired("Cast","LOCALS")
  See(NearestEnemyOf(Myself))
  !Range(LastSeenBy(Myself),4)
  HPPercentLT(Myself,60)
  HaveSpell(CLERIC_CURE_SERIOUS_WOUNDS)
THEN
  RESPONSE #100
    Spell(Myself,CLERIC_CURE_SERIOUS_WOUNDS)
END

IF
  !GlobalTimerNotExpired("Cast","LOCALS")
  See(NearestEnemyOf(Myself))
  !Range(LastSeenBy(Myself),4)
  HPPercentLT(Myself,60)
  HaveSpell(CLERIC_CURE_MEDIUM_WOUNDS)
THEN
  RESPONSE #100
    Spell(Myself,CLERIC_CURE_MEDIUM_WOUNDS)
END

IF
  !GlobalTimerNotExpired("Cast","LOCALS")
  See(NearestEnemyOf(Myself))
  !Range(LastSeenBy(Myself),4)
  HPPercentLT(Myself,80)
  HaveSpell(CLERIC_CURE_LIGHT_WOUNDS)
THEN
  RESPONSE #100
    Spell(Myself,CLERIC_CURE_LIGHT_WOUNDS)
END

IF
  See(NearestEnemyOf(Myself))
  Range(NearestEnemyOf(Myself),4)
THEN
  RESPONSE #100
    EquipMostDamagingMelee()
    AttackReevaluate(NearestEnemyOf(Myself),30)
END

IF
  See(NearestEnemyOf(Myself))
  !Range(NearestEnemyOf(Myself),4)
THEN
  RESPONSE #100
    EquipRanged()
    AttackReevaluate(NearestEnemyOf(Myself),30)
END
