[Release] BDC's Loot and Zed Spawn Configurable Parameters

BDC

Well-Known Member
Howdy guys, I'm not sure if I should be posting this this soon as I'm not convinced I'm 100% done with it, but I think nonetheless it'll work. This is one I've been trying to tweak and get right for a while now. What this mod does is it gives server owners the ability to configure several things within the guts of the player_spawnCheck.SQF file in \z\dayz_code\compiles folder. The idea is to trim up and improve some of the loot and zed spawn characteristics to help with realism. On my servers, I grew tired of having to drive a vehicle off a good distance, then jump out on foot, to trigger spawn (loot in particular). I've re-written some of the code in here to make it possible to have both loot and zed spawn more naturally while in any kind of vehicle making it more possible to drive up to a location and have loot piles waiting.

Also included is the guts of a previous modification I wrote for preventing loot and zed from spawning in pre-defined areas. I will include all of the instructions for it in here as well.

On to the mod.

Step 1) Modify Init.SQF

This ought to be already located within the \dayz_server\MPMissions\xxx folder for your server.

The first chunk of code to put in here is all of the configuration options. This can be placed really anywhere in the init.SQF file but I prefer to place it below everything else for cleanliness. So, tack this chunk at the end of the file:

Code:
// Spawn Loot/Zed Parameters - ^bdc - Player_SpawnCheck.SQF modifications
dayz_DisableGlobalZedSpawn = false; // Global flag to enable/disable ALL zed spawn on map 
dayz_LootZedSpawn_DisableDynamicLootSpawn = false; // (default: false) - Disables dynamically spawned loot from client machines
dayz_LootZedSpawn_MaxWeaponHolders = 160; // (default: 80) - maximum number of "weapon holders" for each client (replaces dayz_maxmaxweaponholders)
dayz_LootZedSpawn_SpawnZedRadius = 30; // (default: 30) - maximum radius from center of building/object to spawn zed
dayz_LootZedSpawn_MaxSpawnRange = 325; // (default: 200) - max global range (radius in meters) from player of any loot/zed spawn (nearby buildings check)
dayz_LootZedSpawn_MaxGroundVehicleSpeed = 80; // max speed of ground vehicle (player in) that will generate loot/zed spawn
dayz_LootZedSpawn_MaxAirVehicleSpeed = 125; // max speed of air vehicle (player in) that will generate loot/zed spawn
dayz_LootZedSpawn_MaxAirVehicleAltitude = 80; // max terrain altitude (meters) of air vehicle (player in) that will generate loot/zed spawn
dayz_LootZedSpawn_ExcludePlanes = true; // Exclude loot/zed spawn triggered by player while in a plane
dayz_LootZedSpawn_MaxLootSpawnDistance = 200; // (default: 125) - maximum loot spawn distance from player for loot
dayz_LootZedSpawn_MinLootSpawnDistance = 10; // (default: 30) - minimum loot spawn distance from player for loot
dayz_LootZedSpawn_LootRespawnTimer = 2700; // Time in seconds until respawn of loot in a given building (default: 900 for 15 minutes) - Works if permanentloot set false
dayz_LootZedSpawn_PermanentLoot = false; // Enable/disable permanent loot (default: false) - if true, loot spawns once at building and remains permanently until server reset

As you can see, there's a lot of variables I've made that can be adjusted. The defined variables I've cut/pasted are the ones I use on both of my servers. I've made comments next to each one to help explain what they do (and remind myself, too) but I'll give a further explanation here:

dayz_DisableGlobalZedSpawn -- Pretty much self-explanatory. This simple flag, when set to true, will hinder any zed from spawning. Handy for testing such as grabbing precise X/Y coordinates to create no loot/zed spawn areas. Default is false.

dayz_LootZedSpawn_DisableDynamicLootSpawn -- true or false -- default is false. If set to true, no loot will spawn dynamically. This is only set to false if used in conjunction with pre-spawning of all loot on the entire server (which I've not included in this post; I may change my mind if anyone asks for it).

dayz_LootZedSpawn_MaxWeaponHolders -- I'm still not sure what this does, but since I run the clients a little harder on my machines, I decided to double this value from the default of 80 to 160.

dayz_LootZedSpawn_SpawnZedRadius -- The radius that zed will spawn from the center point/exact position of a building or other structure that's compelling the zed spawn. Default is 30.

dayz_LootZedSpawn_MaxSpawnRange -- This is the range, in meters, from the client player's current position (when the "tick" has hit to run loot/zed spawn) that the routine will search for structures/buildings that can pop loot piles and/or zed up. Default is 200 but I've set mine to 325. One can experiment and set it up further but I believe it will produce an FPS drop progressively. I've experimented with this one as high as 500 and wound up settling at 325. Things to take into account are the maximum number of zed agents a client's PC is responsible for spawning. I believe the createVehicle and createAgents are what drops the FPS on certain machines so the further this is placed, especially when running in densely populated areas like towns, the more a precipitous drop in FPS player machines might experience.

dayz_LootZedSpawn_MaxGroundVehicleSpeed -- This value determines the maximum speed any ground vehicle (car, truck, bike, etc) a player can be cruising in that will run the loot and zed spawn routine. Above this figure, nothing will spawn until said vehicle has slowed down below. DayZ default I believe is 25kph but I've set mine up to 80. Again, like maxspawnrange, this can have an affect on player's FPS.

dayz_LootZedSpawn_MaxAirVehicleSpeed -- This value determines the max speed in kph an air vehicle (plane/chopper) the loot and zed spawn routine will run. Anything above, like maxgroundvehiclespeed above this, will not run the routine. There is no default for this so I've set mine to 125. This one is worth experimenting with as going too fast in a chopper fly-over of a town with this value set very high may load a player's PC up attempting to spawn loot and zed that may never be encountered. So, my thinking on this is is to keep it reasonably low to help spawn get going while coming into an area that the chopper may land in shortly.

dayz_LootZedSpawn_MaxAirVehicleAltitude -- This one coincides with maxairvehiclespeed -- the maximum TERRAIN altitude in meters that the spawn routine will run for an air vehicle. There is no default so I've experimented and set mine to 80. When setting this variable and the one above it, consider the hypothetical use of a chopper or fly over an area and take note of the chopper's speed and altitude that seems reasonable for spawn to start occurring.

dayz_LootZedSpawn_ExcludePlanes -- True or false, this will or won't exclude planes from running the spawn routine. Doing a fly-over in a slow plane, like the AN-2 cargo plane, may not warrant loot/zed spawn, but for those that use the Osprey may want it.

dayz_LootZedSpawn_MaxLootSpawnDistance -- A more specific trim to maximum spawn range chance. If we don't want loot piles to spawn all the way out the same range that we want zed to spawn (maxspawnrange), then we can use a smaller number here to reduce player PC load and FPS drop. I use 200 meters on my boxes. Default is 125.

dayz_LootZedSpawn_MinLootSpawnDistance -- The opposite end of the same coin from the variable above -- the minimum distance away a player must be from a precise loot pile position for the spawn routine to run in that spot. Default is 30, but I like doing 10 meters. An example: consider if a person is in a ground vehicle driving up to the very edge of a building that he or she is expecting loot to spawn in -- if the spawn routine hasn't run by the time he's parked, and he's under the default of 30 meters from the loot pile spots in that building, then nothing will appear.

dayz_LootZedSpawn_LootRespawnTimer -- Loot pile respawn timer in seconds - default is 900 seconds (or 15 minutes). This determines how long a loot pile will be "tagged" and excluded from concurrent loot spawn routines. I prefer to set mine up anywhere from 45 minutes (2700 seconds) to 1 hour (3600 seconds) to prohibit constant loot mining of a particular building. It compels players to explore more ground before coming back to the same spot over and over.

dayz_LootZedSpawn_PermanentLoot -- True or false, this sets a particular loot pile spot in a building or structure to produce loot one time. Set to true, lootrespawntimer is disregarded. By default, it's set to false, but if you want a more ultra-realistic feel, where loot never respawns in the same spot twice, then set this to true.

(continued on second page)
 
Step 2) Modify Init.SQF (Part II)

This portion is about the no zed/loot spawn area definition (safe zones, if you will). I've already posted a thread ( ) that defines this, but since it modifies the same file (player_spawnCheck.SQF), I'm including an examples from the no zed and loot spawn markers I use on my Chernarus server.

This chunk can be placed below the dayz_xxx variable definitions that've been just pasted into init.sqf:

Code:
//Prevent zed from spawning in specific spots according to position - Used in Player_SpawnCheck.SQF -^bdc
PreventZedSpawnPositions = [];
PreventZedSpawnDistances = [];
PreventZedSpawnLootInclusions = [];

If you want to use my examples from my Chernarus server, then paste this chunk below instead and modify it as you please:

Code:
//Prevent zed from spawning in specific spots according to position - Used in Player_SpawnCheck.SQF -^bdc
// Devil's Castle 155m, NWAF (Between NW hangars 1 and 2) and Mil building NW at 75m, Balota (SE side) 75m and 100m, NEAF (both hangars) 75m, NEAF ATC Tower/workshop 100m, Cap Golova South camp, Zelenogorsk city central (all)
// Marker positions in X, Y, and Z coordinates; can be derived from Object or Character entries in dBase
PreventZedSpawnPositions = [[6898,11446],[4540,10785],[4540,10750],[4563,10714],[4508,10806],[12011,12638],[12061,12622],[12139,12615],[4703.5,2582.5],[4769.5,2552.5],[4833,2534],[8373,2628],[6564,14128],[2718,5355]];
// Radius (in meters) of zed/loot no-spawn markers relative to position in above array
PreventZedSpawnDistances = [155,75,75,100,75,75,75,100,125,110,100,125,175,650];
// Include no-spawning of loot at given position within defined radius (default true per element)
PreventZedSpawnLootInclusions = [false,true,true,true,true,true,true,true,true,true,true,true,false,false];

A note -- Z coordinates do not need to be defined in each of the definitions in PreventZedSpawnPositions as all buildings by default sit at 0 Z coordinate (relative to terrain), but they can be specified for unusual conditions.

A quick run-thru of the three array definitions:

PreventZedSpawnPositions -- This array contains all of the X/Y coordinates for the desired no spawn marker. This can (in theory) contain an unlimited number. They're defined within their own set of bracket's and separated by commas. Example:

PreventZedSpawnPosition = [[1000,1000],[2000,2000]];

This array contains two elements; one of which is at 1000 by 1000 and the second being at 2000,2000.

PreventZedSpawnDistances -- This array houses the radius of each spawn marker listed in the prior array, PreventZedSpawnPositions. I know there's another way of doing this which includes placing all of these variables into one giant array, but I felt that this was cleaner and easier to modify by server owners. Here's a quick example:

PreventZedSpawnDistances = [100,200];

The first element, 100, coincides with the first element defined in PreventZedSpawnPositions. If using the example above, it means the marker placed at 1000,1000 would have a 100 meter radius from center. Likewise, the element 200 would give the 2000,2000 position a no spawn marker radius of 200 meters.

PreventZedSpawnLootInclusions -- This array is specific definition of each PreventZedSpawnPosition element on whether or not there's an exception on loot spawn. By default, everything is true when not defined, meaning loot will NOT spawn. But in some instances, such as if we're placing static spawn AI in an area that we want no zed to spawn but want loot to spawn, we'd set this to false. Example:

PreventZedSpawnLootInclusions = [true,false];

In the above example, the 1000,1000 no spawn marker would not produce, but the one at 2000,2000 would as the loot no-spawn routine would be excluded (meaning we're going to spawn loot).

Step 3) Modify Compiles.SQF

Since we're going to use a custom player_spawnCheck.SQF file, we need to modify where compiles is going to point for a player_SpawnCheck.SQF file. On or about line 20, we'll find this definition:

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

Let's comment it out and then below it add the following line (combined, it should look like this):

Code:
//player_spawnCheck = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\player_spawnCheck.sqf";
    player_spawnCheck = compile preprocessFileLineNumbers "scripts\compiles\player_spawnCheck.sqf"; // Modified for custom loot/zed spawn by ^bdc
The path I use on my servers is scripts\compiles\. The scripts folder in this case would be located under the MPMissions\dayz_1.Chernarus (or other map name) folder as a subfolder.

Step 4) Player_SpawnCheck.SQF

In the next post below is a paste of my exact file. If that method is not preferred, then it can be procured from my MediaFire share here -->
https://www.mediafire.com/?hqcvstg198hrqvw

Step 5) We're done!

Hope that helps. The help thread for this thread can be found here -->
http://www.opendayz.net/threads/help-bdcs-loot-and-zed-configurable-spawn-parameters.19155/

Shoot me any questions there you've got.

B
 
Back
Top