Jump to content

Getting a reference for an active magic effect on an actor


Recommended Posts

I want to create a script based magic effect, and then be able to access that script effect so I can call functions from it.

 

Say I have one magic effect that's part of a constant effect with a function defined called "DoSomething()".

 

From another script I want to do this:

MagicEffect Property targetEffect auto    ; The magic effect I want to access

Actor targetActor
MagicEffect effectRef

;;; Find the target actor somehow

effectRef = GetReferenceToMagicEffect(targetActor,targetEffect)    ; This is what I don't know how to do
effectRef.DoSomething()
Link to comment
Share on other sites

Actor Who = IDKLetsGoWithNazeem as Actor
Spell FirstSpellFound = Who.GetNthSpell(0)
MagicEffect FirstEffectFound = FirstSpellFound.GetNthEffectMagicEffect(0)
Projectile TheMissleItUses = FirstEffectFound.GetProjectile()

Etc...

 

Now if summoning an atronach or something far as I know you cannot read that unless its also a script property so best you could do there

is scan for a nearby actor of that base using Game.FindNearest... call

 

As for the script yeah you could cast the MagicEffect as ScriptName, but if it extends ActiveMagicEffect that wont work. And even if you could read MagicEffect, thats something you would need to know in advance manually unless you use a clever and complicated StringUtil call to read the script name, but then youd still need to know what properties to interact with so... yeah kinda where that stands

 

TBH you might want to look into ModEvents. The ActiveMagicEffect can send a ModEvent to a listener script when applicable and take whatever action. I am assuming you want something dynamic to happen on demand, which is where ModEvents shine

Link to comment
Share on other sites

You wrote: "I want to create a script based magic effect, and then be able to access that script effect so I can call functions from it."

 

Depends on:

1. count of actors be involved by this kind of magic effect

2. content of function code to run here

there are various ways to come along with.

 

A simple way would be the use of a GlobalVariable with different values, which makes the magic effect to do somethings depends on value.

A script of type activemagiceffect do not have "really" a self on it! So there is no way to call functions here from other scripts like external function call, as well as property get or set.

But you can use OnUpdate() to wait for and respond of the value from a GlobalVariable. In other scripts you set the value to force action in the base magic effect.

 

zorakConstantMGEFScript

  Reveal hidden contents

 

Edited by ReDragon2013
Link to comment
Share on other sites

  • Recently Browsing   0 members

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