Jump to content

[LE] Scripting Help - Calling Properties Between Scripts


Myst42

Recommended Posts

Anybody knows how to do this?

 

I have a "ScriptA" ActiveMagicEffect script, with a "Caster" Actor property that is kind of dynamic since the caster can be anyone who casts the spell.

Then I have a "ScriptB" ObjectReference script that needs to know who the Caster in script A is

 

How do I do this?

I can't for the life of me make "GetLinkedRef" function to work, compiler tells me every single iteration of it I've tried is wrong.

 

Link to comment
Share on other sites

You would want something like this for your MGE script (note, this is pseudocode since I'm not at my main computer):

ObjectReference Property MyObj Auto
 
Event OnEffectStart(Actor akTarget, Actor akCaster)
   (MyObj As YourScriptNameHere).PropertyName = akCaster
endEvent
Edited by Reneer
Link to comment
Share on other sites

Having the property on the magic effect would cause your objectreference to pull invalid data should the magic effect cease to exist.

 

Here is another solution:

 

  Reveal hidden contents

 

With the actor property on the objectreference, it can be filled by the magic effect and remain filled even after the magic effect ends and ceases to exist.

 

Even with this, depending upon how and when you wish your script to function, it may be better to utilize a quest script to hold the property.

I can see the following as viable:

 

  Reveal hidden contents

 

 

On the CK wiki the following discusses how to do this in regards to functions. https://www.creationkit.com/index.php?title=Function_Reference#Accessing_Functions_From_Other_Scripts

The process is the same only substituting property variables in place of functions.

Link to comment
Share on other sites

  On 11/8/2018 at 9:22 PM, Reneer said:

 

 

  On 11/8/2018 at 10:26 PM, IsharaMeradin said:

 

 

  On 11/8/2018 at 10:28 PM, jdrfox said:

 

 

Ah. Thank you all very much.

I think now I get the mechanics of calling properties between scripts

It's really just a matter of "OtherScriptCall.RetrievedProperty right"?

Previous inclusion of the other script as a property itself ofc ("OtherScript'sRealName Property OtherScriptCall Auto")

Curiously, I've been calling functions just like that for a while, but functions use the () on their name so I didn't know the name was enough to get the property

 

Well, the compiling worked

Did the the swap thing, so now the magic effect fills the property on the object reference script instead

 

Found myself with another issue though

The magic effect I was using is strange since it's delivery is "target location" instead of an NPC or something, also the casting is type "Voice"

As a consequence, it generates no events

Been struggling with such thing for a while, I'm just finding out "OnEffectStart" needs to always hit something to exist

Some other issues I had with it relate to wanting a spell to generate a script effect even if the projectile hit no one.

 

As this thing itself proves, a placed object/explosion can call scripts from the ground, but I still have no idea how to make it know who the caster of the spell that placed them was.

Edited by Myst42
Link to comment
Share on other sites

  On 11/8/2018 at 10:26 PM, IsharaMeradin said:

Having the property on the magic effect would cause your objectreference to pull invalid data should the magic effect cease to exist.

No, it won't. Having the ScriptB Objectreference property in the ScriptA ActiveMagicEffect script will have no effect upon the ScriptB Objectreference script. There is no "invalid data." ScriptB won't magically lose the already-set property value when ScriptA's magic effect finishes.

Edited by Reneer
Link to comment
Share on other sites

You can skip the property and any issues it may or may not create due to persistence, timing, etc.

 

Create a function on the object reference script that has an actor parameter and pass in the akCaster.

Example:

 

  Reveal hidden contents

 

 

But that doesn't solve the new issue of not getting any events to fire on the magic effect in question...

 

 

Link to comment
Share on other sites

Regarding your issue of not being able to get the caster from the magic effect due to its type. If you can create one of those "cloak ability" spells that can reach out and fill quest aliases with targets that match the targets of the magic effect, apply a script to those aliases using the OnHit event. Listen for the projectile from the magic effect and get the "caster" that way by using the akAgressor parameter.

Link to comment
Share on other sites

Myst42 wrote: "Been struggling with such thing for a while, I'm just finding out "OnEffectStart" needs to always hit something to exist"
That is impossible. Since the event "OnEffectStart" is called, it ends always with commandline "endevent".

The only way to hold alive the event "OnEffectStart" is using a while loop inside.

Myst42 wrote: "As this thing itself proves, a placed object/explosion can call scripts from the ground, but I still have no idea how to make it know who the caster of the spell that placed them was."

TestEffectScript

  Reveal hidden contents

TestQuestScript

  Reveal hidden contents

 

Edited by ReDragon2013
Link to comment
Share on other sites

Well, thanks again for the help on this. I did learn some useful tricks.

 

Anyway, the goal was to set up the bases for a teleport blink effect that someday NPCs could use.

Basically, it throws a projectile that spawns a marker that calls the player to it's location.

Had I succeeded, the marker would call the caster of the spell Instead of the player all the time.

But looking at this it looks like way more trouble than I can get involved right now for so little.

 

It's not really that important, since it was just a thought. So I'm dropping it.

 

Finally being able to call and set properties between scripts was priceless though.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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