Jump to content
TheCommander

Quick Guide: How To Mod The Loot Distribution System (Distributions.lua, ProceduralDistributions.lua)

Recommended Posts

Posted (edited)

This is a visual guide for mappers and modders who need to add or modify PZ's loot entries using the new ProceduralDistributions.lua approach.

 

Whilst the ProceduralDistributions.lua file has been in the game for quite a while (i.e. the Gigamart shelves having distinct loot types), TIS will be eventually using this file to populate containers with loot in all its building 'room definitions' (Build 41.51 onward).

 

So What's Changed?

For those familiar with adding loot to PZ's loot tables, the old approach to editing lua files involved adding items directly to the tables named after room definitions in the Distribution.lua file. The downside of this was that loot tended to be a hodge-podge collection of items rather than a logical or thematic grouping of items like you would find in a store's shelves.

 

The new approach use the ProceduralDistribution.lua to maintain the same loot tables, but classifies them by some distinct purpose or category rather than room definition. For example: BakeryBread, BakeryCake, BakeryPie are all new loot tables in this file, and each will ensure a distinct set of bakery items appear in a container.

 

Using this new approach, the Distributions.lua file no longer needs a massive list of items under each room definition, but instead randomly roles against a list of ProceduralDistribution loo tables to populate each container. This the above bakery example, it ensures a Bakery with multiple display cases has a good chance of spawning either bread, cakes or pies in each rather than all of these bakery items jumbled together.

 

Of course there are many other positives to this new approach which most experience modders will figure out as they look and play around with the files.

 

Important Note For Mods Designed Before Build 41.51?

Now there is one down side to this new (and fantastic) change...it will break alot of loot related mods on the PZ Workshop designed for earlier builds than 41.51. This unfortunately means players will need to be patient until their favorite loot-related mods are updated.

 

This may also mean some classics that are no longer updated may need to be put to rest (mercifully un-ticked from your mod list :( ). In any instance, players should always be mindful that modders are not obligated to update their mods, nor should they be harassed to do so....play nice and treat others the way you expect them to respond to you.

 

So How Does This New Loot System Work?

Here is a visual guide on how to link all the necessary elements of each file depending on the room definition:

 

Loot System Explained v3.png

Edited by TheCommander

Share this post


Link to post
Share on other sites
Posted (edited)

Please make a normal kerning between letters. This is killing the eyes, and because of this I cannot translate your texts in the picture - through the service of translating images into my language.

The explanatory texts can simply be placed in the main text of the post ... under the picture, and everyone will be happy.

Edited by Nebula

Share this post


Link to post
Share on other sites

I typed it real quick

 

Quote

 

This room is using the 'bedroom' loot definition.
It contains furniture which acts as the following container types: 'wardrobe' and 'sidetable'.
Note the double bunk associated with the theme of a kids room. This is important as the loot generation method will check the sprite name of furniture to understand the intended purpose of the room.


This is the Distributions.lua file. Each entry in this file tells the game what type of loot to generate based on the container types, furniture and zones present in the room. In our example, you can see the container types specified along with the rules it must follow.

Each container type entry has the following properties:
    procedural = if true, indicates the entry uses loot tables from the procedural_distribution.lua file.
    name = the name of the loot tables from the procedural_distribution.lua file.
    min = the amount of times minimum this loot table should appear in this container type. 0 (zero) indicates there is a chance it might not spawn in this container, 1 indicates it must spawn at least once in the container. If you set the value to 10, then assuming there were 10 or more of the container type in the room, it would spawn in 10 of those containers.
    max = As you might guess, it does the same thing as 'min' but in this case sets the upper limit on how many times this loot table can be used. Typically a vanilla entry will have a value of 99 set given that most rooms do not contain the same container type more than a dozen times at most. If you set it to 2 (for example), then a third container of this type would ignore this loot table which may lead to it either looking for an alternative entry or spawning nothing (empty).
    forceForItems = indicates that if the room has furniture with any of the specified spritenames, then it must use this loot table as a priority over any other entries.
    forceForZone = Similar to forceForItem, if the room is located in a part of the map that is designated with the specified zone type, then it will use this loot table as a priority over any other entries. In this above example, a trailer house on the vanilla map is typically located in areas of the map designated as 'TrailerPark'. That's how the game knows to spawn those trailer trash style zombies.
    
Notes to mappers:
    - The spritenames and offset values for furniture items can be identified via TileZed's 'Tile Properties' screen.
    - Container type names can also be identified via the properties of the furniture via the same 'Tile Properties' screen.
    - Zones can be viewed and defined via WorldEd.
    
    
This is the ProceduralDistributions.lua file. This file contains the various items that a room definition can use in game. In our example, it shows all the various wardrobe entries that get used. We typically refer to these as the 'loot tables' which tell the game what items to include in a container when it randomly generates contents.

Each loot table entry is structured as follows:
    rolls = the amount of times the game will roll to add an item to the container. There is a lot of complex magic that goes into these rolls which this guide does not cover. If you need to know more, then it's recommended to look into the code or ask on the discord.
    items = a list of the items that will be considered. The number that appears after the item is the 'weight' Think of it as the chance it has of appearing over the other items. A weight of 100 should make the item appear almost always, where as a very small number such as '0.5' would make it quite rare. Balancing these numbers can be challenging, so if you want something to appear either make the weight higher or consider adding the same item in the table multiple times.
    junk (not shown in example) = some entries will also have a 'junk' entry which is structured in a similar manner to 'items'. The junk entry allows the loot table to ensure that specific junk-type items (e.g. pens, toys) also get thrown into the mix of items when the container is populated. The junk entry can also be used to ensure a specific type of item has a better chance of appearing if it is also listed here.

 

 

Share this post


Link to post
Share on other sites
Posted (edited)

@TheCommander  Thanks for the heads up...

 

Can you explain to me how we would go about adding Procedural lists ?

and also give me the list of new procedural lists ?

or point me in the direction of where that info might be ? Thanks for any info you might share...

 

[edit]   DoH!!  Disregard... figured it out...

Edited by Arsenal26

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...