[Release] Spawn Custom Weapon/Magazine Crates (Crash Sites/Loot) (1.8+) with rMod 2.1+

BDC

Well-Known Member
Hey gang, wrote this one up a few weeks ago for my server to spice things up a bit. This one's for DayZ 1.8+ using the rMod 2.1 addon. What this mod does is make for the possibility to spawn ammo or weapons' crates, with custom loadouts, as spawned loot using the CfgBuildingLoot.hpp loot table file. They can be generated in specific building types (Hospital, Industrial, Military, etc) or at heli crash sites as part of the random generation of loot choices. We've had a lot of fun with this one in making up names and combinations of things to drop. I'll be adding my server's file directly here to be used as a starting example. It's FULL of different types of crates and box types.

Regarding rMod, I believe this addon requires it due to the names of the box types being used but I could be wrong. The only issue I can see is whether or not DayZ bans the basic box/crate types within Arma 2 and OA (USBasicAmmunitionBox, etc.).

Step 1) Getting access to CfgBuildingLoot.hpp

This first step is required for any custom loot loadouts. All of the threads out there about making your own loot drops include this step. This file is located within \dayz_code\Configs\CfgLoot and must be extracted out.

Your loot_init.SQF file must also be modified to point to the new CfgBuildingLoot.hpp file or none of this will work. This is also an integral part of gaining the ability to create custom loot spawn and must be performed here for this to work.

Step 2) Modify description.ext

Modify your description.ext file located in the \dayzserver\MPMissions\dayz_1.Chernarus folder and add this line anywhere in it:

Code:
// Modifying loot tables for rMod goodies - ^bdc
#include "fixes\configs\cfgBuildingLoot.hpp"

The path "fixes\configs" can be any folder with your server's dayz_1.Chernarus folder (or other map file folder for that matter). This is just the one I use on mine. This will point to the new CfgBuildingsLoot.hpp file instead of the one in dayz_code.pbo.

Step 3) Modify Compiles.SQF / Gain Access to Spawn_Loot.SQF

Modify your compiles.sqf -- at or around line 530 you'll see this line:

Code:
spawn_loot = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\spawn_loot.sqf";


Comment it out (with two forward slashes) and below it add these two lines:

Code:
spawn_loot = compile preprocessFileLineNumbers "fixes\compiles\spawn_loot.sqf"; // custom spawn loot ^bdc
    spawn_rMod_loot = compile preprocessFileLineNumbers "fixes\compiles\spawn_rmod_loot.sqf"; // specific to spawning rMod based ammo box loot - ^bdc

What we're doing is telling the server, when something calls the 'spawn_loot' variable, to point it to one we've extracted. We're also adding a new variable, 'spawn_rmod_loot', to the list. Also, check the paths used to where your spawn_loot.sqf and spawn_rmod_loot.sqf (when downloaded) will be located. Again, I use "fixes" folder for mine but yours can be "scripts", "addons", etc. Both of these files will be located in a subfolder off of your \dayzserver\MPMissions\dayz_1.Chernarus server folder.

Once done with this, gain access to spawn_loot.sqf by unpacking dayz_code and getting into the \compile folder.

Step 4) Modify newly-copied spawn_loot.SQF

On or around line 95 or so, look for this chunk of code within the "switch" statement:

Code:
case "object": {
        //Item is one magazine
        _item = createVehicle [_iItem, _iPos, [], _radius, "CAN_COLLIDE"];
    };

... and add this directly below it before the function's closing }; statement:

Code:
case "rModBox": { // added for spawning misc crates/boxes at crash sites
        _item = [_iItem, _iPos, _radius] call spawn_rMod_loot; // compiles.sqf - ^bdc
    };

This is the function that processes the certain type of loot drop based upon the entry made in CfgBuildingLoot.hpp. For example, if we're in an industrial building, DayZ will look at the "class Industrial:" section of that file and gather the loot array (lootType[]) to select what it will drop depending upon roll chance. The default loot types are "object", "weapon", and "magazine". What I've done is add a fourth type I've called "rModBox" that this function here now recognizes. When it encounters an "rModBox" type within the loottype[] array of a given building type, it will call the spawn_rmod_loot file and find the crate type to spawn on the ground.

Step 5) Modify CfgBuildingLoot.hpp

We'll use HeliCrashWEST as an example here. InCfgBuildingLoot.hpp, look for 'HeliCrashWEST'. Mine is around line 290 or so. This is the loot table used when an American/BLUFOR (UH-1Y Venom, UH-60 Blackhawk) heli crash site is spawned. Within it, in the lootType[] array, you can add entries like this:

Code:
{"CarePackage1","rModBox",0.045},
{"FoodMRE","rModBox",0.045},

Make sure the entries are separated by commas and the type is "rModBox" as reflected in spawn_loot.SQF. "CarePackage1" and "FoodMRE" are names of specific crate types listed in spawn_rmod_loot.sqf which we'll get to shortly. The numbers to the right of those names are the loot chances with 1.00 being 100% (in this case, these two items have a 4.5% chance of spawning).

Step 6) Spawn_Rmod_Loot.SQF

Grab the file here: http://www.mediafire.com/?qews337w6b99p9a

Have a look at it to see how I've structured it. I've tried to keep it simple and well-documented. The function can produce many different types of crates visually (there's links to two sites with references on the kinds of crate names you can use) plus it can produce crates with multiple types of magazines and weapons. The one I've used here for download is the one I use for my server and I've made a gajillion different kinds.

BattlEye consideration: Since we're using a _createVehicle statement here, it might trip BattlEye so an exception might have to be added for it. I am unsure how to do this.

We're done!

Hope this works out for ya'll out there.

B
 
Back
Top