Care Packages & New Wreck Types With Pwnozor

Forgotten

Well-Known Member
Hey all, I've been running with these on my Pwnozor server for awhile, and realized most people think that care packages are a Bliss only option. Incorrect!

Here's what you need to do to get care packages, new wrecks like urals, UAZs, armored cars, even random buildings to spawn! Note, these use the heli crash position system, so open ground and in a certain radius of the center of the map, which is also editable.

Open up your dayz_server.pbo. Inside find your dayz_server>init> server_function.sqf. Inside this file, find spawn_heliCrash. This is your current helicrash spawn system. This can be edited, but I already have a thread about how to edit this here in this thread.

For the purpose of this, I am going to assume you know what many of the variables already are.

Here is the code for care packages. Credit for this goes to UnclearWall. I am unaware if anyone made this before him.

Code:
diag_log ("DEBUG Care Packages processing... START");
 
spawn_Misc_cargo_cont_net1 = {
private["_position","_veh","_num","_config","_itemType","_itemChance","_weights","_index","_iArray"];
 
waitUntil{!isNil "BIS_fnc_selectRandom"};
if (isDedicated) then {
_position = [getMarkerPos "center",0,4000,10,0,2000,0] call BIS_fnc_findSafePos;
diag_log("DEBUG: Spawning a Misc_cargo_cont_net1 at " + str(_position));
_veh = createVehicle ["Misc_cargo_cont_net1",_position, [], 0, "CAN_COLLIDE"];
//dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_veh];
_veh setVariable ["ObjectID",1,true];
 
_num = round(random 9) + 5;
_config = configFile >> "CfgBuildingLoot" >> "Residential";
_itemType = [] + getArray (_config >> "itemType");
//_itemType = [["AK_74","weapon"], ["AK_47_M","weapon"], ["M4A1_Aim","weapon"], ["Saiga12K","weapon"], ["RPK_74","weapon"], ["AK_107_kobra","weapon"], ["FN_FAL","weapon"], ["bizon_silenced","weapon"], ["M14_EP1","weapon"], ["FN_FAL_ANPVS4","weapon"], ["MakarovSD","weapon"], ["KSVK","weapon"], ["Mk_48_DZ","weapon"], ["M249_DZ","weapon"], ["SVD_CAMO","weapon"], ["DMR","weapon"], ["","military"], ["","medical"], ["MedBox0","object"], ["NVGoggles","weapon"], ["AmmoBoxSmall_556","object"], ["AmmoBoxSmall_762","object"], ["Skin_Camo1_DZ","magazine"], ["Skin_Sniper1_DZ","magazine"], ["DZ_Backpack_EP1","object"]];
//diag_log ("DW_DEBUG: _itemType: " + str(_itemType));
_itemChance = [] + getArray (_config >> "itemChance");
//_itemChance = [0.07, 0.07, 0.05, 0.02, 0.02, 0.02, 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.03, 0.03, 0.03];
//diag_log ("DW_DEBUG: _itemChance: " + str(_itemChance));
//diag_log ("DW_DEBUG: (isnil fnc_buildWeightedArray): " + str(isnil "fnc_buildWeightedArray"));
 
waituntil {!isnil "fnc_buildWeightedArray"};
 
_weights = [];
_weights = [_itemType,_itemChance] call fnc_buildWeightedArray;
//diag_log ("DW_DEBUG: _weights: " + str(_weights));
for "_x" from 1 to _num do {
//create loot
_index = _weights call BIS_fnc_selectRandom;
sleep 1;
if (count _itemType > _index) then {
//diag_log ("DW_DEBUG: " + str(count (_itemType)) + " select " + str(_index));
_iArray = _itemType select _index;
_iArray set [2,_position];
_iArray set [3,5];
_iArray call spawn_loot;
_nearby = _position nearObjects ["WeaponHolder",20];
{
_x setVariable ["permaLoot",true];
} forEach _nearBy;
};
};
};
};
 
spawn_Misc_cargo_cont_net2 = {
private["_position","_veh","_num","_config","_itemType","_itemChance","_weights","_index","_iArray"];
 
waitUntil{!isNil "BIS_fnc_selectRandom"};
if (isDedicated) then {
_position = [getMarkerPos "center",0,4000,10,0,2000,0] call BIS_fnc_findSafePos;
diag_log("DEBUG: Spawning a Misc_cargo_cont_net2 at " + str(_position));
_veh = createVehicle ["Misc_cargo_cont_net2",_position, [], 0, "CAN_COLLIDE"];
dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_veh];
_veh setVariable ["ObjectID",1,true];
 
_num = round(random 6) + 5;
_config = configFile >> "CfgBuildingLoot" >> "Industrial";
_itemType = [] + getArray (_config >> "itemType");
//diag_log ("DW_DEBUG: _itemType: " + str(_itemType));
_itemChance = [] + getArray (_config >> "itemChance");
//diag_log ("DW_DEBUG: _itemChance: " + str(_itemChance));
//diag_log ("DW_DEBUG: (isnil fnc_buildWeightedArray): " + str(isnil "fnc_buildWeightedArray"));
 
waituntil {!isnil "fnc_buildWeightedArray"};
 
_weights = [];
_weights = [_itemType,_itemChance] call fnc_buildWeightedArray;
//diag_log ("DW_DEBUG: _weights: " + str(_weights));
for "_x" from 1 to _num do {
//create loot
_index = _weights call BIS_fnc_selectRandom;
sleep 1;
if (count _itemType > _index) then {
//diag_log ("DW_DEBUG: " + str(count (_itemType)) + " select " + str(_index));
_iArray = _itemType select _index;
_iArray set [2,_position];
_iArray set [3,5];
_iArray call spawn_loot;
_nearby = _position nearObjects ["WeaponHolder",30];
{
_x setVariable ["permaLoot",true];
} forEach _nearBy;
};
};
};
};
 
spawn_Misc_cargo_cont_net3 = {
private["_position","_veh","_num","_config","_itemType","_itemChance","_weights","_index","_iArray"];
 
waitUntil{!isNil "BIS_fnc_selectRandom"};
if (isDedicated) then {
_position = [getMarkerPos "center",0,4000,10,0,2000,0] call BIS_fnc_findSafePos;
diag_log("DEBUG: Spawning a Misc_cargo_cont_net3 at " + str(_position));
_veh = createVehicle ["Misc_cargo_cont_net3",_position, [], 0, "CAN_COLLIDE"];
//dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_veh];
_veh setVariable ["ObjectID",1,true];
 
_num = round(random 6) + 3;
_config = configFile >> "CfgBuildingLoot" >> "Military";
_itemType = [] + getArray (_config >> "itemType");
//diag_log ("DW_DEBUG: _itemType: " + str(_itemType));
_itemChance = [] + getArray (_config >> "itemChance");
//diag_log ("DW_DEBUG: _itemChance: " + str(_itemChance));
//diag_log ("DW_DEBUG: (isnil fnc_buildWeightedArray): " + str(isnil "fnc_buildWeightedArray"));
 
waituntil {!isnil "fnc_buildWeightedArray"};
 
_weights = [];
_weights = [_itemType,_itemChance] call fnc_buildWeightedArray;
//diag_log ("DW_DEBUG: _weights: " + str(_weights));
for "_x" from 1 to _num do {
//create loot
_index = _weights call BIS_fnc_selectRandom;
sleep 1;
if (count _itemType > _index) then {
//diag_log ("DW_DEBUG: " + str(count (_itemType)) + " select " + str(_index));
_iArray = _itemType select _index;
_iArray set [2,_position];
_iArray set [3,5];
_iArray call spawn_loot;
diag_log("LOOTSPAWN: " + str(_iArray) + " Spawned At A Military Care Package");
_nearby = _position nearObjects ["WeaponHolder",20];
{
_x setVariable ["permaLoot",true];
} forEach _nearBy;
};
};
};
};

This gets inserted after the helicrash script.

Once you have that in and save, you need to open your system>server_monitor.sqf. All the way at the bottom, find:

//Spawn crashed helos
for "_x" from 1 to 6 do {
_id = [] spawn spawn_heliCrash;
//waitUntil{scriptDone _id};
};

If you did not already know, this is how many helicrashes will spawn on your server. After that, add:

Code:
//Spawn Misc_cargo_cont_net1
for "_x" from 1 to 6 do {
_id = [] spawn spawn_Misc_cargo_cont_net1;
//waitUntil{scriptDone _id};
};
 
//Spawn Misc_cargo_cont_net2
for "_x" from 1 to 4 do {
_id = [] spawn spawn_Misc_cargo_cont_net2;
//waitUntil{scriptDone _id};
};
 
//Spawn Misc_cargo_cont_net3
for "_x" from 1 to 4 do {
_id = [] spawn spawn_Misc_cargo_cont_net3;
//waitUntil{scriptDone _id};
};

Save your file, re-pbo it, and your server should now be spawning care packages!

Find out by reading the arma2oaserver.RPT file, and if you used the code above, that report will be telling you where the care packages are spawning at. It will look like:

Code:
 9:27:15 "DEBUG: Spawning a Misc_cargo_cont_net1 at [4439.73,5652.6]"
9:27:15 "DEBUG: Spawning a Misc_cargo_cont_net1 at [6150.82,8862.69]"
9:27:15 "DEBUG: Spawning a Misc_cargo_cont_net1 at [6927.37,9635.6]"
9:27:15 "DEBUG: Spawning a Misc_cargo_cont_net1 at [7709.75,10066.2]"
9:27:16 "DEBUG: Spawning a Misc_cargo_cont_net1 at [8851.32,8559.9]"
9:27:16 "DEBUG: Spawning a Misc_cargo_cont_net1 at [11568.6,7472.14]"
9:27:16 "DEBUG: Spawning a Misc_cargo_cont_net2 at [10107.4,10482.1]"
9:27:16 "DEBUG: Spawning a Misc_cargo_cont_net2 at [4589.17,5770.46]"
9:27:16 "DEBUG: Spawning a Misc_cargo_cont_net2 at [8184.35,5794.95]"
9:27:16 "DEBUG: Spawning a Misc_cargo_cont_net2 at [9620.19,9641.57]"
9:27:16 "DEBUG: Spawning a Misc_cargo_cont_net3 at [4793.86,7343.37]"
9:27:16 "DEBUG: Spawning a Misc_cargo_cont_net3 at [6780.27,7904.9]"
9:27:16 "DEBUG: Spawning a Misc_cargo_cont_net3 at [5129.41,5487.15]"
9:27:16 "DEBUG: Spawning a Misc_cargo_cont_net3 at [10034.1,8499.07]"

And that's it for care packages!
 
I have also played with the vehicle types and loot types, and came up with the following different crashes I figured I would share.

First up are Ural crashes. I have them spawning regular Military loot, which is the kind you can find in fire stations and deer stands.

Here is the server_functions.sqf for the Urals:

Code:
spawn_UralCrash = {
private["_position","_veh","_num","_config","_itemType","_itemChance","_weights","_index","_iArray"];
 
waitUntil{!isNil "BIS_fnc_selectRandom"};
if (isDedicated) then {
_position = [getMarkerPos "center",0,4000,10,0,2000,0] call BIS_fnc_findSafePos;
diag_log("DEBUG: Spawning a Ural Crash at " + str(_position));
_veh = createVehicle ["UralWreck",_position, [], 0, "CAN_COLLIDE"];
dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_veh];
_veh setVariable ["ObjectID",1,true];
dayzFire = [_veh,2,time,false,false];
publicVariable "dayzFire";
if (isServer) then {
nul=dayzFire spawn BIS_Effects_Burn;
};
_num = round(random 6) + 3;
_config = configFile >> "CfgBuildingLoot" >> "Military";
_itemType = [] + getArray (_config >> "itemType");
//diag_log ("DW_DEBUG: _itemType: " + str(_itemType));
_itemChance = [] + getArray (_config >> "itemChance");
//diag_log ("DW_DEBUG: _itemType: " + str(_itemType));
//_itemChance = [] + getArray (_config >> "itemChance");
//diag_log ("DW_DEBUG: _itemChance: " + str(_itemChance));
//diag_log ("DW_DEBUG: (isnil fnc_buildWeightedArray): " + str(isnil "fnc_buildWeightedArray"));
 
waituntil {!isnil "fnc_buildWeightedArray"};
 
_weights = [];
_weights = [_itemType,_itemChance] call fnc_buildWeightedArray;
//diag_log ("DW_DEBUG: _weights: " + str(_weights));
for "_x" from 1 to _num do {
//create loot
_index = _weights call BIS_fnc_selectRandom;
sleep 1;
if (count _itemType > _index) then {
//diag_log ("DW_DEBUG: " + str(count (_itemType)) + " select " + str(_index));
_iArray = _itemType select _index;
_iArray set [2,_position];
_iArray set [3,5];
_iArray call spawn_loot;
_nearby = _position nearObjects ["WeaponHolder",20];
{
_x setVariable ["permaLoot",true];
} forEach _nearBy;
};
};
};
};

Then in server_monitor.sqf:

Code:
//Spawn crashed Ural
for "_x" from 1 to 4 do {
    _id = [] spawn spawn_UralCrash;
    //waitUntil{scriptDone _id};
};

This code is completely interchangeable with other types of vehicles or even buildings. I have used the MI8, UAZs, BMPs, BDRMs, and three types of small buildings.

Here is the excerpt for one of the "supply depots" as I call them on my server.

In server_functions.sqf:

Code:
spawn_Outpost1 = {
private["_position","_veh","_num","_config","_itemType","_itemChance","_weights","_index","_iArray"];
 
waitUntil{!isNil "BIS_fnc_selectRandom"};
if (isDedicated) then {
_position = [getMarkerPos "center",0,6000,10,0,3000,0] call BIS_fnc_findSafePos;
diag_log("DEBUG: Spawning a Outpost1 at " + str(_position));
_veh = createVehicle ["RU_WarfareBUAVterminal",_position, [], 0, "CAN_COLLIDE"];
dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_veh];
_veh setVariable ["ObjectID",1,true];
_num = round(random 6) + 3;
_config = configFile >> "CfgBuildingLoot" >> "MilitarySpecial";
_itemType = [] + getArray (_config >> "itemType");
//diag_log ("DW_DEBUG: _itemType: " + str(_itemType));
_itemChance = [] + getArray (_config >> "itemChance");//diag_log ("DW_DEBUG: _itemType: " + str(_itemType));
//_itemChance = [] + getArray (_config >> "itemChance");
//diag_log ("DW_DEBUG: _itemChance: " + str(_itemChance));
//diag_log ("DW_DEBUG: (isnil fnc_buildWeightedArray): " + str(isnil "fnc_buildWeightedArray"));
 
waituntil {!isnil "fnc_buildWeightedArray"};
 
_weights = [];
_weights = [_itemType,_itemChance] call fnc_buildWeightedArray;
//diag_log ("DW_DEBUG: _weights: " + str(_weights));
for "_x" from 1 to _num do {
//create loot
_index = _weights call BIS_fnc_selectRandom;
sleep 1;
if (count _itemType > _index) then {
//diag_log ("DW_DEBUG: " + str(count (_itemType)) + " select " + str(_index));
_iArray = _itemType select _index;
_iArray set [2,_position];
_iArray set [3,5];
_iArray call spawn_loot;
diag_log("LOOTSPAWN: " + str(_iArray) + " Spawned At A UH-1Y CrashSite");
_nearby = _position nearObjects ["WeaponHolder",20];
{
_x setVariable ["permaLoot",true];
} forEach _nearBy;
};
};
};
};

And in server_monitor.sqf:

Code:
//Spawn Outpost1
for "_x" from 1 to 2 do {
    _id = [] spawn spawn_Outpost1;
    //waitUntil{scriptDone _id};
};


Any questions or suggestions, feel free to post.
 
Like like like like. Have been contemplating doing this myself but never had the time. Will be putting this up on my server in the next few days. Will post feedback when I do. Thank you :)

Admins this should be a sticky!


EDIT: Works great. Modified for Mi8 and T72 crashes too/
 
Any updates on how to get this working for 1.7.5?

EDIT 1: I'm going to try just commenting out the system for 1.7.5 and paste back in the scripts from 1.7.4.4. It is probably pretty obvious now that I have no idea wtf I'm doing, but it would be nice if it worked! xD
EDIT 2: Incredibly, it seems to work to comment out the new system and paste the old system back in. The only thing I can't seem to get working is the smoke effect on the helicrashes. The fire effect is fine, loot spawns, everything works, but no smoke.
EDIT3: Manually added smoke on a repeating script, everything works.
 
Back
Top