Jump to content

[SOLVED] Loot Rarity in Zombies


Typhon

Recommended Posts

Hello,

 

I've been fixing this for a few minutes and I'm not sure if I am correct or not. There isn't any available documentation or detailed explanation on the percentage of the loot drop because whatever I try to set is always a lot still. I'm trying to adjust the rarity of the drops in zombies as an experiment and get into modding PZ.

 

This is what I've written so far and for a total of 20 zombies I kill I get about 5-7 items that I've set. Is the game ignoring the values I've input or is there a limit? Also I've set it to only drop on male zombies because putting the items on both male and female zombies drops a lot.

Distributions = Distributions or {};

-- custom distributions table
local nDistTable = {
    all = {
        inventorymale = {
            rolls = 1,
            items = {
                "Crisps", 0.007,
                "Crisps2", 0.002,
                "Chocolate", 0.002,
                "SunflowerSeeds", 0.002,
                "Peanuts", 0.002,
                "MintCandy", 0.002,
                "Lollipop", 0.002,
            }
        },
    },
}

-- insert
table.insert(Distributions, 1, nDistTable);

-- for mod compat:
SuburbsDistributions = nDistTable;

Above is the first code I've written, the second one below still drops the same amount of items.

require "Items/SuburbsDistributions"

local i;

local nDistTable = {
    "Crisps", 0.007,
    "Crisps2", 0.002,
    "Chocolate", 0.002,
    "SunflowerSeeds", 0.002,
    "Peanuts", 0.002,
    "MintCandy", 0.002,
    "Lollipop", 0.002,
}

for i = 1, #nDistTable, 2 do 
  table.insert(SuburbsDistributions["all"]["inventorymale"].items, nDistTable[i]);
  table.insert(SuburbsDistributions["all"]["inventorymale"].items, nDistTable[i+1]);
end

myDistTable = nil;

Any feedback or suggestions is appreciated and I'd like to improve it more.

Edited by Typhon
Problem solved
Link to comment
Share on other sites

I'm not an expert, but my understanding is that the number is just the relative spawn chance - so Crisps are 3.5 times more likely to be picked that any other item, and your code work the exact same if you used 7 for Crisps, and 2 for everything else.  I don't know how to stop the game spawning so much stuff using the normal system.

 

We had a problem related to this with Hydrocraft - our code was causing more loot from other mods to spawn (we had increased the number of rolls...).  Our solution was to remove the code similar to yours and use the OnZombieDead event ( https://pzwiki.net/wiki/Modding:Lua_Events/OnZombieDead ) to manually spawn what we wanted, this also let us add sandbox settings to give the player control over how much loot they wanted.

Link to comment
Share on other sites

  • Typhon changed the title to [SOLVED] Loot Rarity in Zombies

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...