spawn_heliCrash = {
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 helicopter crashed at" + str(_position));
_veh createVehicle = ["UH1Wreck_DZ" _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 4) + 3;
_config = configFile >> "CfgBuildingLoot" >> "HeliCrash";
_ItemType = [["AK_107_Kobra", "weapon"],["revolver_gold_EP1", "weapon"],["AK_107", "weapon"], ["G36C_SD_Camo", "weapon"], ["G36K_Camo", "weapon"], ["M4A1_HWS", "weapon"], ["M4A1_HWS_GL_SD_CAMO", "weapon"], ["FN_FAL", "weapon"], ["M14_EP1", "weapon"], ["FN_FAL_ANPVS4", "weapon"], ["BAF_L85A2_RIS_Holo", "weapon "], ["M40A3", "weapon"], ["Mk_48_DZ", "weapon"], ["M249_DZ", "weapon"], ["SVD_CAMO", "weapon"], ["DMR", "weapon "], ["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 = [0.2, 0.01, 0.5, 0.04, 0.04, 0.06, 0.02, 0.3, 0.3, 0.02, 0.03, 0.05, 0.1, 0.1, 0.1, 0.5, 0.1, 0.1, 0.03, 0.03, 0.3, 0.3, 0.3];
// 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 near objects ["Weapon Holder", 20];
{
_x setVariable ["permaLoot", true];
ForEach} _nearBy;
};
};
};
};