Jump to content

loot probabilities


falcon470

Recommended Posts

so im making a new mod for my freinds to use on our private game, the item does work. It can be looted as well, issue becomes when i look at loot.xml im seeing stuff that i cant account for trying to make it a true 5 percent drop rate. fyi playing with lootable zombies mod and added item in here is a small snipet to showcase my problem lootground medicine no prob on it. scroll up to loot group medcine none there either

 

    <item group="junk" prob="1.5" />
    <item name="backpackRH" prob="0.2" />
    <item name="Ancients" count="1" prob="0.12" />
    <item name="AncientCollections" count="1" prob="0.012" />
    <item group="medicine" />
    <item name="oldCash" count="1,20" prob="0.5" />

 

antoher item to showcase my confusion

    <item name="drinkJarEmpty" count="1,4" />

no prob but i know you get them early game why no prob where is the prob i know they dont always drop from cubboards which is where this is i just dont understand this

Link to comment
Share on other sites

  • 4 weeks later...

This is something I have been bashing my head on too.

Best I can guess is that prob does not have anything at all to do with percentage, but is some sort of weighted chance of it do drop.

For some reason, removing the leading 0 and just have .5 did change how often things dropped when I mucked about with this.

Would be nice if a dev could give a definite answer on this, it seems noone knows just exactly how it calculates loot.

 

Link to comment
Share on other sites

Not a dev, but AFAIK if no probability is specified it is assumed to be "1.0". And all probabilities are summed up and each item drops depending on its fraction of the sum. I.e. if all probabilites sum up to 15 and your item has prob 1.5, then it would drop in 1/10th of all cases, i.e. with a probability of 10%.

 

Link to comment
Share on other sites

It looks like there's a lot of math here. From what I can decipher -

 

there's a base probability template which is used by default. This varies based on gamestage. And then there's weighting, so prob has different meanings in different contexts in the same file.

From what I can gather, a container will have an item count range, and a list of items or groups that may drop from that container. I am not sure if the game rolls for each slot or rolls once and then rolls for how many.  for example
 

lootcontainer id="143" count="1,2" size="8,9" sound_open="UseActions/open_cooler" sound_close="UseActions/close_chest" loot_quality_template="qualBaseTemplate">
	<item name="drinkJarRiverWater" count="1,2"/>
</lootcontainer>


The count should be the range of potential items in the containers, but if there's a probability of .1 as the base for the  gamestage I do not know if it rolls 1d10 twice or if it rolls 1d10 once and then 1d2 to determine how many items. By default I believe it uses the base probability group defined at the top of the loot.xml file unless a different template is defined.
If the base probability roll does pass, then the item to award gets picked from a list. In the above example, there's one item, so it has a 100% chance of dropping 1-2 water jars if it drops 1 item. Looking at a more complex example:
 

<lootcontainer id="141" count="1,3" size="7,2" sound_open="UseActions/open_garbage" sound_close="silencefiller" loot_quality_template="qualBaseTemplate">
	<item name="resourceCloth" count="2,7" prob=".08"/>
	<item group="groupApparelShirtLong" prob=".55"/>
	<item group="groupApparelTankTopTShirt" prob="0.55"/>
</lootcontainer>

So, above we have a potential for 1-3 items to drop from the container, based on the base gamestage probability. If the items had no prob value, there would be a 33% chance for each item to drop. But the items are weighted and the math gets crazy. To determine the probability of the long shirt, we add each probability (where no prob is given, it is assumed to be 1), and then find the percentage of the total.
So, we get .08+.55+.55, or 1.18. Since the shirt is .55, we get .55/1.18, or a 47ish percent chance of getting a long shirt if one item drops.

If we look at the loot group:

 

<lootgroup name="groupApparelShirtLong">
	<item name="apparelLongShirt" mods="dye" mod_chance="0"/>
	<item name="apparelArmyShirt"/>
	<item name="apparelHoodySweatshirt" mods="dye" mod_chance="0"/>
	<item name="apparelSweatshirt" mods="dye" mod_chance="0"/>
	<item name="apparelFlannelShirt" mods="dye" mod_chance="0"/>
</lootgroup>

There is a 20% chance of getting an army shirt if we get a long shirt (1/5).  So, what are the chances of getting an army shirt from that container?
 

	<lootprobtemplate name="baseProbTemplate">
		<loot level="1,100" prob="0.25"/>
		<loot level="101,200" prob="0.5"/>
		<loot level="201,300" prob="0.75"/>
		<loot level="301,999999" prob="1"/>
	</lootprobtemplate>

Let's assume our gamestage is 150.  There is a .5 chance of getting an item (it's actually 1-3 items but let's make the example easier). If an item drops, there is a 47% chance of getting an item from the long shirt group, and there is a 20% chance of getting an army shirt in that group. So, .5*.47*.2 gives us about a 4.7% chance of getting an army shirt from that container.

To the original question: if I wanted zombie X to drop item Y 5% of the time under all circumstances, I'd have to do the following:

Append a new probability group with a constant 5% drop chance:
 

<append xpath="/loot/lootcontainers/lootprobtemplates">
	<lootprobtemplate name="myProbTemplate">
		<loot level="1,999999" prob="0.05"/>
	</lootprobtemplate>
</append>
<append xpath="/loot/lootcontainers/">
  	<lootcontainer id="900" count="1" size="6,2" sound_open="UseActions/open_backpack" sound_close="UseActions/close_backpack" open_time="1.5" loot_quality_template="qualBaseTemplate" loot_prob_template="myProbTemplate"> <!-- I'm pretty sure this will work here. note that the container IDs are fixed, so be careful not to overwrite one -->
      	<item name="myItem"/> 
</lootcontainer>
  

That gives you a 5% drop chance any time that template is called, regardless of game stage. And creates a container that calls that probability template and drops one of the item myItem. If you wanted to have a zombie drop the item 5% of the time, you could either change the prob in the template to 1 and then modify entityclasses.xml to make the desired zombie drop a pack 5% of the time (<property name="LootDropProb" value=".05"/>, modify the LootDropEntityClass property to a new entity class name, then add that entity class in with a LootListOnDeath value of 900 (calling back to the lootcontainer ID). 
-
There's probably a simpler way, and of course you can muck with the probabilities (zombie has 100% chance to drop a backpack with a 5% chance of having loot, etc.). And I'm not 100% on any of this, so ymmv. I welcome corrections.

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...