dayz_lootSpawnBias?

dagg929

Well-Known Member
Anyone played with this?

It's in variables. I've bypassed and upped it from 69 or 67 whatever it was by default to 75, seems to not have made a difference.
 

berupp

New Member
This value seems to be responsible for the horrible spawn in 1.7.7.1

It is used in building_spawnLoot.sqf
Code:
// bias for this building. The lower it is, the lower chance some of the lootpiles will spawn
_bias = 50 max dayz_lootSpawnBias;
_bias = 100 min _bias;
_bias = (_bias + random(100-_bias)) / 100;
//diag_log(format["BIAS:%1 LOOTCHANCE:%2", _bias, _lootChance]);
{
        if (count _x == 3) then {
                _rnd = (random 1) / _bias;
                _iPos = _obj modelToWorld _x;
                if (_rnd <= _lootChance) then {
(random 1) / _bias needs to be lower than 'lootChance' for something to spawn. I am not 100% sure whar random 1 evaluates to but i guess it is a floating point number between 0 and 1.

Example: Lets say dayz_lootSpawnBias is 67 and your average lootChance is 0.4 (as of 1.7.7.1)
Lets further assume that the random expressions evaluate to an average value (e.g. random 1 = 0.5)

_bias = (67 + random ( 100 - 67)) /100 = 0.82 (assuming random 33 evaluates to 15)
_rnd = (random 1) / 0.82 = 0.6 (assuming random 1 evaluates to 0.5)

0.6 <= 0.4 = false => No loot spawn

I personally find this approach to random fairly bad to tweak. It is basically a double RANDOM

I'll test my theory later today by setting dayzlootSpawnBias to 100. This way I will only have one random value (random 1). That makes a lootChance of 0.8 way more comprehensive.
 

dagg929

Well-Known Member
So you think that the higher it is, the less loot spawns? I upped this to 100 on my server and I still have a fair amount spawning, though I did edit most loot chances to at least .7 or .8 It is much better than it was, though I made a /lot/ of tweaks and it may not just be this solely.

Let me know what you think.
 

berupp

New Member
My theory ist that if you up it to 100 the _rnd expression will always be:

_rnd = (random 1) / 1;
Assuming that random 1 evaluates to a floating point between 0 and 1. I will basicall have 0.4 /1 = 0.4 or 0.93/1= 0.93.

Now with that it seems to be way easier to adjust lootChance values in CfgBuildingLoot.hpp and CfgBuildingPos.hpp to actually reflect a % value. e.g. 0.8 will actuall be 80% (since random 1 will have and 80% chance to be <=0.8)
Whereas the double random (lower bias value) means that 0.8 is not 80% but a value RELATIVE to you bias value
 

berupp

New Member
Just for anyone who will come across this and wants to know the loot mechanic in 1.7.7.1:

My above assumptions where correct. Setting dayz_lootSpawnBias to 100 will allow you to ignore this value for the loot spawn chance calculation, and focus on 'lootChance' for loot categories and building classes in CfgBuildingLoot.hpp and CfgBuildingPos.hpp.

Note: A 'lootChance' value set in CfgBuildingPos.hpp will overwrite the value set for the loot category configured in CfgBuildingLoot.hpp

Example:
CfgBuildingPos.hpp defines a building class Land_a_stationhouse with the loot category 'Military"
Code:
class Land_a_stationhouse: Military {
    lootChance = 0.3;
    lootPos[] = {{-2.69922,-7.57422,-9.46057}, ....
};
This sets the lootChance for loot piles in a Firestation to 30%. Meaning 30% of the available lootPositions will be populated.

Now in CfgBuildingLoot.hpp you can specify a 'lootChance' for a loot category.
Code:
class Military: Default {
                zombieChance = 0.3;
                maxRoaming = 6;
                zombieClass[] = {"z_soldier","z_soldier_heavy","z_policeman"};
                lootChance = 0.9;
                lootPos[] = {};
                lootType[] = {
                        {"M9","weapon",0.05},
                        .....
Sets the spawn chance for military loot to 90%.

Result: The effective lootChance in a firestation will be 30%. Remove the 'lootChance' entry from CfgBuildingPos.hpp and your loot chance in Firestations will increase to 90%.
 
Top