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
  Global("BP_BOMB","LOCALS",2)
  See([PC])
THEN
  RESPONSE #100
    SetGlobal("BP_BOMB","LOCALS",0)
    SetGlobal("BP_BOMBSAWAY","MYAREA",0)
    SetGlobal("BP_CHASER","LOCALS",0)
    SetGlobal("BP_CHASE","LOCALS",0)
    SmallWait(10)
    ActionOverride("BPTARGET",DestroySelf())
END

IF
  Global("BP_BOMB","LOCALS",1)
THEN
  RESPONSE #100
    SetGlobal("BP_BOMB","LOCALS",2)
    ReallyForceSpellRES("BPTARGET",Myself)
END

IF
  GlobalTimerNotExpired("BPCHASE","LOCALS")
  Global("BPCHASER","LOCALS",1)
  OR(2)
    See([GOODCUTOFF])
    See(LastHitter(Myself))
  OR(2)
    General(Myself,HUMANOID)
    General(Myself,GIANTHUMANOID)
THEN
  RESPONSE #50
    DisplayStringHead(Myself,@0)
    SetGlobal("BPCHASER","LOCALS",0)
    AttackReevaluate(LastSeenBy(Myself),15)
  RESPONSE #25
    DisplayStringHead(Myself,@0)
    SetGlobal("BPCHASER","LOCALS",0)
    SetGlobalTimer("CHARM","LOCALS",9)
    ReallyForceSpell(LastSeenBy(Myself),VAMPIRE_DOMINATION)
  RESPONSE #25
    DisplayStringHead(Myself,@1)
    SetGlobal("BPCHASER","LOCALS",0)
    SetGlobalTimer("FEAR","LOCALS",7)
    ReallyForceSpell(LastSeenBy(Myself),VAMPIRE_FEAR)
END

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

IF
  TookDamage()
  Global("BPCHASER","LOCALS",0)
  !See(LastHitter(Myself))
  !See([GOODCUTOFF])
  CheckStatGT(Myself,5,INT)
THEN
  RESPONSE #75
    DisplayStringHead(Myself,@3)
    SetGlobalTimer("BPCHASE","LOCALS",12)
    SetGlobal("BPCHASER","LOCALS",1)
    MoveToObject(LastHitter(Myself))
  RESPONSE #25
    DisplayStringHead(Myself,@3)
    RunAwayFrom(LastHitter(Myself),45)
END

IF
  Global("VAPOR","LOCALS",1)
  CheckStatLT(Myself,11,WIZARD_GREATER_MALISON)
THEN
  RESPONSE #100
    SetGlobal("VAPOR","LOCALS",0)
    SpellNoDecRES("BPVAMBAK",Myself)
    EquipMostDamagingMelee()
    AttackOneRound(NearestEnemyOf(Myself))
END

IF
  CheckStatGT(Myself,10,WIZARD_GREATER_MALISON)
  CheckStatGT(Myself,5,INT)
  OR(2)
    See(LastAttackerOf(Myself))
    See(LastHitter(Myself))
  CheckStatLT(LastSeenBy(Myself),11,WIZARD_GREATER_MALISON)
  !GlobalTimerNotExpired("BPCHASE","LOCALS")
THEN
  RESPONSE #100
    SetGlobalTimer("BPCHASE","LOCALS",TWO_ROUNDS)
    SetGlobal("VAPOR","LOCALS",1)
    DisplayStringHead(Myself,@4)
    SpellNoDecRES("BPVAMGAS",Myself)
    MoveToObject(LastSeenBy(Myself))
END

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

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

IF
  CheckStatGT(Myself,10,WIZARD_GREATER_MALISON)
  CheckStatGT(Myself,5,INT)
  !GlobalTimerNotExpired("BPCHASE","LOCALS")
  See([ANYONE])
  CheckStatGT(LastSeenBy(Myself),10,WIZARD_GREATER_MALISON)
THEN
  RESPONSE #100
    SetGlobalTimer("BPCHASE","LOCALS",ONE_ROUND)
    SetGlobal("VAPOR","LOCALS",1)
    DisplayStringHead(Myself,@4)
    SpellNoDecRES("BPVAMGAS",Myself)
    RunAwayFrom(LastSeenBy(Myself),45)
END

IF
  CheckStatGT(Myself,10,WIZARD_GREATER_MALISON)
  CheckStatGT(Myself,5,INT)
  !GlobalTimerNotExpired("BPCHASE","LOCALS")
  !See([GOODCUTOFF])
THEN
  RESPONSE #100
    SetGlobal("BPCHASER","LOCALS",1)
    SetGlobal("VAPOR","LOCALS",1)
    SetGlobalTimer("BPCHASE","LOCALS",TWO_ROUNDS)
    DisplayStringHead(Myself,@4)
    SpellNoDecRES("BPVAMGAS",Myself)
    MoveToObject(Player1)
END

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

IF
  ActionListEmpty()
  Global("Prep","LOCALS",0)
THEN
  RESPONSE #100
    SetGlobal("Prep","LOCALS",1)
    ReallyForceSpell(Myself,COM_AURA_OF_FOCUS)
    ReallyForceSpell(Myself,WIZARD_SPELL_TRAP)
END

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

IF
  ActionListEmpty()
  HaveSpell(COM_PRIEST_GREATER_UNDEAD)
  See(ThirdNearestEnemyOf(Myself))
  !GlobalTimerNotExpired("BPT","LOCALS")
  NumCreatureVsPartyLT([0.0.0.0.0.SUMMONED],7)
  RandomNumLT(4,3)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),COM_PRIEST_GREATER_UNDEAD)
END

IF
  ActionListEmpty()
  HaveSpell(COM_ARMY_DARKNESS)
  See(FourthNearestEnemyOf(Myself))
  !GlobalTimerNotExpired("BPT","LOCALS")
  NumCreatureVsPartyLT([0.0.0.0.0.SUMMONED],7)
  RandomNumLT(6,4)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),COM_ARMY_DARKNESS)
END

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

IF
  ActionListEmpty()
  HaveSpell(CLERIC_PHYSICAL_MIRROR)
  !GlobalTimerNotExpired("BPT","LOCALS")
  CheckStat(Myself,0,WIZARD_PROTECTION_FROM_MAGIC_WEAPONS)
  OR(2)
    RandomNumLT(7,3)
    HitBy([ANYONE],MISSILE)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_PHYSICAL_MIRROR)
END

IF
  ActionListEmpty()
  HaveSpell(WIZARD_SPELL_TRAP)
  !GlobalTimerNotExpired("BPT","LOCALS")
  CheckStat(Myself,0,WIZARD_SPELL_TRAP)
  CheckStat(Myself,0,WIZARD_SPELL_IMMUNITY)
  CheckStat(Myself,0,WIZARD_SPELL_TURNING)
  RandomNumLT(8,4)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_SPELL_TRAP)
END

IF
  ActionListEmpty()
  HaveSpell(WIZARD_SPELL_TURNING)
  !GlobalTimerNotExpired("BPT","LOCALS")
  CheckStat(Myself,0,WIZARD_SPELL_TRAP)
  CheckStat(Myself,0,WIZARD_SPELL_IMMUNITY)
  CheckStat(Myself,0,WIZARD_SPELL_TURNING)
  RandomNumLT(5,3)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_SPELL_TURNING)
END

IF
  ActionListEmpty()
  HaveSpell(WIZARD_SPELL_IMMUNITY_NECROMANCY)
  !GlobalTimerNotExpired("BPT","LOCALS")
  CheckStat(Myself,0,WIZARD_SPELL_TRAP)
  CheckStat(Myself,0,WIZARD_SPELL_TURNING)
  RandomNumLT(9,4)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_SPELL_IMMUNITY_NECROMANCY)
END

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

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

IF
  ActionListEmpty()
  !GlobalTimerNotExpired("CHARM","LOCALS")
  RandomNumLT(10,7)
  OR(6)
    See(NearestEnemyOf(Myself))
    See(LastHitter(Myself))
    See([GOODCUTOFF.0.0.FIGHTER_ALL])
    See([GOODCUTOFF.0.0.PALADIN_ALL])
    See([GOODCUTOFF.0.0.RANGER_ALL])
    See([GOODCUTOFF.0.0.THIEF_ALL])
  !Kit(LastSeenBy(Myself),INQUISITOR)
  !StateCheck(LastSeenBy(Myself),STATE_CHARMED)
  CheckStat(LastSeenBy(Myself),0,CLERIC_CHAOTIC_COMMANDS)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
THEN
  RESPONSE #100
    SetGlobalTimer("CHARM","LOCALS",9)
    ReallyForceSpell(LastSeenBy(Myself),VAMPIRE_DOMINATION)
END

IF
  ActionListEmpty()
  !GlobalTimerNotExpired("FEAR","LOCALS")
  RandomNumLT(11,8)
  OR(7)
    See(NearestEnemyOf(Myself))
    See(LastHitter(Myself))
    See([GOODCUTOFF.0.0.BARD_ALL])
    See([GOODCUTOFF.0.0.DRUID_ALL])
    See([GOODCUTOFF.0.0.CLERIC_ALL])
    See([GOODCUTOFF.0.0.LONG_BOW])
    See([GOODCUTOFF.0.0.SORCERER])
  !Kit(LastSeenBy(Myself),CAVALIER)
  !StateCheck(LastSeenBy(Myself),STATE_PANIC)
  CheckStat(LastSeenBy(Myself),0,CLERIC_CHAOTIC_COMMANDS)
  CheckStat(LastSeenBy(Myself),0,WIZARD_RESIST_FEAR)
  !CheckStat(LastSeenBy(Myself),1,SCRIPTINGSTATE4)
THEN
  RESPONSE #100
    SetGlobalTimer("FEAR","LOCALS",7)
    ReallyForceSpell(LastSeenBy(Myself),VAMPIRE_FEAR)
END

IF
  ActionListEmpty()
  HaveSpell(WIZARD_SHADOW_DOOR)
  !GlobalTimerNotExpired("BPT","LOCALS")
  !StateCheck(Myself,STATE_INVISIBLE)
  !StateCheck(Myself,STATE_IMPROVEDINVISIBILITY)
  !StateCheck(Myself,STATE_POISONED)
  RandomNumLT(12,5)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_SHADOW_DOOR)
END

IF
  ActionListEmpty()
  HaveSpell(WIZARD_BREACH)
  !GlobalTimerNotExpired("BPT","LOCALS")
  RandomNumLT(13,6)
  OR(9)
    See(NearestEnemyOf(Myself))
    See(Player1)
    See(LastAttackerOf(Myself))
    See(LastHitter(Myself))
    See([GOODCUTOFF.0.0.BARD_ALL])
    See([GOODCUTOFF.0.0.CLERIC_ALL])
    See([GOODCUTOFF.0.0.DRUID_ALL])
    See([GOODCUTOFF.0.0.LONG_BOW])
    See([GOODCUTOFF.0.0.SORCERER])
  CheckStat(LastSeenBy(Myself),0,WIZARD_SPELL_TRAP)
  CheckStat(LastSeenBy(Myself),0,WIZARD_SPELL_SHIELD)
  OR(13)
    CheckStatGT(LastSeenBy(Myself),0,WIZARD_RESIST_FEAR)
    CheckStatGT(LastSeenBy(Myself),50,RESISTMAGICFIRE)
    CheckStatGT(LastSeenBy(Myself),50,RESISTMAGICCOLD)
    CheckStatGT(LastSeenBy(Myself),50,RESISTACID)
    CheckStatGT(LastSeenBy(Myself),50,RESISTELECTRICITY)
    CheckStatGT(LastSeenBy(Myself),0,WIZARD_PROTECTION_FROM_MAGIC_ENERGY)
    CheckStatGT(LastSeenBy(Myself),0,WIZARD_PROTECTION_FROM_THE_ELEMENTS)
    CheckStatGT(LastSeenBy(Myself),0,WIZARD_PROTECTION_FROM_ENERGY)
    CheckStatGT(LastSeenBy(Myself),0,WIZARD_PROTECTION_FROM_NORMAL_MISSILES)
    CheckStatGT(LastSeenBy(Myself),0,WIZARD_PROTECTION_FROM_NORMAL_WEAPONS)
    CheckStatGT(LastSeenBy(Myself),0,WIZARD_PROTECTION_FROM_MAGIC_WEAPONS)
    CheckStatGT(LastSeenBy(Myself),3,STONESKINS)
    CheckStatGT(LastSeenBy(Myself),0,SCRIPTINGSTATE5)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_BREACH)
END

IF
  ActionListEmpty()
  HaveSpell(WIZARD_RUBY_RAY_OF_REVERSAL)
  !GlobalTimerNotExpired("BPT","LOCALS")
  RandomNumLT(14,8)
  OR(9)
    See(NearestEnemyOf(Myself))
    See(Player1)
    See(LastAttackerOf(Myself))
    See(LastHitter(Myself))
    See([GOODCUTOFF.0.0.BARD_ALL])
    See([GOODCUTOFF.0.0.CLERIC_ALL])
    See([GOODCUTOFF.0.0.DRUID_ALL])
    See([GOODCUTOFF.0.0.LONG_BOW])
    See([GOODCUTOFF.0.0.SORCERER])
  OR(7)
    CheckStatGT(LastSeenBy(Myself),0,WIZARD_SPELL_TURNING)
    CheckStatGT(LastSeenBy(Myself),0,WIZARD_SPELL_DEFLECTION)
    CheckStatGT(LastSeenBy(Myself),0,MINORGLOBE)
    CheckStatGT(LastSeenBy(Myself),0,SHIELDGLOBE)
    CheckStatGT(LastSeenBy(Myself),0,WIZARD_SPELL_IMMUNITY)
    CheckStatGT(LastSeenBy(Myself),0,WIZARD_SPELL_SHIELD)
    CheckStatGT(LastSeenBy(Myself),0,WIZARD_SPELL_TRAP)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_RUBY_RAY_OF_REVERSAL)
END

IF
  ActionListEmpty()
  HaveSpell(WIZARD_FIRE_SHIELD_BLUE)
  !GlobalTimerNotExpired("BPT","LOCALS")
  CheckStat(Myself,0,WIZARD_PROTECTION_FROM_MAGIC_WEAPONS)
  CheckStat(Myself,0,WIZARD_FIRE_SHIELD)
  RandomNumLT(15,5)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_FIRE_SHIELD_BLUE)
END

IF
  ActionListEmpty()
  HaveSpell(WIZARD_REMOVE_MAGIC)
  !GlobalTimerNotExpired("BPT","LOCALS")
  RandomNumLT(16,9)
  OR(9)
    See(NearestEnemyOf(Myself))
    See(Player1)
    See(LastAttackerOf(Myself))
    See(LastHitter(Myself))
    See([GOODCUTOFF.0.0.BARD_ALL])
    See([GOODCUTOFF.0.0.CLERIC_ALL])
    See([GOODCUTOFF.0.0.DRUID_ALL])
    See([GOODCUTOFF.0.0.LONG_BOW])
    See([GOODCUTOFF.0.0.SORCERER])
  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)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_REMOVE_MAGIC)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_ANIMATE_DEAD)
  See(ThirdNearestEnemyOf(Myself))
  !GlobalTimerNotExpired("BPT","LOCALS")
  NumCreatureVsPartyLT([0.0.0.0.0.SUMMONED],7)
  RandomNumLT(17,7)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_ANIMATE_DEAD)
END

IF
  ActionListEmpty()
  HaveSpell(COM_DRUID_TEMPERATURE_COLD)
  !GlobalTimerNotExpired("BPT","LOCALS")
  See(NearestEnemyOf(Myself))
  RandomNumLT(18,6)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),COM_DRUID_TEMPERATURE_COLD)
END

IF
  See(NearestEnemyOf(Myself))
  False()
THEN
  RESPONSE #100
    Continue()
END

IF
  RandomNumLT(31,21)
  OR(9)
    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.CLERIC_ALL.0.0.MASK_GOOD])
    See([0.0.0.PALADIN_ALL])
  RandomNumLT(27,21)
  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(7)
    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.PALADIN_ALL])
    See([PC.0.0.CLERIC_ALL])
  RandomNumLT(30,18)
  See(Protagonist)
  RandomNumLT(26,14)
  OR(3)
    See([GOODCUTOFF.0.0.DRUID_ALL])
    See([GOODCUTOFF.0.0.PALADIN_ALL])
    See([GOODCUTOFF.0.0.CLERIC_ALL])
  RandomNumLT(28,15)
  OR(3)
    See([GOODCUTOFF.0.0.MONK])
    See([GOODCUTOFF.0.0.BARD_ALL])
    See([GOODCUTOFF.0.0.THIEF_ALL])
  RandomNumLT(24,13)
  OR(3)
    See(StrongestOf)
    See(BestAC)
    See(LeastDamagedOf)
  RandomNumLT(25,13)
  See(WeakestOf)
  RandomNumLT(23,13)
  See(WorstAC)
  RandomNumLT(22,12)
  See(MostDamagedOf)
  RandomNumLT(32,25)
  OR(3)
    See(TenthNearest([GOODCUTOFF.0.0.LONG_BOW]))
    See(TenthNearest([GOODCUTOFF.0.0.CLERIC_ALL]))
    See(TenthNearest([GOODCUTOFF.0.0.PALADIN_ALL]))
  RandomNumLT(20,16)
  !See(TenthNearest([0.0.0.0.0.0.LAWFUL_GOOD]))
  False()
THEN
  RESPONSE #100
    Continue()
END

IF
  Allegiance(LastSeenBy(Myself),EVILCUTOFF)
THEN
  RESPONSE #100
END

IF
  ActionListEmpty()
  StateCheck(Myself,STATE_INVISIBLE)
  Delay(8)
THEN
  RESPONSE #80
    AttackReevaluate(LastSeenBy(Myself),30)
  RESPONSE #20
    Continue()
END

IF
  StateCheck(Myself,STATE_INVISIBLE)
THEN
  RESPONSE #30
    Continue()
END

IF
  ActionListEmpty()
  !GlobalTimerNotExpired("BPT","LOCALS")
  HaveSpell(WIZARD_TIME_STOP)
  Global("BP_Special","LOCALS",0)
  RandomNumLT(36,26)
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()
  HaveSpell(WIZARD_NPC_SYMBOL_STUN)
  !GlobalTimerNotExpired("BPT","LOCALS")
  CheckStat(LastSeenBy(Myself),0,WIZARD_SPELL_TURNING)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !Range(LastSeenBy(Myself),5)
  RandomNumLT(37,25)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_NPC_SYMBOL_STUN)
END

IF
  ActionListEmpty()
  HaveSpell(WIZARD_NPC_SYMBOL_FEAR)
  !GlobalTimerNotExpired("BPT","LOCALS")
  CheckStat(LastSeenBy(Myself),0,WIZARD_SPELL_TURNING)
  !Range(LastSeenBy(Myself),5)
  !StateCheck(LastSeenBy(Myself),STATE_PANIC)
  RandomNumLT(38,23)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_NPC_SYMBOL_FEAR)
END

IF
  ActionListEmpty()
  HaveSpell(WIZARD_POWER_WORD_SILENCE)
  !GlobalTimerNotExpired("BPT","LOCALS")
  CheckStat(LastSeenBy(Myself),0,WIZARD_SPELL_TURNING)
  !StateCheck(LastSeenBy(Myself),STATE_SILENCED)
  RandomNumLT(39,27)
  OR(6)
    Class(LastSeenBy(Myself),DRUID_ALL)
    Class(LastSeenBy(Myself),BARD_ALL)
    Class(LastSeenBy(Myself),CLERIC_ALL)
    Class(LastSeenBy(Myself),LONG_BOW)
    Class(LastSeenBy(Myself),SORCERER)
    InPartySlot(LastSeenBy(Myself),0)
  CheckStat(LastSeenBy(Myself),0,WIZARD_SPELL_TURNING)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_POWER_WORD_SILENCE)
END

IF
  ActionListEmpty()
  HaveSpell(WIZARD_POWER_WORD_BLIND)
  CheckStat(LastSeenBy(Myself),0,WIZARD_SPELL_TURNING)
  !StateCheck(LastSeenBy(Myself),STATE_BLIND)
  !Range(LastSeenBy(Myself),5)
  HPLT(LastSeenBy(Myself),90)
  RandomNumLT(40,25)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_POWER_WORD_BLIND)
END

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

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

IF
  ActionListEmpty()
  HaveSpell(COM_PRIEST_CLOUD_OF_PESTILENCE)
  !GlobalTimerNotExpired("BPT","LOCALS")
  RandomNumLT(45,31)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),COM_PRIEST_CLOUD_OF_PESTILENCE)
END

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

IF
  ActionListEmpty()
  HaveSpell(COM_DRUID_VITALITY_DRAIN)
  !GlobalTimerNotExpired("BPT","LOCALS")
  CheckStat(LastSeenBy(Myself),0,WIZARD_SPELL_TURNING)
  OR(5)
    Class(LastSeenBy(Myself),FIGHTER_ALL)
    Class(LastSeenBy(Myself),PALADIN_ALL)
    Class(LastSeenBy(Myself),RANGER_ALL)
    Class(LastSeenBy(Myself),THIEF_ALL)
    Class(LastSeenBy(Myself),MONK)
  RandomNumLT(44,27)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),COM_DRUID_VITALITY_DRAIN)
END

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

IF
  ActionListEmpty()
  HaveSpell(COM_ICE_SHARD)
  !GlobalTimerNotExpired("BPT","LOCALS")
  CheckStat(LastSeenBy(Myself),0,WIZARD_SPELL_TURNING)
  CheckStatLT(LastSeenBy(Myself),51,RESISTMAGICCOLD)
  RandomNumLT(46,24)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),COM_ICE_SHARD)
END

IF
  ActionListEmpty()
  HaveSpell(CLERIC_POISON)
  !GlobalTimerNotExpired("BPT","LOCALS")
  CheckStat(LastSeenBy(Myself),0,WIZARD_SPELL_TURNING)
  !StateCheck(LastSeenBy(Myself),STATE_POISONED)
  RandomNumLT(47,24)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),CLERIC_POISON)
END

IF
  ActionListEmpty()
  HPPercentLT(Myself,25)
  Range(LastHitter(Myself),10)
  !GlobalTimerNotExpired("BPW","LOCALS")
THEN
  RESPONSE #30
    Shout(124)
    SetGlobalTimer("BPW","LOCALS",10)
    RunAwayFrom(LastHitter(Myself),40)
  RESPONSE #30
    Shout(124)
    SetGlobalTimer("BPW","LOCALS",10)
    AttackReevaluate(LastHitter(Myself),15)
  RESPONSE #40
    Shout(123)
    SetGlobalTimer("BPW","LOCALS",10)
    AttackReevaluate(LastSeenBy(Myself),15)
END

IF
  ActionListEmpty()
  CheckStatGT(LastSeenBy(Myself),10,WIZARD_GREATER_MALISON)
  CheckStatLT(Myself,11,WIZARD_GREATER_MALISON)
THEN
  RESPONSE #100
    EquipRanged()
    AttackOneRound(LastSeenBy(Myself))
END

IF
  ActionListEmpty()
  OR(3)
    !Range(NearestEnemyOf(Myself),5)
    CheckStatGT(NearestEnemyOf(Myself),0,CLERIC_BLADE_BARRIER)
    CheckStatGT(LastSeenBy(Myself),0,WIZARD_FIRE_SHIELD)
THEN
  RESPONSE #100
    EquipRanged()
    AttackOneRound(LastSeenBy(Myself))
END

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

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

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

