Jump to content

Best way to attach a script to everything?


PAPVAFS11

Recommended Posts

I have multiple mechanics included in my mod that are meant to affect all human actors, the player included. At present, the existing mechanics are implemented directly into the HumanRace form. This is acceptable for my mod as it's not intended to be compatible with anything else, but I know this is bad practice, and I'd like to find a more flexible solution.

 

With respects to my previously-posted thread, I do not intend to have fast-looping timers on all human actors, and will have substantial checks to minimize unnecessary processing.

Link to comment
Share on other sites

You could register some permanent (or renewable) event that tells you a new cell has loaded and then use this.

https://falloutck.uesp.net/wiki/FindAllReferencesOfType_-_ObjectReference

"Finds all references of any of the objects in the list in the loaded area within the given radius of the calling ref."

You should be able to fit at least all race forms in one such formlist.

As for the new-cell-loaded event, there are a bunch, like OnCellLoad, OnLocationChange, OnLoad, OnPlayerTeleport, OnPlayerLoadGame... which you can register for and then add some time to allow all things to load, unless that is already what the event you chose actually does, such as OnCellLoad:

"Event called when every object's 3d in this object's parent cell loaded and ready. At this point you should be able to animate these objects, or manipulate them in other ways without issues. This event is sent every time the cell is loaded, which may happen multiple times in a single game session."


EDIT: And don't worry about array length limits, when arrays are fetched this way Bethesda have taken the liberty of removing the length cap. If you want to start splicing the arrays up and create new ones on your end you need to be mindful of the ridiculous 128 length-cap, however.

Link to comment
Share on other sites

Here's the link to SPID: https://www.nexusmods.com/fallout4/mods/48365

 

You just need to make a config file to have it affect any npcs of any race etc

I was able to find it myself, but I appreciate the tip. I've already got it running, and it seems to be working fine.

 

 

You could register some permanent (or renewable) event that tells you a new cell has loaded and then use this.

 

https://falloutck.uesp.net/wiki/FindAllReferencesOfType_-_ObjectReference

 

"Finds all references of any of the objects in the list in the loaded area within the given radius of the calling ref."

I think SPID is easier for me to wrap my brain around, but I appreciate the advice all the same. This will help me with a music flavor system I've been thinking about, though, so this is something I'll surely need to remember later.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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