[Tutorial] Custom Loot Tables and Adjusting Spawn Rates

AVendettaForYou

Well-Known Member
======================= PREFACE =======================

This will be broken up into different parts and show customization to each one.

First before we begin I would like to thank each person that has contributed to figuring out how to customize loot tables as well as these threads that provide help regarding loot spawns:
If I missed any thread please let know so I can add it to this list.
The purpose of this guide is just to collect all the gathered information and put it in one centralized location so it's easier to find.

So you want to edit your loot spawns because we all know with DayZ 1.7.7.1 loot spawns are not what they use to be and us server admins have to deal with the constant questions and complaints about players not finding loot and it taking forever just to find a simple can of beans. Well here is the place for all the useful information you are going to be needing.
Github for pre made mission file that has everything installed just needs to be configured to your liking.
1.8
https://github.com/AVendettaForYou/DayZ_1.8_Custom_Loot_Tables
1.7.7.1
https://github.com/AVendettaForYou/DayZ_1.7.7.1_Custom_Loot_Tables
 

AVendettaForYou

Well-Known Member
======================== ITEMS REQUIRED ===========================
Before we can begin you are going to need these:
  • A PBO manager of choice
  • Notepad/Notepad ++
  • Mission.pbo
  • Server.pbo
  • dayz_code.pbo
Dayz_code can be found in:
Code:
For Steam users, this is normally:  C:/Program Files (x86)/Steam/SteamApps/common/ArmA 2 Operation Arrowhead/@DayZ/Addons
and
Code:
For non-Steam  users: C:/Program FIles (x86)/Bohemia Interactive/ArmA 2 Operation Arrowhead/@DayZ/Addons
Once you have all the PBO files unpack them to a folder of choice.
 

AVendettaForYou

Well-Known Member
================== INSTALLING CUSTOM LOOT TABLES =====================

Ok now that we have everything unpacked lets move to the next step

Open up your mission folder and create a folder named Fixes. (This is where we will be putting most of our edits.)

Now let's open our dayz_code folder this is the list of files that you will need to copy and paste into your Fixes folder:
  • dayz_code\init\compiles.sqf
  • dayz_code\init\loot_init.sqf
  • dayz_code\init\variables.sqf
  • dayz_code\compile\building_spawnLoot.sqf
  • dayz_code\compile\building_spawnZombies.sqf
  • dayz_code\compile\player_spawnCheck.sqf
  • dayz_code\compile\spawn_loot.sqf
  • dayz_code\compile\zombie_generate.sqf
Once you have copied each of those into your Fixes folder move to the next part.
In the main directory of you mission.pbo folder you will need to copy and paste these three files:
  • dayz_code\Configs\CfgLoot\CfgBuildingLoot.hpp
  • dayz_code\Configs\CfgLoot\CfgBuildingPos.hpp
  • dayz_code\Configs\CfgLoot\CfgLoot.hpp
Once you have done that move to the next part.
After all this has been done open up description.ext in the root of your mission.pbo and place this line at the very top:
Code:
#include "cfgBuildingLoot.hpp"
Save your changes.
Open up init.sqf and edit these lines:
Variables
Code:
call compile preprocessFileLineNumbers "\z\addons\dayz_code\init\variables.sqf"; //Initilize the Variables (IMPORTANT: Must happen very early)
to
Code:
call compile preprocessFileLineNumbers "Fixes\variables.sqf";//Initilize the Variables (IMPORTANT: Must happen very early)
Compiles
Code:
call compile preprocessFileLineNumbers "\z\addons\dayz_code\init\compiles.sqf";//Compile regular functions
to
Code:
call compile preprocessFileLineNumbers "Fixes\compiles.sqf";//Compile regular functions
Save your changes and we can move to the next part.
After you have done this move to the compiles.sqf in your fixes folder and edit the folder call on each of these lines to correspond to the Fixes folder:
  1. Line 19: player_spawnCheck = compile preprocessFileLineNumbers "Fixes\player_spawnCheck.sqf";
  2. Line 22: building_spawnLoot = compile preprocessFileLineNumbers "Fixes\building_spawnLoot.sqf";
  3. Line 24: building_spawnZombies = compile preprocessFileLineNumbers "Fixes\building_spawnZombies.sqf";
  4. Line 56: zombie_generate = compile preprocessFileLineNumbers "Fixes\zombie_generate.sqf";
  5. Line 502: spawn_loot = compile preprocessFileLineNumbers "Fixes\spawn_loot.sqf";
Now you will need to open EACH of the files that you placed in the fixes folder and look for
Code:
_config = configfile >> "CfgBuildingLoot" >> _type;
you will need to do it for both CFGBUILDINGLOOT and CFGLOOT and will need to read as:
Code:
_config = missionConfigfile >> "CfgBuildingLoot"
Save your edits then move to variables.sqf and edit this line to correspond to call out of the fixes folder.

  1. Line 420: call compile preprocessFileLineNumbers "Fixes\loot_init.sqf";
Save your changes and continue.

Congratulations you have installed the necessary files and can now customize your loot tables!
 

AVendettaForYou

Well-Known Member
===================== CUSTOMIZING LOOT TABLES ======================

Let us begin by opening variables.sqf in our fixes folder.

On line 407 you should see this line:
Code:
dayz_maxMaxWeaponHolders = 80; // max quantity of loot piles around players. Below this limit we can spawn some loot
Now this line determines the amount of loot that will spawn around a player. The higher it is the more loot will spawn around players, you can edit the 80 to a higher number of your choice.

On line 408 and 409 you can adjust the time on how often a loot cycle will occur and replace any old loot with new loot.
Code:
dayz_tagDelayWeaponHolders = 20; // prevent any new loot spawn on this building during this delay (minutes)
dayz_tagDelayZombies = 20; // prevent any new zombie spawn into or near this building during this delay (minutes)
On line 410 you will see this line:
Code:
dayz_spawnArea = 200; // radius around player where we can spawn loot & Z
This determines the radius at which both loot and zombies spawn around your players the higher it is the larger the radius of loot and zombies spawn adjust to your liking.

On line 415 you will see this line:
Code:
dayz_lootSpawnBias = 67; // between 50 and 100. The lower it is, the lower chance some of the lootpiles will spawn
This determines the spawning of loot piles, you can edit this to your liking as well.


On line 497 and 498 you will want to change it to:
Code:
dayz_spawnDelay = 120;
dayz_spawnWait = -120;
This will give you the exact configuration that was used in 1.7.6.1

Once you have adjusted all these properties save your changes and move to the next part.

In the root of your mission folder you can edit CfgBuildingLoot, CfgBuildingPos, and CfgLoot, I will be giving a quick run down of what each does.

CfgBuildingLoot:
Code:
class Hospital: Default {
zombieChance = 0.4;
minRoaming = 2;
maxRoaming = 6;
zombieClass[] = {"z_doctor","z_doctor","z_doctor"};
lootChance = 0.2;
lootPos[] = {};
lootType[] = {
{"","trash",0.5},
{"","hospital",0.5},
{"MedBox0","object",0.01}
};
};
As you can see this is the building loot for hospitals we can edit the chance at which zombies spawn as well as the minimum and maximum zombies if you want to you can even edit the types of zombies that spawn.

Your lootChance will determine the percentage of how loot spawns as you can see by default it is 0.2 which = 20% you can adjust that to your liking. The higher the number the better chance at loot spawning.

Under lootType you see each type of loot that spawns you can edit the chance as well as add in other loot, remember that the last class does not need a "," at the end only the classes above that.

CfgBuildingPos:
Code:
class Land_HouseV_1I4: Residential {
lootPos[] = {{-0.400146,-3.87891,-2.7688},{-3.67651,-2.51758,-2.76544},{-0.472412,3.19824,-2.72028}};
};
This determines how many spots in the buildings that loot spawns you can configure your own coordinates and add in more loot spawn areas for each building.

CfgLoot:
Code:
hospital[] = {
{"ItemBandage",0.06},
{"ItemPainkiller",0.04},
{"ItemMorphine",0.04},
{"ItemEpinephrine",0.03},
{"ItemBloodbag",0.03},
{"ItemAntibiotic",0.01}
};
This determines the percentage of each loot spawning in the category you can edit this however you please.

After you have edited the loot tables to your liking you can save the changes and pack up your mission folder and upload it to the server. Now you have edited your loot spawns and should see a good increase on loot spawns.
 

AVendettaForYou

Well-Known Member
====================== SERVER SIDE FILE EDITING ======================

This is completely optional if you decide to do it, use at your own risk.

A thank you to [GSG] Az for putting this out to the public to use.
Open up your server_cleanup.fsm under dayz_server/system and replace it with:

https://github.com/azmodii/DayZ-Sou...7.1/SQF/dayz_server/system/server_cleanup.fsm

Now find this string of code:
Code:
/*%FSM<LINK "too_many_objects">*/
class too_many_objects
{
priority = 2.000000;
to="cleanup_objects";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/"((diag_tickTime - _timeNem) > 60)"/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/"_timeNem = diag_tickTime;"/*%FSM</ACTION""">*/;
};
/*%FSM</LINK>*/
and replace it with:
Code:
/*%FSM<LINK "too_many_objects">*/
class too_many_objects
        {
          priority = 2.000000;
          to="cleanup_objects";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"((diag_tickTime - _timeNem) > 3600)"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/"_timeNem = diag_tickTime;"/*%FSM</ACTION""">*/;
        };
/*%FSM</LINK>*/
This should resolve loot not spawning, as well as server lag and general gameplay issues.
 

AVendettaForYou

Well-Known Member
======================== COMMUNITY NOTES ======================

This is reserved for community input.

Was just helping somebody with an unrelated problem when I stumbled upon an issue with custom loot tables.
Turns out there are three files in dayz_server which also need edited. They don't cause a problem unless you edit the heli crash loot table or castle loot table which is probably why most people haven't noticed or haven't cared about the errors spamming their RPT.

The files you need to edit are
dayz_server\compile\fa_hiveMaintenance.sqf on line 76
Code:
    _config = configFile >> "CfgBuildingLoot" >> "HeliCrash";
dayz_server\compile\fn_bases.sqf on line 25
Code:
    _itemTypes =    [] + getArray (configFile >> "CfgBuildingLoot" >> _lootTable >> "lootType");
dayz_server\compile\server_spawnCrashSite.sqf on line 84

Code:
            _itemTypes = [] + getArray (missionconfigFile >> "CfgBuildingLoot" >> _lootTable >> "lootType");
 
I have a working 1.7.7.1 loot script. i have one more thing to test on it. once i am sure it is 100% ready I will post it with instructions on how to add it... it is VERY easy to do with what i already have done.

I cant do any testing right now cause i am on my laptop.. but i will once i get back.
 

AVendettaForYou

Well-Known Member
Guide is finished. If you have any other useful information please let me know and I will post it in the community notes section. Once again I would like to thank everyone who put out the resources to make this guide possible.
 
I dont know if this is needed but it is in the fixes folder and being called so im sure it should be added
Around line 24:
building_spawnZombies = compile preprocessFileLineNumbers "Fixes\building_spawnZombies.sqf";



Question...

Did you have to go into the player_spawnCheck.sqf file in the fixes folder and change at line 87:

_config = configFile >> "CfgBuildingLoot" >> _type;

to

_config = missionconfigFile >> "CfgBuildingLoot" >> _type;




I did this with all the "configFile" in all the files in the fixes folder that called for one for the Cfg files.
 

AVendettaForYou

Well-Known Member
No, I do not have anything calling from missionconfigfile, I have loot spawns working perfectly on my server without changing where it calls the config file from, I know there is some pointers to change it to missionconfig but I have not tested myself since it worked fine with just calling it from config.
 

kaysio

Valued Member!
This does NOT work without 'missionconfigfile'

How did I test,

I created a new class in the loot table with the invisible helipad.
To spawn 100% loot, covered Balota airstrip with 20 'H'
Not one spawned any loot or zeds.


Changing the 60 to 3600 does fix the spawn problems, as that what the fix is for.
 

sukkaed

Well-Known Member
I`m getting these on .rpt log

Code:
22:28:07 Error Zero divisor
 
22:28:07 File mpmissions\__cur_mp.chernarus\Fixes\spawn_loot.sqf, line 27
 
22:28:07 Error in expression <find _iClass;
 
_weights = dayz_CLChances select _index;
 
_cntWeights = count _weig>
 
22:28:07 Error position: <select _index;
 
_cntWeights = count _weig>
 

seaweeduk

OpenDayZ Rockstar!
The problem I've been having is the mod doesn't work unless I replace the call in variables.sqf for loot_init.sqf

Doing so makes everything work but also results in a lot of rpt spam anyone know why? _j should be defined unless its null in the call to loot_init.sqf right?

Code:
21:04:17 Error in expression <
{
_weighted set [_j + _k, _l];
};
_j = _j + _weight;
};
dayz_CBLChances set [co>
21:04:17  Error position: <_j + _weight;
};
dayz_CBLChances set [co>
21:04:17  Error Undefined variable in expression: _j
21:04:17 File mpmissions\__cur_mp.chernarus\fixes\loot_init.sqf, line 23
 
I didnt need to replace all of them.. the only thing I had to do is in the files that are in the mission.pbo I changed almost all of the line that calls for:

_config = configFile >> "CfgBuildingLoot" >> _type;

To

_config = missionconfigFile >> "CfgBuildingLoot" >> _type;

If you look where it says CfgBuildingLoot. That is a file that has been added to the mission.pbo by you. There are more then just that one and there are other files it calls for.

However there are a few lines that have the same _config line but they call for a file that is not part of this. So they DO NOT need to be changed...

This works 100% for me.
 

sukkaed

Well-Known Member
This works for me. Is there way to trigger loot spawn faster. After 1.7.7 it takes a lot longer to spawn.
I dont want to increase spawn radius too much.

Maybe these lines in variables.sqf
Code:
dayz_lootDelay = 3;
 
dayz_lootWait = -300;
 
U probably have too much loot trying to spawn in an area. The default limit is 80 objects in a 200m radius. If u try to go from hospital to a supermarket that is only 150m away one of then won't spawn because u have a bunch of little loot piles everywhere in between.

Look around ur loot files and find where u can change max loot limit and spawn area. Not at my comp right now so can't tell u what they are. It took me a lot of tweaking to find the sweet spot.
 

AVendettaForYou

Well-Known Member
I`m getting these on .rpt log

Code:
22:28:07 Error Zero divisor
 
22:28:07 File mpmissions\__cur_mp.chernarus\Fixes\spawn_loot.sqf, line 27
 
22:28:07 Error in expression <find _iClass;
 
_weights = dayz_CLChances select _index;
 
_cntWeights = count _weig>
 
22:28:07 Error position: <select _index;
 
_cntWeights = count _weig>
Somewhere in your changes it is trying to divide by zero, you would need to go over your changes and look to where it would contain a zero. If you still can't find the error upload your mission file and I'll take a look at it.

This works for me. Is there way to trigger loot spawn faster. After 1.7.7 it takes a lot longer to spawn.
I dont want to increase spawn radius too much.

Maybe these lines in variables.sqf
Code:
dayz_lootDelay = 3;
 
dayz_lootWait = -300;


Those lines are default in 1.7.6.1, now for your loot spawning for the first time would it happen to take 5-10 minutes after you start your server or is this anywhere you go on the map after the server has been up for awhile? With the 1.7.7.1 update after each restart it takes about 5 minutes to load every configuration on the server so if you are having the issue after restarts then that would be the cause of it.
 
Top