IF
  HPLT(Myself,2)
THEN
  RESPONSE #100
    SetGlobal("IrenicusBeat","AR2806",1)
    StartDialogueNoSet([PC])
END

IF
  See([GOODCUTOFF])
  Global("Prep","LOCALS",0)
THEN
  RESPONSE #100
    SetGlobal("Prep","LOCALS",1)
    ReallyForceSpell(Myself,WIZARD_STONE_SKIN)
    ReallyForceSpell(Myself,WIZARD_ABSOLUTE_IMMUNITY)
    ReallyForceSpell(Myself,WIZARD_PROTECTION_FROM_ENERGY)
END

IF
  See(NearestEnemyOf(Myself))
  TookDamage()
  Global("Contingency","LOCALS",0)
THEN
  RESPONSE #100
    SetGlobal("Contingency","LOCALS",1)
    DisplayString(Myself,@270)
    ReallyForceSpell(Myself,WIZARD_PROTECTION_FROM_MAGIC_WEAPONS)
    DisplayString(Myself,@271)
    ReallyForceSpell(Myself,WIZARD_SPELL_TURNING)
    DisplayString(Myself,@272)
    ReallyForceSpell(Myself,WIZARD_MISLEAD)
END

IF
  See(NearestEnemyOf(Myself))
  TookDamage()
  HPPercentLT(Myself,80)
  Global("Contingency","LOCALS",1)
THEN
  RESPONSE #100
    DisplayString(Myself,29736) // Contingency - Stokeskin
    ReallyForceSpell(Myself,WIZARD_STONE_SKIN)
    SetGlobal("Contingency","LOCALS",2)
END

IF
  See(NearestEnemyOf(Myself))
  Global("SpellTrigger","LOCALS",0)
THEN
  RESPONSE #100
    SetGlobal("SpellTrigger","LOCALS",1)
    DisplayString(Myself,39968) // Spell Trigger - Fired
    DisplayString(Myself,@273)
    ReallyForceSpell(Myself,WIZARD_FIRE_SHIELD_RED)
    ReallyForceSpell(Myself,WIZARD_FIRE_SHIELD_BLUE)
    DisplayString(Myself,40245) // Spell Trigger - Globe of Invulnerability
    ReallyForceSpell(Myself,WIZARD_GLOBE_OF_INVULNERABILITY)
    DisplayString(Myself,328) // Spell Trigger - Mislead
    ReallyForceSpell(Myself,WIZARD_MISLEAD)
    SetGlobal("Timestop","LOCALS",2)
END

IF
  OR(2)
    !GlobalTimerNotExpired("CAST","LOCALS")
    CheckStatGT(Myself,0,165)
  !GlobalTimerNotExpired("TimestopTimer","LOCALS")
  Global("Timestop","LOCALS",2)
  See(NearestEnemyOf(Myself))
  HaveSpell(WIZARD_TIME_STOP)
THEN
  RESPONSE #100
    SetGlobalTimer("TimestopTimer","LOCALS",30)
    SetGlobalTimer("CAST","LOCALS",6)
    SetGlobal("TimeStop","LOCALS",1)
    Spell(Myself,WIZARD_TIME_STOP)
END

IF
  !GlobalTimerNotExpired("TimestopTimer","LOCALS")
  See(NearestEnemyOf(Myself))
  Global("TimeStop","LOCALS",1)
THEN
  RESPONSE #100
    SetGlobal("TimeStop","LOCALS",2)
    ForceSpell(Myself,WIZARD_ABSOLUTE_IMMUNITY)
    Continue()
END

IF
  Allegiance(Myself,ENEMY)
  Detect([PC])
  !See(LastSeenBy(Myself))
  Delay(10)
THEN
  RESPONSE #100
    ReallyForceSpell(Myself,WIZARD_TRUE_SIGHT)
END

IF
  See(NearestEnemyOf(Myself))
  StateCheck(Myself,STATE_SILENCED)
THEN
  RESPONSE #100
    ReallyForceSpell(Myself,WIZARD_VOCALIZE)
    Continue()
END

// Enormously illegal Spell Sequencer.
/* IF
See([PC.0.0.MAGE_ALL])
Global("SpellTrigger","LOCALS",1)
THEN
  RESPONSE #100
    DisplayString(Myself,39969) // Spell Sequencer - Fired
    ReallyForceSpell(LastSeenBy(Myself),WIZARD_SPELL_STRIKE)
    ReallyForceSpell(LastSeenBy(Myself),WIZARD_POWER_WORD_KILL)
    ReallyForceSpell(LastSeenBy(Myself),WIZARD_ICE_STORM)
    SetGlobal("SpellTrigger","LOCALS",2)
END */

IF
  !GlobalTimerNotExpired("CAST","LOCALS")
  !CheckStatGT(Myself,0,165)
  DifficultyGT(NORMAL)
  Global("Alacrity","LOCALS",0)
THEN
  RESPONSE #100
    SetGlobal("Alacrity","LOCALS",1)
    SetGlobalTimer("Cast","LOCALS",6)
    SpellNoDec(Myself,2921)
END

IF
  !GlobalTimerNotExpired("CAST","LOCALS")
  !CheckStatGT(Myself,0,165)
  DifficultyGT(HARD)
  Global("Alacrity","LOCALS",1)
THEN
  RESPONSE #100
    SetGlobal("Alacrity","LOCALS",2)
    SetGlobalTimer("Cast","LOCALS",6)
    SpellNoDec(Myself,2921)
END

IF
  OR(2)
    !GlobalTimerNotExpired("CAST","LOCALS")
    CheckStatGT(Myself,0,165)
  RandomNum(2,1)
  NumCreatureGT([GOODCUTOFF.0.0.0.0.SUMMONED],1)
  OR(5)
    NumCreatureGT([GOODCUTOFF.0.0.0.0.SUMMONED],3)
    CheckStatGT(NearestEnemyOfType([GOODCUTOFF.0.0.0.0.SUMMONED]),50,RESISTMAGIC)
    CheckStatGT(SecondNearestEnemyOfType([GOODCUTOFF.0.0.0.0.SUMMONED]),50,RESISTMAGIC)
    CheckStatGT(ThirdNearestEnemyOfType([GOODCUTOFF.0.0.0.0.SUMMONED]),50,RESISTMAGIC)
    RandomNumGT(10,7)
  See([GOODCUTOFF.0.0.0.0.SUMMONED])
  HaveSpell(WIZARD_DEATH_SPELL)
THEN
  RESPONSE #100
    SetGlobalTimer("CAST","LOCALS",6)
    Spell(LastSeenBy(Myself),WIZARD_DEATH_SPELL)
END

IF
  OR(2)
    !GlobalTimerNotExpired("CAST","LOCALS")
    CheckStatGT(Myself,0,165)
  RandomNum(3,1)
  HaveSpell(WIZARD_DEATH_SPELL)
  OR(2)
    !See(NearestEnemyOf(Myself))
    LevelGT(NearestEnemyOf(Myself),8)
  OR(2)
    !See(SecondNearestEnemyOf(Myself))
    LevelGT(SecondNearestEnemyOf(Myself),8)
  OR(2)
    !See(ThirdNearestEnemyOf(Myself))
    LevelGT(ThirdNearestEnemyOf(Myself),8)
  OR(2)
    !See(FourthNearestEnemyOf(Myself))
    LevelGT(FourthNearestEnemyOf(Myself),8)
  OR(2)
    !See(FifthNearestEnemyOf(Myself))
    LevelGT(FifthNearestEnemyOf(Myself),8)
  OR(2)
    !See(SixthNearestEnemyOf(Myself))
    LevelGT(SixthNearestEnemyOf(Myself),8)
  See(NearestEnemyOf(Myself))
  False()
THEN
  RESPONSE #100
    Continue()
END

IF
  OR(2)
    !GlobalTimerNotExpired("CAST","LOCALS")
    CheckStatGT(Myself,0,165)
  RandomNum(3,1)
  See(LastSeenBy(Myself))
  OR(2)
    Gender(LastSeenBy(Myself),SUMMONED)
    LevelLT(LastSeenBy(Myself),9)
  HaveSpell(WIZARD_DEATH_SPELL)
THEN
  RESPONSE #100
    SetGlobalTimer("CAST","LOCALS",6)
    Spell(LastSeenBy(Myself),WIZARD_DEATH_SPELL)
END

IF
  OR(2)
    !GlobalTimerNotExpired("CAST","LOCALS")
    CheckStatGT(Myself,0,165)
  HaveSpell(WIZARD_SPELL_STRIKE)
  !HasItemEquiped("CLCK26",TenthNearestEnemyOf(Myself)) // Cloak of Mirroring
  OR(6)
    CheckStatGT(TenthNearestEnemyOf(Myself),0,116)
    CheckStatGT(TenthNearestEnemyOf(Myself),0,129)
    CheckStatGT(TenthNearestEnemyOf(Myself),0,164)
    CheckStatGT(TenthNearestEnemyOf(Myself),0,177)
    CheckStatGT(TenthNearestEnemyOf(Myself),0,162)
    CheckStatGT(TenthNearestEnemyOf(Myself),0,123)
  See(TenthNearestEnemyOf(Myself))
  False()
THEN
  RESPONSE #100
    Continue()
END

IF
  OR(2)
    !GlobalTimerNotExpired("CAST","LOCALS")
    CheckStatGT(Myself,0,165)
  HaveSpell(WIZARD_SPELL_STRIKE)
  !HasItemEquiped("CLCK26",SixthNearestEnemyOf(Myself)) // Cloak of Mirroring
  OR(6)
    CheckStatGT(SixthNearestEnemyOf(Myself),0,116)
    CheckStatGT(SixthNearestEnemyOf(Myself),0,129)
    CheckStatGT(SixthNearestEnemyOf(Myself),0,164)
    CheckStatGT(SixthNearestEnemyOf(Myself),0,177)
    CheckStatGT(SixthNearestEnemyOf(Myself),0,162)
    CheckStatGT(SixthNearestEnemyOf(Myself),0,123)
  See(SixthNearestEnemyOf(Myself))
  False()
THEN
  RESPONSE #100
    Continue()
END

IF
  OR(2)
    !GlobalTimerNotExpired("CAST","LOCALS")
    CheckStatGT(Myself,0,165)
  HaveSpell(WIZARD_SPELL_STRIKE)
  !HasItemEquiped("CLCK26",FifthNearestEnemyOf(Myself)) // Cloak of Mirroring
  OR(6)
    CheckStatGT(FifthNearestEnemyOf(Myself),0,116)
    CheckStatGT(FifthNearestEnemyOf(Myself),0,129)
    CheckStatGT(FifthNearestEnemyOf(Myself),0,164)
    CheckStatGT(FifthNearestEnemyOf(Myself),0,177)
    CheckStatGT(FifthNearestEnemyOf(Myself),0,162)
    CheckStatGT(FifthNearestEnemyOf(Myself),0,123)
  See(FifthNearestEnemyOf(Myself))
  False()
THEN
  RESPONSE #100
    Continue()
END

IF
  OR(2)
    !GlobalTimerNotExpired("CAST","LOCALS")
    CheckStatGT(Myself,0,165)
  HaveSpell(WIZARD_SPELL_STRIKE)
  !HasItemEquiped("CLCK26",FourthNearestEnemyOf(Myself)) // Cloak of Mirroring
  OR(6)
    CheckStatGT(FourthNearestEnemyOf(Myself),0,116)
    CheckStatGT(FourthNearestEnemyOf(Myself),0,129)
    CheckStatGT(FourthNearestEnemyOf(Myself),0,164)
    CheckStatGT(FourthNearestEnemyOf(Myself),0,177)
    CheckStatGT(FourthNearestEnemyOf(Myself),0,162)
    CheckStatGT(FourthNearestEnemyOf(Myself),0,123)
  See(FourthNearestEnemyOf(Myself))
  False()
THEN
  RESPONSE #100
    Continue()
END

IF
  OR(2)
    !GlobalTimerNotExpired("CAST","LOCALS")
    CheckStatGT(Myself,0,165)
  HaveSpell(WIZARD_SPELL_STRIKE)
  !HasItemEquiped("CLCK26",ThirdNearestEnemyOf(Myself)) // Cloak of Mirroring
  OR(6)
    CheckStatGT(ThirdNearestEnemyOf(Myself),0,116)
    CheckStatGT(ThirdNearestEnemyOf(Myself),0,129)
    CheckStatGT(ThirdNearestEnemyOf(Myself),0,164)
    CheckStatGT(ThirdNearestEnemyOf(Myself),0,177)
    CheckStatGT(ThirdNearestEnemyOf(Myself),0,162)
    CheckStatGT(ThirdNearestEnemyOf(Myself),0,123)
  See(ThirdNearestEnemyOf(Myself))
  False()
THEN
  RESPONSE #100
    Continue()
END

IF
  OR(2)
    !GlobalTimerNotExpired("CAST","LOCALS")
    CheckStatGT(Myself,0,165)
  HaveSpell(WIZARD_SPELL_STRIKE)
  !HasItemEquiped("CLCK26",SecondNearestEnemyOf(Myself)) // Cloak of Mirroring
  OR(6)
    CheckStatGT(SecondNearestEnemyOf(Myself),0,116)
    CheckStatGT(SecondNearestEnemyOf(Myself),0,129)
    CheckStatGT(SecondNearestEnemyOf(Myself),0,164)
    CheckStatGT(SecondNearestEnemyOf(Myself),0,177)
    CheckStatGT(SecondNearestEnemyOf(Myself),0,162)
    CheckStatGT(SecondNearestEnemyOf(Myself),0,123)
  See(SecondNearestEnemyOf(Myself))
  False()
THEN
  RESPONSE #100
    Continue()
END

IF
  OR(2)
    !GlobalTimerNotExpired("CAST","LOCALS")
    CheckStatGT(Myself,0,165)
  HaveSpell(WIZARD_SPELL_STRIKE)
  !HasItemEquiped("CLCK26",NearestEnemyOf(Myself)) // Cloak of Mirroring
  OR(6)
    CheckStatGT(NearestEnemyOf(Myself),0,116)
    CheckStatGT(NearestEnemyOf(Myself),0,129)
    CheckStatGT(NearestEnemyOf(Myself),0,164)
    CheckStatGT(NearestEnemyOf(Myself),0,177)
    CheckStatGT(NearestEnemyOf(Myself),0,162)
    CheckStatGT(NearestEnemyOf(Myself),0,123)
  See(NearestEnemyOf(Myself))
  False()
THEN
  RESPONSE #100
    Continue()
END

IF
  OR(2)
    !GlobalTimerNotExpired("CAST","LOCALS")
    CheckStatGT(Myself,0,165)
  HaveSpell(WIZARD_SPELL_STRIKE)
  !HasItemEquiped("CLCK26",SecondNearestEnemyOfType([0.0.0.MAGE_ALL])) // Cloak of Mirroring
  OR(5)
    CheckStatGT(SecondNearestEnemyOfType([0.0.0.MAGE_ALL]),0,116)
    CheckStatGT(SecondNearestEnemyOfType([0.0.0.MAGE_ALL]),0,129)
    CheckStatGT(SecondNearestEnemyOfType([0.0.0.MAGE_ALL]),0,164)
    CheckStatGT(SecondNearestEnemyOfType([0.0.0.MAGE_ALL]),0,177)
    CheckStatGT(SecondNearestEnemyOfType([0.0.0.MAGE_ALL]),0,162)
  See(SecondNearestEnemyOfType([0.0.0.MAGE_ALL]))
  False()
THEN
  RESPONSE #100
    Continue()
END

IF
  OR(2)
    !GlobalTimerNotExpired("CAST","LOCALS")
    CheckStatGT(Myself,0,165)
  HaveSpell(WIZARD_SPELL_STRIKE)
  !HasItemEquiped("CLCK26",NearestEnemyOfType([0.0.0.MAGE_ALL])) // Cloak of Mirroring
  OR(5)
    CheckStatGT(NearestEnemyOfType([0.0.0.MAGE_ALL]),0,116)
    CheckStatGT(NearestEnemyOfType([0.0.0.MAGE_ALL]),0,129)
    CheckStatGT(NearestEnemyOfType([0.0.0.MAGE_ALL]),0,164)
    CheckStatGT(NearestEnemyOfType([0.0.0.MAGE_ALL]),0,177)
    CheckStatGT(NearestEnemyOfType([0.0.0.MAGE_ALL]),0,162)
  See(NearestEnemyOfType([0.0.0.MAGE_ALL]))
  False()
THEN
  RESPONSE #100
    Continue()
END

IF
  OR(2)
    !GlobalTimerNotExpired("CAST","LOCALS")
    CheckStatGT(Myself,0,165)
  See(LastSeenBy(Myself))
  OR(5)
    CheckStatGT(LastSeenBy(Myself),0,116)
    CheckStatGT(LastSeenBy(Myself),0,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,177)
    CheckStatGT(LastSeenBy(Myself),0,162)
  HaveSpell(WIZARD_SPELL_STRIKE)
THEN
  RESPONSE #100
    SetGlobalTimer("CAST","LOCALS",6)
    Spell(LastSeenBy(Myself),WIZARD_SPELL_STRIKE)
END

IF
  OR(2)
    !GlobalTimerNotExpired("CAST","LOCALS")
    CheckStatGT(Myself,0,165)
  HaveSpell(WIZARD_ABI_DALZIMS_HORRID_WILTING)
  RandomNumGT(8,3)
  See(NearestEnemyOf(Myself))
  OR(8)
    CheckStatGT(LastSeenBy(Myself),1,116)
    CheckStatGT(LastSeenBy(Myself),1,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStat(LastSeenBy(Myself),7,162)
    HasItemEquiped("CLCK26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatGT(LastSeenBy(Myself),40,RESISTMAGIC)
    RandomNumGT(10,3)
  See(SecondNearestEnemyOf(Myself))
  OR(8)
    CheckStatGT(LastSeenBy(Myself),1,116)
    CheckStatGT(LastSeenBy(Myself),1,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStat(LastSeenBy(Myself),7,162)
    HasItemEquiped("CLCK26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatGT(LastSeenBy(Myself),40,RESISTMAGIC)
    RandomNumGT(10,4)
  See(ThirdNearestEnemyOf(Myself))
  OR(8)
    CheckStatGT(LastSeenBy(Myself),1,116)
    CheckStatGT(LastSeenBy(Myself),1,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStat(LastSeenBy(Myself),7,162)
    HasItemEquiped("CLCK26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatGT(LastSeenBy(Myself),40,RESISTMAGIC)
    RandomNumGT(10,5)
  See(FourthNearestEnemyOf(Myself))
  OR(8)
    CheckStatGT(LastSeenBy(Myself),1,116)
    CheckStatGT(LastSeenBy(Myself),1,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStat(LastSeenBy(Myself),7,162)
    HasItemEquiped("CLCK26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatGT(LastSeenBy(Myself),40,RESISTMAGIC)
    RandomNumGT(10,6)
  See(FifthNearestEnemyOf(Myself))
  OR(8)
    CheckStatGT(LastSeenBy(Myself),1,116)
    CheckStatGT(LastSeenBy(Myself),1,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStat(LastSeenBy(Myself),7,162)
    HasItemEquiped("CLCK26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatGT(LastSeenBy(Myself),40,RESISTMAGIC)
    RandomNumGT(10,7)
  See(SixthNearestEnemyOf(Myself))
  OR(8)
    CheckStatGT(LastSeenBy(Myself),1,116)
    CheckStatGT(LastSeenBy(Myself),1,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStat(LastSeenBy(Myself),7,162)
    HasItemEquiped("CLCK26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatGT(LastSeenBy(Myself),40,RESISTMAGIC)
    RandomNumGT(10,8)
  See(SeventhNearestEnemyOf(Myself))
  OR(8)
    CheckStatGT(LastSeenBy(Myself),1,116)
    CheckStatGT(LastSeenBy(Myself),1,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStat(LastSeenBy(Myself),7,162)
    HasItemEquiped("CLCK26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatGT(LastSeenBy(Myself),40,RESISTMAGIC)
    RandomNumGT(10,9)
  See(EighthNearestEnemyOf(Myself))
  OR(7)
    CheckStatGT(LastSeenBy(Myself),1,116)
    CheckStatGT(LastSeenBy(Myself),1,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStat(LastSeenBy(Myself),7,162)
    HasItemEquiped("CLCK26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatGT(LastSeenBy(Myself),40,RESISTMAGIC)
  See(NinthNearestEnemyOf(Myself))
  OR(7)
    CheckStatGT(LastSeenBy(Myself),1,116)
    CheckStatGT(LastSeenBy(Myself),1,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStat(LastSeenBy(Myself),7,162)
    HasItemEquiped("CLCK26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatGT(LastSeenBy(Myself),40,RESISTMAGIC)
  See(TenthNearestEnemyOf(Myself))
  OR(7)
    CheckStatGT(LastSeenBy(Myself),1,116)
    CheckStatGT(LastSeenBy(Myself),1,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStat(LastSeenBy(Myself),7,162)
    HasItemEquiped("CLCK26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatGT(LastSeenBy(Myself),40,RESISTMAGIC)
  See(NearestEnemyOf(Myself))
  False()
THEN
  RESPONSE #100
    Continue()
END

IF
  OR(2)
    !GlobalTimerNotExpired("CAST","LOCALS")
    CheckStatGT(Myself,0,165)
  See(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),1,116)
  !CheckStatGT(LastSeenBy(Myself),1,129)
  !CheckStatGT(LastSeenBy(Myself),0,164)
  !CheckStatGT(LastSeenBy(Myself),0,123)
  !HasItemEquiped("CLCK26",LastSeenBy(Myself)) // Cloak of Mirroring
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  HaveSpell(WIZARD_ABI_DALZIMS_HORRID_WILTING)
  RandomNumGT(8,3)
THEN
  RESPONSE #100
    SetGlobalTimer("CAST","LOCALS",6)
    Spell(LastSeenBy(Myself),WIZARD_ABI_DALZIMS_HORRID_WILTING)
END

IF
  OR(2)
    !GlobalTimerNotExpired("CAST","LOCALS")
    CheckStatGT(Myself,0,165)
  Range(NearestEnemyOf(Myself),10)
  Range(SecondNearestEnemyOf(Myself),10)
  HaveSpell(WIZARD_ABI_DALZIMS_HORRID_WILTING)
  RandomNumGT(8,5)
THEN
  RESPONSE #100
    SetGlobalTimer("CAST","LOCALS",6)
    Spell(Myself,WIZARD_ABI_DALZIMS_HORRID_WILTING)
END

IF
  OR(2)
    !GlobalTimerNotExpired("CAST","LOCALS")
    CheckStatGT(Myself,0,165)
  HaveSpell(WIZARD_POWER_WORD_KILL)
  RandomNumGT(7,2)
  OR(2)
    !See(NearestEnemyOf(Myself))
    HPGT(NearestEnemyOf(Myself),60)
  OR(2)
    !See(SecondNearestEnemyOf(Myself))
    HPGT(SecondNearestEnemyOf(Myself),60)
  OR(2)
    !See(ThirdNearestEnemyOf(Myself))
    HPGT(ThirdNearestEnemyOf(Myself),60)
  OR(2)
    !See(FourthNearestEnemyOf(Myself))
    HPGT(FourthNearestEnemyOf(Myself),60)
  OR(2)
    !See(FifthNearestEnemyOf(Myself))
    HPGT(FifthNearestEnemyOf(Myself),60)
  OR(2)
    !See(SixthNearestEnemyOf(Myself))
    HPGT(SixthNearestEnemyOf(Myself),60)
  OR(2)
    !See(SeventhNearestEnemyOf(Myself))
    HPGT(SeventhNearestEnemyOf(Myself),60)
  OR(2)
    !See(EighthNearestEnemyOf(Myself))
    HPGT(EighthNearestEnemyOf(Myself),60)
  OR(2)
    !See(NinthNearestEnemyOf(Myself))
    HPGT(NinthNearestEnemyOf(Myself),60)
  OR(2)
    !See(TenthNearestEnemyOf(Myself))
    HPGT(TenthNearestEnemyOf(Myself),60)
  See(NearestEnemyOf(Myself))
  False()
THEN
  RESPONSE #100
    Continue()
END

IF
  OR(2)
    !GlobalTimerNotExpired("CAST","LOCALS")
    CheckStatGT(Myself,0,165)
  See(LastSeenBy(Myself))
  HPLT(LastSeenBy(Myself),61)
  HaveSpell(WIZARD_POWER_WORD_KILL)
  RandomNumGT(7,2)
THEN
  RESPONSE #100
    SetGlobalTimer("CAST","LOCALS",6)
    Spell(LastSeenBy(Myself),WIZARD_POWER_WORD_KILL)
END

IF
  OR(2)
    !GlobalTimerNotExpired("CAST","LOCALS")
    CheckStatGT(Myself,0,165)
  HaveSpell(WIZARD_POWER_WORD_STUN)
  RandomNumGT(6,1)
  OR(2)
    !See(NearestEnemyOf(Myself))
    HPGT(NearestEnemyOf(Myself),90)
  OR(2)
    !See(SecondNearestEnemyOf(Myself))
    HPGT(SecondNearestEnemyOf(Myself),90)
  OR(2)
    !See(ThirdNearestEnemyOf(Myself))
    HPGT(ThirdNearestEnemyOf(Myself),90)
  OR(2)
    !See(FourthNearestEnemyOf(Myself))
    HPGT(FourthNearestEnemyOf(Myself),90)
  OR(2)
    !See(FifthNearestEnemyOf(Myself))
    HPGT(FifthNearestEnemyOf(Myself),90)
  OR(2)
    !See(SixthNearestEnemyOf(Myself))
    HPGT(SixthNearestEnemyOf(Myself),90)
  OR(2)
    !See(SeventhNearestEnemyOf(Myself))
    HPGT(SeventhNearestEnemyOf(Myself),90)
  OR(2)
    !See(EighthNearestEnemyOf(Myself))
    HPGT(EighthNearestEnemyOf(Myself),90)
  OR(2)
    !See(NinthNearestEnemyOf(Myself))
    HPGT(NinthNearestEnemyOf(Myself),90)
  OR(2)
    !See(TenthNearestEnemyOf(Myself))
    HPGT(TenthNearestEnemyOf(Myself),90)
  See(NearestEnemyOf(Myself))
  False()
THEN
  RESPONSE #100
    Continue()
END

IF
  OR(2)
    !GlobalTimerNotExpired("CAST","LOCALS")
    CheckStatGT(Myself,0,165)
  See(LastSeenBy(Myself))
  HPLT(LastSeenBy(Myself),91)
  HaveSpell(WIZARD_POWER_WORD_STUN)
  RandomNumGT(6,1)
THEN
  RESPONSE #100
    SetGlobalTimer("CAST","LOCALS",6)
    Spell(LastSeenBy(Myself),WIZARD_POWER_WORD_STUN)
END

IF
  OR(2)
    !GlobalTimerNotExpired("CAST","LOCALS")
    CheckStatGT(Myself,0,165)
  See(NearestEnemyOf(Myself))
  OR(2)
    NumCreatureGT([GOODCUTOFF],3)
    CheckStatGT(NearestEnemyOf(Myself),10,SAVEVSDEATH)
  HaveSpell(WIZARD_WAIL_OF_THE_BANSHEE)
  RandomNumGT(4,3)
THEN
  RESPONSE #100
    SetGlobalTimer("CAST","LOCALS",6)
    Spell(Myself,WIZARD_WAIL_OF_THE_BANSHEE)
END

IF
  OR(2)
    !GlobalTimerNotExpired("CAST","LOCALS")
    CheckStatGT(Myself,0,165)
  See(NearestEnemyOf(Myself))
  Range(NearestEnemyOf(Myself),7)
  HaveSpell(WIZARD_PRISMATIC_SPRAY)
  RandomNumGT(5,2)
THEN
  RESPONSE #100
    SetGlobalTimer("CAST","LOCALS",6)
    Spell(LastSeenBy(Myself),WIZARD_PRISMATIC_SPRAY)
END

IF
  OR(2)
    !GlobalTimerNotExpired("CAST","LOCALS")
    CheckStatGT(Myself,0,165)
  Range(NearestEnemyOf(Myself),10)
  OR(2)
    Range(SecondNearestEnemyOf(Myself),10)
    CheckStatLT(NearestEnemyOf(Myself),50,RESISTFIRE)
  HaveSpell(WIZARD_SUN_FIRE)
  RandomNumGT(7,2)
THEN
  RESPONSE #100
    SetGlobalTimer("CAST","LOCALS",6)
    Spell(LastSeenBy(Myself),WIZARD_SUN_FIRE)
END

IF
  OR(2)
    !GlobalTimerNotExpired("CAST","LOCALS")
    CheckStatGT(Myself,0,165)
  See(NearestEnemyOf(Myself))
  Range(NearestEnemyOf(Myself),7)
  HaveSpell(WIZARD_MAZE)
  RandomNumGT(6,3)
THEN
  RESPONSE #100
    SetGlobalTimer("CAST","LOCALS",6)
    Spell(NearestEnemyOf(Myself),WIZARD_MAZE)
END

IF
  OR(2)
    !GlobalTimerNotExpired("CAST","LOCALS")
    CheckStatGT(Myself,0,165)
  HaveSpell(WIZARD_DISPEL_MAGIC)
  OR(8)
    StateCheck(SixthNearestEnemyOf(Myself),STATE_BLESS)
    StateCheck(SixthNearestEnemyOf(Myself),STATE_CHANT)
    StateCheck(SixthNearestEnemyOf(Myself),STATE_DRAWUPONHOLYMIGHT)
    StateCheck(SixthNearestEnemyOf(Myself),STATE_BLUR)
    StateCheck(SixthNearestEnemyOf(Myself),STATE_MIRRORIMAGE)
    CheckStatGT(SixthNearestEnemyOf(Myself),0,STONESKINS)
    HasBounceEffects(SixthNearestEnemyOf(Myself))
    HasImmunityEffects(SixthNearestEnemyOf(Myself))
  See(SixthNearestEnemyOf(Myself))
  False()
THEN
  RESPONSE #100
    Continue()
END

IF
  OR(2)
    !GlobalTimerNotExpired("CAST","LOCALS")
    CheckStatGT(Myself,0,165)
  HaveSpell(WIZARD_DISPEL_MAGIC)
  OR(8)
    StateCheck(FifthNearestEnemyOf(Myself),STATE_BLESS)
    StateCheck(FifthNearestEnemyOf(Myself),STATE_CHANT)
    StateCheck(FifthNearestEnemyOf(Myself),STATE_DRAWUPONHOLYMIGHT)
    StateCheck(FifthNearestEnemyOf(Myself),STATE_BLUR)
    StateCheck(FifthNearestEnemyOf(Myself),STATE_MIRRORIMAGE)
    CheckStatGT(FifthNearestEnemyOf(Myself),0,STONESKINS)
    HasBounceEffects(FifthNearestEnemyOf(Myself))
    HasImmunityEffects(FifthNearestEnemyOf(Myself))
  See(FifthNearestEnemyOf(Myself))
  False()
THEN
  RESPONSE #100
    Continue()
END

IF
  OR(2)
    !GlobalTimerNotExpired("CAST","LOCALS")
    CheckStatGT(Myself,0,165)
  HaveSpell(WIZARD_DISPEL_MAGIC)
  OR(8)
    StateCheck(FourthNearestEnemyOf(Myself),STATE_BLESS)
    StateCheck(FourthNearestEnemyOf(Myself),STATE_CHANT)
    StateCheck(FourthNearestEnemyOf(Myself),STATE_DRAWUPONHOLYMIGHT)
    StateCheck(FourthNearestEnemyOf(Myself),STATE_BLUR)
    StateCheck(FourthNearestEnemyOf(Myself),STATE_MIRRORIMAGE)
    CheckStatGT(FourthNearestEnemyOf(Myself),0,STONESKINS)
    HasBounceEffects(FourthNearestEnemyOf(Myself))
    HasImmunityEffects(FourthNearestEnemyOf(Myself))
  See(FourthNearestEnemyOf(Myself))
  False()
THEN
  RESPONSE #100
    Continue()
END

IF
  OR(2)
    !GlobalTimerNotExpired("CAST","LOCALS")
    CheckStatGT(Myself,0,165)
  HaveSpell(WIZARD_DISPEL_MAGIC)
  OR(8)
    StateCheck(ThirdNearestEnemyOf(Myself),STATE_BLESS)
    StateCheck(ThirdNearestEnemyOf(Myself),STATE_CHANT)
    StateCheck(ThirdNearestEnemyOf(Myself),STATE_DRAWUPONHOLYMIGHT)
    StateCheck(ThirdNearestEnemyOf(Myself),STATE_BLUR)
    StateCheck(ThirdNearestEnemyOf(Myself),STATE_MIRRORIMAGE)
    CheckStatGT(ThirdNearestEnemyOf(Myself),0,STONESKINS)
    HasBounceEffects(ThirdNearestEnemyOf(Myself))
    HasImmunityEffects(ThirdNearestEnemyOf(Myself))
  See(ThirdNearestEnemyOf(Myself))
  False()
THEN
  RESPONSE #100
    Continue()
END

IF
  OR(2)
    !GlobalTimerNotExpired("CAST","LOCALS")
    CheckStatGT(Myself,0,165)
  HaveSpell(WIZARD_DISPEL_MAGIC)
  OR(8)
    StateCheck(SecondNearestEnemyOf(Myself),STATE_BLESS)
    StateCheck(SecondNearestEnemyOf(Myself),STATE_CHANT)
    StateCheck(SecondNearestEnemyOf(Myself),STATE_DRAWUPONHOLYMIGHT)
    StateCheck(SecondNearestEnemyOf(Myself),STATE_BLUR)
    StateCheck(SecondNearestEnemyOf(Myself),STATE_MIRRORIMAGE)
    CheckStatGT(SecondNearestEnemyOf(Myself),0,STONESKINS)
    HasBounceEffects(SecondNearestEnemyOf(Myself))
    HasImmunityEffects(SecondNearestEnemyOf(Myself))
  See(SecondNearestEnemyOf(Myself))
  False()
THEN
  RESPONSE #100
    Continue()
END

IF
  OR(2)
    !GlobalTimerNotExpired("CAST","LOCALS")
    CheckStatGT(Myself,0,165)
  HaveSpell(WIZARD_DISPEL_MAGIC)
  OR(8)
    StateCheck(NearestEnemyOf(Myself),STATE_BLESS)
    StateCheck(NearestEnemyOf(Myself),STATE_CHANT)
    StateCheck(NearestEnemyOf(Myself),STATE_DRAWUPONHOLYMIGHT)
    StateCheck(NearestEnemyOf(Myself),STATE_BLUR)
    StateCheck(NearestEnemyOf(Myself),STATE_MIRRORIMAGE)
    CheckStatGT(NearestEnemyOf(Myself),0,STONESKINS)
    HasBounceEffects(NearestEnemyOf(Myself))
    HasImmunityEffects(NearestEnemyOf(Myself))
  See(NearestEnemyOf(Myself))
  False()
THEN
  RESPONSE #100
    Continue()
END

IF
  OR(2)
    !GlobalTimerNotExpired("CAST","LOCALS")
    CheckStatGT(Myself,0,165)
  HaveSpell(WIZARD_DISPEL_MAGIC)
  OR(8)
    StateCheck(LastSeenBy(Myself),STATE_BLESS)
    StateCheck(LastSeenBy(Myself),STATE_CHANT)
    StateCheck(LastSeenBy(Myself),STATE_DRAWUPONHOLYMIGHT)
    StateCheck(LastSeenBy(Myself),STATE_BLUR)
    StateCheck(LastSeenBy(Myself),STATE_MIRRORIMAGE)
    CheckStatGT(LastSeenBy(Myself),0,STONESKINS)
    HasBounceEffects(LastSeenBy(Myself))
    HasImmunityEffects(LastSeenBy(Myself))
THEN
  RESPONSE #100
    SetGlobalTimer("CAST","LOCALS",6)
    Spell(LastSeenBy(Myself),WIZARD_DISPEL_MAGIC)
END

IF
  OR(2)
    !GlobalTimerNotExpired("CAST","LOCALS")
    CheckStatGT(Myself,0,165)
  HaveSpell(WIZARD_FLAME_ARROW)
  See(NearestEnemyOf(Myself))
  OR(12)
    HasItemEquiped("clck26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatGT(LastSeenBy(Myself),0,116)
    CheckStatGT(LastSeenBy(Myself),0,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStatGT(LastSeenBy(Myself),0,MINORGLOBE)
    CheckStatGT(LastSeenBy(Myself),0,SHIELDGLOBE)
    CheckStat(LastSeenBy(Myself),2,162)
    CheckStatGT(LastSeenBy(Myself),60,RESISTFIRE)
    CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
  See(SecondNearestEnemyOf(Myself))
  OR(12)
    HasItemEquiped("clck26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatGT(LastSeenBy(Myself),0,116)
    CheckStatGT(LastSeenBy(Myself),0,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStatGT(LastSeenBy(Myself),0,MINORGLOBE)
    CheckStatGT(LastSeenBy(Myself),0,SHIELDGLOBE)
    CheckStat(LastSeenBy(Myself),2,162)
    CheckStatGT(LastSeenBy(Myself),60,RESISTFIRE)
    CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
  See(ThirdNearestEnemyOf(Myself))
  OR(12)
    HasItemEquiped("clck26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatGT(LastSeenBy(Myself),0,116)
    CheckStatGT(LastSeenBy(Myself),0,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStatGT(LastSeenBy(Myself),0,MINORGLOBE)
    CheckStatGT(LastSeenBy(Myself),0,SHIELDGLOBE)
    CheckStat(LastSeenBy(Myself),2,162)
    CheckStatGT(LastSeenBy(Myself),60,RESISTFIRE)
    CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
  See(FourthNearestEnemyOf(Myself))
  OR(12)
    HasItemEquiped("clck26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatGT(LastSeenBy(Myself),0,116)
    CheckStatGT(LastSeenBy(Myself),0,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStatGT(LastSeenBy(Myself),0,MINORGLOBE)
    CheckStatGT(LastSeenBy(Myself),0,SHIELDGLOBE)
    CheckStat(LastSeenBy(Myself),2,162)
    CheckStatGT(LastSeenBy(Myself),60,RESISTFIRE)
    CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
  See(FifthNearestEnemyOf(Myself))
  OR(12)
    HasItemEquiped("clck26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatGT(LastSeenBy(Myself),0,116)
    CheckStatGT(LastSeenBy(Myself),0,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStatGT(LastSeenBy(Myself),0,MINORGLOBE)
    CheckStatGT(LastSeenBy(Myself),0,SHIELDGLOBE)
    CheckStat(LastSeenBy(Myself),2,162)
    CheckStatGT(LastSeenBy(Myself),60,RESISTFIRE)
    CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
  See(SixthNearestEnemyOf(Myself))
  OR(12)
    HasItemEquiped("clck26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatGT(LastSeenBy(Myself),0,116)
    CheckStatGT(LastSeenBy(Myself),0,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStatGT(LastSeenBy(Myself),0,MINORGLOBE)
    CheckStatGT(LastSeenBy(Myself),0,SHIELDGLOBE)
    CheckStat(LastSeenBy(Myself),2,162)
    CheckStatGT(LastSeenBy(Myself),60,RESISTFIRE)
    CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
  See(SeventhNearestEnemyOf(Myself))
  OR(12)
    HasItemEquiped("clck26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatGT(LastSeenBy(Myself),0,116)
    CheckStatGT(LastSeenBy(Myself),0,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStatGT(LastSeenBy(Myself),0,MINORGLOBE)
    CheckStatGT(LastSeenBy(Myself),0,SHIELDGLOBE)
    CheckStat(LastSeenBy(Myself),2,162)
    CheckStatGT(LastSeenBy(Myself),60,RESISTFIRE)
    CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
  See(EighthNearestEnemyOf(Myself))
  OR(12)
    HasItemEquiped("clck26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatGT(LastSeenBy(Myself),0,116)
    CheckStatGT(LastSeenBy(Myself),0,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStatGT(LastSeenBy(Myself),0,MINORGLOBE)
    CheckStatGT(LastSeenBy(Myself),0,SHIELDGLOBE)
    CheckStat(LastSeenBy(Myself),2,162)
    CheckStatGT(LastSeenBy(Myself),60,RESISTFIRE)
    CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
  See(NinthNearestEnemyOf(Myself))
  OR(12)
    HasItemEquiped("clck26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatGT(LastSeenBy(Myself),0,116)
    CheckStatGT(LastSeenBy(Myself),0,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStatGT(LastSeenBy(Myself),0,MINORGLOBE)
    CheckStatGT(LastSeenBy(Myself),0,SHIELDGLOBE)
    CheckStat(LastSeenBy(Myself),2,162)
    CheckStatGT(LastSeenBy(Myself),60,RESISTFIRE)
    CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
  See(TenthNearestEnemyOf(Myself))
  OR(12)
    HasItemEquiped("clck26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatGT(LastSeenBy(Myself),0,116)
    CheckStatGT(LastSeenBy(Myself),0,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStatGT(LastSeenBy(Myself),0,MINORGLOBE)
    CheckStatGT(LastSeenBy(Myself),0,SHIELDGLOBE)
    CheckStat(LastSeenBy(Myself),2,162)
    CheckStatGT(LastSeenBy(Myself),60,RESISTFIRE)
    CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
  See(NearestEnemyOf(Myself))
  False()
THEN
  RESPONSE #100
    Continue()
END

IF
  OR(2)
    !GlobalTimerNotExpired("CAST","LOCALS")
    CheckStatGT(Myself,0,165)
  HaveSpell(WIZARD_FLAME_ARROW)
  See(LastSeenBy(Myself))
  !HasItemEquiped("clck26",LastSeenBy(Myself)) // Cloak of Mirroring
  !CheckStatGT(LastSeenBy(Myself),0,116)
  !CheckStatGT(LastSeenBy(Myself),0,129)
  !CheckStatGT(LastSeenBy(Myself),0,164)
  !CheckStatGT(LastSeenBy(Myself),0,123)
  !CheckStatGT(LastSeenBy(Myself),0,MINORGLOBE)
  !CheckStatGT(LastSeenBy(Myself),0,SHIELDGLOBE)
  !CheckStat(LastSeenBy(Myself),2,162)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTFIRE)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
THEN
  RESPONSE #100
    SetGlobalTimer("CAST","LOCALS",6)
    Spell(LastSeenBy(Myself),WIZARD_FLAME_ARROW)
END

IF
  OR(2)
    !GlobalTimerNotExpired("CAST","LOCALS")
    CheckStatGT(Myself,0,165)
  HaveSpell(WIZARD_MELF_ACID_ARROW)
  See(NearestEnemyOf(Myself))
  OR(12)
    HasItemEquiped("clck26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatGT(LastSeenBy(Myself),0,116)
    CheckStatGT(LastSeenBy(Myself),0,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStatGT(LastSeenBy(Myself),0,MINORGLOBE)
    CheckStatGT(LastSeenBy(Myself),0,SHIELDGLOBE)
    CheckStat(LastSeenBy(Myself),2,162)
    CheckStatGT(LastSeenBy(Myself),60,RESISTACID)
    CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
  See(SecondNearestEnemyOf(Myself))
  OR(12)
    HasItemEquiped("clck26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatGT(LastSeenBy(Myself),0,116)
    CheckStatGT(LastSeenBy(Myself),0,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStatGT(LastSeenBy(Myself),0,MINORGLOBE)
    CheckStatGT(LastSeenBy(Myself),0,SHIELDGLOBE)
    CheckStat(LastSeenBy(Myself),2,162)
    CheckStatGT(LastSeenBy(Myself),60,RESISTACID)
    CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
  See(ThirdNearestEnemyOf(Myself))
  OR(12)
    HasItemEquiped("clck26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatGT(LastSeenBy(Myself),0,116)
    CheckStatGT(LastSeenBy(Myself),0,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStatGT(LastSeenBy(Myself),0,MINORGLOBE)
    CheckStatGT(LastSeenBy(Myself),0,SHIELDGLOBE)
    CheckStat(LastSeenBy(Myself),2,162)
    CheckStatGT(LastSeenBy(Myself),60,RESISTACID)
    CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
  See(FourthNearestEnemyOf(Myself))
  OR(12)
    HasItemEquiped("clck26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatGT(LastSeenBy(Myself),0,116)
    CheckStatGT(LastSeenBy(Myself),0,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStatGT(LastSeenBy(Myself),0,MINORGLOBE)
    CheckStatGT(LastSeenBy(Myself),0,SHIELDGLOBE)
    CheckStat(LastSeenBy(Myself),2,162)
    CheckStatGT(LastSeenBy(Myself),60,RESISTACID)
    CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
  See(FifthNearestEnemyOf(Myself))
  OR(12)
    HasItemEquiped("clck26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatGT(LastSeenBy(Myself),0,116)
    CheckStatGT(LastSeenBy(Myself),0,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStatGT(LastSeenBy(Myself),0,MINORGLOBE)
    CheckStatGT(LastSeenBy(Myself),0,SHIELDGLOBE)
    CheckStat(LastSeenBy(Myself),2,162)
    CheckStatGT(LastSeenBy(Myself),60,RESISTACID)
    CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
  See(SixthNearestEnemyOf(Myself))
  OR(12)
    HasItemEquiped("clck26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatGT(LastSeenBy(Myself),0,116)
    CheckStatGT(LastSeenBy(Myself),0,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStatGT(LastSeenBy(Myself),0,MINORGLOBE)
    CheckStatGT(LastSeenBy(Myself),0,SHIELDGLOBE)
    CheckStat(LastSeenBy(Myself),2,162)
    CheckStatGT(LastSeenBy(Myself),60,RESISTACID)
    CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
  See(SeventhNearestEnemyOf(Myself))
  OR(12)
    HasItemEquiped("clck26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatGT(LastSeenBy(Myself),0,116)
    CheckStatGT(LastSeenBy(Myself),0,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStatGT(LastSeenBy(Myself),0,MINORGLOBE)
    CheckStatGT(LastSeenBy(Myself),0,SHIELDGLOBE)
    CheckStat(LastSeenBy(Myself),2,162)
    CheckStatGT(LastSeenBy(Myself),60,RESISTACID)
    CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
  See(EighthNearestEnemyOf(Myself))
  OR(12)
    HasItemEquiped("clck26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatGT(LastSeenBy(Myself),0,116)
    CheckStatGT(LastSeenBy(Myself),0,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStatGT(LastSeenBy(Myself),0,MINORGLOBE)
    CheckStatGT(LastSeenBy(Myself),0,SHIELDGLOBE)
    CheckStat(LastSeenBy(Myself),2,162)
    CheckStatGT(LastSeenBy(Myself),60,RESISTACID)
    CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
  See(NinthNearestEnemyOf(Myself))
  OR(12)
    HasItemEquiped("clck26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatGT(LastSeenBy(Myself),0,116)
    CheckStatGT(LastSeenBy(Myself),0,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStatGT(LastSeenBy(Myself),0,MINORGLOBE)
    CheckStatGT(LastSeenBy(Myself),0,SHIELDGLOBE)
    CheckStat(LastSeenBy(Myself),2,162)
    CheckStatGT(LastSeenBy(Myself),60,RESISTACID)
    CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
  See(TenthNearestEnemyOf(Myself))
  OR(12)
    HasItemEquiped("clck26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatGT(LastSeenBy(Myself),0,116)
    CheckStatGT(LastSeenBy(Myself),0,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStatGT(LastSeenBy(Myself),0,MINORGLOBE)
    CheckStatGT(LastSeenBy(Myself),0,SHIELDGLOBE)
    CheckStat(LastSeenBy(Myself),2,162)
    CheckStatGT(LastSeenBy(Myself),60,RESISTACID)
    CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
  See(NearestEnemyOf(Myself))
  False()
THEN
  RESPONSE #100
    Continue()
END

IF
  OR(2)
    !GlobalTimerNotExpired("CAST","LOCALS")
    CheckStatGT(Myself,0,165)
  HaveSpell(WIZARD_MELF_ACID_ARROW)
  See(LastSeenBy(Myself))
  !HasItemEquiped("clck26",LastSeenBy(Myself)) // Cloak of Mirroring
  !CheckStatGT(LastSeenBy(Myself),0,116)
  !CheckStatGT(LastSeenBy(Myself),0,129)
  !CheckStatGT(LastSeenBy(Myself),0,164)
  !CheckStatGT(LastSeenBy(Myself),0,123)
  !CheckStatGT(LastSeenBy(Myself),0,MINORGLOBE)
  !CheckStatGT(LastSeenBy(Myself),0,SHIELDGLOBE)
  !CheckStat(LastSeenBy(Myself),2,162)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTACID)
  !CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  !CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
THEN
  RESPONSE #100
    SetGlobalTimer("CAST","LOCALS",6)
    Spell(LastSeenBy(Myself),WIZARD_MELF_ACID_ARROW)
END

IF
  OR(2)
    !GlobalTimerNotExpired("CAST","LOCALS")
    CheckStatGT(Myself,0,165)
  RandomNumGT(5,2)
  See(NearestEnemyOf(Myself))
  OR(12)
    HasItemEquiped("clck26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatGT(LastSeenBy(Myself),0,116)
    CheckStatGT(LastSeenBy(Myself),0,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStatGT(LastSeenBy(Myself),0,MINORGLOBE)
    CheckStatGT(LastSeenBy(Myself),0,SHIELDGLOBE)
    CheckStat(LastSeenBy(Myself),6,162)
    CheckStatGT(LastSeenBy(Myself),60,MAGICDAMAGERESISTANCE)
    CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
  See(SecondNearestEnemyOf(Myself))
  OR(12)
    HasItemEquiped("clck26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatGT(LastSeenBy(Myself),0,116)
    CheckStatGT(LastSeenBy(Myself),0,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStatGT(LastSeenBy(Myself),0,MINORGLOBE)
    CheckStatGT(LastSeenBy(Myself),0,SHIELDGLOBE)
    CheckStat(LastSeenBy(Myself),6,162)
    CheckStatGT(LastSeenBy(Myself),60,MAGICDAMAGERESISTANCE)
    CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
  See(ThirdNearestEnemyOf(Myself))
  OR(12)
    HasItemEquiped("clck26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatGT(LastSeenBy(Myself),0,116)
    CheckStatGT(LastSeenBy(Myself),0,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStatGT(LastSeenBy(Myself),0,MINORGLOBE)
    CheckStatGT(LastSeenBy(Myself),0,SHIELDGLOBE)
    CheckStat(LastSeenBy(Myself),6,162)
    CheckStatGT(LastSeenBy(Myself),60,MAGICDAMAGERESISTANCE)
    CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
  See(FourthNearestEnemyOf(Myself))
  OR(12)
    HasItemEquiped("clck26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatGT(LastSeenBy(Myself),0,116)
    CheckStatGT(LastSeenBy(Myself),0,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStatGT(LastSeenBy(Myself),0,MINORGLOBE)
    CheckStatGT(LastSeenBy(Myself),0,SHIELDGLOBE)
    CheckStat(LastSeenBy(Myself),6,162)
    CheckStatGT(LastSeenBy(Myself),60,MAGICDAMAGERESISTANCE)
    CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
  See(FifthNearestEnemyOf(Myself))
  OR(12)
    HasItemEquiped("clck26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatGT(LastSeenBy(Myself),0,116)
    CheckStatGT(LastSeenBy(Myself),0,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStatGT(LastSeenBy(Myself),0,MINORGLOBE)
    CheckStatGT(LastSeenBy(Myself),0,SHIELDGLOBE)
    CheckStat(LastSeenBy(Myself),6,162)
    CheckStatGT(LastSeenBy(Myself),60,MAGICDAMAGERESISTANCE)
    CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
  See(SixthNearestEnemyOf(Myself))
  OR(12)
    HasItemEquiped("clck26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatGT(LastSeenBy(Myself),0,116)
    CheckStatGT(LastSeenBy(Myself),0,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStatGT(LastSeenBy(Myself),0,MINORGLOBE)
    CheckStatGT(LastSeenBy(Myself),0,SHIELDGLOBE)
    CheckStat(LastSeenBy(Myself),6,162)
    CheckStatGT(LastSeenBy(Myself),60,MAGICDAMAGERESISTANCE)
    CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
  See(SeventhNearestEnemyOf(Myself))
  OR(12)
    HasItemEquiped("clck26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatGT(LastSeenBy(Myself),0,116)
    CheckStatGT(LastSeenBy(Myself),0,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStatGT(LastSeenBy(Myself),0,MINORGLOBE)
    CheckStatGT(LastSeenBy(Myself),0,SHIELDGLOBE)
    CheckStat(LastSeenBy(Myself),6,162)
    CheckStatGT(LastSeenBy(Myself),60,MAGICDAMAGERESISTANCE)
    CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
  See(EighthNearestEnemyOf(Myself))
  OR(12)
    HasItemEquiped("clck26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatGT(LastSeenBy(Myself),0,116)
    CheckStatGT(LastSeenBy(Myself),0,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStatGT(LastSeenBy(Myself),0,MINORGLOBE)
    CheckStatGT(LastSeenBy(Myself),0,SHIELDGLOBE)
    CheckStat(LastSeenBy(Myself),6,162)
    CheckStatGT(LastSeenBy(Myself),60,MAGICDAMAGERESISTANCE)
    CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
  See(NinthNearestEnemyOf(Myself))
  OR(12)
    HasItemEquiped("clck26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatGT(LastSeenBy(Myself),0,116)
    CheckStatGT(LastSeenBy(Myself),0,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStatGT(LastSeenBy(Myself),0,MINORGLOBE)
    CheckStatGT(LastSeenBy(Myself),0,SHIELDGLOBE)
    CheckStat(LastSeenBy(Myself),6,162)
    CheckStatGT(LastSeenBy(Myself),60,MAGICDAMAGERESISTANCE)
    CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
  See(TenthNearestEnemyOf(Myself))
  OR(12)
    HasItemEquiped("clck26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatGT(LastSeenBy(Myself),0,116)
    CheckStatGT(LastSeenBy(Myself),0,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStatGT(LastSeenBy(Myself),0,MINORGLOBE)
    CheckStatGT(LastSeenBy(Myself),0,SHIELDGLOBE)
    CheckStat(LastSeenBy(Myself),6,162)
    CheckStatGT(LastSeenBy(Myself),60,MAGICDAMAGERESISTANCE)
    CheckStatGT(LastSeenBy(Myself),50,RESISTMAGIC)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
  See(NearestEnemyOf(Myself))
  False()
THEN
  RESPONSE #100
    Continue()
END

IF
  OR(2)
    !GlobalTimerNotExpired("CAST","LOCALS")
    CheckStatGT(Myself,0,165)
  See(LastSeenBy(Myself))
  Allegiance(Myself,ENEMY)
  Allegiance(LastSeenBy(Myself),GOODCUTOFF)
  RandomNumGT(5,2)
THEN
  RESPONSE #100
    SetGlobalTimer("CAST","LOCALS",6)
    ForceSpell(LastSeenBy(Myself),WIZARD_MAGIC_MISSILE)
END

IF
  OR(2)
    !GlobalTimerNotExpired("CAST","LOCALS")
    CheckStatGT(Myself,0,165)
  See(NearestEnemyOf(Myself))
  RandomNum(6,1)
THEN
  RESPONSE #100
    ForceSpell(NearestEnemyOf(Myself),WIZARD_MAGIC_MISSILE)
    SetGlobalTimer("CAST","LOCALS",6)
  RESPONSE #125
    ForceSpell(NearestEnemyOf(Myself),WIZARD_CHROMATIC_ORB)
    SetGlobalTimer("CAST","LOCALS",6)
  RESPONSE #150
    ForceSpell(NearestEnemyOf(Myself),WIZARD_LARLOCH_MINOR_DRAIN)
    SetGlobalTimer("CAST","LOCALS",6)
END

IF
  OR(2)
    !GlobalTimerNotExpired("CAST","LOCALS")
    CheckStatGT(Myself,0,165)
  See(NearestEnemyOf(Myself))
  RandomNum(6,2)
THEN
  RESPONSE #100
    ForceSpell(SecondNearestEnemyOf(Myself),WIZARD_MAGIC_MISSILE)
    SetGlobalTimer("CAST","LOCALS",6)
  RESPONSE #125
    ForceSpell(SecondNearestEnemyOf(Myself),WIZARD_CHROMATIC_ORB)
    SetGlobalTimer("CAST","LOCALS",6)
  RESPONSE #150
    ForceSpell(SecondNearestEnemyOf(Myself),WIZARD_LARLOCH_MINOR_DRAIN)
    SetGlobalTimer("CAST","LOCALS",6)
END

IF
  OR(2)
    !GlobalTimerNotExpired("CAST","LOCALS")
    CheckStatGT(Myself,0,165)
  See(NearestEnemyOf(Myself))
  RandomNum(6,3)
THEN
  RESPONSE #100
    ForceSpell(ThirdNearestEnemyOf(Myself),WIZARD_MAGIC_MISSILE)
    SetGlobalTimer("CAST","LOCALS",6)
  RESPONSE #125
    ForceSpell(ThirdNearestEnemyOf(Myself),WIZARD_CHROMATIC_ORB)
    SetGlobalTimer("CAST","LOCALS",6)
  RESPONSE #150
    ForceSpell(ThirdNearestEnemyOf(Myself),WIZARD_LARLOCH_MINOR_DRAIN)
    SetGlobalTimer("CAST","LOCALS",6)
END

IF
  OR(2)
    !GlobalTimerNotExpired("CAST","LOCALS")
    CheckStatGT(Myself,0,165)
  See(NearestEnemyOf(Myself))
  RandomNum(6,4)
THEN
  RESPONSE #100
    ForceSpell(FourthNearestEnemyOf(Myself),WIZARD_MAGIC_MISSILE)
    SetGlobalTimer("CAST","LOCALS",6)
  RESPONSE #125
    ForceSpell(FourthNearestEnemyOf(Myself),WIZARD_CHROMATIC_ORB)
    SetGlobalTimer("CAST","LOCALS",6)
  RESPONSE #150
    ForceSpell(FourthNearestEnemyOf(Myself),WIZARD_LARLOCH_MINOR_DRAIN)
    SetGlobalTimer("CAST","LOCALS",6)
END

IF
  OR(2)
    !GlobalTimerNotExpired("CAST","LOCALS")
    CheckStatGT(Myself,0,165)
  See(NearestEnemyOf(Myself))
  RandomNum(6,5)
THEN
  RESPONSE #100
    ForceSpell(FifthNearestEnemyOf(Myself),WIZARD_MAGIC_MISSILE)
    SetGlobalTimer("CAST","LOCALS",6)
  RESPONSE #125
    ForceSpell(FifthNearestEnemyOf(Myself),WIZARD_CHROMATIC_ORB)
    SetGlobalTimer("CAST","LOCALS",6)
  RESPONSE #150
    ForceSpell(FifthNearestEnemyOf(Myself),WIZARD_LARLOCH_MINOR_DRAIN)
    SetGlobalTimer("CAST","LOCALS",6)
END

IF
  OR(2)
    !GlobalTimerNotExpired("CAST","LOCALS")
    CheckStatGT(Myself,0,165)
  See(TenthNearestEnemyOf(Myself))
THEN
  RESPONSE #100
    ForceSpell(TenthNearestEnemyOf(Myself),WIZARD_MAGIC_MISSILE)
    SetGlobalTimer("CAST","LOCALS",6)
  RESPONSE #125
    ForceSpell(TenthNearestEnemyOf(Myself),WIZARD_CHROMATIC_ORB)
    SetGlobalTimer("CAST","LOCALS",6)
  RESPONSE #150
    ForceSpell(TenthNearestEnemyOf(Myself),WIZARD_LARLOCH_MINOR_DRAIN)
    SetGlobalTimer("CAST","LOCALS",6)
END

IF
  !Detect(Player1)
  !Detect(Player2)
  !Detect(Player3)
  !Detect(Player4)
  !Detect(Player5)
  !Detect(Player6)
THEN
  RESPONSE #100
    ReallyForceSpell(Player1,WIZARD_DIMENSION_DOOR)
END

IF
  TookDamage()
  Detect(LastAttackerOf(Myself))
THEN
  RESPONSE #100
    RunAwayFromNoInterrupt(LastAttackerOf(Myself),10)
END
