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

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

IF
  GlobalTimerNotExpired("BPCHASE","LOCALS")
  Global("BPCHASER","LOCALS",1)
  OR(2)
    See([GOODCUTOFF])
    See(LastHitter(Myself))
THEN
  RESPONSE #50
    DisplayStringHead(Myself,@0)
    SetGlobal("BPCHASER","LOCALS",0)
    AttackReevaluate(LastSeenBy(Myself),15)
  RESPONSE #30
    DisplayStringHead(Myself,@0)
    SetGlobal("BPCHASER","LOCALS",0)
    SetGlobalTimer("RANG","LOCALS",9)
    SetGlobalTimer("DemTel","LOCALS",9)
    ActionOverride(LastSeenBy(Myself),ClearActions(Myself))
    ReallyForceSpell(LastSeenBy(Myself),DEMON_ATTRACTION)
    AttackOneRound(LastSeenBy(Myself))
  RESPONSE #20
    DisplayStringHead(Myself,@0)
    SetGlobal("BPCHASER","LOCALS",0)
    ReallyForceSpell(Myself,TELEKINESIS)
    SetGlobal("BP_BehTel","LOCALS",1)
    ChangeSpecifics(Myself,CALLED_FOR_BOULDER)
    FaceObject(LastSeenBy(Myself))
END

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

IF
  OR(3)
    AttackedBy([GOODCUTOFF],DEFAULT)
    Heard([NEUTRAL],79)
    Heard([EVILCUTOFF],79)
  !Allegiance(Myself,ENEMY)
THEN
  RESPONSE #100
    Enemy()
    Shout(151)
    Continue()
END

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

IF
  TookDamage()
  Global("BPCHASER","LOCALS",0)
  !See(LastHitter(Myself))
  !See([GOODCUTOFF])
THEN
  RESPONSE #60
    DisplayStringHead(Myself,@3)
    SetGlobalTimer("BPCHASE","LOCALS",12)
    SetGlobal("BPCHASER","LOCALS",1)
    MoveToObject(LastHitter(Myself))
  RESPONSE #25
    DisplayStringHead(Myself,@3)
    RunAwayFrom(LastHitter(Myself),45)
  RESPONSE #15
    DisplayStringHead(Myself,@2)
    SetGlobal("BPCHASER","LOCALS",0)
    ReallyForceSpell(LastHitter(Myself),WIZARD_DIMENSION_DOOR)
END

IF
  HPPercentLT(Myself,35)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("SNAFU","LOCALS",0)
  HaveSpell(CLERIC_HEAL)
THEN
  RESPONSE #100
    Spell(Myself,CLERIC_HEAL)
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
END

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

IF
  CheckStat(Myself,3,127)
  See([EVILCUTOFF.0.DEMONIC.CLERIC_MAGE.MAGIC.NIETHER.CHAOTIC_EVIL])
  Range(LastSeenBy(Myself),1)
THEN
  RESPONSE #100
    ActionOverride(LastSeenBy(Myself),RemoveSpell(WIZARD_SIMULACRUM))
    ChangeSpecifics(LastSeenBy(Myself),SIMULACRUM)
    ChangeGender(LastSeenBy(Myself),EXTRA3)
    ActionOverride(LastSeenBy(Myself),ChangeAIScript("BPORCUS",CLASS))
    SpellNoDecRES("SPMISLED",Myself)
    RunAwayFrom(LastSeenBy(Myself),20)
END

IF
  CheckStatGT(Myself,0,165)
  GlobalTimerNotExpired("BPT","LOCALS")
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",0)
    Continue()
END

IF
  ActionListEmpty()
  SpellCast(Myself,0)
  HaveAnySpells()
  HitBy([ANYONE],CRUSHING)
  See(SecondNearest([EVILCUTOFF]))
  !GlobalTimerNotExpired("SBN","LOCALS")
THEN
  RESPONSE #100
    SetGlobalTimer("SBN","LOCALS",15)
    DisplayStringHead(Myself,@4)
    Shout(69)
END

IF
  Global("BP_BehTel","LOCALS",0)
  See(NearestEnemyOf(Myself))
THEN
  RESPONSE #100
    ForceSpell(Myself,TELEKINESIS)
    SetGlobal("BP_BehTel","LOCALS",1)
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)
    ReallyForceSpell(NearestEnemyOf(Myself),DEMON_REPULSION)
  RESPONSE #20
    Continue()
END

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

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

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

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

IF
  Global("OrcBuff","LOCALS",0)
  Global("SNAFU","LOCALS",0)
THEN
  RESPONSE #100
    SetGlobal("OrcBuff","LOCALS",1)
    DisplayStringHead(Myself,39968)
    ReallyForceSpell(Myself,WIZARD_ABSOLUTE_IMMUNITY)
    ReallyForceSpell(Myself,WIZARD_PROTECTION_FROM_ENERGY)
    ReallyForceSpell(Myself,WIZARD_STONE_SKIN)
    ReallyForceSpell(Myself,WIZARD_SPELL_SHIELD)
    ReallyForceSpell(Myself,WIZARD_SPELL_TRAP)
    SetGlobalTimer("BPT","LOCALS",6)
END

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

IF
  ActionListEmpty()
  HaveSpell(WIZARD_STONE_SKIN)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("SNAFU","LOCALS",0)
  CheckStatLT(Myself,1,STONESKINS)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_STONE_SKIN)
END

IF
  ActionListEmpty()
  HaveSpell(WIZARD_TRUE_SIGHT)
  CheckStat(Myself,0,118)
  !GlobalTimerNotExpired("BPT","LOCALS")
  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,WIZARD_TRUE_SIGHT)
END

IF
  ActionListEmpty()
  HaveSpell(WIZARD_SIMULACRUM)
  !GlobalTimerNotExpired("BPT","LOCALS")
  CheckStat(Myself,0,127)
  Global("SNAFU","LOCALS",0)
  RandomNumLT(101,68)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_SIMULACRUM)
END

IF
  ActionListEmpty()
  HaveSpell(WIZARD_GLOBE_OF_INVULNERABILITY)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("SNAFU","LOCALS",0)
  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])
  CheckStat(Myself,0,129)
  CheckStat(Myself,0,164)
  CheckStat(Myself,0,SHIELDGLOBE)
  CheckStat(Myself,0,MINORGLOBE)
  CheckStat(Myself,0,116)
  RandomNumLT(10,7)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_GLOBE_OF_INVULNERABILITY)
END

IF
  ActionListEmpty()
  HaveSpell(WIZARD_SPELL_IMMUNITY_INVOCATION)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("SNAFU","LOCALS",0)
  CheckStat(Myself,0,162)
  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])
  CheckStat(Myself,0,129)
  CheckStat(Myself,0,164)
  CheckStat(Myself,0,SHIELDGLOBE)
  CheckStat(Myself,0,116)
  RandomNumLT(11,7)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_SPELL_IMMUNITY_INVOCATION)
END

IF
  ActionListEmpty()
  HaveSpell(WIZARD_IMPROVED_INVISIBILITY)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("SNAFU","LOCALS",0)
  !StateCheck(Myself,STATE_INVISIBLE)
  !StateCheck(Myself,STATE_IMPROVEDINVISIBILITY)
  RandomNumLT(12,8)
THEN
  RESPONSE #100
    SetGlobalTimer("BPIP","LOCALS",15)
    Spell(Myself,WIZARD_IMPROVED_INVISIBILITY)
END

IF
  !GlobalTimerNotExpired("DemTel","LOCALS")
  RandomNumLT(5,4)
  OR(5)
    See([PC.0.0.BARD_ALL])
    See([PC.0.0.DRUID_ALL])
    See([PC.0.0.SORCERER])
    See([PC.0.0.LONG_BOW])
    See([PC.0.0.CLERIC_ALL])
  !Range(LastSeenBy(Myself),8)
THEN
  RESPONSE #90
    SetGlobalTimer("DemTel","LOCALS",18)
    ActionOverride(LastSeenBy(Myself),ClearActions(Myself))
    DisplayStringHead(Myself,@6)
    ReallyForceSpell(LastSeenBy(Myself),DEMON_ATTRACTION)
    AttackReevaluate(LastSeenBy(Myself),180)
  RESPONSE #40
    ChangeSpecifics(Myself,CALLED_FOR_BOULDER)
    FaceObject(LastSeenBy(Myself))
END

IF
  HitBy([GOODCUTOFF],CRUSHING)
  OR(2)
    !Range(LastHitter(Myself),7)
    !Range(LastAttackerOf(Myself),7)
  OR(2)
    See(LastHitter(Myself))
    See(LastAttackerOf(Myself))
  !TargetUnreachable(LastSeenBy(Myself))
  !GlobalTimerNotExpired("RANG","LOCALS")
THEN
  RESPONSE #90
    DisplayStringHead(Myself,@7)
    SetGlobalTimer("RANG","LOCALS",THREE_ROUNDS)
    SetGlobalTimer("DemTel","LOCALS",18)
    ActionOverride(LastSeenBy(Myself),ClearActions(Myself))
    ReallyForceSpell(LastSeenBy(Myself),DEMON_ATTRACTION)
    AttackReevaluate(LastSeenBy(Myself),180)
  RESPONSE #50
    DisplayStringHead(Myself,@8)
    ChangeSpecifics(Myself,CALLED_FOR_BOULDER)
    FaceObject(LastSeenBy(Myself))
  RESPONSE #20
    DisplayStringHead(Myself,@9)
    SetGlobalTimer("RANG","LOCALS",FIVE_ROUNDS)
    MoveToObject(LastSeenBy(Myself))
    Wait(3)
    AttackReevaluate(LastSeenBy(Myself),240)
END

IF
  See(Nearest)
  False()
THEN
  RESPONSE #100
    Continue()
END

IF
  RandomNumLT(31,21)
  OR(8)
    See(NearestEnemyOf(Myself))
    See(MostDamagedOf)
    See(WorstAC)
    See(LastTargetedBy(Myself))
    See(LastAttackerOf(Myself))
    See(LastHitter(Myself))
    See([0.0.0.0.0.0.LAWFUL_GOOD])
    See([0.0.0.PALADIN_ALL])
  RandomNumLT(27,22)
  OR(3)
    See([GOODCUTOFF.0.0.0.0.SUMMONED])
    See([GOODCUTOFF.0.0.0.SIMULACRUM])
    See([GOODCUTOFF.0.0.0.0.ILLUSIONARY])
  RandomNumLT(29,24)
  OR(10)
    See([PC.0.0.BARD_ALL])
    See([PC.0.0.DRUID_ALL])
    See([PC.0.0.RANGER_ALL])
    See([PC.0.0.LONG_BOW])
    See([PC.0.0.SORCERER])
    See([PC.0.0.CLERIC_ALL])
    See([PC.0.0.CLERIC_MAGE])
    See([PC.0.0.CLERIC_RANGER])
    See([PC.0.0.PALADIN_ALL])
    See([PC.0.0.CLERIC.0.0.MASK_GOOD])
  RandomNumLT(30,16)
  See(Nearest)
  RandomNumLT(26,14)
  OR(3)
    See([GOODCUTOFF.0.0.RANGER_ALL])
    See([GOODCUTOFF.0.0.PALADIN_ALL])
    See([GOODCUTOFF.0.0.CLERIC.0.0.MASK_GOOD])
  RandomNumLT(28,10)
  OR(3)
    See([GOODCUTOFF.0.0.MONK])
    See([GOODCUTOFF.0.0.THIEF_ALL])
    See([GOODCUTOFF.0.0.BARD_ALL])
  RandomNumLT(24,9)
  OR(3)
    See(StrongestOf)
    See(BestAC)
    See(LeastDamagedOf)
  RandomNumLT(25,9)
  See(WeakestOf)
  RandomNumLT(23,8)
  See(WorstAC)
  RandomNumLT(22,8)
  See(MostDamagedOf)
  RandomNumLT(32,11)
  See(TenthNearest([GOODCUTOFF.0.0.PALADIN_ALL]))
  RandomNumLT(34,12)
  See(TenthNearest([GOODCUTOFF.0.0.LONG_BOW]))
  RandomNumLT(35,12)
  See(TenthNearest([GOODCUTOFF.0.0.CLERIC_ALL]))
  RandomNumLT(33,12)
  See(TenthNearest([0.0.0.0.0.0.LAWFUL_GOOD]))
  False()
THEN
  RESPONSE #100
    Continue()
END

IF
  OR(8)
    General(LastSeenBy(Myself),UNDEAD)
    Race(LastSeenBy(Myself),DEMONIC)
    Race(LastSeenBy(Myself),RAKSHASA)
    Race(LastSeenBy(Myself),IMP)
    Race(LastSeenBy(Myself),MEPHIT)
    Gender(LastSeenBy(Myself),SUMMONED_DEMON)
    CheckStatGT(LastSeenBy(Myself),0,117)
    StateCheck(LastSeenBy(Myself),STATE_DEAD)
THEN
  RESPONSE #100
END

IF
  ActionListEmpty()
  HPPercentGT(Myself,35)
  Global("SNAFU","LOCALS",1)
THEN
  RESPONSE #75
    AttackOneRound(LastSeenBy(Myself))
  RESPONSE #25
    Continue()
END

IF
  ActionListEmpty()
  OR(2)
    StateCheck(Myself,STATE_INVISIBLE)
    StateCheck(Myself,STATE_IMPROVEDINVISIBILITY)
  GlobalTimerNotExpired("BPIP","LOCALS")
THEN
  RESPONSE #15
    Continue()
  RESPONSE #60
    SetGlobalTimer("BPT","LOCALS",0)
  RESPONSE #90
    SetGlobalTimer("BPT","LOCALS",0)
    RunAwayFrom(NearestEnemyOf(Myself),10)
END

IF
  ActionListEmpty()
  HaveSpell(WIZARD_DEATH_SPELL)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Gender(LastSeenBy(Myself),SUMMONED)
  !Range([EVILCUTOFF.0.0.0.0.SUMMONED],15)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_DEATH_SPELL)
END

IF
  ActionListEmpty()
  HaveSpell(WIZARD_DEATH_FOG)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Gender(LastSeenBy(Myself),SUMMONED)
  !Range(LastSeenBy(Myself),15)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_DEATH_FOG)
END

IF
  ActionListEmpty()
  HaveSpell(WIZARD_RUBY_RAY_OF_REVERSAL)
  !GlobalTimerNotExpired("BPT","LOCALS")
  CheckStatGT(LastSeenBy(Myself),0,164)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_RUBY_RAY_OF_REVERSAL)
END

IF
  !GlobalTimerNotExpired("DemTel1","LOCALS")
  RandomNumLT(3,3)
  OR(6)
    Class(LastSeenBy(Myself),FIGHTER_ALL)
    Class(LastSeenBy(Myself),RANGER_ALL)
    Class(LastSeenBy(Myself),PALADIN_ALL)
    Class(LastSeenBy(Myself),THIEF_ALL)
    Class(LastSeenBy(Myself),MONK)
    HPGT(LastSeenBy(Myself),50)
  Range(LastSeenBy(Myself),10)
THEN
  RESPONSE #90
    SetGlobalTimer("DemTel1","LOCALS",THREE_ROUNDS)
    DisplayStringHead(Myself,314)
    ReallyForceSpell(LastSeenBy(Myself),DEMON_REPULSION)
  RESPONSE #40
    ChangeSpecifics(Myself,CALLED_FOR_BOULDER)
    FaceObject(LastSeenBy(Myself))
END

IF
  ActionListEmpty()
  !GlobalTimerNotExpired("BPT","LOCALS")
  HaveSpell(WIZARD_TIME_STOP)
  Global("BP_Special","LOCALS",0)
THEN
  RESPONSE #100
    SetGlobal("BP_Special","LOCALS",1)
    ForceSpell(Myself,WIZARD_IMPROVED_ALUCRITY)
    DisplayStringHead(Myself,63217)  // ~Improved Alacrity~
    Spell(Myself,WIZARD_TIME_STOP)
    Continue()
END

IF
  ActionListEmpty()
  GlobalLT("SYMBOL","LOCALS",4)
  !GlobalTimerNotExpired("BPT","LOCALS")
  !Range(LastSeenBy(Myself),5)
  RandomNumLT(50,32)
THEN
  RESPONSE #100
    IncrementGlobal("SYMBOL","LOCALS",1)
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    ReallyForceSpell(LastSeenBy(Myself),WIZARD_SYMBOL_DEATH)
END

IF
  ActionListEmpty()
  GlobalLT("SYMBOL","LOCALS",4)
  !GlobalTimerNotExpired("BPT","LOCALS")
  CheckStat(LastSeenBy(Myself),0,129)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  RandomNumLT(51,32)
THEN
  RESPONSE #100
    IncrementGlobal("SYMBOL","LOCALS",1)
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    ReallyForceSpell(LastSeenBy(Myself),WIZARD_NPC_SYMBOL_STUN)
END

IF
  ActionListEmpty()
  GlobalLT("SYMBOL","LOCALS",4)
  !GlobalTimerNotExpired("BPT","LOCALS")
  CheckStat(LastSeenBy(Myself),0,129)
  !StateCheck(LastSeenBy(Myself),STATE_PANIC)
  RandomNumLT(52,31)
THEN
  RESPONSE #100
    IncrementGlobal("SYMBOL","LOCALS",1)
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    ReallyForceSpell(LastSeenBy(Myself),WIZARD_NPC_SYMBOL_FEAR)
END

IF
  ActionListEmpty()
  GlobalLT("SYMBOL","LOCALS",4)
  !GlobalTimerNotExpired("BPT","LOCALS")
  CheckStat(LastSeenBy(Myself),0,129)
  !StateCheck(LastSeenBy(Myself),STATE_SILENCED)
  OR(5)
    Class(LastSeenBy(Myself),DRUID_ALL)
    Class(LastSeenBy(Myself),BARD_ALL)
    Class(LastSeenBy(Myself),CLERIC_ALL)
    Class(LastSeenBy(Myself),LONG_BOW)
    Class(LastSeenBy(Myself),SORCERER)
  CheckStat(LastSeenBy(Myself),0,129)
  RandomNumLT(53,36)
THEN
  RESPONSE #100
    IncrementGlobal("SYMBOL","LOCALS",1)
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    ReallyForceSpell(LastSeenBy(Myself),WIZARD_POWER_WORD_SILENCE)
END

IF
  ActionListEmpty()
  HaveSpell(WIZARD_COMET)
  !GlobalTimerNotExpired("BPT","LOCALS")
  CheckStatLT(LastSeenBy(Myself),65,RESISTMAGICFIRE)
  RandomNumLT(57,37)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_COMET)
END

IF
  ActionListEmpty()
  HaveSpell(WIZARD_ABI_DALZIMS_HORRID_WILTING)
  !GlobalTimerNotExpired("BPT","LOCALS")
  CheckStatLT(LastSeenBy(Myself),70,RESISTMAGIC)
  RandomNumLT(58,38)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_ABI_DALZIMS_HORRID_WILTING)
END

IF
  ActionListEmpty()
  HaveSpell(WIZARD_IMPRISONMENT)
  !GlobalTimerNotExpired("BPT","LOCALS")
  !CheckStat(LastSeenBy(Myself),1,SCRIPTINGSTATE4)
  RandomNumLT(46,22)
THEN
  RESPONSE #100
    Spell(LastSeenBy(Myself),WIZARD_IMPRISONMENT)
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
END

IF
  ActionListEmpty()
  HaveSpell(WIZARD_MAZE)
  !GlobalTimerNotExpired("BPT","LOCALS")
  HPGT(LastSeenBy(Myself),50)
  CheckStat(LastSeenBy(Myself),0,129)
  RandomNumLT(69,42)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_MAZE)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_CREEPING_DOOM)
  !GlobalTimerNotExpired("BPT","LOCALS")
  OR(5)
    Class(LastSeenBy(Myself),DRUID_ALL)
    Class(LastSeenBy(Myself),BARD_ALL)
    Class(LastSeenBy(Myself),CLERIC_ALL)
    Class(LastSeenBy(Myself),LONG_BOW)
    Class(LastSeenBy(Myself),SORCERER)
  CheckStat(LastSeenBy(Myself),0,120)
  RandomNumLT(36,26)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_CREEPING_DOOM)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_DOLOROUS_DECAY)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("MORPH","LOCALS",0)
  CheckStat(LastSeenBy(Myself),0,129)
  RandomNumLT(50,33)
THEN
  RESPONSE #100
    SetGlobal("BPT","LOCALS",6)
    Spell(LastSeenBy(Myself),CLERIC_DOLOROUS_DECAY)
END

IF
  ActionListEmpty()
  HaveSpell(WIZARD_SUMMON_PLANATAR_EVIL)
  !GlobalTimerNotExpired("BPT","LOCALS")
  !GlobalTimerNotExpired("DEVA","GLOBAL")
  NumCreatureLT([EVILCUTOFF.0.0.0.0.SUMMONED],7)
  RandomNumLT(64,36)
THEN
  RESPONSE #100
    SetGlobalTimer("DEVA","GLOBAL",96)
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_SUMMON_PLANATAR_EVIL)
END

IF
  ActionListEmpty()
  HaveSpell(WIZARD_SPHERE_OF_CHAOS)
  !GlobalTimerNotExpired("BPT","LOCALS")
  CheckStat(LastSeenBy(Myself),0,129)
  !Range(LastSeenBy(Myself),15)
  RandomNumLT(54,31)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_SPHERE_OF_CHAOS)
END

IF
  ActionListEmpty()
  HaveSpell(WIZARD_CHAOS)
  !GlobalTimerNotExpired("BPT","LOCALS")
  CheckStat(LastSeenBy(Myself),0,129)
  !StateCheck(LastSeenBy(Myself),STATE_CONFUSED)
  RandomNumLT(65,38)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_CHAOS)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_INSECT_PLAGUE)
  !GlobalTimerNotExpired("BPT","LOCALS")
  OR(5)
    Class(LastSeenBy(Myself),DRUID_ALL)
    Class(LastSeenBy(Myself),BARD_ALL)
    Class(LastSeenBy(Myself),CLERIC_ALL)
    Class(LastSeenBy(Myself),LONG_BOW)
    Class(LastSeenBy(Myself),SORCERER)
  CheckStat(LastSeenBy(Myself),0,120)
  RandomNumLT(37,26)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_INSECT_PLAGUE)
END

IF
  ActionListEmpty()
  !GlobalTimerNotExpired("SLAY","LOCALS")
  !GlobalTimerNotExpired("BPT","LOCALS")
  CheckStat(LastSeenBy(Myself),0,129)
  RandomNumLT(41,24)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    SetGlobalTimer("SLAY","LOCALS",36)
    ForceSpell(LastSeenBy(Myself),ENEMY_CLERIC_SLAY_LIVING)
END

IF
  ActionListEmpty()
  HaveSpell(ENEMY_CLERIC_HARM)
  !GlobalTimerNotExpired("BPT","LOCALS")
  CheckStat(LastSeenBy(Myself),0,129)
  RandomNumLT(42,25)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),ENEMY_CLERIC_HARM)
END

IF
  ActionListEmpty()
  !GlobalTimerNotExpired("DEATH","LOCALS")
  !GlobalTimerNotExpired("BPT","LOCALS")
  CheckStat(LastSeenBy(Myself),0,129)
  CheckStatGT(LastSeenBy(Myself),6,SAVEVSDEATH)
  RandomNumLT(68,38)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    SetGlobalTimer("DEATH","LOCALS",24)
    ForceSpell(LastSeenBy(Myself),WIZARD_FINGER_OF_DEATH)
END

IF
  ActionListEmpty()
  GlobalLT("GATE","LOCALS",3)
  !GlobalTimerNotExpired("BPT","LOCALS")
  !GlobalTimerNotExpired("GATEWAY","LOCALS")
  NumCreatureLT([EVILCUTOFF.0.0.0.0.SUMMONED],7)
  RandomNumLT(57,29)
THEN
  RESPONSE #100
    ReallyForceSpell(Myself,WIZARD_PROTECTION_FROM_EVIL)
    IncrementGlobal("GATE","LOCALS",1)
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    SetGlobalTimer("GATEWAY","LOCALS",60)
    ForceSpell(LastSeenBy(Myself),WIZARD_GATE)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_UNHOLY_WORD)
  Alignment(LastSeenBy(Myself),MASK_GOOD)
  !GlobalTimerNotExpired("BPT","LOCALS")
  !Alignment(Myself,MASK_GOOD)
  RandomNumLT(10,7)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_UNHOLY_WORD)
END

IF
  ActionListEmpty()
  GlobalLT("GATE","LOCALS",3)
  !GlobalTimerNotExpired("BPT","LOCALS")
  !GlobalTimerNotExpired("GATEWAY","LOCALS")
  NumCreatureLT([EVILCUTOFF.0.0.0.0.SUMMONED],7)
  RandomNumLT(60,30)
THEN
  RESPONSE #100
    ReallyForceSpell(Myself,WIZARD_PROTECTION_FROM_EVIL)
    IncrementGlobal("GATE","LOCALS",1)
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    SetGlobalTimer("GATEWAY","LOCALS",60)
    ForceSpell(LastSeenBy(Myself),WIZARD_SUMMON_FIEND)
END

IF
  ActionListEmpty()
  HaveSpell(WIZARD_DISINTEGRATE)
  !GlobalTimerNotExpired("BPT","LOCALS")
  CheckStat(LastSeenBy(Myself),0,129)
  CheckStatLT(LastSeenBy(Myself),70,RESISTMAGIC)
  RandomNumLT(71,36)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_DISINTEGRATE)
END

IF
  ActionListEmpty()
  HaveSpell(WIZARD_REMOVE_MAGIC)
  !GlobalTimerNotExpired("BPT","LOCALS")
  OR(7)
    HasImmunityEffects(LastSeenBy(Myself))
    HasBounceEffects(LastSeenBy(Myself))
    InPartySlot(LastSeenBy(Myself),0)
    StateCheck(LastSeenBy(Myself),STATE_BLESS)
    StateCheck(LastSeenBy(Myself),STATE_HASTED)
    StateCheck(LastSeenBy(Myself),STATE_LUCK)
    StateCheck(LastSeenBy(Myself),STATE_CHANT)
  RandomNumLT(37,25)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_REMOVE_MAGIC)
END

IF
  ActionListEmpty()
  HaveSpell(WIZARD_RUBY_RAY_OF_REVERSAL)
  !GlobalTimerNotExpired("BPT","LOCALS")
  OR(7)
    CheckStatGT(LastSeenBy(Myself),0,129)
    CheckStatGT(LastSeenBy(Myself),0,116)
    CheckStatGT(LastSeenBy(Myself),0,MINORGLOBE)
    CheckStatGT(LastSeenBy(Myself),0,SHIELDGLOBE)
    CheckStatGT(LastSeenBy(Myself),0,162)
    CheckStatGT(LastSeenBy(Myself),0,177)
    CheckStatGT(LastSeenBy(Myself),0,164)
  RandomNumLT(78,48)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_RUBY_RAY_OF_REVERSAL)
END

IF
  ActionListEmpty()
  HaveSpell(WIZARD_SPELL_STRIKE)
  !GlobalTimerNotExpired("BPT","LOCALS")
  OR(8)
    CheckStatGT(LastSeenBy(Myself),0,129)
    CheckStatGT(LastSeenBy(Myself),0,116)
    CheckStatGT(LastSeenBy(Myself),0,MINORGLOBE)
    CheckStatGT(LastSeenBy(Myself),0,SHIELDGLOBE)
    CheckStatGT(LastSeenBy(Myself),0,162)
    CheckStatGT(LastSeenBy(Myself),0,177)
    CheckStatGT(LastSeenBy(Myself),0,164)
    RandomNumLT(52,34)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_SPELL_STRIKE)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_GREATER_COMMAND)
  !GlobalTimerNotExpired("BPT","LOCALS")
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  CheckStat(LastSeenBy(Myself),0,129)
  RandomNumLT(40,23)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_GREATER_COMMAND)
END

IF
  ActionListEmpty()
  HaveSpell(WIZARD_CONFUSION)
  !GlobalTimerNotExpired("BPT","LOCALS")
  !StateCheck(LastSeenBy(Myself),STATE_CONFUSED)
  RandomNumLT(80,46)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_CONFUSION)
END

IF
  ActionListEmpty()
  HaveSpell(WIZARD_HOLD_MONSTER)
  !GlobalTimerNotExpired("BPT","LOCALS")
  CheckStat(LastSeenBy(Myself),0,129)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  RandomNumLT(74,42)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_HOLD_MONSTER)
END

IF
  ActionListEmpty()
  GlobalLT("GATE","LOCALS",3)
  !GlobalTimerNotExpired("BPT","LOCALS")
  !GlobalTimerNotExpired("GATEWAY","LOCALS")
  NumCreatureLT([EVILCUTOFF.0.0.0.0.SUMMONED],7)
  RandomNumLT(62,24)
THEN
  RESPONSE #100
    ReallyForceSpell(Myself,WIZARD_PROTECTION_FROM_EVIL)
    IncrementGlobal("GATE","LOCALS",1)
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    SetGlobalTimer("GATEWAY","LOCALS",60)
    ForceSpell(LastSeenBy(Myself),WIZARD_CACOFIEND)
END

IF
  ActionListEmpty()
  HaveSpell(WIZARD_FEEBLEMIND)
  !GlobalTimerNotExpired("BPT","LOCALS")
  OR(5)
    Class(LastSeenBy(Myself),DRUID_ALL)
    Class(LastSeenBy(Myself),BARD_ALL)
    Class(LastSeenBy(Myself),CLERIC_ALL)
    Class(LastSeenBy(Myself),LONG_BOW)
    Class(LastSeenBy(Myself),SORCERER)
  CheckStat(LastSeenBy(Myself),0,129)
  RandomNumLT(81,51)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_FEEBLEMIND)
END

IF
  ActionListEmpty()
  HaveSpell(WIZARD_SLOW)
  !GlobalTimerNotExpired("BPT","LOCALS")
  !StateCheck(LastSeenBy(Myself),STATE_SLOWED)
  RandomNumLT(82,48)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_SLOW)
END

IF
  ActionListEmpty()
  HaveSpell(WIZARD_SKULL_TRAP)
  !GlobalTimerNotExpired("BPT","LOCALS")
  !Range(LastSeenBy(Myself),15)
  NumCreatureGT([GOODCUTOFF],3)
  CheckStatLT(LastSeenBy(Myself),60,RESISTMAGIC)
  RandomNumLT(48,30)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_SKULL_TRAP)
END

IF
  ActionListEmpty()
  !GlobalTimerNotExpired("DEATH","LOCALS")
  !GlobalTimerNotExpired("BPT","LOCALS")
  CheckStat(LastSeenBy(Myself),0,129)
  CheckStatGT(LastSeenBy(Myself),6,SAVEVSDEATH)
  NumCreatureGT([GOODCUTOFF],3)
  RandomNumLT(87,45)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    SetGlobalTimer("DEATH","LOCALS",24)
    ForceSpell(LastSeenBy(Myself),WIZARD_DEATH_SPELL)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_UNHOLY_BLIGHT)
  Alignment(LastSeenBy(Myself),MASK_GOOD)
  !GlobalTimerNotExpired("BPT","LOCALS")
  !Alignment(Myself,MASK_GOOD)
  RandomNumLT(43,23)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_UNHOLY_BLIGHT)
END

IF
  !GlobalTimerNotExpired("BPT","LOCALS")
  HaveSpell(WIZARD_DARKNESS_15_RADIUS)
  RandomNumLT(20,4)
  !StateCheck(LastSeenBy(Myself),STATE_BLIND)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",3)
    Spell(LastSeenBy(Myself),WIZARD_DARKNESS_15_RADIUS)
END

IF
  !GlobalTimerNotExpired("BPT","LOCALS")
  RandomNumGT(20,3)
  RandomNumLT(20,7)
  !StateCheck(LastSeenBy(Myself),STATE_CHARMED)
  CheckStat(LastSeenBy(Myself),0,119)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",4)
    ReallyForceSpell(LastSeenBy(Myself),VAMPIRE_DOMINATION)
END

IF
  !GlobalTimerNotExpired("BPT","LOCALS")
  RandomNumGT(20,6)
  RandomNumLT(20,9)
  NumCreatureVsPartyLT([ENEMY.UNDEAD],6)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    ReallyForceSpell(LastSeenBy(Myself),CLERIC_ANIMATE_DEAD)
END

IF
  !GlobalTimerNotExpired("BPT","LOCALS")
  RandomNumGT(20,8)
  RandomNumLT(20,12)
  !StateCheck(LastSeenBy(Myself),STATE_SLEEPING)
  CheckStat(LastSeenBy(Myself),0,119)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",3)
    ReallyForceSpell(LastSeenBy(Myself),SPECTATOR_SUGGESTION)
END

IF
  !GlobalTimerNotExpired("BPT","LOCALS")
  RandomNumGT(20,11)
  RandomNumLT(20,15)
  !StateCheck(LastSeenBy(Myself),STATE_PANIC)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",4)
    ReallyForceSpell(LastSeenBy(Myself),DEMON_FEAR)
END

IF
  HaveSpell(CLERIC_SILENCE_15_FOOT)
  !GlobalTimerNotExpired("BPT","LOCALS")
  OR(5)
    Class(LastSeenBy(Myself),DRUID_ALL)
    Class(LastSeenBy(Myself),BARD_ALL)
    Class(LastSeenBy(Myself),CLERIC_ALL)
    Class(LastSeenBy(Myself),LONG_BOW)
    Class(LastSeenBy(Myself),SORCERER)
  !Range(LastSeenBy(Myself),15)
  !StateCheck(LastSeenBy(Myself),STATE_SILENCED)
  RandomNumLT(4,4)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_SILENCE_15_FOOT)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_RIGID_THINKING)
  !GlobalTimerNotExpired("BPT","LOCALS")
  !StateCheck(LastSeenBy(Myself),STATE_CONFUSED)
  RandomNumLT(51,31)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_RIGID_THINKING)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_HOLD_PERSON)
  !GlobalTimerNotExpired("BPT","LOCALS")
  CheckStat(LastSeenBy(Myself),0,129)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  General(LastSeenBy(Myself),HUMANOID)
  RandomNumLT(55,41)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_HOLD_PERSON)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_ENTANGLE)
  !GlobalTimerNotExpired("BPT","LOCALS")
  CheckStat(LastSeenBy(Myself),0,ENTANGLE)
  !Range(LastSeenBy(Myself),15)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  RandomNumLT(47,27)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_ENTANGLE)
END

IF
  ActionListEmpty()
  HaveSpell(WIZARD_RAY_OF_ENFEEBLEMENT)
  !GlobalTimerNotExpired("BPT","LOCALS")
  CheckStatGT(LastSeenBy(Myself),15,STR)
  CheckStat(LastSeenBy(Myself),0,129)
  RandomNumLT(99,45)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_RAY_OF_ENFEEBLEMENT)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_CLOAK_OF_FEAR)
  !GlobalTimerNotExpired("BPT","LOCALS")
  RandomNumLT(57,27)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_CLOAK_OF_FEAR)
END

IF
  ActionListEmpty()
  HaveSpell(WIZARD_HORROR)
  !GlobalTimerNotExpired("BPT","LOCALS")
  CheckStatLT(LastSeenBy(Myself),50,RESISTMAGIC)
  CheckStatGT(LastSeenBy(Myself),8,SAVEVSSPELL)
  !StateCheck(LastSeenBy(Myself),STATE_PANIC)
  RandomNumLT(69,26)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_HORROR)
END

IF
  ActionListEmpty()
  HaveSpell(WIZARD_MAGIC_MISSILE)
  !GlobalTimerNotExpired("BPT","LOCALS")
  CheckStatLT(LastSeenBy(Myself),50,RESISTMAGIC)
  !CheckStat(LastSeenBy(Myself),2,SCRIPTINGSTATE5)
  CheckStat(LastSeenBy(Myself),0,129)
  RandomNumLT(109,38)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_MAGIC_MISSILE)
END

IF
  ActionListEmpty()
  HaveSpell(WIZARD_BURNING_HANDS)
  !GlobalTimerNotExpired("BPT","LOCALS")
  CheckStat(LastSeenBy(Myself),0,129)
  CheckStatLT(LastSeenBy(Myself),50,RESISTMAGIC)
  CheckStatLT(LastSeenBy(Myself),50,RESISTMAGICFIRE)
  Range(LastSeenBy(Myself),5)
  RandomNumLT(110,34)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_BURNING_HANDS)
END

IF
  HPPercentLT(Myself,25)
  Range(LastHitter(Myself),10)
  !GlobalTimerNotExpired("BPW","LOCALS")
THEN
  RESPONSE #30
    SetGlobalTimer("BPW","LOCALS",10)
    DisplayStringHead(Myself,@10)
    Shout(124)
    RunAwayFrom(Nearest,90)
  RESPONSE #30
    SetGlobalTimer("BPW","LOCALS",10)
    DisplayStringHead(Myself,@11)
    Shout(124)
    EquipMostDamagingMelee()
    Attack(LastHitter(Myself))
  RESPONSE #40
    SetGlobalTimer("BPW","LOCALS",FOUR_ROUNDS)
    DisplayStringHead(Myself,314)
    ReallyForceSpell(NearestEnemyOf(Myself),DEMON_REPULSION)
    ReallyForceSpell(SecondNearestEnemyOf(Myself),DEMON_REPULSION)
    ReallyForceSpell(ThirdNearestEnemyOf(Myself),DEMON_REPULSION)
  RESPONSE #40
    SetGlobalTimer("BPW","LOCALS",16)
    DisplayStringHead(Myself,@12)
    Shout(123)
    ReallyForceSpell(LastHitter(Myself),CLERIC_ANIMATE_DEAD)
END

IF
  HPPercentLT(Myself,21)
  Range(NearestEnemyOf(Myself),5)
  !GlobalTimerNotExpired("BPT","LOCALS")
  !Range(LastSeenBy(Myself),10)
THEN
  RESPONSE #90
    SetGlobalTimer("BPT","LOCALS",3)
    ForceSpell(TenthNearest([EVILCUTOFF]),WIZARD_DIMENSION_DOOR)
  RESPONSE #10
    Continue()
END

IF
  OR(3)
    !Range(LastSeenBy(Myself),5)
    CheckStatGT(LastSeenBy(Myself),0,121)
    CheckStatGT(LastSeenBy(Myself),0,125)
THEN
  RESPONSE #60
    EquipRanged()
    AttackOneRound(LastSeenBy(Myself))
  RESPONSE #90
    ChangeSpecifics(Myself,CALLED_FOR_BOULDER)
    FaceObject(LastSeenBy(Myself))
END

IF
  CheckStatGT(NearestEnemyOf(Myself),0,121)
THEN
  RESPONSE #25
    Continue()
  RESPONSE #75
    ReallyForceSpell(NearestEnemyOf(Myself),DEMON_REPULSION)
END

IF
  CheckStatGT(LastSeenBy(Myself),0,125)
THEN
  RESPONSE #25
    Continue()
  RESPONSE #75
    ReallyForceSpell(LastSeenBy(Myself),DEMON_REPULSION)
END

IF
  !Range(LastSeenBy(Myself),8)
THEN
  RESPONSE #90
    EquipMostDamagingMelee()
    AttackReevaluate(NearestEnemyOf(Myself),45)
  RESPONSE #40
    EquipMostDamagingMelee()
    AttackOneRound(LastSeenBy(Myself))
END

IF
  True()
THEN
  RESPONSE #60
    AttackReevaluate(LastSeenBy(Myself),45)
  RESPONSE #60
    ChangeSpecifics(Myself,CALLED_FOR_BOULDER)
    FaceObject(LastSeenBy(Myself))
  RESPONSE #45
END

