IF
  Global("party","LOCALS",0)
  !See([GOODCUTOFF])
THEN
  RESPONSE #100
    NoAction()
END

IF
  !GlobalTimerNotExpired("LockTarget","LOCALS")
  CheckStat(Myself,3,PUPPETTYPE)
  See([ENEMY.HUMANOID.ELF.MAGE.0.MALE])
  !Specifics(Myself,207)
  !Range(LastSeenBy(Myself),0)
  Range(LastSeenBy(Myself),2)
THEN
  RESPONSE #100
    DisplayStringHead(LastSeenBy(Myself),26234)  // ~Simulacrum~
    ActionOverride(LastSeenBy(Myself),RemoveSpell(WIZARD_SIMULACRUM))
    ActionOverride(LastSeenBy(Myself),RemoveSpell(WIZARD_PROJECT_IMAGE))
    ActionOverride(LastSeenBy(Myself),RemoveSpell(WIZARD_MISLEAD))
    ChangeSpecifics(LastSeenBy(Myself),207)
    ActionOverride(LastSeenBy(Myself),ChangeAIScript("finiren",OVERRIDE))
    ChangeGender(LastSeenBy(Myself),EXTRA3)
    RunAwayFrom(LastSeenBy(Myself),30)
END

IF
  OR(2)
    Specifics(Myself,207)
    Gender(Myself,ILLUSIONARY)
 Global("sim-gear","LOCALS",0)
THEN
  RESPONSE #100
    SetGlobal("sim-gear","LOCALS",1)
    GiveItemCreate("FINIROBE",Myself,0,0,0)  // ~Robe of Vecna~
    FillSlot(SLOT_ARMOR)
    GiveItemCreate("STONSKIN",Myself,0,0,0)  // <Invalid Strref -1>
    FillSlot(0)
    GiveItemCreate("FINIR0M",Myself,0,0,0)  // <Invalid Strref -1>
    FillSlot(SLOT_WEAPON1)
    GiveItemCreate("FINIR0R",Myself,0,0,0)  // ~Firetooth +5~
    FillSlot(SLOT_WEAPON2)
    GiveItemCreate("FINIPOTN",Myself,5,1,1)  // ~Potion of Superior Healing~
    GiveItemCreate("IRENBRCH",Myself,5,1,1)  // ~Wand of Spell Striking~
    GiveItemCreate("IRENPRCE",Myself,5,1,1)  // ~Wand of Spell Striking~
END

IF
  OR(2)
    Specifics(Myself,207)
    Gender(Myself,ILLUSIONARY)
  Dead("finiren")  // ~Jon Irenicus~
  Global("TimeToGo","LOCALS",0)
THEN
  RESPONSE #100
    SetGlobal("TimeToGo","LOCALS",1)
    CreateVisualEffectObject("SPFLESHS",Myself)
    DestroySelf()
END

IF
  Global("CloseCombat","LOCALS",1)
  GlobalTimerExpired("attacked","LOCALS")
THEN
  RESPONSE #100
    SetGlobal("CloseCombat","LOCALS",0)
    SetGlobalTimer("SafeForAWhile","LOCALS",6)
END

IF
  Global("CloseCombat","LOCALS",0)
  Global("safe","LOCALS",0)
  GlobalTimerExpired("SafeForAWhile","LOCALS")
THEN
  RESPONSE #100
    SetGlobal("safe","LOCALS",1)
END

IF
  Global("CloseCombat","LOCALS",0)
  OR(2)
    HitBy([ANYONE],CRUSHING)
    AttackedBy([ANYONE],DEFAULT)
  Range(NearestEnemyOf(Myself),8)
THEN
  RESPONSE #100
    SetGlobal("CloseCombat","LOCALS",1)
    SetGlobal("safe","LOCALS",0)
    SetGlobalTimer("attacked","LOCALS",5)
END

IF
  CombatCounterGT(0)
  !GlobalTimerNotExpired("WeapProt","LOCALS")
  !GlobalTimerNotExpired("Alacrity","LOCALS")
  !GlobalTimerNotExpired("ChainContingency","LOCALS")
  !Specifics(Myself,207)
  !Gender(Myself,ILLUSIONARY)
THEN
  RESPONSE #100
    SetGlobalTimer("ChainContingency","LOCALS",1000)
    DisplayString(Myself,73139)  // ~Contingency - Fired~
    ReallyForceSpell(Myself,WIZARD_SIMULACRUM)
    ReallyForceSpell(Myself,WIZARD_PROTECTION_FROM_ENERGY)
    ReallyForceSpell(Myself,WIZARD_ABI_DALZIMS_HORRID_WILTING)
    SetGlobalTimer("WeapProt","LOCALS",12)
    SetGlobal("party","LOCALS",1)
END

IF
  CombatCounterGT(0)
  !GlobalTimerNotExpired("Alacrity","LOCALS")
  !GlobalTimerNotExpired("SpellSequencer","LOCALS")
  !Specifics(Myself,207)
  !Gender(Myself,ILLUSIONARY)
THEN
  RESPONSE #100
    SetGlobalTimer("SpellSequencer","LOCALS",1000)
    DisplayString(Myself,39969)  // ~Spell Sequencer - Fired~
    ReallyForceSpell(Myself,WIZARD_IMPROVED_INVISIBILITY)
    ReallyForceSpell(NearestEnemyOf(Myself),WIZARD_GREATER_MALISON)
    ReallyForceSpell(Myself,WIZARD_HASTE)
    SetGlobal("party","LOCALS",1)
END

IF
  HPPercentLT(Myself,70)
  !CheckStatGT(Myself,0,128)
  !GlobalTimerNotExpired("Alacrity","LOCALS")
  !Specifics(Myself,207)
  !Gender(Myself,ILLUSIONARY)
  !GlobalTimerNotExpired("Contingency","LOCALS")
THEN
  RESPONSE #100
    SetGlobalTimer("Contingency","LOCALS",1000)
    DisplayString(Myself,73139)  // ~Contingency - Fired~
    ReallyForceSpell(Myself,WIZARD_PROTECTION_FROM_MAGIC_WEAPONS)
END

IF
  Exists(NearestEnemyOf(Myself))
  !GlobalTimerNotExpired("Alacrity","LOCALS")
  !GlobalTimerNotExpired("SpellTrigger","LOCALS")
  !Specifics(Myself,207)
  !Gender(Myself,ILLUSIONARY)
THEN
  RESPONSE #100
    SetGlobalTimer("SpellTrigger","LOCALS",1000)
    FaceObject(NearestEnemyOf(Myself))
    DisplayString(Myself,39968)  // ~Spell Trigger - Fired~
    ReallyForceSpell(Myself,WIZARD_SPELL_IMMUNITY_ABJURATION)
    ReallyForceSpell(Myself,WIZARD_SPELL_IMMUNITY_DIVINATION)
    ReallyForceSpell(NearestEnemyOf(Myself),WIZARD_CHAIN_LIGHTNING)
END

IF
  Exists(NearestEnemyOf(Myself))
  !GlobalTimerNotExpired("Alacrity","LOCALS")
  !GlobalTimerNotExpired("MinorSequencer","LOCALS")
  !Specifics(Myself,207)
  !Gender(Myself,ILLUSIONARY)
  !HasItemEquiped("CLCK26",NearestEnemyOf(Myself))
THEN
  RESPONSE #100
    SetGlobalTimer("MinorSequencer","LOCALS",1000)
    FaceObject(NearestEnemyOf(Myself))
    DisplayString(Myself,39969)  // ~Spell Sequencer - Fired~
    ReallyForceSpell(NearestEnemyOf(Myself),WIZARD_MELF_ACID_ARROW)
    ReallyForceSpell(NearestEnemyOf(Myself),WIZARD_MELF_ACID_ARROW)
END

IF
  StateCheck(Myself,STATE_SILENCED)
  HaveSpell(WIZARD_VOCALIZE)
  OR(2)
    !GlobalTimerNotExpired("SpellCast","LOCALS")
    GlobalTimerNotExpired("Alacrity","LOCALS")
THEN
  RESPONSE #30
    SetGlobalTimer("SpellCast","LOCALS",6)
    Spell(Myself,WIZARD_VOCALIZE)
  RESPONSE #70
    SetGlobalTimer("SpellCast","LOCALS",6)
    RemoveSpell(WIZARD_VOCALIZE)
    ForceSpell(Myself,WIZARD_VOCALIZE)
END

IF
  Specifics(Myself,207)
  !CheckStatGT(Myself,0,118)
  HaveSpell(WIZARD_TRUE_SIGHT)
  !GlobalTimerNotExpired("SpellCast","LOCALS")
  !GlobalTimerNotExpired("Alacrity","LOCALS")
THEN
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    Spell(Myself,WIZARD_TRUE_SIGHT)
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    RemoveSpell(WIZARD_TRUE_SIGHT)
    ForceSpell(Myself,WIZARD_TRUE_SIGHT)
END

IF
  HaveSpell(WIZARD_PROJECT_IMAGE)
  Global("party","LOCALS",1)
  OR(2)
    StateCheck(NearestEnemyOf(Myself),STATE_DEAD)
    !CheckStatGT(NearestEnemyOf(Myself),0,118)
  OR(2)
    StateCheck(SecondNearestEnemyOf(Myself),STATE_DEAD)
    !CheckStatGT(SecondNearestEnemyOf(Myself),0,118)
  OR(2)
    StateCheck(ThirdNearestEnemyOf(Myself),STATE_DEAD)
    !CheckStatGT(ThirdNearestEnemyOf(Myself),0,118)
  OR(2)
    StateCheck(FourthNearestEnemyOf(Myself),STATE_DEAD)
    !CheckStatGT(FourthNearestEnemyOf(Myself),0,118)
  OR(2)
    StateCheck(FifthNearestEnemyOf(Myself),STATE_DEAD)
    !CheckStatGT(FifthNearestEnemyOf(Myself),0,118)
  OR(2)
    StateCheck(SixthNearestEnemyOf(Myself),STATE_DEAD)
    !CheckStatGT(SixthNearestEnemyOf(Myself),0,118)
  OR(2)
    StateCheck(SeventhNearestEnemyOf(Myself),STATE_DEAD)
    !CheckStatGT(SeventhNearestEnemyOf(Myself),0,118)
  OR(2)
    StateCheck(EighthNearestEnemyOf(Myself),STATE_DEAD)
    !CheckStatGT(EighthNearestEnemyOf(Myself),0,118)
  StateCheck(Myself,STATE_INVISIBLE)
  !GlobalTimerNotExpired("SpellCast","LOCALS")
THEN
  RESPONSE #100
    SetGlobalTimer("SpellCast","LOCALS",6)
    CreateCreatureObject("FINIRAT",Myself,0,0,0)  // ~Rat~
    RemoveSpell(WIZARD_PROJECT_IMAGE)
    ForceSpell(Myself,WIZARD_PROJECT_IMAGE)
END

IF
  !GlobalTimerNotExpired("LockTarget","LOCALS")
  See(NearestEnemyOf(Myself))
  HaveSpell(WIZARD_TIME_STOP)
  !GlobalTimerNotExpired("SpellCast","LOCALS")
  !GlobalTimerNotExpired("Alacrity","LOCALS")
  !GlobalTimerNotExpired("TimeStop","LOCALS")
  !Difficulty(EASIEST)
THEN
  RESPONSE #30
    SetGlobalTimer("SpellCast","LOCALS",6)
    Spell(Myself,WIZARD_TIME_STOP)
    SetGlobalTimer("TimeStop","LOCALS",36)
  RESPONSE #70
    SetGlobalTimer("SpellCast","LOCALS",6)
    SetGlobalTimer("TimeStop","LOCALS",36)
    RemoveSpell(WIZARD_TIME_STOP)
    ForceSpell(Myself,WIZARD_TIME_STOP)
END

IF
  !GlobalTimerNotExpired("LockTarget","LOCALS")
  OR(2)
    See([PC])
    See([ALLY])
  HaveSpell(WIZARD_IMPROVED_ALUCRITY)
  !GlobalTimerNotExpired("Alacrity","LOCALS")
  OR(2)
    Global("Alac","LOCALS",0)
    !GlobalTimerNotExpired("AlacrityRepeat","LOCALS")
  OR(4)
    Global("Alac","LOCALS",0)
    CheckStatGT(Myself,0,128)
    !GlobalTimerNotExpired("attacked","LOCALS")
    Global("safe","LOCALS",1)
  !DifficultyLT(NORMAL)
THEN
  RESPONSE #50
    SetGlobalTimer("PreventAttack","LOCALS",18)
    SetGlobalTimer("Alacrity","LOCALS",18)
    SetGlobalTimer("AlacrityRepeat","LOCALS",18)
    IncrementGlobal("Alac","LOCALS",1)
    Spell(Myself,WIZARD_IMPROVED_ALUCRITY)
  RESPONSE #50
    SetGlobalTimer("PreventAttack","LOCALS",18)
    SetGlobalTimer("Alacrity","LOCALS",18)
    SetGlobalTimer("AlacrityRepeat","LOCALS",18)
    IncrementGlobal("Alac","LOCALS",1)
    RemoveSpell(WIZARD_IMPROVED_ALUCRITY)
    ForceSpell(Myself,WIZARD_IMPROVED_ALUCRITY)
END

IF
  !Gender(Myself,ILLUSIONARY)
  HaveSpell(WIZARD_SPELL_IMMUNITY_ABJURATION)
  !CheckStatGT(Myself,0,162)
  OR(2)
    !GlobalTimerNotExpired("SpellCast","LOCALS")
    GlobalTimerNotExpired("Alacrity","LOCALS")
THEN
  RESPONSE #40
    SetGlobalTimer("SpellCast","LOCALS",6)
    Spell(Myself,WIZARD_SPELL_IMMUNITY_ABJURATION)
  RESPONSE #60
    SetGlobalTimer("SpellCast","LOCALS",6)
    RemoveSpell(WIZARD_SPELL_IMMUNITY_ABJURATION)
    ForceSpell(Myself,WIZARD_SPELL_IMMUNITY_ABJURATION)
END

IF
  HaveSpell(WIZARD_SPELL_IMMUNITY_DIVINATION)
  !CheckStatGT(Myself,2,162)
  OR(3)
    Gender(Myself,ILLUSIONARY)
    StateCheck(Myself,STATE_INVISIBLE)
    StateCheck(Myself,STATE_IMPROVEDINVISIBILITY)
  OR(2)
    !GlobalTimerNotExpired("SpellCast","LOCALS")
    GlobalTimerNotExpired("Alacrity","LOCALS")
THEN
  RESPONSE #40
    SetGlobalTimer("SpellCast","LOCALS",6)
    Spell(Myself,WIZARD_SPELL_IMMUNITY_DIVINATION)
  RESPONSE #60
    SetGlobalTimer("SpellCast","LOCALS",6)
    RemoveSpell(WIZARD_SPELL_IMMUNITY_DIVINATION)
    ForceSpell(Myself,WIZARD_SPELL_IMMUNITY_DIVINATION)
END

IF
  Allegiance(Myself,ENEMY)
  CheckStatLT(Myself,1,STONESKINS)
  HaveSpell(WIZARD_STONE_SKIN)
  OR(2)
    !GlobalTimerNotExpired("SpellCast","LOCALS")
    GlobalTimerNotExpired("Alacrity","LOCALS")
THEN
  RESPONSE #40
    SetGlobalTimer("SpellCast","LOCALS",6)
    Spell(Myself,WIZARD_STONE_SKIN)
  RESPONSE #60
    SetGlobalTimer("SpellCast","LOCALS",6)
    RemoveSpell(WIZARD_STONE_SKIN)
    ForceSpell(Myself,WIZARD_STONE_SKIN)
END

IF
  HaveSpell(WIZARD_PROTECTION_FROM_MAGIC_WEAPONS)
  OR(7)
    HitBy([ANYONE],CRUSHING)
    HitBy([ANYONE],PIERCING)
    HitBy([ANYONE],MISSILE)
    HitBy([ANYONE],SLASHING)
    Global("safe","LOCALS",0)
    GlobalTimerNotExpired("attacked","LOCALS")
    !HPPercentGT(Myself,70)
  OR(9)
    Global("CloseCombat","LOCALS",1)
    !HaveSpell(WIZARD_STONE_SKIN)
    GlobalTimerNotExpired("attacked","LOCALS")
    AttackedBy([ANYONE],DEFAULT)
    HitBy([ANYONE],CRUSHING)
    HitBy([ANYONE],PIERCING)
    HitBy([ANYONE],MISSILE)
    HitBy([ANYONE],SLASHING)
    !HPPercentGT(Myself,70)
  !Specifics(Myself,2001)
  !CheckStatGT(Myself,0,128)
  !GlobalTimerNotExpired("SpellCast","LOCALS")
  !GlobalTimerNotExpired("Alacrity","LOCALS")
THEN
  RESPONSE #100
    SetGlobalTimer("SpellCast","LOCALS",6)
    RemoveSpell(WIZARD_PROTECTION_FROM_MAGIC_WEAPONS)
    ForceSpell(Myself,WIZARD_PROTECTION_FROM_MAGIC_WEAPONS)
END

IF
  Specifics(Myself,2001)
  HaveSpell(WIZARD_PROTECTION_FROM_MAGIC_WEAPONS)
  OR(6)
    HitBy([ANYONE],CRUSHING)
    HitBy([ANYONE],PIERCING)
    HitBy([ANYONE],MISSILE)
    HitBy([ANYONE],SLASHING)
    Global("safe","LOCALS",0)
    GlobalTimerNotExpired("attacked","LOCALS")
  OR(7)
    Global("CloseCombat","LOCALS",1)
    GlobalTimerNotExpired("attacked","LOCALS")
    AttackedBy([ANYONE],DEFAULT)
    HitBy([ANYONE],CRUSHING)
    HitBy([ANYONE],PIERCING)
    HitBy([ANYONE],MISSILE)
    HitBy([ANYONE],SLASHING)
  !CheckStatGT(Myself,0,128)
  !GlobalTimerNotExpired("SpellCast","LOCALS")
  !GlobalTimerNotExpired("Alacrity","LOCALS")
THEN
  RESPONSE #100
    SetGlobalTimer("SpellCast","LOCALS",6)
    RemoveSpell(WIZARD_PROTECTION_FROM_MAGIC_WEAPONS)
    ForceSpell(Myself,WIZARD_PROTECTION_FROM_MAGIC_WEAPONS)
END

IF
  HaveSpell(WIZARD_IMPROVED_INVISIBILITY)
  !CheckStatLT(Myself,3,162)
  !StateCheck(Myself,STATE_INVISIBLE)
  !StateCheck(Myself,STATE_IMPROVEDINVISIBILITY)
  !GlobalTimerNotExpired("SpellCast","LOCALS")
  !GlobalTimerNotExpired("Alacrity","LOCALS")
THEN
  RESPONSE #40
    SetGlobalTimer("SpellCast","LOCALS",6)
    Spell(Myself,WIZARD_IMPROVED_INVISIBILITY)
  RESPONSE #60
    SetGlobalTimer("SpellCast","LOCALS",6)
    RemoveSpell(WIZARD_IMPROVED_INVISIBILITY)
    ForceSpell(Myself,WIZARD_IMPROVED_INVISIBILITY)
END

IF
  Global("party","LOCALS",1)
  !StateCheck(Myself,STATE_INVISIBLE)
  HaveSpell(WIZARD_PROJECT_IMAGE)
  HaveSpell(WIZARD_IMPROVED_INVISIBILITY)
  !HaveSpell(WIZARD_SIMULACRUM)
  !GlobalTimerNotExpired("SpellCast","LOCALS")
  !GlobalTimerNotExpired("Alacrity","LOCALS")
  !GlobalTimerNotExpired("TimeStop","LOCALS")
THEN
  RESPONSE #100
    SetGlobalTimer("SpellCast","LOCALS",6)
    SetGlobalTimer("PreventAttack","LOCALS",13)
    RemoveSpell(WIZARD_IMPROVED_INVISIBILITY)
    ForceSpell(Myself,WIZARD_IMPROVED_INVISIBILITY)
END

IF
  Global("party","LOCALS",1)
  StateCheck(Myself,STATE_INVISIBLE)
  HaveSpell(WIZARD_PROJECT_IMAGE)
  !HaveSpell(WIZARD_SIMULACRUM)
  !GlobalTimerNotExpired("SpellCast","LOCALS")
  !GlobalTimerNotExpired("Alacrity","LOCALS")
  !GlobalTimerNotExpired("TimeStop","LOCALS")
THEN
  RESPONSE #100
    SetGlobalTimer("SpellCast","LOCALS",6)
    CreateCreatureObject("FINIRAT",Myself,0,0,0)  // ~Rat~
    RemoveSpell(WIZARD_PROJECT_IMAGE)
    ForceSpell(Myself,WIZARD_PROJECT_IMAGE)
END

IF
  RandomNumLT(10,5)
  OR(2)
    StateCheck(NearestEnemyOf(Myself),STATE_DEAD)
    !CheckStatGT(NearestEnemyOf(Myself),0,118)
  OR(2)
    StateCheck(SecondNearestEnemyOf(Myself),STATE_DEAD)
    !CheckStatGT(SecondNearestEnemyOf(Myself),0,118)
  OR(2)
    StateCheck(ThirdNearestEnemyOf(Myself),STATE_DEAD)
    !CheckStatGT(ThirdNearestEnemyOf(Myself),0,118)
  OR(2)
    StateCheck(FourthNearestEnemyOf(Myself),STATE_DEAD)
    !CheckStatGT(FourthNearestEnemyOf(Myself),0,118)
  OR(2)
    StateCheck(FifthNearestEnemyOf(Myself),STATE_DEAD)
    !CheckStatGT(FifthNearestEnemyOf(Myself),0,118)
  OR(2)
    StateCheck(SixthNearestEnemyOf(Myself),STATE_DEAD)
    !CheckStatGT(SixthNearestEnemyOf(Myself),0,118)
  Global("party","LOCALS",1)
  HaveSpell(WIZARD_PROJECT_IMAGE)
  Exists(NearestEnemyOf(Myself))
  !GlobalTimerNotExpired("SpellCast","LOCALS")
  !GlobalTimerNotExpired("Alacrity","LOCALS")
  !GlobalTimerNotExpired("TimeStop","LOCALS")
THEN
  RESPONSE #100
    SetGlobalTimer("SpellCast","LOCALS",6)
    CreateCreatureObject("FINIRAT",Myself,0,0,0)  // ~Rat~
    RemoveSpell(WIZARD_PROJECT_IMAGE)
    ApplySpell(Myself,WIZARD_IMPROVED_INVISIBILITY)
    ForceSpell(Myself,WIZARD_PROJECT_IMAGE)
END

IF
  HPPercentLT(Myself,50)
  !GlobalTimerNotExpired("PotionUsed","LOCALS")
  !GlobalTimerNotExpired("Alacrity","LOCALS")
  HasItem("finipotn",Myself)  // ~Potion of Superior Healing~
THEN
  RESPONSE #100
    SetGlobalTimer("PotionUsed","LOCALS",6)
    DisplayStringHead(Myself,46150)  // ~quaffs a potion~
    UseItem("finipotn",Myself)  // ~Potion of Superior Healing~
END

IF
  HaveSpell(WIZARD_MIRROR_IMAGE)
  OR(2)
    !Specifics(Myself,207)
    RandomNumGT(20,14)
  OR(2)
    !Gender(Myself,ILLUSIONARY)
    RandomNumGT(30,24)
  OR(6)
    Global("CloseCombat","LOCALS",1)
    Range([GOODCUTOFF.0.0.THIEF_ALL],10)
    Range([GOODCUTOFF.0.0.FIGHTER_ALL],10)
    Range([GOODCUTOFF.0.0.PALADIN_ALL],10)
    See([GOODCUTOFF.0.0.RANGER_ALL])
    HitBy([ANYONE],MISSILE)
  !GlobalTimerNotExpired("MirrorImage","LOCALS")
  OR(2)
    !StateCheck(Myself,STATE_MIRRORIMAGE)
    !GlobalTimerNotExpired("WeapProt","LOCALS")
  !GlobalTimerNotExpired("SpellCast","LOCALS")
  !GlobalTimerNotExpired("Alacrity","LOCALS")
THEN
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    SetGlobalTimer("MirrorImage","LOCALS",36)
    Spell(Myself,WIZARD_MIRROR_IMAGE)
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    SetGlobalTimer("MirrorImage","LOCALS",36)
    RemoveSpell(WIZARD_MIRROR_IMAGE)
    ForceSpell(Myself,WIZARD_MIRROR_IMAGE)
END

IF
  Allegiance(Myself,GOODCUTOFF)
  !CheckStatGT(Myself,0,129)
  HaveSpell(WIZARD_SPELL_TURNING)
  !CheckStatGT(Myself,0,162)
  OR(2)
    !GlobalTimerNotExpired("SpellCast","LOCALS")
    !GlobalTimerNotExpired("Alacrity","LOCALS")
  OR(5)
    Detect([EVILCUTOFF.0.0.CLERIC_ALL])
    Detect([EVILCUTOFF.0.0.DRUID_ALL])
    Detect([EVILCUTOFF.0.0.MAGE_ALL])
    Detect([EVILCUTOFF.0.0.SORCERER])
    Detect([EVILCUTOFF.0.0.BARD_ALL])
THEN
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    Spell(Myself,WIZARD_SPELL_TURNING)
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    RemoveSpell(WIZARD_SPELL_TURNING)
    ForceSpell(Myself,WIZARD_SPELL_TURNING)
END

IF
  Allegiance(Myself,EVILCUTOFF)
  !CheckStatGT(Myself,0,129)
  HaveSpell(WIZARD_SPELL_TURNING)
  !CheckStatGT(Myself,0,162)
  OR(2)
    !GlobalTimerNotExpired("SpellCast","LOCALS")
    !GlobalTimerNotExpired("Alacrity","LOCALS")
  OR(5)
    Detect([GOODCUTOFF.0.0.CLERIC_ALL])
    Detect([GOODCUTOFF.0.0.DRUID_ALL])
    Detect([GOODCUTOFF.0.0.MAGE_ALL])
    Detect([GOODCUTOFF.0.0.SORCERER])
    Detect([GOODCUTOFF.0.0.BARD_ALL])
THEN
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    Spell(Myself,WIZARD_SPELL_TURNING)
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    RemoveSpell(WIZARD_SPELL_TURNING)
    ForceSpell(Myself,WIZARD_SPELL_TURNING)
END

IF
  RandomNumGT(40,28)
  Global("safe","LOCALS",0)
  HaveSpell(WIZARD_FIRE_SHIELD_RED)
  CheckStat(Myself,0,128)
  CheckStat(Myself,0,125)
  CheckStat(Myself,0,SHIELDGLOBE)
  OR(2)
    !GlobalTimerNotExpired("SpellCast","LOCALS")
    !GlobalTimerNotExpired("Alacrity","LOCALS")
THEN
  RESPONSE #100
    SetGlobalTimer("SpellCast","LOCALS",6)
    Spell(Myself,WIZARD_FIRE_SHIELD_RED)
END

IF
  RandomNumLT(50,25)
  OR(2)
    !Specifics(Myself,2001)
    RandomNumLT(60,18)
  OR(2)
    !Gender(Myself,ILLUSIONARY)
    RandomNumLT(70,21)
  Global("safe","LOCALS",0)
  HaveSpell(WIZARD_FIRE_SHIELD_BLUE)
  CheckStat(Myself,0,128)
  CheckStat(Myself,0,125)
  CheckStat(Myself,0,SHIELDGLOBE)
  OR(2)
    !GlobalTimerNotExpired("SpellCast","LOCALS")
    !GlobalTimerNotExpired("Alacrity","LOCALS")
THEN
  RESPONSE #60
    SetGlobalTimer("SpellCast","LOCALS",6)
    Spell(Myself,WIZARD_FIRE_SHIELD_BLUE)
  RESPONSE #40
    SetGlobalTimer("SpellCast","LOCALS",6)
    RemoveSpell(WIZARD_FIRE_SHIELD_BLUE)
    ForceSpell(Myself,WIZARD_FIRE_SHIELD_BLUE)
END

IF
  RandomNumLT(80,56)
  Allegiance(Myself,ENEMY)
  HaveSpell(WIZARD_IMPROVED_HASTE)
  !StateCheck(Myself,STATE_HASTED)
  OR(2)
    !GlobalTimerNotExpired("SpellCast","LOCALS")
    !GlobalTimerNotExpired("Alacrity","LOCALS")
THEN
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    Spell(Myself,WIZARD_IMPROVED_HASTE)
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    ForceSpell(Myself,WIZARD_IMPROVED_HASTE)
    RemoveSpell(WIZARD_IMPROVED_HASTE)
END

IF
  RandomNumLT(8,5)
  Allegiance(Myself,ENEMY)
  !StateCheck(Myself,STATE_HASTED)
  HaveSpell(WIZARD_IMPROVED_HASTE)
  HPGT(LastSeenBy(Myself),100)
  !StateCheck(LastSeenBy(Myself),STATE_HASTED)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !StateCheck(LastSeenBy(Myself),STATE_CONFUSED)
  !StateCheck(LastSeenBy(Myself),STATE_STUNNED)
  !StateCheck(LastSeenBy(Myself),STATE_SLEEPING)
  OR(2)
    !GlobalTimerNotExpired("SpellCast","LOCALS")
    !GlobalTimerNotExpired("Alacrity","LOCALS")
THEN
  RESPONSE #70
    SetGlobalTimer("SpellCast","LOCALS",6)
    Spell(Myself,WIZARD_IMPROVED_HASTE)
  RESPONSE #30
    SetGlobalTimer("SpellCast","LOCALS",6)
    ForceSpell(Myself,WIZARD_IMPROVED_HASTE)
    RemoveSpell(WIZARD_IMPROVED_HASTE)
END

IF
  RandomNumLT(12,6)
  Allegiance(Myself,ENEMY)
  HaveSpell(WIZARD_HASTE)
  !HaveSpell(WIZARD_IMPROVED_HASTE)
  !StateCheck(Myself,STATE_HASTED)
  OR(2)
    !GlobalTimerNotExpired("SpellCast","LOCALS")
    !GlobalTimerNotExpired("Alacrity","LOCALS")
THEN
  RESPONSE #70
    SetGlobalTimer("SpellCast","LOCALS",6)
    SetGlobalTimer("Haste","LOCALS",21)
    Spell(Myself,WIZARD_HASTE)
  RESPONSE #30
    SetGlobalTimer("SpellCast","LOCALS",6)
    SetGlobalTimer("Haste","LOCALS",21)
    ForceSpell(Myself,WIZARD_HASTE)
    RemoveSpell(WIZARD_HASTE)
END

IF
  RandomNumLT(14,7)
  Allegiance(Myself,ENEMY)
  StateCheck(Myself,STATE_HASTED)
  HaveSpell(WIZARD_HASTE)
  !HaveSpell(WIZARD_IMPROVED_HASTE)
  !StateCheck(LastSeenBy(Myself),STATE_HASTED)
  !StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !StateCheck(LastSeenBy(Myself),STATE_CONFUSED)
  !StateCheck(LastSeenBy(Myself),STATE_STUNNED)
  !StateCheck(LastSeenBy(Myself),STATE_SLEEPING)
  !StateCheck(LastSeenBy(Myself),STATE_DEAD)
  OR(2)
    !GlobalTimerNotExpired("SpellCast","LOCALS")
    !GlobalTimerNotExpired("Alacrity","LOCALS")
THEN
  RESPONSE #70
    SetGlobalTimer("SpellCast","LOCALS",6)
    Spell(Myself,WIZARD_HASTE)
  RESPONSE #30
    SetGlobalTimer("SpellCast","LOCALS",6)
    RemoveSpell(WIZARD_HASTE)
    ForceSpell(Myself,WIZARD_HASTE)
END

IF
  RandomNumGT(10,5)
  Allegiance(Myself,ENEMY)
  HaveSpell(WIZARD_TRUE_SIGHT)
  CheckStat(Myself,0,118)
  OR(2)
    !GlobalTimerNotExpired("SpellCast","LOCALS")
    !GlobalTimerNotExpired("Alacrity","LOCALS")
  Exists(LastAttackerOf(Myself))
  OR(8)
    !See([GOODCUTOFF])
    !See(LastAttackerOf(Myself))
    StateCheck(NearestEnemyOf(Myself),STATE_MIRRORIMAGE)
    StateCheck(NearestEnemyOf(Myself),0x60400010)
    StateCheck(NearestEnemyOf(Myself),STATE_BLUR)
    Gender(NearestEnemyOf(Myself),ILLUSIONARY)
    Specifics(NearestEnemyOf(Myself),207)
    Specifics(NearestEnemyOf(Myself),205)
THEN
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    Spell(Myself,WIZARD_TRUE_SIGHT)
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    RemoveSpell(WIZARD_TRUE_SIGHT)
    ForceSpell(Myself,WIZARD_TRUE_SIGHT)
END

IF
  !GlobalTimerNotExpired("LockTarget","LOCALS")
  !See(NearestEnemyOf(Myself))
  Detect(NearestEnemyOf(Myself))
  HaveSpell(WIZARD_TRUE_SIGHT)
  OR(2)
    !GlobalTimerNotExpired("SpellCast","LOCALS")
    !GlobalTimerNotExpired("Alacrity","LOCALS")
THEN
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    Spell(Myself,WIZARD_TRUE_SIGHT)
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    RemoveSpell(WIZARD_TRUE_SIGHT)
    ForceSpell(Myself,WIZARD_TRUE_SIGHT)
END

IF
  RandomNum(10,10)
  OR(2)
    !GlobalTimerNotExpired("SpellCast","LOCALS")
    GlobalTimerNotExpired("Alacrity","LOCALS")
  HaveSpell(WIZARD_TELEPORT_FIELD)
  Range(SecondNearestEnemyOf(Myself),10)
THEN
  RESPONSE #100
    SetGlobalTimer("SpellCast","LOCALS",6)
    Spell(Myself,WIZARD_TELEPORT_FIELD)
END

IF
  HPLT(Myself,107)
  !GlobalTimerNotExpired("SpellCast","LOCALS")
  !GlobalTimerNotExpired("Alacrity","LOCALS")
  HasItem("finipotn",Myself)  // ~Potion of Superior Healing~
THEN
  RESPONSE #100
    SetGlobalTimer("SpellCast","LOCALS",6)
    DisplayStringHead(Myself,46150)  // ~quaffs a potion~
    UseItem("finipotn",Myself)  // ~Potion of Superior Healing~
END

IF
  !GlobalTimerNotExpired("LockTarget","LOCALS")
  See(NearestEnemyOf(Myself))
  False()
THEN
  RESPONSE #100
END

IF
  !Detect(Player1)
  !Detect(Player2)
  !Detect(Player3)
  !Detect(Player4)
  !Detect(Player5)
  !Detect(Player6)
  Global("party","LOCALS",1)
THEN
  RESPONSE #16
    MoveToObject(Player1)
  RESPONSE #16
    MoveToObject(Player2)
  RESPONSE #17
    MoveToObject(Player3)
  RESPONSE #17
    MoveToObject(Player4)
  RESPONSE #17
    MoveToObject(Player5)
  RESPONSE #17
    MoveToObject(Player6)
END

IF
  StateCheck(LastSeenBy(Myself),STATE_DEAD)
THEN
  RESPONSE #100
    AttackOneRound(NearestEnemyOf(Myself))
END

IF
  !GlobalTimerNotExpired("LockTarget","LOCALS")
  !Allegiance(LastSeenBy(Myself),GOODCUTOFF)
  !InParty(LastSeenBy(Myself))
  See(NearestEnemyOf(Myself))
THEN
  RESPONSE #100
    AttackOneRound(NearestEnemyOf(Myself))
END

IF
  Allegiance(Myself,EVILCUTOFF)
  !GlobalTimerNotExpired("LockTarget","LOCALS")
  !GlobalTimerNotExpired("SpellCast","LOCALS")
  OR(5)
    See(NearestEnemyOf(Myself))
    See([GOODCUTOFF.UNDEAD])
    See([GOODCUTOFF.GIANTHUMANOID])
    See([GOODCUTOFF.ANIMAL])
    See([GOODCUTOFF.MONSTER])
  Gender(LastSeenBy(Myself),SUMMONED)
  LevelLT(LastSeenBy(Myself),11)
THEN
  RESPONSE #50
    SetGlobalTimer("MelissanDeathSpell","LOCALS",30)
    SetGlobalTimer("SpellCast","LOCALS",6)
    ForceSpell(LastSeenBy(Myself),WIZARD_DEATH_SPELL)
  RESPONSE #50
    SetGlobalTimer("MelissanDeathSpell","LOCALS",30)
    SetGlobalTimer("SpellCast","LOCALS",6)
    SpellNoDec(LastSeenBy(Myself),WIZARD_DEATH_SPELL)
END

IF
  Allegiance(Myself,GOODCUTOFF)
  !GlobalTimerNotExpired("LockTarget","LOCALS")
  !GlobalTimerNotExpired("SpellCast","LOCALS")
  OR(5)
    See(NearestEnemyOf(Myself))
    See([EVILCUTOFF.UNDEAD])
    See([EVILCUTOFF.GIANTHUMANOID])
    See([EVILCUTOFF.ANIMAL])
    See([EVILCUTOFF.MONSTER])
  Gender(LastSeenBy(Myself),SUMMONED)
  LevelLT(LastSeenBy(Myself),11)
THEN
  RESPONSE #50
    SetGlobalTimer("MelissanDeathSpell","LOCALS",30)
    SetGlobalTimer("SpellCast","LOCALS",6)
    ForceSpell(LastSeenBy(Myself),WIZARD_DEATH_SPELL)
  RESPONSE #50
    SetGlobalTimer("MelissanDeathSpell","LOCALS",30)
    SetGlobalTimer("SpellCast","LOCALS",6)
    SpellNoDec(LastSeenBy(Myself),WIZARD_DEATH_SPELL)
END

IF
  !GlobalTimerNotExpired("LockTarget","LOCALS")
  !GlobalTimerNotExpired("TimeStop","LOCALS")
  OR(2)
    !GlobalTimerNotExpired("SpellCast","LOCALS")
    GlobalTimerNotExpired("Alacrity","LOCALS")
  HaveSpell(WIZARD_POWER_WORD_KILL)
  OR(6)
    See(Player6)
    See(Player5)
    See(Player4)
    See(Player3)
    See(Player2)
    See(Player1)
  HPGT(LastSeenBy(Myself),60)
  See(Player1)
  HPGT(LastSeenBy(Myself),60)
  See(Player2)
  HPGT(LastSeenBy(Myself),60)
  See(Player3)
  HPGT(LastSeenBy(Myself),60)
  See(Player4)
  HPGT(LastSeenBy(Myself),60)
  See(Player5)
  HPGT(LastSeenBy(Myself),60)
  See(Player6)
  HPGT(LastSeenBy(Myself),60)
  See(NearestEnemyOf(Myself))
  False()
THEN
  RESPONSE #100
END

IF
  !HPGT(LastSeenBy(Myself),60)
  HaveSpell(WIZARD_POWER_WORD_KILL)
  InParty(LastSeenBy(Myself))
  !GlobalTimerNotExpired("TimeStop","LOCALS")
  OR(2)
    !GlobalTimerNotExpired("SpellCast","LOCALS")
    GlobalTimerNotExpired("Alacrity","LOCALS")
  !HasItemEquiped("CLCK26",LastSeenBy(Myself))
  !Difficulty(EASIEST)
THEN
  RESPONSE #40
    SetGlobalTimer("SpellCast","LOCALS",6)
    Spell(LastSeenBy(Myself),WIZARD_POWER_WORD_KILL)
    DisplayStringHead(Myself,34638)  // ~Power Word Kill~
  RESPONSE #60
    SetGlobalTimer("SpellCast","LOCALS",6)
    RemoveSpell(WIZARD_POWER_WORD_KILL)
    ForceSpell(LastSeenBy(Myself),WIZARD_POWER_WORD_KILL)
    DisplayStringHead(Myself,34638)  // ~Power Word Kill~
END

IF
  !GlobalTimerNotExpired("LockTarget","LOCALS")
  GlobalLT("wbreach","LOCALS",5)
  !GlobalTimerNotExpired("SpellCast","LOCALS")
  See(NearestEnemyOf(Myself))
  See(LastSeenBy("finbodhi"))  // finbodhi
  CheckStatLT(LastSeenBy(Myself),1,STONESKINS)
  See(LastSeenBy("finsol04"))  // ~Fallen Solar~
  CheckStatLT(LastSeenBy(Myself),1,STONESKINS)
  See(LastSeenBy("finimoen"))  // ~Imoen~
  CheckStatLT(LastSeenBy(Myself),1,STONESKINS)
  See(LastSeenBy("finbodhi"))  // finbodhi
  CheckStatLT(LastSeenBy(Myself),1,STONESKINS)
  See(NearestEnemyOf(Myself))
  CheckStatLT(LastSeenBy(Myself),1,STONESKINS)
  See(SecondNearestEnemyOf(Myself))
  CheckStatLT(LastSeenBy(Myself),1,STONESKINS)
  See(ThirdNearestEnemyOf(Myself))
  CheckStatLT(LastSeenBy(Myself),1,STONESKINS)
  See(FourthNearestEnemyOf(Myself))
  CheckStatLT(LastSeenBy(Myself),1,STONESKINS)
  See(FifthNearestEnemyOf(Myself))
  CheckStatLT(LastSeenBy(Myself),1,STONESKINS)
  See(SixthNearestEnemyOf(Myself))
  CheckStatLT(LastSeenBy(Myself),1,STONESKINS)
  See(NearestEnemyOf(Myself))
  False()
THEN
  RESPONSE #100
END

IF
  GlobalLT("wbreach","LOCALS",5)
  Allegiance(LastSeenBy(Myself),GOODCUTOFF)
  CheckStatGT(LastSeenBy(Myself),0,STONESKINS)
  !GlobalTimerNotExpired("SpellCast","LOCALS")
  !GlobalTimerNotExpired("Alacrity","LOCALS")
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    IncrementGlobal("wbreach","LOCALS",1)
    SetGlobalTimer("SpellCast","LOCALS",6)
    DisplayStringHead(Myself,31971)  // ~uses a wand~
    UseItem("irenbrch",LastSeenBy(Myself))  // ~Wand of Spell Striking~
    SetInterrupt(TRUE)
END

IF
  HasItemEquiped("CLCK26",LastSeenBy(Myself))
  OR(2)
    !GlobalTimerNotExpired("SpellCast","LOCALS")
    GlobalTimerNotExpired("Alacrity","LOCALS")
  HaveSpell(WIZARD_MAZE)
  OR(2)
    !CheckStatGT(LastSeenBy(Myself),60,RESISTMAGIC)
    Gender(Myself,17)
  !StateCheck(LastSeenBy(Myself),STATE_CONFUSED)
  !StateCheck(LastSeenBy(Myself),STATE_SLEEPING)
  !StateCheck(LastSeenBy(Myself),STATE_STUNNED)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !StateCheck(LastSeenBy(Myself),STATE_PANIC)
  !StateCheck(LastSeenBy(Myself),STATE_FEEBLEMINDED)
  NumInPartyAliveGT(1)
THEN
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    RemoveSpell(WIZARD_MAZE)
    ForceSpell(LastSeenBy(Myself),WIZARD_MAZE)
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    Spell(LastSeenBy(Myself),WIZARD_MAZE)
END

IF
  !HasItemEquiped("CLCK26",LastSeenBy(Myself))
  OR(2)
    Gender(Myself,17)
    RandomNumLT(16,8)
  OR(2)
    !GlobalTimerNotExpired("SpellCast","LOCALS")
    GlobalTimerNotExpired("Alacrity","LOCALS")
  HaveSpell(KAISHAS_CHANGE)
  !CheckStatGT(LastSeenBy(Myself),75,RESISTFIRE)
THEN
  RESPONSE #100
    SetGlobalTimer("SpellCast","LOCALS",6)
    Spell(LastSeenBy(Myself),KAISHAS_CHANGE)
END

IF
  OR(2)
    Gender(Myself,17)
    RandomNumLT(18,5)
  OR(2)
    !GlobalTimerNotExpired("SpellCast","LOCALS")
    GlobalTimerNotExpired("Alacrity","LOCALS")
  HaveSpell(WIZARD_DRAGONS_BREATH)
  !CheckStatGT(LastSeenBy(Myself),75,RESISTFIRE)
  !CheckStatGT(LastSeenBy(Myself),80,RESISTMAGIC)
  !HasItemEquiped("CLCK26",LastSeenBy(Myself))
THEN
  RESPONSE #100
    SetGlobalTimer("SpellCast","LOCALS",6)
    Spell(LastSeenBy(Myself),WIZARD_DRAGONS_BREATH)
END

IF
  OR(2)
    RandomNumLT(24,13)
    !HaveSpell(WIZARD_TIME_STOP)
  OR(2)
    !GlobalTimerNotExpired("SpellCast","LOCALS")
    GlobalTimerNotExpired("Alacrity","LOCALS")
  HaveSpell(WIZARD_ABI_DALZIMS_HORRID_WILTING)
  !CheckStatGT(LastSeenBy(Myself),50,MAGICDAMAGERESISTANCE)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !HasItemEquiped("CLCK26",LastSeenBy(Myself))
THEN
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    Spell(LastSeenBy(Myself),WIZARD_ABI_DALZIMS_HORRID_WILTING)
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    RemoveSpell(WIZARD_ABI_DALZIMS_HORRID_WILTING)
    ForceSpell(LastSeenBy(Myself),WIZARD_ABI_DALZIMS_HORRID_WILTING)
END

IF
  RandomNumGT(36,12)
  Allegiance(Myself,EVILCUTOFF)
  !GlobalTimerNotExpired("LockTarget","LOCALS")
  OR(6)
    See(TenthNearestEnemyOf(Myself))
    See([GOODCUTOFF.0.0.BARD_ALL])
    See([GOODCUTOFF.0.0.CLERIC_ALL])
    See([GOODCUTOFF.0.0.DRUID_ALL])
    See([GOODCUTOFF.0.0.MAGE_ALL])
    See([GOODCUTOFF.0.0.SORCERER])
  False()
THEN
  RESPONSE #100
END

IF
  RandomNumGT(36,12)
  Allegiance(Myself,GOODCUTOFF)
  !GlobalTimerNotExpired("LockTarget","LOCALS")
  OR(6)
    See(TenthNearestEnemyOf(Myself))
    See([EVILCUTOFF.0.0.BARD_ALL])
    See([EVILCUTOFF.0.0.CLERIC_ALL])
    See([EVILCUTOFF.0.0.DRUID_ALL])
    See([EVILCUTOFF.0.0.LONG_BOW])
    See([EVILCUTOFF.0.0.SORCERER])
  False()
THEN
  RESPONSE #100
END

IF
  RandomNumGT(36,12)
  RandomNumGT(9,3)
  OR(6)
    See(NinthNearestEnemyOf(Myself))
    See(SecondNearestEnemyOfType([0.0.0.BARD_ALL]))
    See(SecondNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(SecondNearestEnemyOfType([0.0.0.DRUID_ALL]))
    See(SecondNearestEnemyOfType([0.0.0.LONG_BOW]))
    See(SecondNearestEnemyOfType([0.0.0.SORCERER]))
  RandomNumGT(9,5)
  OR(6)
    See(EighthNearestEnemyOf(Myself))
    See(ThirdNearestEnemyOfType([0.0.0.BARD_ALL]))
    See(ThirdNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(ThirdNearestEnemyOfType([0.0.0.DRUID_ALL]))
    See(ThirdNearestEnemyOfType([0.0.0.LONG_BOW]))
    See(ThirdNearestEnemyOfType([0.0.0.SORCERER]))
  RandomNumGT(9,7)
  OR(6)
    See(SeventhNearestEnemyOf(Myself))
    See(FourthNearestEnemyOfType([0.0.0.BARD_ALL]))
    See(FourthNearestEnemyOfType([0.0.0.CLERIC_ALL]))
    See(FourthNearestEnemyOfType([0.0.0.DRUID_ALL]))
    See(FourthNearestEnemyOfType([0.0.0.LONG_BOW]))
    See(FourthNearestEnemyOfType([0.0.0.SORCERER]))
  False()
THEN
  RESPONSE #100
END

IF
  RandomNumLT(36,13)
  Allegiance(Myself,EVILCUTOFF)
  !GlobalTimerNotExpired("LockTarget","LOCALS")
  OR(6)
    See(TenthNearestEnemyOf(Myself))
    See(StrongestOf)
    See([GOODCUTOFF.0.0.FIGHTER_ALL])
    See([GOODCUTOFF.0.0.RANGER_ALL])
    See([GOODCUTOFF.0.0.PALADIN_ALL])
    See(BestAC)
  False()
THEN
  RESPONSE #100
END

IF
  RandomNumLT(36,13)
  Allegiance(Myself,GOODCUTOFF)
  !GlobalTimerNotExpired("LockTarget","LOCALS")
  OR(4)
    See(TenthNearestEnemyOf(Myself))
    See([EVILCUTOFF.0.0.FIGHTER_ALL])
    See([EVILCUTOFF.0.0.RANGER_ALL])
    See([EVILCUTOFF.0.0.PALADIN_ALL])
  False()
THEN
  RESPONSE #100
END

IF
  RandomNumLT(36,13)
  !GlobalTimerNotExpired("LockTarget","LOCALS")
  RandomNumGT(9,4)
  See(SecondNearestEnemyOfType([0.0.0.FIGHTER_ALL]))
  See(SecondNearestEnemyOfType([0.0.0.RANGER_ALL]))
  See(SecondNearestEnemyOfType([0.0.0.PALADIN_ALL]))
  RandomNumGT(9,6)
  See(ThirdNearestEnemyOfType([0.0.0.FIGHTER_ALL]))
  See(ThirdNearestEnemyOfType([0.0.0.RANGER_ALL]))
  See(ThirdNearestEnemyOfType([0.0.0.PALADIN_ALL]))
  RandomNumGT(9,8)
  See(FourthNearestEnemyOfType([0.0.0.FIGHTER_ALL]))
  See(FourthNearestEnemyOfType([0.0.0.RANGER_ALL]))
  See(FourthNearestEnemyOfType([0.0.0.PALADIN_ALL]))
  False()
THEN
  RESPONSE #100
END

IF
  HasItemEquiped("CLCK26",LastSeenBy(Myself))
  OR(2)
    !GlobalTimerNotExpired("SpellCast","LOCALS")
    GlobalTimerNotExpired("Alacrity","LOCALS")
  HaveSpell(WIZARD_MAZE)
  OR(2)
    !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
    Gender(Myself,17)
  !StateCheck(LastSeenBy(Myself),STATE_CONFUSED)
  !StateCheck(LastSeenBy(Myself),STATE_SLEEPING)
  !StateCheck(LastSeenBy(Myself),STATE_STUNNED)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !StateCheck(LastSeenBy(Myself),STATE_PANIC)
  !StateCheck(LastSeenBy(Myself),STATE_FEEBLEMINDED)
  NumInPartyAliveGT(1)
THEN
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    RemoveSpell(WIZARD_MAZE)
    ForceSpell(LastSeenBy(Myself),WIZARD_MAZE)
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    Spell(LastSeenBy(Myself),WIZARD_MAZE)
END

IF
  !GlobalTimerNotExpired("LockTarget","LOCALS")
  HasItemEquiped("CLCK26",LastSeenBy(Myself))
  Allegiance(Myself,EVILCUTOFF)
  See(BestAC)
  HasItemEquiped("CLCK26",LastSeenBy(Myself))
  See(StrongestOf)
  HasItemEquiped("CLCK26",LastSeenBy(Myself))
  OR(2)
    See([GOODCUTOFF.0.0.MAGE_ALL])
    See([GOODCUTOFF.0.0.SORCERER])
  HasItemEquiped("CLCK26",LastSeenBy(Myself))
  OR(3)
    See([GOODCUTOFF.0.0.BARD_ALL])
    See([GOODCUTOFF.0.0.CLERIC_ALL])
    See([GOODCUTOFF.0.0.DRUID_ALL])
  HasItemEquiped("CLCK26",LastSeenBy(Myself))
  See(NearestEnemyOf(Myself))
  HasItemEquiped("CLCK26",LastSeenBy(Myself))
  See(SecondNearestEnemyOf(Myself))
  HasItemEquiped("CLCK26",LastSeenBy(Myself))
  See(ThirdNearestEnemyOf(Myself))
THEN
  RESPONSE #16
    MoveToObject(Player1)
  RESPONSE #16
    MoveToObject(Player2)
  RESPONSE #17
    MoveToObject(Player3)
  RESPONSE #17
    MoveToObject(Player4)
  RESPONSE #17
    MoveToObject(Player5)
  RESPONSE #17
    MoveToObject(Player6)
END

IF
  RandomNumLT(44,23)
  Allegiance(LastSeenBy(Myself),GOODCUTOFF)
  !HasItemEquiped("CLCK26",LastSeenBy(Myself))
  !HasItemEquiped("BLUN30",LastSeenBy(Myself))
  !HasItemEquiped("RING09",LastSeenBy(Myself))
  !HasItemEquiped("NPPLAT",LastSeenBy(Myself))
  OR(2)
    !GlobalTimerNotExpired("SpellCast","LOCALS")
    GlobalTimerNotExpired("Alacrity","LOCALS")
  !GlobalTimerNotExpired("TimeStop","LOCALS")
  HaveSpell(WIZARD_POWER_WORD_STUN)
  HPLT(LastSeenBy(Myself),91)
  !CheckStatGT(LastSeenBy(Myself),40,RESISTMAGIC)
THEN
  RESPONSE #100
    SetGlobalTimer("SpellCast","LOCALS",6)
    Spell(LastSeenBy(Myself),WIZARD_POWER_WORD_STUN)
END

IF
  OR(2)
    !GlobalTimerNotExpired("SpellCast","LOCALS")
    GlobalTimerNotExpired("Alacrity","LOCALS")
  HaveSpell(WIZARD_LOWER_RESISTANCE)
  CheckStatGT(LastSeenBy(Myself),60,RESISTMAGIC)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    SetGlobalTimer("SpellCast","LOCALS",6)
    Spell(LastSeenBy(Myself),WIZARD_LOWER_RESISTANCE)
    Spell(LastSeenBy(Myself),WIZARD_LOWER_RESISTANCE)
    SetInterrupt(TRUE)
END

IF
  OR(2)
    !GlobalTimerNotExpired("SpellCast","LOCALS")
    GlobalTimerNotExpired("Alacrity","LOCALS")
  !GlobalTimerNotExpired("TimeStop","LOCALS")
  HaveSpell(WIZARD_LOWER_RESISTANCE)
  CheckStatGT(LastSeenBy(Myself),30,RESISTMAGIC)
THEN
  RESPONSE #100
    IncrementGlobal("LowerRes","LOCALS",1)
    SetGlobalTimer("SpellCast","LOCALS",6)
    Spell(LastSeenBy(Myself),WIZARD_LOWER_RESISTANCE)
END

IF
  GlobalLT("wpierce","LOCALS",5)
  RandomNumLT(48,25)
  !GlobalTimerNotExpired("SpellCast","LOCALS")
  !GlobalTimerNotExpired("Alacrity","LOCALS")
  !HaveSpell(WIZARD_LOWER_RESISTANCE)
  CheckStatGT(LastSeenBy(Myself),30,RESISTMAGIC)
THEN
  RESPONSE #100
    SetInterrupt(FALSE)
    IncrementGlobal("wpierce","LOCALS",1)
    SetGlobalTimer("SpellCast","LOCALS",6)
    DisplayStringHead(Myself,31971)  // ~uses a wand~
    UseItem("irenprce",LastSeenBy(Myself))  // ~Wand of Spell Striking~
    SetInterrupt(TRUE)
END

IF
  OR(2)
    Gender(Myself,17)
    RandomNumLT(15,4)
  !GlobalTimerNotExpired("TimeStop","LOCALS")
  OR(2)
    !GlobalTimerNotExpired("SpellCast","LOCALS")
    GlobalTimerNotExpired("Alacrity","LOCALS")
  HaveSpell(WIZARD_MAZE)
  OR(2)
    CheckStatLT(LastSeenBy(Myself),40,RESISTMAGIC)
    Gender(Myself,17)
  !StateCheck(LastSeenBy(Myself),STATE_CONFUSED)
  !StateCheck(LastSeenBy(Myself),STATE_SLEEPING)
  !StateCheck(LastSeenBy(Myself),STATE_STUNNED)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !StateCheck(LastSeenBy(Myself),STATE_PANIC)
  !StateCheck(LastSeenBy(Myself),STATE_FEEBLEMINDED)
  !HPLT(LastSeenBy(Myself),60)
  InParty(LastSeenBy(Myself))
  NumInPartyAliveGT(1)
THEN
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    RemoveSpell(WIZARD_MAZE)
    ForceSpell(LastSeenBy(Myself),WIZARD_MAZE)
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    Spell(LastSeenBy(Myself),WIZARD_MAZE)
END

IF
  OR(3)
    RandomNum(10,3)
    RandomNum(10,7)
    RandomNum(10,10)
  OR(2)
    !GlobalTimerNotExpired("SpellCast","LOCALS")
    GlobalTimerNotExpired("Alacrity","LOCALS")
  HaveSpell(WIZARD_POWER_WORD_BLIND)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !StateCheck(LastSeenBy(Myself),STATE_BLIND)
  CheckStat(LastSeenBy(Myself),0,129)
  !HasItemEquiped("CLCK26",LastSeenBy(Myself))
THEN
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    RemoveSpell(WIZARD_POWER_WORD_BLIND)
    ForceSpell(LastSeenBy(Myself),WIZARD_POWER_WORD_BLIND)
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    Spell(LastSeenBy(Myself),WIZARD_POWER_WORD_BLIND)
END

IF
  HaveSpell(2302)
  RandomNumLT(33,11)
  !GlobalTimerNotExpired("SpellCast","LOCALS")
  !GlobalTimerNotExpired("Alacrity","LOCALS")
  Allegiance(LastSeenBy(Myself),GOODCUTOFF)
  OR(6)
    HasImmunityEffects(LastSeenBy(Myself))
    HasBounceEffects(LastSeenBy(Myself))
    StateCheck(LastSeenBy(Myself),STATE_BLESS)
    StateCheck(LastSeenBy(Myself),STATE_HASTED)
    StateCheck(LastSeenBy(Myself),STATE_LUCK)
    StateCheck(LastSeenBy(Myself),STATE_CHANT)
  !GlobalTimerNotExpired("RemoveMagic","LOCALS")
THEN
  RESPONSE #100
    SetGlobalTimer("SpellCast","LOCALS",6)
    SetGlobalTimer("RemoveMagic","LOCALS",36)
    ForceSpell(LastSeenBy(Myself),2302)
    RemoveSpell(2302)
END

IF
  RandomNumLT(25,11)
  OR(2)
    !GlobalTimerNotExpired("SpellCast","LOCALS")
    !GlobalTimerNotExpired("Alacrity","LOCALS")
  !GlobalTimerNotExpired("TimeStop","LOCALS")
  HaveSpell(WIZARD_GREATER_MALISON)
  !CheckStatGT(LastSeenBy(Myself),0,180)
  !GlobalTimerNotExpired("Malison","LOCALS")
THEN
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    SetGlobalTimer("Malison","LOCALS",15)
    Spell(LastSeenBy(Myself),WIZARD_GREATER_MALISON)
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    SetGlobalTimer("Malison","LOCALS",15)
    RemoveSpell(WIZARD_GREATER_MALISON)
    ForceSpell(LastSeenBy(Myself),WIZARD_GREATER_MALISON)
END

IF
  RandomNumLT(35,12)
  !GlobalTimerNotExpired("SpellCast","LOCALS")
  !GlobalTimerNotExpired("Alacrity","LOCALS")
  HaveSpell(WIZARD_MORDENKAINENS_SWORD)
THEN
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    Spell(LastSeenBy(Myself),WIZARD_MORDENKAINENS_SWORD)
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    RemoveSpell(WIZARD_MORDENKAINENS_SWORD)
    ForceSpell(LastSeenBy(Myself),WIZARD_MORDENKAINENS_SWORD)
  RESPONSE #500
    Continue()
END

IF
  RandomNumLT(37,12)
  !GlobalTimerNotExpired("SpellCast","LOCALS")
  !GlobalTimerNotExpired("Alacrity","LOCALS")
  HaveSpell(WIZARD_SUMMON_EFREET)
THEN
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    Spell(LastSeenBy(Myself),WIZARD_SUMMON_EFREET)
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    RemoveSpell(WIZARD_SUMMON_EFREET)
    ForceSpell(LastSeenBy(Myself),WIZARD_SUMMON_EFREET)
  RESPONSE #100
    Continue()
END

IF
  RandomNumLT(55,23)
  !GlobalTimerNotExpired("SpellCast","LOCALS")
  !GlobalTimerNotExpired("Alacrity","LOCALS")
  OR(3)
    Exists(NearestEnemyOfType([0.0.0.LONG_BOW]))
    Exists(NearestEnemyOfType([0.0.0.SORCERER]))
    Exists(NearestEnemyOfType([0.0.0.BARD_ALL]))
  HaveSpell(WIZARD_SUMMON_HAKEASHAR)
THEN
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    Spell(LastSeenBy(Myself),WIZARD_SUMMON_HAKEASHAR)
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    RemoveSpell(WIZARD_SUMMON_HAKEASHAR)
    ForceSpell(LastSeenBy(Myself),WIZARD_SUMMON_HAKEASHAR)
END

IF
  !Gender(Myself,17)
  !Specifics(Myself,207)
  !GlobalTimerNotExpired("SpellCast","LOCALS")
  !GlobalTimerNotExpired("Alacrity","LOCALS")
  OR(3)
    Range(ThirdNearestEnemyOf(Myself),15)
    NumInPartyAliveLT(3)
    RandomNumLT(69,49)
  OR(3)
    Range(SecondNearestEnemyOf(Myself),15)
    NumInPartyAliveLT(2)
    RandomNumLT(67,22)
  Range(NearestEnemyOf(Myself),15)
  OR(2)
    !Range(SecondNearest([EVILCUTOFF]),15)
    Range(ThirdNearestEnemyOf(Myself),15)
THEN
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    Spell(Myself,WIZARD_SUN_FIRE)
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    RemoveSpell(WIZARD_SUN_FIRE)
    ForceSpell(Myself,WIZARD_SUN_FIRE)
END

IF
  !GlobalTimerNotExpired("SpellCast","LOCALS")
  !GlobalTimerNotExpired("Alacrity","LOCALS")
  OR(3)
    Range(ThirdNearestEnemyOf(Myself),15)
    NumInPartyAliveLT(3)
    RandomNumLT(69,49)
  OR(3)
    Range(SecondNearestEnemyOf(Myself),15)
    NumInPartyAliveLT(2)
    RandomNumLT(67,22)
  Range(NearestEnemyOf(Myself),15)
  !Range(SecondNearest([EVILCUTOFF]),15)
THEN
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    Spell(Myself,WIZARD_SUN_FIRE)
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    RemoveSpell(WIZARD_SUN_FIRE)
    ForceSpell(Myself,WIZARD_SUN_FIRE)
END

IF
  RandomNumLT(71,23)
  OR(2)
    !GlobalTimerNotExpired("SpellCast","LOCALS")
    GlobalTimerNotExpired("Alacrity","LOCALS")
  HaveSpell(WIZARD_CHAIN_LIGHTNING)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTELECTRICITY)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !HasItemEquiped("CLCK26",LastSeenBy(Myself))
THEN
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    Spell(LastSeenBy(Myself),WIZARD_CHAIN_LIGHTNING)
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    RemoveSpell(WIZARD_CHAIN_LIGHTNING)
    ForceSpell(LastSeenBy(Myself),WIZARD_CHAIN_LIGHTNING)
  RESPONSE #50
    Continue()
END

IF
  !Gender(Myself,17)
  !Range(LastSeenBy(Myself),10)
  OR(2)
    Specifics(Myself,207)
    RandomNumLT(43,14)
  OR(2)
    !GlobalTimerNotExpired("SpellCast","LOCALS")
    GlobalTimerNotExpired("Alacrity","LOCALS")
  HaveSpell(WIZARD_SKULL_TRAP)
  !CheckStatGT(LastSeenBy(Myself),50,MAGICDAMAGERESISTANCE)
  !HasItemEquiped("CLCK26",LastSeenBy(Myself))
THEN
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    Spell(LastSeenBy(Myself),WIZARD_SKULL_TRAP)
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    RemoveSpell(WIZARD_SKULL_TRAP)
    ForceSpell(LastSeenBy(Myself),WIZARD_SKULL_TRAP)
END

IF
  OR(2)
    Gender(Myself,17)
    RandomNumLT(47,32)
  OR(2)
    !GlobalTimerNotExpired("SpellCast","LOCALS")
    GlobalTimerNotExpired("Alacrity","LOCALS")
  HaveSpell(WIZARD_CONE_OF_COLD)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTCOLD)
  OR(2)
    !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
    RandomNumGT(10,8)
  !HasItemEquiped("CLCK26",LastSeenBy(Myself))
THEN
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    Spell(LastSeenBy(Myself),WIZARD_CONE_OF_COLD)
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    RemoveSpell(WIZARD_CONE_OF_COLD)
    ForceSpell(LastSeenBy(Myself),WIZARD_CONE_OF_COLD)
END

IF
  RandomNumGT(48,24)
  OR(2)
    !GlobalTimerNotExpired("SpellCast","LOCALS")
    GlobalTimerNotExpired("Alacrity","LOCALS")
  HaveSpell(WIZARD_DISINTEGRATE)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !HasItemEquiped("CLCK26",LastSeenBy(Myself))
THEN
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    Spell(LastSeenBy(Myself),WIZARD_DISINTEGRATE)
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    RemoveSpell(WIZARD_DISINTEGRATE)
    ForceSpell(LastSeenBy(Myself),WIZARD_DISINTEGRATE)
END

IF
  RandomNumGT(49,27)
  OR(2)
    !GlobalTimerNotExpired("SpellCast","LOCALS")
    GlobalTimerNotExpired("Alacrity","LOCALS")
  HaveSpell(WIZARD_FINGER_OF_DEATH)
  CheckStatLT(LastSeenBy(Myself),30,RESISTMAGIC)
  !CheckStatLT(LastSeenBy(Myself),0,SAVEVSDEATH)
  !StateCheck(LastSeenBy(Myself),STATE_SLEEPING)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !HasItemEquiped("CLCK26",LastSeenBy(Myself))
THEN
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    Spell(LastSeenBy(Myself),WIZARD_FINGER_OF_DEATH)
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    RemoveSpell(WIZARD_FINGER_OF_DEATH)
    ForceSpell(LastSeenBy(Myself),WIZARD_FINGER_OF_DEATH)
END

IF
  RandomNumGT(51,30)
  OR(2)
    !GlobalTimerNotExpired("SpellCast","LOCALS")
    GlobalTimerNotExpired("Alacrity","LOCALS")
  HaveSpell(WIZARD_FLESH_TO_STONE)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
THEN
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    Spell(LastSeenBy(Myself),WIZARD_FLESH_TO_STONE)
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    RemoveSpell(WIZARD_FLESH_TO_STONE)
    ForceSpell(LastSeenBy(Myself),WIZARD_FLESH_TO_STONE)
END

IF
  RandomNumGT(54,27)
  OR(2)
    !GlobalTimerNotExpired("SpellCast","LOCALS")
    GlobalTimerNotExpired("Alacrity","LOCALS")
  HaveSpell(WIZARD_POWER_WORD_SILENCE)
  !StateCheck(LastSeenBy(Myself),STATE_SILENCED)
  CheckStatLT(LastSeenBy(Myself),50,RESISTMAGIC)
  !HasItemEquiped("CLCK26",LastSeenBy(Myself))
  !HasItem("AMUL21",LastSeenBy(Myself))  // ~Amulet of Power~
  OR(4)
    Class(LastSeenBy(Myself),BARD_ALL)
    Class(LastSeenBy(Myself),DRUID_ALL)
    Class(LastSeenBy(Myself),CLERIC_ALL)
    Class(LastSeenBy(Myself),MAGE_ALL)
THEN
  RESPONSE #100
    SetGlobalTimer("SpellCast","LOCALS",6)
    Spell(LastSeenBy(Myself),WIZARD_POWER_WORD_SILENCE)
END

IF
  RandomNumGT(56,22)
  !GlobalTimerNotExpired("SpellCast","LOCALS")
  !GlobalTimerNotExpired("Alacrity","LOCALS")
  HaveSpell(WIZARD_FEEBLEMIND)
  !Global("CloseCombat","GLOBAL",1)
  CheckStatLT(LastSeenBy(Myself),50,RESISTMAGIC)
  !StateCheck(LastSeenBy(Myself),STATE_FEEBLEMINDED)
  OR(4)
    Class(LastSeenBy(Myself),BARD_ALL)
    Class(LastSeenBy(Myself),DRUID_ALL)
    Class(LastSeenBy(Myself),CLERIC_ALL)
    Class(LastSeenBy(Myself),MAGE_ALL)
THEN
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    Spell(LastSeenBy(Myself),WIZARD_FEEBLEMIND)
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    RemoveSpell(WIZARD_FEEBLEMIND)
    ForceSpell(LastSeenBy(Myself),WIZARD_FEEBLEMIND)
END

IF
  RandomNumGT(58,34)
  !GlobalTimerNotExpired("SpellCast","LOCALS")
  !GlobalTimerNotExpired("Alacrity","LOCALS")
  HaveSpell(WIZARD_CONTAGION)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
THEN
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    Spell(LastSeenBy(Myself),WIZARD_CONTAGION)
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    RemoveSpell(WIZARD_CONTAGION)
    ForceSpell(LastSeenBy(Myself),WIZARD_CONTAGION)
END

IF
  OR(2)
    !GlobalTimerNotExpired("SpellCast","LOCALS")
    GlobalTimerNotExpired("Alacrity","LOCALS")
  HaveSpell(WIZARD_CHAOS)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !StateCheck(LastSeenBy(Myself),STATE_CONFUSED)
  !StateCheck(LastSeenBy(Myself),STATE_SLEEPING)
  !StateCheck(LastSeenBy(Myself),STATE_STUNNED)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !HasItemEquiped("CLCK26",LastSeenBy(Myself))
THEN
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    Spell(LastSeenBy(Myself),WIZARD_CHAOS)
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    RemoveSpell(WIZARD_CHAOS)
    ForceSpell(LastSeenBy(Myself),WIZARD_CHAOS)
END

IF
  HaveSpell(WIZARD_FLAME_ARROW)
  OR(2)
    !GlobalTimerNotExpired("SpellCast","LOCALS")
    GlobalTimerNotExpired("Alacrity","LOCALS")
  !HasItemEquiped("CLCK26",LastSeenBy(Myself))
THEN
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    Spell(LastSeenBy(Myself),WIZARD_FLAME_ARROW)
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    RemoveSpell(WIZARD_FLAME_ARROW)
    ForceSpell(LastSeenBy(Myself),WIZARD_FLAME_ARROW)
END

IF
  HaveSpell(WIZARD_MAGIC_MISSILE)
  OR(2)
    !GlobalTimerNotExpired("SpellCast","LOCALS")
    GlobalTimerNotExpired("Alacrity","LOCALS")
  !HasItemEquiped("CLCK26",LastSeenBy(Myself))
THEN
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    Spell(LastSeenBy(Myself),WIZARD_MAGIC_MISSILE)
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    RemoveSpell(WIZARD_MAGIC_MISSILE)
    ForceSpell(LastSeenBy(Myself),WIZARD_MAGIC_MISSILE)
END

IF
  HaveSpell(WIZARD_MELF_ACID_ARROW)
  OR(2)
    !GlobalTimerNotExpired("SpellCast","LOCALS")
    GlobalTimerNotExpired("Alacrity","LOCALS")
  !HasItemEquiped("CLCK26",LastSeenBy(Myself))
THEN
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    Spell(LastSeenBy(Myself),WIZARD_MELF_ACID_ARROW)
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    RemoveSpell(WIZARD_MELF_ACID_ARROW)
    ForceSpell(LastSeenBy(Myself),WIZARD_MELF_ACID_ARROW)
END

IF
  OR(2)
    !GlobalTimerNotExpired("SpellCast","LOCALS")
    GlobalTimerNotExpired("Alacrity","LOCALS")
  HaveSpell(KAISHAS_CHANGE)
  !CheckStatGT(LastSeenBy(Myself),75,RESISTFIRE)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !HasItemEquiped("CLCK26",LastSeenBy(Myself))
THEN
  RESPONSE #100
    SetGlobalTimer("SpellCast","LOCALS",6)
    Spell(LastSeenBy(Myself),KAISHAS_CHANGE)
END

IF
  OR(2)
    !GlobalTimerNotExpired("SpellCast","LOCALS")
    GlobalTimerNotExpired("Alacrity","LOCALS")
  HaveSpell(WIZARD_DRAGONS_BREATH)
  !CheckStatGT(LastSeenBy(Myself),75,RESISTFIRE)
  !HasItemEquiped("CLCK26",LastSeenBy(Myself))
THEN
  RESPONSE #100
    SetGlobalTimer("SpellCast","LOCALS",6)
    Spell(LastSeenBy(Myself),WIZARD_DRAGONS_BREATH)
END

IF
  !GlobalTimerNotExpired("TimeStop","LOCALS")
  OR(2)
    !GlobalTimerNotExpired("SpellCast","LOCALS")
    GlobalTimerNotExpired("Alacrity","LOCALS")
  HaveSpell(WIZARD_MAZE)
  OR(2)
    CheckStatLT(LastSeenBy(Myself),40,RESISTMAGIC)
    Gender(Myself,17)
  !StateCheck(LastSeenBy(Myself),STATE_CONFUSED)
  !StateCheck(LastSeenBy(Myself),STATE_SLEEPING)
  !StateCheck(LastSeenBy(Myself),STATE_STUNNED)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  !StateCheck(LastSeenBy(Myself),STATE_PANIC)
  !StateCheck(LastSeenBy(Myself),STATE_FEEBLEMINDED)
  !HPLT(LastSeenBy(Myself),60)
  InParty(LastSeenBy(Myself))
  NumInPartyAliveGT(1)
THEN
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    RemoveSpell(WIZARD_MAZE)
    ForceSpell(LastSeenBy(Myself),WIZARD_MAZE)
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    Spell(LastSeenBy(Myself),WIZARD_MAZE)
END

IF
  OR(2)
    !GlobalTimerNotExpired("SpellCast","LOCALS")
    GlobalTimerNotExpired("Alacrity","LOCALS")
  HaveSpell(WIZARD_ABI_DALZIMS_HORRID_WILTING)
  !CheckStatGT(LastSeenBy(Myself),50,MAGICDAMAGERESISTANCE)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !HasItemEquiped("CLCK26",LastSeenBy(Myself))
THEN
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    Spell(LastSeenBy(Myself),WIZARD_ABI_DALZIMS_HORRID_WILTING)
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    RemoveSpell(WIZARD_ABI_DALZIMS_HORRID_WILTING)
    ForceSpell(LastSeenBy(Myself),WIZARD_ABI_DALZIMS_HORRID_WILTING)
END

IF
  OR(2)
    !GlobalTimerNotExpired("SpellCast","LOCALS")
    GlobalTimerNotExpired("Alacrity","LOCALS")
  HaveSpell(WIZARD_CHAIN_LIGHTNING)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTELECTRICITY)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !HasItemEquiped("CLCK26",LastSeenBy(Myself))
THEN
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    Spell(LastSeenBy(Myself),WIZARD_CHAIN_LIGHTNING)
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    RemoveSpell(WIZARD_CHAIN_LIGHTNING)
    ForceSpell(LastSeenBy(Myself),WIZARD_CHAIN_LIGHTNING)
  RESPONSE #50
    Continue()
END

IF
  !Gender(Myself,17)
  !Range(LastSeenBy(Myself),10)
  OR(2)
    !GlobalTimerNotExpired("SpellCast","LOCALS")
    GlobalTimerNotExpired("Alacrity","LOCALS")
  HaveSpell(WIZARD_SKULL_TRAP)
  !CheckStatGT(LastSeenBy(Myself),50,MAGICDAMAGERESISTANCE)
  !HasItemEquiped("CLCK26",LastSeenBy(Myself))
THEN
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    Spell(LastSeenBy(Myself),WIZARD_SKULL_TRAP)
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    RemoveSpell(WIZARD_SKULL_TRAP)
    ForceSpell(LastSeenBy(Myself),WIZARD_SKULL_TRAP)
END

IF
  OR(2)
    !GlobalTimerNotExpired("SpellCast","LOCALS")
    GlobalTimerNotExpired("Alacrity","LOCALS")
  HaveSpell(WIZARD_FLESH_TO_STONE)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
THEN
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    Spell(LastSeenBy(Myself),WIZARD_FLESH_TO_STONE)
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    RemoveSpell(WIZARD_FLESH_TO_STONE)
    ForceSpell(LastSeenBy(Myself),WIZARD_FLESH_TO_STONE)
END

IF
  !GlobalTimerNotExpired("SpellCast","LOCALS")
  !GlobalTimerNotExpired("Alacrity","LOCALS")
  OR(3)
    Class(LastSeenBy(Myself),MAGE_ALL)
    Class(LastSeenBy(Myself),SORCERER)
    Class(LastSeenBy(Myself),BARD_ALL)
  HaveSpell(WIZARD_SUMMON_HAKEASHAR)
THEN
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    Spell(LastSeenBy(Myself),WIZARD_SUMMON_HAKEASHAR)
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    RemoveSpell(WIZARD_SUMMON_HAKEASHAR)
    ForceSpell(LastSeenBy(Myself),WIZARD_SUMMON_HAKEASHAR)
END

IF
  !GlobalTimerNotExpired("SpellCast","LOCALS")
  !GlobalTimerNotExpired("Alacrity","LOCALS")
  HaveSpell(WIZARD_MORDENKAINENS_SWORD)
THEN
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    Spell(LastSeenBy(Myself),WIZARD_MORDENKAINENS_SWORD)
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    RemoveSpell(WIZARD_MORDENKAINENS_SWORD)
    ForceSpell(LastSeenBy(Myself),WIZARD_MORDENKAINENS_SWORD)
  RESPONSE #50
    Continue()
END

IF
  !GlobalTimerNotExpired("SpellCast","LOCALS")
  !GlobalTimerNotExpired("Alacrity","LOCALS")
  HaveSpell(WIZARD_SUMMON_EFREET)
THEN
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    Spell(LastSeenBy(Myself),WIZARD_SUMMON_EFREET)
  RESPONSE #50
    SetGlobalTimer("SpellCast","LOCALS",6)
    RemoveSpell(WIZARD_SUMMON_EFREET)
    ForceSpell(LastSeenBy(Myself),WIZARD_SUMMON_EFREET)
END

IF
  !GlobalTimerNotExpired("WeapProt","LOCALS")
  !GlobalTimerNotExpired("SpellCast","LOCALS")
  !GlobalTimerNotExpired("Alacrity","LOCALS")
  CheckStat(Myself,0,125)
  HaveSpell(WIZARD_FIRE_SHIELD_RED)
THEN
  RESPONSE #60
    SetGlobalTimer("SpellCast","LOCALS",6)
    Spell(Myself,WIZARD_FIRE_SHIELD_RED)
  RESPONSE #40
    SetGlobalTimer("SpellCast","LOCALS",6)
    RemoveSpell(WIZARD_FIRE_SHIELD_RED)
    ForceSpell(Myself,WIZARD_FIRE_SHIELD_RED)
END

IF
  !GlobalTimerNotExpired("WeapProt","LOCALS")
  !GlobalTimerNotExpired("SpellCast","LOCALS")
  !GlobalTimerNotExpired("Alacrity","LOCALS")
  HaveSpell(WIZARD_FIRE_SHIELD_BLUE)
  CheckStat(Myself,0,125)
THEN
  RESPONSE #60
    SetGlobalTimer("SpellCast","LOCALS",6)
    Spell(Myself,WIZARD_FIRE_SHIELD_BLUE)
  RESPONSE #40
    SetGlobalTimer("SpellCast","LOCALS",6)
    RemoveSpell(WIZARD_FIRE_SHIELD_BLUE)
    ForceSpell(Myself,WIZARD_FIRE_SHIELD_BLUE)
END

IF
  HPLT(Myself,107)
  !GlobalTimerNotExpired("SpellCast","LOCALS")
  !GlobalTimerNotExpired("Alacrity","LOCALS")
  HasItem("finipotn",Myself)  // ~Potion of Superior Healing~
THEN
  RESPONSE #100
    SetGlobalTimer("SpellCast","LOCALS",6)
    DisplayStringHead(Myself,46150)  // ~quaffs a potion~
    UseItem("finipotn",Myself)  // ~Potion of Superior Healing~
END

IF
  !GlobalTimerNotExpired("LockTarget","LOCALS")
  See(NearestEnemyOf(Myself))
  See(LastSeenBy([EVILCUTOFF]))
  RandomNumGT(5,2)
  See(WorstAC)
  RandomNumGT(7,3)
  See([GOODCUTOFF.0.ELF])
  False()
THEN
  RESPONSE #100
END

IF
  !Gender(Myself,ILLUSIONARY)
  !GlobalTimerNotExpired("LockTarget","LOCALS")
  RandomNumGT(4,1)
  See(NearestEnemyOf(Myself))
  OR(2)
    !StateCheck(LastSeenBy(Myself),STATE_STUNNED)
    !InParty(LastSeenBy(Myself))
  OR(2)
    !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
    !InParty(LastSeenBy(Myself))
  OR(2)
    !StateCheck(LastSeenBy(Myself),STATE_SLEEPING)
    !InParty(LastSeenBy(Myself))
  OR(2)
    !CheckStatGT(LastSeenBy(Myself),0,HELD)
    !InParty(LastSeenBy(Myself))
  See(SecondNearestEnemyOf(Myself))
  OR(2)
    !StateCheck(LastSeenBy(Myself),STATE_STUNNED)
    !InParty(LastSeenBy(Myself))
  OR(2)
    !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
    !InParty(LastSeenBy(Myself))
  OR(2)
    !StateCheck(LastSeenBy(Myself),STATE_SLEEPING)
    !InParty(LastSeenBy(Myself))
  OR(2)
    !CheckStatGT(LastSeenBy(Myself),0,HELD)
    !InParty(LastSeenBy(Myself))
  See(ThirdNearestEnemyOf(Myself))
  OR(2)
    !StateCheck(LastSeenBy(Myself),STATE_STUNNED)
    !InParty(LastSeenBy(Myself))
  OR(2)
    !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
    !InParty(LastSeenBy(Myself))
  OR(2)
    !StateCheck(LastSeenBy(Myself),STATE_SLEEPING)
    !InParty(LastSeenBy(Myself))
  OR(2)
    !CheckStatGT(LastSeenBy(Myself),0,HELD)
    !InParty(LastSeenBy(Myself))
  See(FourthNearestEnemyOf(Myself))
  OR(2)
    !StateCheck(LastSeenBy(Myself),STATE_STUNNED)
    !InParty(LastSeenBy(Myself))
  OR(2)
    !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
    !InParty(LastSeenBy(Myself))
  OR(2)
    !StateCheck(LastSeenBy(Myself),STATE_SLEEPING)
    !InParty(LastSeenBy(Myself))
  OR(2)
    !CheckStatGT(LastSeenBy(Myself),0,HELD)
    !InParty(LastSeenBy(Myself))
  See(FifthNearestEnemyOf(Myself))
  OR(2)
    !StateCheck(LastSeenBy(Myself),STATE_STUNNED)
    !InParty(LastSeenBy(Myself))
  OR(2)
    !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
    !InParty(LastSeenBy(Myself))
  OR(2)
    !StateCheck(LastSeenBy(Myself),STATE_SLEEPING)
    !InParty(LastSeenBy(Myself))
  OR(2)
    !CheckStatGT(LastSeenBy(Myself),0,HELD)
    !InParty(LastSeenBy(Myself))
  See(SixthNearestEnemyOf(Myself))
  OR(2)
    !StateCheck(LastSeenBy(Myself),STATE_STUNNED)
    !InParty(LastSeenBy(Myself))
  OR(2)
    !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
    !InParty(LastSeenBy(Myself))
  OR(2)
    !StateCheck(LastSeenBy(Myself),STATE_SLEEPING)
    !InParty(LastSeenBy(Myself))
  OR(2)
    !CheckStatGT(LastSeenBy(Myself),0,HELD)
    !InParty(LastSeenBy(Myself))
  See(NearestEnemyOf(Myself))
  OR(2)
    CheckStatLT(LastSeenBy(Myself),-4,ARMORCLASS)
    !InParty(LastSeenBy(Myself))
  OR(2)
    HPGT(LastSeenBy(Myself),41)
    !InParty(LastSeenBy(Myself))
  See(SecondNearestEnemyOf(Myself))
  OR(2)
    CheckStatLT(LastSeenBy(Myself),-4,ARMORCLASS)
    !InParty(LastSeenBy(Myself))
  OR(2)
    HPGT(LastSeenBy(Myself),41)
    !InParty(LastSeenBy(Myself))
  See(ThirdNearestEnemyOf(Myself))
  OR(2)
    CheckStatLT(LastSeenBy(Myself),-4,ARMORCLASS)
    !InParty(LastSeenBy(Myself))
  OR(2)
    HPGT(LastSeenBy(Myself),41)
    !InParty(LastSeenBy(Myself))
  See(FourthNearestEnemyOf(Myself))
  OR(2)
    CheckStatLT(LastSeenBy(Myself),-4,ARMORCLASS)
    !InParty(LastSeenBy(Myself))
  OR(2)
    HPGT(LastSeenBy(Myself),41)
    !InParty(LastSeenBy(Myself))
  See(FifthNearestEnemyOf(Myself))
  OR(2)
    CheckStatLT(LastSeenBy(Myself),-4,ARMORCLASS)
    !InParty(LastSeenBy(Myself))
  OR(2)
    HPGT(LastSeenBy(Myself),41)
    !InParty(LastSeenBy(Myself))
  See(SixthNearestEnemyOf(Myself))
  OR(2)
    CheckStatLT(LastSeenBy(Myself),-4,ARMORCLASS)
    !InParty(LastSeenBy(Myself))
  OR(2)
    HPGT(LastSeenBy(Myself),41)
    !InParty(LastSeenBy(Myself))
  See(NearestEnemyOf(Myself))
  OR(2)
    CheckStatLT(LastSeenBy(Myself),-8,ARMORCLASS)
    !InParty(LastSeenBy(Myself))
  OR(2)
    HPGT(LastSeenBy(Myself),71)
    !InParty(LastSeenBy(Myself))
  See(SecondNearestEnemyOf(Myself))
  OR(2)
    CheckStatLT(LastSeenBy(Myself),-8,ARMORCLASS)
    !InParty(LastSeenBy(Myself))
  OR(2)
    HPGT(LastSeenBy(Myself),71)
    !InParty(LastSeenBy(Myself))
  See(ThirdNearestEnemyOf(Myself))
  OR(2)
    CheckStatLT(LastSeenBy(Myself),-8,ARMORCLASS)
    !InParty(LastSeenBy(Myself))
  OR(2)
    HPGT(LastSeenBy(Myself),71)
    !InParty(LastSeenBy(Myself))
  See(FourthNearestEnemyOf(Myself))
  OR(2)
    CheckStatLT(LastSeenBy(Myself),-8,ARMORCLASS)
    !InParty(LastSeenBy(Myself))
  OR(2)
    HPGT(LastSeenBy(Myself),71)
    !InParty(LastSeenBy(Myself))
  See(FifthNearestEnemyOf(Myself))
  OR(2)
    CheckStatLT(LastSeenBy(Myself),-8,ARMORCLASS)
    !InParty(LastSeenBy(Myself))
  OR(2)
    HPGT(LastSeenBy(Myself),71)
    !InParty(LastSeenBy(Myself))
  See(SixthNearestEnemyOf(Myself))
  OR(2)
    CheckStatLT(LastSeenBy(Myself),-8,ARMORCLASS)
    !InParty(LastSeenBy(Myself))
  OR(2)
    HPGT(LastSeenBy(Myself),71)
    !InParty(LastSeenBy(Myself))
  OR(7)
    Allegiance(Myself,EVILCUTOFF)
    See([GOODCUTOFF.0.0.BARD_ALL])
    See([GOODCUTOFF.0.0.CLERIC_ALL])
    See([GOODCUTOFF.0.0.DRUID_ALL])
    See([GOODCUTOFF.0.0.MAGE_ALL])
    See([GOODCUTOFF.0.0.SORCERER])
    RandomNumGT(27,9)
  OR(6)
    Allegiance(Myself,EVILCUTOFF)
    See(SecondNearest([GOODCUTOFF.0.0.BARD_ALL]))
    See(SecondNearest([GOODCUTOFF.0.0.CLERIC_ALL]))
    See(SecondNearest([GOODCUTOFF.0.0.DRUID_ALL]))
    See(SecondNearest([GOODCUTOFF.0.0.MAGE_ALL]))
    See(SecondNearest([GOODCUTOFF.0.0.SORCERER]))
    RandomNumGT(27,15)
  OR(6)
    Allegiance(Myself,EVILCUTOFF)
    See(ThirdNearest([GOODCUTOFF.0.0.BARD_ALL]))
    See(ThirdNearest([GOODCUTOFF.0.0.CLERIC_ALL]))
    See(ThirdNearest([GOODCUTOFF.0.0.DRUID_ALL]))
    See(ThirdNearest([GOODCUTOFF.0.0.MAGE_ALL]))
    See(ThirdNearest([GOODCUTOFF.0.0.SORCERER]))
    RandomNumGT(27,21)
  OR(6)
    Allegiance(Myself,EVILCUTOFF)
    See(FourthNearest([GOODCUTOFF.0.0.BARD_ALL]))
    See(FourthNearest([GOODCUTOFF.0.0.CLERIC_ALL]))
    See(FourthNearest([GOODCUTOFF.0.0.DRUID_ALL]))
    See(FourthNearest([GOODCUTOFF.0.0.MAGE_ALL]))
    See(FourthNearest([GOODCUTOFF.0.0.SORCERER]))
    False()
THEN
  RESPONSE #100
END

IF
  !StateCheck(LastSeenBy(Myself),STATE_DEAD)
  OR(3)
    HPGT(LastSeenBy(Myself),60)
    !HaveSpell(WIZARD_POWER_WORD_KILL)
    !HPGT(LastSeenBy(Myself),25)
  OR(4)
    StateCheck(LastSeenBy(Myself),STATE_STUNNED)
    StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
    StateCheck(LastSeenBy(Myself),STATE_SLEEPING)
    CheckStatGT(LastSeenBy(Myself),0,HELD)
  !Gender(Myself,ILLUSIONARY)
  OR(2)
    Allegiance(LastSeenBy(Myself),GOODCUTOFF)
    InParty(LastSeenBy(Myself))
THEN
  RESPONSE #100
    SetGlobalTimer("LockTarget","LOCALS",6)
    SetGlobalTimer("SpellCast","LOCALS",6)
    DisplayStringHead(Myself,13736)  // ~  Die here, you will!~
    EquipMostDamagingMelee()
    AttackOneRound(LastSeenBy(Myself))
END

IF
  HasItemEquiped("MAGE01",LastSeenBy(Myself))
  !HasItemEquiped("STALKER",LastSeenBy(Myself))
THEN
  RESPONSE #100
    MoveToObject(Player1)
END

IF
  OR(2)
    HPGT(LastSeenBy(Myself),60)
    !HaveSpell(WIZARD_POWER_WORD_KILL)
  !GlobalTimerNotExpired("PreventAttack","LOCALS")
  OR(2)
    !GlobalTimerNotExpired("invis","LOCALS")
    !StateCheck(Myself,STATE_INVISIBLE)
  !GlobalTimerNotExpired("Alacrity","LOCALS")
  OR(2)
    Allegiance(LastSeenBy(Myself),GOODCUTOFF)
    InParty(LastSeenBy(Myself))
  !Gender(Myself,ILLUSIONARY)
THEN
  RESPONSE #80
    EquipRanged()
    AttackOneRound(LastSeenBy(Myself))
  RESPONSE #10
    EquipMostDamagingMelee()
    AttackOneRound(LastSeenBy(Myself))
END

IF
  OR(2)
    !GlobalTimerNotExpired("invis","LOCALS")
    !StateCheck(Myself,STATE_INVISIBLE)
  OR(2)
    Allegiance(LastSeenBy(Myself),GOODCUTOFF)
    InParty(LastSeenBy(Myself))
  OR(2)
    Range(NearestEnemyOf(Myself),7)
    Global("CloseCombat","LOCALS",1)
  OR(2)
    HPGT(LastSeenBy(Myself),60)
    !HaveSpell(WIZARD_POWER_WORD_KILL)
  !GlobalTimerNotExpired("PreventAttack","LOCALS")
  Range(LastSeenBy(Myself),13)
  !Gender(Myself,17)
THEN
  RESPONSE #50
    EquipMostDamagingMelee()
    AttackOneRound(LastSeenBy(Myself))
  RESPONSE #50
    EquipMostDamagingMelee()
    RunAwayFrom(NearestEnemyOf(Myself),15)
END

IF
  OR(2)
    !GlobalTimerNotExpired("invis","LOCALS")
    !StateCheck(Myself,STATE_INVISIBLE)
  OR(2)
    Allegiance(LastSeenBy(Myself),GOODCUTOFF)
    InParty(LastSeenBy(Myself))
  OR(3)
    GlobalTimerNotExpired("insects","LOCALS")
    Range(NearestEnemyOf(Myself),7)
    Global("CloseCombat","LOCALS",1)
  OR(2)
    HPGT(LastSeenBy(Myself),60)
    !HaveSpell(WIZARD_POWER_WORD_KILL)
  !GlobalTimerNotExpired("PreventAttack","LOCALS")
  !Range(LastSeenBy(Myself),13)
  !StateCheck(Myself,STATE_SLOWED)
  !Gender(Myself,17)
THEN
  RESPONSE #50
    EquipMostDamagingMelee()
    AttackOneRound(NearestEnemyOf(Myself))
  RESPONSE #50
    EquipMostDamagingMelee()
    AttackOneRound(LastSeenBy(Myself))
END

IF
  !GlobalTimerNotExpired("PreventAttack","LOCALS")
  OR(2)
    !GlobalTimerNotExpired("invis","LOCALS")
    !StateCheck(Myself,STATE_INVISIBLE)
  OR(2)
    Allegiance(LastSeenBy(Myself),GOODCUTOFF)
    InParty(LastSeenBy(Myself))
  OR(2)
    HPGT(LastSeenBy(Myself),60)
    !HaveSpell(WIZARD_POWER_WORD_KILL)
  !Gender(Myself,17)
THEN
  RESPONSE #100
    EquipMostDamagingMelee()
    AttackOneRound(NearestEnemyOf(Myself))
END

