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
  AttackedBy([GOODCUTOFF],DEFAULT)
  !Allegiance(Myself,ENEMY)
  !Allegiance(Myself,PC)
THEN
  RESPONSE #100
    Enemy()
    Shout(151)
END

IF
  HitBy([GOODCUTOFF],CRUSHING)
  !Allegiance(Myself,GOODCUTOFF)
  !Allegiance(Myself,ENEMY)
THEN
  RESPONSE #100
    Shout(151)
    Enemy()
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
  TargetUnreachable(LastSeenBy(Myself))
  Delay(3)
THEN
  RESPONSE #100
    ClearActions(Myself)
    Continue()
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
  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("TURN","LOCALS",1)
  GlobalTimerNotExpired("BPTurn","LOCALS")
  HPPercentGT(Myself,50)
  See([GOODCUTOFF.UNDEAD])
THEN
  RESPONSE #10
    SetGlobal("TURN","LOCALS",0)
    SetGlobalTimer("BPTurn","LOCALS",0)
    ClearActions(Myself)
    SmallWait(5)
    Continue()
  RESPONSE #90
END

IF
  HaveSpell(PALADIN_LAY_ON_HANDS)
  !GlobalTimerNotExpired("BPT","LOCALS")
  HPPercentLT(Myself,50)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,PALADIN_LAY_ON_HANDS)
END

IF
  HaveSpell(INNATE_LAY_ON_HANDS)
  !GlobalTimerNotExpired("BPT","LOCALS")
  HPPercentLT(Myself,50)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,INNATE_LAY_ON_HANDS)
END

IF
  HasItem("potn55",Myself)  // ~Potion of Superior Healing~
  !GlobalTimerNotExpired("POT","LOCALS")
  HPPercentLT(Myself,55)
THEN
  RESPONSE #100
    DisplayStringHead(Myself,46150)  // ~quaffs a potion~
    SetGlobalTimer("POT","LOCALS",ONE_ROUND)
    UseItem("potn55",Myself)  // ~Potion of Superior Healing~
END

IF
  HasItem("potn52",Myself)  // ~Potion of Extra Healing~
  !GlobalTimerNotExpired("POT","LOCALS")
  HPPercentLT(Myself,60)
THEN
  RESPONSE #100
    DisplayStringHead(Myself,46150)  // ~quaffs a potion~
    SetGlobalTimer("POT","LOCALS",ONE_ROUND)
    UseItem("potn52",Myself)  // ~Potion of Extra Healing~
END

IF
  HPPercentLT(Myself,65)
  HaveSpell(CLERIC_CURE_SERIOUS_WOUNDS)
  !GlobalTimerNotExpired("BPT","LOCALS")
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_CURE_SERIOUS_WOUNDS)
END

IF
  HPPercentLT(Myself,70)
  HaveSpell(CLERIC_CURE_MEDIUM_WOUNDS)
  !GlobalTimerNotExpired("BPT","LOCALS")
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_CURE_MEDIUM_WOUNDS)
END

IF
  HasItem("POTN08",Myself)  // ~Potion of Healing~
  !GlobalTimerNotExpired("POT","LOCALS")
  RandomNumLT(201,41)
  HPPercentLT(Myself,85)
THEN
  RESPONSE #100
    SetGlobalTimer("POT","LOCALS",ONE_ROUND)
    UseItem("POTN08",Myself)  // ~Potion of Healing~
    DisplayStringHead(Myself,46150)  // ~quaffs a potion~
END

IF
  HPPercentLT(Myself,85)
  HaveSpell(CLERIC_CURE_LIGHT_WOUNDS)
  !GlobalTimerNotExpired("BPT","LOCALS")
  RandomNumLT(202,41)
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)  // ~Potion of Superior Healing~
  !HasItem("POTN52",Myself)  // ~Potion of Extra Healing~
  !HaveSpell(CLERIC_CURE_SERIOUS_WOUNDS)
  !HaveSpell(CLERIC_CURE_MEDIUM_WOUNDS)
  !HaveSpell(PALADIN_LAY_ON_HANDS)
  !HaveSpell(INNATE_LAY_ON_HANDS)
THEN
  RESPONSE #100
    SetGlobalTimer("BPW","LOCALS",ONE_ROUND)
    DisplayStringHead(Myself,72808)  // ~I need healing!~
    Shout(123)
END

IF
  StateCheck(Myself,STATE_POISONED)
  HaveSpell(CLERIC_SLOW_POISON)
  !GlobalTimerNotExpired("BPT","LOCALS")
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_SLOW_POISON)
END

IF
  StateCheck(Myself,STATE_POISONED)
  HasItem("potn17",Myself)  // ~Elixir of Health~
  !GlobalTimerNotExpired("POT","LOCALS")
THEN
  RESPONSE #100
    SetGlobalTimer("POT","LOCALS",ONE_ROUND)
    DisplayStringHead(Myself,46150)  // ~quaffs a potion~
    UseItem("potn17",Myself)  // ~Elixir of Health~
END

IF
  StateCheck(Myself,STATE_POISONED)
  HasItem("potn20",Myself)  // ~Antidote~
  !GlobalTimerNotExpired("POT","LOCALS")
THEN
  RESPONSE #100
    SetGlobalTimer("POT","LOCALS",ONE_ROUND)
    DisplayStringHead(Myself,46150)  // ~quaffs a potion~
    UseItem("potn20",Myself)  // ~Antidote~
END

IF
  ActionListEmpty()
  StateCheck(Myself,STATE_POISONED)
  !GlobalTimerNotExpired("POIS","LOCALS")
  See([EVILCUTOFF])
  !HasItem("POTN17",Myself)  // ~Elixir of Health~
  !HasItem("POTN20",Myself)  // ~Antidote~
  !HaveSpell(CLERIC_SLOW_POISON)
THEN
  RESPONSE #100
    Shout(83)
    DisplayStringHead(Myself,@0)
    SetGlobalTimer("POIS","LOCALS",ONE_ROUND)
END

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

IF
  ActionListEmpty()
  HaveSpell(INQUIS_TRUE_SIGHT)
  CheckStat(Myself,0,118)
  !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,@1)
    Spell(Myself,INQUIS_TRUE_SIGHT)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_FREE_ACTION)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("SNAFU","LOCALS",0)
  CheckStat(Myself,0,131)
  OR(4)
    RandomNumLT(3,3)
    StateCheck(Myself,STATE_HELPLESS)
    !CheckStat(Myself,0,WEB)
    !CheckStat(Myself,0,ENTANGLE)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_FREE_ACTION)
END

IF
  ActionListEmpty()
  HaveSpell(WARRIOR_RESIST_MAGIC)
  CheckStatLT(Myself,50,RESISTMAGIC)
  !GlobalTimerNotExpired("BPT","LOCALS")
  RandomNumLT(6,5)
  OR(5)
    See([GOODCUTOFF.0.0.CLERIC_ALL])
    See([GOODCUTOFF.0.0.BARD_ALL])
    See([GOODCUTOFF.0.0.DRUID_ALL])
    See([GOODCUTOFF.0.0.LONG_BOW])
    See([GOODCUTOFF.0.0.SORCERER])
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,WARRIOR_RESIST_MAGIC)
END

IF
  ActionListEmpty()
  HaveSpell(WARRIOR_WAR_CRY)
  !GlobalTimerNotExpired("BPT","LOCALS")
  RandomNum(2,1)
  Range(SecondNearestEnemyOf(Myself),10)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    DisplayStringHead(Myself,33783)  // ~RRRAAAUUGH!!~
    Spell(Myself,WARRIOR_WAR_CRY)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_DEFENSIVE_HARMONY)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("SNAFU","LOCALS",0)
  RandomNumLT(4,4)
  CheckStat(Myself,0,133)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_DEFENSIVE_HARMONY)
END

IF
  ActionListEmpty()
  HaveSpell(WARRIOR_HARDINESS)
  !GlobalTimerNotExpired("BPT","LOCALS")
  !GlobalTimerNotExpired("HARD","LOCALS")
  RandomNumLT(5,4)
  !CombatCounter(0)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    DisplayStringHead(Myself,63953)  // ~Hardiness~
    Spell(Myself,WARRIOR_HARDINESS)
    SetGlobalTimer("HARD","LOCALS",ONE_TURN)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_HOLY_POWER)
  !GlobalTimerNotExpired("BPT","LOCALS")
  RandomNumLT(8,6)
  CheckStatLT(Myself,19,STR)
  CheckStatLT(Myself,3,SCRIPTINGSTATE6)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_HOLY_POWER)
END

IF
  ActionListEmpty()
  HasItem("POTN14",Myself)  // ~Oil of Speed~
  !GlobalTimerNotExpired("BPT","LOCALS")
  RandomNumLT(15,11)
  !StateCheck(Myself,STATE_HASTED)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    UseItem("POTN14",Myself)  // ~Oil of Speed~
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_DRAW_UPON_HOLY_MIGHT)
  !GlobalTimerNotExpired("BPT","LOCALS")
  RandomNumLT(9,6)
  CheckStatLT(Myself,4,SCRIPTINGSTATE6)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_DRAW_UPON_HOLY_MIGHT)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_RESIST_FIRE)
  !GlobalTimerNotExpired("BPT","LOCALS")
  OR(5)
    HitBy([ANYONE],MAGICFIRE)
    HitBy([ANYONE],MAGICCOLD)
    HitBy([ANYONE],FIRE)
    HitBy([ANYONE],COLD)
    RandomNumLT(12,8)
  OR(3)
    CheckStatLT(Myself,40,RESISTMAGICFIRE)
    CheckStatLT(Myself,40,RESISTMAGICCOLD)
    RandomNumLT(10,7)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_RESIST_FIRE)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_BLESS)
  !GlobalTimerNotExpired("BPT","LOCALS")
  RandomNumLT(11,7)
  !StateCheck(Myself,STATE_BLESS)
  !StateCheck(Myself,STATE_CHANT)
  See([EVILCUTOFF])
  Range(LastSeenBy(Myself),12)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_BLESS)
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
  ActionListEmpty()
  HaveSpell(INQUIS_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),INQUIS_DISPEL_MAGIC)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_REMOVE_FEAR)
  !GlobalTimerNotExpired("BPT","LOCALS")
  See([EVILCUTOFF])
  StateCheck(LastSeenBy(Myself),STATE_PANIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),0)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_REMOVE_FEAR)
END

IF
  ActionListEmpty()
  HaveSpell(PALADIN_REMOVE_FEAR)
  !GlobalTimerNotExpired("BPT","LOCALS")
  See([EVILCUTOFF])
  StateCheck(LastSeenBy(Myself),STATE_PANIC)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),0)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),PALADIN_REMOVE_FEAR)
END

IF
  ActionListEmpty()
  HaveSpell(PALADIN_PROTECTION_FROM_EVIL)
  !GlobalTimerNotExpired("BPT","LOCALS")
  RandomNumLT(13,9)
  CheckStat(Myself,0,117)
  Detect([GOODCUTOFF.0.0.0.0.0.MASK_EVIL])
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,PALADIN_PROTECTION_FROM_EVIL)
END

IF
  ActionListEmpty()
  HaveSpell(INNATE_PROTECTION_FROM_EVIL)
  !GlobalTimerNotExpired("BPT","LOCALS")
  RandomNumLT(13,9)
  CheckStat(Myself,0,117)
  Detect([GOODCUTOFF.0.0.0.0.0.MASK_EVIL])
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,INNATE_PROTECTION_FROM_EVIL)
END

IF
  ActionListEmpty()
  HitBy([GOODCUTOFF],CRUSHING)
  !GlobalTimerNotExpired("RANG","LOCALS")
  !StateCheck(Myself,STATE_POISONED)
  CheckStatGT(Myself,7,INT)
  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,@2)
    SetGlobalTimer("RANG","LOCALS",ONE_ROUND)
  RESPONSE #50
    DisplayStringHead(Myself,@3)
    SetGlobalTimer("RANG","LOCALS",ONE_ROUND)
  RESPONSE #25
    DisplayStringHead(Myself,@4)
    SetGlobalTimer("RANG","LOCALS",ONE_ROUND)
  RESPONSE #25
    DisplayStringHead(Myself,@5)
    SetGlobalTimer("RANG","LOCALS",ONE_ROUND)
  RESPONSE #60
    DisplayStringHead(Myself,@5)
    SetGlobalTimer("RANG","LOCALS",ONE_ROUND)
    MoveToObject(LastSeenBy(Myself))
    AttackReevaluate(LastSeenBy(Myself),180)
END

IF
  ActionListEmpty()
  HaveSpell(INNATE_LAY_ON_HANDS)
  OR(3)
    Heard(ThirdNearest([EVILCUTOFF]),123)
    Heard(SecondNearest([EVILCUTOFF]),123)
    Heard([EVILCUTOFF],123)
  !GlobalTimerNotExpired("BPT","LOCALS")
  HPGT(LastHeardBy(Myself),0)
  HPPercentGT(Myself,75)
  Range(LastHeardBy(Myself),10)
  !Range([EVILCUTOFF.0.0.CLERIC_ALL],10)
  !HasItem("POTN55",LastHeardBy(Myself))  // ~Potion of Superior Healing~
  !HasItem("POTN52",LastHeardBy(Myself))  // ~Potion of Extra Healing~
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastHeardBy(Myself),INNATE_LAY_ON_HANDS)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_SLOW_POISON)
  OR(3)
    Heard(ThirdNearest([EVILCUTOFF]),83)
    Heard(SecondNearest([EVILCUTOFF]),83)
    Heard([EVILCUTOFF],83)
  Range(LastHeardBy(Myself),10)
  !GlobalTimerNotExpired("BPT","LOCALS")
  !StateCheck(Myself,STATE_POISONED)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastHeardBy(Myself),CLERIC_SLOW_POISON)
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
  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)
  False()
THEN
  RESPONSE #100
    Continue()
END

IF
  RandomNumLT(32,25)
  OR(3)
    Heard(ThirdNearestMyGroupOfType([EVILCUTOFF]),124)
    Heard(SecondNearestMyGroupOfType([EVILCUTOFF]),124)
    Heard(NearestMyGroupOfType([EVILCUTOFF]),124)
  HPGT(LastHeardBy(Myself),1)
  Range(LastHeardBy(Myself),20)
  Exists(LastAttackerOf(LastHeardBy(Myself)))
  !Allegiance(LastAttackerOf(LastHeardBy(Myself)),EVILCUTOFF)
  !StateCheck(LastAttackerOf(LastHeardBy(Myself)),STATE_CHARMED)
  OR(3)
    !Race(LastAttackerOf(LastHeardBy(Myself)),MORNINGSTAR)
    !Class(LastAttackerOf(LastHeardBy(Myself)),FAIRY_NYMPH)
    !Specifics(LastAttackerOf(LastHeardBy(Myself)),65)
  OR(3)  
    !StateCheck(LastAttackerOf(LastHeardBy(Myself)),0x00400010)
    CheckStatGT(Myself,0,SEEINVISIBLE)
    CheckStatGT(Myself,0,118)
  See(LastAttackerOf(LastHeardBy(Myself)))
  False()
THEN
  RESPONSE #100
    Continue()
END

IF
  RandomNumLT(33,13)
  HitBy([0],0x0000)
  !Allegiance(LastHitter(Myself),EVILCUTOFF)
  !StateCheck(LastHitter(Myself),STATE_CHARMED)
  OR(3)
    !Race(LastHitter(Myself),MORNINGSTAR)
    !Class(LastHitter(Myself),FAIRY_NYMPH)
    !Specifics(LastHitter(Myself),65)
  OR(3)  
    !StateCheck(LastHitter(Myself),0x00400010)
    CheckStatGT(Myself,0,SEEINVISIBLE)
    CheckStatGT(Myself,0,118)
  False()
THEN
  RESPONSE #100
    Continue()
END

IF
  RandomNumGT(33,22)
  AttackedBy([0],DEFAULT)
  !Allegiance(LastAttackerOf(Myself),EVILCUTOFF)
  !StateCheck(LastAttackerOf(Myself),STATE_CHARMED)
  OR(3)
    !Race(LastAttackerOf(Myself),MORNINGSTAR)
    !Class(LastAttackerOf(Myself),FAIRY_NYMPH)
    !Specifics(LastAttackerOf(Myself),65)
  OR(3)  
    !StateCheck(LastAttackerOf(Myself),0x00400010)
    CheckStatGT(Myself,0,SEEINVISIBLE)
    CheckStatGT(Myself,0,118)
  See(LastAttackerOf(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()
  CheckStatGT(Myself,0,SCRIPTINGSTATE4)
THEN
  RESPONSE #100
    EquipMostDamagingMelee()
    AttackOneRound(LastSeenBy(Myself))
END

IF
  OR(3)
    CheckStatGT(Myself,0,SANCTUARY)
    StateCheck(Myself,STATE_IMPROVEDINVISIBILITY)
    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(WARRIOR_SMITE)
  !GlobalTimerNotExpired("BPT","LOCALS")
  RandomNumLT(6,5)
  CheckStat(LastSeenBy(Myself),0,128)
  CheckStat(Myself,0,SCRIPTINGSTATE4)
  Range(LastSeenBy(Myself),7)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    DisplayStringHead(Myself,65598)  // ~Smite~
    Spell(Myself,WARRIOR_SMITE)
    EquipMostDamagingMelee()
    AttackReevaluate(LastSeenBy(Myself),45)
END

IF
  ActionListEmpty()
  HaveSpell(WARRIOR_GREATER_WHIRLWIND)
  !GlobalTimerNotExpired("BPT","LOCALS")
  RandomNumLT(66,40)
  CheckStat(LastSeenBy(Myself),0,128)
  CheckStat(Myself,0,SCRIPTINGSTATE4)
  Range(LastSeenBy(Myself),8)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    DisplayStringHead(Myself,63904)  // ~Greater Whirlwind Attack~
    Spell(Myself,WARRIOR_GREATER_WHIRLWIND)
    EquipMostDamagingMelee()
    AttackReevaluate(LastSeenBy(Myself),45)
END

IF
  ActionListEmpty()
  HaveSpell(WARRIOR_CRITICAL_STRIKE)
  !GlobalTimerNotExpired("BPT","LOCALS")
  RandomNumLT(68,38)
  Range(LastSeenBy(Myself),8)
  CheckStat(LastSeenBy(Myself),0,128)
  CheckStat(Myself,0,SCRIPTINGSTATE4)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    DisplayStringHead(Myself,65434)  // ~Critical Strike~
    Spell(Myself,WARRIOR_CRITICAL_STRIKE)
    EquipMostDamagingMelee()
    AttackReevaluate(LastSeenBy(Myself),45)
END

IF
  ActionListEmpty()
  HaveSpell(WARRIOR_GREATER_DEATHBLOW)
  !GlobalTimerNotExpired("BPT","LOCALS")
  RandomNumLT(67,36)
  CheckStat(LastSeenBy(Myself),0,128)
  CheckStat(Myself,0,SCRIPTINGSTATE4)
  CheckStatLT(LastSeenBy(Myself),13,LEVEL)
  Range(LastSeenBy(Myself),8)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    DisplayStringHead(Myself,63938)  // ~Greater Deathblow~
    Spell(Myself,WARRIOR_GREATER_DEATHBLOW)
    EquipMostDamagingMelee()
    AttackReevaluate(LastSeenBy(Myself),45)
END

IF
  ActionListEmpty()
  HaveSpell(WARRIOR_WHIRLWIND)
  !GlobalTimerNotExpired("BPT","LOCALS")
  RandomNumLT(72,32)
  CheckStat(LastSeenBy(Myself),0,128)
  CheckStat(Myself,0,SCRIPTINGSTATE4)
  Range(LastSeenBy(Myself),8)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    DisplayStringHead(Myself,63904)  // ~Greater Whirlwind Attack~
    Spell(Myself,WARRIOR_WHIRLWIND)
    EquipMostDamagingMelee()
    AttackReevaluate(LastSeenBy(Myself),45)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_HOLY_SMITE)
  !GlobalTimerNotExpired("BPT","LOCALS")
  RandomNumLT(38,25)
  Alignment(LastSeenBy(Myself),MASK_EVIL)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_HOLY_SMITE)
END

IF
  ActionListEmpty()
  General(LastSeenBy(Myself),UNDEAD)
  !GlobalTimerNotExpired("BPTurn","LOCALS")
  Global("TURN","LOCALS",0)
  Range(LastSeenBy(Myself),15)
  HPPercentGT(Myself,50)
  !Range([EVILCUTOFF.UNDEAD],15)
THEN
  RESPONSE #100
    SetGlobalTimer("BPTurn","LOCALS",ONE_ROUND)
    SetGlobal("TURN","LOCALS",1)
    DisplayStringHead(Myself,4974)  // ~Turn Undead~
    Turn()
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_DISPEL_MAGIC)
  !GlobalTimerNotExpired("BPT","LOCALS")
  RandomNumLT(48,31)
  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)
THEN
  RESPONSE #100
    SetGlobal("BPT","LOCALS",6)
    Spell(NearestEnemyOf(Myself),CLERIC_DISPEL_MAGIC)
END

IF
  ActionListEmpty()
  HaveSpell(INQUIS_DISPEL_MAGIC)
  !GlobalTimerNotExpired("BPT","LOCALS")
  RandomNumLT(48,31)
  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)
THEN
  RESPONSE #100
    SetGlobal("BPT","LOCALS",6)
    Spell(NearestEnemyOf(Myself),INQUIS_DISPEL_MAGIC)
END

IF
  ActionListEmpty()
  HaveSpell(WARRIOR_DEATHBLOW)
  !GlobalTimerNotExpired("BPT","LOCALS")
  RandomNumLT(75,26)
  CheckStat(LastSeenBy(Myself),0,128)
  CheckStat(Myself,0,SCRIPTINGSTATE4)
  CheckStatLT(LastSeenBy(Myself),9,LEVEL)
  Range(LastSeenBy(Myself),8)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    DisplayStringHead(Myself,63922)  // ~Deathblow~
    Spell(Myself,WARRIOR_DEATHBLOW)
    EquipMostDamagingMelee()
    AttackReevaluate(LastSeenBy(Myself),45)
END

IF
  ActionListEmpty()
  HaveSpell(WARRIOR_POWER_ATTACK)
  !GlobalTimerNotExpired("BPT","LOCALS")
  RandomNumLT(76,20)
  CheckStat(LastSeenBy(Myself),0,128)
  CheckStat(Myself,0,SCRIPTINGSTATE4)
  Range(LastSeenBy(Myself),8)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    DisplayStringHead(Myself,63941)  // ~Power Attack~
    Spell(Myself,WARRIOR_POWER_ATTACK)
    EquipMostDamagingMelee()
    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)  // ~No more~
    Shout(124)
    SetGlobalTimer("BPW","LOCALS",10)
    RunAwayFrom(LastHitter(Myself),40)
  RESPONSE #30
    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()
  CheckStatGT(LastSeenBy(Myself),10,180)
  CheckStatLT(Myself,11,180)
THEN
  RESPONSE #30
    EquipRanged()
    AttackOneRound(LastSeenBy(Myself))
  RESPONSE #40
    EquipRanged()
    AttackOneRound(LastSeenBy(Myself))
    AttackOneRound(LastSeenBy(Myself))
  RESPONSE #30
    EquipRanged()
    AttackOneRound(LastSeenBy(Myself))
    AttackOneRound(LastSeenBy(Myself))
    AttackOneRound(LastSeenBy(Myself))
END

IF
  ActionListEmpty()
  OR(3)
    !Range(NearestEnemyOf(Myself),5)
    CheckStatGT(NearestEnemyOf(Myself),0,121)
    CheckStatGT(LastSeenBy(Myself),0,125)
THEN
  RESPONSE #30
    EquipRanged()
    AttackOneRound(LastSeenBy(Myself))
  RESPONSE #40
    EquipRanged()
    AttackOneRound(LastSeenBy(Myself))
    AttackOneRound(LastSeenBy(Myself))
  RESPONSE #30
    EquipRanged()
    AttackOneRound(LastSeenBy(Myself))
    AttackOneRound(LastSeenBy(Myself))
    AttackOneRound(LastSeenBy(Myself))
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),10)
THEN
  RESPONSE #16
    EquipMostDamagingMelee()
    AttackOneRound(NearestEnemyOf(Myself))
  RESPONSE #16
    EquipMostDamagingMelee()
    AttackOneRound(NearestEnemyOf(Myself))
    AttackOneRound(NearestEnemyOf(Myself))
  RESPONSE #16
    EquipMostDamagingMelee()
    AttackOneRound(NearestEnemyOf(Myself))
    AttackOneRound(NearestEnemyOf(Myself))
    AttackOneRound(NearestEnemyOf(Myself))
  RESPONSE #26
    EquipMostDamagingMelee()
    MoveToObjectNoInterrupt(LastSeenBy(Myself))
    AttackReevaluate(LastSeenBy(Myself),135)
  RESPONSE #26
    EquipMostDamagingMelee()
    MoveToObjectNoInterrupt(LastSeenBy(Myself))
    AttackReevaluate(LastSeenBy(Myself),270)
END

IF
  ActionListEmpty()
THEN
  RESPONSE #30
    EquipMostDamagingMelee()
    AttackOneRound(LastSeenBy(Myself))
  RESPONSE #40
    EquipMostDamagingMelee()
    AttackOneRound(LastSeenBy(Myself))
    AttackOneRound(LastSeenBy(Myself))
  RESPONSE #30
    EquipMostDamagingMelee()
    AttackOneRound(LastSeenBy(Myself))
    AttackOneRound(LastSeenBy(Myself))
    AttackOneRound(LastSeenBy(Myself))
END

