100% Custom Loot tables - TUTORIAL

How Custom new Building spawn Loot?;)

English is not very good:oops:

Code:
_config =              configFile >> "CfgBuildingLoot" >> _type;
_positions =    [] + getArray (_config >> "lootPos");
//_itemTypes =  [] + getArray (_config >> "itemType"); // Default System
_lootChance =  getNumber (_config >> "lootChance");
 
//------------------//
//CUSTOM LOOT SPAWNS//
//------------------//
_itemTypes = []; //Initialise array
_itemChance = []; //Initialise array
 
switch (_type) do { //Assign building classes
        case "Land_HouseV_1I4": { _LootClass = "Residential"; };
        case "Land_kulna": { _LootClass = "Residential"; };
        case "Land_Ind_Workshop01_04": { _LootClass = "Industrial"; };
        case "Land_hut06": { _LootClass = "Residential"; };
        case "Land_Hlidac_budka": { _LootClass = "Residential"; };
        case "Land_HouseV2_02_Interier": { _LootClass = "Residential"; };
        case "Land_A_Pub_01": { _LootClass = "Residential"; };
        case "Land_Shed_wooden": { _LootClass = "Residential"; };
        case "Land_HouseBlock_A1_1": { _LootClass = "Residential"; };
        case "Land_A_MunicipalOffice": { _LootClass = "Residential"; };
        case "Land_ruin_01": { _LootClass = "Residential"; };
        case "Land_HouseV2_04_interier": { _LootClass = "Residential"; };
        case "Land_HouseV2_01A": { _LootClass = "Residential"; };
        case "Land_psi_bouda": { _LootClass = "Residential"; };
        case "Land_KBud": { _LootClass = "Residential"; };
        case "Land_A_Castle_Bergfrit": { _LootClass = "Residential"; };
        case "Land_A_Castle_Stairs_A": { _LootClass = "Residential"; };
        case "Land_A_Castle_Gate": { _LootClass = "Residential"; };
        case "Land_sara_domek_zluty": { _LootClass = "Residential"; };
        case "Land_Church_01": { _LootClass = "Residential"; };
        case "Land_Church_03": { _LootClass = "Residential"; };
        case "Land_HouseB_Tenement": { _LootClass = "Residential"; };
        case "Land_Panelak": { _LootClass = "Residential"; };
        case "Land_Panelak2": { _LootClass = "Residential"; };
        case "Land_rail_station_big": { _LootClass = "Residential"; };
        case "Land_A_Office01": { _LootClass = "Residential"; };
        case "Land_A_Office02": { _LootClass = "Residential"; };
        case "Land_Ind_Workshop01_01": { _LootClass = "Industrial"; };
        case "Land_Ind_Garage01": { _LootClass = "Industrial"; };
        case "Land_Ind_Workshop01_02": { _LootClass = "Industrial"; };
        case "Land_Ind_Workshop01_L": { _LootClass = "Industrial"; };
        case "Land_Hangar_2": { _LootClass = "Industrial"; };
        case "Land_A_FuelStation_Build": { _LootClass = "Industrial"; };
        case "Land_Shed_Ind02": { _LootClass = "Industrial"; };
        case "Land_Misc_PowerStation": { _LootClass = "Industrial"; };
        case "Land_Shed_W01": { _LootClass = "Industrial"; };
        case "Land_Tovarna2": { _LootClass = "Industrial"; };
        case "Land_Ind_Vysypka": { _LootClass = "Industrial"; };
        case "Land_A_BuildingWIP": { _LootClass = "Industrial"; };
        case "Land_A_TVTower_Base": { _LootClass = "Industrial"; };
        case "Land_Misc_Cargo1Ao": { _LootClass = "Industrial"; };
        case "Land_Misc_Cargo1Bo": { _LootClass = "Industrial"; };
        case "Land_Nav_Boathouse": { _LootClass = "Industrial"; };
        case "Land_wagon_box": { _LootClass = "Industrial"; };
        case "Land_Rail_House_01": { _LootClass = "Industrial"; };
        case "Land_A_GeneralStore_01a": { _LootClass = "Supermarket"; };
        case "Land_A_GeneralStore_01": { _LootClass = "Supermarket"; };
        case "Land_A_Hospital": { _LootClass = "Hospital"; };
        case "MASH": { _LootClass = "Hospital"; };
        case "MASH_EP1": { _LootClass = "Hospital"; };
        case "USMC_WarfareBFieldhHospital": { _LootClass = "Hospital"; };
        case "Land_a_stationhouse": { _LootClass = "Military"; };
        case "Land_Mil_ControlTower": { _LootClass = "Military"; };
        case "Land_SS_hangar": { _LootClass = "Military"; };
        case "Land_Mil_House": { _LootClass = "Military"; };
        case "Camp": { _LootClass = "Military"; };
        case "CampEast": { _LootClass = "Military"; };
        case "CampEast_EP1": { _LootClass = "Military"; };
        case "Land_Mil_Barracks_i": { _LootClass = "MilitarySpecial"; };
        case "Land_A_Villa_EP1": { _LootClass = "MilitarySpecial"; _positions = [[-23.3442,1.71484,-3.65929],[14.5498,-5.69775,-5.06722],[5.8457,-2.09814,-5.06717],[9.5249,3.76563,-5.06717],[10.0454,11.5093,-5.0734],[0.268555,8.64648,-5.06699],[-0.378906,15.3989,-5.06724],[-6.68506,14.9448,-5.06722],[-10.9644,13.0996,-5.06719],[11.0571,4.48926,-1.48401],[2.85938,9.12939,-1.48407],[-3.87646,8.01416,-1.4844],[0.0537109,10.3984,-1.4844],[-2.78467,13.5903,-1.4844],[-0.118652,15.3394,-1.4844],[-6.73779,15.772,-1.4844],[-8.39453,13.5249,-1.4844],[-10.5317,9.75146,-1.4844],[-11.8062,14.2358,-1.4844],[-15.5771,14.0396,-1.4844]]; };
        case "Land_Misc_deerstand": { _LootClass = "Hunting"; };
        case "Land_stodola_old_open": { _LootClass = "Farm"; };
        case "Land_Farm_Cowshed_a": { _LootClass = "Farm"; };
        case "Land_stodola_open": { _LootClass = "Farm"; };
        case "Land_Barn_W_01": { _LootClass = "Farm"; };
        case "Land_Barn_W_02": { _LootClass = "Farm"; };
        default { _LootClass = "Residential"; };
};


就是说你把下面武器装备代码加上,仔细看,例如作者所说加上AS50,同时也要注意标点符号,少年,你还太年轻!
 
Hi! How I can create a new loot table for the firestation?
When I do it, loot don't spawn everywhere.
It's part of my building_spawnLoot.sqf about firestation.
Code:
case "Land_a_stationhouse": { _LootClass = "Station"; };
and
Code:
switch (_LootClass) do { //Find correct loot
    case "Station": {
        _itemTypes = [
            ["","trash"],
            ["","hospital"],
            ["WeaponHolder_ItemHatchet","object"],
            ["Makarov","weapon"],
            ["Colt1911","weapon"],
            ["revolver_EP1","weapon"],
            ["Binocular","weapon"],
            ["","generic"],
            ["M9","weapon"],
            ["M1014","weapon"],
            ["Remington870_lamp","weapon"],
            ["glock17_EP1","weapon"],
            ["ItemMap","military"],
            ["AK_74","weapon"],
            ["","military"],
            ["ItemGPS","weapon"]
           
            ["DZ_ALICE_Pack_EP1","object"], // 16
            ["DZ_TK_Assault_Pack_EP1","object"], // 16
            ["DZ_British_ACU","object"], // 18
            ["DZ_CivilBackpack_EP1","object"], // 24
            ["DZ_Backpack_EP1","object"], // 24
            ["MR43","weapon"] // Remember the last object doesn't not need a comma
        ];
        _itemChance = [
            0.2,
            0.05,
            0.18,
            0.10,
            0.07,
            0.07,
            0.05,
            0.10,
            0.04,
            0.03,
            0.03,
            0.04,
            0.04,
            0.02,
            0.03,
            0.01
            //Bags
            0.06,
            0.06,
            0.04,
            0.01,
            0.01
        ];
    };
P.S. Sorry for my bad english :)
 
So I used the same method as Manatee for the custom Piles...but they don't seem to want to spawn.

I used a custom cfgLoot.hpp, included in the description.ext.

Made a "test" pile with 2 items, 0.5 chance on each.

Replaced "hospital" loot pile with "test" inside the hospital, now the Med boxes and all other loot still spawn, but no test pile...

Any help would be great :)
 
For anyone who's interested, I've managed to successfully override cfgloot.cfg on my chernarus server.

If anyone would like a hand with this let me know.when I get done with the dev work I'm neck deep in, ill put up a tutorial.
 
Hi! How I can create a new loot table for the firestation?
When I do it, loot don't spawn everywhere.
It's part of my building_spawnLoot.sqf about firestation.
Code:
case "Land_a_stationhouse": { _LootClass = "Station"; };
and
Code:
switch (_LootClass) do { //Find correct loot
    case "Station": {
        _itemTypes = [
            ["","trash"],
            ["","hospital"],
            ["WeaponHolder_ItemHatchet","object"],
            ["Makarov","weapon"],
            ["Colt1911","weapon"],
            ["revolver_EP1","weapon"],
            ["Binocular","weapon"],
            ["","generic"],
            ["M9","weapon"],
            ["M1014","weapon"],
            ["Remington870_lamp","weapon"],
            ["glock17_EP1","weapon"],
            ["ItemMap","military"],
            ["AK_74","weapon"],
            ["","military"],
            ["ItemGPS","weapon"]
         
            ["DZ_ALICE_Pack_EP1","object"], // 16
            ["DZ_TK_Assault_Pack_EP1","object"], // 16
            ["DZ_British_ACU","object"], // 18
            ["DZ_CivilBackpack_EP1","object"], // 24
            ["DZ_Backpack_EP1","object"], // 24
            ["MR43","weapon"] // Remember the last object doesn't not need a comma
        ];
        _itemChance = [
            0.2,
            0.05,
            0.18,
            0.10,
            0.07,
            0.07,
            0.05,
            0.10,
            0.04,
            0.03,
            0.03,
            0.04,
            0.04,
            0.02,
            0.03,
            0.01
            //Bags
            0.06,
            0.06,
            0.04,
            0.01,
            0.01
        ];
    };
P.S. Sorry for my bad english :)

you lost a "," on //Bags!

like :
0.2,
0.05,
0.18,
0.10,
0.07,
0.07,
0.05,
0.10,
0.04,
0.03,
0.03,
0.04,
0.04,
0.02,
0.03,
0.01,
//Bags
0.06,
0.06,
0.04,
0.01,
0.01
 
Running Chernarus, Im getting this error:
8:41:06 "SPAWNING WITH CUSTOM LOOT"
8:41:06 Error in expression <"_LootClass"];

_obj = _this select 0;
_type = >
8:41:06 Error position: <_this select 0;
_type = >
8:41:06 Error Undefined variable in expression: _this
8:41:06 File mpmissions\__cur_mp.chernarus\building_spawnLoot.sqf, line 3

and here is the code im using:

private["_obj","_type","_config","_positions","_iPos","_nearBy","_itemType","_itemTypes","_itemChances","_lootChance","_weights","_cntWeights","_index","_LootClass"];

_obj = _this select 0;
_type = typeOf _obj;
_config = configFile >> "CfgBuildingLoot" >> _type;
_positions = [] + getArray (_config >> "lootPos");
//_itemTypes = [] + getArray (_config >> "itemType"); // Default System
_lootChance = getNumber (_config >> "lootChance");

//------------------//
//CUSTOM LOOT SPAWNS//
//------------------//
_itemTypes = []; //Initialise array
_itemChance = []; //Initialise array

diag_log "SPAWNING WITH CUSTOM LOOT";//Remove This line after testing

switch (_type) do { //Assign building classes
case "Land_HouseV_1I4": { _LootClass = "Residential"; };
case "Land_kulna": { _LootClass = "Residential"; };
case "Land_Ind_Workshop01_04": { _LootClass = "Industrial"; };
case "Land_hut06": { _LootClass = "Residential"; };
case "Land_Hlidac_budka": { _LootClass = "Residential"; };
case "Land_HouseV2_02_Interier": { _LootClass = "Residential"; };
case "Land_A_Pub_01": { _LootClass = "Residential"; };
case "Land_Shed_wooden": { _LootClass = "Residential"; };
case "Land_HouseBlock_A1_1": { _LootClass = "Residential"; };
case "Land_A_MunicipalOffice": { _LootClass = "Residential"; };
case "Land_ruin_01": { _LootClass = "Residential"; };
case "Land_HouseV2_04_interier": { _LootClass = "Residential"; };
case "Land_HouseV2_01A": { _LootClass = "Residential"; };
case "Land_psi_bouda": { _LootClass = "Residential"; };
case "Land_KBud": { _LootClass = "Residential"; };
case "Land_A_Castle_Bergfrit": { _LootClass = "Residential"; };
case "Land_A_Castle_Stairs_A": { _LootClass = "Residential"; };
case "Land_A_Castle_Gate": { _LootClass = "Residential"; };
case "Land_sara_domek_zluty": { _LootClass = "Residential"; };
case "Land_Church_01": { _LootClass = "Residential"; };
case "Land_Church_03": { _LootClass = "Residential"; };
case "Land_HouseB_Tenement": { _LootClass = "Residential"; };
case "Land_Panelak": { _LootClass = "Residential"; };
case "Land_Panelak2": { _LootClass = "Residential"; };
case "Land_rail_station_big": { _LootClass = "Residential"; };
case "Land_A_Office01": { _LootClass = "Residential"; };
case "Land_A_Office02": { _LootClass = "Residential"; };
case "Land_Ind_Workshop01_01": { _LootClass = "Industrial"; };

any help to the actual problem would be grateful(I shortened the loot tables to fit it in the post. kept the code related to the error)
 
This can't be right at all.

Are you sure you executed the code correctly. The error is saying that _this is an undefined variable which is impossible since it is the buildings that execute this code.
 
This is working great on our server, but there does seem to be rather a lot of Coyote Backpacks spawning in.
 
This can't be right at all.

Are you sure you executed the code correctly. The error is saying that _this is an undefined variable which is impossible since it is the buildings that execute this code.

dont know, but i ended up doing the working around with the .cpp files mentioned in another post.
 
Hello people !

Is there a way we could add new skins as dropable items ? Working the same way as a Ghillie suit or Camo suit ?

I've seen in the loot tables that the Ghillie suit and Camo suit look like this :
["Skin_Camo1_DZ","magazine"],
["Skin_Sniper1_DZ","magazine"],

So now what came to my mind was, if we find the name of those other skins we want and simply add in that loot table the following code would it work ?
["Skin_Rocket_DZ","magazine"],
["Skin_Ins_Soldier_1","magazine"],

Cheers, SparxOne
 
Im getting this error anyone help me ?


"SPAWNING WITH CUSTOM LOOT"
Error in expression <hts","_index","_LootClass"];

_obj = _this select 0;
_type = typeOf _obj;
_>
Error position: <_this select 0;
_type = typeOf _obj;
_>
Error Undefined variable in expression: _this
File mpmissions\__CUR_MP.chernarus\fixes\building_spawnLoot.sqf, line 3
 
I just did this for a Panthera server:

Server Side PBO:
This may differ depending on the mod, so I suggest you open each file and do a search:

You're looking for this: configFile >> "CfgBuildingLoot" ... According to arma 2 wiki, configFile looks into the mods folder root. so replace that with missionConfigFile >> "CfgBuildingLoot"

Note: You may also find cfgLoot, you'll want to modify it like above.

You want to replace every instance only for the "CfgBuildingLoot" from configFile to missionConfigFile. ignore instances of cfgVehicle, etc. leave those as they are.

" For Panthera, the only server-side file I needed edited for custom loot was server_spawnCrashSite.

Mission Side PBO:
step 1: create a file called cfgLoot.hpp in your mission pbo
step 2: create a file called cfgBuilding.hpp in your mission pbo

Next, you want to open and decompile the dayz_code.pbo for your specific mod/map.

Most maps I've seen have the cfgLoot class within a cfgLoot.hpp file already there, copy out the cfgLoot class and copy it into the cfgLoot.hpp in your mission pbo. If you dont specifically see a cfgBuilding.hpp within the dayz_code for your map, then most likely you need to open config.hpp

Open config.hpp, or if your mod had some cfgBuilding.hpp, from there, you will need to copy out the complete cfgBuildingLoot class. Copy that into your cfgBuilding.hpp in your mission pbo.

Edit your description.ext and add the following lines to the top:
#include "cfgBuilding.hpp"
#include "cfgLoot.hpp"


========

So at this point, we have 2 files in the description include, each of those files contain classes which were copied from the original dayz_code for that specific map your working with.
The server files at this point are looking in missionConfigFile, which is the description.ext, now we need to modify all the mission side files properly as well.

Step 1: You will need an overridden compiles.sqf (There are plenty tutorials on how to do that).
Step 2: You will need an overridden variables.sqf
Step 3: from your mods dayz_code, copy over init\loot_init.sqf, make the appropriate configFile to missionConfigFile changes.
Step 4: Open the variables.sqf, find:
call compile preprocessFileLineNumbers "\z\addons\dayz_code\init\loot_init.sqf";
and change the path to your modified loot_init.sqf, usually dayz_code\init\loot_init.sqf if your dayz_code folder is in your mission pbo root.

Step 5: (This is specific to panthera, so i suggest opening all the compile files and searching [same as server side pbo previously modified.]) From the dayz_code compiles folder, I copied over files such as building_spawnLoot, building_spawnZombies, player_spawnCheck. spawn_loot, wild_spawnZombies, zombie_generate.. Your list may differ slightly, so open all the files and do a search for cfgBuildingLoot and cfgLoot and make sure any configFile >> are changed to missionConfigFile >>,

For each file you will need to copy into your mission pbo and override it in the compiles.sqf


So what we did: We just copied over the cfgBuildingLoot and cfgLoot class from the original dayz_code, and then we told all the necessary files to read from the mission description rather than looking into the map mod folder.

Now we can freely play with the cfgBuildingLoot and cfgLoot classes to modify the loot table.
 
  • Like
Reactions: Fox
Back
Top