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
  Global("BPSC","LOCALS",0)
  Allegiance(LastSummonerOf(Myself),GOODCUTOFF)
  !Race(Myself,DEMONIC)
  HaveAnySpells()
THEN
  RESPONSE #100
    ChangeAIScript("",OVERRIDE)
    ChangeAIScript("GB-SMAGE",CLASS)
    ChangeAIScript("",RACE)
    ChangeAIScript("",GENERAL)
    ChangeAIScript("",DEFAULT)
END

IF
  Global("BPSC","LOCALS",0)
  Allegiance(LastSummonerOf(Myself),GOODCUTOFF)
  !Race(Myself,DEMONIC)
  !HaveAnySpells()
THEN
  RESPONSE #100
    ChangeAIScript("",OVERRIDE)
    ChangeAIScript("GB-SUMM",CLASS)
    ChangeAIScript("",RACE)
    ChangeAIScript("",GENERAL)
    ChangeAIScript("",DEFAULT)
END

IF
  Global("BPSC","LOCALS",0)
THEN
  RESPONSE #100
    SetGlobal("BPSC","LOCALS",1)
    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 #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,180)
THEN
  RESPONSE #100
    SetGlobal("VAPOR","LOCALS",0)
    SpellNoDecRES("BPVAMBAK",Myself)
    EquipMostDamagingMelee()
    AttackOneRound(NearestEnemyOf(Myself))
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)
    SetGlobal("VAPOR","LOCALS",1)
    DisplayStringHead(Myself,@4)
    SpellNoDecRES("BPVAMGAS",Myself)
    MoveToObject(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)
    SetGlobal("VAPOR","LOCALS",1)
    DisplayStringHead(Myself,@4)
    SpellNoDecRES("BPVAMGAS",Myself)
    MoveToObject(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)
    SetGlobal("VAPOR","LOCALS",1)
    DisplayStringHead(Myself,@4)
    SpellNoDecRES("BPVAMGAS",Myself)
    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(3)
    !Allegiance(Myself,EVILCUTOFF)
    TurnedBy([GOODCUTOFF.0.0.CLERIC_ALL])
    TurnedBy([GOODCUTOFF.0.0.PALADIN_ALL])
THEN
  RESPONSE #100
END

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

IF
  See(NearestEnemyOf(Myself))
  Global("SHOUT","LOCALS",0)
THEN
  RESPONSE #100
    SetGlobal("SHOUT","LOCALS",1)
    Shout(151)
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
  ActionListEmpty()
  OR(2)
    Heard([ENEMY.0.VAMPIRE.VAMPIRE],124)
    Heard([ENEMY.0.VAMPYRE.VAMPYRE],124)
  Range(LastHeardBy(Myself),40)
  HPGT(LastHeardBy(Myself),0)
  !GlobalTimerNotExpired("HELP","LOCALS")
THEN
  RESPONSE #60
    SetGlobalTimer("HELP","LOCALS",THREE_ROUNDS)
    AttackReevaluate(LastHitter(LastHeardBy(Myself)),180)
  RESPONSE #30
    SetGlobalTimer("HELP","LOCALS",TWO_ROUNDS)
    SetGlobalTimer("CHARM","LOCALS",10)
    ReallyForceSpell(LastAttackerOf(LastHeardBy(Myself)),VAMPIRE_DOMINATION)
  RESPONSE #30
    SetGlobalTimer("HELP","LOCALS",TWO_ROUNDS)
    SetGlobalTimer("FEAR","LOCALS",10)
    ReallyForceSpell(LastAttackerOf(LastHeardBy(Myself)),VAMPIRE_FEAR)
  RESPONSE #80
    MoveToObject(LastHeardBy(Myself))
    SetGlobalTimer("HELP","LOCALS",FOUR_ROUNDS)
    AttackReevaluate(LastHitter(LastHeardBy(Myself)),270)
  RESPONSE #20
    SetGlobalTimer("HELP","LOCALS",TWO_ROUNDS)
END

IF
  ActionListEmpty()
  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 #75
    DisplayStringHead(Myself,@5)
    SetGlobalTimer("RANG","LOCALS",ONE_ROUND)
  RESPONSE #25
    DisplayStringHead(Myself,@6)
    SetGlobalTimer("RANG","LOCALS",ONE_ROUND)
    SetGlobalTimer("CHARM","LOCALS",10)
    ReallyForceSpell(LastSeenBy(Myself),VAMPIRE_DOMINATION)
  RESPONSE #25
    DisplayStringHead(Myself,@7)
    SetGlobalTimer("RANG","LOCALS",ONE_ROUND)
    SetGlobalTimer("FEAR","LOCALS",10)
    ReallyForceSpell(LastSeenBy(Myself),VAMPIRE_FEAR)
  RESPONSE #50
    DisplayStringHead(Myself,@8)
    SetGlobalTimer("RANG","LOCALS",ONE_ROUND)
    MoveToObject(LastSeenBy(Myself))
    AttackReevaluate(LastSeenBy(Myself),180)
END



IF
  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(26,18)
  OR(14)
    See([GOODCUTOFF.0.0.MONK])
    See([GOODCUTOFF.0.0.BARD_ALL])
    See([GOODCUTOFF.0.0.THIEF_ALL])
    See([GOODCUTOFF.0.0.RANGER_ALL])
    See([GOODCUTOFF.0.0.PALADIN_ALL])
    See([GOODCUTOFF.0.0.LONG_BOW])
    See([GOODCUTOFF.0.0.CLERIC_ALL])
    See([GOODCUTOFF.0.0.SORCERER])
    See([GOODCUTOFF.0.0.DRUID_ALL])
    See([GOODCUTOFF.0.0.CLERIC_ALL])
    See([GOODCUTOFF.0.0.CLERIC_MAGE])
    See([GOODCUTOFF.0.0.CLERIC_RANGER])
    See([GOODCUTOFF.0.0.PALADIN_ALL])
    See([GOODCUTOFF.0.0.CLERIC.0.0.MASK_GOOD])
  False()
THEN
  RESPONSE #100
    Continue()
END

IF
  RandomNumLT(29,23)
  OR(10)
    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.LONG_BOW]))
    See(SecondNearestEnemyOfType([PC.0.0.SORCERER]))
    See(SecondNearestEnemyOfType([PC.0.0.CLERIC_ALL]))
    See(SecondNearestEnemyOfType([PC.0.0.DRUID_ALL]))
    See(SecondNearestEnemyOfType([GOODCUTOFF.0.0.RANGER_ALL]))
    See(SecondNearestEnemyOfType([GOODCUTOFF.0.0.PALADIN_ALL]))
    See(SecondNearestEnemyOfType([GOODCUTOFF.0.0.CLERIC.0.0.MASK_GOOD]))
  RandomNumLT(27,23)
  OR(10)
    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.LONG_BOW]))
    See(ThirdNearestEnemyOfType([PC.0.0.SORCERER]))
    See(ThirdNearestEnemyOfType([PC.0.0.CLERIC_ALL]))
    See(ThirdNearestEnemyOfType([PC.0.0.DRUID_ALL]))
    See(ThirdNearestEnemyOfType([GOODCUTOFF.0.0.RANGER_ALL]))
    See(ThirdNearestEnemyOfType([GOODCUTOFF.0.0.PALADIN_ALL]))
    See(ThirdNearestEnemyOfType([GOODCUTOFF.0.0.CLERIC.0.0.MASK_GOOD]))
  RandomNumLT(32,18)
  OR(7)
    See(TenthNearestEnemyOfType([GOODCUTOFF.0.0.LONG_BOW]))
    See(TenthNearestEnemyOfType([GOODCUTOFF.0.0.SORCERER]))
    See(TenthNearestEnemyOfType([GOODCUTOFF.0.0.CLERIC_ALL]))
    See(TenthNearestEnemyOfType([GOODCUTOFF.0.0.DRUID_ALL]))
    See(TenthNearestEnemyOfType([GOODCUTOFF.0.0.RANGER_ALL]))
    See(TenthNearestEnemyOfType([GOODCUTOFF.0.0.PALADIN_ALL]))
    See(TenthNearestEnemyOfType([GOODCUTOFF.0.0.CLERIC.0.0.MASK_GOOD]))
  RandomNumLT(20,8)
  See(TenthNearestEnemyOf(Myself))
  RandomNumLT(30,6)
  See(Protagonist)
  False()
THEN
  RESPONSE #100
    Continue()
END



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

IF
  ActionListEmpty()
  StateCheck(LastSeenBy(Myself),STATE_CHARMED)
  !InParty(LastSeenBy(Myself))
  !GlobalTimerNotExpired("CHARM","LOCALS")
THEN
  RESPONSE #80
    SetGlobalTimer("CHARM","LOCALS",9)
    ReallyForceSpell(LastSeenBy(Myself),VAMPIRE_DOMINATION)
  RESPONSE #20
    Continue()
END

IF
  StateCheck(LastSeenBy(Myself),STATE_CHARMED)
THEN
  RESPONSE #80
    Continue()
  RESPONSE #20
END



IF
  ActionListEmpty()
  !GlobalTimerNotExpired("CHARM","LOCALS")
  OR(5)
    RandomNumLT(48,25)
    Class(LastSeenBy(Myself),FIGHTER_ALL)
    Class(LastSeenBy(Myself),PALADIN_ALL)
    Class(LastSeenBy(Myself),RANGER_ALL)
    Class(LastSeenBy(Myself),THIEF_ALL)
  !Kit(LastSeenBy(Myself),INQUISITOR)
  !StateCheck(LastSeenBy(Myself),STATE_CHARMED)
  CheckStat(LastSeenBy(Myself),0,119)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
THEN
  RESPONSE #100
    SetGlobalTimer("CHARM","LOCALS",9)
    ReallyForceSpell(LastSeenBy(Myself),VAMPIRE_DOMINATION)
END

IF
  ActionListEmpty()
  !GlobalTimerNotExpired("FEAR","LOCALS")
  OR(6)
    RandomNumLT(55,28)
    Class(LastSeenBy(Myself),BARD_ALL)
    Class(LastSeenBy(Myself),DRUID_ALL)
    Class(LastSeenBy(Myself),CLERIC_ALL)
    Class(LastSeenBy(Myself),LONG_BOW)
    Class(LastSeenBy(Myself),SORCERER)
  !Kit(LastSeenBy(Myself),CAVALIER)
  !StateCheck(LastSeenBy(Myself),STATE_PANIC)
  CheckStat(LastSeenBy(Myself),0,119)
  CheckStat(LastSeenBy(Myself),0,178)
  !CheckStat(LastSeenBy(Myself),1,SCRIPTINGSTATE4)
THEN
  RESPONSE #100
    SetGlobalTimer("FEAR","LOCALS",7)
    ReallyForceSpell(LastSeenBy(Myself),VAMPIRE_FEAR)
END

IF
  ActionListEmpty()
  !GlobalTimerNotExpired("DEAD","LOCALS")
  GlobalLT("UDEAD","LOCALS",6)
  RandomNumLT(93,46)
THEN
  RESPONSE #60
    SetGlobalTimer("DEAD","LOCALS",FOUR_ROUNDS)
    IncrementGlobal("UDEAD","LOCALS",1)
    ReallyForceSpell(LastSeenBy(Myself),INNATE_GLOBE_OF_DARKNESS)
  RESPONSE #45
    SetGlobalTimer("DEAD","LOCALS",THREE_ROUNDS)
    IncrementGlobal("UDEAD","LOCALS",1)
    ChangeClass(Myself,CLERIC)
    ReallyForceSpell(LastSeenBy(Myself),CLERIC_COMMAND)
  RESPONSE #35
    SetGlobalTimer("DEAD","LOCALS",THREE_ROUNDS)
    IncrementGlobal("UDEAD","LOCALS",1)
    ChangeClass(Myself,CLERIC)
    ReallyForceSpell(LastSeenBy(Myself),CLERIC_DOOM)
  RESPONSE #30
    SetGlobalTimer("DEAD","LOCALS",THREE_ROUNDS)
    IncrementGlobal("UDEAD","LOCALS",1)
    ChangeClass(Myself,MAGE)
    ReallyForceSpell(LastSeenBy(Myself),WIZARD_ANIMATE_DEAD)
  RESPONSE #95
    SetGlobalTimer("DEAD","LOCALS",THREE_ROUNDS)
END

IF
  ActionListEmpty()
  !GlobalTimerNotExpired("DEAD","LOCALS")
  GlobalLT("UDEAD","LOCALS",4)
  RandomNumLT(92,36)
  LevelGT(Myself,9)
THEN
  RESPONSE #60
    SetGlobalTimer("DEAD","LOCALS",ONE_ROUND)
    ReallyForceSpell(Myself,WIZARD_IMPROVED_HASTE)
  RESPONSE #50
    SetGlobalTimer("DEAD","LOCALS",FOUR_ROUNDS)
    IncrementGlobal("UDEAD","LOCALS",1)
    ReallyForceSpell(LastSeenBy(Myself),INNATE_IMPROVED_GLOBE_OF_DARKNESS)
  RESPONSE #40
    SetGlobalTimer("DEAD","LOCALS",THREE_ROUNDS)
    IncrementGlobal("UDEAD","LOCALS",1)
    ChangeClass(Myself,MAGE)
    ReallyForceSpell(LastSeenBy(Myself),WIZARD_GREATER_MALISON)
  RESPONSE #30
    SetGlobalTimer("DEAD","LOCALS",THREE_ROUNDS)
    IncrementGlobal("UDEAD","LOCALS",1)
    ReallyForceSpell(LastSeenBy(Myself),SPECTATOR_SUGGESTION)
  RESPONSE #25
    SetGlobalTimer("DEAD","LOCALS",THREE_ROUNDS)
    IncrementGlobal("UDEAD","LOCALS",1)
    ReallyForceSpell(LastSeenBy(Myself),BEHOLDER_SLOW)
  RESPONSE #15
    SetGlobalTimer("DEAD","LOCALS",THREE_ROUNDS)
    IncrementGlobal("UDEAD","LOCALS",1)
    ChangeClass(Myself,MAGE)
    ReallyForceSpell(LastSeenBy(Myself),WIZARD_RAY_OF_ENFEEBLEMENT)
  RESPONSE #10
    SetGlobalTimer("DEAD","LOCALS",THREE_ROUNDS)
    IncrementGlobal("UDEAD","LOCALS",1)
    ReallyForceSpell(LastSeenBy(Myself),ENEMY_SUMMON_GHAST)
  RESPONSE #10
    SetGlobalTimer("DEAD","LOCALS",THREE_ROUNDS)
    IncrementGlobal("UDEAD","LOCALS",1)
    ReallyForceSpell(LastSeenBy(Myself),SUMMON_SHADOW)
  RESPONSE #95
    SetGlobalTimer("DEAD","LOCALS",THREE_ROUNDS)
END

IF
  ActionListEmpty()
  !GlobalTimerNotExpired("DEAD","LOCALS")
  GlobalLT("UDEAD","LOCALS",2)
  RandomNumLT(91,36)
  LevelGT(Myself,14)
THEN
  RESPONSE #55
    SetGlobalTimer("DEAD","LOCALS",THREE_ROUNDS)
    IncrementGlobal("UDEAD","LOCALS",1)
    ChangeClass(Myself,CLERIC)
    ReallyForceSpell(LastSeenBy(Myself),CLERIC_UNHOLY_WORD)
  RESPONSE #30
    SetGlobalTimer("DEAD","LOCALS",FOUR_ROUNDS)
    IncrementGlobal("UDEAD","LOCALS",1)
    ChangeClass(Myself,CLERIC)
    ReallyForceSpell(LastSeenBy(Myself),CLERIC_ANIMATE_DEAD)
  RESPONSE #25
    SetGlobalTimer("DEAD","LOCALS",THREE_ROUNDS)
    IncrementGlobal("UDEAD","LOCALS",1)
    ChangeClass(Myself,MAGE)
    ReallyForceSpell(LastSeenBy(Myself),WIZARD_FEEBLEMIND)
  RESPONSE #15
    SetGlobalTimer("DEAD","LOCALS",THREE_ROUNDS)
    IncrementGlobal("UDEAD","LOCALS",1)
    ChangeClass(Myself,MAGE)
    ReallyForceSpell(Myself,WIZARD_WAIL_OF_THE_BANSHEE)
  RESPONSE #95
    SetGlobalTimer("DEAD","LOCALS",THREE_ROUNDS)
END



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

IF
  RandomNumLT(28,22)
  OR(4)
    See([GOODCUTOFF.0.0.0.0.SUMMONED_DEMON])
    See([GOODCUTOFF.0.0.0.0.SUMMONED])
    See([GOODCUTOFF.0.0.0.SIMULACRUM])
    See([GOODCUTOFF.0.0.0.0.ILLUSIONARY])
  False()
THEN
  RESPONSE #100
    Continue()
END

IF
  RandomNumLT(31,26)
  OR(6)
    See(NearestEnemyOf(Myself))
    See(WeakestOf)
    See(WorstAC)
    See(MostDamagedOf)
    See(LastAttackerOf(Myself))
    See(LastHitter(Myself))
  False()
THEN
  RESPONSE #100
    Continue()
END

IF
  RandomNumLT(24,9)
  OR(3)
    See(StrongestOf)
    See(BestAC)
    See(LeastDamagedOf)
  RandomNumLT(25,9)
  See(WeakestOf)
  RandomNumLT(23,8)
  See(WorstAC)
  RandomNumLT(21,8)
  See(MostDamagedOf)
  False()
THEN
  RESPONSE #100
    Continue()
END

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

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

IF
  RandomNumGT(33,22)
  AttackedBy([0],DEFAULT)
  !Allegiance(LastAttackerOf(LastHeardBy(Myself)),EVILCUTOFF)
  OR(3)  
    !StateCheck(LastAttackerOf(Myself),0x00400010)
    CheckStatGT(Myself,0,SEEINVISIBLE)
    CheckStatGT(Myself,0,118)
  !StateCheck(LastAttackerOf(Myself),STATE_CHARMED)
  See(LastAttackerOf(Myself))
  False()
THEN
  RESPONSE #100
    Continue()
END

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


IF
  StateCheck(LastSeenBy(Myself),STATE_CHARMED)
THEN
  RESPONSE #80
    Continue()
  RESPONSE #20
END



IF
  ActionListEmpty()
  HPPercentLT(Myself,25)
  Range(LastHitter(Myself),10)
  !GlobalTimerNotExpired("BPW","LOCALS")
THEN
  RESPONSE #60
    SetGlobalTimer("BPW","LOCALS",10)
    DisplayStringHead(Myself,@9)
    Shout(124)
    RunAwayFrom(LastHitter(Myself),45)
  RESPONSE #30
    SetGlobalTimer("BPW","LOCALS",10)
    DisplayStringHead(Myself,@10)
    Shout(124)
    AttackOneRound(LastHitter(Myself))
END

IF
  ActionListEmpty()
  OR(2)
    CheckStatGT(NearestEnemyOf(Myself),0,121)
    CheckStatGT(LastSeenBy(Myself),0,125)
THEN
  RESPONSE #25
    Continue()
  RESPONSE #75
END

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

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

