IF
    OR(2)
		!GlobalTimerNotExpired("CAST","LOCALS")
        CheckStatGT(Myself,0,WIZARD_IMPROVED_ALACRITY)
    HaveSpell(WIZARD_DISINTEGRATE)
    See(NearestEnemyOf(Myself))
    OR(10)
		CheckStatGT(LastSeenBy(Myself),1,WIZARD_SPELL_DEFLECTION)
		CheckStatGT(LastSeenBy(Myself),1,WIZARD_SPELL_TURNING)
		CheckStatGT(LastSeenBy(Myself),0,WIZARD_SPELL_TRAP)
		CheckStatGT(LastSeenBy(Myself),0,CLERIC_SHIELD_OF_THE_ARCHONS)
		CheckStat(LastSeenBy(Myself),8,WIZARD_SPELL_IMMUNITY)
        HasItemEquiped("CLCK26",LastSeenBy(Myself)) // Cloak of Mirroring
        CheckStatLT(LastSeenBy(Myself),6,SAVEVSSPELL)
        CheckStatGT(LastSeenBy(Myself),25,RESISTMAGIC)
        CheckStatGT(LastSeenBy(Myself),0,SCRIPTINGSTATE2)
        HasItemEquipedReal("SW1H71",LastSeenBy(Myself)) // Hindo's Doom +4
    See(SecondNearestEnemyOf(Myself))
    OR(10)
		CheckStatGT(LastSeenBy(Myself),1,WIZARD_SPELL_DEFLECTION)
		CheckStatGT(LastSeenBy(Myself),1,WIZARD_SPELL_TURNING)
		CheckStatGT(LastSeenBy(Myself),0,WIZARD_SPELL_TRAP)
		CheckStatGT(LastSeenBy(Myself),0,CLERIC_SHIELD_OF_THE_ARCHONS)
		CheckStat(LastSeenBy(Myself),8,WIZARD_SPELL_IMMUNITY)
        HasItemEquiped("CLCK26",LastSeenBy(Myself)) // Cloak of Mirroring
        CheckStatLT(LastSeenBy(Myself),6,SAVEVSSPELL)
        CheckStatGT(LastSeenBy(Myself),25,RESISTMAGIC)
        CheckStatGT(LastSeenBy(Myself),0,SCRIPTINGSTATE2)
        HasItemEquipedReal("SW1H71",LastSeenBy(Myself)) // Hindo's Doom +4
    See(ThirdNearestEnemyOf(Myself))
    OR(10)
		CheckStatGT(LastSeenBy(Myself),1,WIZARD_SPELL_DEFLECTION)
		CheckStatGT(LastSeenBy(Myself),1,WIZARD_SPELL_TURNING)
		CheckStatGT(LastSeenBy(Myself),0,WIZARD_SPELL_TRAP)
		CheckStatGT(LastSeenBy(Myself),0,CLERIC_SHIELD_OF_THE_ARCHONS)
		CheckStat(LastSeenBy(Myself),8,WIZARD_SPELL_IMMUNITY)
        HasItemEquiped("CLCK26",LastSeenBy(Myself)) // Cloak of Mirroring
        CheckStatLT(LastSeenBy(Myself),6,SAVEVSSPELL)
        CheckStatGT(LastSeenBy(Myself),25,RESISTMAGIC)
        CheckStatGT(LastSeenBy(Myself),0,SCRIPTINGSTATE2)
        HasItemEquipedReal("SW1H71",LastSeenBy(Myself)) // Hindo's Doom +4
    See(FourthNearestEnemyOf(Myself))
    OR(10)
		CheckStatGT(LastSeenBy(Myself),1,WIZARD_SPELL_DEFLECTION)
		CheckStatGT(LastSeenBy(Myself),1,WIZARD_SPELL_TURNING)
		CheckStatGT(LastSeenBy(Myself),0,WIZARD_SPELL_TRAP)
		CheckStatGT(LastSeenBy(Myself),0,CLERIC_SHIELD_OF_THE_ARCHONS)
		CheckStat(LastSeenBy(Myself),8,WIZARD_SPELL_IMMUNITY)
        HasItemEquiped("CLCK26",LastSeenBy(Myself)) // Cloak of Mirroring
        CheckStatLT(LastSeenBy(Myself),6,SAVEVSSPELL)
        CheckStatGT(LastSeenBy(Myself),25,RESISTMAGIC)
        CheckStatGT(LastSeenBy(Myself),0,SCRIPTINGSTATE2)
        HasItemEquipedReal("SW1H71",LastSeenBy(Myself)) // Hindo's Doom +4
    See(FifthNearestEnemyOf(Myself))
    OR(10)
		CheckStatGT(LastSeenBy(Myself),1,WIZARD_SPELL_DEFLECTION)
		CheckStatGT(LastSeenBy(Myself),1,WIZARD_SPELL_TURNING)
		CheckStatGT(LastSeenBy(Myself),0,WIZARD_SPELL_TRAP)
		CheckStatGT(LastSeenBy(Myself),0,CLERIC_SHIELD_OF_THE_ARCHONS)
		CheckStat(LastSeenBy(Myself),8,WIZARD_SPELL_IMMUNITY)
        HasItemEquiped("CLCK26",LastSeenBy(Myself)) // Cloak of Mirroring
        CheckStatLT(LastSeenBy(Myself),6,SAVEVSSPELL)
        CheckStatGT(LastSeenBy(Myself),25,RESISTMAGIC)
        CheckStatGT(LastSeenBy(Myself),0,SCRIPTINGSTATE2)
        HasItemEquipedReal("SW1H71",LastSeenBy(Myself)) // Hindo's Doom +4
    See(SixthNearestEnemyOf(Myself))
    OR(10)
		CheckStatGT(LastSeenBy(Myself),1,WIZARD_SPELL_DEFLECTION)
		CheckStatGT(LastSeenBy(Myself),1,WIZARD_SPELL_TURNING)
		CheckStatGT(LastSeenBy(Myself),0,WIZARD_SPELL_TRAP)
		CheckStatGT(LastSeenBy(Myself),0,CLERIC_SHIELD_OF_THE_ARCHONS)
		CheckStat(LastSeenBy(Myself),8,WIZARD_SPELL_IMMUNITY)
        HasItemEquiped("CLCK26",LastSeenBy(Myself)) // Cloak of Mirroring
        CheckStatLT(LastSeenBy(Myself),6,SAVEVSSPELL)
        CheckStatGT(LastSeenBy(Myself),25,RESISTMAGIC)
        CheckStatGT(LastSeenBy(Myself),0,SCRIPTINGSTATE2)
        HasItemEquipedReal("SW1H71",LastSeenBy(Myself)) // Hindo's Doom +4
    See(SeventhNearestEnemyOf(Myself))
    OR(10)
		CheckStatGT(LastSeenBy(Myself),1,WIZARD_SPELL_DEFLECTION)
		CheckStatGT(LastSeenBy(Myself),1,WIZARD_SPELL_TURNING)
		CheckStatGT(LastSeenBy(Myself),0,WIZARD_SPELL_TRAP)
		CheckStatGT(LastSeenBy(Myself),0,CLERIC_SHIELD_OF_THE_ARCHONS)
		CheckStat(LastSeenBy(Myself),8,WIZARD_SPELL_IMMUNITY)
        HasItemEquiped("CLCK26",LastSeenBy(Myself)) // Cloak of Mirroring
        CheckStatLT(LastSeenBy(Myself),6,SAVEVSSPELL)
        CheckStatGT(LastSeenBy(Myself),25,RESISTMAGIC)
        CheckStatGT(LastSeenBy(Myself),0,SCRIPTINGSTATE2)
        HasItemEquipedReal("SW1H71",LastSeenBy(Myself)) // Hindo's Doom +4
    See(EighthNearestEnemyOf(Myself))
    OR(10)
		CheckStatGT(LastSeenBy(Myself),1,WIZARD_SPELL_DEFLECTION)
		CheckStatGT(LastSeenBy(Myself),1,WIZARD_SPELL_TURNING)
		CheckStatGT(LastSeenBy(Myself),0,WIZARD_SPELL_TRAP)
		CheckStatGT(LastSeenBy(Myself),0,CLERIC_SHIELD_OF_THE_ARCHONS)
		CheckStat(LastSeenBy(Myself),8,WIZARD_SPELL_IMMUNITY)
        HasItemEquiped("CLCK26",LastSeenBy(Myself)) // Cloak of Mirroring
        CheckStatLT(LastSeenBy(Myself),6,SAVEVSSPELL)
        CheckStatGT(LastSeenBy(Myself),25,RESISTMAGIC)
        CheckStatGT(LastSeenBy(Myself),0,SCRIPTINGSTATE2)
        HasItemEquipedReal("SW1H71",LastSeenBy(Myself)) // Hindo's Doom +4
    See(NinthNearestEnemyOf(Myself))
    OR(10)
		CheckStatGT(LastSeenBy(Myself),1,WIZARD_SPELL_DEFLECTION)
		CheckStatGT(LastSeenBy(Myself),1,WIZARD_SPELL_TURNING)
		CheckStatGT(LastSeenBy(Myself),0,WIZARD_SPELL_TRAP)
		CheckStatGT(LastSeenBy(Myself),0,CLERIC_SHIELD_OF_THE_ARCHONS)
		CheckStat(LastSeenBy(Myself),8,WIZARD_SPELL_IMMUNITY)
        HasItemEquiped("CLCK26",LastSeenBy(Myself)) // Cloak of Mirroring
        CheckStatLT(LastSeenBy(Myself),6,SAVEVSSPELL)
        CheckStatGT(LastSeenBy(Myself),25,RESISTMAGIC)
        CheckStatGT(LastSeenBy(Myself),0,SCRIPTINGSTATE2)
        HasItemEquipedReal("SW1H71",LastSeenBy(Myself)) // Hindo's Doom +4
    See(TenthNearestEnemyOf(Myself))
    OR(10)
		CheckStatGT(LastSeenBy(Myself),1,WIZARD_SPELL_DEFLECTION)
		CheckStatGT(LastSeenBy(Myself),1,WIZARD_SPELL_TURNING)
		CheckStatGT(LastSeenBy(Myself),0,WIZARD_SPELL_TRAP)
		CheckStatGT(LastSeenBy(Myself),0,CLERIC_SHIELD_OF_THE_ARCHONS)
		CheckStat(LastSeenBy(Myself),8,WIZARD_SPELL_IMMUNITY)
        HasItemEquiped("CLCK26",LastSeenBy(Myself)) // Cloak of Mirroring
        CheckStatLT(LastSeenBy(Myself),6,SAVEVSSPELL)
        CheckStatGT(LastSeenBy(Myself),25,RESISTMAGIC)
        CheckStatGT(LastSeenBy(Myself),0,SCRIPTINGSTATE2)
        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,WIZARD_IMPROVED_ALACRITY)
    HaveSpell(WIZARD_DISINTEGRATE)
    See(LastSeenBy(Myself))
	!CheckStatGT(LastSeenBy(Myself),1,WIZARD_SPELL_DEFLECTION)
	!CheckStatGT(LastSeenBy(Myself),1,WIZARD_SPELL_TURNING)
	!CheckStatGT(LastSeenBy(Myself),0,WIZARD_SPELL_TRAP)
	!CheckStatGT(LastSeenBy(Myself),0,CLERIC_SHIELD_OF_THE_ARCHONS)
	!CheckStat(LastSeenBy(Myself),8,WIZARD_SPELL_IMMUNITY)
    !HasItemEquiped("CLCK26",LastSeenBy(Myself)) // Cloak of Mirroring
    !CheckStatLT(LastSeenBy(Myself),6,SAVEVSSPELL)
    !CheckStatGT(LastSeenBy(Myself),25,RESISTMAGIC)
    !CheckStatGT(LastSeenBy(Myself),0,SCRIPTINGSTATE2)
    !HasItemEquipedReal("SW1H71",LastSeenBy(Myself)) // Hindo's Doom +4
THEN
	RESPONSE #100
		SetGlobalTimer("CAST","LOCALS",6)
		Spell(LastSeenBy(Myself),WIZARD_DISINTEGRATE)
END
