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))
  OR(2)
    General(Myself,HUMANOID)
    General(Myself,GIANTHUMANOID)
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_INSECT_PLAGUE)
    RemoveSpell(CLERIC_INSECT_PLAGUE)
  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_HOLD_PERSON)
    RemoveSpell(CLERIC_HOLD_PERSON)
    ForceSpell(LastSeenBy(Myself),CLERIC_SILENCE_15_FOOT)
    RemoveSpell(CLERIC_SILENCE_15_FOOT)
  RESPONSE #15
    DisplayStringHead(Myself,@0)
    SetGlobal("BPCHASER","LOCALS",0)
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    ForceSpell(LastSeenBy(Myself),CLERIC_CALL_LIGHTNING)
    RemoveSpell(CLERIC_CALL_LIGHTNING)
  RESPONSE #10
    DisplayStringHead(Myself,@0)
    SetGlobal("BPCHASER","LOCALS",0)
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    ForceSpell(LastSeenBy(Myself),CLERIC_POISON)
    RemoveSpell(CLERIC_POISON)
END

IF
  GlobalTimerExpired("BPCHASE","LOCALS")
  Global("BPCHASER","LOCALS",1)
  !See([GOODCUTOFF])
  !See(LastHitter(Myself))
  OR(2)
    General(Myself,HUMANOID)
    General(Myself,GIANTHUMANOID)
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,WIZARD_GREATER_MALISON)
    CheckStat(Myself,16,WIZARD_GREATER_MALISON)
    CheckStat(Myself,17,WIZARD_GREATER_MALISON)
    CheckStat(Myself,20,WIZARD_GREATER_MALISON)
THEN
  RESPONSE #50
    SetGlobal("BP_SweetZone","LOCALS",1)
    DisplayStringHead(Myself,@2)
    ForceSpell(Myself,CLERIC_ZONE_OF_SWEET_AIR)
  RESPONSE #50
    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 #20
    DisplayStringHead(Myself,@3)
    SetGlobalTimer("BPCHASE","LOCALS",12)
    SetGlobal("BPCHASER","LOCALS",1)
    MoveToObject(LastHitter(Myself))
  RESPONSE #15
    DisplayStringHead(Myself,@3)
    SetGlobalTimer("BPCHASE","LOCALS",12)
    SetGlobal("BPCHASER","LOCALS",1)
    ReallyForceSpell(Myself,CLERIC_BARKSKIN)
    ReallyForceSpell(Myself,CLERIC_DRAW_UPON_HOLY_MIGHT)
    ReallyForceSpell(Myself,CLERIC_PHYSICAL_MIRROR)
    SetGlobalTimer("CHE","LOCALS",ONE_TURN)
    IncrementGlobal("SCH","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_ZONE_OF_SWEET_AIR)
    ReallyForceSpell(Myself,CLERIC_AID)
    SetGlobalTimer("CHE","LOCALS",ONE_TURN)
    IncrementGlobal("SCH","LOCALS",1)
    MoveToObject(LastHitter(Myself))
  RESPONSE #15
    DisplayStringHead(Myself,@3)
    SetGlobalTimer("BPCHASE","LOCALS",12)
    SetGlobal("BPCHASER","LOCALS",1)
    ReallyForceSpell(Myself,NPC_BLADE_BARRIER)
    ReallyForceSpell(Myself,CLERIC_DEFENSIVE_HARMONY)
    SetGlobalTimer("CHE","LOCALS",ONE_TURN)
    IncrementGlobal("SCH","LOCALS",1)
    MoveToObject(LastHitter(Myself))
  RESPONSE #20
    DisplayStringHead(Myself,@3)
    SetGlobalTimer("BPCHASE","LOCALS",12)
    SetGlobal("BPCHASER","LOCALS",1)
    ReallyForceSpell(Myself,CLERIC_SANCTUARY)
    ReallyForceSpell(Myself,CLERIC_CHAOTIC_COMMANDS)
    ReallyForceSpell(Myself,CLERIC_IRONSKIN)
    SetGlobalTimer("BPIP","LOCALS",15)
    SetGlobalTimer("CHE","LOCALS",ONE_TURN)
    IncrementGlobal("SCH","LOCALS",1)
    RunAwayFrom(LastHitter(Myself),45)
  RESPONSE #20
    DisplayStringHead(Myself,@3)
    RunAwayFrom(LastHitter(Myself),45)
END

IF
  CheckStatGT(Myself,10,WIZARD_GREATER_MALISON)
  CheckStatGT(Myself,5,INT)
  OR(2)
    See(LastAttackerOf(Myself))
    See(LastHitter(Myself))
  CheckStatLT(LastSeenBy(Myself),11,WIZARD_GREATER_MALISON)
  !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,WIZARD_GREATER_MALISON)
  CheckStatGT(Myself,5,INT)
  OR(2)
    See(TenthNearest([GOODCUTOFF]))
    See(TenthNearest([PC]))
  CheckStatLT(LastSeenBy(Myself),11,WIZARD_GREATER_MALISON)
  !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,WIZARD_GREATER_MALISON)
  CheckStatGT(Myself,5,INT)
  See(TenthNearest)
  CheckStatLT(TenthNearest,11,WIZARD_GREATER_MALISON)
  !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
  ActionListEmpty()
  SpellCastPriest(Myself,0)
  HaveAnySpells()
  HitBy([ANYONE],CRUSHING)
  NumCreatureGT([EVILCUTOFF],3)
  !GlobalTimerNotExpired("SBN","LOCALS")
THEN
  RESPONSE #100
    SetGlobalTimer("SBN","LOCALS",TWO_ROUNDS)
    DisplayStringHead(Myself,64573)  // ~Help! Guards, protect me!~
    Shout(69)
END

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

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

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

IF
  Global("BPMRC","LOCALS",0)
  OR(3)
    Class(Myself,DRUID)
    Class(Myself,FIGHTER_DRUID)
    Class(Myself,RANGER_ALL)
THEN
  RESPONSE #100
    SetGlobal("BPMRC","LOCALS",1)
END

IF
  Global("BPMRC","LOCALS",0)
THEN
  RESPONSE #100
    ChangeClass(Myself,DRUID)
    SetGlobal("BPMRC","LOCALS",1)
END

IF
  HPPercentLT(Myself,50)
  !GlobalTimerNotExpired("POT","LOCALS")
  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
  HPPercentLT(Myself,40)
  HaveSpell(CLERIC_HEAL)
  Global("MORPH","LOCALS",0)
  Global("SNAFU","LOCALS",0)
  !GlobalTimerNotExpired("BPT","LOCALS")
THEN
  RESPONSE #100
    SetGlobal("BPT","LOCALS",6)
    SetInterrupt(FALSE)
    Spell(Myself,CLERIC_HEAL)
    SetInterrupt(TRUE)
END

IF
  HPPercentLT(Myself,60)
  HaveSpell(CLERIC_MASS_CURE)
  Global("MORPH","LOCALS",0)
  Global("SNAFU","LOCALS",0)
  !GlobalTimerNotExpired("BPT","LOCALS")
THEN
  RESPONSE #100
    SetGlobal("BPT","LOCALS",6)
    SetInterrupt(FALSE)
    Spell(Myself,CLERIC_MASS_CURE)
    SetInterrupt(TRUE)
END

IF
  HPPercentLT(Myself,65)
  HaveSpell(CLERIC_CURE_SERIOUS_WOUNDS)
  Global("MORPH","LOCALS",0)
  Global("SNAFU","LOCALS",0)
  !GlobalTimerNotExpired("BPT","LOCALS")
THEN
  RESPONSE #100
    SetGlobal("BPT","LOCALS",6)
    SetInterrupt(FALSE)
    Spell(Myself,CLERIC_CURE_SERIOUS_WOUNDS)
    SetInterrupt(TRUE)
END

IF
  HPPercentLT(Myself,70)
  HaveSpell(CLERIC_CURE_MEDIUM_WOUNDS)
  Global("MORPH","LOCALS",0)
  Global("SNAFU","LOCALS",0)
  !GlobalTimerNotExpired("BPT","LOCALS")
THEN
  RESPONSE #100
    SetGlobal("BPT","LOCALS",6)
    SetInterrupt(FALSE)
    Spell(Myself,CLERIC_CURE_MEDIUM_WOUNDS)
    SetInterrupt(TRUE)
END

IF
  ActionListEmpty()
  See([EVILCUTOFF])
  !HaveSpell(CLERIC_MASS_CURE)
  !HaveSpell(CLERIC_CURE_SERIOUS_WOUNDS)
  !HaveSpell(CLERIC_HEAL)
  !HaveSpell(CLERIC_CURE_MEDIUM_WOUNDS)
  !HasItem("POTN52",Myself)  // ~Potion of Extra Healing~
  HPPercentLT(Myself,35)
  !GlobalTimerNotExpired("HEAL","LOCALS")
THEN
  RESPONSE #80
    SetGlobalTimer("BPW","LOCALS",ONE_ROUND)
    DisplayStringHead(Myself,72808)  // ~I need healing!~
    Shout(123)
  RESPONSE #20
    Continue()
END

IF
  ActionListEmpty()
  StateCheck(Myself,STATE_POISONED)
  !GlobalTimerNotExpired("POIS","LOCALS")
  !HasItem("POTN17",Myself)  // ~Elixir of Health~
  !HasItem("POTN20",Myself)  // ~Antidote~
THEN
  RESPONSE #100
    Shout(83)
    DisplayStringHead(Myself,5236)  // ~ Please. . . that pack of gnolls . . .they poisoned me.  ~ [POISN01]
    SetGlobalTimer("POIS","LOCALS",ONE_ROUND)
END

IF
  ActionListEmpty()
  !GlobalTimerNotExpired("CHE","LOCALS")
  GlobalLT("SCH","LOCALS",2)
  Global("MORPH","LOCALS",0)
  Global("SNAFU","LOCALS",0)
THEN
  RESPONSE #50
    ReallyForceSpell(Myself,CLERIC_SANCTUARY)
    ReallyForceSpell(Myself,CLERIC_CHAOTIC_COMMANDS)
    ReallyForceSpell(Myself,CLERIC_IRONSKIN)
    SetGlobalTimer("BPIP","LOCALS",15)
    SetGlobalTimer("CHE","LOCALS",ONE_TURN)
    IncrementGlobal("SCH","LOCALS",1)
  RESPONSE #50
    ReallyForceSpell(Myself,CLERIC_BARKSKIN)
    ReallyForceSpell(Myself,CLERIC_DRAW_UPON_HOLY_MIGHT)
    ReallyForceSpell(Myself,CLERIC_PHYSICAL_MIRROR)
    SetGlobalTimer("CHE","LOCALS",ONE_TURN)
    IncrementGlobal("SCH","LOCALS",1)
  RESPONSE #50
    ReallyForceSpell(Myself,CLERIC_IRONSKIN)
    ReallyForceSpell(Myself,CLERIC_ZONE_OF_SWEET_AIR)
    ReallyForceSpell(Myself,CLERIC_AID)
    SetGlobalTimer("CHE","LOCALS",ONE_TURN)
    IncrementGlobal("SCH","LOCALS",1)
  RESPONSE #50
    ReallyForceSpell(Myself,NPC_BLADE_BARRIER)
    ReallyForceSpell(Myself,CLERIC_DEFENSIVE_HARMONY)
    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()
  HaveSpell(CLERIC_SANCTUARY)
  !GlobalTimerNotExpired("BPT","LOCALS")
  !Global("MORPH","LOCALS",0)
  Global("SNAFU","LOCALS",0)
  CheckStat(Myself,0,SANCTUARY)
  OR(2)
    RandomNum(2,1)
    HPPercentLT(Myself,50)
  Global("MORPH","LOCALS",0)
THEN
  RESPONSE #100
    SetGlobalTimer("BPIP","LOCALS",15)
    Spell(Myself,CLERIC_SANCTUARY)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_IRONSKIN)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("MORPH","LOCALS",0)
  Global("SNAFU","LOCALS",0)
  CheckStat(Myself,0,STONESKINS)
THEN
  RESPONSE #100
    SetGlobal("BPT","LOCALS",6)
    Spell(Myself,CLERIC_IRONSKIN)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_TRUE_SIGHT)
  CheckStat(Myself,0,TRUE_SIGHT)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("SNAFU","LOCALS",0)
  Exists(LastAttackerOf(Myself))
  OR(8)
    !See([GOODCUTOFF])
    !See(LastAttackerOf(Myself))
    StateCheck(NearestEnemyOf(Myself),STATE_MIRRORIMAGE)
    StateCheck(NearestEnemyOf(Myself),STATE_ILLUSIONS)
    StateCheck(NearestEnemyOf(Myself),STATE_BLUR)
    Gender(NearestEnemyOf(Myself),ILLUSIONARY)
    Specifics(NearestEnemyOf(Myself),SIMULACRUM)
    Specifics(NearestEnemyOf(Myself),NEEDS_BREACH)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    DisplayStringHead(Myself,@5)
    Spell(Myself,CLERIC_TRUE_SIGHT)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_INVISIBILITY_PURGE)
  !GlobalTimerNotExpired("BPT","LOCALS")
  CheckStat(Myself,0,TRUE_SIGHT)
  Global("MORPH","LOCALS",0)
  Global("SNAFU","LOCALS",0)
  !See([GOODCUTOFF])
THEN
  RESPONSE #100
    SetGlobal("BPT","LOCALS",6)
    Spell(Myself,CLERIC_INVISIBILITY_PURGE)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_REMOVE_FEAR)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("MORPH","LOCALS",0)
  Global("SNAFU","LOCALS",0)
  CheckStat(Myself,0,WIZARD_RESIST_FEAR)
  OR(4)
    StateCheck([EVILCUTOFF],STATE_PANIC)
    StateCheck(SecondNearest([EVILCUTOFF]),STATE_PANIC)
    StateCheck(ThirdNearest([EVILCUTOFF]),STATE_PANIC)
    StateCheck(FourthNearest([EVILCUTOFF]),STATE_PANIC)
  See(ThirdNearest([EVILCUTOFF]))
THEN
  RESPONSE #100
    SetGlobal("BPT","LOCALS",6)
    Spell(ThirdNearest([EVILCUTOFF]),CLERIC_REMOVE_FEAR)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_PHYSICAL_MIRROR)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("MORPH","LOCALS",0)
  Global("SNAFU","LOCALS",0)
  CheckStat(Myself,0,CLERIC_PHYSICAL_MIRROR)
  RandomNum(3,3)
THEN
  RESPONSE #100
    SetGlobal("BPT","LOCALS",6)
    Spell(Myself,CLERIC_PHYSICAL_MIRROR)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_PROTECTION_FROM_FIRE)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("MORPH","LOCALS",0)
  Global("SNAFU","LOCALS",0)
  CheckStatLT(Myself,100,RESISTFIRE)
  CheckStatLT(Myself,80,RESISTMAGICFIRE)
  RandomNumLT(5,3)
THEN
  RESPONSE #100
    SetGlobal("BPT","LOCALS",6)
    Spell(Myself,CLERIC_PROTECTION_FROM_FIRE)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_RESIST_FIRE)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("MORPH","LOCALS",0)
  Global("SNAFU","LOCALS",0)
  CheckStatLT(Myself,50,RESISTMAGICFIRE)
  CheckStatLT(Myself,50,RESISTFIRE)
  RandomNum(4,3)
THEN
  RESPONSE #100
    SetGlobal("BPT","LOCALS",6)
    Spell(Myself,CLERIC_RESIST_FIRE)
END

IF
  ActionListEmpty()
  HaveSpell(COM_DRUID_DELAY_POISEN)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("MORPH","LOCALS",0)
  Global("SNAFU","LOCALS",0)
  CheckStatLT(Myself,50,RESISTMAGICCOLD)
  CheckStatLT(Myself,50,RESISTCOLD)
  RandomNumLT(6,3)
THEN
  RESPONSE #100
    SetGlobal("BPT","LOCALS",6)
    Spell(Myself,COM_DRUID_DELAY_POISEN)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_BARKSKIN)
  CheckStat(Myself,0,SCRIPTINGSTATE5)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("MORPH","LOCALS",0)
  Global("SNAFU","LOCALS",0)
  RandomNumLT(11,4)
THEN
  RESPONSE #100
    SetGlobal("BPT","LOCALS",6)
    Spell(Myself,CLERIC_BARKSKIN)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_DRAW_UPON_HOLY_MIGHT)
  !GlobalTimerNotExpired("BPT","LOCALS")
  CheckStatLT(Myself,4,SCRIPTINGSTATE6)
  Global("MORPH","LOCALS",0)
  Global("SNAFU","LOCALS",0)
  RandomNumLT(8,3)
THEN
  RESPONSE #100
    SetGlobal("BPT","LOCALS",6)
    Spell(Myself,CLERIC_DRAW_UPON_HOLY_MIGHT)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_ARMOR_OF_FAITH)
  CheckStatLT(Myself,10,SCRIPTINGSTATE5)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("MORPH","LOCALS",0)
  Global("SNAFU","LOCALS",0)
  RandomNumLT(9,3)
THEN
  RESPONSE #100
    SetGlobal("BPT","LOCALS",6)
    Spell(Myself,CLERIC_ARMOR_OF_FAITH)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_CHANT)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("MORPH","LOCALS",0)
  Global("SNAFU","LOCALS",0)
  !StateCheck(Myself,STATE_CHANT)
  !StateCheck(Myself,STATE_BLESS)
  RandomNumLT(10,3)
THEN
  RESPONSE #100
    SetGlobal("BPT","LOCALS",6)
    Spell(Myself,CLERIC_CHANT)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_BLESS)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("MORPH","LOCALS",0)
  Global("SNAFU","LOCALS",0)
  !StateCheck(Myself,STATE_CHANT)
  !StateCheck(Myself,STATE_BLESS)
  RandomNumLT(12,4)
THEN
  RESPONSE #100
    SetGlobal("BPT","LOCALS",6)
    Spell(Myself,CLERIC_BLESS)
END

IF
  Global("MORPH","LOCALS",1)
  Global("BRBEAR","LOCALS",1)
  OR(3)
    HPPercentLT(Myself,20)
    RandomNumLT(7,2)
    GlobalTimerExpired("FORM","LOCALS")
THEN
  RESPONSE #100
    ForceSpellRES("SPIN124",Myself)  // ~Shapeshifts Natural Form~
    SetGlobal("FORM","LOCALS",0)
    SetGlobal("MORPH","LOCALS",0)
    SetGlobal("BRBEAR","LOCALS",2)
END

IF
  Global("MORPH","LOCALS",1)
  Global("BLBEAR","LOCALS",1)
  OR(3)
    HPPercentLT(Myself,20)
    RandomNumLT(7,2)
    GlobalTimerExpired("FORM","LOCALS")
THEN
  RESPONSE #100
    ForceSpellRES("SPIN123",Myself)  // ~Shapeshifts Natural Form~
    SetGlobal("FORM","LOCALS",0)
    SetGlobal("MORPH","LOCALS",0)
    SetGlobal("BLBEAR","LOCALS",2)
END

IF
  Global("MORPH","LOCALS",1)
  Global("WOLF","LOCALS",1)
  OR(3)
    HPPercentLT(Myself,20)
    RandomNumLT(7,2)
    GlobalTimerExpired("FORM","LOCALS")
THEN
  RESPONSE #100
    ForceSpellRES("SPIN122",Myself)  // ~Shapeshifts Natural Form~
    SetGlobal("FORM","LOCALS",0)
    SetGlobal("MORPH","LOCALS",0)
    SetGlobal("WOLF","LOCALS",2)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_DISPEL_MAGIC)
  !GlobalTimerNotExpired("BPT","LOCALS")
  See(SecondNearest([EVILCUTOFF]))
  OR(8)
    StateCheck(LastSeenBy(Myself),STATE_CONFUSED)
    StateCheck(LastSeenBy(Myself),STATE_SILENCED)
    StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
    StateCheck(LastSeenBy(Myself),STATE_BLIND)
    StateCheck(LastSeenBy(Myself),STATE_STUNNED)
    StateCheck(LastSeenBy(Myself),STATE_SLOWED)
    StateCheck(LastSeenBy(Myself),STATE_SLEEPING)
    StateCheck(LastSeenBy(Myself),STATE_FEEBLEMINDED)
  OR(2)
    !HasImmunityEffects(Myself)
    !Range(LastSeenBy(Myself),15)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_DISPEL_MAGIC)
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(32,21)
  OR(3)
    Heard(ThirdNearest([EVILCUTOFF]),124)
    Heard(SecondNearest([EVILCUTOFF]),124)
    Heard([EVILCUTOFF],124)
  HPGT(LastHeardBy(Myself),1)
  Range(LastHeardBy(Myself),20)
  HPGT(LastHitter(LastHeardBy(Myself)),1)
  !See(LastHitter(LastHeardBy(Myself)))
  HPGT(LastAttackerOf(LastHeardBy(Myself)),1)
  !See(LastAttackerOf(LastHeardBy(Myself)))
  False()
THEN
  RESPONSE #100
    Continue()
END

IF
  RandomNumLT(31,21)
  OR(6)
    See(NearestEnemyOf(Myself))
    See(WeakestOf)
    See(WorstAC)
    See(MostDamagedOf)
    See(LastAttackerOf(Myself))
    See(LastHitter(Myself))
  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])
  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(24,9)
  OR(3)
    See(StrongestOf)
    See(BestAC)
    See(LeastDamagedOf)
  RandomNumLT(25,9)
  See(WeakestOf)
  RandomNumLT(23,8)
  See(WorstAC)
  RandomNumLT(21,8)
  See(MostDamagedOf)
  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
  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
  StateCheck(LastSeenBy(Myself),STATE_CHARMED)
THEN
  RESPONSE #80
    Continue()
  RESPONSE #20
END

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

IF
  ActionListEmpty()
  OR(2)
    HasItem("SHILLE",Myself)  // ~Shillelagh~
    HasItem("FBLADE",Myself)  // ~Flame Blade~
  HPPercentGT(Myself,35)
THEN
  RESPONSE #75
    AttackOneRound(LastSeenBy(Myself))
  RESPONSE #25
    Continue()
END

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

IF
  ActionListEmpty()
  HaveSpell(CLERIC_CHARM_PERSON)
  StateCheck(LastSeenBy(Myself),STATE_CHARMED)
  !GlobalTimerNotExpired("BPT","LOCALS")
  CheckStat(LastSeenBy(Myself),0,WIZARD_SPELL_TURNING)
  OR(2)
    General(LastSeenBy(Myself),HUMANOID)
    General(LastSeenBy(Myself),ANIMAL)
THEN
  RESPONSE #80
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_CHARM_PERSON)
  RESPONSE #20
    Continue()
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_SILENCE_15_FOOT)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("MORPH","LOCALS",0)
  CheckStat(LastSeenBy(Myself),0,WIZARD_SPELL_TURNING)
  OR(5)
    Class(LastSeenBy(Myself),DRUID_ALL)
    Class(LastSeenBy(Myself),CLERIC_ALL)
    Class(LastSeenBy(Myself),LONG_BOW)
    Class(LastSeenBy(Myself),SORCERER)
    Class(LastSeenBy(Myself),BARD_ALL)
  !Range(LastSeenBy(Myself),8)
  !StateCheck(LastSeenBy(Myself),STATE_SILENCED)
  RandomNumLT(48,34)
THEN
  RESPONSE #100
    SetGlobal("BPT","LOCALS",6)
    Spell(LastSeenBy(Myself),CLERIC_SILENCE_15_FOOT)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_INSECT_PLAGUE)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("MORPH","LOCALS",0)
  CheckStat(LastSeenBy(Myself),0,WIZARD_SPELL_TURNING)
  CheckStat(LastSeenBy(Myself),0,CLERIC_INSECT_PLAGUE)
  OR(5)
    Class(LastSeenBy(Myself),DRUID_ALL)
    Class(LastSeenBy(Myself),CLERIC_ALL)
    Class(LastSeenBy(Myself),LONG_BOW)
    Class(LastSeenBy(Myself),SORCERER)
    Class(LastSeenBy(Myself),BARD_ALL)
  RandomNumLT(49,35)
THEN
  RESPONSE #100
    SetGlobal("BPT","LOCALS",6)
    Spell(LastSeenBy(Myself),CLERIC_INSECT_PLAGUE)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_MISCAST_MAGIC)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("MORPH","LOCALS",0)
  CheckStatLT(LastSeenBy(Myself),60,SPELLFAILUREMAGE)
  CheckStatLT(LastSeenBy(Myself),60,SPELLFAILUREPRIEST)
  OR(5)
    Class(LastSeenBy(Myself),DRUID_ALL)
    Class(LastSeenBy(Myself),CLERIC_ALL)
    Class(LastSeenBy(Myself),LONG_BOW)
    Class(LastSeenBy(Myself),SORCERER)
    Class(LastSeenBy(Myself),BARD_ALL)
  RandomNumLT(50,34)
THEN
  RESPONSE #100
    SetGlobal("BPT","LOCALS",6)
    Spell(LastSeenBy(Myself),CLERIC_MISCAST_MAGIC)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_DISPEL_MAGIC)
  !GlobalTimerNotExpired("BPT","LOCALS")
  OR(7)
    StateCheck(LastSeenBy(Myself),STATE_CHARMED)
    StateCheck(LastSeenBy(Myself),STATE_HASTED)
    StateCheck(LastSeenBy(Myself),STATE_BLESS)
    StateCheck(LastSeenBy(Myself),STATE_CHANT)
    StateCheck(LastSeenBy(Myself),STATE_MIRRORIMAGE)
    StateCheck(LastSeenBy(Myself),STATE_BLUR)
    HasImmunityEffects(LastSeenBy(Myself))
  OR(2)
    !Range(LastSeenBy(Myself),15)
    !HasImmunityEffects(Myself)
  RandomNumLT(48,31)
THEN
  RESPONSE #100
    SetGlobal("BPT","LOCALS",6)
    Spell(NearestEnemyOf(Myself),CLERIC_DISPEL_MAGIC)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_CONJURE_FIRE_ELEMENTAL)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("MORPH","LOCALS",0)
  NumCreatureLT([EVILCUTOFF.0.0.0.0.SUMMONED],7)
  RandomNumLT(51,31)
THEN
  RESPONSE #100
    SetGlobal("BPT","LOCALS",6)
    Spell(LastSeenBy(Myself),CLERIC_CONJURE_FIRE_ELEMENTAL)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_CONJURE_ANIMALS)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("MORPH","LOCALS",0)
  NumCreatureLT([EVILCUTOFF.0.0.0.0.SUMMONED],7)
  RandomNumLT(52,31)
THEN
  RESPONSE #100
    SetGlobal("BPT","LOCALS",6)
    Spell(LastSeenBy(Myself),CLERIC_CONJURE_ANIMALS)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_ANIMAL_SUMMONING_2)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("MORPH","LOCALS",0)
  NumCreatureLT([EVILCUTOFF.0.0.0.0.SUMMONED],7)
  RandomNumLT(53,29)
THEN
  RESPONSE #100
    SetGlobal("BPT","LOCALS",6)
    Spell(LastSeenBy(Myself),CLERIC_ANIMAL_SUMMONING_2)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_CALL_WOODLAND_BEINGS)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("MORPH","LOCALS",0)
  NumCreatureLT([EVILCUTOFF.0.0.0.0.SUMMONED],7)
  RandomNumLT(34,18)
THEN
  RESPONSE #100
    SetGlobal("BPT","LOCALS",6)
    Spell(LastSeenBy(Myself),CLERIC_CALL_WOODLAND_BEINGS)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_CALL_LIGHTNING)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("MORPH","LOCALS",0)
  CheckStat(LastSeenBy(Myself),0,WIZARD_SPELL_TURNING)
  CheckStatLT(LastSeenBy(Myself),50,RESISTELECTRICITY)
  AreaType(OUTDOOR)
  RandomNumLT(58,48)
THEN
  RESPONSE #100
    SetGlobal("BPT","LOCALS",6)
    Spell(LastSeenBy(Myself),CLERIC_CALL_LIGHTNING)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_POISON)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("MORPH","LOCALS",0)
  CheckStat(LastSeenBy(Myself),0,WIZARD_SPELL_TURNING)
  !StateCheck(LastSeenBy(Myself),STATE_POISONED)
  RandomNumLT(35,20)
THEN
  RESPONSE #100
    SetGlobal("BPT","LOCALS",6)
    Spell(LastSeenBy(Myself),CLERIC_POISON)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_ANIMAL_SUMMONING_1)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("MORPH","LOCALS",0)
  NumCreatureLT([EVILCUTOFF.0.0.0.0.SUMMONED],7)
  RandomNumLT(36,18)
THEN
  RESPONSE #100
    SetGlobal("BPT","LOCALS",6)
    Spell(LastSeenBy(Myself),CLERIC_ANIMAL_SUMMONING_1)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_HOLD_PERSON)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("MORPH","LOCALS",0)
  CheckStat(LastSeenBy(Myself),0,WIZARD_SPELL_TURNING)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  General(LastSeenBy(Myself),HUMANOID)
  RandomNumLT(37,20)
THEN
  RESPONSE #100
    SetGlobal("BPT","LOCALS",6)
    Spell(LastSeenBy(Myself),CLERIC_HOLD_PERSON)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_ENTANGLE)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("MORPH","LOCALS",0)
  CheckStat(LastSeenBy(Myself),0,ENTANGLE)
  !Range(LastSeenBy(Myself),12)
  RandomNumLT(38,19)
THEN
  RESPONSE #100
    SetGlobal("BPT","LOCALS",6)
    Spell(LastSeenBy(Myself),CLERIC_ENTANGLE)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_SUMMON_INSECTS)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("MORPH","LOCALS",0)
  CheckStat(LastSeenBy(Myself),0,WIZARD_SPELL_TURNING)
  CheckStat(LastSeenBy(Myself),0,CLERIC_INSECT_PLAGUE)
  OR(5)
    Class(LastSeenBy(Myself),DRUID_ALL)
    Class(LastSeenBy(Myself),CLERIC_ALL)
    Class(LastSeenBy(Myself),LONG_BOW)
    Class(LastSeenBy(Myself),SORCERER)
    Class(LastSeenBy(Myself),BARD_ALL)
  RandomNumLT(39,22)
THEN
  RESPONSE #100
    SetGlobal("BPT","LOCALS",6)
    Spell(LastSeenBy(Myself),CLERIC_SUMMON_INSECTS)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_CHARM_PERSON)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("MORPH","LOCALS",0)
  CheckStat(LastSeenBy(Myself),0,WIZARD_SPELL_TURNING)
  OR(2)
    General(LastSeenBy(Myself),HUMANOID)
    General(LastSeenBy(Myself),ANIMAL)
  !StateCheck(LastSeenBy(Myself),STATE_CHARMED)
  RandomNumLT(40,19)
THEN
  RESPONSE #100
    SetGlobal("BPT","LOCALS",6)
    Spell(LastSeenBy(Myself),CLERIC_CHARM_PERSON)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_DOOM)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("MORPH","LOCALS",0)
  CheckStat(LastSeenBy(Myself),0,WIZARD_SPELL_TURNING)
  RandomNumLT(41,18)
THEN
  RESPONSE #100
    SetGlobal("BPT","LOCALS",6)
    Spell(LastSeenBy(Myself),CLERIC_DOOM)
END

IF
  ActionListEmpty()
  Range(LastSeenBy(Myself),10)
  HaveSpell(CLERIC_FLAME_BLADE)
  Global("MORPH","LOCALS",0)
  !GlobalTimerNotExpired("BPT","LOCALS")
  RandomNumLT(42,17)
  !HasItem("FBLADE",Myself)  // ~Flame Blade~
  !HasItem("SHILLE",Myself)  // ~Shillelagh~
THEN
  RESPONSE #100
    SetGlobal("BPT","LOCALS",6)
    Spell(Myself,CLERIC_FLAME_BLADE)
    AttackReevaluate(LastSeenBy(Myself),45)
END

IF
  ActionListEmpty()
  Range(LastSeenBy(Myself),10)
  HaveSpell(CLERIC_SHILLELAGH)
  Global("MORPH","LOCALS",0)
  !GlobalTimerNotExpired("BPT","LOCALS")
  RandomNumLT(43,17)
  !HasItem("FBLADE",Myself)  // ~Flame Blade~
  !HasItem("SHILLE",Myself)  // ~Shillelagh~
THEN
  RESPONSE #100
    SetGlobal("BPT","LOCALS",6)
    Spell(Myself,CLERIC_SHILLELAGH)
    AttackReevaluate(LastSeenBy(Myself),45)
END

IF
  !GlobalTimerNotExpired("FORM","LOCALS")
  Global("BRBEAR","LOCALS",0)
  Global("MORPH","LOCALS",0)
  OR(5)
    HPPercentLT(Myself,35)
    RandomNumLT(44,11)
    !HaveAnySpells()
    Range(SecondNearestEnemyOf(Myself),3)
    Range(ThirdNearestEnemyOf(Myself),5)
  !HasItem("FBLADE",Myself)  // ~Flame Blade~
  !HasItem("SHILLE",Myself)  // ~Shillelagh~
THEN
  RESPONSE #100
    ForceSpellRES("SPIN107",Myself)  // ~Shapeshifts Brown Bear~
    SetGlobalTimer("FORM","LOCALS",FIVE_ROUNDS)
    SetGlobal("BRBEAR","LOCALS",1)
    SetGlobal("MORPH","LOCALS",1)
END

IF
  !GlobalTimerNotExpired("FORM","LOCALS")
  Global("BLBEAR","LOCALS",0)
  Global("MORPH","LOCALS",0)
  OR(5)
    HPPercentLT(Myself,35)
    RandomNumLT(45,11)
    !HaveAnySpells()
    Range(SecondNearestEnemyOf(Myself),3)
    Range(ThirdNearestEnemyOf(Myself),5)
  !HasItem("FBLADE",Myself)  // ~Flame Blade~
  !HasItem("SHILLE",Myself)  // ~Shillelagh~
THEN
  RESPONSE #100
    ForceSpellRES("SPIN111",Myself)  // ~Shapeshifts Black Bear~
    SetGlobalTimer("FORM","LOCALS",FIVE_ROUNDS)
    SetGlobal("BLBEAR","LOCALS",1)
    SetGlobal("MORPH","LOCALS",1)
END

IF
  !GlobalTimerNotExpired("FORM","LOCALS")
  Global("WOLF","LOCALS",0)
  Global("MORPH","LOCALS",0)
  OR(5)
    HPPercentLT(Myself,35)
    RandomNumLT(46,11)
    !HaveAnySpells()
    Range(SecondNearestEnemyOf(Myself),3)
    Range(ThirdNearestEnemyOf(Myself),5)
  !HasItem("FBLADE",Myself)  // ~Flame Blade~
  !HasItem("SHILLE",Myself)  // ~Shillelagh~
THEN
  RESPONSE #100
    ForceSpellRES("SPIN110",Myself)  // ~Shapeshifts Wolf~
    SetGlobalTimer("FORM","LOCALS",FIVE_ROUNDS)
    SetGlobal("WOLF","LOCALS",1)
    SetGlobal("MORPH","LOCALS",1)
END

IF
  Global("BPMRC","LOCALS",0)
  OR(3)
    Class(Myself,DRUID)
    Class(Myself,FIGHTER_DRUID)
    Class(Myself,RANGER_ALL)
THEN
  RESPONSE #100
    SetGlobal("BPMRC","LOCALS",1)
END

IF
  Global("BPMRC","LOCALS",0)
THEN
  RESPONSE #100
    ChangeClass(Myself,DRUID)
    SetGlobal("BPMRC","LOCALS",1)
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)  // ~No more~
    Shout(124)
    SetGlobalTimer("BPW","LOCALS",10)
    RunAwayFrom(LastHitter(Myself),40)
  RESPONSE #15
    DisplayStringHead(Myself,@6)
    Shout(124)
    SetGlobalTimer("BPW","LOCALS",10)
    Attack(LastHitter(Myself))
  RESPONSE #40
    DisplayStringHead(Myself,49766)  // ~I can't take this~
    Shout(123)
    SetGlobalTimer("BPW","LOCALS",10)
    AttackReevaluate(LastSeenBy(Myself),15)
END

IF
  ActionListEmpty()
  Global("MORPH","LOCALS",0)
  !HasItem("FBLADE",Myself)
  !HasItem("SHILLE",Myself)
  CheckStatGT(LastSeenBy(Myself),10,WIZARD_GREATER_MALISON)
  CheckStatLT(Myself,11,WIZARD_GREATER_MALISON)
  !HasItemSlot(Myself,SLOT_MISC0)
  !HasItemSlot(Myself,SLOT_MISC1)
  !HasItemSlot(Myself,SLOT_MISC2)
THEN
  RESPONSE #100
    EquipRanged()
    AttackOneRound(LastSeenBy(Myself))
END

IF
  ActionListEmpty()
  Global("MORPH","LOCALS",0)
  OR(4)
    !Range(NearestEnemyOf(Myself),5)
    CheckStatGT(NearestEnemyOf(Myself),0,CLERIC_BLADE_BARRIER)
    CheckStatGT(LastSeenBy(Myself),0,WIZARD_FIRE_SHIELD)
    !HaveAnySpells()
  !HasItem("FBLADE",Myself)  // ~Flame Blade~
  !HasItem("SHILLE",Myself)  // ~Shillelagh~
  !HasItemSlot(Myself,SLOT_MISC0)
  !HasItemSlot(Myself,SLOT_MISC1)
  !HasItemSlot(Myself,SLOT_MISC2)
THEN
  RESPONSE #100
    EquipRanged()
    AttackOneRound(LastSeenBy(Myself))
END

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

IF
  ActionListEmpty()
  Global("MORPH","LOCALS",0)
  !Range(LastSeenBy(Myself),8)
  !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()
  Global("MORPH","LOCALS",0)
  !HasItemSlot(Myself,SLOT_MISC0)
  !HasItemSlot(Myself,SLOT_MISC1)
  !HasItemSlot(Myself,SLOT_MISC2)
THEN
  RESPONSE #100
    EquipMostDamagingMelee()
    AttackOneRound(LastSeenBy(Myself))
END

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

