IF
    OR(2)
		!GlobalTimerNotExpired("CAST","LOCALS")
        CheckStatGT(Myself,0,WIZARD_IMPROVED_ALACRITY)
    HaveSpell(WIZARD_HORROR)
	See(NearestEnemyOf(Myself))
	OR(21)
		HasItemEquiped("clck26",LastSeenBy(Myself))
	    CheckStatGT(LastSeenBy(Myself),0,WIZARD_SPELL_DEFLECTION)
	    CheckStatGT(LastSeenBy(Myself),0,WIZARD_SPELL_TURNING)
	    CheckStatGT(LastSeenBy(Myself),0,WIZARD_SPELL_TRAP)
	    CheckStatGT(LastSeenBy(Myself),0,CLERIC_SHIELD_OF_THE_ARCHONS)
	    CheckStatGT(LastSeenBy(Myself),0,MINORGLOBE)
	    CheckStatGT(LastSeenBy(Myself),0,SHIELDGLOBE)
		CheckStat(LastSeenBy(Myself),7,WIZARD_SPELL_IMMUNITY)
		General(LastSeenBy(Myself),UNDEAD)
	    CheckStatLT(LastSeenBy(Myself),6,SAVEVSSPELL)
	    StateCheck(LastSeenBy(Myself),STATE_BERSERK)
	    CheckStat(LastSeenBy(Myself),1,SCRIPTINGSTATE4)
	    CheckStat(LastSeenBy(Myself),3,SCRIPTINGSTATE4)
	    CheckStat(LastSeenBy(Myself),0,WIZARD_RESIST_FEAR)
	    Kit(LastSeenBy(Myself),CAVALIER)
	    HasItemEquiped("CLCK30",LastSeenBy(Myself)) // Cloak of Bravery
	    HasItemEquiped("MISCBC",LastSeenBy(Myself)) // Blackrazor
	    HasItemEquiped("SW1H32",LastSeenBy(Myself)) // Dragonslayer
	    CheckStatGT(LastSeenBy(Myself),75,RESISTMAGIC)
	    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
	    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
	See(SecondNearestEnemyOf(Myself))
	OR(21)
		HasItemEquiped("clck26",LastSeenBy(Myself))
	    CheckStatGT(LastSeenBy(Myself),0,WIZARD_SPELL_DEFLECTION)
	    CheckStatGT(LastSeenBy(Myself),0,WIZARD_SPELL_TURNING)
	    CheckStatGT(LastSeenBy(Myself),0,WIZARD_SPELL_TRAP)
	    CheckStatGT(LastSeenBy(Myself),0,CLERIC_SHIELD_OF_THE_ARCHONS)
	    CheckStatGT(LastSeenBy(Myself),0,MINORGLOBE)
	    CheckStatGT(LastSeenBy(Myself),0,SHIELDGLOBE)
		CheckStat(LastSeenBy(Myself),7,WIZARD_SPELL_IMMUNITY)
		General(LastSeenBy(Myself),UNDEAD)
	    CheckStatLT(LastSeenBy(Myself),6,SAVEVSSPELL)
	    StateCheck(LastSeenBy(Myself),STATE_BERSERK)
	    CheckStat(LastSeenBy(Myself),1,SCRIPTINGSTATE4)
	    CheckStat(LastSeenBy(Myself),3,SCRIPTINGSTATE4)
	    CheckStat(LastSeenBy(Myself),0,WIZARD_RESIST_FEAR)
	    Kit(LastSeenBy(Myself),CAVALIER)
	    HasItemEquiped("CLCK30",LastSeenBy(Myself)) // Cloak of Bravery
	    HasItemEquiped("MISCBC",LastSeenBy(Myself)) // Blackrazor
	    HasItemEquiped("SW1H32",LastSeenBy(Myself)) // Dragonslayer
	    CheckStatGT(LastSeenBy(Myself),75,RESISTMAGIC)
	    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
	    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
	See(ThirdNearestEnemyOf(Myself))
	OR(21)
		HasItemEquiped("clck26",LastSeenBy(Myself))
	    CheckStatGT(LastSeenBy(Myself),0,WIZARD_SPELL_DEFLECTION)
	    CheckStatGT(LastSeenBy(Myself),0,WIZARD_SPELL_TURNING)
	    CheckStatGT(LastSeenBy(Myself),0,WIZARD_SPELL_TRAP)
	    CheckStatGT(LastSeenBy(Myself),0,CLERIC_SHIELD_OF_THE_ARCHONS)
	    CheckStatGT(LastSeenBy(Myself),0,MINORGLOBE)
	    CheckStatGT(LastSeenBy(Myself),0,SHIELDGLOBE)
		CheckStat(LastSeenBy(Myself),7,WIZARD_SPELL_IMMUNITY)
		General(LastSeenBy(Myself),UNDEAD)
	    CheckStatLT(LastSeenBy(Myself),6,SAVEVSSPELL)
	    StateCheck(LastSeenBy(Myself),STATE_BERSERK)
	    CheckStat(LastSeenBy(Myself),1,SCRIPTINGSTATE4)
	    CheckStat(LastSeenBy(Myself),3,SCRIPTINGSTATE4)
	    CheckStat(LastSeenBy(Myself),0,WIZARD_RESIST_FEAR)
	    Kit(LastSeenBy(Myself),CAVALIER)
	    HasItemEquiped("CLCK30",LastSeenBy(Myself)) // Cloak of Bravery
	    HasItemEquiped("MISCBC",LastSeenBy(Myself)) // Blackrazor
	    HasItemEquiped("SW1H32",LastSeenBy(Myself)) // Dragonslayer
	    CheckStatGT(LastSeenBy(Myself),75,RESISTMAGIC)
	    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
	    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
	See(FourthNearestEnemyOf(Myself))
	OR(21)
		HasItemEquiped("clck26",LastSeenBy(Myself))
	    CheckStatGT(LastSeenBy(Myself),0,WIZARD_SPELL_DEFLECTION)
	    CheckStatGT(LastSeenBy(Myself),0,WIZARD_SPELL_TURNING)
	    CheckStatGT(LastSeenBy(Myself),0,WIZARD_SPELL_TRAP)
	    CheckStatGT(LastSeenBy(Myself),0,CLERIC_SHIELD_OF_THE_ARCHONS)
	    CheckStatGT(LastSeenBy(Myself),0,MINORGLOBE)
	    CheckStatGT(LastSeenBy(Myself),0,SHIELDGLOBE)
		CheckStat(LastSeenBy(Myself),7,WIZARD_SPELL_IMMUNITY)
		General(LastSeenBy(Myself),UNDEAD)
	    CheckStatLT(LastSeenBy(Myself),6,SAVEVSSPELL)
	    StateCheck(LastSeenBy(Myself),STATE_BERSERK)
	    CheckStat(LastSeenBy(Myself),1,SCRIPTINGSTATE4)
	    CheckStat(LastSeenBy(Myself),3,SCRIPTINGSTATE4)
	    CheckStat(LastSeenBy(Myself),0,WIZARD_RESIST_FEAR)
	    Kit(LastSeenBy(Myself),CAVALIER)
	    HasItemEquiped("CLCK30",LastSeenBy(Myself)) // Cloak of Bravery
	    HasItemEquiped("MISCBC",LastSeenBy(Myself)) // Blackrazor
	    HasItemEquiped("SW1H32",LastSeenBy(Myself)) // Dragonslayer
	    CheckStatGT(LastSeenBy(Myself),75,RESISTMAGIC)
	    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
	    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
	See(FifthNearestEnemyOf(Myself))
	OR(21)
		HasItemEquiped("clck26",LastSeenBy(Myself))
	    CheckStatGT(LastSeenBy(Myself),0,WIZARD_SPELL_DEFLECTION)
	    CheckStatGT(LastSeenBy(Myself),0,WIZARD_SPELL_TURNING)
	    CheckStatGT(LastSeenBy(Myself),0,WIZARD_SPELL_TRAP)
	    CheckStatGT(LastSeenBy(Myself),0,CLERIC_SHIELD_OF_THE_ARCHONS)
	    CheckStatGT(LastSeenBy(Myself),0,MINORGLOBE)
	    CheckStatGT(LastSeenBy(Myself),0,SHIELDGLOBE)
		CheckStat(LastSeenBy(Myself),7,WIZARD_SPELL_IMMUNITY)
		General(LastSeenBy(Myself),UNDEAD)
	    CheckStatLT(LastSeenBy(Myself),6,SAVEVSSPELL)
	    StateCheck(LastSeenBy(Myself),STATE_BERSERK)
	    CheckStat(LastSeenBy(Myself),1,SCRIPTINGSTATE4)
	    CheckStat(LastSeenBy(Myself),3,SCRIPTINGSTATE4)
	    CheckStat(LastSeenBy(Myself),0,WIZARD_RESIST_FEAR)
	    Kit(LastSeenBy(Myself),CAVALIER)
	    HasItemEquiped("CLCK30",LastSeenBy(Myself)) // Cloak of Bravery
	    HasItemEquiped("MISCBC",LastSeenBy(Myself)) // Blackrazor
	    HasItemEquiped("SW1H32",LastSeenBy(Myself)) // Dragonslayer
	    CheckStatGT(LastSeenBy(Myself),75,RESISTMAGIC)
	    StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
	    CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
	See(SixthNearestEnemyOf(Myself))
	OR(21)
		HasItemEquiped("clck26",LastSeenBy(Myself))
	    CheckStatGT(LastSeenBy(Myself),0,WIZARD_SPELL_DEFLECTION)
	    CheckStatGT(LastSeenBy(Myself),0,WIZARD_SPELL_TURNING)
	    CheckStatGT(LastSeenBy(Myself),0,WIZARD_SPELL_TRAP)
	    CheckStatGT(LastSeenBy(Myself),0,CLERIC_SHIELD_OF_THE_ARCHONS)
	    CheckStatGT(LastSeenBy(Myself),0,MINORGLOBE)
	    CheckStatGT(LastSeenBy(Myself),0,SHIELDGLOBE)
		CheckStat(LastSeenBy(Myself),7,WIZARD_SPELL_IMMUNITY)
		General(LastSeenBy(Myself),UNDEAD)
	    CheckStatLT(LastSeenBy(Myself),6,SAVEVSSPELL)
	    StateCheck(LastSeenBy(Myself),STATE_BERSERK)
	    CheckStat(LastSeenBy(Myself),1,SCRIPTINGSTATE4)
	    CheckStat(LastSeenBy(Myself),3,SCRIPTINGSTATE4)
	    CheckStat(LastSeenBy(Myself),0,WIZARD_RESIST_FEAR)
	    Kit(LastSeenBy(Myself),CAVALIER)
	    HasItemEquiped("CLCK30",LastSeenBy(Myself)) // Cloak of Bravery
	    HasItemEquiped("MISCBC",LastSeenBy(Myself)) // Blackrazor
	    HasItemEquiped("SW1H32",LastSeenBy(Myself)) // Dragonslayer
	    CheckStatGT(LastSeenBy(Myself),75,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,WIZARD_IMPROVED_ALACRITY)
    HaveSpell(WIZARD_HORROR)
	See(LastSeenBy(Myself))
	!HasItemEquiped("clck26",LastSeenBy(Myself))
    !CheckStatGT(LastSeenBy(Myself),0,WIZARD_SPELL_DEFLECTION)
    !CheckStatGT(LastSeenBy(Myself),0,WIZARD_SPELL_TURNING)
    !CheckStatGT(LastSeenBy(Myself),0,WIZARD_SPELL_TRAP)
    !CheckStatGT(LastSeenBy(Myself),0,CLERIC_SHIELD_OF_THE_ARCHONS)
    !CheckStatGT(LastSeenBy(Myself),0,MINORGLOBE)
    !CheckStatGT(LastSeenBy(Myself),0,SHIELDGLOBE)
	!CheckStat(LastSeenBy(Myself),7,WIZARD_SPELL_IMMUNITY)
	!General(LastSeenBy(Myself),UNDEAD)
    !CheckStatLT(LastSeenBy(Myself),6,SAVEVSSPELL)
    !StateCheck(LastSeenBy(Myself),STATE_BERSERK)
    !CheckStat(LastSeenBy(Myself),1,SCRIPTINGSTATE4)
    !CheckStat(LastSeenBy(Myself),3,SCRIPTINGSTATE4)
    !CheckStat(LastSeenBy(Myself),0,WIZARD_RESIST_FEAR)
    !Kit(LastSeenBy(Myself),CAVALIER)
    !HasItemEquiped("CLCK30",LastSeenBy(Myself)) // Cloak of Bravery
    !HasItemEquiped("MISCBC",LastSeenBy(Myself)) // Blackrazor
    !HasItemEquiped("SW1H32",LastSeenBy(Myself)) // Dragonslayer
    !CheckStatGT(LastSeenBy(Myself),75,RESISTMAGIC)
    !StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    !CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
THEN
	RESPONSE #100
		SetGlobalTimer("CAST","LOCALS",6)
		Spell(LastSeenBy(Myself),WIZARD_HORROR)
END
