Jump to content

Outfit + loot variations by script? NPCs decide what to wear.


Recommended Posts

Hi everyone, I haven't really touched quest modding yet so I'm pretty lost on this one, even though I feel like it should be simple enough...

 

How would I set up a quest/script to let every npc in game decide what to wear? And what to carry in their inventory based of different conditions?

 

I'd like NPCs to pick an outfit and Omods from a formlist based on what they're supposed to be wearing.

 

For example if npc Rick is a farmer and he is wearing the farmhand outfit, then every time he loads in he picks an outfit from a "farmer outfits" formlist and wears that instead. -

Hoods and hats when it rains, pyjamas before bed etc.

 

 

How do I call every npc at once in a script? And how do I tell them to make a random selection from a form list?

Edited by SandMouseAnarchy
Link to comment
Share on other sites

The scripting to do the inventory and apparel is straightforward.

 

Finding the actors to populate quest ReferenceCollectionAliases so the scripts can be attached can be intensive so needs care.

 

Most effective method is to run a scan of the active uGridsToLoad around the player, so get to know .FindAllReferencesWithKeyword(ThisKeyword, 10240) and the common actor keywords. Top tip .FindAllReferencesOfType(ListOfObjects, 10240) looks attractive but you will have to fire that against a LOT of objects which can grind to a halt.

 

The scan needs to run every 50% of uGridsToLoad movement for overlap, so drop a marker at the player and register for event OnDistanceGreaterThan()

 

And you will need to run multiple scavenging processes to remove/release dead, disabled or deleted actors.

 

What you cant do is find all actors in worldspaces up front because each interior is its own worldspace, and only the initial static placed actors will be found, not spawns or respawns.

 

Budget around 50 hours effort to get that framework running so you can populate with lists of gear 'n stuff.

Edited by SKK50
Link to comment
Share on other sites

In a quest you can define aliases, each alias stores a reference, references are everything in the game, for example you create a new object, and you put this object in to the world twice, those two objects place in the world are called references.

 

There is a type of alias that is called ref collection alias, which can store multiple references, and you don't need to specify what references, just put some conditions so the game will fill the collection with all references in the game that match these conditions.

 

So you need a ref collection alias for each of the formlists that you create.

 

Following your example, you would need a collection for farmers, so you will need to put some conditions to fill the collection with farmers, for example a first condition could be "IsObjectType Actor == 1", then add as many conditions as you need until you've "filtered" it only for the type of actor you want to match.

 

Then you need to create a script for this collection that will equip the outfit. You need to add the FormList as a property for the script, then use the event OnLoad to equip the outfit, you can get the outfit from the FormList using GetAt(index) and you can create a random index using RandomInt(). Once you have one outfit you can equip it to the reference that triggered the OnLoad event. Note that all events in a RefCollectionAlias Script will return the reference that triggers it in the first argument:

 

Event OnLoad(ObjectReference akSenderRef)

Int HigherIndex = MyOutfitsFormList.GetSize() - 1

Int RandomIndex = Utility.RandomInt(0, HigherIndex)

Outfit RandomOutfit = MyOutfitsFormList.GetAt(RandomIndex) As Outfit

(akSenderRef As Actor).SetOutfit(RandomOutfit)

EndEvent

Link to comment
Share on other sites

  • Recently Browsing   0 members

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