tommysticks Posted January 20, 2014 Share Posted January 20, 2014 I'm looking for a better explanation for the way that items are distributed in PZ. I've noticed in a few mods (every mod with custom items), including my own, that no matter how low I change the chance of an item being found it is still ridiculously abundant like in this example: table.insert(SuburbsDistributions["all"]["shelves"].items, "tommyguns.Rucksack");table.insert(SuburbsDistributions["all"]["shelves"].items, 0.025); The item Rucksack is still relatively abundant. I suspect that the code in the example does not execute the same way the in-game items do on the distribution list or that it skips over some other code that takes the "0.025" into account. Does anyone know how to properly distribute custom items? Link to comment Share on other sites More sharing options...
NCrawler Posted January 20, 2014 Share Posted January 20, 2014 I've noticed the same thing. I am in the process of rewriting my distributions using the OnFillContainer event. That way I can have complete control of when/where my items spawn. Link to comment Share on other sites More sharing options...
RoboMat Posted January 20, 2014 Share Posted January 20, 2014 RJ added a OnFillContainer event for me some time ago and it allows you to hook into the system. Currently I'm also looking into writing a different system for item spawns (not sure if it will work out though). Afaik the vanilla container dist doesn't take numbers < 1 into account. Link to comment Share on other sites More sharing options...
ExcentriCreation Posted January 20, 2014 Share Posted January 20, 2014 Afaik the vanilla container dist doesn't take numbers < 1 into account. That was my original thought too, but vanilla uses them.... Although they don't go any smaller than 0.1, bedroom = { other = { rolls = 2, items = { "Base.Vest", 5, "Base.Shirt", 4, "Base.Blouse", 5, "Base.Trousers", 5, "Base.Skirt", 7, "Base.Shoes", 7, "Base.Sheet", 9, "Base.Pillow", 9, "Base.Socks", 5, "Base.Belt", 5, "Base.BaseballBat", 2, "Base.Pistol", 0.5, "Base.Bullets9mm", 0.5, "Base.Bullets9mm", 0.5, "Base.Bullets9mm", 0.5, "Base.Bullets9mm", 0.5, "Base.Bullets9mm", 0.5, "Base.Duffelbag", 1, "Base.Schoolbag", 3, "Base.NormalHikingBag", 0.8, "Base.BigHikingBag", 0.5, } } }, After looking at the math in ItemPicker.rollItem in ItemPicker.lua it looks like it could go as low as you want, as long as the result of:((itemNumber*100) * ZomboidGlobals.LootModifier) + (zombieDensity * 10)isn't lower than 1, in which case the item would never spawn Maybe the problem with OP is number of rolls associated with the choice of container? [all] [shelves] will roll 3 times for each item, where as [bedroom] [other] will only roll twice Link to comment Share on other sites More sharing options...
Talksintext Posted January 21, 2014 Share Posted January 21, 2014 Kinda seems like anything under 0.1 reverts to 1 or even higher (10 or 100?). I modded some things that were spawning a bit too much and set them from 0.1 to 0.001, and suddenly they're mass spawning everywhere they can (weren't nearly so bad before). That needs fixing. Some items need to be very rare, but 0.1 isn't really that rare. Link to comment Share on other sites More sharing options...
NCrawler Posted January 21, 2014 Share Posted January 21, 2014 RJ added a OnFillContainer event for me some time ago and it allows you to hook into the system. Currently I'm also looking into writing a different system for item spawns (not sure if it will work out though).Afaik the vanilla container dist doesn't take numbers < 1 into account. When, exactly, does this event fire? Is it during initial game setup? Link to comment Share on other sites More sharing options...
ExcentriCreation Posted January 21, 2014 Share Posted January 21, 2014 (edited) Kinda seems like anything under 0.1 reverts to 1 or even higher (10 or 100?). The EXACT condition from ItemPicker.lua is:if ZombRand(10000) <= ((((itemNumber*100) * ZomboidGlobals.LootModifier) + (zombieDensity * 10))) thenwhere itemNumber = distribution no.ZomboidGlobals.LootModifier = is initially set to 0.6 (I havent had much to do with this, dont know if it changes based on game conditions)zombieDensity = a value based on chunk data which is never 0 & is capped at 8 So for the sake of your example:((0.001*100) * 0.6) + (8*10) = 80.06if ZombRand lands on 80 or lower the item will spawn.... this is at MAXIMUM EDIT:My Bad..... I Overlookedif itemNumber<0 then itemNumber=0.1;endBut this only occurs if the player character is unlucky (the trait unlucky) When, exactly, does this event fire? Is it during initial game setup? Containers are filled when the player walks onto an adjacent gridsquare Edited January 21, 2014 by ExcentriCreation Link to comment Share on other sites More sharing options...
RoboMat Posted January 21, 2014 Share Posted January 21, 2014 RJ added a OnFillContainer event for me some time ago and it allows you to hook into the system. Currently I'm also looking into writing a different system for item spawns (not sure if it will work out though). Afaik the vanilla container dist doesn't take numbers < 1 into account. When, exactly, does this event fire? Is it during initial game setup? Like Excentri said they are loaded on the fly once the player gets close to them ... I wanted to write a item spawner that starts its work when the map is loaded, but cycling through one cell to find all containers causes a pretty big hit on the loading time Link to comment Share on other sites More sharing options...
Talksintext Posted January 22, 2014 Share Posted January 22, 2014 Yeah, I've seen the code. I'm just telling you what's happened in my experience. I set one item to 0.0001. It spawned in the second container I came across, along with 3 or 4 other things that should've never spawned (0.001). When I set these things to 0.1, they almost never spawn. Setting it to lower than 0.1 seems to make it more likely (by a lot) than 0.1. I can't see anywhere in the code that would cause that (even the unlucky part would cap it at 0.1), but it's happening. I'm not an expert in this language, though, so I might be looking right at it and missing it :/ Additionally, if we do want less than 0.1 rarity items (I think it's a must), then the lucky/unlucky part needs to be changed from an absolute increase (+/-1) to a percentage increase (+/-50% or whatever). Link to comment Share on other sites More sharing options...
francogp Posted March 7, 2016 Share Posted March 7, 2016 did someone create a good code for this kind of custom item loot probabilities? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now