IF
	See(NearestEnemyOf(Myself))
	Global("RemoveMagic","LOCALS",0)
THEN
	RESPONSE #100
		ForceSpell(Myself,DRAGON_STONE_SKIN) // SPIN694.SPL (Stoneskin)
		ForceSpell(LastSeenBy(Myself),WIZARD_DISPEL_MAGIC) // SPWI302.SPL (Remove Magic)
		SetGlobal("StoneSkin","LOCALS",1)
		SetGlobal("RemoveMagic","LOCALS",1)
END

IF
	!Detect([PC])
	HPLT(Myself,50)
	CombatCounter(0)
THEN
	RESPONSE #100
		SetGlobal("RemoveMagic","LOCALS",0)
		SetGlobal("WingBuffet","LOCALS",0)
		SetGlobal("Haste","LOCALS",0)
		SetGlobal("DRAGONFEAR","LOCALS",0)
		ForceSpell(Myself,CLERIC_HEAL) // SPPR607.SPL (Heal)
END

IF
	See(NearestEnemyOf(Myself))
	Global("DRAGONFEAR","LOCALS",0)
THEN
	RESPONSE #100
		ReallyForceSpell(NearestEnemyOf(Myself),WIZARD_HORROR) // SPWI205.SPL (Horror)
		ReallyForceSpell(NearestEnemyOf(Myself),DRAGON_LOWER_FIRE) // SPIN682.SPL (Lower Fire Resistance)
		SetGlobal("DRAGONFEAR","LOCALS",1)
		SetGlobalTimer("REDDRAGONBREATH","GLOBAL",1)
		ForceSpell(LastSeenBy(Myself),DRAGON_WING_BUFFET) // SPIN695.SPL (Wing Buffet)
END

IF
	GlobalTimerExpired("REDDRAGONBREATH","GLOBAL")
	See(NearestEnemyOf(Myself))
	Range(LastSeenBy(Myself),11)
	Global("WingBuffet","LOCALS",0)
THEN
	RESPONSE #100
		ForceSpell(LastSeenBy(Myself),DRAGON_WING_BUFFET) // SPIN695.SPL (Wing Buffet)
		Wait(1)
		SetGlobal("WingBuffet","LOCALS",1)
	RESPONSE #60
		Continue()
END

IF
	See(NearestEnemyOf(Myself))
	!Range(LastSeenBy(Myself),10)
	GlobalTimerExpired("REDDRAGONBREATH","GLOBAL")
THEN
	RESPONSE #100
		SetGlobal("WingBuffet","LOCALS",0)
		ForceSpell(LastSeenBy(Myself),WIZARD_FIREBALL) // SPWI304.SPL (Fireball)
		ReallyForceSpell(LastSeenBy(Myself),WIZARD_HORROR) // SPWI205.SPL (Horror)
		SetGlobalTimer("REDDRAGONBREATH","GLOBAL",18)
END

IF
	Global("WingBuffet","LOCALS",1)
	See(NearestEnemyOf(Myself))
	Range(LastSeenBy(Myself),11)
THEN
	RESPONSE #100
		SetGlobal("WingBuffet","LOCALS",0)
		SetGlobalTimer("REDDRAGONBREATH","GLOBAL",18)
END

IF
	See(NearestEnemyOf(Myself))
	Global("Offense1","LOCALS",0)
THEN
	RESPONSE #100
		ForceSpell(LastSeenBy(Myself),WIZARD_GREATER_MALISON) // SPWI412.SPL (Greater Malison)
		SetGlobal("Offense1","LOCALS",1)
END

IF
	See(NearestEnemyOf(Myself))
	Global("Haste","LOCALS",0)
THEN
	RESPONSE #100
		ForceSpell(Myself,WIZARD_HASTE) // SPWI305.SPL (Haste)
		SetGlobal("Haste","LOCALS",1)
END

IF
	See(NearestEnemyOf(Myself))
	Global("HoldPerson","LOCALS",0)
THEN
	RESPONSE #100
		ForceSpell(LastSeenBy(Myself),CLERIC_HOLD_PERSON) // SPPR208.SPL (Hold Person)
		SetGlobal("HoldPerson","LOCALS",1)
END

IF
	Global("Silence","LOCALS",0)
	OR(2)
		See(NearestEnemyOfType([0.0.0.LONG_BOW]))
		See(NearestEnemyOfType([0.0.0.CLERIC_ALL]))
THEN
	RESPONSE #100
		ForceSpell(LastSeenBy(Myself),DRAGON_SILENCE) // SPIN692.SPL (Silence, 15' Radius)
		SetGlobal("Silence","LOCALS",1)
		AttackOneRound(LastSeenBy(Myself))
		AttackOneRound(LastSeenBy(Myself))
END

IF
	See(NearestEnemyOf(Myself))
	Delay(6)
	GlobalLT("CharmPerson","LOCALS",3)
THEN
	RESPONSE #100
		ForceSpell(NearestEnemyOf(Myself),WIZARD_CHARM_PERSON) // SPWI104.SPL (Charm Person)
		IncrementGlobal("CharmPerson","LOCALS",1)
END

IF
	See(NearestEnemyOf(Myself))
THEN
	RESPONSE #100
		EquipMostDamagingMelee()
		AttackReevaluate(NearestEnemyOf(Myself),35)
	RESPONSE #10
		ForceSpell(LastSeenBy(Myself),WIZARD_MELF_ACID_ARROW) // SPWI211.SPL (Melf's Acid Arrow)
END

IF
	Allegiance(Myself,ENEMY)
THEN
	RESPONSE #100
		MoveToObject(NearestEnemyOf(Myself))
END

IF
	AttackedBy([GOODCUTOFF],DEFAULT)
	Allegiance(Myself,NEUTRAL)
THEN
	RESPONSE #100
		Enemy()
END
