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

IF
  OR(2)
    Heard([NEUTRAL],79)
    Heard([EVILCUTOFF],79)
  Allegiance(Myself,NEUTRAL)
  !Global("BP_PlotMan","LOCALS",1)
THEN
  RESPONSE #100
    Enemy()
    Continue()
END

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

IF
  Global("BPIM","LOCALS",0)
  CheckStat(Myself,2,127)
  See([EVILCUTOFF.0.0.LONG_BOW.0.ILLUSIONARY])
  Range(LastSeenBy(Myself),2)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    SetGlobal("BPIM","LOCALS",1)
    ReallyForceSpell(Myself,WIZARD_INVISIBILITY)
    ActionOverride(LastSeenBy(Myself),DisplayStringHead(Myself,25944))  // ~Project Image~
    ActionOverride(LastSeenBy(Myself),ChangeAIScript("BEHHIV02",CLASS))
    ActionOverride(LastSeenBy(Myself),RemoveSpell(WIZARD_PROJECT_IMAGE))
    ChangeGender(LastSeenBy(Myself),EXTRA8)
    ChangeSpecifics(LastSeenBy(Myself),NEEDS_BREACH)
    RunAwayFrom(LastSeenBy(Myself),20)
    SmallWait(20)
    ClearActions(Myself)
    SetInterrupt(TRUE)
END

IF
  GlobalTimerNotExpired("BPCHASE","LOCALS")
  Global("BPCHASER","LOCALS",1)
  OR(2)
    See([GOODCUTOFF])
    See(LastHitter(Myself))
  !General(Myself,HUMANOID)
  !General(Myself,GIANTHUMANOID)
THEN
  RESPONSE #10
    DisplayStringHead(Myself,@0)
    SetGlobal("BPCHASER","LOCALS",0)
    AttackReevaluate(LastSeenBy(Myself),15)
  RESPONSE #20
    DisplayStringHead(Myself,@0)
    SetGlobal("BPCHASER","LOCALS",0)
    ForceSpell(Myself,TELEKINESIS)
    SetGlobal("BP_BehTel","LOCALS",1)
    DisplayStringHead(Myself,@1)
    ChangeSpecifics(Myself,CALLED_FOR_BOULDER)
  RESPONSE #15
    FaceObject(LastSeenBy(Myself))
    ForceSpell(LastSeenBy(Myself),HIVE_MOTHER_ANTIMAGIC_RAY)
    SetGlobalTimer("RAY","LOCALS",3)
    IncrementGlobal("BeholdRay","LOCALS",1)
  RESPONSE #10
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_NPC_SYMBOL_STUN)
  RESPONSE #10
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_MAZE)
  RESPONSE #5
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    IncrementGlobal("mmiss","LOCALS",1)
    ForceSpell(LastSeenBy(Myself),BEHOLDER_MAGIC_MISSILE)
  RESPONSE #10
    FaceObject(LastSeenBy(Myself))
    ForceSpell(LastSeenBy(Myself),BEHOLDER_PARALYZATION)
    SetGlobalTimer("par","LOCALS",2)
    IncrementGlobal("BeholdParal","LOCALS",1)
  RESPONSE #100
    FaceObject(LastSeenBy(Myself))
    ForceSpell(LastSeenBy(Myself),BEHOLDER_FEAR)
    SetGlobalTimer("fear","LOCALS",4)
    IncrementGlobal("BeFear","LOCALS",1)
  RESPONSE #5
    FaceObject(LastSeenBy(Myself))
    ForceSpell(LastSeenBy(Myself),HIVE_MOTHER_CAUSE_SERIOUS_WOUNDS)
    SetGlobalTimer("wnd","LOCALS",2)
    IncrementGlobal("BeWound","LOCALS",1)
  RESPONSE #10
    FaceObject(LastSeenBy(Myself))
    ForceSpell(LastSeenBy(Myself),BEHOLDER_FLESH_TO_STONE)
    IncrementGlobal("BeStone","LOCALS",1)
    SetGlobalTimer("stn","LOCALS",8)
  RESPONSE #10
    FaceObject(LastSeenBy(Myself))
    ForceSpell(LastSeenBy(Myself),BEHOLDER_DEATH_RAY)
    SetGlobalTimer("dth","LOCALS",10)
    IncrementGlobal("BeDeath","LOCALS",1)
  RESPONSE #10
    FaceObject(LastSeenBy(Myself))
    ForceSpell(LastSeenBy(Myself),BEHOLDER_DOMINATION)
    SetGlobalTimer("dom","LOCALS",3)
    IncrementGlobal("BeDom","LOCALS",1)
  RESPONSE #10
    FaceObject(LastSeenBy(Myself))
    ForceSpell(LastSeenBy(Myself),BEHOLDER_SLOW)
    SetGlobalTimer("slo","LOCALS",8)
    IncrementGlobal("BeSlow","LOCALS",1)

END

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

IF
  !Allegiance(Myself,ENEMY)
  !Allegiance(Myself,PC)
  OR(2)
    AttackedBy([GOODCUTOFF],DEFAULT)
    Allegiance(LastAttackerOf(Myself),GOODCUTOFF)
THEN
  RESPONSE #100
    Enemy()
    Shout(151)
    Continue()
END

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

IF
  ActionListEmpty()
  OR(4)
    CheckStat(Myself,11,180)
    CheckStat(Myself,16,180)
    CheckStat(Myself,17,180)
    CheckStat(Myself,20,180)
THEN
  RESPONSE #100
    DisplayStringHead(Myself,@1)
    SpellNoDec(Myself,CLERIC_ZONE_OF_SWEET_AIR)
END

IF
  TookDamage()
  Global("BPCHASER","LOCALS",0)
  !See(LastHitter(Myself))
  !See([GOODCUTOFF])
THEN
  RESPONSE #30
    DisplayStringHead(Myself,@3)
    SetGlobalTimer("BPCHASE","LOCALS",12)
    SetGlobal("BPCHASER","LOCALS",1)
    MoveToObject(LastHitter(Myself))
  RESPONSE #15
    DisplayStringHead(Myself,@3)
    SetGlobalTimer("BPCHASE","LOCALS",13)
    SetGlobal("BPCHASER","LOCALS",1)
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    ForceSpell(Myself,WIZARD_STONE_SKIN)
    RemoveSpell(WIZARD_STONE_SKIN)
    Wait(1)
    MoveToObject(LastHitter(Myself))
  RESPONSE #15
    DisplayStringHead(Myself,@3)
    SetGlobalTimer("BPCHASE","LOCALS",15)
    SetGlobal("BPCHASER","LOCALS",1)
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    ForceSpell(Myself,WIZARD_TRUE_SIGHT)
    RemoveSpell(WIZARD_TRUE_SIGHT)
    Wait(1)
    MoveToObject(LastHitter(Myself))
  RESPONSE #15
    DisplayStringHead(Myself,@3)
    SetGlobalTimer("BPCHASE","LOCALS",15)
    SetGlobal("BPCHASER","LOCALS",1)
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    ForceSpell(Myself,WIZARD_PROTECTION_FROM_THE_ELEMENTS)
    RemoveSpell(WIZARD_PROTECTION_FROM_THE_ELEMENTS)
    Wait(1)
    MoveToObject(LastHitter(Myself))
  RESPONSE #15
    DisplayStringHead(Myself,@3)
    SetGlobalTimer("BPCHASE","LOCALS",13)
    SetGlobal("BPCHASER","LOCALS",1)
    IncrementGlobal("TURN","LOCALS",1)
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    ReallyForceSpell(Myself,BEHOLDER_SPELL_TURNING)
    Wait(1)
    MoveToObject(LastHitter(Myself))
  RESPONSE #30
    DisplayStringHead(Myself,@3)
    RunAwayFrom(LastHitter(Myself),45)
END

IF
  CheckStatGT(Myself,10,180)
  CheckStatGT(Myself,5,INT)
  OR(2)
    See(LastAttackerOf(Myself))
    See(LastHitter(Myself))
  CheckStatLT(LastSeenBy(Myself),11,180)
  !GlobalTimerNotExpired("BPCHASE","LOCALS")
THEN
  RESPONSE #100
    SetGlobalTimer("BPCHASE","LOCALS",TWO_ROUNDS)
    DisplayStringHead(Myself,@4)
    EquipMostDamagingMelee()
    MoveToObject(LastSeenBy(Myself))
    AttackOneRound(LastSeenBy(Myself))
END

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

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

//////////////CLOUDLIKE  EFFECTS//////////////////////

IF
  CheckStat(Myself,11,180) // I'm in a stinking cloud
  CheckStatGT(Myself,5,INT)
  !StateCheck(Myself,STATE_SLEEPING) // not yet affected
  CheckStatGT(Myself,4,SAVEVSSPELL) //and I got a reasonable chance of failing a save throw (25%+)
  OR(2)
    Detect(NearestEnemyOfType([0.0.MORNINGSTAR.FAIRY_NYMPH.65]))
    Detect(NearestMyGroupOfType([0.0.MORNINGSTAR.FAIRY_NYMPH.65]))
  Range(LastSeenBy(Myself),16)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    RunAwayFrom(LastSeenBy(Myself),30)
    SetInterrupt(TRUE)
END

IF
  CheckStatGT(Myself,11,180) // I'm in a web,entangle, or grease spell
  CheckStatLT(Myself,15,180)
  CheckStatGT(Myself,5,INT)
  CheckStatLT(Myself,1,131) // I don't have free action
  CheckStatLT(Myself,1,WEB) //and not webbed up
  CheckStatLT(Myself,1,ENTANGLE) //nor entangled --I can move
  CheckStatGT(Myself,4,SAVEVSSPELL) //and I got a reasonable chance of failing a save throw (25%+)
  OR(3)
    Detect([0.0.MORNINGSTAR.FAIRY_NYMPH.65])
    Detect(NearestEnemyOfType([0.0.MORNINGSTAR.FAIRY_NYMPH.65]))
    Detect(NearestMyGroupOfType([0.0.MORNINGSTAR.FAIRY_NYMPH.65]))
  Range(LastSeenBy(Myself),16)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    RunAwayFrom(LastSeenBy(Myself),30)
    SetInterrupt(TRUE)
END

IF
  CheckStat(Myself,15,180) // I'm in an Ice Storm
  CheckStatGT(Myself,5,INT)
  CheckStatLT(Myself,100,RESISTCOLD) // Not Immune
  OR(3)
    Detect([0.0.MORNINGSTAR.FAIRY_NYMPH.65])
    Detect(NearestEnemyOfType([0.0.MORNINGSTAR.FAIRY_NYMPH.65]))
    Detect(NearestMyGroupOfType([0.0.MORNINGSTAR.FAIRY_NYMPH.65]))
  Range(LastSeenBy(Myself),16)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    RunAwayFrom(LastSeenBy(Myself),30)
    SetInterrupt(TRUE)
END

IF
  CheckStat(Myself,16,180) // I'm in a Cloudkill or Death Fog
  CheckStatGT(Myself,5,INT)
  CheckStatLT(Myself,100,RESISTPOISON) // Not Immune
  OR(3)
    Detect([0.0.MORNINGSTAR.FAIRY_NYMPH.65])
    Detect(NearestEnemyOfType([0.0.MORNINGSTAR.FAIRY_NYMPH.65]))
    Detect(NearestMyGroupOfType([0.0.MORNINGSTAR.FAIRY_NYMPH.65]))
  Range(LastSeenBy(Myself),16)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    RunAwayFrom(LastSeenBy(Myself),30)
    SetInterrupt(TRUE)
END

IF
  CheckStat(Myself,17,180) // I'm in a Death Fog
  CheckStatGT(Myself,5,INT)
  CheckStatLT(Myself,100,RESISTACID) // Not Immune
  OR(3)
    Detect([0.0.MORNINGSTAR.FAIRY_NYMPH.65])
    Detect(NearestEnemyOfType([0.0.MORNINGSTAR.FAIRY_NYMPH.65]))
    Detect(NearestMyGroupOfType([0.0.MORNINGSTAR.FAIRY_NYMPH.65]))
  Range(LastSeenBy(Myself),16)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    RunAwayFrom(LastSeenBy(Myself),30)
    SetInterrupt(TRUE)
END

IF
  CheckStat(Myself,18,180) // Incendiary Cloud, Meteor Swarm or Fire Storm -- bad stuff
  CheckStatGT(Myself,5,INT)
  CheckStatLT(Myself,100,RESISTFIRE) // Not Immune
  OR(3)
    Detect([0.0.MORNINGSTAR.FAIRY_NYMPH.65])
    Detect(NearestEnemyOfType([0.0.MORNINGSTAR.FAIRY_NYMPH.65]))
    Detect(NearestMyGroupOfType([0.0.MORNINGSTAR.FAIRY_NYMPH.65]))
  Range(LastSeenBy(Myself),16)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    RunAwayFrom(LastSeenBy(Myself),30)
    SetInterrupt(TRUE)
END

// This is to try and keep them from going back in to whomp somebody
IF
  CheckStatLT(Myself,11,180) // No longer in the cloud effects
  CheckStatGT(Myself,5,INT)
  OR(3)
    Detect([0.0.MORNINGSTAR.FAIRY_NYMPH.65])
    Detect(NearestEnemyOfType([0.0.MORNINGSTAR.FAIRY_NYMPH.65]))
    Detect(NearestMyGroupOfType([0.0.MORNINGSTAR.FAIRY_NYMPH.65]))
  !Range(LastSeenBy(Myself),16)
  Exists([EVILCUTOFF])
  !Range(NearestEnemyOf(Myself),2)
THEN
  RESPONSE #100
    EquipRanged()  //use your bow, then
    SmallWait(3)
    Continue()
END

//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////

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

IF
  Global("BPIM","LOCALS",0)
  CheckStat(Myself,2,127)
  See([EVILCUTOFF.0.0.LONG_BOW.0.ILLUSIONARY])
  Range(LastSeenBy(Myself),2)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    SetGlobal("BPIM","LOCALS",1)
    ReallyForceSpell(Myself,WIZARD_INVISIBILITY)
    ActionOverride(LastSeenBy(Myself),DisplayStringHead(Myself,25944))  // ~Project Image~
    ActionOverride(LastSeenBy(Myself),ChangeAIScript("BEHHIV02",CLASS))
    ActionOverride(LastSeenBy(Myself),RemoveSpell(WIZARD_PROJECT_IMAGE))
    ChangeGender(LastSeenBy(Myself),EXTRA8)
    ChangeSpecifics(LastSeenBy(Myself),NEEDS_BREACH)
    RunAwayFrom(LastSeenBy(Myself),20)
    SmallWait(20)
    ClearActions(Myself)
    SetInterrupt(TRUE)
END

IF
  Global("BP_ShBald","LOCALS",0)
  PartyHasItem("WA2SHIEL")  // ~Shield of Balduran~
THEN
  RESPONSE #100
    SetGlobalTimer("BALD","LOCALS",7)
    SetGlobal("BP_ShBald","LOCALS",1)
END

IF
  Global("BP_ShBald","LOCALS",1)
  GlobalTimerExpired("BALD","LOCALS")
THEN
  RESPONSE #100
    SetGlobal("BP_ShBald","LOCALS",2)
END

IF
  Global("BP_BehTel","LOCALS",0)
  !Global("CLON","LOCALS",2)
THEN
  RESPONSE #100
    ReallyForceSpell(Myself,TELEKINESIS)
    SetGlobal("BP_BehTel","LOCALS",1)
END

IF
  CheckStat(Myself,2,127)
  Exists([EVILCUTOFF.0.0.0.NEEDS_BREACH.EXTRA8])
THEN
  RESPONSE #25
    ChangeSpecifics(Myself,CALLED_FOR_BOULDER)
  RESPONSE #75
END


IF
  ActionListEmpty()
  HPLT(Myself,40)
  HaveSpell(CLERIC_HEAL)
  !GlobalTimerNotExpired("BPT","LOCALS")
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    SetInterrupt(FALSE)
    Spell(Myself,CLERIC_HEAL)
    SetInterrupt(TRUE)
END

IF
  ActionListEmpty()
  Global("BP_ShBald","LOCALS",2)
  HasItemEquiped("WA2SHIEL",Player1)
  !GlobalTimerNotExpired("SHIELD","LOCALS")
  !Specifics(Myself,CALLED_FOR_BOULDER)
  GlobalLT("BP_TelSum","LOCALS",40)
  See(Player1)
THEN
  RESPONSE #90
    DisplayStringHead(Myself,100660)  // @1
    ChangeSpecifics(Myself,CALLED_FOR_BOULDER)
    SetGlobalTimer("SHIELD","LOCALS",3)
    IncrementGlobal("BP_TelSum","LOCALS",1)
  RESPONSE #35
    ReallyForceSpell(Player1,HIVE_MOTHER_SUMMON_GAUTH)
    SetGlobalTimer("SHIELD","LOCALS",ONE_ROUND)
    IncrementGlobal("BP_TelSum","LOCALS",3)
  RESPONSE #80
    Continue()
END

IF
  Global("BP_ShBald","LOCALS",2)
  HasItemEquiped("WA2SHIEL",Player2)
  !GlobalTimerNotExpired("SHIELD","LOCALS")
  !Specifics(Myself,CALLED_FOR_BOULDER)
  GlobalLT("BP_TelSum","LOCALS",40)
  See(Player2)
THEN
  RESPONSE #90
    DisplayStringHead(Myself,100660)  // @1
    ChangeSpecifics(Myself,CALLED_FOR_BOULDER)
    SetGlobalTimer("SHIELD","LOCALS",3)
    IncrementGlobal("BP_TelSum","LOCALS",1)
  RESPONSE #35
    ReallyForceSpell(Player2,HIVE_MOTHER_SUMMON_GAUTH)
    SetGlobalTimer("SHIELD","LOCALS",ONE_ROUND)
    IncrementGlobal("BP_TelSum","LOCALS",3)
  RESPONSE #80
    Continue()
END

IF
  Global("BP_ShBald","LOCALS",2)
  HasItemEquiped("WA2SHIEL",Player3)
  !GlobalTimerNotExpired("SHIELD","LOCALS")
  !Specifics(Myself,CALLED_FOR_BOULDER)
  GlobalLT("BP_TelSum","LOCALS",40)
  See(Player3)
THEN
  RESPONSE #90
    DisplayStringHead(Myself,100660)  // @1
    ChangeSpecifics(Myself,CALLED_FOR_BOULDER)
    SetGlobalTimer("SHIELD","LOCALS",3)
    IncrementGlobal("BP_TelSum","LOCALS",1)
  RESPONSE #35
    ReallyForceSpell(Player3,HIVE_MOTHER_SUMMON_GAUTH)
    SetGlobalTimer("SHIELD","LOCALS",ONE_ROUND)
    IncrementGlobal("BP_TelSum","LOCALS",3)
  RESPONSE #80
    Continue()
END

IF
  Global("BP_ShBald","LOCALS",2)
  HasItemEquiped("WA2SHIEL",Player4)
  !GlobalTimerNotExpired("SHIELD","LOCALS")
  !Specifics(Myself,CALLED_FOR_BOULDER)
  GlobalLT("BP_TelSum","LOCALS",40)
  See(Player4)
THEN
  RESPONSE #90
    DisplayStringHead(Myself,100660)  // @1
    ChangeSpecifics(Myself,CALLED_FOR_BOULDER)
    SetGlobalTimer("SHIELD","LOCALS",3)
    IncrementGlobal("BP_TelSum","LOCALS",1)
  RESPONSE #35
    ReallyForceSpell(Player4,HIVE_MOTHER_SUMMON_GAUTH)
    SetGlobalTimer("SHIELD","LOCALS",ONE_ROUND)
    IncrementGlobal("BP_TelSum","LOCALS",3)
  RESPONSE #80
    Continue()
END

IF
  Global("BP_ShBald","LOCALS",2)
  HasItemEquiped("WA2SHIEL",Player5)
  !GlobalTimerNotExpired("SHIELD","LOCALS")
  !Specifics(Myself,CALLED_FOR_BOULDER)
  GlobalLT("BP_TelSum","LOCALS",40)
  See(Player5)
THEN
  RESPONSE #90
    DisplayStringHead(Myself,100660)  // @1
    ChangeSpecifics(Myself,CALLED_FOR_BOULDER)
    SetGlobalTimer("SHIELD","LOCALS",3)
    IncrementGlobal("BP_TelSum","LOCALS",1)
  RESPONSE #35
    ReallyForceSpell(Player5,HIVE_MOTHER_SUMMON_GAUTH)
    SetGlobalTimer("SHIELD","LOCALS",ONE_ROUND)
    IncrementGlobal("BP_TelSum","LOCALS",3)
  RESPONSE #80
    Continue()
END

IF
  Global("BP_ShBald","LOCALS",2)
  HasItemEquiped("WA2SHIEL",Player6)
  !GlobalTimerNotExpired("SHIELD","LOCALS")
  !Specifics(Myself,CALLED_FOR_BOULDER)
  GlobalLT("BP_TelSum","LOCALS",40)
  See(Player6)
THEN
  RESPONSE #90
    DisplayStringHead(Myself,100660)  // @1
    ChangeSpecifics(Myself,CALLED_FOR_BOULDER)
    SetGlobalTimer("SHIELD","LOCALS",3)
    IncrementGlobal("BP_TelSum","LOCALS",1)
  RESPONSE #35
    ReallyForceSpell(Player6,HIVE_MOTHER_SUMMON_GAUTH)
    SetGlobalTimer("SHIELD","LOCALS",ONE_ROUND)
    IncrementGlobal("BP_TelSum","LOCALS",3)
  RESPONSE #80
    Continue()
END

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

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

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

IF
  RandomNumLT(59,13)
  HaveSpell(WIZARD_ABSOLUTE_IMMUNITY)
  !GlobalTimerNotExpired("BPT","LOCALS")
  CheckStat(Myself,0,128)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_ABSOLUTE_IMMUNITY)
END

IF
  RandomNumLT(50,6)
  HaveSpell(WIZARD_PROTECTION_FROM_ENERGY)
  !GlobalTimerNotExpired("BPT","LOCALS")
  OR(2)
    Range(NearestEnemyOf(Myself),6)
    AttackedBy([GOODCUTOFF],DEFAULT)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_PROTECTION_FROM_ENERGY)
END

IF
  RandomNumLT(70,11)
  GlobalTimerNotExpired("BPT","LOCALS")
  GlobalLT("TURN","LOCALS",3)
  CheckStat(Myself,0,129)
THEN
  RESPONSE #100
    IncrementGlobal("TURN","LOCALS",1)
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    ReallyForceSpell(Myself,BEHOLDER_SPELL_TURNING)
END

IF
  RandomNumLT(49,6)
  HaveSpell(WIZARD_PROTECTION_FROM_MAGIC_ENERGY)
  !GlobalTimerNotExpired("BPT","LOCALS")
  CheckStat(Myself,0,126)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_PROTECTION_FROM_MAGIC_ENERGY)
END

IF
  RandomNumLT(60,11)
  HaveSpell(NPC_BLADE_BARRIER)
  !GlobalTimerNotExpired("BPT","LOCALS")
  CheckStat(Myself,0,121)
  Range(SecondNearestEnemyOf(Myself),6)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,NPC_BLADE_BARRIER)
END

IF
  RandomNumLT(51,11)
  HaveSpell(CLERIC_PHYSICAL_MIRROR)
  !GlobalTimerNotExpired("BPT","LOCALS")
  CheckStat(Myself,0,122)
  OR(2)
    CheckStatGT(Myself,0,121)
    AttackedBy([GOODCUTOFF],RANGED)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,CLERIC_PHYSICAL_MIRROR)
END

IF
  RandomNumLT(63,9)
  HaveSpell(WIZARD_PROJECT_IMAGE)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("SNAFU","LOCALS",0)
  CheckStat(Myself,0,127)
THEN
  RESPONSE #100
    ReallyForceSpell(Myself,WIZARD_INVISIBILITY)
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_PROJECT_IMAGE)
END

IF
  RandomNumLT(62,11)
  HaveSpell(WIZARD_SPELL_SHIELD)
  !GlobalTimerNotExpired("BPT","LOCALS")
  CheckStat(Myself,0,177)
  OR(3)
    CheckStatGT(Myself,0,128)
    CheckStatGT(Myself,0,126)
    CheckStatGT(Myself,3,STONESKINS)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_SPELL_SHIELD)
END

IF
  See([GOODCUTOFF.0.0.0.0.SUMMONED])
  GlobalLT("summon","LOCALS",3)
  !GlobalTimerNotExpired("summ","LOCALS")
  RandomNum(3,1)
THEN
  RESPONSE #100
    FaceObject(LastSeenBy(Myself))
    ForceSpell(LastSeenBy(Myself),BEHOLDER_PARALYZATION)
    ReallyForceSpell(LastSeenBy(Myself),WIZARD_DEATH_SPELL)
    IncrementGlobal("summon","LOCALS",1)
    SetGlobalTimer("summ","LOCALS",8)
END

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

IF
  RandomNumLT(31,21)
  OR(6)
    See(NearestEnemyOf(Myself))
    See(WeakestOf)
    See(WorstAC)
    See(MostDamagedOf)
    See(LastAttackerOf(Myself))
    See(LastHitter(Myself))
  RandomNumLT(28,22)
  OR(4)
    See([GOODCUTOFF.0.0.0.0.SUMMONED_DEMON])
    See([GOODCUTOFF.0.0.0.0.SUMMONED])
    See([GOODCUTOFF.0.0.0.SIMULACRUM])
    See([GOODCUTOFF.0.0.0.0.ILLUSIONARY])
  RandomNumLT(29,23)
  OR(7)
    See([PC.0.0.RANGER_ALL])
    See([PC.0.0.PALADIN_ALL])
    See([PC.0.0.BARD_ALL])
    See([PC.0.0.DRUID_ALL])
    See([PC.0.0.CLERIC_ALL])
    See([PC.0.0.LONG_BOW])
    See([PC.0.0.SORCERER])
  RandomNumLT(30,16)
  See(Protagonist)
  RandomNumLT(26,10)
  OR(4)
    See([GOODCUTOFF.0.0.RANGER_ALL])
    See([GOODCUTOFF.0.0.DRUID_ALL])
    See([GOODCUTOFF.0.0.PALADIN_ALL])
    See([GOODCUTOFF.0.0.CLERIC_ALL])
  RandomNumLT(27,10)
  OR(3)
    See([GOODCUTOFF.0.0.MONK])
    See([GOODCUTOFF.0.0.BARD_ALL])
    See([GOODCUTOFF.0.0.THIEF_ALL])
  RandomNumLT(24,9)
  OR(3)
    See(StrongestOf)
    See(BestAC)
    See(LeastDamagedOf)
  RandomNumLT(25,9)
  See(WeakestOf)
  RandomNumLT(23,8)
  See(WorstAC)
  RandomNumLT(21,8)
  See(MostDamagedOf)
  RandomNumLT(32,11)
  OR(2)
    See(TenthNearest([GOODCUTOFF.0.0.LONG_BOW]))
    See(TenthNearest([GOODCUTOFF.0.0.SORCERER]))
  RandomNumLT(20,8)
  See(TenthNearestEnemyOf(Myself))
  False()
THEN
  RESPONSE #100
    Continue()
END

IF
  OR(3)
    Allegiance(LastSeenBy(Myself),ENEMY)
    Allegiance(LastSeenBy(Myself),EVILCUTOFF)
    Allegiance(LastSeenBy(Myself),GOODBUTRED)
THEN
  RESPONSE #100
END

IF
  GlobalLT("BeDom","LOCALS",12)
  !GlobalTimerNotExpired("dom","LOCALS")
THEN
  RESPONSE #65
    FaceObject(LastSeenBy(Myself))
    ForceSpell(LastSeenBy(Myself),BEHOLDER_DOMINATION)
    SetGlobalTimer("dom","LOCALS",3)
    IncrementGlobal("BeDom","LOCALS",1)
  RESPONSE #35
    Continue()
END

IF
  StateCheck(LastSeenBy(Myself),STATE_CHARMED)
  !InParty(LastSeenBy(Myself))
  GlobalLT("BeCharm","LOCALS",12)
  !GlobalTimerNotExpired("cha","LOCALS")
THEN
  RESPONSE #65
    FaceObject(LastSeenBy(Myself))
    ForceSpell(LastSeenBy(Myself),BEHOLDER_CHARM_PERSON)
    SetGlobalTimer("cha","LOCALS",3)
    IncrementGlobal("BeCharm","LOCALS",1)
  RESPONSE #35
    Continue()
END

IF
  RandomNum(2,1)
  GlobalLT("BeholdRay","LOCALS",24)
  !GlobalTimerNotExpired("RAY","LOCALS")
  OR(12)
    SpellCastInnate(LastSeenBy(Myself),0)
    SpellCastPriest(LastSeenBy(Myself),0)
    SpellCast(LastSeenBy(Myself),0)
    HasImmunityEffects(LastSeenBy(Myself))
    HasBounceEffects(LastSeenBy(Myself))
    StateCheck(LastSeenBy(Myself),STATE_HASTED)
    StateCheck(LastSeenBy(Myself),STATE_BLESS)
    StateCheck(LastSeenBy(Myself),STATE_CHANT)
    StateCheck(LastSeenBy(Myself),STATE_LUCK)
    StateCheck(LastSeenBy(Myself),STATE_BLUR)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
THEN
  RESPONSE #100
    FaceObject(LastSeenBy(Myself))
    ForceSpell(LastSeenBy(Myself),HIVE_MOTHER_ANTIMAGIC_RAY)
    SetGlobalTimer("RAY","LOCALS",3)
    IncrementGlobal("BeholdRay","LOCALS",1)
END

IF
  RandomNumLT(41,11)
  !GlobalTimerNotExpired("BPT","LOCALS")
  HaveSpell(WIZARD_TIME_STOP)
THEN
  RESPONSE #100
    Spell(Myself,WIZARD_TIME_STOP)
END

IF
  RandomNumLT(42,7)
  HaveSpell(WIZARD_WAIL_OF_THE_BANSHEE)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Range(LastSeenBy(Myself),6)
  NumCreatureVsPartyLT([ENEMY],2)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(Myself,WIZARD_WAIL_OF_THE_BANSHEE)
END

IF
  RandomNumLT(39,5)
  HaveSpell(CLERIC_CREEPING_DOOM)
  !GlobalTimerNotExpired("BPT","LOCALS")
  Global("MORPH","LOCALS",0)
  CheckStat(LastSeenBy(Myself),0,129)
  CheckStat(LastSeenBy(Myself),0,120)
  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)
THEN
  RESPONSE #100
    SetGlobal("BPT","LOCALS",6)
    Spell(LastSeenBy(Myself),CLERIC_CREEPING_DOOM)
END

IF
  RandomNumLT(33,4)
  HaveSpell(WIZARD_PRISMATIC_SPRAY)
  !GlobalTimerNotExpired("BPT","LOCALS")
  CheckStatGT(LastSeenBy(Myself),6,SAVEVSSPELL)
  CheckStatLT(LastSeenBy(Myself),70,RESISTMAGIC)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_PRISMATIC_SPRAY)
END

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

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

IF
  RandomNumLT(72,14)
  !GlobalTimerNotExpired("BPT","LOCALS")
  GlobalLT("DIS","LOCALS",2)
  CheckStat(LastSeenBy(Myself),0,129)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    IncrementGlobal("DIS","LOCALS",1)
    ReallyForceSpell(LastSeenBy(Myself),HIVE_MOTHER_DISINTEGRATE)
END

IF
  RandomNumLT(36,6)
  HaveSpell(WIZARD_CHAOS)
  !GlobalTimerNotExpired("BPT","LOCALS")
  !HasBounceEffects(LastSeenBy(Myself))
  !StateCheck(LastSeenBy(Myself),STATE_CONFUSED)
  !Range(LastSeenBy(Myself),10)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_CHAOS)
END

IF
  RandomNumLT(37,6)
  HaveSpell(WIZARD_CHAIN_LIGHTNING)
  !GlobalTimerNotExpired("BPT","LOCALS")
  CheckStat(LastSeenBy(Myself),0,129)
  CheckStatLT(LastSeenBy(Myself),60,RESISTELECTRICITY)
  CheckStatLT(LastSeenBy(Myself),60,RESISTMAGIC)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    Spell(LastSeenBy(Myself),WIZARD_CHAIN_LIGHTNING)
END

IF
  RandomNumLT(71,16)
  !GlobalTimerNotExpired("BPT","LOCALS")
  GlobalLT("FING","LOCALS",3)
  CheckStat(LastSeenBy(Myself),0,129)
THEN
  RESPONSE #100
    SetGlobalTimer("BPT","LOCALS",ONE_ROUND)
    IncrementGlobal("FING","LOCALS",1)
    ReallyForceSpell(LastSeenBy(Myself),BEHOLDER_FINGER_OF_DEATH)
END

IF
  RandomNumLT(15,3)
  GlobalLT("BeholdParal","LOCALS",12)
  !GlobalTimerNotExpired("par","LOCALS")
  OR(2)
    !Global("BP_ShBald","LOCALS",2)
    !HasItem("WA2SHIEL",LastSeenBy(Myself))  // ~Shield of Balduran~
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
THEN
  RESPONSE #100
    FaceObject(LastSeenBy(Myself))
    ForceSpell(LastSeenBy(Myself),BEHOLDER_PARALYZATION)
    SetGlobalTimer("par","LOCALS",2)
    IncrementGlobal("BeholdParal","LOCALS",1)
END

IF
  RandomNumGT(15,4)
  RandomNumLT(15,7)
  GlobalLT("BeFear","LOCALS",16)
  !GlobalTimerNotExpired("fear","LOCALS")
  OR(2)
    !Global("BP_ShBald","LOCALS",2)
    !HasItem("WA2SHIEL",LastSeenBy(Myself))  // ~Shield of Balduran~
  !CheckStatGT(LastSeenBy(Myself),0,178)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !StateCheck(LastSeenBy(Myself),STATE_PANIC)
THEN
  RESPONSE #100
    FaceObject(LastSeenBy(Myself))
    ForceSpell(LastSeenBy(Myself),BEHOLDER_FEAR)
    SetGlobalTimer("fear","LOCALS",4)
    IncrementGlobal("BeFear","LOCALS",1)
END

IF
  RandomNumGT(15,6)
  RandomNumLT(15,11)
  GlobalLT("BeWound","LOCALS",20)
  !GlobalTimerNotExpired("wnd","LOCALS")
  See(MostDamagedOf)
  OR(2)
    !Global("BP_ShBald","LOCALS",2)
    !HasItem("WA2SHIEL",LastSeenBy(Myself))  // ~Shield of Balduran~
THEN
  RESPONSE #100
    FaceObject(LastSeenBy(Myself))
    ForceSpell(LastSeenBy(Myself),HIVE_MOTHER_CAUSE_SERIOUS_WOUNDS)
    SetGlobalTimer("wnd","LOCALS",2)
    IncrementGlobal("BeWound","LOCALS",1)
END

IF
  RandomNum(15,11)
  GlobalLT("BeStone","LOCALS",8)
  !GlobalTimerNotExpired("stn","LOCALS")
  OR(2)
    !Global("BP_ShBald","LOCALS",2)
    !HasItem("WA2SHIEL",LastSeenBy(Myself))  // ~Shield of Balduran~
THEN
  RESPONSE #100
    FaceObject(LastSeenBy(Myself))
    ForceSpell(LastSeenBy(Myself),BEHOLDER_FLESH_TO_STONE)
    IncrementGlobal("BeStone","LOCALS",1)
    SetGlobalTimer("stn","LOCALS",8)
END

IF
  RandomNum(15,15)
  GlobalLT("BeDeath","LOCALS",10)
  !GlobalTimerNotExpired("dth","LOCALS")
  OR(2)
    !Global("BP_ShBald","LOCALS",2)
    !HasItem("WA2SHIEL",LastSeenBy(Myself))  // ~Shield of Balduran~
  HPLT(LastSeenBy(Myself),75)
  CheckStatLT(LastSeenBy(Myself),50,RESISTMAGIC)
THEN
  RESPONSE #100
    FaceObject(LastSeenBy(Myself))
    ForceSpell(LastSeenBy(Myself),BEHOLDER_DEATH_RAY)
    SetGlobalTimer("dth","LOCALS",10)
    IncrementGlobal("BeDeath","LOCALS",1)
END

IF
  OR(6)
    See(NearestEnemyOf(Myself))
    See(Player1)
    See([GOODCUTOFF.0.0.FIGHTER_ALL])
    See([GOODCUTOFF.0.0.MONK])
    See([GOODCUTOFF.0.0.RANGER_ALL])
    See([GOODCUTOFF.0.0.PALADIN_ALL])
  False()
THEN
  RESPONSE #100
    Continue()
END

IF
  RandomNumGT(15,12)
  RandomNumLT(15,15)
  GlobalLT("BeSlow","LOCALS",12)
  !GlobalTimerNotExpired("slo","LOCALS")
  OR(2)
    !Global("BP_ShBald","LOCALS",2)
    !HasItem("WA2SHIEL",LastSeenBy(Myself))  // ~Shield of Balduran~
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !StateCheck(LastSeenBy(Myself),STATE_SLOWED)
THEN
  RESPONSE #100
    FaceObject(LastSeenBy(Myself))
    ForceSpell(LastSeenBy(Myself),BEHOLDER_SLOW)
    SetGlobalTimer("slo","LOCALS",8)
    IncrementGlobal("BeSlow","LOCALS",1)
END

IF
  RandomNum(15,12)
  GlobalLT("BeDom","LOCALS",12)
  !GlobalTimerNotExpired("dom","LOCALS")
  OR(2)
    !Global("BP_ShBald","LOCALS",2)
    !HasItem("WA2SHIEL",LastSeenBy(Myself))  // ~Shield of Balduran~
  !StateCheck(LastSeenBy(Myself),STATE_CONFUSED)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !CheckStatGT(LastSeenBy(Myself),0,119)
THEN
  RESPONSE #100
    FaceObject(LastSeenBy(Myself))
    ForceSpell(LastSeenBy(Myself),BEHOLDER_DOMINATION)
    SetGlobalTimer("dom","LOCALS",3)
    IncrementGlobal("BeDom","LOCALS",1)
END

IF
  RandomNumGT(15,2)
  RandomNumLT(15,5)
  GlobalLT("BeCharm","LOCALS",12)
  !GlobalTimerNotExpired("cha","LOCALS")
  OR(2)
    !Global("BP_ShBald","LOCALS",2)
    !HasItem("WA2SHIEL",LastSeenBy(Myself))  // ~Shield of Balduran~
  !StateCheck(LastSeenBy(Myself),STATE_CONFUSED)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !CheckStatGT(LastSeenBy(Myself),0,119)
  HPGT(Myself,50)
THEN
  RESPONSE #100
    FaceObject(LastSeenBy(Myself))
    ForceSpell(LastSeenBy(Myself),BEHOLDER_CHARM_PERSON)
    SetGlobalTimer("cha","LOCALS",3)
    IncrementGlobal("BeCharm","LOCALS",1)
END

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

IF
  True()
THEN
  RESPONSE #50
    Continue()
  RESPONSE #50
END

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

IF
  Range(LastSeenBy(Myself),3)
THEN
  RESPONSE #90
    AttackReevaluate(LastSeenBy(Myself),35)
  RESPONSE #10
END

IF
  True()
THEN
  RESPONSE #60
    AttackReevaluate(LastSeenBy(Myself),25)
  RESPONSE #60
    DisplayStringHead(Myself,100660)  // @1
    ChangeSpecifics(Myself,CALLED_FOR_BOULDER)
  RESPONSE #45
END

