Scriptname nDragonGripControllerScript extends Actor
  
actor me
actor he
float PosX
float PosY
float PosZ
bool bready=false

Event OnLoad()

me = self
		registerForAnimationEvent(self, "DragonBiteEffect")
		registerForAnimationEvent(self, "DragonLandEffect")
		registerForAnimationEvent(self, "DragonForcefulLandEffect")
		registerForAnimationEvent(self, "DragonTakeoffEffect")
		RegisterForUpdate(30.0)
Endevent

	EVENT onAnimationEvent(objectReference dragonref, string eventName)
		If (eventName == "DragonBiteEffect")
			;debug.notification("===========DD AnimEvent=========== " + me + " bite stagger effect.")
			debug.trace("===========DD AnimEvent=========== " + me + " bite stagger effect.")
			me.docombatspellapply(xDragonBiteStagger, me.GetCombatTarget())
		elseIf (eventName == "DragonTakeoffEffect")
			bready=false
		elseIf (eventName == "DragonlLandEffect")
			If dKnockdownEnabled.Value > 0
				debug.trace("===========DD AnimEvent===========> " + me + " is knocking back actors.")
				xDragonLandingArea.cast(me)
			Endif
			bready=true
		elseIf (eventName == "DragonForcefulLandEffect")
			If dKnockdownEnabled.Value > 0
				debug.trace("===========DD AnimEvent===========> " + me + " is knocking back actors.")
				xDragonLandingArea.cast(me)
			Endif
			bready=true
		endif
	endEVENT

Event OnUpdate()
If bReady
	If me.GetDistance(he) >= 500.0
		he = me.GetCombatTarget()
		me.docombatspellapply(xGrip, he)
	Endif
Endif
Endevent

Spell Property xDragonLandingArea auto
SPELL Property xDragonBiteStagger  Auto  
GlobalVariable Property dKnockdownEnabled  Auto  
SPELL Property xGrip  Auto  
