Jump to content

Trying to make an effect to reapply when unique actor is3dloaded


Recommended Posts

Hello all,
I'm trying to make a script to reapply an effect everytime a unique actor is3dloaded and have no idea how to accomplish this. 
Is for a follower actor I want to reapply skeleton netimmerse changes when the actor is reloaded. The script I have applies the effect correctly, but everytime the actor is reloaded (like when crossing a door) the effect resets.
Anybody have any idea how this type of thing can be done?
Link to comment

First thing that I can think of right now it to just use an OnLocationChange Event to reapply the effect 

The downside here is that it would also fire when you just move from a location like Falkreath into a WIlderness cell, I dont know what would happen if you apply the effect while its already active

If you have a way to simply detect wether or not the effect is active (through a keyword or so) you could check for that before reapplying the effect, which would avoid the issue above - if it is an issue

 

Theres also an "OnLoad" Event though I never worked with that one, unsure if its what you want

Link to comment
1 hour ago, Scrab said:

Theres also an "OnLoad" Event though I never worked with that one, unsure if its what you want

OnLoad() is very unreliable.  I would avoid it.  Frankly, most events of this sort are unreliable when put on an NPC.  This is one of the reasons why cloak spells were preferred in the past.

Link to comment

Yep, I tried OnLoad and it didn't work. 

10 minutes ago, Seijin8 said:

OnLoad() is very unreliable.  I would avoid it.  Frankly, most events of this sort are unreliable when put on an NPC.  This is one of the reasons why cloak spells were preferred in the past.

What is a "cloak spell" and how could I use it?

Link to comment

I can check for the effect to not apply over itself. 

1 hour ago, Scrab said:

First thing that I can think of right now it to just use an OnLocationChange Event to reapply the effect 

The downside here is that it would also fire when you just move from a location like Falkreath into a WIlderness cell, I dont know what would happen if you apply the effect while its already active

If you have a way to simply detect wether or not the effect is active (through a keyword or so) you could check for that before reapplying the effect, which would avoid the issue above - if it is an issue

 

Theres also an "OnLoad" Event though I never worked with that one, unsure if its what you want

Gonna try OnLocationChange and see how it goes.

Link to comment
12 hours ago, Roggvir said:

Wouldn't a simple active magic effect work?
Give the actor some ability and use OnEffectStart in its Active Magic Effect script to do what you need?

The only active magic effects that reliably track and retain event data are those attached to the race record.  If it is just placed on an NPC, it can unload/deactivate when the actor unloads its 3D.

Link to comment
9 hours ago, Seijin8 said:

The only active magic effects that reliably track and retain event data are those attached to the race record.  If it is just placed on an NPC, it can unload/deactivate when the actor unloads its 3D.

Which is the reason why i suggested it, because it works the other way too - when the actor loads, the effect kicks in.

I am using it for various things, for example to apply face morphs on NPCs, and it works fine.

Btw. the OnLoad event handler also works perfectly fine for me - i have no idea what unreliability you were talking about, is it maybe under some specific, rare circumstances? (can you elaborate?).

Link to comment
18 minutes ago, Roggvir said:

Btw. the OnLoad event handler also works perfectly fine for me

Under how much script load?

While extending what?

Are you declaring the NPC/actor itself as a property within the script?

 

I obviously can't speak to each and every use case.  I'm glad it is working for you.

 

In my experience, an active magic effect on a spell that is not part of the race record (and is not using an actor property) does not reliably trigger OnLoad() events, and more often than not, just fails entirely after they are unloaded from memory.  It can be made to work more reliably (but still not perfectly) if the actor it is attached to is a property of the spell effect -- fine for a few individuals, not fine for dozens or hundreds.

 

Active magic effects attached to race records do trigger reliably with OnLoad() as well as most other events.  This is my preference for these effects, but wouldn't seem to fit the OP's use case.

 

The majority of my testing with this has been on creatures (particularly wolves and werewolves) and spell effects using OnLoad() don't reliably function on those (unless, as noted, the spell is part of the race record).

 

I'm very much open to any tricks or tips you would have for this.

Link to comment

Well, I tried both ways, adding the script to the race makes the game crash when crossing a door. Adding to the npc makes it crash when I try to enter the room the npc is in.

So, there is something wrong with the script and I have no idea what. I have to confess I have no idea what I'm doing. I'm a newb.

Link to comment
4 hours ago, Seijin8 said:
Spoiler

Under how much script load?

While extending what?

Are you declaring the NPC/actor itself as a property within the script?

 

I obviously can't speak to each and every use case.  I'm glad it is working for you.

 

In my experience, an active magic effect on a spell that is not part of the race record (and is not using an actor property) does not reliably trigger OnLoad() events, and more often than not, just fails entirely after they are unloaded from memory.  It can be made to work more reliably (but still not perfectly) if the actor it is attached to is a property of the spell effect -- fine for a few individuals, not fine for dozens or hundreds.

 

Active magic effects attached to race records do trigger reliably with OnLoad() as well as most other events.  This is my preference for these effects, but wouldn't seem to fit the OP's use case.

 

The majority of my testing with this has been on creatures (particularly wolves and werewolves) and spell effects using OnLoad() don't reliably function on those (unless, as noted, the spell is part of the race record).

 

I'm very much open to any tricks or tips you would have for this.

 

Hmm, interesting, maybe it is the number of actors - few times, i had it running on 30 actors at same time, but that was when i was testing something and its very possible i simply didn't notice any problems, normal situation is about 1-5 actors having the spell at the same time (one usually being the player and another some follower, then some NPCs).
Anyway, no tricks, nothing special, but i never experienced any kind of unreliability with OnLoad in my game in general.
I am using the SSE Engine Fixes though - if that is relevant here, i have no clue.

 

57 minutes ago, Sunspot2 said:

Well, I tried both ways, adding the script to the race makes the game crash when crossing a door. Adding to the npc makes it crash when I try to enter the room the npc is in.

So, there is something wrong with the script and I have no idea what. I have to confess I have no idea what I'm doing. I'm a newb.

That could be because you are trying to do whatever it is you are trying to do before the 3D is really loaded - are you sure that is not the case?
Try adding some trace output with result of Is3DLoaded() just before you run that code, and see what it spits in the log.
Or, maybe simply what you are doing is messed up (for example, it may not be that hard to cause a CTD when trying to mess with NiO in some wrong way).

Link to comment

Well, added that If Is3dLoaded and is not crashing anymore, but also nothing is happening.

I added this to the npc:

 

scriptName FaeWeelaSizeAOBScript extends ObjectReference


actor property WeelaREF auto
spell property FaeWeelaSetSize auto

 

    Event OnLoad()
        If (WeelaREF.Is3DLoaded())
        FaeWeelaSetSize.Cast(WeelaREF as objectreference, WeelaREF as objectreference)
        EndIf
    EndEvent

 

And this is the script of the spell cast:

 

scriptName FaeWeelaSetSizeEffectScript extends activemagiceffect


Float property WeelaHeight auto
Float property WeelaHOV auto

 

 

function OnEffectStart(Actor akTarget, Actor akCaster)

        NetImmerse.SetNodeScale(akTarget, "NPC", (WeelaHeight), true)
        NetImmerse.SetNodeLocalPositionZ(akTarget, "NPC", (WeelaHOV), true)
        akTarget.QueueNiNodeUpdate()
endFunction

 

I have another spell with the same netimmerse effects that I cast at the npc and it changes size immediately. No idea what happens here. How would I add that to the race? Maybe that is the problem.

Link to comment
9 hours ago, Sunspot2 said:

How would I add that to the race? Maybe that is the problem

In this case, you probably wouldn't.  If it were to be done, you would add the spell effect directly to the race record (same as racial abilities).

 

Given that you are trying to alter height, I would look into how hdt High Heels functioned, since it was doing the same thing.

 

Another option if this is supposed to be "always on" would be to add a NiOverride to the actor's mesh.  I'm not a fan of this method since they will have the height change when sitting and laying down (whereas hdt HH type effects can detect these things).

Link to comment
55 minutes ago, Seijin8 said:

Another option if this is supposed to be "always on" would be to add a NiOverride to the actor's mesh.  I'm not a fan of this method since they will have the height change when sitting and laying down (whereas hdt HH type effects can detect these things).

Please, how can I add NiOverride to the actor's mesh? In the skeleton? But anyway, is not supposed to be always on.

Link to comment
5 hours ago, Sunspot2 said:

Please, how can I add NiOverride to the actor's mesh?

Look at the nif files for various high heels, and there is an extra item under one of the shapes that will apply this effect.

5 hours ago, Sunspot2 said:

But anyway, is not supposed to be always on.

Then look at hdt High Heels since it does what you want, and is fairly reliable.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more information, see our Privacy Policy & Terms of Use