Scriptname nDragonSpectralAllyScript extends activemagiceffect  
import utility

actor me
actor ally
objectreference he
bool isready=true
int iTimer=0

Event OnEffectStart(Actor akTarget, Actor akCaster)
	me = akCaster
	ally = me.placeatme(SpectralAlly) as actor
	ally.addtofaction(MqNoDragonAbsorb)
	me.GetActorBase().SetInvulnerable(true)
	RegisterForUpdate(1.0)
Endevent

Event OnUpdate()
	If Ally.IsDead() || iTimer >= iDur
		me.dispelspell(xBuff)
	Else
		iTimer += 1
	Endif
Endevent

Event OnEffectFinish(Actor akTarget, Actor akCaster)
	ally.placeatme(defExp)
	ally.disable()
	ally.delete()
	me.GetActorBase().SetInvulnerable(false)
Endevent

SPELL Property xBuff  Auto  
ActorBase Property SpectralAlly  Auto  
Int Property iDur=30  Auto  

Faction Property MQNoDragonAbsorb  Auto  

Explosion Property defExp  Auto  
