Jump to content

Script to change container's items


Recommended Posts

I'm looking for a way to change the contents of all references of a certain container based on characteristics of the reference. I'm not certain how to get started though.

 

For starters I'm assuming the way to go is a script attached to the base object. But I don't really know which event(s) to use. The container I'm going to start with has thousands of references, so I'd want to avoid save bloat. It's also respawning, so I'd want to make sure the contents get changed when that happens.

 

On the other hand I've poked around enough mods to think that a quest might be the way to go about this. But that's probably beyond my capabilities.

 

Anyway, any input or suggestions would be appreciated.

Link to comment
Share on other sites

To help, I'd need more info for what you're trying to do. A simple way I can think to is just have separate containers, and enable / disable different ones that have different items in them based on conditions.

 

Example:

Actor Property PlayerRef Auto

Event OnLoad() ;event triggered when this reference loads 3D. 
    If PlayerRef.GetLevel() > 20 ;if players level is greater than 20, enable this container, else, disable it.
        Self.Enable() 
    Else 
        Self.Disable() 
    Endif
    
EndEvent

Another way is to just use leveled items in the container, and put the conditions on those in the creation kit, but that might be a lot more work if you've already set up the container.

Link to comment
Share on other sites

Thanks for the response.

 

Basically, I want to change the contents of the reference if certain conditions are met. For starters, if it has NPC or faction ownership defined. In the interim I wrote an xEdit script that found all the references with ownership, copied them as override, and changed the Base object to a copy of the original with the contents modified. But I'd rather find a method that doesn't involve overrides. And I'm toying around with the idea of a few more advanced conditions that can't be solved like that anyway.

Link to comment
Share on other sites

So you're trying to change vanilla container's contents based on conditions? If that's the case, I would recommend using SkyPal: https://www.nexusmods.com/skyrimspecialedition/mods/43925

 

It's a script resource where you can pass all object references in the game, then filter them by type (28 for containers) and can then filter those with an array of actor owners.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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