IF
  See(NearestEnemyOf(Myself))
  Global("Prep","LOCALS",0)
THEN
  RESPONSE #100
    SetGlobal("Prep","LOCALS",1)
    ReallyForceSpell(Myself,WIZARD_STONE_SKIN)
    ReallyForceSpell(Myself,WIZARD_SPELL_TURNING)
    ReallyForceSpell(Myself,WIZARD_PROTECTION_FROM_ELECTRICITY)
END

IF
  See(NearestEnemyOf(Myself))
  OR(6)
    StateCheck(LastSeenBy(Myself),STATE_HASTED)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    StateCheck(LastSeenBy(Myself),STATE_BLESS)
    StateCheck(LastSeenBy(Myself),STATE_CHANT)
    StateCheck(LastSeenBy(Myself),STATE_MIRRORIMAGE)
    StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
//    StateCheck(LastSeenBy(Myself),STATE_NORMAL)
  Global("PrepDef","LOCALS",0)
THEN
  RESPONSE #70
    SetGlobal("PrepDef","LOCALS",1)
    ReallyForceSpell(LastSeenBy(Myself),WIZARD_DISPEL_MAGIC)
  RESPONSE #30
    SetGlobal("PrepDef","LOCALS",1)
    ReallyForceSpell(Myself,WIZARD_MIRROR_IMAGE)
END

IF
  StateCheck(Myself,STATE_SILENCED)
  DifficultyGT(EASY)
THEN
  RESPONSE #100
    ReallyForceSpell(Myself,WIZARD_VOCALIZE)
    Continue()
END

IF
  !GlobalTimerNotExpired("Cast","LOCALS")
  StateCheck(Myself,STATE_SILENCED)
  Difficulty(EASY)
THEN
  RESPONSE #100
    SetGlobalTimer("Cast","LOCALS",6)
    ForceSpell(Myself,WIZARD_VOCALIZE)
    Continue()
END

IF
  !GlobalTimerNotExpired("Cast","LOCALS")
  StateCheck(Myself,STATE_SILENCED)
  Difficulty(EASIEST)
THEN
  RESPONSE #100
    SetGlobalTimer("Cast","LOCALS",6)
    SpellNoDec(Myself,WIZARD_VOCALIZE)
    Continue()
END

IF
  !GlobalTimerNotExpired("Cast","LOCALS")
  Allegiance(Myself,ENEMY)
  Detect([PC])
  !See(LastSeenBy(Myself))
  HaveSpell(WIZARD_TRUE_SIGHT)
THEN
  RESPONSE #100
    SetGlobalTimer("Cast","LOCALS",6)
    Spell(Myself,WIZARD_TRUE_SIGHT)
END

IF
  See(NearestEnemyOf(Myself))
  HaveSpell(WIZARD_STONE_SKIN)
  CheckStatLT(Myself,1,STONESKINS)
  HitBy([ANYONE],CRUSHING)
  Global("Prep2","LOCALS",0)
THEN
  RESPONSE #100
    DisplayString(Myself,40199) // Chain Contingency - Mirror Image
    ReallyForceSpell(Myself,WIZARD_MIRROR_IMAGE)
    DisplayString(Myself,3302) // Chain Contingency - Spell Turning
    ReallyForceSpell(Myself,WIZARD_SPELL_TURNING)
    DisplayString(Myself,@274) // Chain Contingency - Stoneskin
    ReallyForceSpell(Myself,WIZARD_STONE_SKIN)
    SetGlobal("Prep2","LOCALS",1)
END

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

IF
  !GlobalTimerNotExpired("Cast","LOCALS")
  Allegiance(Myself,ENEMY)
  !HasBounceEffects(Myself)
  HaveSpell(WIZARD_SPELL_TURNING)
THEN
  RESPONSE #100
    SetGlobalTimer("Cast","LOCALS",6)
    Spell(Myself,WIZARD_SPELL_TURNING)
END

IF
  OR(2)
    !GlobalTimerNotExpired("CAST","LOCALS")
    CheckStatGT(Myself,0,165)
  OR(2)
    HaveSpell(WIZARD_NPC_SYMBOL_STUN)
    HaveSpell(WIZARD_NPC_SYMBOL_FEAR)
  Allegiance(Myself,ENEMY)
  RandomNumGT(3,1)
  OR(2)
    !See(NearestEnemyOf(Myself))
    HasBounceEffects(NearestEnemyOf(Myself))
  Range(NearestEnemyOf(Myself),5)
  OR(2)
    !See(SecondNearestEnemyOf(Myself))
    HasBounceEffects(SecondNearestEnemyOf(Myself))
  Range(SecondNearestEnemyOf(Myself),5)
  OR(2)
    !See(ThirdNearestEnemyOf(Myself))
    HasBounceEffects(ThirdNearestEnemyOf(Myself))
  Range(ThirdNearestEnemyOf(Myself),5)
  OR(2)
    !See(FourthNearestEnemyOf(Myself))
    HasBounceEffects(FourthNearestEnemyOf(Myself))
  Range(FourthNearestEnemyOf(Myself),5)
  See(NearestEnemyOf(Myself))
  False()
THEN
  RESPONSE #100
    Continue()
END

IF
  OR(2)
    !GlobalTimerNotExpired("CAST","LOCALS")
    CheckStatGT(Myself,0,165)
  Allegiance(Myself,ENEMY)
  See(LastSeenBy(Myself))
  !HasBounceEffects(LastSeenBy(Myself))
  !Range(LastSeenBy(Myself),5)
  !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
  HaveSpell(WIZARD_SYMBOL_STUN)
  RandomNumGT(3,1)
THEN
  RESPONSE #100
    SetGlobalTimer("CAST","LOCALS",6)
    Spell(LastSeenBy(Myself),WIZARD_NPC_SYMBOL_STUN)
END

IF
  OR(2)
    !GlobalTimerNotExpired("CAST","LOCALS")
    CheckStatGT(Myself,0,165)
  Allegiance(Myself,ENEMY)
  See(LastSeenBy(Myself))
  !HasBounceEffects(LastSeenBy(Myself))
  !Range(LastSeenBy(Myself),5)
  !StateCheck(LastSeenBy(Myself),STATE_PANIC)
  HaveSpell(WIZARD_SYMBOL_FEAR)
  RandomNumGT(3,1)
THEN
  RESPONSE #100
    SetGlobalTimer("CAST","LOCALS",6)
    Spell(LastSeenBy(Myself),WIZARD_NPC_SYMBOL_FEAR)
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
  !GlobalTimerNotExpired("Cast","LOCALS")
  See(NearestEnemyOf(Myself))
  HaveSpell(WIZARD_CHAIN_LIGHTNING)
  RandomNum(4,1)
THEN
  RESPONSE #100
    SetGlobalTimer("Cast","LOCALS",6)
    Spell(TenthNearestEnemyOf(Myself),WIZARD_CHAIN_LIGHTNING)
END

IF
  !GlobalTimerNotExpired("Cast","LOCALS")
  See(NearestEnemyOf(Myself))
  HaveSpell(WIZARD_CHAIN_LIGHTNING)
  RandomNum(4,3)
THEN
  RESPONSE #100
    SetGlobalTimer("Cast","LOCALS",6)
    Spell(SixthNearestEnemyOf(Myself),WIZARD_CHAIN_LIGHTNING)
END

IF
  !GlobalTimerNotExpired("Cast","LOCALS")
  See(NearestEnemyOf(Myself))
  HaveSpell(WIZARD_CHAIN_LIGHTNING)
  RandomNum(4,4)
THEN
  RESPONSE #100
    SetGlobalTimer("Cast","LOCALS",6)
    Spell(NearestEnemyOf(Myself),WIZARD_CHAIN_LIGHTNING)
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
  See(NearestEnemyOf(Myself))
  HaveSpell(WIZARD_ABI_DALZIMS_HORRID_WILTING)
THEN
  RESPONSE #100
    DisplayString(Myself,39968) // Spell Trigger - Fired
    DisplayString(Myself,40244) // Spell Trigger - Stoneskins
    ReallyForceSpell(Myself,WIZARD_STONE_SKIN)
    DisplayString(Myself,40245) // Spell Trigger - Globe of Invulnerability
    ReallyForceSpell(Myself,WIZARD_GLOBE_OF_INVULNERABILITY)
    DisplayString(Myself,40246) // Spell Trigger - Minor Spell Turning
    ReallyForceSpell(Myself,WIZARD_MINOR_SPELL_TURNING)
    Spell(NearestEnemyOf(Myself),WIZARD_ABI_DALZIMS_HORRID_WILTING)
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)
  HaveSpell(WIZARD_FINGER_OF_DEATH)
  Allegiance(Myself,ENEMY)
  See(NearestEnemyOf(Myself))
  OR(12)
    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
    CheckStatLT(NearestEnemyOf(Myself),4,SAVEVSSPELL)
    CheckStatGT(LastSeenBy(Myself),0,157)
    HasItemEquipedReal("SW1H71",LastSeenBy(Myself)) // Hindo's Doom +4
    CheckStatGT(LastSeenBy(Myself),25,RESISTMAGIC)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    CheckStat(LastSeenBy(Myself),1,SANCTUARY)
  See(SecondNearestEnemyOf(Myself))
  OR(12)
    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
    CheckStatLT(NearestEnemyOf(Myself),4,SAVEVSSPELL)
    CheckStatGT(LastSeenBy(Myself),0,157)
    HasItemEquipedReal("SW1H71",LastSeenBy(Myself)) // Hindo's Doom +4
    CheckStatGT(LastSeenBy(Myself),25,RESISTMAGIC)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    CheckStat(LastSeenBy(Myself),1,SANCTUARY)
  See(ThirdNearestEnemyOf(Myself))
  OR(12)
    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
    CheckStatLT(NearestEnemyOf(Myself),4,SAVEVSSPELL)
    CheckStatGT(LastSeenBy(Myself),0,157)
    HasItemEquipedReal("SW1H71",LastSeenBy(Myself)) // Hindo's Doom +4
    CheckStatGT(LastSeenBy(Myself),25,RESISTMAGIC)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    CheckStat(LastSeenBy(Myself),1,SANCTUARY)
  See(FourthNearestEnemyOf(Myself))
  OR(12)
    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
    CheckStatLT(NearestEnemyOf(Myself),4,SAVEVSSPELL)
    CheckStatGT(LastSeenBy(Myself),0,157)
    HasItemEquipedReal("SW1H71",LastSeenBy(Myself)) // Hindo's Doom +4
    CheckStatGT(LastSeenBy(Myself),25,RESISTMAGIC)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    CheckStat(LastSeenBy(Myself),1,SANCTUARY)
  See(FifthNearestEnemyOf(Myself))
  OR(12)
    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
    CheckStatLT(NearestEnemyOf(Myself),4,SAVEVSSPELL)
    CheckStatGT(LastSeenBy(Myself),0,157)
    HasItemEquipedReal("SW1H71",LastSeenBy(Myself)) // Hindo's Doom +4
    CheckStatGT(LastSeenBy(Myself),25,RESISTMAGIC)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    CheckStat(LastSeenBy(Myself),1,SANCTUARY)
  See(SixthNearestEnemyOf(Myself))
  OR(12)
    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
    CheckStatLT(NearestEnemyOf(Myself),4,SAVEVSSPELL)
    CheckStatGT(LastSeenBy(Myself),0,157)
    HasItemEquipedReal("SW1H71",LastSeenBy(Myself)) // Hindo's Doom +4
    CheckStatGT(LastSeenBy(Myself),25,RESISTMAGIC)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    CheckStat(LastSeenBy(Myself),1,SANCTUARY)
  See(SeventhNearestEnemyOf(Myself))
  OR(12)
    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
    CheckStatLT(NearestEnemyOf(Myself),4,SAVEVSSPELL)
    CheckStatGT(LastSeenBy(Myself),0,157)
    HasItemEquipedReal("SW1H71",LastSeenBy(Myself)) // Hindo's Doom +4
    CheckStatGT(LastSeenBy(Myself),25,RESISTMAGIC)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    CheckStat(LastSeenBy(Myself),1,SANCTUARY)
  See(EighthNearestEnemyOf(Myself))
  OR(12)
    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
    CheckStatLT(NearestEnemyOf(Myself),4,SAVEVSSPELL)
    CheckStatGT(LastSeenBy(Myself),0,157)
    HasItemEquipedReal("SW1H71",LastSeenBy(Myself)) // Hindo's Doom +4
    CheckStatGT(LastSeenBy(Myself),25,RESISTMAGIC)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    CheckStat(LastSeenBy(Myself),1,SANCTUARY)
  See(NinthNearestEnemyOf(Myself))
  OR(12)
    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
    CheckStatLT(NearestEnemyOf(Myself),4,SAVEVSSPELL)
    CheckStatGT(LastSeenBy(Myself),0,157)
    HasItemEquipedReal("SW1H71",LastSeenBy(Myself)) // Hindo's Doom +4
    CheckStatGT(LastSeenBy(Myself),25,RESISTMAGIC)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    CheckStat(LastSeenBy(Myself),1,SANCTUARY)
  See(TenthNearestEnemyOf(Myself))
  OR(12)
    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
    CheckStatLT(NearestEnemyOf(Myself),4,SAVEVSSPELL)
    CheckStatGT(LastSeenBy(Myself),0,157)
    HasItemEquipedReal("SW1H71",LastSeenBy(Myself)) // Hindo's Doom +4
    CheckStatGT(LastSeenBy(Myself),25,RESISTMAGIC)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    CheckStat(LastSeenBy(Myself),1,SANCTUARY)
  See(NearestEnemyOf(Myself))
  OR(12)
    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
    CheckStatLT(NearestEnemyOf(Myself),1,SAVEVSSPELL)
    CheckStatGT(LastSeenBy(Myself),0,157)
    HasItemEquipedReal("SW1H71",LastSeenBy(Myself)) // Hindo's Doom +4
    CheckStatGT(LastSeenBy(Myself),75,RESISTMAGIC)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    CheckStat(LastSeenBy(Myself),1,SANCTUARY)
  See(SecondNearestEnemyOf(Myself))
  OR(12)
    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
    CheckStatLT(NearestEnemyOf(Myself),1,SAVEVSSPELL)
    CheckStatGT(LastSeenBy(Myself),0,157)
    HasItemEquipedReal("SW1H71",LastSeenBy(Myself)) // Hindo's Doom +4
    CheckStatGT(LastSeenBy(Myself),75,RESISTMAGIC)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    CheckStat(LastSeenBy(Myself),1,SANCTUARY)
  See(ThirdNearestEnemyOf(Myself))
  OR(12)
    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
    CheckStatLT(NearestEnemyOf(Myself),1,SAVEVSSPELL)
    CheckStatGT(LastSeenBy(Myself),0,157)
    HasItemEquipedReal("SW1H71",LastSeenBy(Myself)) // Hindo's Doom +4
    CheckStatGT(LastSeenBy(Myself),75,RESISTMAGIC)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    CheckStat(LastSeenBy(Myself),1,SANCTUARY)
  See(FourthNearestEnemyOf(Myself))
  OR(12)
    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
    CheckStatLT(NearestEnemyOf(Myself),1,SAVEVSSPELL)
    CheckStatGT(LastSeenBy(Myself),0,157)
    HasItemEquipedReal("SW1H71",LastSeenBy(Myself)) // Hindo's Doom +4
    CheckStatGT(LastSeenBy(Myself),75,RESISTMAGIC)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    CheckStat(LastSeenBy(Myself),1,SANCTUARY)
  See(FifthNearestEnemyOf(Myself))
  OR(12)
    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
    CheckStatLT(NearestEnemyOf(Myself),1,SAVEVSSPELL)
    CheckStatGT(LastSeenBy(Myself),0,157)
    HasItemEquipedReal("SW1H71",LastSeenBy(Myself)) // Hindo's Doom +4
    CheckStatGT(LastSeenBy(Myself),75,RESISTMAGIC)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    CheckStat(LastSeenBy(Myself),1,SANCTUARY)
  See(SixthNearestEnemyOf(Myself))
  OR(12)
    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
    CheckStatLT(NearestEnemyOf(Myself),1,SAVEVSSPELL)
    CheckStatGT(LastSeenBy(Myself),0,157)
    HasItemEquipedReal("SW1H71",LastSeenBy(Myself)) // Hindo's Doom +4
    CheckStatGT(LastSeenBy(Myself),75,RESISTMAGIC)
    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    CheckStat(LastSeenBy(Myself),1,SANCTUARY)
  See(NearestEnemyOf(Myself))
  False()
THEN
  RESPONSE #100
    Continue()
END

IF
  OR(2)
    !GlobalTimerNotExpired("CAST","LOCALS")
    CheckStatGT(Myself,0,165)
  Allegiance(Myself,ENEMY)
  HaveSpell(WIZARD_FINGER_OF_DEATH)
  !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
  !CheckStat(NearestEnemyOf(Myself),0,157)
  !HasItemEquipedReal("SW1H71",LastSeenBy(Myself)) // Hindo's Doom +4
  CheckStatLT(LastSeenBy(Myself),75,RESISTMAGIC)
  CheckStatGT(NearestEnemyOf(Myself),0,SAVEVSSPELL)
  !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
  CheckStat(LastSeenBy(Myself),0,SANCTUARY)
THEN
  RESPONSE #100
    SetGlobalTimer("CAST","LOCALS",6)
    Spell(LastSeenBy(Myself),WIZARD_FINGER_OF_DEATH)
END

IF
  See(NearestEnemyOf(Myself))
  HaveSpell(WIZARD_FLESH_TO_STONE)
  Global("D0Sequencer","LOCALS",0)
THEN
  RESPONSE #100
    SetGlobal("D0Sequencer","LOCALS",1)
    DisplayString(Myself,39969) // Spell Sequencer - Fired
    DisplayString(Myself,40241) // Spell Sequencer - Stoneskins
    ReallyForceSpell(Myself,WIZARD_STONE_SKIN)
    DisplayString(Myself,40243) // Spell Sequencer - Fireshield Red
    ReallyForceSpell(Myself,WIZARD_FIRE_SHIELD_RED)
END

IF
  OR(2)
    !GlobalTimerNotExpired("CAST","LOCALS")
    CheckStatGT(Myself,0,165)
  HaveSpell(WIZARD_FLESH_TO_STONE)
  Allegiance(Myself,ENEMY)
  See(NearestEnemyOf(Myself))
  OR(10)
    CheckStatGT(LastSeenBy(Myself),1,116)
    CheckStatGT(LastSeenBy(Myself),1,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStat(LastSeenBy(Myself),8,162)
    HasItemEquiped("CLCK26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatLT(LastSeenBy(Myself),6,SAVEVSSPELL)
    CheckStatGT(LastSeenBy(Myself),25,RESISTMAGIC)
    CheckStatGT(LastSeenBy(Myself),0,176)
    StateCheck(LastSeenBy(Myself),STATE_STONE_DEATH)
  See(SecondNearestEnemyOf(Myself))
  OR(10)
    CheckStatGT(LastSeenBy(Myself),1,116)
    CheckStatGT(LastSeenBy(Myself),1,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStat(LastSeenBy(Myself),8,162)
    HasItemEquiped("CLCK26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatLT(LastSeenBy(Myself),6,SAVEVSSPELL)
    CheckStatGT(LastSeenBy(Myself),25,RESISTMAGIC)
    CheckStatGT(LastSeenBy(Myself),0,176)
    StateCheck(LastSeenBy(Myself),STATE_STONE_DEATH)
  See(ThirdNearestEnemyOf(Myself))
  OR(10)
    CheckStatGT(LastSeenBy(Myself),1,116)
    CheckStatGT(LastSeenBy(Myself),1,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStat(LastSeenBy(Myself),8,162)
    HasItemEquiped("CLCK26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatLT(LastSeenBy(Myself),6,SAVEVSSPELL)
    CheckStatGT(LastSeenBy(Myself),25,RESISTMAGIC)
    CheckStatGT(LastSeenBy(Myself),0,176)
    StateCheck(LastSeenBy(Myself),STATE_STONE_DEATH)
  See(FourthNearestEnemyOf(Myself))
  OR(10)
    CheckStatGT(LastSeenBy(Myself),1,116)
    CheckStatGT(LastSeenBy(Myself),1,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStat(LastSeenBy(Myself),8,162)
    HasItemEquiped("CLCK26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatLT(LastSeenBy(Myself),6,SAVEVSSPELL)
    CheckStatGT(LastSeenBy(Myself),25,RESISTMAGIC)
    CheckStatGT(LastSeenBy(Myself),0,176)
    StateCheck(LastSeenBy(Myself),STATE_STONE_DEATH)
  See(FifthNearestEnemyOf(Myself))
  OR(10)
    CheckStatGT(LastSeenBy(Myself),1,116)
    CheckStatGT(LastSeenBy(Myself),1,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStat(LastSeenBy(Myself),8,162)
    HasItemEquiped("CLCK26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatLT(LastSeenBy(Myself),6,SAVEVSSPELL)
    CheckStatGT(LastSeenBy(Myself),25,RESISTMAGIC)
    CheckStatGT(LastSeenBy(Myself),0,176)
    StateCheck(LastSeenBy(Myself),STATE_STONE_DEATH)
  See(SixthNearestEnemyOf(Myself))
  OR(10)
    CheckStatGT(LastSeenBy(Myself),1,116)
    CheckStatGT(LastSeenBy(Myself),1,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStat(LastSeenBy(Myself),8,162)
    HasItemEquiped("CLCK26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatLT(LastSeenBy(Myself),6,SAVEVSSPELL)
    CheckStatGT(LastSeenBy(Myself),25,RESISTMAGIC)
    CheckStatGT(LastSeenBy(Myself),0,176)
    StateCheck(LastSeenBy(Myself),STATE_STONE_DEATH)
  See(SeventhNearestEnemyOf(Myself))
  OR(10)
    CheckStatGT(LastSeenBy(Myself),1,116)
    CheckStatGT(LastSeenBy(Myself),1,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStat(LastSeenBy(Myself),8,162)
    HasItemEquiped("CLCK26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatLT(LastSeenBy(Myself),6,SAVEVSSPELL)
    CheckStatGT(LastSeenBy(Myself),25,RESISTMAGIC)
    CheckStatGT(LastSeenBy(Myself),0,176)
    StateCheck(LastSeenBy(Myself),STATE_STONE_DEATH)
  See(EighthNearestEnemyOf(Myself))
  OR(10)
    CheckStatGT(LastSeenBy(Myself),1,116)
    CheckStatGT(LastSeenBy(Myself),1,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStat(LastSeenBy(Myself),8,162)
    HasItemEquiped("CLCK26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatLT(LastSeenBy(Myself),6,SAVEVSSPELL)
    CheckStatGT(LastSeenBy(Myself),25,RESISTMAGIC)
    CheckStatGT(LastSeenBy(Myself),0,176)
    StateCheck(LastSeenBy(Myself),STATE_STONE_DEATH)
  See(NinthNearestEnemyOf(Myself))
  OR(10)
    CheckStatGT(LastSeenBy(Myself),1,116)
    CheckStatGT(LastSeenBy(Myself),1,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStat(LastSeenBy(Myself),8,162)
    HasItemEquiped("CLCK26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatLT(LastSeenBy(Myself),6,SAVEVSSPELL)
    CheckStatGT(LastSeenBy(Myself),25,RESISTMAGIC)
    CheckStatGT(LastSeenBy(Myself),0,176)
    StateCheck(LastSeenBy(Myself),STATE_STONE_DEATH)
  See(TenthNearestEnemyOf(Myself))
  OR(10)
    CheckStatGT(LastSeenBy(Myself),1,116)
    CheckStatGT(LastSeenBy(Myself),1,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStat(LastSeenBy(Myself),8,162)
    HasItemEquiped("CLCK26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatLT(LastSeenBy(Myself),6,SAVEVSSPELL)
    CheckStatGT(LastSeenBy(Myself),25,RESISTMAGIC)
    CheckStatGT(LastSeenBy(Myself),0,176)
    StateCheck(LastSeenBy(Myself),STATE_STONE_DEATH)
  See(NearestEnemyOf(Myself))
  False()
THEN
  RESPONSE #100
    Continue()
END

IF
  OR(2)
    !GlobalTimerNotExpired("CAST","LOCALS")
    CheckStatGT(Myself,0,165)
  HaveSpell(WIZARD_FLESH_TO_STONE)
  Allegiance(Myself,ENEMY)
  See(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),1,116)
  !CheckStatGT(LastSeenBy(Myself),1,129)
  !CheckStatGT(LastSeenBy(Myself),0,164)
  !CheckStatGT(LastSeenBy(Myself),0,123)
  !CheckStat(LastSeenBy(Myself),8,162)
  !HasItemEquiped("CLCK26",LastSeenBy(Myself)) // Cloak of Mirroring
  !CheckStatLT(LastSeenBy(Myself),6,SAVEVSSPELL)
  !CheckStatGT(LastSeenBy(Myself),25,RESISTMAGIC)
  !CheckStatGT(LastSeenBy(Myself),0,176)
  !StateCheck(LastSeenBy(Myself),STATE_STONE_DEATH)
THEN
  RESPONSE #100
    SetGlobalTimer("CAST","LOCALS",6)
    Spell(LastSeenBy(Myself),WIZARD_FLESH_TO_STONE)
END

IF
  OR(2)
    !GlobalTimerNotExpired("CAST","LOCALS")
    CheckStatGT(Myself,0,165)
  HaveSpell(WIZARD_DISINTEGRATE)
  Allegiance(Myself,ENEMY)
  See(NearestEnemyOf(Myself))
  OR(10)
    CheckStatGT(LastSeenBy(Myself),1,116)
    CheckStatGT(LastSeenBy(Myself),1,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStat(LastSeenBy(Myself),8,162)
    HasItemEquiped("CLCK26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatLT(LastSeenBy(Myself),6,SAVEVSSPELL)
    CheckStatGT(LastSeenBy(Myself),25,RESISTMAGIC)
    CheckStatGT(LastSeenBy(Myself),0,157)
    HasItemEquipedReal("SW1H71",LastSeenBy(Myself)) // Hindo's Doom +4
  See(SecondNearestEnemyOf(Myself))
  OR(10)
    CheckStatGT(LastSeenBy(Myself),1,116)
    CheckStatGT(LastSeenBy(Myself),1,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStat(LastSeenBy(Myself),8,162)
    HasItemEquiped("CLCK26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatLT(LastSeenBy(Myself),6,SAVEVSSPELL)
    CheckStatGT(LastSeenBy(Myself),25,RESISTMAGIC)
    CheckStatGT(LastSeenBy(Myself),0,157)
    HasItemEquipedReal("SW1H71",LastSeenBy(Myself)) // Hindo's Doom +4
  See(ThirdNearestEnemyOf(Myself))
  OR(10)
    CheckStatGT(LastSeenBy(Myself),1,116)
    CheckStatGT(LastSeenBy(Myself),1,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStat(LastSeenBy(Myself),8,162)
    HasItemEquiped("CLCK26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatLT(LastSeenBy(Myself),6,SAVEVSSPELL)
    CheckStatGT(LastSeenBy(Myself),25,RESISTMAGIC)
    CheckStatGT(LastSeenBy(Myself),0,157)
    HasItemEquipedReal("SW1H71",LastSeenBy(Myself)) // Hindo's Doom +4
  See(FourthNearestEnemyOf(Myself))
  OR(10)
    CheckStatGT(LastSeenBy(Myself),1,116)
    CheckStatGT(LastSeenBy(Myself),1,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStat(LastSeenBy(Myself),8,162)
    HasItemEquiped("CLCK26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatLT(LastSeenBy(Myself),6,SAVEVSSPELL)
    CheckStatGT(LastSeenBy(Myself),25,RESISTMAGIC)
    CheckStatGT(LastSeenBy(Myself),0,157)
    HasItemEquipedReal("SW1H71",LastSeenBy(Myself)) // Hindo's Doom +4
  See(FifthNearestEnemyOf(Myself))
  OR(10)
    CheckStatGT(LastSeenBy(Myself),1,116)
    CheckStatGT(LastSeenBy(Myself),1,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStat(LastSeenBy(Myself),8,162)
    HasItemEquiped("CLCK26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatLT(LastSeenBy(Myself),6,SAVEVSSPELL)
    CheckStatGT(LastSeenBy(Myself),25,RESISTMAGIC)
    CheckStatGT(LastSeenBy(Myself),0,157)
    HasItemEquipedReal("SW1H71",LastSeenBy(Myself)) // Hindo's Doom +4
  See(SixthNearestEnemyOf(Myself))
  OR(10)
    CheckStatGT(LastSeenBy(Myself),1,116)
    CheckStatGT(LastSeenBy(Myself),1,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStat(LastSeenBy(Myself),8,162)
    HasItemEquiped("CLCK26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatLT(LastSeenBy(Myself),6,SAVEVSSPELL)
    CheckStatGT(LastSeenBy(Myself),25,RESISTMAGIC)
    CheckStatGT(LastSeenBy(Myself),0,157)
    HasItemEquipedReal("SW1H71",LastSeenBy(Myself)) // Hindo's Doom +4
  See(SeventhNearestEnemyOf(Myself))
  OR(10)
    CheckStatGT(LastSeenBy(Myself),1,116)
    CheckStatGT(LastSeenBy(Myself),1,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStat(LastSeenBy(Myself),8,162)
    HasItemEquiped("CLCK26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatLT(LastSeenBy(Myself),6,SAVEVSSPELL)
    CheckStatGT(LastSeenBy(Myself),25,RESISTMAGIC)
    CheckStatGT(LastSeenBy(Myself),0,157)
    HasItemEquipedReal("SW1H71",LastSeenBy(Myself)) // Hindo's Doom +4
  See(EighthNearestEnemyOf(Myself))
  OR(10)
    CheckStatGT(LastSeenBy(Myself),1,116)
    CheckStatGT(LastSeenBy(Myself),1,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStat(LastSeenBy(Myself),8,162)
    HasItemEquiped("CLCK26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatLT(LastSeenBy(Myself),6,SAVEVSSPELL)
    CheckStatGT(LastSeenBy(Myself),25,RESISTMAGIC)
    CheckStatGT(LastSeenBy(Myself),0,157)
    HasItemEquipedReal("SW1H71",LastSeenBy(Myself)) // Hindo's Doom +4
  See(NinthNearestEnemyOf(Myself))
  OR(10)
    CheckStatGT(LastSeenBy(Myself),1,116)
    CheckStatGT(LastSeenBy(Myself),1,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStat(LastSeenBy(Myself),8,162)
    HasItemEquiped("CLCK26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatLT(LastSeenBy(Myself),6,SAVEVSSPELL)
    CheckStatGT(LastSeenBy(Myself),25,RESISTMAGIC)
    CheckStatGT(LastSeenBy(Myself),0,157)
    HasItemEquipedReal("SW1H71",LastSeenBy(Myself)) // Hindo's Doom +4
  See(TenthNearestEnemyOf(Myself))
  OR(10)
    CheckStatGT(LastSeenBy(Myself),1,116)
    CheckStatGT(LastSeenBy(Myself),1,129)
    CheckStatGT(LastSeenBy(Myself),0,164)
    CheckStatGT(LastSeenBy(Myself),0,123)
    CheckStat(LastSeenBy(Myself),8,162)
    HasItemEquiped("CLCK26",LastSeenBy(Myself)) // Cloak of Mirroring
    CheckStatLT(LastSeenBy(Myself),6,SAVEVSSPELL)
    CheckStatGT(LastSeenBy(Myself),25,RESISTMAGIC)
    CheckStatGT(LastSeenBy(Myself),0,157)
    HasItemEquipedReal("SW1H71",LastSeenBy(Myself)) // Hindo's Doom +4
  See(NearestEnemyOf(Myself))
  False()
THEN
  RESPONSE #100
    Continue()
END

IF
  OR(2)
    !GlobalTimerNotExpired("CAST","LOCALS")
    CheckStatGT(Myself,0,165)
  HaveSpell(WIZARD_DISINTEGRATE)
  Allegiance(Myself,ENEMY)
  See(LastSeenBy(Myself))
  !CheckStatGT(LastSeenBy(Myself),1,116)
  !CheckStatGT(LastSeenBy(Myself),1,129)
  !CheckStatGT(LastSeenBy(Myself),0,164)
  !CheckStatGT(LastSeenBy(Myself),0,123)
  !CheckStat(LastSeenBy(Myself),8,162)
  !HasItemEquiped("CLCK26",LastSeenBy(Myself)) // Cloak of Mirroring
  !CheckStatLT(LastSeenBy(Myself),6,SAVEVSSPELL)
  !CheckStatGT(LastSeenBy(Myself),25,RESISTMAGIC)
  !CheckStatGT(LastSeenBy(Myself),0,157)
  !HasItemEquipedReal("SW1H71",LastSeenBy(Myself)) // Hindo's Doom +4
THEN
  RESPONSE #100
    SetGlobalTimer("CAST","LOCALS",6)
    Spell(LastSeenBy(Myself),WIZARD_DISINTEGRATE)
END

IF
  !GlobalTimerNotExpired("Cast","LOCALS")
  See(TenthNearestEnemyOf(Myself))
  HaveSpell(WIZARD_CHAOS)
  RandomNum(3,1)
THEN
  RESPONSE #100
    SetGlobalTimer("Cast","LOCALS",6)
    Spell(TenthNearestEnemyOf(Myself),WIZARD_CHAOS)
END

IF
  !GlobalTimerNotExpired("Cast","LOCALS")
  See(NearestEnemyOf(Myself))
  HaveSpell(WIZARD_CHAOS)
  RandomNum(3,3)
THEN
  RESPONSE #100
    SetGlobalTimer("Cast","LOCALS",6)
    Spell(NearestEnemyOf(Myself),WIZARD_CHAOS)
END

IF
  !GlobalTimerNotExpired("Cast","LOCALS")
  See(NearestEnemyOf(Myself))
  HaveSpell(WIZARD_ANIMATE_DEAD)
  RandomNumGT(8,4)
THEN
  RESPONSE #100
    SetGlobalTimer("Cast","LOCALS",6)
    Spell(Myself,WIZARD_ANIMATE_DEAD)
END

IF
  !GlobalTimerNotExpired("Cast","LOCALS")
  See(NearestEnemyOf(Myself))
  HaveSpell(WIZARD_SPIDER_SPAWN)
  RandomNumGT(6,4)
THEN
  RESPONSE #100
    SetGlobalTimer("Cast","LOCALS",6)
    Spell(Myself,WIZARD_SPIDER_SPAWN)
END

IF
  OR(2)
    !GlobalTimerNotExpired("CAST","LOCALS")
    CheckStatGT(Myself,0,165)
  HaveSpell(WIZARD_FLAME_ARROW)
  See(NearestEnemyOf(Myself))
  RandomNumGT(6,2)
  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))
  RandomNumGT(6,2)
  !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)
  RandomNumGT(7,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),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)
  RandomNumGT(7,2)
  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)
  HaveSpell(WIZARD_MAGIC_MISSILE)
  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)
  HaveSpell(WIZARD_MAGIC_MISSILE)
THEN
  RESPONSE #100
    SetGlobalTimer("CAST","LOCALS",6)
    ForceSpell(LastSeenBy(Myself),WIZARD_MAGIC_MISSILE)
END

IF
  See(NearestEnemyOf(Myself))
  !HaveSpell(WIZARD_MAGIC_MISSILE)
  !HaveSpell(WIZARD_MELF_ACID_ARROW)
  !HaveSpell(WIZARD_FLAME_ARROW)
  !HaveSpell(WIZARD_DISINTEGRATE)
  !HaveSpell(WIZARD_FLESH_TO_STONE)
  !HaveSpell(WIZARD_FINGER_OF_DEATH)
  !HaveSpell(WIZARD_POWER_WORD_KILL)
  !HaveSpell(WIZARD_CHAIN_LIGHTNING)
  !HaveSpell(WIZARD_ABI_DALZIMS_HORRID_WILTING)
THEN
  RESPONSE #100
    Attack(NearestEnemyOf(Myself))
END

IF
  TookDamage()
  Detect(LastAttackerOf(Myself))
  OR(9)
    HaveSpell(WIZARD_MAGIC_MISSILE)
    HaveSpell(WIZARD_MELF_ACID_ARROW)
    HaveSpell(WIZARD_FLAME_ARROW)
    HaveSpell(WIZARD_DISINTEGRATE)
    HaveSpell(WIZARD_FLESH_TO_STONE)
    HaveSpell(WIZARD_FINGER_OF_DEATH)
    HaveSpell(WIZARD_POWER_WORD_KILL)
    HaveSpell(WIZARD_CHAIN_LIGHTNING)
    HaveSpell(WIZARD_ABI_DALZIMS_HORRID_WILTING)
THEN
  RESPONSE #100
    RunAwayFromNoInterrupt(LastAttackerOf(Myself),10)
END
