IF
  HaveSpell(CLERIC_CURE_MEDIUM_WOUNDS)
  !GlobalTimerNotExpired("X#DCA","LOCALS")
  HPPercentLT(Myself,70)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,75,SPELLFAILUREPRIEST)
THEN
  RESPONSE #100
    SetGlobalTimer("X#DCA","LOCALS",6)
    Spell(Myself,CLERIC_CURE_MEDIUM_WOUNDS)
END

IF
  HaveSpell(CLERIC_CURE_LIGHT_WOUNDS)
  !GlobalTimerNotExpired("X#DCA","LOCALS")
  HPPercentLT(Myself,80)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,75,SPELLFAILUREPRIEST)
THEN
  RESPONSE #100
    SetGlobalTimer("X#DCA","LOCALS",6)
    Spell(Myself,CLERIC_CURE_LIGHT_WOUNDS)
END

IF
  !Allegiance(Myself,ENEMY)
THEN
  RESPONSE #100
    NoAction()
END

IF
  HaveSpell(CLERIC_BARKSKIN)
  !GlobalTimerNotExpired("X#DCA","LOCALS")
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,75,SPELLFAILUREPRIEST)
THEN
  RESPONSE #100
    SetGlobalTimer("X#DCA","LOCALS",6)
    Spell(Myself,CLERIC_BARKSKIN)
END

IF
  !See([GOODCUTOFF.0.0.FIGHTER_DRUID])
  !See([GOODCUTOFF.0.0.DRUID_ALL])
  !See([GOODCUTOFF.0.0.MAGE_ALL])
  !See([GOODCUTOFF.0.0.CLERIC_ALL])
  !See([GOODCUTOFF.0.0.BARD_ALL])
  !See([GOODCUTOFF])
  False()
THEN
  RESPONSE #100
    Continue()
END

IF
 HaveSpell(CLERIC_MISCAST_MAGIC)
 !GlobalTimerNotExpired("X#BCA","LOCALS")
 CheckStatLT(LastSeenBy(),80,SPELLFAILUREMAGE)
 CheckStatLT(LastSeenBy(),80,SPELLFAILUREPRIEST)
 !StateCheck(Myself,STATE_SILENCED)
 !CheckStatGT(Myself,75,SPELLFAILUREPRIEST)
 !HasBounceEffects(LastSeenBy())
THEN
 RESPONSE #100
 SetGlobalTimer("X#BCA","LOCALS",6)
 Spell(LastSeenBy(),CLERIC_MISCAST_MAGIC)
END

IF
  HaveSpell(CLERIC_ARMOR_OF_FAITH)
  !GlobalTimerNotExpired("X#DCA","LOCALS")
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,75,SPELLFAILUREPRIEST)
THEN
  RESPONSE #100
    SetGlobalTimer("X#DCA","LOCALS",6)
    Spell(Myself,CLERIC_ARMOR_OF_FAITH)
END

IF
  HaveSpell(CLERIC_DOOM)
  !GlobalTimerNotExpired("X#DCA","LOCALS")
  !StateCheck(LastSeenBy(),STATE_SLEEPING)
  !StateCheck(LastSeenBy(),STATE_HELPLESS)
  !StateCheck(LastSeenBy(),STATE_CONFUSED)
  !StateCheck(LastSeenBy(),STATE_PANIC)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,75,SPELLFAILUREPRIEST)
  !HasBounceEffects(LastSeenBy())
THEN
  RESPONSE #100
    SetGlobalTimer("X#DCA","LOCALS",6)
    Spell(LastSeenBy(),CLERIC_DOOM)
END

IF
  HaveSpell(CLERIC_RESIST_FIRE)
  !GlobalTimerNotExpired("X#DCA","LOCALS")
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,75,SPELLFAILUREPRIEST)
THEN
  RESPONSE #100
    SetGlobalTimer("X#DCA","LOCALS",6)
    Spell(Myself,CLERIC_RESIST_FIRE)
END

IF
  HaveSpell(CLERIC_CHARM_PERSON)
  !GlobalTimerNotExpired("X#DCA","LOCALS")
  !StateCheck(LastSeenBy(),STATE_SLEEPING)
  !StateCheck(LastSeenBy(),STATE_HELPLESS)
  !StateCheck(LastSeenBy(),STATE_CHARMED)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,75,SPELLFAILUREPRIEST)
  !HasBounceEffects(LastSeenBy())
THEN
  RESPONSE #100
    SetGlobalTimer("X#DCA","LOCALS",6)
    Spell(LastSeenBy(),CLERIC_CHARM_PERSON)
END

IF
  HaveSpell(CLERIC_ENTANGLE)
  !GlobalTimerNotExpired("X#DCA","LOCALS")
  !StateCheck(LastSeenBy(),STATE_SLEEPING)
  !StateCheck(LastSeenBy(),STATE_HELPLESS)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,75,SPELLFAILUREPRIEST)
  !HasBounceEffects(LastSeenBy())
  !Range(LastSeenBy(),15)
THEN
  RESPONSE #100
    SetGlobalTimer("X#DCA","LOCALS",6)
    Spell(LastSeenBy(),CLERIC_ENTANGLE)
END

IF
  HaveSpell(WIZARD_CHROMATIC_ORB)
  !GlobalTimerNotExpired("X#DCA","LOCALS")
  !StateCheck(LastSeenBy(),STATE_SLEEPING)
  !StateCheck(LastSeenBy(),STATE_HELPLESS)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,75,SPELLFAILUREMAGE)
  !HasBounceEffects(LastSeenBy())
THEN
  RESPONSE #100
    SetGlobalTimer("X#DCA","LOCALS",6)
    Spell(LastSeenBy(),WIZARD_CHROMATIC_ORB)
END

IF
  HaveSpell(WIZARD_WEB)
  !GlobalTimerNotExpired("X#DCA","LOCALS")
  !StateCheck(LastSeenBy(),STATE_SLEEPING)
  !StateCheck(LastSeenBy(),STATE_HELPLESS)
  !StateCheck(Myself,STATE_SILENCED)
  !CheckStatGT(Myself,75,SPELLFAILUREMAGE)
  !HasBounceEffects(LastSeenBy())
  !Range(LastSeenBy(),15)
THEN
  RESPONSE #100
    SetGlobalTimer("X#DCA","LOCALS",6)
    Spell(LastSeenBy(),WIZARD_WEB)
END

IF
  !GlobalGT("X#DSL","LOCALS",0)
  !GlobalTimerNotExpired("X#DCA","LOCALS")
THEN
  RESPONSE #100
    SetGlobalTimer("X#DCA","LOCALS",6)
    SetGlobal("X#DSL","LOCALS",1)
    Spell(Myself,4633)
END

IF
  GlobalTimerNotExpired("X#DCA","LOCALS")
THEN
  RESPONSE #100
    AttackOneRound(LastSeenBy())
END

IF
  !GlobalTimerNotExpired("X#DCA","LOCALS")
THEN
  RESPONSE #100
    Attack(LastSeenBy())
END

IF
  AttackedBy([GOODCUTOFF],DEFAULT)
  !Allegiance(Myself,ENEMY)
THEN
  RESPONSE #100
    Enemy()
END

IF
  AttackedBy([0],DEFAULT)
THEN
  RESPONSE #100
    Attack(LastAttackerOf())
END