Jump to content

Loot tables


Tiax

Recommended Posts

Let's talk about how loot tables currently work. I made a mod adding a bunch of items, added them to the loot tables for zombie male+female as a (what I thought was a rare chance) drop and to my surprise got stuff from every couple of zombies. Really... stuff dropped like crazy.

 

Checking the the java implementation, I found the equation for loot to be generated in a container is:

 

Roll N times (that's a var in the table) for every item in the table check if:

Rand.Next(10000) <= loot_table_chance × 100.0 × luck_modifier × world_loot_modifier + chunk_zombie_intensity_modifier

Problem #1:

the chunk_zombie_intensity_modifier sets a lower bound for the minimum drop chance, which you CANNOT influence (unless you set a negative drop chance, but that breaks pretty much every mechanic of lucky/unlucky traits and world_loot_modifier etc., so let's disregard that "hack"). This makes it so by definition you cannot make rare drops, if you add many items. You can expect this to max out at 80  (=0.8% bonus) quickly, which doesn't sound like a lot, but it adds up very quickly, which leads me to problem 2...

 

Problem #2:

It always rolls for every item in the table; there are no groups in the drops. Let's assume your mod adds 20 items to a container with a drop chance of literally zero, you'll still find at least one of those 20 items at almost 15% chance, assuming maxed out chunk_zombie_intensity_modifier (1 - (1-0.008)^20 = 0.148). This explained my observation of stuff dropping like crazy.

 

With drop groups introduced to the existing tables, it could (also) roll if a group is "hit"  (think: a drop group for a container to have ANY handgun, another one for pills like antideps, beta blockers and the likes) and then pick something from those lists. That would also resolve stuff like zombies dropping two pistols, which with the current implementation you cannot prevent (though the chances for it to happen are rare, of course!).

Edited by Tiax
Link to comment
Share on other sites

Well the change could be as simple as adding a lua table instead of a string to the Distribution.

 

Let's go with wallets on inventorymale:

inventorymale = {
  rolls = 1,
  items = {
    ...
    "RiversideMap",0.1,
    "Wallet", 1,
    "Wallet2", 1,
    "Wallet3", 1,
    "Wallet4", 1,
    "Locket", 1,
    ...
  }
},

becomes

inventorymale = {
  rolls = 1,
  items = {
    ...
    "RiversideMap", 0.1,
    { "Wallet", "Wallet2", "Wallet3", "Wallet4" }, 4,
    "Locket", 1,
    ...
  }
},

Type being string/list should be easy to check in the java. If it's string nothing changes, if it's a list pick a string from it at random (all same chance). Wouldn't break anything and open a lot of possibilities. You could now add a thousand wallet types and wouldn't drown in drops :)

Want some wallets to be more common than others? Add them multiple times to the list!

Edited by Tiax
Link to comment
Share on other sites

  • 3 months later...
On 11/27/2020 at 2:51 PM, Tiax said:

...

 

With drop groups introduced to the existing tables, it could (also) roll if a group is "hit"  (think: a drop group for a container to have ANY handgun, another one for pills like antideps, beta blockers and the likes) and then pick something from those lists. That would also resolve stuff like zombies dropping two pistols, which with the current implementation you cannot prevent (though the chances for it to happen are rare, of course!).

Pretty sure you could write a new function for ItemPicker() and remove the increase in chance added by the zombies in the area.

Link to comment
Share on other sites

  • 3 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...