Protected NPCs in runtime via SKSE?

Post » Tue Feb 16, 2016 12:28 pm

Would it be possible to make an SKSE mod that adds the Protected flag on (certain) NPCs in runtime when loading cells? I'm using NPCs Protected Redux, but the problem is that every mod that edits the same NPCs (as, say, Elven Ethereal Overhaul, Bijin's Warmaidens etc.) overrides the flag, so you basically have to make patches for everything.

User avatar
Jesus Duran
 
Posts: 3444
Joined: Wed Aug 15, 2007 12:16 am

Post » Tue Feb 16, 2016 9:18 am

If it's for certain NPCs, can't you just Script it?



NPC.GetActorBase().SetProtected(True)



Not sure about loading Cells, but you could probably do something using OnReload, and force them to update whenever the Player Reloads, just to make sure they've not been tweaked? You'd have to find/script every NPC you wanted to protect originally, but it'd do the job.



I do not think either Reload or SetProtected are SKSE functions, but not 100% sure.

User avatar
Mr. Ray
 
Posts: 3459
Joined: Sun Jul 29, 2007 8:08 am

Post » Mon Feb 15, 2016 11:15 pm


Thanks! So basically, you could do it with vanilla scripting as above? I just figured that it was something you'd need SKSE for. I'll try it out and get back!

User avatar
Victoria Bartel
 
Posts: 3325
Joined: Tue Apr 10, 2007 10:20 am

Post » Tue Feb 16, 2016 1:31 am

Should be, the Wiki doesn't say the commands are SKSE ones (that I can see), so it should be as easy as :



1) Make a Magic Effect


2) Script it as such :


[Script]


Actor Property WhoeverYouWant Auto



Event OnPlayerLoadGame()


WhoeverYouWant.GetActorBase().SetProtected(True)


EndEvent



3) Make an Ability with that Magic Effect


4) Make an Alias, point it at the PC, and attach that effect.



The one thing is, OPLG only fires on a load, so you'd need either a 'first time' script, or to make at least one load. What I'd personally do is make a Quest Script, make the 'set protected' part a Function, and have OPLG and OnInit() run that Function.



Edit: Untested, UnMastered Mod - https://www.dropbox.com/s/mhrr8djiqvb414m/Scripted%20Protection.rar?dl=0



Should do what you want, just follow the instructions on the Quest Script. Any issues, let me know :)

User avatar
Lalla Vu
 
Posts: 3411
Joined: Wed Jul 19, 2006 9:40 am

Post » Tue Feb 16, 2016 5:57 am

That's awesome, thanks! I'm a bit lost as I almost haven't done any modding for Skyrim, but I've added Skyrim.esm as a master and I'll try to figure it out.

User avatar
Nathan Barker
 
Posts: 3554
Joined: Sun Jun 10, 2007 5:55 am


Return to V - Skyrim