Jump to content

Creating Radial Attack Spells That React to Enemies


pyrotx

Recommended Posts

I recently started trying to create a new type of spell that would automatically attack enemies within a radius, but without using the cloak spells. I want to reuse the candlelight effect archetype and then attach a script to it. The script is similar to the lightning storm shout effect, mainly because that is the script I am trying to copy. So far the script compiles, but in game it doesn't do anything.

Here is the script so far. Also I have a condition in the spell effect that says it must be hostile to the caster, would that prevent it from working due to it being a remote cast?

Can anyone help me with the script?

 

Scriptname LightDestructionSpellScript extends ActiveMagicEffect

 

;=========================================================

 

; PROPERTIES

 

;===========

 

Spell Property SpellRef Auto

 

Activator Property PlacedActivator Auto

 

Sound Property SoundFX Auto

 

Float Property PosX Auto

 

Float Property PosY Auto

 

Float Property PosZ Auto

 

Float Property fHeight Auto

 

Float Property fDelay Auto

 

Float Property fRange Auto

 

Float Property fRandomVar Auto

 

Bool KeepUpdating = True

 

;=========================================================

 

; VARIABLES

 

;===========

 

ObjectReference CasterRef

 

ObjectReference ActivatorRef

 

Actor CasterActor

 

Actor TargetActor

 

Actor Player

 

;=========================================================

 

; EVENTS

 

;===========

 

Event OnEffectStart(Actor akTarget, Actor akCaster)

 

TargetActor = akTarget

 

CasterActor = akCaster

 

CasterRef = CasterActor

 

ActivatorRef = CasterRef.PlaceAtMe(PlacedActivator)

 

RegisterForSingleUpdate(fDelay) ; or (fDelay + RandomFloat(0.0, fRandomVar)

 

EndEvent

 

;=========================================================

 

Event OnUpdate()

 

PosX = CasterRef.GetPositionX()

 

PosY = CasterRef.GetPositionY()

 

PosZ = CasterRef.GetPositionZ() + fHeight

 

ActivatorRef.SetPosition(PosX,PosY,PosZ)

 

if TargetActor.GetDistance(CasterRef) <= fRange

 

SpellRef.RemoteCast(ActivatorRef,CasterActor,TargetActor)

 

SoundFX.play(TargetActor)

 

endIf

 

 

 

if KeepUpdating == true

 

RegisterForSingleUpdate(fDelay)

 

endIf

 

EndEvent

 

;=========================================================

 

Event OnEffectFinish(Actor akTarget, Actor akCaster)

 

KeepUpdating = false

 

if (ActivatorRef != none)

 

ActivatorRef.disable()

 

ActivatorRef.delete()

 

endIf

 

EndEvent

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...