Custom Wrecks with loot - Why limit it to heli crashes :p

Gorsy

Valued Member!
So this is someone elses code, modded slightly to do what we want.

If you are running the clean up rockets rubbish script to remove all the wrecks, then you can take full advantage of this script, that will create vehicle wrecks on your map that have random loot tables.

So lets start putting it in.

SERVER.PBO ONLY

You will be making changes to init\Server_Functions.sqf and system\Server_Monitor.sqf

Step 1 - Server_Functions.sqf


Find the section that does your compile preprocessFileLineNumbers

and add the following line

server_spawnMedicCarePackages = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_spawnMedicCarePackages.sqf";

For example look at my code below


Code:
server_deleteObj =            compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_deleteObj.sqf";
 
server_playerSync =            compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_playerSync.sqf";
 
zombie_findOwner =            compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\zombie_findOwner.sqf";
 
server_updateNearbyObjects =    compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_updateNearbyObjects.sqf";
 
server_spawnCrashSite  =    compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_spawnCrashSite.sqf";
 
server_spawnMedicCarePackages = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_spawnMedicCarePackages.sqf";

Step 2 - Server_monitor.sqf

Ok so next thing to do is find your Server_monitor.sqf, scroll right to the bottom and look for your helicopter crash site code shown below

Code:
allowConnection = true;
// [_guaranteedLoot, _randomizedLoot, _frequency, _variance, _spawnChance, _spawnMarker, _spawnRadius, _spawnFire, _fadeFire, _prewaypoints, _damage]
nul = [3, 4, 400, 0, 0.99, 'center', 4000, true, false, false, 1, 0.0001] spawn server_spawnCrashSite;

Just above this piece of coding add the green bit of coding below

diag_log (format["CAREPKG Red : ABOUT TO SPAWN"]);
for "_x" from 1 to 6 do {
_id = [] spawn server_spawnMedicCarePackages;
}; //Spawn care packages

Code:
diag_log (format["CAREPKG Red : ABOUT TO SPAWN"]);
for "_x" from 1 to 6 do {
    _id = [] spawn server_spawnMedicCarePackages;
}; //Spawn care packages
 
 
if (isDedicated) then {
    _id = [] execFSM "\z\addons\dayz_server\system\server_cleanup.fsm";
};
allowConnection = true;
// [_guaranteedLoot, _randomizedLoot, _frequency, _variance, _spawnChance, _spawnMarker, _spawnRadius, _spawnFire, _fadeFire, _prewaypoints, _damage]
nul = [3, 4, 400, 0, 0.99, 'center', 4000, true, false, false, 1, 0.0001] spawn server_spawnCrashSite;

Step 3 - Adding the actual code to a new file


Create a file called server_spawnMedicCarePackages.sqf and add the following code below to it.

It will be saved in your compiles folder


Code:
private["_position","_veh","_num","_config","_itemType","_itemChance","_weights","_index","_iArray"];
 
 
if (isDedicated) then {
  diag_log(format["CAREPACKAGE RED: IN FILE"]);
    _position = [getMarkerPos "center",0,4000,10,0,2000,0] call BIS_fnc_findSafePos;
    _randomvehicle = ["HMMWVWreck","HMMWVWreck","HMMWVWreck"] call BIS_fnc_selectRandom;
    _vehicleloottype = ["Hospital"] call BIS_fnc_selectRandom;
 
    _veh = createVehicle [_randomvehicle,_position, [], 0, "CAN_COLLIDE"];
    dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_veh];
    _veh setVariable ["ObjectID",1,true];
 
    if (_randomvehicle == "HMMWVWreck") then { _num = round(random 3) + 3; };
    if (_randomvehicle == "HMMWVWreck") then { _num = round(random 6) + 4; };
    if (_randomvehicle == "HMMWVWreck") then { _num = round(random 12) + 5; };
 
  diag_log(format["CAREPACKAGE: rv: '%1', pos: '%2',vlt :'%3'", str(_randomvehicle), str(_position), str(_vehicleloottype)]);
    switch (_vehicleloottype) do {
        case "Hospital": {
    _itemType = [["MedBox0", "object"], ["MedBox0", "object"], ["FoodBox0", "object"], ["FoodBox0", "object"], ["DZ_British_ACU", "object"], ["DZ_Backpack_EP1", "object"], ["DZ_TK_Assault_Pack_EP1", "object"], ["DZ_ALICE_Pack_EP1", "object"], ["", "medical"], ["", "generic"], ["", "hospital"]];               
        };
    };
 
    diag_log(format["CAREPACKAGE RED Medic: Spawning a " + str (_randomvehicle) + " at " + str(_position) + " with loot type " + str(_vehicleloottype) + " With total loot drops = " + str(_num)]);
 
    itemTypeCount = (count _itemType) - 1;
    for "_x" from 1 to _num do {
        _index = random itemTypeCount;
        sleep 1;
        if (count _itemType > _index) then {
            _iArray = _itemType select _index;
            _iArray set [2,_position];
            _iArray set [3,10];
            _iArray call spawn_loot;
            _nearby = _position nearObjects ["WeaponHolder",20];
            {
                _x setVariable ["permaLoot",true];
            } forEach _nearBy;
        };
    };
 
 
};

So above what we have is the humvee wreck being spawned in this can be changed by actually editing the name of the wreck, Ive gone with the ones that are normally found on the road, but they can be any vehicle that is normally on the server. However unless they are in the 3D editor as unburned wrecks, then they will spawn in black and charred.

The second section of the loot table is changable. Feel free to add to it or change it any way you want



Ive run out of space here so ill add another post on how to edit the loot tables further down
 
Editing loot tables

Very simply find the section that looks like this:

_itemType = [["MedBox0", "object"], ["MedBox0", "object"], ["FoodBox0", "object"], ["FoodBox0", "object"], ["DZ_British_ACU", "object"], ["DZ_Backpack_EP1", "object"], ["DZ_TK_Assault_Pack_EP1", "object"], ["DZ_ALICE_Pack_EP1", "object"], ["", "medical"], ["", "generic"], ["", "hospital"]

And adjust it as you need to, just make sure you find out the type of the item. weapon/object etc or it will break the script

or add varible spawns (the loot piles you find on the floors of hospitals for example) just add something like ["", "hospital"] or ["", "industrial"]



If you would also like a URAL wreck that spawns industrial gear, follow the steps above but use

Server_functions.sqf

Code:
server_spawnYellowCarePackages = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_spawnYellowCarePackages.sqf";

Server_monitor.sqf

Code:
diag_log (format["CAREPKG Yellow: ABOUT TO SPAWN"]); 
for "_x" from 1 to 6 do {
    _id = [] spawn server_spawnYellowCarePackages;
}; //Spawn care packages

server_spawnYellowCarePackages.sqf (Goes in your compiles folder)

Code:
private["_position","_veh","_num","_config","_itemType","_itemChance","_weights","_index","_iArray"];
 
 
if (isDedicated) then {
  diag_log(format["CAREPACKAGE URAL: IN FILE"]);
    _position = [getMarkerPos "center",0,4000,10,0,2000,0] call BIS_fnc_findSafePos; 
    _randomvehicle = ["UralWreck","UralWreck","UralWreck"] call BIS_fnc_selectRandom;
    _vehicleloottype = ["Industrial"] call BIS_fnc_selectRandom;
 
    _veh = createVehicle [_randomvehicle,_position, [], 0, "CAN_COLLIDE"];
    dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_veh];
    _veh setVariable ["ObjectID",1,true]; 
 
    if (_randomvehicle == "UralWreck") then { _num = round(random 3) + 3; };
    if (_randomvehicle == "UralWreck") then { _num = round(random 6) + 4; };
    if (_randomvehicle == "UralWreck") then { _num = round(random 12) + 5; };
 
  diag_log(format["CAREPACKAGE URAL: rv: '%1', pos: '%2',vlt :'%3'", str(_randomvehicle), str(_position), str(_vehicleloottype)]);
    switch (_vehicleloottype) do {
        case "Industrial": {   
    _itemType = [["WeaponHolder_PartGeneric", "object"], ["WeaponHolder_PartFueltank", "object"], ["WeaponHolder_PartWheel", "object"], ["WeaponHolder_PartEngine", "object"], ["WeaponHolder_PartGlass", "object"], ["WeaponHolder_PartVRotor", "object"], ["ItemToolbox", "weapon"], ["ItemToolbox", "weapon"], ["ItemToolbox", "weapon"], ["WeaponHolder_ItemJerrycan", "object"], ["", "Industrial"], ["ItemGPS", "weapon"]];                   
        };
    };
 
    diag_log(format["CAREPACKAGE URAL Medic: Spawning a " + str (_randomvehicle) + " at " + str(_position) + " with loot type " + str(_vehicleloottype) + " With total loot drops = " + str(_num)]);
 
    itemTypeCount = (count _itemType) - 1;
    for "_x" from 1 to _num do {
        _index = random itemTypeCount;
        sleep 1;
        if (count _itemType > _index) then {
            _iArray = _itemType select _index;
            _iArray set [2,_position];
            _iArray set [3,10];
            _iArray call spawn_loot;
            _nearby = _position nearObjects ["WeaponHolder",20];
            {
                _x setVariable ["permaLoot",true];
            } forEach _nearBy;
        };
    };
 
 
};

Hope you all enjoy
 
With this you can create as many different type of wrecks as you want, We have these spawn in along with normal care packages that contain guns to just add some spice to the server restart.
 
when you say the current wrecks that spawn? you mean rockets, or did someone already post this? :p

I get pestered by server admins to give them my scripts i usually direct them to open dayz and then they go and come back saying "but its not on thereeeeeeeeeeee, please do it for meeeeee" and i dont mind doing it for good friends, (they know who they are) but random strangers is rather annoying, unless they are willing to pay for my time which most arnt lol
 
The ones that come with Reality. I have had wrecks on my servers for a while. I was just curious to how your's was different than it.


Edit: fnc_wrecks.sqf in server pbo

Code:
private["_position","_veh","_num","_config","_itemType","_itemChance","_weights","_index","_iArray"];
 
waitUntil{!isNil "BIS_fnc_selectRandom"};
if (isDedicated) then {
_position = [getMarkerPos "center",0,7000,10,0,2000,0] call BIS_fnc_findSafePos;
 
_randomvehicle = ["MV22Wreck","LADAWreck","BMP2Wreck","MH60Wreck","C130JWreck","Mi24Wreck","UralWreck","HMMWVWreck","T72Wreck"] call BIS_fnc_selectRandom;
_vehicleloottype = ["Residential","Industrial","Military","Farm","Supermarket","Hospital"] call BIS_fnc_selectRandom;
 
_veh = createVehicle [_randomvehicle,_position, [], 0, "CAN_COLLIDE"];
dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_veh];
_veh setVariable ["ObjectID",1,true];
 
_num = round(random 3) + 3;
 
if (_randomvehicle == "UralWreck") then { _num = round(random 12) + 5; };
if (_randomvehicle == "C130JWreck") then { _num = round(random 12) + 5; };
 
switch (_vehicleloottype) do {
    case "Military": {
        _itemType = [["M9", "weapon"], ["M16A2", "weapon"], ["M16A2GL", "weapon"], ["M9SD", "weapon"], ["AK_47_M", "weapon"], ["AK_74", "weapon"], ["M4A1_Aim", "weapon"], ["AKS_74_kobra", "weapon"], ["AKS_74_U", "weapon"], ["AK_47_M", "weapon"], ["M24", "weapon"], ["M1014", "weapon"], ["DMR", "weapon"], ["M4A1", "weapon"], ["M14_EP1", "weapon"], ["UZI_EP1", "weapon"], ["Remington870_lamp", "weapon"], ["glock17_EP1", "weapon"], ["MP5A5", "weapon"], ["MP5SD", "weapon"], ["M4A3_CCO_EP1", "weapon"], ["Binocular", "weapon"], ["ItemFlashlightRed", "military"], ["ItemKnife", "military"], ["ItemGPS", "weapon"], ["ItemMap", "military"], ["DZ_Assault_Pack_EP1", "object"], ["DZ_Patrol_Pack_EP1", "object"], ["DZ_Backpack_EP1", "object"], ["", "medical"], ["", "generic"], ["", "military"], ["ItemEtool", "weapon"], ["ItemSandbag", "magazine"]];
        _itemChance = [0.05, 0.05, 0.01, 0.02, 0.2, 0.15, 0.01, 0.08, 0.05, 0.05, 0.01, 0.1, 0.01, 0.02, 0.01, 0.05, 0.08, 0.1, 0.04, 0.02, 0.01, 0.06, 0.1, 0.1, 0.01, 0.05, 0.06, 0.04, 0.02, 0.1, 1.0, 2.5, 0.05, 0.02];
    };
    case "Residential": {
        _itemType = [["ItemSodaMdew", "magazine"], ["ItemWatch", "generic"], ["ItemCompass", "generic"], ["ItemMap", "weapon"], ["Makarov", "weapon"], ["Colt1911", "weapon"], ["ItemFlashlight", "generic"], ["ItemKnife", "generic"], ["ItemMatchbox", "generic"], ["", "generic"], ["LeeEnfield", "weapon"], ["revolver_EP1", "weapon"], ["CZ_VestPouch_EP1", "object"], ["DZ_CivilBackpack_EP1", "object"], ["DZ_ALICE_Pack_EP1", "object"], ["Winchester1866", "weapon"], ["WeaponHolder_ItemTent", "object"], ["", "military"], ["", "trash"], ["Crossbow", "weapon"], ["Binocular", "weapon"], ["PartWoodPile", "magazine"], ["Skin_Camo1_DZ", "magazine"], ["Skin_Sniper1_DZ", "magazine"], ["WeaponHolder_MeleeCrowbar", "object"], [MR43, "weapon"]];
        _itemChance = [0.01, 0.15, 0.05, 0.03, 0.13, 0.05, 0.03, 0.08, 0.06, 2, 0.06, 0.04, 0.01, 0.03, 0.03, 0.01, 0.01, 0.03, 0.5, 0.01, 0.06, 0.06, 0.01, 0.01, 0.08, 0.03];
    };   
    case "Industrial": {
        _itemType = [["", "generic"], ["", "trash"], ["", "military"], ["WeaponHolder_PartGeneric", "object"], ["WeaponHolder_PartWheel", "object"], ["WeaponHolder_PartFueltank", "object"], ["WeaponHolder_PartEngine", "object"], ["WeaponHolder_PartGlass", "object"], ["WeaponHolder_PartVRotor", "object"], ["WeaponHolder_ItemJerrycan", "object"], ["WeaponHolder_ItemHatchet", "object"], ["ItemKnife", "military"], ["ItemToolbox", "weapon"], ["ItemWire", "magazine"], ["ItemTankTrap", "magazine"]];
        _itemChance = [0.18, 0.29, 0.04, 0.04, 0.05, 0.02, 0.01, 0.04, 0.01, 0.04, 0.11, 0.07, 0.02, 0.06, 0.04];   
    };
    case "HeliCrash": {
        _itemType = [[FN_FAL, "weapon"], ["bizon_silenced", "weapon"], [M14_EP1, "weapon"], [FN_FAL_ANPVS4, "weapon"], [M107_DZ, "weapon"], ["BAF_AS50_scoped", "weapon"], ["Mk_48_DZ", "weapon"], [M249_DZ, "weapon"], [BAF_L85A2_RIS_CWS, "weapon"], [DMR, "weapon"], ["", "military"], ["", "medical"], ["MedBox0", "object"], ["NVGoggles", "weapon"], ["AmmoBoxSmall_556", "object"], ["AmmoBoxSmall_762", "object"], ["Skin_Camo1_DZ", "magazine"], ["Skin_Sniper1_DZ", "magazine"]];
        _itemChance = [0.02, 0.05, 0.05, 0.02, 0.01, 0.02, 0.03, 0.05, 0.01, 0.1, 1, 0.5, 0.1, 0.01, 0.1, 0.1, 0.08, 0.05];
    };
    case "Farm": {
        itemType = [["WeaponHolder_ItemJerrycan", "object"], ["", "generic"], ["huntingrifle", "weapon"], ["LeeEnfield", "weapon"], ["Winchester1866", "weapon"], ["", "trash"], ["Crossbow", "weapon"], ["PartWoodPile", "magazine"], ["WeaponHolder_ItemHatchet", "object"], [MR43, "weapon"], ["TrapBear", "magazine"]];
        itemChance = [0.06, 0.28, 0.01, 0.04, 0.03, 0.22, 0.03, 0.11, 0.17, 0.06, 0.01];   
    };
    case "Supermarket": {   
        _itemType = [["ItemWatch", "generic"], ["ItemCompass", "generic"], ["ItemMap", "weapon"], ["Makarov", "weapon"], ["Colt1911", "weapon"], ["ItemFlashlight", "generic"], ["ItemKnife", "generic"], ["ItemMatchbox", "generic"], ["", "generic"], ["LeeEnfield", "weapon"], ["revolver_EP1", "weapon"], ["CZ_VestPouch_EP1", "object"], ["DZ_CivilBackpack_EP1", "object"], ["DZ_ALICE_Pack_EP1", "object"], ["Winchester1866", "weapon"], ["WeaponHolder_ItemTent", "object"], ["", "food"], ["", "trash"], ["Crossbow", "weapon"], ["Binocular", "weapon"], ["PartWoodPile", "magazine"], [MR43, "weapon"]];
        _itemChance = [0.15, 0.01, 0.05, 0.02, 0.02, 0.05, 0.02, 0.05, 0.05, 0.01, 0.01, 0.01, 0.02, 0.03, 0.01, 0.01, 0.3, 0.15, 0.01, 0.05, 0.02, 0.01];
    };
    case "Hospital": {
        _itemType = [["", "trash"], ["", "hospital"], ["MedBox0", "object"]];
        _itemChance = [0.2, 0.5, 0.5];
    };   
};
 
diag_log("DEBUG: Spawning a " + str (_randomvehicle) + " at " + str(_position) + " with loot type " + str(_vehicleloottype) + " With total loot drops = " + str(_num));
 
waituntil {!isnil "fnc_buildWeightedArray"};
 
_weights = [];
_weights =        [_itemType,_itemChance] call fnc_buildWeightedArray;   
for "_x" from 1 to _num do {
    _index = _weights call BIS_fnc_selectRandom;
    sleep 1;
    if (count _itemType > _index) then {
        _iArray = _itemType select _index;
        _iArray set [2,_position];
        _iArray set [3,10];
        _iArray call spawn_loot;
        _nearby = _position nearObjects ["WeaponHolder",20];
        {
            _x setVariable ["permaLoot",true];
        } forEach _nearBy;
    };
};
};
 
They arnt much different tbh, just got pestered to post em up here. the people pestering said they cudnt find them on here
 
Weird. Wrecks have been a part of DayZ since....1.7.4 or 1.7.5? Not sure. Anyway, I wasn't knocking your scripts, was just curious to how they were different. :)
 
nah its cool, theres always new people coming through who dont know how to do this stuff or very new to coding. Ive not been at it very long myself. When I first started, trying to follow some of the scripts people had written up was very difficult cuz it was posted like 2 pages in with improvements on page 5 then rewritten entirely on page 7, with another bit on page 9. etc etc. So I figure, make it easy the way some of the scripts are on here
 
diag_log (format["CAREPKG Red : ABOUT TO SPAWN"]);
for "_x" from 1 to 6 do {
_id = [] spawn server_spawnMedicCarePackages;
}; //Spawn care packages

change the 6 to 10 or whatever
 
Is it possible that some of the care packages are spawning in the water? or is the script smart enough to know whats land and water? because Namalsk's landscape is so small.

By the way thank you for all the help Gorsy :)
 
if u check ur RPT log it shud give u the co-ords and how many spawned etc.

If i remember rightly (not checked this) then that release has the find safe point to place, so it shudnt be spawning stuff in the sea, but no promises :p i wud teleport around them and check that way
 
When I tried installing this I followed all the necessary steps but when I checked my RPT logs it was giving an error with this coding

diag_log (format["CAREPKG Red : ABOUT TO SPAWN"]);
for "_x" from 1 to 6 do {
_id = [] spawn server_spawnMedicCarePackages;
}; //Spawn care packages

It was something along the lines of ERROR: for "_x" from 1 to 6 do { variables not determined.
 
check to make sure it is in your server_funtions.sqf, as it is looking for server_spawnMedicCarePackages which is defined as an address in your server_functions, check to make sure its the correct address and file name, check uppercase/lowercase just incase etc
 
I did edit the server_spawnMedicCarePackages to say sever_spawnCarePackages since I only wanted carepackages with weapons but I made sure to change all the other details to show CarePackages and not the medic part to it. When the server population dies down I'll retest it.
 
just make sure u update it in Server_monitor and Server_functions aswell

diag_log (format["CAREPKG Red : ABOUT TO SPAWN"]);
for "_x" from 1 to 10 do {
_id = [] spawn server_spawnMedicCarePackages;
};


server_spawnMedicCarePackages = compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_spawnMedicCarePackages.sqf";
 
Back
Top