• If you have a mod, tool or prefab, please use the Resources section. Click Mods at the top of the forums.

Loot Probability

issa

New member
Hello everyone, I'm currently working on a mod that enables a player to loot zombies. To add for immersion, I added the ability to define loot by a specific zombie such as a nurse, cop, soldier, utlility worker, etc...

Now I have the following loot group:

 

<lootgroup name="ZEDRegularPackContainer" count="1,6">
<item name="oldCash" count="1,10" prob="1"/>
<item name="casinoCoin" count="1,10" prob="0.85"/>
<item name="resourceLockPick" count="1,3" prob="0.63"/>
</lootgroup>
Basically, a few items a zombie can drop with a specified probability.
 
Code:
	<lootgroup name="ZEDNursePackContainer" count="1,3">
		<item name="drugAntibiotics"  count="1" prob="0.50"/>
		<item name="drugPainkillers"  count="1" prob="0.40"/>
		<item name="drugRockBusters"  count="1" prob="0.40"/>
		<item name="drugSteroids"  count="1" prob="0.45"/>
		<item name="drugVitamins"  count="1" prob="0.55"/>
		<item name="medicalBandage"  count="1" prob="0.85"/>
		<item name="medicalBloodBag"  count="1" prob="0.45"/>
		<item name="medicalFirstAidBandage"  count="1" prob="0.65"/>
		<item name="medicalFirstAidKit"  count="1" prob="0.45"/>
		<item name="medicalPlasterCast"  count="1" prob="0.50"/>
		<item name="medicalSplint"  count="1" prob="0.35"/>
	</lootgroup>

Here is a loot group specifically for nurse zombies. I have added both containers into one also with a specified probability. To explain, regular zombies should have a very minimal chance to also drop medical supplies but it's a small percentage.

For some reason, that's ignored entirely since I tested killing a nurse and it didn't drop medical supplies even though the probability was set to "1".

<lootgroup name="ZEDRegularPackUtility">
<item group="ZEDRegularPackContainer" count="1" prob="1"/>
<item group="ZEDNursePackContainer" count="1" prob="0.15"/>
</lootgroup>




Any help would be appreciated!
 
Code:
	<lootgroup name="ZEDRegularPackUtility"  count="all">
		<item group="ZEDRegularPackContainer" count="1" prob="1"/>
		<item group="ZEDNursePackContainer" count="1" prob="0.15"/>
	</lootgroup>
So it would have a chance to drop both, rather than either or?

 
Any help would be appreciated!


Also, 1 is not a guarantee.  prob = # / total.  So for RegularPack your probability is 1 / (1+0.15) = 0.87

And look how you set your probability numbers.  The regular pack has the prob=1 while the specialized nurse pack is set at 0.15

 
Last edited by a moderator:
<lootgroup name="ZEDRegularPackUtility" count="all">
<item group="ZEDRegularPackContainer" count="1" loot_prob_template="low"/>
<item group="ZEDNursePackContainer" count="1" loot_prob_template="guaranteed"/>
</lootgroup>



Would be a straightforward way. It would always drop the Nurse bag list, with a 20% chance to drop the regular bag list as well.

*edit* I think I read that wrong and swapped the values. So just swap the guaranteed and low to have the drop you described. The Nurse reference is what is throwing things off here, I think.

 
Last edited by a moderator:
Hello, I appreciate the responses and clarification. Is it possible to include my own probabilities for loot_prob_template?

My original way of using them for probabilities wasn't working out well

Code:
<config>
  
  <append xpath="lootcontainers/lootprobtemplate">
    	<lootprobtemplate name="CustomNameHere">
		<loot level="1,999999" prob=".02"/>
	</lootprobtemplate>
    
    	<lootprobtemplate name="CustomNameHere02">
		<loot level="1,999999" prob=".05"/>
	</lootprobtemplate>
    
    	<lootprobtemplate name="CustomNameHere03">
		<loot level="1,999999" prob="1"/>
	</lootprobtemplate>
  </append>
  
  	<lootgroup name="ZEDRegularPackUtility"  count="all">
		<item group="ZEDRegularPackContainer" count="1" loot_prob_template="CustomNameHere"/>
		<item group="ZEDNursePackContainer" count="1" loot_prob_template="CustomNameHere03"/>
	</lootgroup>
  
</config>
 
Last edited by a moderator:
So it would have a chance to drop both, rather than either or?
So yes, I think for immersion reasons, there is a chance you might encounter a zombie who is carrying medical supplies. I want the ZEDRegularPack to always drop on zombies that are not nurses/doctors while still pertaining a small chance to drop it anyway. To clarify, I have loot groups for nurses, burnt, cop, soldiers, utility workers, and hazmat zombies. So basically, soldiers always drop the ZEDSoldierPack while also having better chances of dropping the ZEDNursePack and ZEDRegularPack.

Code:
	<lootgroup name="ZEDRegularPackUtility" count="all">
		<item group="ZEDRegularPackContainer" count="1" loot_prob_template="guaranteed"/>
		<item group="ZEDNursePackContainer" count="1" loot_prob_template="low"/>
		<item group="ZEDConstructorPackContainer" count="1" loot_prob_template="veryLow"/>
		<item group="ZEDPolicePackContainer" count="1" loot_prob_template="veryLow"/>
		<item group="ZEDSoldierPackContainer" count="1" loot_prob_template="veryLow"/>
		<item group="ZEDBurntPackContainer" count="1" loot_prob_template="med"/>
	</lootgroup>
 
Update: According to the code, we have two scenarios. If we add the count="all" to the loot group, it will drop a bit of each container regardless of probability. If we remove it, it will randomly drop one of the containers regardless of the guaranteed probability. This is weird and also interesting.

<lootgroup name="ZEDNursePackUtility">
<item group="ZEDNursePackContainer" count="1" loot_prob_template="guaranteed"/>
<item group="ZEDRegularPackContainer" count="1" loot_prob_template="high"/>
<item group="ZEDConstructorPackContainer" count="1" loot_prob_template="veryLow"/>
<item group="ZEDPolicePackContainer" count="1" loot_prob_template="veryLow"/>
<item group="ZEDSoldierPackContainer" count="1" loot_prob_template="veryLow"/>
<item group="ZEDBurntPackContainer" count="1" loot_prob_template="med"/>
</lootgroup>




image.png

 
Look at the crates as reference:

Working stiffs crate

<lootgroup name="groupWorkingStiffsCrate" count="all">
    <item group="groupWorkingStiffs01" count="1"/>
    <item group="groupWorkingStiffs02" loot_prob_template="medHigh" force_prob="true"/>
    <item group="groupWorkingStiffs03" loot_prob_template="low" force_prob="true"/>
    <item group="groupWorkingStiffs04" loot_prob_template="low" force_prob="true"/>
</lootgroup>




So when you loot the crate, the following is going to happen:

the lootgrooup is set to count="all".  This means each group has a chance to spawn something in.

  • groupWorkingStiffs01 is guaranteed to spawn in (no probability set, count="1")
  • groupWorkingStiffs02 is medHigh (63%)
  • groupWorkingStiffs03 and 04 are low (20%)
 
Look at the crates as reference:

Working stiffs crate

<lootgroup name="groupWorkingStiffsCrate" count="all">
    <item group="groupWorkingStiffs01" count="1"/>
    <item group="groupWorkingStiffs02" loot_prob_template="medHigh" force_prob="true"/>
    <item group="groupWorkingStiffs03" loot_prob_template="low" force_prob="true"/>
    <item group="groupWorkingStiffs04" loot_prob_template="low" force_prob="true"/>
</lootgroup>




So when you loot the crate, the following is going to happen:

the lootgrooup is set to count="all".  This means each group has a chance to spawn something in.

  • groupWorkingStiffs01 is guaranteed to spawn in (no probability set, count="1")
  • groupWorkingStiffs02 is medHigh (63%)
  • groupWorkingStiffs03 and 04 are low (20%)


The weird part in my following is, if I set the count="all" in my loot group, it always drops something from each container. Is it likely because I do not have force_prob?

 
The weird part in my following is, if I set the count="all" in my loot group, it always drops something from each container. Is it likely because I do not have force_prob?


That's my thought process.  Try adding the force probability attribute to your groups and see if that straightens it out.

 
That's my thought process.  Try adding the force probability attribute to your groups and see if that straightens it out.


Interesting result. Forcing probability on items causes no items to drop at all. So I applied the force probability attribute to the containers while keeping guaranteed containers at count=1 with no probability. The result is working as intended. However, the probability percentage is still a little unbalanced so I'll work on customized probability templates. For anyone stumbling across this post looking to achieve that, I attached my code example below.

Code:
<append xpath="/lootcontainers/lootprobtemplates">
  	<lootprobtemplate name="YourTemplateName">
		<loot level="1,999999" prob="Your Probability Here. Example: .02 (2%)"/>
	</lootprobtemplate>
</append>
 
Last edited by a moderator:
Back
Top