Scriptname nDragonVolcanicEruptionScript extends activemagiceffect  

import utility

actor me
actor he
objectreference obj1
objectreference obj2
float fX
float fY
float fZ

Event OnEffectStart(Actor akTarget, Actor akCaster)
	me = akCaster
	he = akTarget
	obj1 = he.placeatme(aSource)
	obj2 = he.placeatme(aTarget)
	RegisterForSingleUpdate(fCooldown + Randomfloat(-fCooldownRate, fCooldownRate))
Endevent

Event onUpdate()
	fX = he.GetPositionX() + RandomFloat(-fOffset, fOffset)
	fY = he.GetPositionY() + RandomFloat(-fOffset, fOffset)
	fZ = he.GetPositionZ()
	obj1.SetPosition(fX, fY, fZ)
	obj2.SetPosition(fX, fY, fZ + fHeight)
	abVisual.cast(obj2, obj1)
	AbToCast.RemoteCast(obj1, me, obj2)
	If !(he.isDead())
		RegisterForSingleUpdate(fCooldown + Randomfloat(-fCooldownRate, fCooldownRate))
	Endif
Endevent

Event OnEffectFinish(Actor akTarget, Actor akCaster)
obj1.delete()
obj2.delete()
Endevent


SPELL Property abToCast  Auto
SPELL Property abVisual  Auto
Activator Property aSource  Auto  
Activator Property aTarget  Auto  
Float Property fOffset  Auto  
Float Property fHeight=10.0  Auto  
Float Property fCooldown  Auto 
Float Property fCooldownRate  Auto