Scriptname nDragonAoEControllerScript extends activemagiceffect  

actor me
bool brun=false

Event OnEffectStart(Actor akTarget, Actor akCaster)
    me = akTarget
    RegisterForSingleUpdate(fDelay)
Endevent

Event OnUpdate()
If me.IsInCombat()
	If bEnableInAir
		If nDS.IsFlying(me)
			brun = true
		Endif
	Else
		If !(nDS.IsFlying(me))
			brun = true
		Endif
	Endif
	If bAlwaysEnable
		brun = true
	Endif
	If brun
		brun=false
		If warnSFX != none
			warnSFX.play(me)
		Endif
		abToCast.cast(me)
   		RegisterForSingleUpdate(fRecharge + utility.RandomFloat(-fOffset, fOffset))
	Else
   		RegisterForSingleUpdate(5.0)
	Endif
Else
   	RegisterForSingleUpdate(5.0)
Endif
Endevent

SPELL Property AbToCast  Auto  
Float Property fDelay = 30.0  Auto  
Bool Property bEnableInAir=false  Auto  
Bool Property bAlwaysEnable=false  Auto  
Float Property fRecharge=30.0  Auto 
Sound Property warnSFX  Auto  
nDataStoreScript Property nDS  Auto
Float Property fOffset=5.0  Auto  