IF
	Dead("CBBDAW01")
THEN
	RESPONSE #100
		DestroySelf()
END

IF
	!GlobalTimerNotExpired("DRAGONFEAR","AR3521")
THEN
	RESPONSE #100
		SetGlobalTimer("DRAGONFEAR","AR3521",100)
		PlaySound("ABAZIG02")
		ReallyForceSpell(NearestEnemyOf("CBBDAW01"),DRAGON_FEAR)
		ReallyForceSpell(NearestEnemyOf("CBBDAW01"),DRAGON_LOWER_ELECTRICAL)
		ForceSpell(LastSeenBy("CBBDAW01"),DRAGON_WING_BUFFET)
END

IF
	!GlobalTimerNotExpired("Prepare2","AR3521")
	!CheckStatGT("CBBDAW01",0,STONESKINS)
THEN
	RESPONSE #100
		SetGlobalTimer("Prepare2","AR3521",1000)
		DisplayString("CBBDAW01",73139) // Contingency - Fired
		ApplySpell("CBBDAW01",DRAGON_STONE_SKIN)
		ReallyForceSpell("CBBDAW01",BEHOLDER_SPELL_TURNING)
		ReallyForceSpell(LastSeenBy("CBBDAW01"),WIZARD_DISPEL_MAGIC)
END

IF
	!GlobalTimerNotExpired("SpellTrigger1","AR3521")
THEN
	RESPONSE #100
		SetGlobalTimer("SpellTrigger1","AR3521",1000)
		DisplayString("CBBDAW01",39968) // Spell Trigger - Fired
		ReallyForceSpell("CBBDAW01",WIZARD_IMPROVED_HASTE)
		ReallyForceSpell("CBBDAW01",HEAL_NO_VISUAL)
		ReallyForceSpellRES("dgright","CBBDAW01") // Righteous Magic
		ReallyForceSpellRES("dgfaith","CBBDAW01") // Armor of Faith
END

IF
	Range(LastSeenBy("CBBDAW01"),30)
	CheckStatLT(LastSeenBy("CBBDAW01"),100,RESISTELECTRICITY)
	!GlobalTimerNotExpired("BLUEDRAGONBREATH","AR3521")
THEN
	RESPONSE #100
		SetGlobalTimer("BLUEDRAGONBREATH","AR3521",24)
		ReallyForceSpell(LastSeenBy("CBBDAW01"),BLUE_DRAGON_BREATH)
//		ReallyForceSpell(LastSeenBy("CBBDAW01"),0)
END

IF
	!GlobalTimerNotExpired("WINGBUFFET","AR3521")
THEN
	RESPONSE #100
		SetGlobalTimer("WINGBUFFET","AR3521",38)
		ForceSpell(NearestEnemyOf("CBBDAW01"),DRAGON_WING_BUFFET)
//		Wait(1)
//		ApplySpell("CBBDAW01",0)
END

IF
	OR(5)
		SpellCast([GOODCUTOFF],WIZARD_CLOUDKILL)
		SpellCast([GOODCUTOFF],WIZARD_INCENDIARY_CLOUD)
		SpellCast([GOODCUTOFF],WIZARD_DEATH_FOG)
		SpellCast([GOODCUTOFF],WIZARD_FOG_CLOUD)
		SpellCast([GOODCUTOFF],WIZARD_STINKING_CLOUD)
	!GlobalTimerNotExpired("WINGBUFFET","AR3521")
THEN
	RESPONSE #100
		SetGlobalTimer("WINGBUFFET","AR3521",38)
//		ApplySpell(Myself,0)
		ForceSpell(NearestEnemyOf(Myself),DRAGON_WING_BUFFET)
END

IF
	!CheckStatGT("CBBDAW01",0,STONESKINS)
	!GlobalTimerNotExpired("DragonStoneSkin","AR3521")
THEN
	RESPONSE #100
		SetGlobalTimer("DragonStoneSkin","AR3521",60)
		ForceSpell("CBBDAW01",DRAGON_STONE_SKIN)
END

IF
	OR(6)
		Class(LastSeenBy("CBBDAW01"),RANGER_ALL)
		Class(LastSeenBy("CBBDAW01"),THIEF_ALL)
		Class(LastSeenBy("CBBDAW01"),DRUID_ALL)
		Class(LastSeenBy("CBBDAW01"),PALADIN_ALL)
		Class(LastSeenBy("CBBDAW01"),BARD_ALL)
		Class(LastSeenBy("CBBDAW01"),SORCERER)
	!StateCheck(LastSeenBy("CBBDAW01"),STATE_SILENCED)
	!HasBounceEffects(LastSeenBy("CBBDAW01"))
	!GlobalTimerNotExpired("dbSilence","AR3521")
THEN
	RESPONSE #100
		SetGlobalTimer("dbSilence","AR3521",15)
		ForceSpell(LastSeenBy("CBBDAW01"),DRAGON_SILENCE)
END

IF
	CheckStatLT("CBBDAW01",50,RESISTMAGIC)
	!GlobalTimerNotExpired("RegainMagic","AR3521")
THEN
	RESPONSE #100
		SetGlobalTimer("RegainMagic","AR3521",15)
		ApplySpellRES("SPCL904","CBBDAW01") // Resist Magic
END

IF
	!CheckStatGT(LastSeenBy("CBBDAW01"),50,RESISTMAGIC)
	!GlobalTimerNotExpired("Barrage","AR3521")
THEN
	RESPONSE #100
		SetGlobalTimer("Barrage","AR3521",6)
		ForceSpell(LastSeenBy("CBBDAW01"),WIZARD_CHAOS)
	RESPONSE #100
		SetGlobalTimer("Barrage","AR3521",12)
		ForceSpell(LastSeenBy("CBBDAW01"),WIZARD_MAZE)
	RESPONSE #100
		SetGlobalTimer("Barrage","AR3521",6)
		ForceSpell(LastSeenBy("CBBDAW01"),WIZARD_FINGER_OF_DEATH)
	RESPONSE #100
		SetGlobalTimer("Barrage","AR3521",6)
		ForceSpell(LastSeenBy("CBBDAW01"),WIZARD_SLOW)
	RESPONSE #100
		SetGlobalTimer("Barrage","AR3521",12)
		ForceSpell(LastSeenBy("CBBDAW01"),WIZARD_POWER_WORD_BLIND)
	RESPONSE #100
		SetGlobalTimer("Barrage","AR3521",12)
		ForceSpell(LastSeenBy("CBBDAW01"),WIZARD_PRISMATIC_SPRAY)
	RESPONSE #100
		SetGlobalTimer("Barrage","AR3521",12)
		ForceSpell(LastSeenBy("CBBDAW01"),WIZARD_FEEBLEMIND)
END

IF
	!HasBounceEffects("CBBDAW01")
	!StateCheck(LastSeenBy("CBBDAW01"),STATE_SILENCED)
	!GlobalTimerNotExpired("SpellTurn","AR3521")
THEN
	RESPONSE #100
		SetGlobalTimer("SpellTurn","AR3521",15)
		ForceSpell("CBBDAW01",BEHOLDER_SPELL_TURNING)
END

IF
	Global("Prepare2","AR3521",0)
THEN
	RESPONSE #100
		DisplayString("CBBDAW01",73139) // Contingency - Fired
		ReallyForceSpell(LastSeenBy("CBBDAW01"),WIZARD_ABI_DALZIMS_HORRID_WILTING)
		ReallyForceSpell("CBBDAW01",WIZARD_IMPROVED_MANTLE)
		ReallyForceSpell(LastSeenBy("CBBDAW01"),WIZARD_SYMBOL_FEAR)
		SetGlobal("Prepare2","AR3521",1)
END

IF
	HPPercentLT("CBBDAW01",50)
	GlobalLT("CbHealPuff","AR3521",2)
THEN
	RESPONSE #100
		IncrementGlobal("CbHealPuff","AR3521",1)
		SpellNoDec("CBBDAW01",CLERIC_HEAL)
END

IF
	Global("CbSpyDidThis1","AR3521",0)
THEN
	RESPONSE #100
		SetGlobal("CbSpyDidThis1","AR3521",1)
		Spell("CBBDAW01",WIZARD_TRUE_SIGHT)
		ForceSpell(LastSeenBy("CBBDAW01"),WIZARD_MELF_ACID_ARROW)
END

IF
	OR(6)
		Gender(LastSeenBy("CBBDAW01"),ILLUSIONARY)
		SpellCast([PC],WIZARD_PROJECT_IMAGE)
		SpellCast([PC],WIZARD_SIMULACRUM)
		SpellCast([PC],WIZARD_MISLEAD)
		StateCheck(LastSeenBy("CBBDAW01"),STATE_BLUR)
		StateCheck(LastSeenBy("CBBDAW01"),STATE_MIRRORIMAGE)
	!GlobalTimerNotExpired("TrueSight","AR3521")
THEN
	RESPONSE #100
		SetGlobalTimer("TrueSight","AR3521",30)
		ForceSpell("CBBDAW01",WIZARD_TRUE_SIGHT)
END

IF
	!GlobalTimerNotExpired("dbDispel","AR3521")
	!StateCheck(LastSeenBy("CBBDAW01"),STATE_SILENCED)
	!StateCheck(LastSeenBy("CBBDAW01"),STATE_STUNNED)
	!StateCheck(LastSeenBy("CBBDAW01"),STATE_SLEEPING)
	OR(3)//(5)
		StateCheck(LastSeenBy("CBBDAW01"),STATE_HASTED)
		StateCheck(LastSeenBy("CBBDAW01"),STATE_BLESS)
		StateCheck(LastSeenBy("CBBDAW01"),STATE_DRAWUPONHOLYMIGHT)
//		CheckStatGT(LastSeenBy("CBBDAW01"),0,0)
//		CheckStatGT(LastSeenBy("CBBDAW01"),0,0)
THEN
	RESPONSE #100
		SetGlobalTimer("dbDispel","AR3521",30)
		ForceSpell(LastSeenBy("CBBDAW01"),WIZARD_DISPEL_MAGIC)
END

IF
	Global("CbSpyDidThis2","AR3521",0)
THEN
	RESPONSE #100
		SetGlobal("CbSpyDidThis2","AR3521",1)
		Spell("CBBDAW01",WIZARD_TIME_STOP)
		Continue()
END

IF
	OR(3)
		Class(LastSeenBy("CBBDAW01"),PALADIN_ALL)
		Class(LastSeenBy("CBBDAW01"),BARD_ALL)
		Class(LastSeenBy("CBBDAW01"),SORCERER)
	OR(2)
		HasBounceEffects(LastSeenBy("CBBDAW01"))
		HasImmunityEffects(LastSeenBy("CBBDAW01"))
	!GlobalTimerNotExpired("dbSecret","AR3521")
THEN
	RESPONSE #100
		SetGlobalTimer("dbSecret","AR3521",30)
		ForceSpell(LastSeenBy("CBBDAW01"),WIZARD_SECRET_WORD)
	RESPONSE #50
		SetGlobalTimer("dbSecret","AR3521",30)
		ForceSpell(LastSeenBy("CBBDAW01"),WIZARD_BREACH)
	RESPONSE #25
		SetGlobalTimer("dbSecret","AR3521",30)
		ForceSpell(LastSeenBy("CBBDAW01"),WIZARD_PIERCE_MAGIC)
END

IF
	Global("CbSpyDidThis3","AR3521",0)
THEN
	RESPONSE #100
		SetGlobal("CbSpyDidThis3","AR3521",1)
		Spell(LastSeenBy("CBBDAW01"),WIZARD_NPC_SYMBOL_STUN)
END

IF
	Global("Prepare","AR3521",0)
	!CheckStatGT("CBBDAW01",0,STONESKINS)
THEN
	RESPONSE #100
		ApplySpell("CBBDAW01",WIZARD_STONE_SKIN)
		ApplySpellRES("jwglobe","CBBDAW01") // Globe of Invulnerability
		SetGlobal("Prepare","AR3521",1)
END

IF
	Global("CbSpyDidThis4","AR3521",0)
THEN
	RESPONSE #100
		SetGlobal("CbSpyDidThis4","AR3521",1)
		Spell(LastSeenBy("CBBDAW01"),WIZARD_NPC_SYMBOL_FEAR)
END

IF
	Global("SpellTrigger","AR3521",0)
	!Dead("CBBDAW01")
THEN
	RESPONSE #100
		DisplayString("CBBDAW01",39968) // Spell Trigger - Fired
		ReallyForceSpell("CBBDAW01",WIZARD_IMPROVED_HASTE)
		ReallyForceSpell("CBBDAW01",WIZARD_MISLEAD)
		ReallyForceSpell(LastSeenBy("CBBDAW01"),WIZARD_DEATH_SPELL)
		SetGlobal("SpellTrigger","AR3521",1)
END

IF
	Global("CbSpyDidThis5","AR3521",0)
THEN
	RESPONSE #100
		SetGlobal("CbSpyDidThis5","AR3521",1)
		Spell(LastSeenBy("CBBDAW01"),WIZARD_WAIL_OF_THE_BANSHEE)
END

IF
	StateCheck("CBBDAW01",STATE_SILENCED)
THEN
	RESPONSE #100
		Spell("CBBDAW01",WIZARD_VOCALIZE)
END

IF
	Global("CbSpyDidThis6","AR3521",0)
THEN
	RESPONSE #100
		SetGlobal("CbSpyDidThis6","AR3521",1)
		Spell(LastSeenBy("CBBDAW01"),WIZARD_SUN_FIRE)
END

IF
	Global("Prepare","AR3521",1)
THEN
	RESPONSE #100
		Spell("CBBDAW01",WIZARD_SPELL_TURNING)
		SetGlobal("Prepare","AR3521",2)
END

IF
	Global("CbSpyDidThis7","AR3521",0)
THEN
	RESPONSE #100
		SetGlobal("CbSpyDidThis7","AR3521",1)
		Spell(LastSeenBy("CBBDAW01"),WIZARD_ABI_DALZIMS_HORRID_WILTING)
END

IF
	!HasBounceEffects("CBBDAW01")
	!HasImmunityEffects("CBBDAW01")
THEN
	RESPONSE #100
		Spell("CBBDAW01",WIZARD_SPELL_TURNING)
END

IF
	Global("CbSpyDidThis8","AR3521",0)
THEN
	RESPONSE #100
		SetGlobal("CbSpyDidThis8","AR3521",1)
		Spell(LastSeenBy("CBBDAW01"),WIZARD_FINGER_OF_DEATH)
END

IF
	Global("Prepare2","AR3521",1)
	HPPercentLT("CBBDAW01",100)
THEN
	RESPONSE #100
		DisplayString("CBBDAW01",40252) // Contingency - Protection from Magical Weapons
		ApplySpell("CBBDAW01",WIZARD_PROTECTION_FROM_MAGIC_WEAPONS)
		SetGlobal("Prepare2","AR3521",2)
END

IF
	Global("CbSpyDidThis9","AR3521",0)
THEN
	RESPONSE #100
		SetGlobal("CbSpyDidThis9","AR3521",1)
		Spell(LastSeenBy("CBBDAW01"),WIZARD_PRISMATIC_SPRAY)
END

IF
	Global("Cb_DSACK_Maze","AR3521",0)
THEN
	RESPONSE #100
		SetGlobal("Cb_DSACK_Maze","AR3521",1)
		Spell(LastSeenBy("CBBDAW01"),WIZARD_MAZE)
END

IF
	Global("CbSpyDidThisA","AR3521",0)
THEN
	RESPONSE #100
		SetGlobal("CbSpyDidThisA","AR3521",1)
		Spell("CBBDAW01",WIZARD_SUMMON_EFREET)
END

IF
	!HasImmunityEffects("CBBDAW01")
THEN
	RESPONSE #100
		ReallyForceSpell("CBBDAW01",WIZARD_STONE_SKIN)
		ReallyForceSpell("CBBDAW01",CLERIC_CURE_CRITICAL_WOUNDS)
		SpellNoDec("CBBDAW01",WIZARD_IMPROVED_MANTLE)
END

IF
	Global("CbSpyDidThisB","AR3521",0)
THEN
	RESPONSE #100
		SetGlobal("CbSpyDidThisB","AR3521",1)
		Spell(LastSeenBy("CBBDAW01"),WIZARD_FLESH_TO_STONE)
END

IF
	Global("CbSpyDidThisC","AR3521",0)
THEN
	RESPONSE #100
		SetGlobal("CbSpyDidThisC","AR3521",1)
		Spell(LastSeenBy("CBBDAW01"),WIZARD_DISINTEGRATE)
END

IF
	Global("CbSpyDidThisD","AR3521",0)
THEN
	RESPONSE #100
		SetGlobal("CbSpyDidThisD","AR3521",1)
		Spell(LastSeenBy("CBBDAW01"),WIZARD_DOMINATION)
END

IF
	!See("CBBDAW01")
	InActiveArea("CBBDAW01")
THEN
	RESPONSE #100
		MoveToObject("CBBDAW01")
END
