Jump to content

[LE] Apply a permanent magic effect to an NPC?


Musjes

Recommended Posts

Is it possible to apply a magic effect to an NPC permanently? I've tried various options such as using a cast spell, adding an Ability spell, or making them wear an enchanted item, but in all cases the magic effect is dispelled as soon as I leave the cell that the NPC is in. When I return, I can for example see that the NPC still has the Ability spell, but the effect is gone.

 

Is there a trick to make this happen?

Link to comment
Share on other sites

Hmmm if the effect is truly not applying, but still on the target...you could take a look at writing a script that checks for that the "ability" is on the target once you get close to the target again, and then have it apply a spell that lasts for say 30 days or such, and have it so recasts renew duration, so if you leave the NPC, the effect is automatically reapplied when you get close.

 

Obviously this wouldn't be a good idea, if for example your effect was say petrifying the target or such, but otherwise if it's just a self constant effect buff like +25% frost resistance, then it should work well as it's not likely that the NPC is wandering off fighting dragur or frost mages while you're not around.

Link to comment
Share on other sites

This sounds to me like you've got an issue with your effect's conditions somewhere, because both abilities and enchanted gear should work. Perhaps throw some debug statements into a short script firing when the effect starts and stops so that you can see things with precision.

Link to comment
Share on other sites

Hey,

 

I have the exact same issue, except that I want to apply a magic effect that lasts a few days (including when the player isn't on the same cell than the npc), so I can't use your solution Seraphim.
The NPC casts a spell on himself, that calls the magic effect. I tried using the Spell Duration, and the Taper Duration (from magic effect), but none of them resolved this issue.
My spell doesn't need any condition to be applied, nor the magic effect (I use a script to trigger the spell cast), so I'm not sure that the issue comes from conditions.

 

EDIT : After some researches, I think it is due to the persistency of the Actor's reference. NPCs I use have temporary references, meaning they are thrown out of memory when I move out of their cell.
There are different types of persistency, listed here : https://afkmods.iguanadons.net/index.php?/topic/4250-skyrim-levels-of-persistence/
And a method to change temporary reference into permanent reference here : https://github.com/xanderdunn/skaar/wiki/Understanding-Forms%2C-Object-References%2C-Reference-Aliases%2C-and-Persistence

 

But before using this method, I'll make a test on Elisif (her reference is persistent in the Blue Palace) to check if our issue is really coming from persistency. Keeping you up !

RE-EDIT : Brrr, whatever, it didn't work. Elisif also looses the magic effect I apply on her, after I leave and re-enter the Blue Palace.

Edited by Shamyase
Link to comment
Share on other sites

This sounds to me like you've got an issue with your effect's conditions somewhere, because both abilities and enchanted gear should work. Perhaps throw some debug statements into a short script firing when the effect starts and stops so that you can see things with

precision.

 

That's exactly what I did :smile: The point of having the effect is to be able to run a script on those NPCs. Anyways, the effect has no conditions attached. The messages from the script show that it applies correctly when the item is donned or the spell ability is added, but disappears immediately when I leave the NPC's cell.

 

 

Hey,

 

I have the exact same issue, except that I want to apply a magic effect that lasts a few days (including when the player isn't on the same cell than the npc), so I can't use your solution Seraphim.

The NPC casts a spell on himself, that calls the magic effect. I tried using the Spell Duration, and the Taper Duration (from magic effect), but none of them resolved this issue.

My spell doesn't need any condition to be applied, nor the magic effect (I use a script to trigger the spell cast), so I'm not sure that the issue comes from conditions.

 

EDIT : After some researches, I think it is due to the persistency of the Actor's reference. NPCs I use have temporary references, meaning they are thrown out of memory when I move out of their cell.

There are different types of persistency, listed here : https://afkmods.iguanadons.net/index.php?/topic/4250-skyrim-levels-of-persistence/

And a method to change temporary reference into permanent reference here : https://github.com/xanderdunn/skaar/wiki/Understanding-Forms%2C-Object-References%2C-Reference-Aliases%2C-and-Persistence

 

But before using this method, I'll make a test on Elisif (her reference is persistent in the Blue Palace) to check if our issue is really coming from persistency. Keeping you up !

 

RE-EDIT : Brrr, whatever, it didn't work. Elisif also looses the magic effect I apply on her, after I leave and re-enter the Blue Palace.

 

That reference thingy is probably the cause of the effects not stikcing. That's a crappy limitation of the engine though :sad:

 

Edit: So sticking them in a ReferenceAlias will make them persistent. Meh... in my case the effect is potentially applied to many NPCs dynamically, so using a RefAlias would place a hard limit on the nr of NPCs it can manage.

Edited by Musjes
Link to comment
Share on other sites

 

This sounds to me like you've got an issue with your effect's conditions somewhere, because both abilities and enchanted gear should work. Perhaps throw some debug statements into a short script firing when the effect starts and stops so that you can see things with

precision.

 

That's exactly what I did :smile: The point of having the effect is to be able to run a script on those NPCs. Anyways, the effect has no conditions attached. The messages from the script show that it applies correctly when the item is donned or the spell ability is added, but disappears immediately when I leave the NPC's cell.

 

 

 

 

Does it reapply when you re-enter?

EDIT:

 

If all you're looking to do is run scripts on these NPCs a RefAlias can do that. While you're limited to the maximum number of aliases you added to a quest, that number can exceed a hundred without issues, which even for dynamic stuff is enough to cover an awful lot of use cases.

Edited by foamyesque
Link to comment
Share on other sites

 

If all you're looking to do is run scripts on these NPCs a RefAlias can do that. While you're limited to the maximum number of aliases you added to a quest, that number can exceed a hundred without issues, which even for dynamic stuff is enough to cover an awful lot of use cases.

 

 

You;d be surprised :laugh: If you provide 1000 aliases, people will cry that they *really* need 1100.

 

I made a mechanism to slot NPCs in and out of RefAliases dynamically to get around the limit, but that mechanism doesn't scale all that well.

Link to comment
Share on other sites

Musjes & foamyesque, nice catch on this workaround, it works quite great for me.

 

My only issue is that i don't want any duplicated reference in the aliases list. So everytime I add an actor reference, I have to check in a "while loop" if it isn't already there (and this loop has to call .GetAlias() and .GetActorReference() for each alias !). Problem is, my quest contains 200 aliases. So it takes like 2 seconds, quite huge. To avoid this issue, I'm creating an "Stored Actors" faction, that stores ID values of these aliases when actors are triggered for the first time. That way I simply have to grab the actor faction rank, instead of using a while loop, to obtain its alias ID next time it is triggered.

 

Sorry for this little speech, I simply think it could help someone who would be confronted to the same issue and who would come on this thread.

EDIT : Done. Everything works like a charm now. :3

Last questions : If I understand correctly, actors that are concerned by references of type "Specific Reference" are marked "persistent" permanently, even when the quest is not running (Copy-pasted from the CK wiki : https://www.creationkit.com/index.php?title=Quest_Alias_Tab)

Let's say I set up a "Specific Reference" alias, and I let it blank. If it is filled during run time, through a script, will the same rules apply (actor permanently marked as persistent) ?
Now, let's say I use "Find Matching Reference" for all aliases, and during run time I add actors to this alias list with the .ForceRefTo() function. Is it still considered as a "Find Matching Reference" (not permanently persistent); or does it become a "Specific Reference" ?

Edited by Shamyase
Link to comment
Share on other sites

  • Recently Browsing   0 members

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