7 Days to Die

7 Days to Die

View Stats:
Bromulus Dec 2, 2016 @ 5:31am
Loot Language
I suppose I'd like to see if I am warm on this.

<!-- lootcontainer 73 ZombieSoldier loot --> -<lootcontainer count="1,3" loot_quality_template="baseTemplate" sound_close="UseActions/close_corpse" sound_open="UseActions/open_corpse" size="4,4" id="73" destroy_on_close="false"> <item prob="2" group="junk"/> <item prob="1" group="militaryguns+ammo"/> <item prob="0.3" group="rocketLauncher+ammo"/> <item prob="1" group="militaryArmor"/> <item name="nightvisionGoggles" prob="0.3"/> </lootcontainer>

The loot containers "count" is the random roll span that determines the "count roll". This is the amount of times to perform an "item check roll" against the containers designated item list.

(1) Perform the count roll.

(2) If the count roll result is a zero (and allowed to be a zero) then you check the item list zero times. The container is empty buh buh now. Go directly to (8) - (Though we all know that in reality (virtual reality?) this never ever happens in game ever never). :steamhappy: -- If the count roll result is one or higher go to (3).

(3) Perform an item check roll (1dTotalNumberofListItems) against it's list of items.
Each listed item (names or groups) has an equal chance of being selected. In the above example each list item has an initial 1d5 chance of being picked.

(4) Check the selected (result of the above item check roll) item to see if it has a "prob" value. If it does not then go to (5), if the item does have a "prob" value then go to (6)

(5) The selected item is in the container. Congratulations you've won a prize! (well, unless your prize is a group, then you should still hold your breath, but that's another story). Go to (7).

(6) A secondary percentage roll is made against the items probability. If the percentage roll scores equal to or under the prob percentage then it is a hit and that item is once and for all selected. Congratulations you've won a prize! If that percentage roll misses, then the item is not selected, that check fails, one potentially occupied slot in the container is deemed empty. Either way go to (7)

(7) This concludes the item check roll. If there are remaining item check rolls then go to (3) until the initial count roll of item check rolls has been completed. If completed go to (8).

(8) Done and done.
Last edited by Bromulus; Dec 2, 2016 @ 5:38am
< >
Showing 1-15 of 30 comments
Bromulus Dec 2, 2016 @ 5:40am 
A secondary independent question I have, is in the OP code example, what is happening when you assign a number greater than zero to prob. That is hurting my head. I assume when you have no prob value then you have a 1 in X (X being the number of items in the list) of being selected. But what happens when the prob value is a 2 or a 3? Or even a 1?

Taking a stab does this mean if/when that item is lucky enough to be selected from the list then it automatically places X (item prob="X") of said item in the container?
But what if said item is part of a group, then does that mean a prob greater than zero ignores subsequent prob values in its subtree, or perhaps it means it rolls again that many times? Cornfused on this.
Last edited by Bromulus; Dec 2, 2016 @ 6:04am
Valmar Dec 3, 2016 @ 10:39am 
-<lootcontainer count="1,3" loot_quality_template="baseTemplate" sound_close="UseActions/close_corpse" sound_open="UseActions/open_corpse" size="4,4" id="73" destroy_on_close="false">

<item prob="2" group="junk"/>

<item prob="1" group="militaryguns+ammo"/>

<item prob="0.3" group="rocketLauncher+ammo"/>

<item prob="1" group="militaryArmor"/>

<item name="nightvisionGoggles" prob="0.3"/>

</lootcontainer>


What this code says is that the container (in this case zombie) will drop between 1-3 items in the list.

Probability just means what are the odds of that specific item or group being chosen. Default is "1", far as I know. But its a bit of a mess to figure out the "real" probability since everything gets factored together to form a sum total of 100%, from my understanding. The easiest way to do it, in my experience, is to add a prob value to all of them and have the sum total of all values combined equal 1.

Example:
<lootgroup name="lockerGood">
<item group="ammo" prob="0.6"/>
<item group="pumpshotgun+ammo" prob="0.1"/>
<item group="medicine" prob="0.3"/>
</lootgroup>

In this group when it is called on it will have a 60% chance to spawn ammo group, a 10% chance to spawn from the pumpshotgun+ammo group and a 30% chance to spawn medicine group. I can be certain of these values because if I combine the values all together they add up to 1. This makes it easier to manage and make precise settings.

Even if all the probs are set to 0 the container will still choose one of them if the container has a count of minimum 1. If that makes sense.
Bromulus Dec 4, 2016 @ 6:01pm 
OK I am going to get fiesty here... Believe it or not I think it is actually happening the way I described, based on the fact (as you mentioned) the vanilla code probabilities rarely (never) add up to 1 or 100% and some of my initial testing.

As I described, I think the list of items all have an equal chance of coming up, this is to say the first "item check" roll doesnt look at prob values, it just randomly picks one of the listed items, all with an equal chance of popping. Above example would be every item has a 1 in 5 chance.

Then if the randomly chosen item happens to have a prob value, then and only then it performs a secondary roll, against the prob value, to see if that (usually rarer) item actually pops up.

This is how a lot of pen and paper RPG's handle treasure lists. They want rare items to be on general treasure lists but they want them to have an even rarer chance of actually appearing, hence the secondary roll if its selected.

And again the "count" is an intially generated random amount of times the list is checked for that container.

Of course feel free to call me completely crazy on this.

Last edited by Bromulus; Dec 4, 2016 @ 6:14pm
Valmar Dec 4, 2016 @ 8:03pm 
Someone actually made a "probability calculator" for 7DTD once. Might be worth checking that out, could provide some insight on how everything is being handled.

https://7daystodie.com/forums/showthread.php?37658-Loot-Probability-Viewer&highlight=loot
Bromulus Dec 4, 2016 @ 11:22pm 
Cool.

Yeah I definitely don't claim to know how to figure the mathmetical percentage chances of an item popping, especially, as the creator noted, when it chooses groups from the list that are in groups that are in group each with their own lists and items with further subset prob values. That is a noble effort, wow.

Pretty sure I am grasping how it it is rolling/functioning though.

My assesment is still chugging along on the placement of the loot containers blocks as well, like these sections:
<!-- Replace the lootPlains with one of the following --> <placeholder name="lootPlains"> <block name="cntTrashPile01" prob="0.1"/> <block name="cntTrashPile02" prob="0.1"/> <block name="cntTrashPile03" prob="0.1"/> <block name="cntTrashPile04" prob="0.1"/> <block name="cntTrashPile05" prob="0.1"/> <block name="cntTrashPile06" prob="0.1"/> <block name="cntTrashPile07" prob="0.1"/> <block name="cntTrashPile08" prob="0.1"/> <block name="cntTrashPile09" prob="0.1"/> <block name="cntBackpack01" prob="0.03"/> <block name="cntBackpack02" prob="0.03"/> <block name="cntBackpack03" prob="0.03"/> <block name="cntDuffle01" prob="0.03"/> <block name="cntSportsBag01" prob="0.03"/> <block name="cntSportsBag02" prob="0.03"/> <block name="cntPurse01" prob="0.03"/> </placeholder>

Note the values don't add up to 1 as usual. I think as a spot is marked (a separate random "map" gen i'm sure) to have a "possible" lootPlains placeholder on the map it triggers this. Then this rolls 1d16 for it's item list.

When it lands on 1 of the 16 choices (all having a 1 in 16 chance) then it reads the prob value of it's selection and rolls an additional/separate roll, a percintile check, against it. If the percintle is <= the prob value then that item appears. Or if initial item selected was a group, and the prob passes, then it sends it to that group for a further check (with possibly further prob values to consider if selected)

If the 1 thru 16 choice doesnt pass a prob check (all items in the example have a prob check), then it places nothing. Which is why an area may seems sparse.

<lootgroup name="rareOres"> <!-- 907 average --> <item name="silverNugget" count="1,4"/> <!-- 250 --> <item name="goldNugget" count="1,3" prob=".3"/> <!-- 700 --> <item name="rawDiamond" count="1,2" prob=".1"/> <!-- 1500 --> </lootgroup>

So applied to this one, my guess is that if you do get lucky enough to discover rareOre (I'm sure a low prob in itself) you will find far more silverNuggets and Nothings/Empty Slots than you would ever see gold or diamond. Because even though they all have an equal chance of being found (1d3) at first, if it lands on the gold or diamond an additional roll is happening with only a 30% chance for gold and 10% chance for diamond to appear instead of nothing appearing at all for that item (aka percentil check fails against that items prob value).

In general the process is a way to have different types of loot equally "in the running" for a container (thematically appropriate item appear in/on appropriate containers/bodies) but still control the rarity of certian (or in loot placeholders case "all") items within that list to a much finer degree than it's initial selection odds.

...I think.
Last edited by Bromulus; Dec 4, 2016 @ 11:35pm
Valmar Dec 5, 2016 @ 9:51am 
Originally posted by Bromulus:
<lootgroup name="rareOres"> <!-- 907 average --> <item name="silverNugget" count="1,4"/> <!-- 250 --> <item name="goldNugget" count="1,3" prob=".3"/> <!-- 700 --> <item name="rawDiamond" count="1,2" prob=".1"/> <!-- 1500 --> </lootgroup>

So applied to this one, my guess is that if you do get lucky enough to discover rareOre (I'm sure a low prob in itself) you will find far more silverNuggets and Nothings/Empty Slots than you would ever see gold or diamond. Because even though they all have an equal chance of being found (1d3) at first, if it lands on the gold or diamond an additional roll is happening with only a 30% chance for gold and 10% chance for diamond to appear instead of nothing appearing at all for that item (aka percentil check fails against that items prob value).

The way I read that:

If your container rolls the rareOre group you have a 30% chance ot get gold, 10% chance to get diamond and 60% chance to get silver. You will never get nothing - you will always get one of those - unless the count of that group in the container is manually set to have a minimum of 0.
Bromulus Dec 8, 2016 @ 1:45pm 
Not how I read it believe it or not.

I have this as two separate and distinct rolls on the items.

First roll is just equally random chance between all items listed, 1d3, ignores prob value all together.

Once it selects an item then it looks to see if that item has a prob value. If it does then it performs a secondary roll... if that roll is a hit the item pops, if not that selected item, with the secondary prob (rarity) value is not there after all.

We see containers with a minimum of 1 produce zero results all the time. The prob value percentages rarely add up to 1/100% even with non-prob value items absorbing the remainder. This would be (is in pen&paper games) a good way to have a rare item or rare item group have an equal chance of being a possibility in a container, but then if it is selected a still further chance you didn't find it anyway. A more refined loot frequency control.

Just a theory.
Last edited by Bromulus; Dec 8, 2016 @ 1:49pm
Valmar Dec 8, 2016 @ 2:11pm 
Name me one container that has a minimum of 1 but can produce zero results.
Bromulus Dec 8, 2016 @ 3:49pm 
off hand (xml not in front of me) cars, night stands, backpacks, shopping carts.

But remember, as i posted earlier on this, my "if the secondary roll fails its a zero" is a theoritcal part of my theory. :) While I truly believe how i describe the item checker flow is probable, I am not sure what happens if that secondary prob value roll fails. I assumed zero because of all the empty containers I find (especially cars). But it might not work that way, if it fails it may immediately roll again until it gets a hit or something, but that doesnt explain all the empties. And I see alot.

Also remember I am testing this with no perks or modified skills and typically on day 1.

Also per my original post while "working this out" I'm still baffled (as are most based on response) by what a prob value of more than "1" would to my (anyone's) theory.
Last edited by Bromulus; Dec 8, 2016 @ 3:56pm
Valmar Dec 8, 2016 @ 4:51pm 
Let me explain why it happens for cars. This is the container:

<!-- lootcontainer 19 cars-->
<lootcontainer id="19" count="1" size="7,4" sound_open="UseActions/open_vehicle" sound_close="UseActions/close_vehicle" open_time="4" loot_quality_template="baseTemplate">
<item group="automotive+tools+junk"/>
<item name="miningHelmet" prob="0.035"/>
</lootcontainer>

Now you see that and you think "okay, it will never be empty". But that isnt true because you have to look at the group it can all on. Check out automotive tools and junk.

<lootgroup name="automotive+tools+junk" count="0,2">
<item group="junk" prob="1"/>
<item group="automotive" prob="0.21"/>
<item group="tools" prob="0.21"/>
</lootgroup>

As you can see the group itself can be told to drop nothing. So even though the container will always grab it or the mining helmet, even if it does pull from the automotive group that group itself does not always reward an item as its minimum is 0.


Are you sure those others can actually be empty?

For what its worth my mod relies on a minimum count of 1 always being 1 and I have NEVER had the class cases spawn nothing - which would be impossible if it is as you say and it doesn't adhere to the count number.

Its is my experience that if a container has a minimum count of 1 then it will never, ever be empty unless it calls on a group that can be empty.
Last edited by Valmar; Dec 8, 2016 @ 6:42pm
Bromulus Dec 8, 2016 @ 6:29pm 
Originally posted by Valmar:
Let me explain why it happens for cars. This is the container:

<!-- lootcontainer 19 cars-->
<lootcontainer id="19" count="1" size="7,4" sound_open="UseActions/open_vehicle" sound_close="UseActions/close_vehicle" open_time="4" loot_quality_template="baseTemplate">
<item group="automotive+tools+junk"/>
<item name="miningHelmet" prob="0.035"/>
</lootcontainer>

Now you see that and you think "okay, it will never be empty". But that isnt true because you have to look at the group it can all on. Check out automotive tools and junk.

<lootgroup name="automotive+tools+junk" count="0,2">
<item group="junk" prob="1"/>
<item group="automotive" prob="0.21"/>
<item group="tools" prob="0.21"/>
</lootgroup>

As you can see the group itself can be told to drop nothing.

I completely understand that is one way the car results in an empty. I believe it is additionally happening as i described. For example it picks automotive from the list, doing its secondary prob check, rolls percentiles, gets a 22% or higher and renders the automotive group a zero without ever leaving the initial list to check its sub group. I find a lot of empty cars.

Originally posted by Valmar:
Are you sure those others can actually be empty?

Constantly under the game level circumstances I mentioned.

Originally posted by Valmar:
For what its worth my mod relies on a minimum count of 1 always being 1 and I have NEVER had the class cases spawn nothing - which would be possible if it is as you say and it doesn't adhere to the count number.

I think you may have meant "impossible", otherwise I am misunderstanding, regardless I am saying it surely adheres to the count number, but that that count number just means how many times to check the list, not how many items mandatorily appear. To me count "1" means check your list one time, with many opportunities for that 1 check to result in zero items, depending on everything from prob value to sub group counts and their subsequent prob values.

If your findings are more accurate than mine, I again may be wrong on what the script does after a failed "secondary" prob value check. It may be a re-roll until you get a hit.

However that doesn't explain my plethora of empty backpacks and night stands.... or why "1.5" would ever be a valid prob value.

Good stuff by the way. :)

Last edited by Bromulus; Dec 8, 2016 @ 6:48pm
Valmar Dec 8, 2016 @ 6:43pm 
Correct, did mean "impossible". Stupid typos!
Bromulus Dec 8, 2016 @ 6:47pm 
Originally posted by Valmar:
Correct, did mean "impossible". Stupid typos!

Just wanted to show you how closely I was following along.
Bromulus Dec 14, 2016 @ 10:20pm 
So I think I found a little more juice behind my theory of the separate and distinct rolls.

In the loot file is this block and comments:

<!-- This generates items with Quality Levels based on the player's level and skills / perks. --> <!-- Level is the percentage to Max Level for the player. Max level is found in progression.xml --> <!-- The list is worked from the top. If you get a hit, the associated QL is generated. --> <!-- If there is no hit the default quality is used. --> <!-- AFTER you have a QL, the QL of your scavenging skill / perk is added straight so once you have 150 in skills/perks you will never find an item lower than that. --> <lootqualitytemplates> <lootqualitytemplate name="baseTemplate"> <qualitytemplate level="0,.16" default_quality="1,100"> <loot quality="301,600" prob=".01"/> <loot quality="201,300" prob=".05"/> <loot quality="101,200" prob=".15"/> <loot quality="1,100" prob="1"/> </qualitytemplate>

I believe the fact that they say "If you get a hit" indicates I was on the right track.

Looking at this list, you wouldn't say "if" you get a hit if those prob values affected the first roll, you would simply definitley get a hit period, no ifs ands or buts. And most likely the "1,100", but if it landed on a 301,600 by chance then you would get that one. A hit no matter what. You cant miss. No ifs.

However, if I'm right, then you could indeed get a miss. You would roll through this list with a 1d4, all line items having an equal chance, completely ignoring the prob value. Then if you landed on say "loot quality="301,600" - you would then and only then perform your probability roll, percentiles, and if you did not meet .01 then its a fail, not a hit, which means you got nothing on the list. Which means you can rightly look at this list and say "if" you get a hit, because you could get a miss if you land on a line with a prob value and fail its separate and distinct probability roll.
Last edited by Bromulus; Dec 14, 2016 @ 10:25pm
Valmar Dec 14, 2016 @ 10:45pm 
Its not possible for a container with a minimum of 1 to give you nothing. I've literally NEVER had that happen before and a big part of my mod functions off of that aspect in terms of my character classes. If the container has a count of "1" then it will always, no matter what, give you something unless you provide a group in the container which itself is empty or has an empty option.

I don't see how you idea can be consistant with that observation.
< >
Showing 1-15 of 30 comments
Per page: 1530 50

Date Posted: Dec 2, 2016 @ 5:31am
Posts: 30