IF
	Global("CbTestCut","GLOBAL",1)
THEN
	RESPONSE #100
		SetGlobal("CbTestCut","GLOBAL",2)
		ClearAllActions()
		StartCutSceneMode()
		StartCutScene("CBEM25LV")
END

IF
	AttackedBy([ANYONE],DEFAULT)
	Global("GoodElfKill","GLOBAL",0)
THEN
	RESPONSE #100
		SetGlobal("GoodElfKill","GLOBAL",2)
END

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

IF
	See(NearestEnemyOf(Myself))
	TookDamage()
	Global("Contingency","LOCALS",0)
THEN
	RESPONSE #100
		DisplayString(Myself,40252) // Contingency - Protection from Magical Weapons
		DisplayString(Myself,325) // Contingency - Spell Turning
		DisplayString(Myself,326) // Contingency - Mislead
		ApplySpell(Myself,WIZARD_ABSOLUTE_IMMUNITY)
		ApplySpell(Myself,WIZARD_SPELL_TURNING)
		ApplySpell(Myself,WIZARD_MISLEAD)
		ApplySpell(Myself,WIZARD_SPELL_SHIELD)
		SetGlobal("Contingency","LOCALS",1)
END

IF
	See(NearestEnemyOf(Myself))
	TookDamage()
	Global("Contingency","LOCALS",1)
THEN
	RESPONSE #100
		DisplayString(Myself,40252) // Contingency - Protection from Magical Weapons
		ApplySpell(Myself,WIZARD_STONE_SKIN)
		SetGlobal("Contingency","LOCALS",2)
END

IF
	See(NearestEnemyOf(Myself))
	Global("SpellTrigger","LOCALS",0)
THEN
	RESPONSE #100
		DisplayString(Myself,39968) // Spell Trigger - Fired
		DisplayString(Myself,329) // Spell Trigger - Monster Summoning III
		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("SpellTrigger","LOCALS",1)
END

IF
	See(NearestEnemyOf(Myself))
	Global("TimeStop","LOCALS",0)
THEN
	RESPONSE #100
		SetGlobal("TimeStop","LOCALS",1)
		Spell(Myself,WIZARD_TIME_STOP)
END

IF
	See(NearestEnemyOf(Myself))
	NumInPartyGT(2)
	Global("TimeStop","LOCALS",1)
THEN
	RESPONSE #100
		SetGlobal("TimeStop","LOCALS",2)
		Spell(Player3,WIZARD_WAIL_OF_THE_BANSHEE)
		Spell(Player3,WIZARD_ABI_DALZIMS_HORRID_WILTING)
		Spell(Player3,WIZARD_MAZE)
		ForceSpell(Myself,WIZARD_ABSOLUTE_IMMUNITY)
END

IF
	See(NearestEnemyOf(Myself))
	Global("TimeStop","LOCALS",1)
THEN
	RESPONSE #100
		SetGlobal("TimeStop","LOCALS",2)
		Spell(Player1,WIZARD_WAIL_OF_THE_BANSHEE)
		Spell(Player1,WIZARD_ABI_DALZIMS_HORRID_WILTING)
		Spell(Player1,WIZARD_MAZE)
		ForceSpell(Myself,WIZARD_ABSOLUTE_IMMUNITY)
END

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

IF
	See(NearestEnemyOf(Myself))
	StateCheck(Myself,STATE_SILENCED)
	HaveSpell(WIZARD_VOCALIZE)
THEN
	RESPONSE #100
		Spell(Myself,WIZARD_VOCALIZE)
END

IF
	See([GOODCUTOFF.0.0.0.0.SUMMONED])
	Allegiance(Myself,ENEMY)
	HaveSpell(WIZARD_DEATH_SPELL)
	Global("CastDeath","LOCALS",0)
THEN
	RESPONSE #100
		Spell(LastSeenBy(Myself),WIZARD_DEATH_SPELL)
		SetGlobal("CastDeath","LOCALS",1)
END

IF
	See([PC.0.0.MAGE])
	Allegiance(Myself,ENEMY)
	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
	See(Player6)
	Global("SpellTrigger","LOCALS",1)
	HaveSpell(WIZARD_PRISMATIC_SPRAY)
	Allegiance(Myself,ENEMY)
THEN
	RESPONSE #100
		SetGlobal("SpellTrigger","LOCALS",2)
		Spell(Player6,WIZARD_PRISMATIC_SPRAY)
END

IF
	See(Player1)
	Global("SpellTrigger","LOCALS",1)
	HaveSpell(WIZARD_PRISMATIC_SPRAY)
	Allegiance(Myself,ENEMY)
THEN
	RESPONSE #100
		SetGlobal("SpellTrigger","LOCALS",2)
		Spell(Player1,WIZARD_PRISMATIC_SPRAY)
END

IF
	See(NearestEnemyOf(Myself))
	Global("TimeStop","LOCALS",2)
THEN
	RESPONSE #100
		SetGlobal("TimeStop","LOCALS",3)
		Spell(Myself,WIZARD_TIME_STOP)
END

IF
	See(NearestEnemyOf(Myself))
	Global("TimeStop","LOCALS",3)
THEN
	RESPONSE #100
		SetGlobal("TimeStop","LOCALS",4)
		Spell(NearestEnemyOf(Myself),WIZARD_MAZE)
		Spell(SecondNearestEnemyOf(Myself),WIZARD_MAZE)
END

IF
	See(NearestEnemyOf(Myself))
	Global("Absolute","LOCALS",0)
THEN
	RESPONSE #100
		SetGlobal("Absolute","LOCALS",1)
		ForceSpell(Myself,WIZARD_ABSOLUTE_IMMUNITY)
END

IF
	See(NearestEnemyOf(Myself))
	HaveSpell(WIZARD_ABI_DALZIMS_HORRID_WILTING)
	Global("ChainLightning","LOCALS",0)
THEN
	RESPONSE #100
		SetGlobal("ChainLightning","LOCALS",1)
		Spell(NearestEnemyOf(Myself),WIZARD_ABI_DALZIMS_HORRID_WILTING)
END

IF
	See(NearestEnemyOf(Myself))
	HPLT(LastSeenBy(Myself),60)
	HaveSpell(WIZARD_POWER_WORD_KILL)
THEN
	RESPONSE #100
		Spell(LastSeenBy(Myself),WIZARD_POWER_WORD_KILL)
END

IF
	See(SecondNearestEnemyOf(Myself))
	HPLT(LastSeenBy(Myself),60)
	HaveSpell(WIZARD_POWER_WORD_KILL)
THEN
	RESPONSE #100
		Spell(LastSeenBy(Myself),WIZARD_POWER_WORD_KILL)
END

IF
	See(ThirdNearestEnemyOf(Myself))
	HPLT(LastSeenBy(Myself),60)
	HaveSpell(WIZARD_POWER_WORD_KILL)
THEN
	RESPONSE #100
		Spell(LastSeenBy(Myself),WIZARD_POWER_WORD_KILL)
END

IF
	See(FourthNearestEnemyOf(Myself))
	HPLT(LastSeenBy(Myself),60)
	HaveSpell(WIZARD_POWER_WORD_KILL)
THEN
	RESPONSE #100
		Spell(LastSeenBy(Myself),WIZARD_POWER_WORD_KILL)
END

IF
	See(FifthNearestEnemyOf(Myself))
	HPLT(LastSeenBy(Myself),60)
	HaveSpell(WIZARD_POWER_WORD_KILL)
THEN
	RESPONSE #100
		Spell(LastSeenBy(Myself),WIZARD_POWER_WORD_KILL)
END

IF
	See(SixthNearestEnemyOf(Myself))
	HPLT(LastSeenBy(Myself),60)
	HaveSpell(WIZARD_POWER_WORD_KILL)
THEN
	RESPONSE #100
		Spell(LastSeenBy(Myself),WIZARD_POWER_WORD_KILL)
END

IF
	See(SeventhNearestEnemyOf(Myself))
	HPLT(LastSeenBy(Myself),60)
	HaveSpell(WIZARD_POWER_WORD_KILL)
THEN
	RESPONSE #100
		Spell(LastSeenBy(Myself),WIZARD_POWER_WORD_KILL)
END

IF
	See(EighthNearestEnemyOf(Myself))
	HPLT(LastSeenBy(Myself),60)
	HaveSpell(WIZARD_POWER_WORD_KILL)
THEN
	RESPONSE #100
		Spell(LastSeenBy(Myself),WIZARD_POWER_WORD_KILL)
END

IF
	See(NinthNearestEnemyOf(Myself))
	HPLT(LastSeenBy(Myself),60)
	HaveSpell(WIZARD_POWER_WORD_KILL)
THEN
	RESPONSE #100
		Spell(LastSeenBy(Myself),WIZARD_POWER_WORD_KILL)
END

IF
	See(TenthNearestEnemyOf(Myself))
	HPLT(LastSeenBy(Myself),60)
	HaveSpell(WIZARD_POWER_WORD_KILL)
THEN
	RESPONSE #100
		Spell(LastSeenBy(Myself),WIZARD_POWER_WORD_KILL)
END

IF
	See(NearestEnemyOf(Myself))
	HaveSpell(WIZARD_POWER_WORD_KILL)
THEN
	RESPONSE #100
		Spell(LastSeenBy(Myself),WIZARD_POWER_WORD_KILL)
END

IF
	See(NearestEnemyOf(Myself))
	HaveSpell(WIZARD_SUN_FIRE)
THEN
	RESPONSE #100
		Spell(LastSeenBy(Myself),WIZARD_SUN_FIRE)
END

IF
	See(NearestEnemyOf(Myself))
	HaveSpell(WIZARD_POWER_WORD_STUN)
THEN
	RESPONSE #100
		Spell(LastSeenBy(Myself),WIZARD_POWER_WORD_STUN)
END

IF
	See(NearestEnemyOf(Myself))
	HaveSpell(WIZARD_MAZE)
THEN
	RESPONSE #100
		Spell(NearestEnemyOf(Myself),WIZARD_MAZE)
END

IF
	See(NearestEnemyOf(Myself))
	HaveSpell(WIZARD_CONE_OF_COLD)
THEN
	RESPONSE #100
		Spell(LastSeenBy(Myself),WIZARD_CONE_OF_COLD)
END

IF
	See(NearestEnemyOf(Myself))
	HaveSpell(WIZARD_FLAME_ARROW)
THEN
	RESPONSE #100
		Spell(LastSeenBy(Myself),WIZARD_FLAME_ARROW)
END

IF
	See(NearestEnemyOf(Myself))
	HaveSpell(WIZARD_MELF_ACID_ARROW)
THEN
	RESPONSE #100
		Spell(LastSeenBy(Myself),WIZARD_MELF_ACID_ARROW)
END

IF
	See(NearestEnemyOf(Myself))
	HaveSpell(WIZARD_STONE_SKIN)
	Global("Prep","LOCALS",0)
THEN
	RESPONSE #100
		ApplySpell(Myself,WIZARD_STONE_SKIN)
		Spell(Myself,WIZARD_MIRROR_IMAGE)
		SetGlobal("Prep","LOCALS",1)
END

IF
	See(NearestEnemyOf(Myself))
	HaveSpell(WIZARD_CHAOS)
	HaveSpell(WIZARD_FIRE_SHIELD_RED)
THEN
	RESPONSE #100
		Spell(NearestEnemyOf(Myself),WIZARD_CHAOS)
		Spell(Myself,WIZARD_FIRE_SHIELD_RED)
END

IF
	See(NearestEnemyOf(Myself))
	HaveSpell(WIZARD_TELEPORT_FIELD)
THEN
	RESPONSE #100
		Spell(Myself,WIZARD_TELEPORT_FIELD)
END

IF
	See(NearestEnemyOf(Myself))
	HaveSpell(WIZARD_CONFUSION)
THEN
	RESPONSE #100
		Spell(NearestEnemyOf(Myself),WIZARD_CONFUSION)
END

IF
	See(NearestEnemyOf(Myself))
	HaveSpell(WIZARD_LIGHTNING_BOLT)
THEN
	RESPONSE #100
		Spell(NearestEnemyOf(Myself),WIZARD_LIGHTNING_BOLT)
END

IF
	See(NearestEnemyOf(Myself))
	!StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
	HaveSpell(WIZARD_HOLD_PERSON)
THEN
	RESPONSE #100
		Spell(NearestEnemyOf(Myself),WIZARD_HOLD_PERSON)
END

IF
	See(NearestEnemyOf(Myself))
	HaveSpell(WIZARD_WEB)
THEN
	RESPONSE #100
		Spell(NearestEnemyOf(Myself),WIZARD_WEB)
END

IF
	See(NearestEnemyOf(Myself))
	HaveSpell(WIZARD_STONE_SKIN)
	CheckStatLT(Myself,1,STONESKINS)
THEN
	RESPONSE #100
		Spell(Myself,WIZARD_STONE_SKIN)
END

IF
	See(NearestEnemyOf(Myself))
	StateCheck(Myself,STATE_SILENCED)
	HaveSpell(WIZARD_VOCALIZE)
THEN
	RESPONSE #100
		Spell(Myself,WIZARD_VOCALIZE)
END

IF
	See(NearestEnemyOf(Myself))
	RandomNum(3,1)
THEN
	RESPONSE #100
		Spell(NearestEnemyOf(Myself),WIZARD_CHROMATIC_ORB)
END

IF
	See(NearestEnemyOf(Myself))
	RandomNum(3,2)
THEN
	RESPONSE #100
		ForceSpell(LastSeenBy(Myself),WIZARD_MAGIC_MISSILE)
END

IF
	See(NearestEnemyOf(Myself))
	RandomNum(3,3)
THEN
	RESPONSE #100
		ForceSpell(LastSeenBy(Myself),WIZARD_BURNING_HANDS)
END


