[Tutorial] Custom Loot Tables and Adjusting Spawn Rates

Hey could you take a look at my mission PBO? All I have been getting is WAIT FOR HOST... all my other scripts work, but this seems to hang my server :S

FILE: http://www.quez.ca/dayz_1.chernarus.pbo

Thanks dude

The init.sqf looks fine, though you do have a couple of errors in two other files.
zombie_generate.sqf
Line 59 and line 90 both have configfile calls that need changed to missionconfigfile.

variables.sqf
Line 456 also has a configfile than needs changed to missionconfigfile.
 
The init.sqf looks fine, though you do have a couple of errors in two other files.
zombie_generate.sqf
Line 59 and line 90 both have configfile calls that need changed to missionconfigfile.

variables.sqf
Line 456 also has a configfile than needs changed to missionconfigfile.

I'll try again but im pretty sure the first time I tried I had it all edited to missionconfigfile just read somehwere here that you didnt need to edit all of em or something xD well i'll give it a go.

Does caps on letters count like missionconfigfile ir missionconfigFile or missionConfigFile
 
I'll try again but im pretty sure the first time I tried I had it all edited to missionconfigfile just read somehwere here that you didnt need to edit all of em or something xD well i'll give it a go.

Does caps on letters count like missionconfigfile ir missionconfigFile or missionConfigFile

No you don't have to edit ALL of them, but you do need to edit all of the ones that point to the files you've moved. Those lines I mentioned are for files that need the line changed. CfgBuildingLoot and CfgLoot. I don't think they are case sensitive.
 
No you don't have to edit ALL of them, but you do need to edit all of the ones that point to the files you've moved. Those lines I mentioned are for files that need the line changed. CfgBuildingLoot and CfgLoot. I don't think they are case sensitive.

Well here is my latest update to it (different name, MISSION.pbo just for example here) and still no go, my server hangs at WAIT FOR HOST :(

FILE: http://www.quez.ca/MISSION.pbo
 
Well here is my latest update to it (different name, MISSION.pbo just for example here) and still no go, my server hangs at WAIT FOR HOST :(

FILE: http://www.quez.ca/MISSION.pbo

What map is that supposed to be running?
Your mission.sqm is calling quite a large number of addons that I don't recognise and when I get the Wait For Host message, it's actually the server crashing and restarting because it can't find the addons.
 
Well I dont know if you know Epoch, but the init is always in the main .pbo , however what do you mean by compiles being loaded too late? The original .pbo we got from our server host (with some mods preinstalled) looks the same in case of the init compile initialisation.

However, you do seem to have a good understanding of these things, do you think you can help me via TS or sth.?

 
Well I dont know if you know Epoch, but the init is always in the main .pbo , however what do you mean by compiles being loaded too late? The original .pbo we got from our server host (with some mods preinstalled) looks the same in case of the init compile initialisation.

However, you do seem to have a good understanding of these things, do you think you can help me via TS or sth.?

Yeah the init should always be in the main pbo, but in the root of it. Yours is inside a folder. I don't run, Epoch, but I do have Epoch server files from when I was messing around with it and my init is in the root of my mission folder for that too.

If the line and file are where they were from your server host then it may not be that at fault, but I don't currently have an Epoch test server configured to try loading it up and seeing what causes it and I'm about to leave for the day.
 
What map is that supposed to be running?
Your mission.sqm is calling quite a large number of addons that I don't recognise and when I get the Wait For Host message, it's actually the server crashing and restarting because it can't find the addons.

It's running Cherno I only changed the name of PBO to avoid confusion with the other one I shared before. Also if I remvoe EVERYTHING related to custom loot editing from this thread it works. It really is this custom loot thing not working everything else works with no errors in RPT. Only when I place this custom loot thing I get problems.

Basically everything worked before I tried to add the Custom Loot tables
PS: The mission.sqm file has custom buildings in it that's what it's calling but that always worked before this like I said.

EDIT: I tried using the default mission.sqm (without my custom buildings) same problem. I really don't get it. I usually have no problems adding scripts and edits, but this one really has me scratching my head...
 
It's running Cherno I only changed the name of PBO to avoid confusion with the other one I shared before. Also if I remvoe EVERYTHING related to custom loot editing from this thread it works. It really is this custom loot thing not working everything else works with no errors in RPT. Only when I place this custom loot thing I get problems.

Basically everything worked before I tried to add the Custom Loot tables
PS: The mission.sqm file has custom buildings in it that's what it's calling but that always worked before this like I said.

EDIT: I tried using the default mission.sqm (without my custom buildings) same problem. I really don't get it. I usually have no problems adding scripts and edits, but this one really has me scratching my head...


Ah ok that explains why I couldn't get the server to run. Sadly it means I can't actually test it locally to see any errors it's popping up.
I'll try taking another look through your code and see if I missed anything.
 
Ah ok that explains why I couldn't get the server to run. Sadly it means I can't actually test it locally to see any errors it's popping up.
I'll try taking another look through your code and see if I missed anything.

Ah thanks for all the replies man. I really appreciate it. You know I tested with a DEFAULT mission.sqm and it still did not work. Can you take my mission.PBO and replace the mission.sqm with a default 1.8 mission like I did so it makes it easier for you? Or I can provide a PBO that has a default mission.sqm inside
 
Ah thanks for all the replies man. I really appreciate it. You know I tested with a DEFAULT mission.sqm and it still did not work. Can you take my mission.PBO and replace the mission.sqm with a default 1.8 mission like I did so it makes it easier for you? Or I can provide a PBO that has a default mission.sqm inside

Haha, can tell my brain is shutting down for the night I didn't even think of that. Yeah I'll do that and see what I get.
 
Oh man, I'm sorry I know straight away what the problem is haha. I've only set them up once on 1.8 so far so totally forgot about the new folder you need.
In dayz_code\configs\cfgloot\
You want to copy the "BuildingLoot" folder to the root of your mission file.
 
So what's the go on decreasing the loot spawn bias in 1.8?
I've uncommented line 15 in building_spawnLoot.sqf and moved that .sqf to the fixes folder along with compiles, variables etc., but the loot still is in over-abundance. Am I missing something here? Any help would be appreciated. Thanks in advance.

Code:
private ["_lootChance","_index","_weights","_cntWeights","_itemType","_qty","_rnd","_iPos","_obj","_type","_config","_pos","_itemTypes","_positions","_bias"];
 
_obj = _this;
_type = typeOf _obj;
_config = configFile >> "CfgBuildingLoot" >> _type;
_pos = [] + getArray (_config >> "lootPos");
_itemTypes = [] + getArray (_config >> "lootType");
_lootChance = getNumber (_config >> "lootChance");
//_countPositions = count _pos;
_qty = 0; // effective quantity of spawned weaponholder
_lootSpawnBias = 67; //67 between 50 and 100. The lower it is, the lower chance some of the lootpiles will spawn
 
 
// shuffles an array
// parameters: array
// example: _myrandomarray = _myNormalArray call _ShuffleArray;
ShuffleArray = {
    private ["_ar","_rand_array","_rand"];
    _ar = _this;
    _rand_array = [];
    while {count _ar > 0} do {
        _rand = (count _ar);
        _rand = floor (random _rand);
        _rand_array set [count _rand_array, _ar select _rand];
        _ar set [_rand, "randarray_del"];
        _ar = _ar - ["randarray_del"];
    };
    _rand_array;
};
_positions = _pos call ShuffleArray;
 
// 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;
 
dayz_currentWeaponHolders;
 
So what's the go on decreasing the loot spawn bias in 1.8?
I've uncommented line 15 in building_spawnLoot.sqf and moved that .sqf to the fixes folder along with compiles, variables etc., but the loot still is in over-abundance. Am I missing something here? Any help would be appreciated. Thanks in advance.

Code:
private ["_lootChance","_index","_weights","_cntWeights","_itemType","_qty","_rnd","_iPos","_obj","_type","_config","_pos","_itemTypes","_positions","_bias"];
 
_obj = _this;
_type = typeOf _obj;
_config = configFile >> "CfgBuildingLoot" >> _type;
_pos = [] + getArray (_config >> "lootPos");
_itemTypes = [] + getArray (_config >> "lootType");
_lootChance = getNumber (_config >> "lootChance");
//_countPositions = count _pos;
_qty = 0; // effective quantity of spawned weaponholder
_lootSpawnBias = 67; //67 between 50 and 100. The lower it is, the lower chance some of the lootpiles will spawn
 
 
// shuffles an array
// parameters: array
// example: _myrandomarray = _myNormalArray call _ShuffleArray;
ShuffleArray = {
    private ["_ar","_rand_array","_rand"];
    _ar = _this;
    _rand_array = [];
    while {count _ar > 0} do {
        _rand = (count _ar);
        _rand = floor (random _rand);
        _rand_array set [count _rand_array, _ar select _rand];
        _ar set [_rand, "randarray_del"];
        _ar = _ar - ["randarray_del"];
    };
    _rand_array;
};
_positions = _pos call ShuffleArray;
 
// 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;
 
dayz_currentWeaponHolders;


Try changing the configFile to missionconfigFile for CfgBuildingLoot.
 
Just to be sure I didn't muck anything up I started from scratch and now I am not getting any loot or zeds spawning at all. I guess I need a pair of fresh eyes to have a look, I don't see anything wrong but obviously there is because it's not working.

If someone could have a look it would be much appreciated. :)

http://www.filedropper.com/dayz1chernarus
 
Just to be sure I didn't muck anything up I started from scratch and now I am not getting any loot or zeds spawning at all. I guess I need a pair of fresh eyes to have a look, I don't see anything wrong but obviously there is because it's not working.

If someone could have a look it would be much appreciated. :)

http://www.filedropper.com/dayz1chernarus

Aren't you running 1.8?
If so, then I think you've taken the wrong files. cfgloot.hpp for instance is not the 1.8 version, it's missing sections for 1.8 loot and it's missing all the calls at the top which should look like this
Code:
class CfgLoot {
 
    #include "BuildingLoot\Supermarket.hpp"
    #include "BuildingLoot\Farm.hpp"
    #include "BuildingLoot\Industrial.hpp"
    #include "BuildingLoot\Residential.hpp"
    #include "BuildingLoot\Church.hpp"
    #include "BuildingLoot\militaryEAST.hpp"
    #include "BuildingLoot\militaryWEST.hpp"
    #include "BuildingLoot\Hospital.hpp"
    //#include "BuildingLoot\Military.hpp"
    #include "BuildingLoot\Hunter.hpp"

Make sure you've updated your local install of DayZ to 1.8 and try copying the files over again, including the buildingloot folder which needs to be in the root of your mission file. If you place the buildingloot folder in the fixes folder, be sure to edit those lines in cfgloot.hpp.
 
Yea, i cannot get this to work, added the whole buildingloot folder, and the files that you mention in the OP. I have changed configfile to missionconfigfile, in each cfgloot and cfgbuildingloot instance in all the files from dayz_code.

I get no loot, just zombies...

In my arma2oaserver.rpt I get this error:
Code:
Error in expression <) select 2) * 100);
for "_k" from 0 to (_weight - 1) do
{
_weighted set [_j + _k>
Error position: <_weight - 1) do
{
_weighted set [_j + _k>
Error Undefined variable in expression: _weight
File mpmissions\__cur_mp.chernarus\Fixes\loot_init.sqf, line 19
 
Yea, i cannot get this to work, added the whole buildingloot folder, and the files that you mention in the OP. I have changed configfile to missionconfigfile, in each cfgloot and cfgbuildingloot instance in all the files from dayz_code.

I get no loot, just zombies...

In my arma2oaserver.rpt I get this error:
Code:
Error in expression <) select 2) * 100);
for "_k" from 0 to (_weight - 1) do
{
_weighted set [_j + _k>
Error position: <_weight - 1) do
{
_weighted set [_j + _k>
Error Undefined variable in expression: _weight
File mpmissions\__cur_mp.chernarus\Fixes\loot_init.sqf, line 19

Upload your mission file so I can check it out.
 
Back
Top