IF
  Die()
THEN
  RESPONSE #100
    Shout(66)
END

IF
  Global("BPCHARM","LOCALS",1)
  !StateCheck(Myself,STATE_CHARMED)
THEN
  RESPONSE #100
    SetGlobal("BPCHARM","LOCALS",0)
    ClearActions(Myself)
    Continue()
END

IF
  OR(2)
    Heard([NEUTRAL],79)
    Heard([EVILCUTOFF],79)
  Allegiance(Myself,NEUTRAL)
  !Global("BP_PlotMan","LOCALS",1)
THEN
  RESPONSE #100
    Enemy()
END

IF
  GlobalTimerNotExpired("BPCHASE","LOCALS")
  Global("BPCHASER","LOCALS",1)
  OR(2)
    See([GOODCUTOFF])
    See(LastHitter(Myself))
THEN
  RESPONSE #30
    DisplayStringHead(Myself,@0)
    SetGlobal("BPCHASER","LOCALS",0)
    AttackReevaluate(LastSeenBy(Myself),15)
  RESPONSE #15
    DisplayStringHead(Myself,@0)
    SetGlobal("BPCHASER","LOCALS",0)
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    ForceSpell(LastSeenBy(Myself),CLERIC_CONJURE_FIRE_ELEMENTAL)
    RemoveSpell(CLERIC_CONJURE_FIRE_ELEMENTAL)
  RESPONSE #15
    DisplayStringHead(Myself,@0)
    SetGlobal("BPCHASER","LOCALS",0)
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    ForceSpell(LastSeenBy(Myself),CLERIC_FLAME_STRIKE)
    RemoveSpell(CLERIC_FLAME_STRIKE)
  RESPONSE #15
    DisplayStringHead(Myself,@0)
    SetGlobal("BPCHASER","LOCALS",0)
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    ForceSpell(LastSeenBy(Myself),CLERIC_CONFUSION)
    RemoveSpell(CLERIC_CONFUSION)
  RESPONSE #15
    DisplayStringHead(Myself,@0)
    SetGlobal("BPCHASER","LOCALS",0)
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    ForceSpell(LastSeenBy(Myself),CLERIC_DISPEL_MAGIC)
    RemoveSpell(CLERIC_DISPEL_MAGIC)
  RESPONSE #10
    DisplayStringHead(Myself,@0)
    SetGlobal("BPCHASER","LOCALS",0)
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    ForceSpell(LastSeenBy(Myself),CLERIC_SILENCE_15_FOOT)
    RemoveSpell(CLERIC_SILENCE_15_FOOT)
    ForceSpell(LastSeenBy(Myself),CLERIC_HOLD_PERSON)
    RemoveSpell(CLERIC_HOLD_PERSON)
END

IF
  GlobalTimerExpired("BPCHASE","LOCALS")
  Global("BPCHASER","LOCALS",1)
  !See([GOODCUTOFF])
  !See(LastHitter(Myself))
THEN
  RESPONSE #100
    DisplayStringHead(Myself,@1)
    SetGlobal("BPCHASER","LOCALS",0)
    ClearActions(Myself)
    Continue()
END

IF
  !Allegiance(Myself,ENEMY)
  !Allegiance(Myself,PC)
  OR(2)
    AttackedBy([GOODCUTOFF],DEFAULT)
    Allegiance(LastAttackerOf(Myself),GOODCUTOFF)
THEN
  RESPONSE #100
    Enemy()
    Shout(151)
    Continue()
END

IF
  !Allegiance(Myself,ENEMY)
  !Allegiance(Myself,GOODCUTOFF)
  OR(2)
    HitBy([GOODCUTOFF],CRUSHING)
    Allegiance(LastHitter(Myself),GOODCUTOFF)
THEN
  RESPONSE #100
    Shout(151)
    Enemy()
    Continue()
END

IF
  ActionListEmpty()
  Global("BP_SweetZone","LOCALS",0)
  OR(4)
    CheckStat(Myself,11,180)
    CheckStat(Myself,16,180)
    CheckStat(Myself,17,180)
    CheckStat(Myself,20,180)
THEN
  RESPONSE #80
    SetGlobal("BP_SweetZone","LOCALS",1)
    DisplayStringHead(Myself,@2)
    ForceSpell(Myself,CLERIC_ZONE_OF_SWEET_AIR)
  RESPONSE #20
    SetGlobal("BP_SweetZone","LOCALS",1)
END

IF
  TookDamage()
  Global("BPCHASER","LOCALS",0)
  !See(LastHitter(Myself))
  !See([GOODCUTOFF])
  OR(2)
    General(Myself,HUMANOID)
    General(Myself,GIANTHUMANOID)
  CheckStatGT(Myself,5,INT)
THEN
  RESPONSE #10
    DisplayStringHead(Myself,@3)
    SetGlobalTimer("BPCHASE","LOCALS",12)
    SetGlobal("BPCHASER","LOCALS",1)
    MoveToObject(LastHitter(Myself))
  RESPONSE #10
    DisplayStringHead(Myself,@3)
    SetGlobalTimer("BPCHASE","LOCALS",12)
    SetGlobal("BPCHASER","LOCALS",1)
    ReallyForceSpell(Myself,CLERIC_PHYSICAL_MIRROR)
    ReallyForceSpell(Myself,CLERIC_BARKSKIN)
    ReallyForceSpell(Myself,CLERIC_AID)
    SetGlobalTimer("CHE","LOCALS",ONE_TURN)
    IncrementGlobal("BPC","LOCALS",1)
    MoveToObject(LastHitter(Myself))
  RESPONSE #10
    DisplayStringHead(Myself,@3)
    SetGlobalTimer("BPCHASE","LOCALS",12)
    SetGlobal("BPCHASER","LOCALS",1)
    ReallyForceSpell(Myself,NPC_BLADE_BARRIER)
    ReallyForceSpell(Myself,CLERIC_FREE_ACTION)
    SetGlobalTimer("CHE","LOCALS",ONE_TURN)
    IncrementGlobal("BPC","LOCALS",1)
    MoveToObject(LastHitter(Myself))
  RESPONSE #5
    DisplayStringHead(Myself,@3)
    SetGlobalTimer("BPCHASE","LOCALS",12)
    SetGlobal("BPCHASER","LOCALS",1)
    ReallyForceSpell(Myself,CLERIC_IRONSKIN)
    ReallyForceSpell(Myself,CLERIC_MAGIC_RESISTANCE)
    SetGlobalTimer("CHE","LOCALS",ONE_TURN)
    IncrementGlobal("BPC","LOCALS",1)
    MoveToObject(LastHitter(Myself))
  RESPONSE #10
    DisplayStringHead(Myself,@3)
    SetGlobalTimer("BPCHASE","LOCALS",12)
    SetGlobal("BPCHASER","LOCALS",1)
    ReallyForceSpell(Myself,CLERIC_RIGHTEOUS_MAGIC)
    ReallyForceSpell(Myself,CLERIC_DEFENSIVE_HARMONY)
    SetGlobalTimer("CHE","LOCALS",ONE_TURN)
    IncrementGlobal("BPC","LOCALS",1)
    MoveToObject(LastHitter(Myself))
  RESPONSE #10
    DisplayStringHead(Myself,@3)
    SetGlobalTimer("BPCHASE","LOCALS",12)
    SetGlobal("BPCHASER","LOCALS",1)
    ReallyForceSpell(Myself,CLERIC_IRONSKIN)
    ReallyForceSpell(Myself,CLERIC_DRAW_UPON_HOLY_MIGHT)
    ReallyForceSpell(Myself,CLERIC_BLESS)
    SetGlobalTimer("CHE","LOCALS",ONE_TURN)
    IncrementGlobal("BPC","LOCALS",1)
    MoveToObject(LastHitter(Myself))
  RESPONSE #10
    DisplayStringHead(Myself,@3)
    SetGlobalTimer("BPCHASE","LOCALS",12)
    SetGlobal("BPCHASER","LOCALS",1)
    ReallyForceSpell(Myself,NPC_BLADE_BARRIER)
    ReallyForceSpell(Myself,CLERIC_BARKSKIN)
    ReallyForceSpell(Myself,CLERIC_PROTECT_FROM_EVIL)
    SetGlobalTimer("CHE","LOCALS",ONE_TURN)
    IncrementGlobal("BPC","LOCALS",1)
    MoveToObject(LastHitter(Myself))
  RESPONSE #5
    DisplayStringHead(Myself,@3)
    SetGlobalTimer("BPCHASE","LOCALS",12)
    SetGlobal("BPCHASER","LOCALS",1)
    ReallyForceSpell(Myself,CLERIC_TRUE_SIGHT)
    ReallyForceSpell(Myself,CLERIC_CHANT)
    ReallyForceSpell(Myself,CLERIC_ARMOR_OF_FAITH)
    SetGlobalTimer("CHE","LOCALS",ONE_TURN)
    IncrementGlobal("BPC","LOCALS",1)
    MoveToObject(LastHitter(Myself))
  RESPONSE #15
    DisplayStringHead(Myself,@3)
    SetGlobalTimer("BPCHASE","LOCALS",12)
    SetGlobal("BPCHASER","LOCALS",1)
    ReallyForceSpell(Myself,CLERIC_CHAOTIC_COMMANDS)
    ReallyForceSpell(Myself,CLERIC_DEATH_WARD)
    ReallyForceSpell(Myself,CLERIC_SANCTUARY)
    SetGlobalTimer("CHE","LOCALS",ONE_TURN)
    SetGlobalTimer("BPIP","LOCALS",15)
    IncrementGlobal("BPC","LOCALS",1)
    RunAwayFrom(LastHitter(Myself),45)
  RESPONSE #15
    DisplayStringHead(Myself,@3)
    RunAwayFrom(LastHitter(Myself),45)
END

IF
  CheckStatGT(Myself,10,180)
  CheckStatGT(Myself,5,INT)
  OR(2)
    See(LastAttackerOf(Myself))
    See(LastHitter(Myself))
  CheckStatLT(LastSeenBy(Myself),11,180)
  !GlobalTimerNotExpired("BPCHASE","LOCALS")
THEN
  RESPONSE #100
    SetGlobalTimer("BPCHASE","LOCALS",TWO_ROUNDS)
    DisplayStringHead(Myself,@4)
    EquipMostDamagingMelee()
    MoveToObject(LastSeenBy(Myself))
    AttackOneRound(LastSeenBy(Myself))
END

IF
  CheckStatGT(Myself,10,180)
  CheckStatGT(Myself,5,INT)
  OR(2)
    See(TenthNearest([GOODCUTOFF]))
    See(TenthNearest([PC]))
  CheckStatLT(LastSeenBy(Myself),11,180)
  !GlobalTimerNotExpired("BPCHASE","LOCALS")
THEN
  RESPONSE #100
    SetGlobalTimer("BPCHASE","LOCALS",TWO_ROUNDS)
    DisplayStringHead(Myself,@4)
    EquipMostDamagingMelee()
    MoveToObject(LastSeenBy(Myself))
    AttackOneRound(LastSeenBy(Myself))
END

IF
  CheckStatGT(Myself,10,180)
  CheckStatGT(Myself,5,INT)
  See(TenthNearest)
  CheckStatLT(TenthNearest,11,180)
  !GlobalTimerNotExpired("BPCHASE","LOCALS")
THEN
  RESPONSE #100
    SetGlobalTimer("BPCHASE","LOCALS",ONE_ROUND)
    DisplayStringHead(Myself,@4)
    MoveToObject(TenthNearest)
END

//////////////CLOUDLIKE  EFFECTS//////////////////////

IF
  CheckStat(Myself,11,180) // I'm in a stinking cloud
  CheckStatGT(Myself,5,INT)
  !StateCheck(Myself,STATE_SLEEPING) // not yet affected
  CheckStatGT(Myself,4,SAVEVSSPELL) //and I got a reasonable chance of failing a save throw (25%+)
  OR(2)
    Detect(NearestEnemyOfType([0.0.MORNINGSTAR.FAIRY_NYMPH.65]))
    Detect(NearestMyGroupOfType([0.0.MORNINGSTAR.FAIRY_NYMPH.65]))
  Range(LastSeenBy(Myself),16)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    RunAwayFrom(LastSeenBy(Myself),30)
    SetInterrupt(TRUE)
END

IF
  CheckStatGT(Myself,11,180) // I'm in a web,entangle, or grease spell
  CheckStatLT(Myself,15,180)
  CheckStatGT(Myself,5,INT)
  CheckStatLT(Myself,1,131) // I don't have free action
  CheckStatLT(Myself,1,WEB) //and not webbed up
  CheckStatLT(Myself,1,ENTANGLE) //nor entangled --I can move
  CheckStatGT(Myself,4,SAVEVSSPELL) //and I got a reasonable chance of failing a save throw (25%+)
  OR(3)
    Detect([0.0.MORNINGSTAR.FAIRY_NYMPH.65])
    Detect(NearestEnemyOfType([0.0.MORNINGSTAR.FAIRY_NYMPH.65]))
    Detect(NearestMyGroupOfType([0.0.MORNINGSTAR.FAIRY_NYMPH.65]))
  Range(LastSeenBy(Myself),16)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    RunAwayFrom(LastSeenBy(Myself),30)
    SetInterrupt(TRUE)
END

IF
  CheckStat(Myself,15,180) // I'm in an Ice Storm
  CheckStatGT(Myself,5,INT)
  CheckStatLT(Myself,100,RESISTCOLD) // Not Immune
  OR(3)
    Detect([0.0.MORNINGSTAR.FAIRY_NYMPH.65])
    Detect(NearestEnemyOfType([0.0.MORNINGSTAR.FAIRY_NYMPH.65]))
    Detect(NearestMyGroupOfType([0.0.MORNINGSTAR.FAIRY_NYMPH.65]))
  Range(LastSeenBy(Myself),16)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    RunAwayFrom(LastSeenBy(Myself),30)
    SetInterrupt(TRUE)
END

IF
  CheckStat(Myself,16,180) // I'm in a Cloudkill or Death Fog
  CheckStatGT(Myself,5,INT)
  CheckStatLT(Myself,100,RESISTPOISON) // Not Immune
  OR(3)
    Detect([0.0.MORNINGSTAR.FAIRY_NYMPH.65])
    Detect(NearestEnemyOfType([0.0.MORNINGSTAR.FAIRY_NYMPH.65]))
    Detect(NearestMyGroupOfType([0.0.MORNINGSTAR.FAIRY_NYMPH.65]))
  Range(LastSeenBy(Myself),16)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    RunAwayFrom(LastSeenBy(Myself),30)
    SetInterrupt(TRUE)
END

IF
  CheckStat(Myself,17,180) // I'm in a Death Fog
  CheckStatGT(Myself,5,INT)
  CheckStatLT(Myself,100,RESISTACID) // Not Immune
  OR(3)
    Detect([0.0.MORNINGSTAR.FAIRY_NYMPH.65])
    Detect(NearestEnemyOfType([0.0.MORNINGSTAR.FAIRY_NYMPH.65]))
    Detect(NearestMyGroupOfType([0.0.MORNINGSTAR.FAIRY_NYMPH.65]))
  Range(LastSeenBy(Myself),16)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    RunAwayFrom(LastSeenBy(Myself),30)
    SetInterrupt(TRUE)
END

IF
  CheckStat(Myself,18,180) // Incendiary Cloud, Meteor Swarm or Fire Storm -- bad stuff
  CheckStatGT(Myself,5,INT)
  CheckStatLT(Myself,100,RESISTFIRE) // Not Immune
  OR(3)
    Detect([0.0.MORNINGSTAR.FAIRY_NYMPH.65])
    Detect(NearestEnemyOfType([0.0.MORNINGSTAR.FAIRY_NYMPH.65]))
    Detect(NearestMyGroupOfType([0.0.MORNINGSTAR.FAIRY_NYMPH.65]))
  Range(LastSeenBy(Myself),16)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    RunAwayFrom(LastSeenBy(Myself),30)
    SetInterrupt(TRUE)
END

// This is to try and keep them from going back in to whomp somebody
IF
  CheckStatLT(Myself,11,180) // No longer in the cloud effects
  CheckStatGT(Myself,5,INT)
  OR(3)
    Detect([0.0.MORNINGSTAR.FAIRY_NYMPH.65])
    Detect(NearestEnemyOfType([0.0.MORNINGSTAR.FAIRY_NYMPH.65]))
    Detect(NearestMyGroupOfType([0.0.MORNINGSTAR.FAIRY_NYMPH.65]))
  !Range(LastSeenBy(Myself),16)
  Exists([EVILCUTOFF])
  !Range(NearestEnemyOf(Myself),2)
THEN
  RESPONSE #100
    EquipRanged()  //use your bow, then
    SmallWait(3)
    Continue()
END

//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////

IF
  OR(2)
    !Allegiance(Myself,EVILCUTOFF)
    !Detect([GOODCUTOFF])
THEN
  RESPONSE #100
END

IF
  Global("TURN","LOCALS",1)
  OR(3)
    GlobalTimerExpired("BPTurn","LOCALS")
    HPPercentLT(Myself,51)
    !See([GOODCUTOFF.UNDEAD])
THEN
  RESPONSE #100
    SetGlobal("TURN","LOCALS",0)
    SetGlobalTimer("BPTurn","LOCALS",0)
    ClearActions(Myself)
    SmallWait(5)
    Continue()
END

IF
  ActionListEmpty()
  SpellCast(Myself,0)
  HaveAnySpells()
  HitBy([ANYONE],CRUSHING)
  NumCreatureGT([EVILCUTOFF],3)
  !GlobalTimerNotExpired("SBN","LOCALS")
THEN
  RESPONSE #100
    SetGlobalTimer("SBN","LOCALS",15)
    DisplayStringHead(Myself,64573)  // ~Help! Guards, protect me!~
    Shout(69)
END

IF
  Global("TURN","LOCALS",1)
  OR(3)
    GlobalTimerExpired("BPTurn","LOCALS")
    HPPercentLT(Myself,51)
    !See([GOODCUTOFF.UNDEAD])
THEN
  RESPONSE #100
    SetGlobalTimer("BPTurn","LOCALS",0)
    ClearActions(Myself)
    SmallWait(5)
    Continue()
END

IF
  Range(NearestEnemyOf(Myself),2)
  OR(2)
    CheckStatGT(NearestEnemyOf(Myself),0,121)
    CheckStatGT(NearestEnemyOf(Myself),0,125)
THEN
  RESPONSE #80
    RunAwayFrom(NearestEnemyOf(Myself),4)
  RESPONSE #20
    Continue()
END

IF
  Global("SNAFU","LOCALS",0)
  OR(3)
    CheckStatGT(Myself,0,SCRIPTINGSTATE4)
    CheckStatGT(Myself,60,SPELLFAILUREPRIEST)
    StateCheck(Myself,STATE_SILENCED)
THEN
  RESPONSE #100
    SetGlobal("SNAFU","LOCALS",1)
END

IF
  Global("SNAFU","LOCALS",1)
  CheckStat(Myself,0,SCRIPTINGSTATE4)
  CheckStatLT(Myself,61,SPELLFAILUREPRIEST)
  !StateCheck(Myself,STATE_SILENCED)
THEN
  RESPONSE #100
    SetGlobal("SNAFU","LOCALS",0)
END

IF
  Global("TURN","LOCALS",1)
  GlobalTimerNotExpired("BPTurn","LOCALS")
  HPPercentGT(Myself,50)
  See([GOODCUTOFF.UNDEAD])
THEN
  RESPONSE #100
END

IF
  Global("BPNOHEAL","LOCALS",0)  
  HPPercentLT(Myself,61)
  OR(2)
    Range(NearestEnemyOf(Myself),3)
    HitBy(LastAttackerOf(Myself),0)
  CheckStat(Myself,0,SHIELDGLOBE)
  CheckStat(Myself,0,122)
  CheckStat(Myself,0,STONESKINS) 
  CheckStat(Myself,0,128)
THEN
  RESPONSE #100
    SetGlobal("BPNOHEAL","LOCALS",1)
    SmallWait(1)
    Continue()
END

IF
  Global("BPNOHEAL","LOCALS",1)
  !Range(NearestEnemyOf(Myself),3)
  OR(6)
    HPPercentGT(Myself,60)
    !Exists(LastAttackerOf(Myself))
    CheckStatGT(Myself,0,SHIELDGLOBE)
    CheckStatGT(Myself,0,122)
    CheckStatGT(Myself,0,STONESKINS) 
    CheckStatGT(Myself,0,128)
THEN
  RESPONSE #100
    SetGlobal("BPNOHEAL","LOCALS",0)
    SmallWait(1)
    Continue()
END

IF
  ActionListEmpty()
  HPPercentLT(Myself,50)
  !GlobalTimerNotExpired("POT","LOCALS")
  CheckStatGT(Myself,69,MAXHITPOINTS)
  HasItem("POTN55",Myself)  // ~Potion of Superior Healing~
THEN
  RESPONSE #100
    SetGlobalTimer("POT","LOCALS",ONE_ROUND)
    DisplayStringHead(Myself,46150)  // ~quaffs a potion~
    UseItem("POTN55",Myself)  // ~Potion of Superior Healing~
END

IF
  ActionListEmpty()
  HPPercentLT(Myself,50)
  !GlobalTimerNotExpired("POT","LOCALS")
  CheckStatGT(Myself,48,MAXHITPOINTS)
  HasItem("POTN52",Myself)  // ~Potion of Extra Healing~
THEN
  RESPONSE #100
    SetGlobalTimer("POT","LOCALS",ONE_ROUND)
    DisplayStringHead(Myself,46150)  // ~quaffs a potion~
    UseItem("POTN52",Myself)  // ~Potion of Extra Healing~
END

IF
  ActionListEmpty()
  HPPercentLT(Myself,61)
  HaveSpell(CLERIC_CURE_SERIOUS_WOUNDS)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("SNAFU","LOCALS",0)
  OR(2)
    RandomNumLT(17,5)
    CheckStatGT(Myself,34,MAXHITPOINTS)
  OR(4) // Either nobody's close, or we're protected in some way from melee
    !Range(NearestEnemyOf(Myself),3)
    CheckStatGT(Myself,0,STONESKINS)
    CheckStatGT(Myself,0,181)
    CheckStatGT(Myself,0,128)      
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_CURE_SERIOUS_WOUNDS)
END

IF
  ActionListEmpty()
  HPPercentLT(Myself,66)
  HaveSpell(CLERIC_CURE_MEDIUM_WOUNDS)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("SNAFU","LOCALS",0)
  OR(2)
    RandomNumLT(17,5)
    CheckStatGT(Myself,28,MAXHITPOINTS)
  OR(4) // Either nobody's close, or we're protected in some way from melee
    !Range(NearestEnemyOf(Myself),3)
    CheckStatGT(Myself,0,STONESKINS)
    CheckStatGT(Myself,0,181)
    CheckStatGT(Myself,0,128)      
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_CURE_MEDIUM_WOUNDS)
END

IF
  ActionListEmpty()
  HPPercentLT(Myself,71)
  HaveSpell(CLERIC_CURE_LIGHT_WOUNDS)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("SNAFU","LOCALS",0)
  OR(2)
    RandomNumLT(17,5)
    CheckStatGT(Myself,16,MAXHITPOINTS)
  OR(4) // Either nobody's close, or we're protected in some way from melee
    !Range(NearestEnemyOf(Myself),3)
    CheckStatGT(Myself,0,STONESKINS)
    CheckStatGT(Myself,0,181)
    CheckStatGT(Myself,0,128)      
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_CURE_LIGHT_WOUNDS)
END

IF
  ActionListEmpty()
  HPPercentLT(Myself,35)
  !GlobalTimerNotExpired("BPW","LOCALS")
  See([EVILCUTOFF])
  !HasItem("POTN55",Myself)
  !HasItem("POTN52",Myself)
  !HaveSpell(CLERIC_CURE_SERIOUS_WOUNDS)
  !HaveSpell(CLERIC_CURE_MEDIUM_WOUNDS)
  !HaveSpell(CLERIC_CURE_LIGHT_WOUNDS)
THEN
  RESPONSE #80
    SetGlobalTimer("BPW","LOCALS",ONE_ROUND)
    DisplayStringHead(Myself,72808)
    Shout(123)
  RESPONSE #20
    Continue()
END

IF
  ActionListEmpty()
  StateCheck(Myself,STATE_POISONED)
  !GlobalTimerNotExpired("POIS","LOCALS")
  See([EVILCUTOFF])
  !HasItem("POTN17",Myself)
  !HasItem("POTN20",Myself)
THEN
  RESPONSE #100
    Shout(83)
    DisplayStringHead(Myself,@5)
    SetGlobalTimer("POIS","LOCALS",ONE_ROUND)
END

IF
  ActionListEmpty()
  !GlobalTimerNotExpired("CHE","LOCALS")
  Global("SNAFU","LOCALS",0)
  GlobalLT("SCH","LOCALS",2)
  Detect(NearestEnemyOf(Myself))
THEN
  RESPONSE #50
    ReallyForceSpell(Myself,NPC_BLADE_BARRIER)
    ReallyForceSpell(Myself,CLERIC_FREE_ACTION)
    SetGlobalTimer("CHE","LOCALS",ONE_TURN)
    IncrementGlobal("SCH","LOCALS",1)
  RESPONSE #50
    ReallyForceSpell(Myself,CLERIC_PHYSICAL_MIRROR)
    ReallyForceSpell(Myself,CLERIC_BARKSKIN)
    ReallyForceSpell(Myself,CLERIC_AID)
    SetGlobalTimer("CHE","LOCALS",ONE_TURN)
    IncrementGlobal("SCH","LOCALS",1)
  RESPONSE #50
    ReallyForceSpell(Myself,CLERIC_IRONSKIN)
    ReallyForceSpell(Myself,CLERIC_MAGIC_RESISTANCE)
    SetGlobalTimer("CHE","LOCALS",ONE_TURN)
    IncrementGlobal("SCH","LOCALS",1)
  RESPONSE #50
    ReallyForceSpell(Myself,CLERIC_RIGHTEOUS_MAGIC)
    ReallyForceSpell(Myself,CLERIC_DEFENSIVE_HARMONY)
    SetGlobalTimer("CHE","LOCALS",ONE_TURN)
    IncrementGlobal("SCH","LOCALS",1)
  RESPONSE #50
    ReallyForceSpell(Myself,CLERIC_CHAOTIC_COMMANDS)
    ReallyForceSpell(Myself,CLERIC_DEATH_WARD)
    ReallyForceSpell(Myself,CLERIC_SANCTUARY)
    SetGlobalTimer("BPIP","LOCALS",15)
    SetGlobalTimer("CHE","LOCALS",ONE_TURN)
    IncrementGlobal("SCH","LOCALS",1)
  RESPONSE #50
    ReallyForceSpell(Myself,CLERIC_TRUE_SIGHT)
    ReallyForceSpell(Myself,CLERIC_CHANT)
    ReallyForceSpell(Myself,CLERIC_ARMOR_OF_FAITH)
    SetGlobalTimer("CHE","LOCALS",ONE_TURN)
    IncrementGlobal("SCH","LOCALS",1)
  RESPONSE #50
    ReallyForceSpell(Myself,CLERIC_IRONSKIN)
    ReallyForceSpell(Myself,CLERIC_DRAW_UPON_HOLY_MIGHT)
    ReallyForceSpell(Myself,CLERIC_BLESS)
    SetGlobalTimer("CHE","LOCALS",ONE_TURN)
    IncrementGlobal("SCH","LOCALS",1)
  RESPONSE #50
    ReallyForceSpell(Myself,NPC_BLADE_BARRIER)
    ReallyForceSpell(Myself,CLERIC_BARKSKIN)
    ReallyForceSpell(Myself,CLERIC_PROTECT_FROM_EVIL)
    SetGlobalTimer("CHE","LOCALS",ONE_TURN)
    IncrementGlobal("SCH","LOCALS",1)
END

IF
  TargetUnreachable(LastSeenBy(Myself))
  Delay(3)
THEN
  RESPONSE #100
    ClearActions(Myself)
    Continue()
END

IF
  ActionListEmpty()
  HPPercentLT(Myself,61)
  HaveSpell(CLERIC_SANCTUARY)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("SNAFU","LOCALS",0)
  CheckStat(Myself,0,SANCTUARY)
THEN
  RESPONSE #100
    SetGlobalTimer("BPIP","LOCALS",15)
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_SANCTUARY)
END

IF
  ActionListEmpty()
  HaveSpell(NPC_BLADE_BARRIER)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("SNAFU","LOCALS",0)
  RandomNum(3,3)
  Range(NearestEnemyOf(Myself),4)
  CheckStatLT(Myself,1,121)
  OR(2)
    Range(Player1,0)
    !Range(Player1,4)
  OR(2)
    Range(Player2,0)
    !Range(Player2,4)
  OR(2)
    Range(Player3,0)
    !Range(Player3,4)
  OR(2)
    Range(Player4,0)
    !Range(Player4,4)
  OR(2)
    Range(Player5,0)
    !Range(Player5,4)
  OR(2)
    Range(Player6,0)
    !Range(Player6,4)
  OR(4) // Either nobody's close, or we're protected in some way from melee
    !Range(NearestEnemyOf(Myself),3)
    CheckStatGT(Myself,0,STONESKINS)
    CheckStatGT(Myself,0,181)
    CheckStatGT(Myself,0,128)      
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,NPC_BLADE_BARRIER)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_PHYSICAL_MIRROR)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("SNAFU","LOCALS",0)
  RandomNum(4,4)
  CheckStat(Myself,0,122)
  OR(3)
    AttackedBy([ANYONE],RANGED) //only works in BG2EE (or will work)
    HitBy([ANYONE],MISSILE)
    !Range(LastAttackerOf(Myself),3)
  HPGT(LastAttackerOf(Myself),19)
  CheckStatLT(Myself,1,122)
  CheckStatLT(Myself,1,179)
  !StateCheck(Myself,0x400010)
  OR(4) // Either nobody's close, or we're protected in some way from melee
    !Range(NearestEnemyOf(Myself),3)
    CheckStatGT(Myself,0,STONESKINS)
    CheckStatGT(Myself,0,181)
    CheckStatGT(Myself,0,128)      
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_PHYSICAL_MIRROR)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_NEGATIVE_PLANE_PROTECTION)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("SNAFU","LOCALS",0)
  CheckStat(Myself,0,SCRIPTINGSTATE3)
  Exists(NearestEnemyOfType([GOODCUTOFF.0.0.LONG_BOW]))
  OR(3)
    CheckStatGT(NearestEnemyOfType([GOODCUTOFF.0.0.LONG_BOW]),17,LEVEL)
    CheckStatGT(Myself,0,LEVELDRAIN)
    SpellCast([ANYONE],WIZARD_ENERGY_DRAIN)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_NEGATIVE_PLANE_PROTECTION)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_HOLY_POWER)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("SNAFU","LOCALS",0)
  RandomNumLT(7,3)
  CheckStatLT(Myself,19,STR)
  CheckStatLT(Myself,3,SCRIPTINGSTATE6)
  NumCreatureGT([GOODCUTOFF],2)
  OR(3) // Be sure at least somebody offers a melee-worthy challenge
    HPGT(NearestEnemyOfType([GOODCUTOFF]),29)
    HPGT(SecondNearestEnemyOfType([GOODCUTOFF]),29)
    HPGT(ThirdNearestEnemyOfType([GOODCUTOFF]),29)
  OR(5) // Either nobody's close, or we're protected in some way from melee &/or missile
    !Range(NearestEnemyOf(Myself),3)
    CheckStatGT(Myself,0,STONESKINS)
    CheckStatGT(Myself,0,181)
    CheckStatGT(Myself,0,128)      
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_HOLY_POWER)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_DEATH_WARD)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("SNAFU","LOCALS",0)
  RandomNumLT(10,4)
  CheckStat(Myself,0,SCRIPTINGSTATE2)
  OR(5)
    See(NearestEnemyOfType([GOODCUTOFF.0.0.CLERIC_ALL]))
    See(NearestEnemyOfType([GOODCUTOFF.0.0.LONG_BOW]))
    See(NearestEnemyOfType([GOODCUTOFF.0.0.BARD_ALL]))
    See(NearestEnemyOfType([GOODCUTOFF.0.0.DRUID_ALL]))
    See(NearestEnemyOfType([GOODCUTOFF.0.0.SORCERER]))
  CheckStatGT(LastSeenBy(Myself),8,LEVEL)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_DEATH_WARD)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_DRAW_UPON_HOLY_MIGHT)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("SNAFU","LOCALS",0)
  RandomNumLT(10,4)
  CheckStatLT(Myself,4,SCRIPTINGSTATE6)
  NumCreatureGT([GOODCUTOFF],2)
  Range(SecondNearestEnemyOf(Myself),10)
  OR(3) // Be sure at least somebody offers a 'somewhat' melee-worthy challenge
    HPGT(NearestEnemyOfType([GOODCUTOFF]),24)
    HPGT(SecondNearestEnemyOfType([GOODCUTOFF]),24)
    HPGT(ThirdNearestEnemyOfType([GOODCUTOFF]),24)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_DRAW_UPON_HOLY_MIGHT)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_CHANT)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("SNAFU","LOCALS",0)
  RandomNumLT(11,4)
  Range(SecondNearestMyGroupOfType,15)
  !StateCheck(Myself,STATE_BLESS)
  !StateCheck(Myself,STATE_CHANT)
  !StateCheck(NearestMyGroupOfType,STATE_BLESS)
  !StateCheck(NearestMyGroupOfType,STATE_CHANT)
  !StateCheck(SecondNearestMyGroupOfType,STATE_BLESS)
  !StateCheck(SecondNearestMyGroupOfType,STATE_CHANT)
  OR(4) // Either nobody's close, or we're protected in some way from melee
    !Range(NearestEnemyOf(Myself),3)
    CheckStatGT(Myself,0,STONESKINS)
    CheckStatGT(Myself,0,181)
    CheckStatGT(Myself,0,128)      
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_CHANT)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_BLESS)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("SNAFU","LOCALS",0)
  RandomNumLT(9,3)
  Range(SecondNearestMyGroupOfType,15)
  CheckStatLT(SecondNearestMyGroupOfType,0,129)
  !StateCheck(SecondNearestMyGroupOfType,STATE_BLESS)
  !StateCheck(SecondNearestMyGroupOfType,STATE_CHANT)
  !StateCheck(SecondNearestMyGroupOfType,0x400010)
  OR(4) // Either nobody's close, or we're protected in some way from melee
    !Range(NearestEnemyOf(Myself),3)
    CheckStatGT(Myself,0,STONESKINS)
    CheckStatGT(Myself,0,181)
    CheckStatGT(Myself,0,128)      
THEN
    RESPONSE #100
        SetGlobalTimer("SPL_CAST","LOCALS",6)
        Spell(SecondNearestMyGroupOfType,CLERIC_BLESS)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_BARKSKIN)
  CheckStatGT(Myself,-4,ARMORCLASS)
  CheckStatGT(Myself,19,LEVEL)
  CheckStatGT(Myself,20,DEX)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("SNAFU","LOCALS",0)
  RandomNumLT(13,5)
  CheckStat(Myself,0,SCRIPTINGSTATE5)
  NumCreatureGT([GOODCUTOFF],2)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_BARKSKIN)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_BARKSKIN)
  CheckStatGT(Myself,-3,ARMORCLASS)
  CheckStatGT(Myself,15,LEVEL)
  OR(2)
    CheckStatGT(Myself,19,LEVEL)
    CheckStatGT(Myself,20,DEX)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("SNAFU","LOCALS",0)
  RandomNumLT(13,5)
  CheckStat(Myself,0,SCRIPTINGSTATE5)
  NumCreatureGT([GOODCUTOFF],2)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_BARKSKIN)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_BARKSKIN)
  CheckStatGT(Myself,-2,ARMORCLASS)
  CheckStatGT(Myself,11,LEVEL)
  OR(2)
    CheckStatGT(Myself,19,LEVEL)
    CheckStatGT(Myself,17,DEX)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("SNAFU","LOCALS",0)
  RandomNumLT(13,5)
  CheckStat(Myself,0,SCRIPTINGSTATE5)
  NumCreatureGT([GOODCUTOFF],2)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_BARKSKIN)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_BARKSKIN)
  CheckStatGT(Myself,-1,ARMORCLASS)
  CheckStatGT(Myself,7,LEVEL)
  OR(2)
    CheckStatGT(Myself,19,LEVEL)
    CheckStatGT(Myself,16,DEX)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("SNAFU","LOCALS",0)
  RandomNumLT(13,5)
  CheckStat(Myself,0,SCRIPTINGSTATE5)
  NumCreatureGT([GOODCUTOFF],2)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_BARKSKIN)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_BARKSKIN)
  CheckStatGT(Myself,0,ARMORCLASS)
  CheckStatGT(Myself,3,LEVEL)
  OR(2)
    CheckStatGT(Myself,19,LEVEL)
    CheckStatGT(Myself,15,DEX)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("SNAFU","LOCALS",0)
  RandomNumLT(13,5)
  CheckStat(Myself,0,SCRIPTINGSTATE5)
  NumCreatureGT([GOODCUTOFF],2)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_BARKSKIN)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_BARKSKIN)
  CheckStatGT(Myself,1,ARMORCLASS)
  OR(2)
    CheckStatGT(Myself,19,LEVEL)
    CheckStatGT(Myself,14,DEX)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("SNAFU","LOCALS",0)
  RandomNumLT(13,5)
  CheckStat(Myself,0,SCRIPTINGSTATE5)
  NumCreatureGT([GOODCUTOFF],2)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_BARKSKIN)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_BARKSKIN)
  CheckStatGT(Myself,2,ARMORCLASS)
  CheckStatLT(Myself,20,LEVEL)
  OR(2)
    CheckStatGT(Myself,15,LEVEL)
    CheckStatGT(Myself,14,DEX)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("SNAFU","LOCALS",0)
  RandomNumLT(13,5)
  CheckStat(Myself,0,SCRIPTINGSTATE5)
  NumCreatureGT([GOODCUTOFF],2)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_BARKSKIN)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_BARKSKIN)
  CheckStatGT(Myself,3,ARMORCLASS)
  CheckStatLT(Myself,16,LEVEL)
  OR(2)
    CheckStatGT(Myself,11,LEVEL)
    CheckStatGT(Myself,14,DEX)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("SNAFU","LOCALS",0)
  RandomNumLT(13,5)
  CheckStat(Myself,0,SCRIPTINGSTATE5)
  NumCreatureGT([GOODCUTOFF],2)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_BARKSKIN)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_BARKSKIN)
  CheckStatGT(Myself,4,ARMORCLASS)
  CheckStatLT(Myself,12,LEVEL)
  OR(2)
    CheckStatGT(Myself,7,LEVEL)
    CheckStatGT(Myself,14,DEX)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("SNAFU","LOCALS",0)
  RandomNumLT(13,5)
  CheckStat(Myself,0,SCRIPTINGSTATE5)
  NumCreatureGT([GOODCUTOFF],2)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_BARKSKIN)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_BARKSKIN)
  CheckStatGT(Myself,5,ARMORCLASS)
  CheckStatLT(Myself,8,LEVEL)
  OR(2)
    CheckStatGT(Myself,3,LEVEL)
    CheckStatGT(Myself,14,DEX)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("SNAFU","LOCALS",0)
  RandomNumLT(13,5)
  CheckStat(Myself,0,SCRIPTINGSTATE5)
  NumCreatureGT([GOODCUTOFF],2)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_BARKSKIN)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_BARKSKIN)
  CheckStatLT(Myself,4,LEVEL)
  CheckStatGT(Myself,6,ARMORCLASS)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("SNAFU","LOCALS",0)
  RandomNumLT(13,5)
  CheckStat(Myself,0,SCRIPTINGSTATE5)
  NumCreatureGT([GOODCUTOFF],2)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_BARKSKIN)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_ARMOR_OF_FAITH)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("SNAFU","LOCALS",0)
  RandomNumLT(14,5)
  CheckStatLT(Myself,10,SCRIPTINGSTATE5)
  CheckStatLT(Myself,1,110)
  NumCreatureGT([GOODCUTOFF],2)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_ARMOR_OF_FAITH)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_DISPEL_MAGIC)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("SNAFU","LOCALS",0)
  Exists(SecondNearestMyGroupOfType)
  Range(SecondNearestMyGroupOfType,15)
  !StateCheck(SecondNearestMyGroupOfType,0x400010)
  !StateCheck(SecondNearestMyGroupOfType,0x2208010)
  !StateCheck(SecondNearestMyGroupOfType,0x62000000)
  OR(8)
    CheckStatGT(SecondNearestMyGroupOfType,0,HELD)
    CheckStatGT(SecondNearestMyGroupOfType,0,ENTANGLE)
    CheckStatGT(SecondNearestMyGroupOfType,0,GREASE)
    CheckStatGT(SecondNearestMyGroupOfType,0,WEB)
    StateCheck(SecondNearestMyGroupOfType,270381)
    StateCheck(SecondNearestMyGroupOfType,0x80100000)
    StateCheck(SecondNearestMyGroupOfType,STATE_SILENCED)
    StateCheck(SecondNearestMyGroupOfType,STATE_SLOWED)
  OR(4) // Either nobody's close, or we're protected in some way from melee
    !Range(NearestEnemyOf(Myself),3)
    CheckStatGT(Myself,0,STONESKINS)
    CheckStatGT(Myself,0,181)
    CheckStatGT(Myself,0,128)      
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(SecondNearestMyGroupOfType,CLERIC_DISPEL_MAGIC)
END

IF
  ActionListEmpty()
  HitBy([GOODCUTOFF],CRUSHING)
  !GlobalTimerNotExpired("RANG","LOCALS")
  !StateCheck(Myself,STATE_POISONED)
  CheckStatGT(Myself,7,INT)
  OR(3)
    Class(Myself,FIGHTER_CLERIC)
    Class(Myself,CLERIC_RANGER)
    Class(Myself,FIGHTER_MAGE_CLERIC)
  OR(2)
    See(LastAttackerOf(Myself))
    See(LastHitter(Myself))
  !Range(LastSeenBy(Myself),7)
  !TargetUnreachable(LastSeenBy(Myself))
  !InWeaponRange(LastSeenBy(Myself))
  HPGT(LastSeenBy(Myself),0)
THEN
  RESPONSE #50
    DisplayStringHead(Myself,@6)
    SetGlobalTimer("RANG","LOCALS",ONE_ROUND)
  RESPONSE #50
    DisplayStringHead(Myself,@7)
    SetGlobalTimer("RANG","LOCALS",ONE_ROUND)
  RESPONSE #25
    DisplayStringHead(Myself,@8)
    SetGlobalTimer("RANG","LOCALS",ONE_ROUND)
  RESPONSE #25
    DisplayStringHead(Myself,@9)
    SetGlobalTimer("RANG","LOCALS",ONE_ROUND)
  RESPONSE #50
    DisplayStringHead(Myself,@10)
    SetGlobalTimer("RANG","LOCALS",THREE_ROUNDS)
    EquipMostDamagingMelee()
    MoveToObject(LastSeenBy(Myself))
    AttackReevaluate(LastSeenBy(Myself),180)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_FREE_ACTION)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("SNAFU","LOCALS",0)
  CheckStatLT(NearestMyGroupOfType,1,131)
  !StateCheck(NearestMyGroupOfType,0x400010)
  OR(3)
    CheckStatGT(NearestMyGroupOfType,0,HELD)
    CheckStatGT(NearestMyGroupOfType,0,WEB)
    CheckStatGT(NearestMyGroupOfType,0,ENTANGLE)
    CheckStatGT(NearestMyGroupOfType,0,GREASE)
    StateCheck(NearestMyGroupOfType,STATE_SLOWED)
    CheckStat(NearestMyGroupOfType,12,180) // In entangle, not nec caught yet
    CheckStat(NearestMyGroupOfType,13,180) // In grease, not nec caught yet
    CheckStat(NearestMyGroupOfType,14,180) // In a web, not nec caught yet
  OR(4) // Either nobody's close, or we're protected in some way from melee
    !Range(NearestEnemyOf(Myself),3)
    CheckStatGT(Myself,0,STONESKINS)
    CheckStatGT(Myself,0,181)
    CheckStatGT(Myself,0,128)      
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(NearestMyGroupOfType,CLERIC_FREE_ACTION)
END

IF
  ActionListEmpty()
  OR(3)
    Heard(NearestMyGroupOfType,123)
    Heard(SecondNearestMyGroupOfType,123)
    Heard(ThirdNearestMyGroupOfType,123)
  HPPercentLT(LastHeardBy(Myself),50)
  HaveSpell(CLERIC_CURE_SERIOUS_WOUNDS)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("SNAFU","LOCALS",0)
  Global("BPNOHEAL","LOCALS",0)
  OR(2)
    RandomNumLT(17,5)
    CheckStatGT(LastHeardBy(Myself),33,MAXHITPOINTS)
  OR(4) // Either nobody's close, or we're protected in some way from melee
    !Range(NearestEnemyOf(Myself),3)
    CheckStatGT(Myself,0,STONESKINS)
    CheckStatGT(Myself,0,181)
    CheckStatGT(Myself,0,128)      
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastHeardBy(Myself),CLERIC_CURE_SERIOUS_WOUNDS)
END

IF
  ActionListEmpty()
  HPPercentLT(LastHeardBy(Myself),50)
  HaveSpell(CLERIC_CURE_MEDIUM_WOUNDS)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("SNAFU","LOCALS",0)
  Global("BPNOHEAL","LOCALS",0)
  OR(2)
    RandomNumLT(17,5)
    CheckStatGT(LastHeardBy(Myself),27,MAXHITPOINTS)
  OR(4) // Either nobody's close, or we're protected in some way from melee
    !Range(NearestEnemyOf(Myself),3)
    CheckStatGT(Myself,0,STONESKINS)
    CheckStatGT(Myself,0,181)
    CheckStatGT(Myself,0,128)      
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastHeardBy(Myself),CLERIC_CURE_MEDIUM_WOUNDS)
END

IF
  ActionListEmpty()
  HPPercentLT(LastHeardBy(Myself),50)
  HaveSpell(CLERIC_CURE_LIGHT_WOUNDS)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("SNAFU","LOCALS",0)
  Global("BPNOHEAL","LOCALS",0)
  OR(2)
    RandomNumLT(17,5)
    CheckStatGT(LastHeardBy(Myself),15,MAXHITPOINTS)
  OR(4) // Either nobody's close, or we're protected in some way from melee
    !Range(NearestEnemyOf(Myself),3)
    CheckStatGT(Myself,0,STONESKINS)
    CheckStatGT(Myself,0,181)
    CheckStatGT(Myself,0,128)      
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastHeardBy(Myself),CLERIC_CURE_LIGHT_WOUNDS)
END



IF
  OR(3)
    !Race(NearestEnemyOf(Myself),MORNINGSTAR)
    !Class(NearestEnemyOf(Myself),FAIRY_NYMPH)
    !Specifics(NearestEnemyOf(Myself),65)
  See(NearestEnemyOf(Myself))
  False()
THEN
  RESPONSE #100
    Continue()
END

IF
  RandomNumLT(28,22)
  OR(4)
    See([GOODCUTOFF.0.0.0.0.SUMMONED_DEMON])
    See([GOODCUTOFF.0.0.0.0.SUMMONED])
    See([GOODCUTOFF.0.0.0.SIMULACRUM])
    See([GOODCUTOFF.0.0.0.0.ILLUSIONARY])
  False()
THEN
  RESPONSE #100
    Continue()
END

IF
  RandomNumLT(31,26)
  OR(6)
    See(NearestEnemyOf(Myself))
    See(WeakestOf)
    See(WorstAC)
    See(MostDamagedOf)
    See(LastAttackerOf(Myself))
    See(LastHitter(Myself))
  False()
THEN
  RESPONSE #100
    Continue()
END

IF
  OR(3)
    Allegiance(LastSeenBy(Myself),ENEMY)
    Allegiance(LastSeenBy(Myself),EVILCUTOFF)
    Allegiance(LastSeenBy(Myself),GOODBUTRED)
THEN
  RESPONSE #100
END

IF
  Race(LastSeenBy(Myself),MORNINGSTAR)
  Class(LastSeenBy(Myself),FAIRY_NYMPH)
  Specifics(LastSeenBy(Myself),65)
THEN
  RESPONSE #100
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_MENTAL_DOMINATION)
  StateCheck(LastSeenBy(Myself),STATE_CHARMED)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("SNAFU","LOCALS",0)
  OR(2)
    CheckStat(LastSeenBy(Myself),0,129) // either they have no spell turning
    RandomNumLT(99,23) //or we'll just shoot the moon
  CheckStatLT(LastSeenBy(Myself),51,RESISTMAGIC)
  CheckStatGT(LastSeenBy(Myself),5,SAVEVSSPELL)
THEN
  RESPONSE #80
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_MENTAL_DOMINATION)
  RESPONSE #20
    Continue()
END

IF
  ActionListEmpty()
  OR(2)
    General(LastSeenBy(Myself),HUMANOID)
    General(LastSeenBy(Myself),ANIMAL)
  HaveSpell(CLERIC_CHARM_PERSON)
  StateCheck(LastSeenBy(Myself),STATE_CHARMED)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("SNAFU","LOCALS",0)
  OR(2)
    CheckStat(LastSeenBy(Myself),0,129) // either they have no spell turning
    RandomNumLT(99,23) //or we'll just shoot the moon
  CheckStatLT(LastSeenBy(Myself),51,RESISTMAGIC)
  CheckStatGT(LastSeenBy(Myself),5,SAVEVSSPELL)
  CheckStatLT(Myself,61,SPELLFAILUREPRIEST)
THEN
  RESPONSE #80
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_CHARM_PERSON)
  RESPONSE #20
    Continue()
END

IF
  ActionListEmpty()
  General(LastSeenBy(Myself),ANIMAL)
  HaveSpell(RANGER_CHARM_ANIMAL)
  !GlobalTimerNotExpired("BPT","LOCALS")
  General(LastSeenBy(Myself),ANIMAL)
  StateCheck(LastSeenBy(Myself),STATE_CHARMED)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("SNAFU","LOCALS",0)
  OR(2)
    CheckStat(LastSeenBy(Myself),0,129) // either they have no spell turning
    RandomNumLT(99,23) //or we'll just shoot the moon
  CheckStatLT(LastSeenBy(Myself),51,RESISTMAGIC)
  CheckStatGT(LastSeenBy(Myself),5,SAVEVSSPELL)
  CheckStatLT(Myself,61,SPELLFAILUREPRIEST)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),RANGER_CHARM_ANIMAL)
END

IF
  StateCheck(LastSeenBy(Myself),STATE_CHARMED)
THEN
  RESPONSE #80
    Continue()
  RESPONSE #20
END

IF
  ActionListEmpty()
  Global("SNAFU","LOCALS",1)
THEN
  RESPONSE #100
    AttackReevaluate(LastSeenBy(Myself),45)
END

IF
  ActionListEmpty()
  OR(3)
    HasItem("SHAMMR",Myself)  // ~Spiritual Hammer~
    HasItem("SERIOUS",Myself)  // ~Cause Serious Wounds~
    HasItem("FBLADE",Myself)  // ~Flame Blade~
  HPPercentGT(Myself,35)
THEN
  RESPONSE #75
    AttackOneRound(LastSeenBy(Myself))
  RESPONSE #25
    Continue()
END

IF
  !GlobalTimerNotExpired("BPIP","LOCALS")
  OR(2)
    CheckStatGT(Myself,0,SANCTUARY)
    StateCheck(Myself,0x00400010)
THEN
  RESPONSE #15
    Continue()
  RESPONSE #60
    IncrementGlobal("BPIP","LOCALS",-1)
  RESPONSE #90
    RunAwayFrom(NearestEnemyOf(Myself),10)
END


IF
  RandomNumLT(30,13)
  OR(6)
    See(NearestEnemyOfType([PC]))
    See(SecondNearestEnemyOfType([PC]))
    See(ThirdNearestEnemyOfType([PC]))
    See(FourthNearestEnemyOfType([PC]))
    See(FifthNearestEnemyOfType([PC]))
    See(SixthNearestEnemyOfType([PC]))
  False()
THEN
  RESPONSE #100
    Continue()
END

IF
  RandomNumGT(30,20)
  OR(6)
    See(NearestEnemyOfType([GOODCUTOFF]))
    See(SecondNearestEnemyOfType([GOODCUTOFF]))
    See(ThirdNearestEnemyOfType([GOODCUTOFF]))
    See(FourthNearestEnemyOfType([GOODCUTOFF]))
    See(FifthNearestEnemyOfType([GOODCUTOFF]))
    See(SixthNearestEnemyOfType([GOODCUTOFF]))
  False()
THEN
  RESPONSE #100
    Continue()
END

IF
  RandomNumGT(30,15)
  RandomNumLT(30,19)
  See(Protagonist)
  False()
THEN
  RESPONSE #100
    Continue()
END
  
IF
  RandomNumLT(29,20)
  OR(7)
    See(NearestEnemyOfType([PC.0.0.RANGER_ALL]))
    See(NearestEnemyOfType([PC.0.0.PALADIN_ALL]))
    See(NearestEnemyOfType([PC.0.0.BARD_ALL]))
    See(NearestEnemyOfType([PC.0.0.DRUID_ALL]))
    See(NearestEnemyOfType([PC.0.0.CLERIC_ALL]))
    See(NearestEnemyOfType([PC.0.0.LONG_BOW]))
    See(NearestEnemyOfType([PC.0.0.SORCERER]))
  OR(7)
    See(SecondNearestEnemyOfType([PC.0.0.RANGER_ALL]))
    See(SecondNearestEnemyOfType([PC.0.0.PALADIN_ALL]))
    See(SecondNearestEnemyOfType([PC.0.0.BARD_ALL]))
    See(SecondNearestEnemyOfType([PC.0.0.DRUID_ALL]))
    See(SecondNearestEnemyOfType([PC.0.0.CLERIC_ALL]))
    See(SecondNearestEnemyOfType([PC.0.0.LONG_BOW]))
    See(SecondNearestEnemyOfType([PC.0.0.SORCERER]))
  OR(7)
    See(ThirdNearestEnemyOfType([PC.0.0.RANGER_ALL]))
    See(ThirdNearestEnemyOfType([PC.0.0.PALADIN_ALL]))
    See(ThirdNearestEnemyOfType([PC.0.0.BARD_ALL]))
    See(ThirdNearestEnemyOfType([PC.0.0.DRUID_ALL]))
    See(ThirdNearestEnemyOfType([PC.0.0.CLERIC_ALL]))
    See(ThirdNearestEnemyOfType([PC.0.0.LONG_BOW]))
    See(ThirdNearestEnemyOfType([PC.0.0.SORCERER]))
  OR(7)
    See(FourthNearestEnemyOfType([PC.0.0.RANGER_ALL]))
    See(FourthNearestEnemyOfType([PC.0.0.PALADIN_ALL]))
    See(FourthNearestEnemyOfType([PC.0.0.BARD_ALL]))
    See(FourthNearestEnemyOfType([PC.0.0.DRUID_ALL]))
    See(FourthNearestEnemyOfType([PC.0.0.CLERIC_ALL]))
    See(FourthNearestEnemyOfType([PC.0.0.LONG_BOW]))
    See(FourthNearestEnemyOfType([PC.0.0.SORCERER]))
  False()
THEN
  RESPONSE #100
    Continue()
END

IF
  RandomNumLT(26,14)
  OR(12)
    See(NearestEnemyOfType([GOODCUTOFF.0.0.BARD_ALL]))
    See(NearestEnemyOfType([GOODCUTOFF.0.0.LONG_BOW]))
    See(NearestEnemyOfType([GOODCUTOFF.0.0.SORCERER]))
    See(SecondNearestEnemyOfType([GOODCUTOFF.0.0.BARD_ALL]))
    See(SecondNearestEnemyOfType([GOODCUTOFF.0.0.LONG_BOW]))
    See(SecondNearestEnemyOfType([GOODCUTOFF.0.0.SORCERER]))
    See(ThirdNearestEnemyOfType([GOODCUTOFF.0.0.BARD_ALL]))
    See(ThirdNearestEnemyOfType([GOODCUTOFF.0.0.LONG_BOW]))
    See(ThirdNearestEnemyOfType([GOODCUTOFF.0.0.SORCERER]))
    See(FourthNearestEnemyOfType([GOODCUTOFF.0.0.BARD_ALL]))
    See(FourthNearestEnemyOfType([GOODCUTOFF.0.0.LONG_BOW]))
    See(FourthNearestEnemyOfType([GOODCUTOFF.0.0.SORCERER]))
  RandomNumLT(27,10)
  OR(12)
    See(NearestEnemyOfType([GOODCUTOFF.0.0.RANGER_ALL]))
    See(NearestEnemyOfType([GOODCUTOFF.0.0.PALADIN_ALL]))
    See(NearestEnemyOfType([GOODCUTOFF.0.0.DRUID_ALL]))
    See(NearestEnemyOfType([GOODCUTOFF.0.0.CLERIC_ALL]))
    See(SecondNearestEnemyOfType([GOODCUTOFF.0.0.RANGER_ALL]))
    See(SecondNearestEnemyOfType([GOODCUTOFF.0.0.PALADIN_ALL]))
    See(SecondNearestEnemyOfType([GOODCUTOFF.0.0.DRUID_ALL]))
    See(SecondNearestEnemyOfType([GOODCUTOFF.0.0.CLERIC_ALL]))
    See(ThirdNearestEnemyOfType([GOODCUTOFF.0.0.RANGER_ALL]))
    See(ThirdNearestEnemyOfType([GOODCUTOFF.0.0.PALADIN_ALL]))
    See(ThirdNearestEnemyOfType([GOODCUTOFF.0.0.DRUID_ALL]))
    See(ThirdNearestEnemyOfType([GOODCUTOFF.0.0.CLERIC_ALL]))
  RandomNumLT(32,12)
  OR(9)
    See(NearestEnemyOfType([GOODCUTOFF.0.0.MONK]))
    See(NearestEnemyOfType([GOODCUTOFF.0.0.THIEF_ALL]))
    See(NearestEnemyOfType([GOODCUTOFF.0.0.BARD_ALL]))
    See(SecondNearestEnemyOfType([GOODCUTOFF.0.0.MONK]))
    See(SecondNearestEnemyOfType([GOODCUTOFF.0.0.THIEF_ALL]))
    See(SecondNearestEnemyOfType([GOODCUTOFF.0.0.BARD_ALL]))
    See(ThirdNearestEnemyOfType([GOODCUTOFF.0.0.MONK]))
    See(ThirdNearestEnemyOfType([GOODCUTOFF.0.0.THIEF_ALL]))
    See(ThirdNearestEnemyOfType([GOODCUTOFF.0.0.BARD_ALL]))
  False()
THEN
  RESPONSE #100
    Continue()
END


IF
  ActionListEmpty()
  HaveSpell(CLERIC_SILENCE_15_FOOT)
  !GlobalTimerNotExpired("BPT","LOCALS")
  RandomNumLT(35,25)
  !StateCheck(LastSeenBy(Myself),STATE_SILENCED)
  CheckStat(LastSeenBy(Myself),0,MINORGLOBE)
  OR(2)
    CheckStat(LastSeenBy(Myself),0,129) // either they have no spell turning
    RandomNumLT(99,23) //or we'll just shoot the moon
  CheckStatGT(LastSeenBy(Myself),3,SAVEVSSPELL) // at -5 gives a 40% chance
  CheckStatLT(LastSeenBy(Myself),61,RESISTMAGIC)
  CheckStatLT(Myself,61,SPELLFAILUREPRIEST)
  OR(5)
    Class(LastSeenBy(Myself),DRUID_ALL)
    Class(LastSeenBy(Myself),BARD_ALL)
    Class(LastSeenBy(Myself),CLERIC_ALL)
    Class(LastSeenBy(Myself),LONG_BOW)
    Class(LastSeenBy(Myself),SORCERER)
  OR(3)
    !Range(LastSeenBy(Myself),16)
    !GlobalTimerNotExpired("BPVOCAL","LOCALS")
    CheckStatGT(Myself,74,RESISTMAGIC)
  OR(6)
    !Exists(NearestMyGroupOfType)
    Range(NearestMyGroupOfType,2)
    CheckStatLT(NearestMyGroupOfType,6,SAVEVSSPELL) // save at -5, thus 50% change
    CheckStatGT(NearestMyGroupOfType,49,RESISTMAGIC)
    CheckStatGT(NearestMyGroupOfType,0,MINORGLOBE)
    StateCheck(NearestMyGroupOfType,STATE_SILENCED)
  OR(6)
    !Exists(SecondNearestMyGroupOfType)
    Range(SecondNearestMyGroupOfType,3)
    CheckStatLT(NearestMyGroupOfType,6,SAVEVSSPELL)
    CheckStatGT(SecondNearestMyGroupOfType,49,RESISTMAGIC)
    CheckStatGT(NearestMyGroupOfType,0,MINORGLOBE)
    StateCheck(NearestMyGroupOfType,STATE_SILENCED)
  OR(6)
    !Exists(ThirdNearestMyGroupOfType)
    Range(ThirdNearestMyGroupOfType,4)
    CheckStatLT(ThirdNearestMyGroupOfType,6,SAVEVSSPELL)
    CheckStatGT(ThirdNearestMyGroupOfType,49,RESISTMAGIC)
    CheckStatGT(ThirdNearestMyGroupOfType,0,MINORGLOBE)
    StateCheck(ThirdNearestMyGroupOfType,STATE_SILENCED)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_SILENCE_15_FOOT)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_MISCAST_MAGIC)
  !GlobalTimerNotExpired("BPT","LOCALS")
  RandomNumLT(34,25)
  CheckStatLT(LastSeenBy(Myself),76,SPELLFAILUREMAGE)
  CheckStatLT(LastSeenBy(Myself),76,SPELLFAILUREPRIEST)
  OR(2)
    CheckStat(LastSeenBy(Myself),0,129) // either they have no spell turning
    RandomNumLT(99,23) //or we'll just shoot the moon
  CheckStatLT(LastSeenBy(Myself),61,RESISTMAGIC)
  CheckStatLT(Myself,61,SPELLFAILUREPRIEST)
  OR(5)
    Class(LastSeenBy(Myself),DRUID_ALL)
    Class(LastSeenBy(Myself),BARD_ALL)
    Class(LastSeenBy(Myself),CLERIC_ALL)
    Class(LastSeenBy(Myself),LONG_BOW)
    Class(LastSeenBy(Myself),SORCERER)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_MISCAST_MAGIC)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_DISPEL_MAGIC)
  !GlobalTimerNotExpired("BPT","LOCALS")
  RandomNumLT(48,31)
  CheckStat(LastSeenBy(Myself),0,177)
  !StateCheck(LastSeenBy(Myself),0x400010)
  CheckStatLT(Myself,61,SPELLFAILUREPRIEST)
  OR(2)
    !HasImmunityEffects(Myself)
    !Range(LastSeenBy(Myself),15)
  OR(2)
    CheckStat(Myself,0,STONESKINS)
    !Range(LastSeenBy(Myself),15)
  OR(4)
    StateCheck(LastSeenBy(Myself),580943904)
    StateCheck(LastSeenBy(Myself),0x2208010)
    StateCheck(LastSeenBy(Myself),0x62000000)
    CheckStatGT(LastSeenBy(Myself),0,STONESKINS)
THEN
  RESPONSE #100
    SetGlobal("BPT","LOCALS",6)
    Spell(LastSeenBy(Myself),CLERIC_DISPEL_MAGIC)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_CONJURE_FIRE_ELEMENTAL)
  !GlobalTimerNotExpired("BPT","LOCALS")
  RandomNumLT(37,24)
  NumCreatureLT([EVILCUTOFF.0.0.0.0.SUMMONED],7)
  NumCreatureLT([EVILCUTOFF.0.ELEMENTAL.0.0.SUMMONED],3)
  CheckStatLT(Myself,61,SPELLFAILUREPRIEST)
  OR(5) // Either nobody's close, or we're protected in some way from melee &/or missile
    !Range(NearestEnemyOf(Myself),3) // not the 3-round blitz of the mage spell, proceed as normal
    CheckStatGT(Myself,0,179)
    CheckStatGT(Myself,0,STONESKINS)
    CheckStatGT(Myself,0,181)
    CheckStatGT(Myself,0,128)      
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_CONJURE_EARTH_ELEMENTAL)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_HOLY_SMITE)
  !GlobalTimerNotExpired("BPT","LOCALS")
  RandomNumLT(40,24)
  Alignment(LastSeenBy(Myself),MASK_EVIL)
  !Range(LastSeenBy(Myself),16)
  CheckStatGT(LastSeenBy(Myself),8,SAVEVSSPELL)
  CheckStatLT(LastSeenBy(Myself),61,RESISTMAGIC)
  CheckStatLT(Myself,61,SPELLFAILUREPRIEST)
  OR(3)
    !Alignment(Myself,MASK_EVIL)
    CheckStatGT(Myself,74,RESISTMAGIC)
    CheckStatGT(Myself,0,MINORGLOBE)
  OR(5)
    !Exists(NearestMyGroupOfType)
    Range(NearestMyGroupOfType,2)
    !Alignment(NearestMyGroupOfType,MASK_EVIL)
    CheckStatGT(NearestMyGroupOfType,49,RESISTMAGIC)
    CheckStatGT(NearestMyGroupOfType,0,MINORGLOBE)
  OR(5)
    !Exists(SecondNearestMyGroupOfType)
    Range(SecondNearestMyGroupOfType,3)
    !Alignment(SecondNearestMyGroupOfType,MASK_EVIL)
    CheckStatGT(SecondNearestMyGroupOfType,49,RESISTMAGIC)
    CheckStatGT(SecondNearestMyGroupOfType,0,MINORGLOBE)
  OR(5)
    !Exists(ThirdNearestMyGroupOfType)
    Range(ThirdNearestMyGroupOfType,4)
    !Alignment(ThirdNearestMyGroupOfType,MASK_EVIL)
    CheckStatGT(ThirdNearestMyGroupOfType,49,RESISTMAGIC)
    CheckStatGT(ThirdNearestMyGroupOfType,0,MINORGLOBE)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_HOLY_SMITE)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_UNHOLY_BLIGHT)
  !GlobalTimerNotExpired("BPT","LOCALS")
  RandomNumLT(41,24)
  Alignment(LastSeenBy(Myself),MASK_GOOD)
  !Range(LastSeenBy(Myself),16)
  CheckStatGT(LastSeenBy(Myself),8,SAVEVSSPELL)
  CheckStatLT(LastSeenBy(Myself),61,RESISTMAGIC)
  CheckStatLT(Myself,61,SPELLFAILUREPRIEST)
  OR(3)
    !Alignment(Myself,MASK_GOOD)
    CheckStatGT(Myself,74,RESISTMAGIC)
    CheckStatGT(Myself,0,MINORGLOBE)
  OR(5)
    !Exists(NearestMyGroupOfType)
    Range(NearestMyGroupOfType,2)
    !Alignment(NearestMyGroupOfType,MASK_GOOD)
    CheckStatGT(NearestMyGroupOfType,49,RESISTMAGIC)
    CheckStatGT(NearestMyGroupOfType,0,MINORGLOBE)
  OR(5)
    !Exists(SecondNearestMyGroupOfType)
    Range(SecondNearestMyGroupOfType,3)
    !Alignment(SecondNearestMyGroupOfType,MASK_GOOD)
    CheckStatGT(SecondNearestMyGroupOfType,49,RESISTMAGIC)
    CheckStatGT(SecondNearestMyGroupOfType,0,MINORGLOBE)
  OR(5)
    !Exists(ThirdNearestMyGroupOfType)
    Range(ThirdNearestMyGroupOfType,4)
    !Alignment(ThirdNearestMyGroupOfType,MASK_GOOD)
    CheckStatGT(ThirdNearestMyGroupOfType,49,RESISTMAGIC)
    CheckStatGT(ThirdNearestMyGroupOfType,0,MINORGLOBE)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_UNHOLY_BLIGHT)
END

IF
  ActionListEmpty()
  RandomNumLT(44,12)
  General(LastSeenBy(Myself),UNDEAD)
  Range(LastSeenBy(Myself),15)
  !GlobalTimerNotExpired("BPTurn","LOCALS")
  Global("TURN","LOCALS",0)
  CheckStat(LastSeenBy(Myself),0,187) // Immune to Turn Undead
  HPPercentGT(Myself,50)
  !Range([EVILCUTOFF.UNDEAD],15)
THEN
  RESPONSE #100
    SetGlobalTimer("BPTurn","LOCALS",TWO_ROUNDS)
    SetGlobal("TURN","LOCALS",1)
    Turn()
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_ANIMATE_DEAD)
  !GlobalTimerNotExpired("BPT","LOCALS")
  RandomNumLT(39,25)
  NumCreatureLT([EVILCUTOFF.0.0.0.0.SUMMONED],7)
  NumCreatureLT([EVILCUTOFF.UNDEAD.0.0.0.SUMMONED],5)
  CheckStatLT(Myself,61,SPELLFAILUREPRIEST)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_ANIMATE_DEAD)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_CONFUSION)
  !GlobalTimerNotExpired("BPT","LOCALS")
  RandomNumLT(41,26)
  !StateCheck(LastSeenBy(Myself),STATE_CONFUSED)
  !StateCheck(LastSeenBy(Myself),STATE_PANIC)
  !StateCheck(LastSeenBy(Myself),STATE_BERSERK)
  CheckStat(LastSeenBy(Myself),0,HELD)
  !StateCheck(LastSeenBy(Myself),0x00102029)  
  !General(LastSeenBy(Myself),UNDEAD)
  CheckStatGT(LastSeenBy(Myself),5,SAVEVSSPELL)
  CheckStatLT(LastSeenBy(Myself),61,RESISTMAGIC)
  CheckStatLT(Myself,61,SPELLFAILUREPRIEST)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_CONFUSION)
END

IF
  ActionListEmpty()
  HaveSpell(ENEMY_CLERIC_SLAY_LIVING)
  !GlobalTimerNotExpired("BPT","LOCALS")
  RandomNumLT(41,24)
  CheckStat(LastSeenBy(Myself),0,157)
  OR(2)
    CheckStat(LastSeenBy(Myself),0,129)
    RandomNumLT(99,23)
  CheckStatGT(LastSeenBy(Myself),5,SAVEVSDEATH)
  CheckStatLT(LastSeenBy(Myself),61,RESISTMAGIC)
  CheckStatLT(Myself,61,SPELLFAILUREPRIEST)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),ENEMY_CLERIC_SLAY_LIVING)
END

IF
  ActionListEmpty()
  HaveSpell(ENEMY_CLERIC_HARM)
  !GlobalTimerNotExpired("BPT","LOCALS")
  RandomNumLT(42,25)
  OR(2)
    CheckStat(LastSeenBy(Myself),0,129)
    RandomNumLT(99,23)
  CheckStatGT(LastSeenBy(Myself),5,SAVEVSDEATH)
  CheckStatLT(LastSeenBy(Myself),61,RESISTMAGIC)
  CheckStatLT(Myself,61,SPELLFAILUREPRIEST)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),ENEMY_CLERIC_HARM)
END

IF
  ActionListEmpty()
  General(LastSeenBy(Myself),HUMANOID)
  HaveSpell(CLERIC_HOLD_PERSON)
  !GlobalTimerNotExpired("BPT","LOCALS")
  RandomNumLT(55,41)
  OR(2)
    CheckStat(LastSeenBy(Myself),0,129)
    RandomNumLT(99,23)
  CheckStatLT(LastSeenBy(Myself),1,131) // Free Action
  !StateCheck(LastSeenBy(Myself),0x00400010) // STATE_NOT_VISIBLE
  !StateCheck(LastSeenBy(Myself),0x102029) // STATE_HARMLESS
  !StateCheck(LastSeenBy(Myself),STATE_BERSERK)
  CheckStatLT(LastSeenBy(Myself),1,HELD)
  CheckStatLT(LastSeenBy(Myself),1,WEB)
  CheckStatLT(LastSeenBy(Myself),1,ENTANGLE)
  CheckStatGT(LastSeenBy(Myself),5,SAVEVSSPELL)
  CheckStatLT(LastSeenBy(Myself),61,RESISTMAGIC)
  CheckStatLT(Myself,61,SPELLFAILUREPRIEST)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_HOLD_PERSON)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_FLAME_STRIKE)
  !GlobalTimerNotExpired("BPT","LOCALS")
  RandomNumLT(45,28)
  OR(2)
    CheckStat(LastSeenBy(Myself),0,129) // either they have no spell turning
    RandomNumLT(99,23)
  !StateCheck(LastSeenBy(Myself),0x00400010)
  CheckStatLT(LastSeenBy(Myself),51,RESISTFIRE)
  CheckStatGT(LastSeenBy(Myself),5,SAVEVSSPELL)
  CheckStatLT(Myself,61,SPELLFAILUREPRIEST)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_FLAME_STRIKE)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_MENTAL_DOMINATION)
  !GlobalTimerNotExpired("BPT","LOCALS")
  RandomNumLT(50,28)
  !General(LastSeenBy(Myself),UNDEAD)
  OR(2)
    CheckStat(LastSeenBy(Myself),0,129) // either they have no spell turning
    RandomNumLT(99,23) //or we'll just shoot the moon
  !StateCheck(LastSeenBy(Myself),0x102029) // state_harmless
  !StateCheck(LastSeenBy(Myself),STATE_PANIC)
  !StateCheck(LastSeenBy(Myself),STATE_BERSERK)
  !StateCheck(LastSeenBy(Myself),0x00400010) // STATE_NOT_VISIBLE
  CheckStatGT(LastSeenBy(Myself),5,SAVEVSSPELL)
  CheckStatLT(LastSeenBy(Myself),61,RESISTMAGIC)
  CheckStatLT(Myself,61,SPELLFAILUREPRIEST)
  OR(6)
    HPGT(LastSeenBy(Myself),25)
    Class(LastSeenBy(Myself),DRUID_ALL)
    Class(LastSeenBy(Myself),BARD_ALL)
    Class(LastSeenBy(Myself),CLERIC_ALL)
    Class(LastSeenBy(Myself),LONG_BOW)
    Class(LastSeenBy(Myself),SORCERER)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_MENTAL_DOMINATION)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_POISON)
  !GlobalTimerNotExpired("BPT","LOCALS")
  RandomNumLT(52,31)
  !StateCheck(LastSeenBy(Myself),STATE_POISONED)
  CheckStatGT(LastSeenBy(Myself),5,SAVEVSSPELL)
  CheckStatLT(LastSeenBy(Myself),61,RESISTMAGIC)
  CheckStatLT(Myself,61,SPELLFAILUREPRIEST)
  OR(6)
    HPGT(LastSeenBy(Myself),29)
    Class(LastSeenBy(Myself),DRUID_ALL)
    Class(LastSeenBy(Myself),BARD_ALL)
    Class(LastSeenBy(Myself),CLERIC_ALL)
    Class(LastSeenBy(Myself),LONG_BOW)
    Class(LastSeenBy(Myself),SORCERER)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_POISON)
END

IF
  ActionListEmpty()
  General(LastSeenBy(Myself),ANIMAL)
  HaveSpell(RANGER_CHARM_ANIMAL)
  !GlobalTimerNotExpired("BPT","LOCALS")
  HPGT(LastSeenBy(Myself),24)
  OR(2)
    CheckStat(LastSeenBy(Myself),0,129) // either they have no spell turning
    RandomNumLT(99,23) //or we'll just shoot the moon
  !StateCheck(LastSeenBy(Myself),0x102029) // state_harmless
  !StateCheck(LastSeenBy(Myself),STATE_PANIC)
  !StateCheck(LastSeenBy(Myself),STATE_BERSERK)
  !StateCheck(LastSeenBy(Myself),0x00400010) // STATE_NOT_VISIBLE
  CheckStatGT(LastSeenBy(Myself),5,SAVEVSSPELL)
  CheckStatLT(LastSeenBy(Myself),61,RESISTMAGIC)
  CheckStatLT(Myself,61,SPELLFAILUREPRIEST)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),RANGER_CHARM_ANIMAL)
END

IF
  ActionListEmpty()
  OR(2)
    General(LastSeenBy(Myself),HUMANOID)
    General(LastSeenBy(Myself),ANIMAL)
  HaveSpell(CLERIC_CHARM_PERSON)
  !GlobalTimerNotExpired("BPT","LOCALS")
  RandomNumLT(44,21)
  OR(2)
    CheckStat(LastSeenBy(Myself),0,129) // either they have no spell turning
    RandomNumLT(99,23) //or we'll just shoot the moon
  !StateCheck(LastSeenBy(Myself),0x102029) // state_harmless
  !StateCheck(LastSeenBy(Myself),STATE_PANIC)
  !StateCheck(LastSeenBy(Myself),STATE_BERSERK)
  !StateCheck(LastSeenBy(Myself),0x00400010) // STATE_NOT_VISIBLE
  CheckStatGT(LastSeenBy(Myself),5,SAVEVSSPELL)
  CheckStatLT(LastSeenBy(Myself),61,RESISTMAGIC)
  CheckStatLT(Myself,61,SPELLFAILUREPRIEST)
  OR(6)
    HPGT(LastSeenBy(Myself),19)
    Class(LastSeenBy(Myself),DRUID_ALL)
    Class(LastSeenBy(Myself),BARD_ALL)
    Class(LastSeenBy(Myself),CLERIC_ALL)
    Class(LastSeenBy(Myself),LONG_BOW)
    Class(LastSeenBy(Myself),SORCERER)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_CHARM_PERSON)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_COMMAND)
  !GlobalTimerNotExpired("BPT","LOCALS")
  RandomNumLT(56,22)
  CheckStat(LastSeenBy(Myself),0,129)
  !StateCheck(LastSeenBy(Myself),0x102029) // state_harmless
  !StateCheck(LastSeenBy(Myself),STATE_SLEEPING)
  OR(2)
    CheckStatGT(LastSeenBy(Myself),5,SAVEVSSPELL)
    CheckStatLT(LastSeenBy(Myself),6,LEVEL)
  CheckStatLT(LastSeenBy(Myself),61,RESISTMAGIC)
  CheckStatLT(Myself,61,SPELLFAILUREPRIEST)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_COMMAND)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_DOOM)
  !GlobalTimerNotExpired("BPT","LOCALS")
  RandomNumLT(55,24)
  OR(2)
    CheckStat(LastSeenBy(Myself),0,129) // either they have no spell turning
    RandomNumLT(99,23) //or we'll just shoot the moon
  CheckStatGT(LastSeenBy(Myself),5,SAVEVSSPELL)
  CheckStatLT(LastSeenBy(Myself),61,RESISTMAGIC)
  CheckStatLT(Myself,61,SPELLFAILUREPRIEST)
  OR(6)
    Class(LastSeenBy(Myself),MONK)
    Class(LastSeenBy(Myself),FIGHTER_ALL)
    Class(LastSeenBy(Myself),RANGER_ALL)
    Class(LastSeenBy(Myself),PALADIN_ALL)
    HPGT(LastSeenBy(Myself),24)
    CheckStatLT(LastSeenBy(Myself),15,THAC0)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_DOOM)
END

IF
  Global("BPRC","LOCALS",0)
  OR(2)
    Class(Myself,CLERIC_ALL)
    Class(Myself,PALADIN_ALL)
THEN
  RESPONSE #100
    SetGlobal("BPRC","LOCALS",1)
    Continue()
END

IF
  Global("BPRC","LOCALS",0)
  !Class(Myself,CLERIC_ALL)
  !Class(Myself,PALADIN_ALL)
THEN
  RESPONSE #100
    ChangeClass(Myself,CLERIC)
    SetGlobal("BPRC","LOCALS",1)
    Continue()
END



IF
  RandomNumLT(29,23)
  OR(7)
    See([PC.0.0.RANGER_ALL])
    See([PC.0.0.PALADIN_ALL])
    See([PC.0.0.BARD_ALL])
    See([PC.0.0.DRUID_ALL])
    See([PC.0.0.CLERIC_ALL])
    See([PC.0.0.LONG_BOW])
    See([PC.0.0.SORCERER])
  RandomNumLT(30,16)
  See(Protagonist)
  RandomNumLT(26,10)
  OR(4)
    See([GOODCUTOFF.0.0.RANGER_ALL])
    See([GOODCUTOFF.0.0.DRUID_ALL])
    See([GOODCUTOFF.0.0.PALADIN_ALL])
    See([GOODCUTOFF.0.0.CLERIC_ALL])
  RandomNumLT(27,10)
  OR(3)
    See([GOODCUTOFF.0.0.MONK])
    See([GOODCUTOFF.0.0.BARD_ALL])
    See([GOODCUTOFF.0.0.THIEF_ALL])
  RandomNumLT(32,11)
  OR(2)
    See(TenthNearest([GOODCUTOFF.0.0.LONG_BOW]))
    See(TenthNearest([GOODCUTOFF.0.0.SORCERER]))
  RandomNumLT(20,8)
  See(TenthNearestEnemyOf(Myself))
  False()
THEN
  RESPONSE #100
    Continue()
END




IF
  ActionListEmpty()
  HaveSpell(CLERIC_CAUSE_SERIOUS_WOUNDS)
  !GlobalTimerNotExpired("BPT","LOCALS")
  RandomNumLT(53,31)
  Range(LastSeenBy(Myself),4)
  !HasItem("CRITICAL",Myself)  // ~Cause Critical Wounds~
  !HasItem("SERIOUS",Myself)  // ~Cause Serious Wounds~
  !HasItem("FBLADE",Myself)  // ~Shocking Grasp~
  CheckStat(LastSeenBy(Myself),0,181)
  CheckStatLT(LastSeenBy(Myself),61,RESISTMAGIC)
  CheckStatLT(Myself,61,SPELLFAILUREPRIEST)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_CAUSE_SERIOUS_WOUNDS)
    AttackOneRound(LastSeenBy(Myself))
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_FLAME_BLADE)
  Range(LastSeenBy(Myself),10)
  !GlobalTimerNotExpired("BPT","LOCALS")
  RandomNumLT(56,25)
  Range(LastSeenBy(Myself),4)
  !HasItem("FBLADE",Myself)  // ~Flame Blade~
  !HasItem("SHAMMR",Myself)  // ~Spiritual Hammer~
  !HasItem("SHAMMR1",Myself)  // ~Flame Blade~
  !HasItem("SHAMMR2",Myself)  // ~Cause Serious Wounds~
  !HasItem("SHAMMR3",Myself)  // ~Cause Serious Wounds~
  !HasItem("SERIOUS",Myself)  // ~Cause Serious Wounds~
  CheckStat(LastSeenBy(Myself),0,181)
  CheckStatLT(LastSeenBy(Myself),61,RESISTFIRE)
  CheckStatLT(LastSeenBy(Myself),61,RESISTMAGIC)
  CheckStatLT(Myself,61,SPELLFAILUREPRIEST)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_FLAME_BLADE)
    AttackReevaluate(LastSeenBy(Myself),45)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_SPIRITUAL_HAMMER)
  !GlobalTimerNotExpired("BPT","LOCALS")
  RandomNumLT(57,27)
  Range(LastSeenBy(Myself),4)
  CheckStatGT(Myself,4,LEVEL)
  CheckStatLT(LastSeenBy(Myself),1,128)
  !HasItem("SHAMMR",Myself)  // ~Spiritual Hammer~
  !HasItem("SHAMMR1",Myself)  // ~Flame Blade~
  !HasItem("SHAMMR2",Myself)  // ~Cause Serious Wounds~
  !HasItem("SHAMMR3",Myself)  // ~Cause Serious Wounds~
  !HasItem("FBLADE",Myself)  // ~Flame Blade~
  !HasItem("SERIOUS",Myself)  // ~Cause Serious Wounds~
THEN
  RESPONSE #100
    Spell(Myself,CLERIC_SPIRITUAL_HAMMER)
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    AttackReevaluate(LastSeenBy(Myself),45)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_SPIRITUAL_HAMMER)
  !GlobalTimerNotExpired("BPT","LOCALS")
  RandomNumLT(57,27)
  Range(LastSeenBy(Myself),4)
  CheckStatLT(Myself,5,LEVEL)
  CheckStat(LastSeenBy(Myself),0,181)
  !HasItem("SHAMMR",Myself)  // ~Spiritual Hammer~
  !HasItem("SHAMMR1",Myself)  // ~Flame Blade~
  !HasItem("SHAMMR2",Myself)  // ~Cause Serious Wounds~
  !HasItem("SHAMMR3",Myself)  // ~Cause Serious Wounds~
  !HasItem("FBLADE",Myself)  // ~Flame Blade~
  !HasItem("SERIOUS",Myself)  // ~Cause Serious Wounds~
THEN
  RESPONSE #100
    Spell(Myself,CLERIC_SPIRITUAL_HAMMER)
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    AttackReevaluate(LastSeenBy(Myself),45)
END

IF
  ActionListEmpty()
  HPPercentLT(Myself,25)
  Range(LastHitter(Myself),10)
  !GlobalTimerNotExpired("BPW","LOCALS")
  OR(3)
    !Race(LastHitter(Myself),MORNINGSTAR)
    !Class(LastHitter(Myself),FAIRY_NYMPH)
    !Specifics(LastHitter(Myself),65)
THEN
  RESPONSE #30
    DisplayStringHead(Myself,49767)
    Shout(124)
    SetGlobalTimer("BPW","LOCALS",10)
    RunAwayFrom(LastHitter(Myself),40)
  RESPONSE #15
    DisplayStringHead(Myself,@11)
    Shout(124)
    SetGlobalTimer("BPW","LOCALS",10)
    Attack(LastHitter(Myself))
  RESPONSE #40
    DisplayStringHead(Myself,49766)
    Shout(123)
    SetGlobalTimer("BPW","LOCALS",10)
    AttackReevaluate(LastSeenBy(Myself),15)
END

IF
  ActionListEmpty()
  CheckStatGT(LastSeenBy(Myself),10,180)
  CheckStatLT(Myself,11,180)
  !HasItem("SHAMMR",Myself)  // ~Spiritual Hammer~
  !HasItem("SHAMMR1",Myself)  // ~Cause Critical Wounds~
  !HasItem("SHAMMR2",Myself)  // ~Cause Critical Wounds~
  !HasItem("SHAMMR3",Myself)  // ~Cause Critical Wounds~
  !HasItem("FBLADE",Myself)  // ~Flame Blade~
  !HasItem("SERIOUS",Myself)  // ~Cause Serious Wounds~
  !HasItemSlot(Myself,SLOT_MISC0)
  !HasItemSlot(Myself,SLOT_MISC1)
  !HasItemSlot(Myself,SLOT_MISC2)
THEN
  RESPONSE #100
    EquipRanged()
    AttackOneRound(LastSeenBy(Myself))
END

IF
  ActionListEmpty()
  OR(3)
    !Range(NearestEnemyOf(Myself),5)
    CheckStatGT(LastSeenBy(Myself),0,121)
    CheckStatGT(LastSeenBy(Myself),0,125)
  !HasItem("SHAMMR",Myself)  // ~Spiritual Hammer~
  !HasItem("SHAMMR",Myself)  // ~Cause Critical Wounds~
  !HasItem("SHAMMR1",Myself)  // ~Cause Critical Wounds~
  !HasItem("SHAMMR2",Myself)  // ~Cause Critical Wounds~
  !HasItem("SHAMMR3",Myself)  // ~Cause Critical Wounds~
  !HasItem("FBLADE",Myself)  // ~Flame Blade~
  !HasItem("SERIOUS",Myself)  // ~Cause Serious Wounds~
  !HasItemSlot(Myself,SLOT_MISC0)
  !HasItemSlot(Myself,SLOT_MISC1)
  !HasItemSlot(Myself,SLOT_MISC2)
THEN
  RESPONSE #100
    EquipRanged()
    AttackReevaluate(LastSeenBy(Myself),45)
END

IF
  OR(2)
    CheckStatGT(NearestEnemyOf(Myself),0,121)
    CheckStatGT(LastSeenBy(Myself),0,125)
THEN
  RESPONSE #25
    Continue()
  RESPONSE #75
END

IF
  ActionListEmpty()
  !Range(LastSeenBy(Myself),8)
  OR(3)
    !Race(NearestEnemyOf(Myself),MORNINGSTAR)
    !Class(NearestEnemyOf(Myself),FAIRY_NYMPH)
    !Specifics(NearestEnemyOf(Myself),65)
  !HasItemSlot(Myself,SLOT_MISC0)
  !HasItemSlot(Myself,SLOT_MISC1)
  !HasItemSlot(Myself,SLOT_MISC2)
THEN
  RESPONSE #90
    AttackOneRound(NearestEnemyOf(Myself))
  RESPONSE #90
    EquipMostDamagingMelee()
    MoveToObjectNoInterrupt(LastSeenBy(Myself))
    AttackReevaluate(LastSeenBy(Myself),135)
END

IF
  ActionListEmpty()
  !HasItemSlot(Myself,SLOT_MISC0)
  !HasItemSlot(Myself,SLOT_MISC1)
  !HasItemSlot(Myself,SLOT_MISC2)
THEN
  RESPONSE #100
    EquipMostDamagingMelee()
    AttackOneRound(LastSeenBy(Myself))
END

IF
  ActionListEmpty()
  OR(6)
    HasItem("FBLADE",Myself)  // ~Shocking Grasp~
    HasItem("SHAMMR",Myself)  // ~Cause Critical Wounds~
    HasItem("SHAMMR1",Myself)  // ~Cause Critical Wounds~
    HasItem("SHAMMR2",Myself)  // ~Cause Critical Wounds~
    HasItem("SHAMMR3",Myself)  // ~Cause Critical Wounds~
    HasItem("SERIOUS",Myself)  // ~Cause Serious Wounds~
  OR(4)
    HasItemSlot(Myself,SLOT_MISC0)
    HasItemSlot(Myself,SLOT_MISC1)
    HasItemSlot(Myself,SLOT_MISC2)
    Specifics(Myself,5)
THEN
  RESPONSE #75
    AttackOneRound(LastSeenBy(Myself))
  RESPONSE #25
    Continue()
END

