IF
    OR(2)
		!GlobalTimerNotExpired("CAST","LOCALS")
        CheckStatGT(Myself,0,WIZARD_IMPROVED_ALACRITY)
    HaveSpell(WIZARD_FLESH_TO_STONE)
    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,WIZARD_PROTECTION_FROM_PETRIFICATION)
		StateCheck(LastSeenBy(Myself),STATE_STONE_DEATH)
    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,WIZARD_PROTECTION_FROM_PETRIFICATION)
		StateCheck(LastSeenBy(Myself),STATE_STONE_DEATH)
    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,WIZARD_PROTECTION_FROM_PETRIFICATION)
		StateCheck(LastSeenBy(Myself),STATE_STONE_DEATH)
    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,WIZARD_PROTECTION_FROM_PETRIFICATION)
		StateCheck(LastSeenBy(Myself),STATE_STONE_DEATH)
    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,WIZARD_PROTECTION_FROM_PETRIFICATION)
		StateCheck(LastSeenBy(Myself),STATE_STONE_DEATH)
    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,WIZARD_PROTECTION_FROM_PETRIFICATION)
		StateCheck(LastSeenBy(Myself),STATE_STONE_DEATH)
    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,WIZARD_PROTECTION_FROM_PETRIFICATION)
		StateCheck(LastSeenBy(Myself),STATE_STONE_DEATH)
    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,WIZARD_PROTECTION_FROM_PETRIFICATION)
		StateCheck(LastSeenBy(Myself),STATE_STONE_DEATH)
    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,WIZARD_PROTECTION_FROM_PETRIFICATION)
		StateCheck(LastSeenBy(Myself),STATE_STONE_DEATH)
    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,WIZARD_PROTECTION_FROM_PETRIFICATION)
		StateCheck(LastSeenBy(Myself),STATE_STONE_DEATH)
	See(NearestEnemyOf(Myself))
	False()
THEN
	RESPONSE #100
		Continue()
END

IF
    OR(2)
		!GlobalTimerNotExpired("CAST","LOCALS")
        CheckStatGT(Myself,0,WIZARD_IMPROVED_ALACRITY)
    HaveSpell(WIZARD_FLESH_TO_STONE)
    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,WIZARD_PROTECTION_FROM_PETRIFICATION)
	!StateCheck(LastSeenBy(Myself),STATE_STONE_DEATH)
THEN
	RESPONSE #100
		SetGlobalTimer("CAST","LOCALS",6)
		Spell(LastSeenBy(Myself),WIZARD_FLESH_TO_STONE)
END
