building_spqwnLoot.sqf questions / solutions / discussions

Fentus

Member
Okay, so I've looked at a lot of other people talking about how the code below is whats is causing the bad spawning rates as of (1.7.7.1) & (1.8), has anyone considered rewriting this code from the ground up so its more streamlined / understandable?

Code:
// bias for this building. The lower it is, the lower chance some of the lootpiles will spawn
_bias = 50 max 62;
_bias = 100 min _bias;
_bias = (_bias + (random(100 - _bias)) / 100);
//diag_log (format["SpawnLoot: Positions: %1, guaranteedloot: %3/%2",_positions,_guaranteedspawn,_countPositions]);
//diag_log(format["BIAS:%1 LOOTCHANCE:%2", _bias, _lootChance]);
{
    if (count _x == 3) then {
        _rnd = (random 1) / _bias;
        _iPos = _obj modelToWorld _x;
        _nearBy = nearestObjects [_iPos, ["ReammoBox"], 2];
 
        if (count _nearBy > 0) then {
            _lootChance = _lootChance + 0.05;
        };
 
        if (dayz_currentWeaponHolders < dayz_maxMaxWeaponHolders) then {   
            if (_rnd <= _lootChance) then {
                if (count _nearBy == 0) then {
                    _index = dayz_CBLBase find _type;
                    _weights = dayz_CBLChances select _index;
                    _cntWeights = count _weights;
                    _index = floor(random _cntWeights);
                    _index = _weights select _index;
                    _itemType = _itemTypes select _index;
                    [_itemType select 0, _itemType select 1 , _iPos, 0.0] call spawn_loot;
    //                diag_log (format["SpawnLoot: Pos: %1, LootType: %2/%3,",_iPos,_itemType select 0,_itemType select 1]);
                    dayz_currentWeaponHolders = dayz_currentWeaponHolders +1;
                };
            };
        };
        //sleep 0.002;
    };
} forEach _positions;
 
Okay, so I've looked at a lot of other people talking about how the code below is whats is causing the bad spawning rates as of (1.7.7.1) & (1.8), has anyone considered rewriting this code from the ground up so its more streamlined / understandable?

Code:
// bias for this building. The lower it is, the lower chance some of the lootpiles will spawn
_bias = 50 max 62;
_bias = 100 min _bias;
_bias = (_bias + (random(100 - _bias)) / 100);
//diag_log (format["SpawnLoot: Positions: %1, guaranteedloot: %3/%2",_positions,_guaranteedspawn,_countPositions]);
//diag_log(format["BIAS:%1 LOOTCHANCE:%2", _bias, _lootChance]);
{
    if (count _x == 3) then {
        _rnd = (random 1) / _bias;
        _iPos = _obj modelToWorld _x;
        _nearBy = nearestObjects [_iPos, ["ReammoBox"], 2];
 
        if (count _nearBy > 0) then {
            _lootChance = _lootChance + 0.05;
        };
 
        if (dayz_currentWeaponHolders < dayz_maxMaxWeaponHolders) then { 
            if (_rnd <= _lootChance) then {
                if (count _nearBy == 0) then {
                    _index = dayz_CBLBase find _type;
                    _weights = dayz_CBLChances select _index;
                    _cntWeights = count _weights;
                    _index = floor(random _cntWeights);
                    _index = _weights select _index;
                    _itemType = _itemTypes select _index;
                    [_itemType select 0, _itemType select 1 , _iPos, 0.0] call spawn_loot;
    //                diag_log (format["SpawnLoot: Pos: %1, LootType: %2/%3,",_iPos,_itemType select 0,_itemType select 1]);
                    dayz_currentWeaponHolders = dayz_currentWeaponHolders +1;
                };
            };
        };
        //sleep 0.002;
    };
} forEach _positions;


Swap

Code:
   if (dayz_currentWeaponHolders < dayz_maxMaxWeaponHolders) then { 
            if (_rnd <= _lootChance) then {

To


Code:
   if (_rnd <= _lootChance) then {
              if (dayz_currentWeaponHolders < dayz_maxMaxWeaponHolders) then {
_bias = 50 max 62;
Increase the number 62 if you want more loot to spawn
 
Back
Top