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

IF
  !Allegiance(Myself,ENEMY)
  !Allegiance(Myself,GOODCUTOFF)
  OR(2)
    HitBy([GOODCUTOFF],CRUSHING)
    Allegiance(LastHitter(Myself),GOODCUTOFF)
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
  !Allegiance(Myself,EVILCUTOFF)
THEN
  RESPONSE #100
END

IF
  TargetUnreachable([GOODCUTOFF])
  !See([GOODCUTOFF])
THEN
  RESPONSE #100
END

IF
  !ActionListEmpty()
  StateCheck(Myself,0x400010)
  !See([GOODCUTOFF])
  Delay(10)
THEN
  RESPONSE #100
    ClearActions(Myself)
    Continue()
END


IF
  !GlobalTimerNotExpired("BPTS","LOCALS")
  Global("BPWatch1","LOCALS",1)
THEN
  RESPONSE #100
    SetGlobal("BPWatch1","LOCALS",0)
    SmallWait(6)
    ClearActions(Myself)
    Continue()
END

IF
  !GlobalTimerNotExpired("BPRW","LOCALS")
  Global("BPWatch","LOCALS",1)
THEN
  RESPONSE #100
    SetGlobal("BPWatch","LOCALS",0)
    SmallWait(6)
END

IF
  ActionListEmpty()
  !GlobalTimerNotExpired("BPT","LOCALS")
  RandomNumLT(10,6)
  !Detect([GOODCUTOFF])
  !StateCheck(Myself,0x400010)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Hide()
END

IF
  ActionListEmpty()
  HaveSpell(NPC_SET_BOMB_TRAP)
  !GlobalTimerNotExpired("BPTS","LOCALS")
  RandomNumLT(12,7)
  !AreaType(OUTDOOR)
  !Detect([GOODCUTOFF])
  CheckStatGT(Myself,34,SETTRAPS)
THEN
  RESPONSE #50
    SetGlobal("BPWatch1","LOCALS",1)
    SetGlobalTimer("BPTS","LOCALS",ONE_ROUND)
    CreateCreatureObjectOffset("SNARE4",Myself,[-5.-5])
    RemoveSpell(NPC_SET_BOMB_TRAP)
    RandomWalkContinuous()
  RESPONSE #50
    RemoveSpell(NPC_SET_BOMB_TRAP)
    SetGlobal("BPWatch1","LOCALS",1)
    SetGlobalTimer("BPTS","LOCALS",4)
    RandomWalkContinuous()
END

IF
  ActionListEmpty()
  HaveSpell(NPC_SET_TIME_TRAP)
  !GlobalTimerNotExpired("BPTS","LOCALS")
  RandomNumLT(14,8)
  !AreaType(OUTDOOR)
  !Detect([GOODCUTOFF])
  CheckStatGT(Myself,34,SETTRAPS)
THEN
  RESPONSE #50
    SetGlobal("BPWatch1","LOCALS",1)
    SetGlobalTimer("BPTS","LOCALS",ONE_ROUND)
    ApplySpell(Myself,NPC_SET_TIME_TRAP)
    SmallWait(10)
    RemoveSpell(NPC_SET_TIME_TRAP)
    RandomWalkContinuous()
  RESPONSE #50
    RemoveSpell(NPC_SET_TIME_TRAP)
    SetGlobal("BPWatch1","LOCALS",1)
    SetGlobalTimer("BPTS","LOCALS",4)
    RandomWalkContinuous()
END

IF
  ActionListEmpty()
  HaveSpell(NPC_SET_SPIKE_TRAP)
  !GlobalTimerNotExpired("BPTS","LOCALS")
  RandomNumLT(10,6)
  !AreaType(OUTDOOR)
  !Detect([GOODCUTOFF])
  CheckStatGT(Myself,24,SETTRAPS)
THEN
  RESPONSE #40
    SetGlobal("BPWatch1","LOCALS",1)
    SetGlobalTimer("BPTS","LOCALS",ONE_ROUND)
    CreateCreatureObjectOffset("SNARE3",Myself,[-5.-5])
    RemoveSpell(NPC_SET_SPIKE_TRAP)
    RandomWalkContinuous()
  RESPONSE #60
    RemoveSpell(NPC_SET_SPIKE_TRAP)
    SetGlobal("BPWatch1","LOCALS",1)
    SetGlobalTimer("BPTS","LOCALS",4)
    RandomWalkContinuous()
END

IF
  ActionListEmpty()
  HaveSpell(NPC_SET_SNARE)
  !GlobalTimerNotExpired("BPTS","LOCALS")
  RandomNumLT(8,5)
  !Detect([GOODCUTOFF])
  !AreaType(OUTDOOR)
  LevelLT(Myself,21)
  CheckStatGT(Myself,24,SETTRAPS)
THEN
  RESPONSE #30
    SetGlobal("BPWatch1","LOCALS",1)
    SetGlobalTimer("BPTS","LOCALS",ONE_ROUND)
    CreateCreatureObjectOffset("SNARE1B",Myself,[-5.-5])
    RemoveSpell(NPC_SET_SNARE)
    RandomWalkContinuous()
  RESPONSE #70
    RemoveSpell(NPC_SET_SNARE)
    SetGlobal("BPWatch1","LOCALS",1)
    SetGlobalTimer("BPTS","LOCALS",4)
    RandomWalkContinuous()
END

IF
  ActionListEmpty()
  HaveSpell(NPC_SET_SNARE)
  !GlobalTimerNotExpired("BPTS","LOCALS")
  RandomNumLT(8,5)
  !Detect([GOODCUTOFF])
  !AreaType(OUTDOOR)
  LevelGT(Myself,20)
  CheckStatGT(Myself,34,SETTRAPS)
THEN
  RESPONSE #40
    SetGlobalTimer("BPTS","LOCALS",ONE_ROUND)
    SetGlobal("BPWatch1","LOCALS",1)
    CreateCreatureObjectOffset("SNARE1C",Myself,[-5.-5])
    RemoveSpell(NPC_SET_SNARE)
    RandomWalkContinuous()
  RESPONSE #60
    RemoveSpell(NPC_SET_SNARE)
    SetGlobal("BPWatch1","LOCALS",1)
    SetGlobalTimer("BPTS","LOCALS",4)
    RandomWalkContinuous()
END

IF
  StateCheck(Myself,0x400010)
  !GlobalTimerNotExpired("BPRW","LOCALS")
  !Detect([GOODCUTOFF])
  !AreaType(OUTDOOR)
THEN
  RESPONSE #100
    SetGlobal("BPWatch","LOCALS",1)
    SetGlobalTimer("BPRW","LOCALS",3)
    RandomWalkContinuous()
END

IF
  CheckStatGT(Myself,24,DETECTILLUSIONS)
  CheckStatLT(Myself,40,DETECTILLUSIONS)
  !GlobalTimerNotExpired("BPT","LOCALS")
  RandomNumLT(99,56)
  CheckStat(Myself,0,118)
  CheckStatLT(Myself,61,194)
  Exists(LastAttackerOf(Myself))
  OR(9)
    SpellCast([GOODCUTOFF],WIZARD_PROJECT_IMAGE)
    SpellCast([GOODCUTOFF],WIZARD_MISLEAD)
    StateCheck(NearestEnemyOfType([GOODCUTOFF]),0x60400010)
    StateCheck(SecondNearestEnemyOfType([GOODCUTOFF]),0x60400010)
    StateCheck(ThirdNearestEnemyOfType([GOODCUTOFF]),0x60400010)
    StateCheck(FourthNearestEnemyOfType([GOODCUTOFF]),0x60400010)
    StateCheck(FifthNearestEnemyOfType([GOODCUTOFF]),0x60400010)
    StateCheck(SixthNearestEnemyOfType([GOODCUTOFF]),0x60400010)
    NumCreatureGT([GOODCUTOFF.0.0.0.0.ILLUSIONARY],0)
THEN
  RESPONSE #35
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    DisplayStringHead(Myself,@0)
    DisplayString(Myself,31858)
    ReallyForceSpellRES("SPIN503",Myself)
  RESPONSE #65
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    DisplayStringHead(Myself,31859)
END

IF
  CheckStatGT(Myself,39,DETECTILLUSIONS)
  CheckStatLT(Myself,60,DETECTILLUSIONS)
  !GlobalTimerNotExpired("BPT","LOCALS")
  RandomNumLT(99,56)
  CheckStat(Myself,0,118)
  CheckStatLT(Myself,61,194)
  Exists(LastAttackerOf(Myself))
  OR(9)
    SpellCast([GOODCUTOFF],WIZARD_PROJECT_IMAGE)
    SpellCast([GOODCUTOFF],WIZARD_MISLEAD)
    StateCheck(NearestEnemyOfType([GOODCUTOFF]),0x60400010)
    StateCheck(SecondNearestEnemyOfType([GOODCUTOFF]),0x60400010)
    StateCheck(ThirdNearestEnemyOfType([GOODCUTOFF]),0x60400010)
    StateCheck(FourthNearestEnemyOfType([GOODCUTOFF]),0x60400010)
    StateCheck(FifthNearestEnemyOfType([GOODCUTOFF]),0x60400010)
    StateCheck(SixthNearestEnemyOfType([GOODCUTOFF]),0x60400010)
    NumCreatureGT([GOODCUTOFF.0.0.0.0.ILLUSIONARY],0)
THEN
  RESPONSE #50
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    DisplayStringHead(Myself,@0)
    DisplayString(Myself,31858)
    ReallyForceSpellRES("SPIN503",Myself)
  RESPONSE #50
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    DisplayStringHead(Myself,31859)
END

IF
  CheckStatGT(Myself,59,DETECTILLUSIONS)
  !GlobalTimerNotExpired("BPT","LOCALS")
  RandomNumLT(99,56)
  CheckStat(Myself,0,118)
  CheckStatLT(Myself,61,194)
  Exists(LastAttackerOf(Myself))
  OR(9)
    SpellCast([GOODCUTOFF],WIZARD_PROJECT_IMAGE)
    SpellCast([GOODCUTOFF],WIZARD_MISLEAD)
    StateCheck(NearestEnemyOfType([GOODCUTOFF]),0x60400010)
    StateCheck(SecondNearestEnemyOfType([GOODCUTOFF]),0x60400010)
    StateCheck(ThirdNearestEnemyOfType([GOODCUTOFF]),0x60400010)
    StateCheck(FourthNearestEnemyOfType([GOODCUTOFF]),0x60400010)
    StateCheck(FifthNearestEnemyOfType([GOODCUTOFF]),0x60400010)
    StateCheck(SixthNearestEnemyOfType([GOODCUTOFF]),0x60400010)
    NumCreatureGT([GOODCUTOFF.0.0.0.0.ILLUSIONARY],0)
THEN
  RESPONSE #70
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    DisplayStringHead(Myself,@0)
    DisplayString(Myself,31858)
    ReallyForceSpellRES("SPIN503",Myself)
  RESPONSE #30
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    DisplayStringHead(Myself,31859)
END

IF
  !Detect([GOODCUTOFF])
THEN
  RESPONSE #100
END

IF
  TargetUnreachable(LastSeenBy(Myself))
  Delay(3)
THEN
  RESPONSE #100
    ClearActions(Myself)
    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
  HasItem("potn52",Myself)
  !GlobalTimerNotExpired("BPT","LOCALS")
  HPPercentLT(Myself,70)
THEN
  RESPONSE #100
    DisplayStringHead(Myself,46150)
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    UseItem("potn52",Myself)
END

IF
  HasItem("potn55",Myself)
  !GlobalTimerNotExpired("BPT","LOCALS")
  HPPercentLT(Myself,60)
THEN
  RESPONSE #100
    DisplayStringHead(Myself,46150)
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    UseItem("potn55",Myself)
END

IF
  ActionListEmpty()
  See([EVILCUTOFF])
  HPPercentLT(Myself,35)
  !GlobalTimerNotExpired("BPW","LOCALS")
  !HasItem("POTN52",Myself)
  !HasItem("POTN55",Myself)
THEN
  RESPONSE #30
    SetGlobalTimer("BPW","LOCALS",ONE_ROUND)
    DisplayStringHead(Myself,72808)
    Shout(123)
  RESPONSE #70
    Continue()
END

IF
  HasItem("POTN17",Myself)
  StateCheck(Myself,STATE_POISONED)
  !GlobalTimerNotExpired("POT","LOCALS")
THEN
  RESPONSE #100
    SetGlobalTimer("POT","LOCALS",ONE_ROUND)
    UseItem("POTN17",Myself)
END

IF
  HasItem("POTN20",Myself)
  StateCheck(Myself,STATE_POISONED)
  !GlobalTimerNotExpired("POT","LOCALS")
THEN
  RESPONSE #100
    SetGlobalTimer("POT","LOCALS",ONE_ROUND)
    UseItem("POTN20",Myself)
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,@1)
    SetGlobalTimer("POIS","LOCALS",ONE_ROUND)
END

IF
  ActionListEmpty()
  HaveSpell(ROGUE_GREATER_EVASION)
  !GlobalTimerNotExpired("BPT","LOCALS")
  !GlobalTimerNotExpired("EVA","LOCALS")
  RandomNumLT(7,5)
  HPPercentLT(Myself,61)
  AttackedBy([ANYTHING],DEFAULT)
  Range(LastAttackerOf(Myself),4)
  HPGT(LastAttackerOf(Myself),39)
  CheckStatLT(Myself,76,194) // spell failure innate
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    DisplayStringHead(Myself,63993)
    Spell(Myself,ROGUE_GREATER_EVASION)
    SetGlobalTimer("EVA","LOCALS",FIVE_ROUNDS)
END

IF
  ActionListEmpty()
  HaveSpell(ROGUE_EVASION)
  !GlobalTimerNotExpired("BPT","LOCALS")
  !GlobalTimerNotExpired("EVA","LOCALS")
  RandomNumLT(8,5)
  HPPercentLT(Myself,76)
  AttackedBy([ANYTHING],DEFAULT)
  Range(LastAttackerOf(Myself),4)
  HPGT(LastAttackerOf(Myself),24)
  CheckStatLT(Myself,76,194) // spell failure innate
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    DisplayStringHead(Myself,63992)
    Spell(Myself,ROGUE_EVASION)
    SetGlobalTimer("EVA","LOCALS",THREE_ROUNDS)
END

IF
  ActionListEmpty()
  HaveSpell(ROGUE_AVOID_DEATH)
  HPPercentLT(Myself,41)
  !GlobalTimerNotExpired("DW","LOCALS")
  !GlobalTimerNotExpired("BPT","LOCALS")
  RandomNumLT(9,6)
  AttackedBy([ANYTHING],DEFAULT)
  Range(LastAttackerOf(Myself),4)
  HPGT(LastAttackerOf(Myself),35)
  CheckStatLT(Myself,76,194) // spell failure innate
  OR(4)
    CheckStat(Myself,0,157)
    Exists(NearestEnemyOfType([EVILCUTOFF.0.0.LONG_BOW]))
    Exists(NearestEnemyOfType([EVILCUTOFF.0.DEMONIC]))
    Exists(NearestEnemyOfType([EVILCUTOFF.0.0.FIGHTER_ALL]))
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    SetGlobalTimer("DW","LOCALS",FIVE_ROUNDS)
    DisplayStringHead(Myself,64001)
    Spell(Myself,ROGUE_AVOID_DEATH)
END

IF
  ActionListEmpty()
  HasItem("potn10",Myself)
  !GlobalTimerNotExpired("BPT","LOCALS")
  RandomNumLT(4,3)
  See(NearestEnemyOf(Myself))
  !StateCheck(Myself,0x400010)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    SetGlobalTimer("BPIP","LOCALS",15)
    DisplayStringHead(Myself,46150)
    UseItem("potn10",Myself)
END

IF
  ActionListEmpty()
  HasItem("FIGURE01",Myself)
  RandomNumLT(32,7)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("BP_Shakti","LOCALS",0)
THEN
  RESPONSE #100
    SetGlobal("BP_Shakti","LOCALS",1)
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    UseItem("FIGURE01",Myself)
END

IF
  ActionListEmpty()
  OR(2)
    Class(Myself,FIGHTER_THIEF)
    Class(Myself,FIGHTER_MAGE_THIEF)
  HitBy([GOODCUTOFF],CRUSHING)
  !GlobalTimerNotExpired("RANG","LOCALS")
  !StateCheck(Myself,STATE_POISONED)
  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",THREE_ROUNDS)
    EquipMostDamagingMelee()
    MoveToObject(LastSeenBy(Myself))
    AttackReevaluate(LastSeenBy(Myself),180)
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(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,18)
  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,12)
  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,8)
  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,10)
  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
  RandomNumLT(23,14)
  OR(3)
    See(NearestEnemyOfType([GOODCUTOFF.0.0.BARD_ALL]))
    See(NearestEnemyOfType([GOODCUTOFF.0.0.LONG_BOW]))
    See(NearestEnemyOfType([GOODCUTOFF.0.0.SORCERER]))
  RandomNumLT(24,11)
  OR(4)
    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]))
  RandomNumLT(25,10)
  OR(3)
    See(NearestEnemyOfType([GOODCUTOFF.0.0.MONK]))
    See(NearestEnemyOfType([GOODCUTOFF.0.0.THIEF_ALL]))
    See(NearestEnemyOfType([GOODCUTOFF.0.0.BARD_ALL]))
  RandomNumLT(21,7)
  OR(3)
    See(NearestEnemyOfType([GOODCUTOFF.0.0.FIGHTER_ALL]))
    See(NearestEnemyOfType([GOODCUTOFF.0.0.RANGER_ALL]))
    See(NearestEnemyOfType([GOODCUTOFF.0.0.PALADIN_ALL]))
  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)
  !Class(LastAttackerOf(LastHeardBy(Myself)),INNOCENT)
  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)
  See(LastHitter(Myself))
  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()
  StateCheck(Myself,0x00400010)
  Class(Myself,THIEF_ALL)
  HPPercentGT(Myself,25)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",12)
    EquipMostDamagingMelee()
    MoveToObject(LastSeenBy(Myself))
    FollowObjectFormation(LastSeenBy(Myself),1,3)
    SmallWait(5)
    AttackOneRound(LastSeenBy(Myself))
END

IF
  ActionListEmpty()
  HaveSpell(ASSASSIN_POISON)
  !GlobalTimerNotExpired("BPT","LOCALS")
  RandomNumLT(42,29)
  CheckStat(Myself,0,SCRIPTINGSTATE4)
  Range(LastSeenBy(Myself),4)
  !General(LastSeenBy(Myself),UNDEAD)
  !StateCheck(LastSeenBy(Myself),STATE_POISONED)
  HPGT(LastSeenBy(Myself),29)
  CheckStatGT(LastSeenBy(Myself),5,SAVEVSDEATH)
  CheckStatLT(LastSeenBy(Myself),51,RESISTPOISON)
  CheckStatLT(Myself,61,194)
  OR(2)
    CheckStat(LastSeenBy(Myself),0,128)
    CheckStat(Myself,0,109)
  OR(2)
    CheckStat(LastSeenBy(Myself),0,181)
    CheckStatGT(Myself,0,109)    
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,ASSASSIN_POISON)
    DisplayStringHead(Myself,52056)
    AttackReevaluate(LastSeenBy(Myself),45)
END

IF
  ActionListEmpty()
  HaveSpell(ROGUE_ASSASINATION)
  !GlobalTimerNotExpired("BPT","LOCALS")
  RandomNumLT(44,29)
  CheckStat(Myself,0,SCRIPTINGSTATE4)
  Range(LastSeenBy(Myself),4)
  HPGT(LastSeenBy(Myself),34)
  !General(LastSeenBy(Myself),UNDEAD)
  CheckStat(LastSeenBy(Myself),0,175) // Immunity to backstab
  CheckStatLT(Myself,61,194)
  OR(2)
    CheckStat(LastSeenBy(Myself),0,128)
    CheckStat(Myself,0,109)
  OR(2)
    CheckStat(LastSeenBy(Myself),0,181)
    CheckStatGT(Myself,0,109)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    DisplayStringHead(Myself,61779)
    Spell(Myself,ROGUE_ASSASINATION)
    AttackReevaluate(LastSeenBy(Myself),45)
END

IF
  ActionListEmpty()
  HPPercentLT(Myself,35)
  !GlobalTimerNotExpired("BPW","LOCALS")
  !Global("BP_PlotMan","LOCALS",1)
  Detect(NearestEnemyOf(Myself))
  !StateCheck(Myself,0x400010)
THEN
  RESPONSE #70
    SetGlobalTimer("BPW","LOCALS",ONE_ROUND)
    DisplayStringHead(Myself,@6)
    Shout(124)
    RunAwayFromNoInterrupt(NearestEnemyOf(Myself),90)
  RESPONSE #10
    SetGlobalTimer("BPW","LOCALS",9)
    DisplayStringHead(Myself,@7)
    Shout(124)
    EquipMostDamagingMelee()
    Attack(LastHitter(Myself))
  RESPONSE #20
    SetGlobalTimer("BPW","LOCALS",9)
    DisplayStringHead(Myself,@8)
    Shout(123)
    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),10)
THEN
  RESPONSE #90
    EquipMostDamagingMelee()
    AttackOneRound(NearestEnemyOf(Myself))
  RESPONSE #90
    EquipMostDamagingMelee()
    MoveToObjectNoInterrupt(LastSeenBy(Myself))
    AttackReevaluate(LastSeenBy(Myself),135)
END

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