SHOW:
|
|
- or go back to the newest paste.
| 1 | private ["_guaranteedLoot", "_randomizedLoot", "_spawnOnStart", "_frequency", "_variance", "_spawnChance", "_spawnMarker", "_spawnRadius", "_spawnFire", "_fadeFire", "_timeAdjust", "_timeToSpawn", "_crashModel", "_lootTable", "_crashName", "_position", "_crash", "_clutter", "_config", "_newHeight", "_itemTypes", "_index", "_weights", "_cntWeights", "_itemType", "_nearby", "_nearBy"]; | |
| 2 | ||
| 3 | _guaranteedLoot = _this select 0; | |
| 4 | _randomizedLoot = _this select 1; | |
| 5 | _spawnOnStart = _this select 2; | |
| 6 | _frequency = _this select 3; | |
| 7 | _variance = _this select 4; | |
| 8 | _spawnChance = _this select 5; | |
| 9 | _spawnMarker = _this select 6; | |
| 10 | _spawnRadius = _this select 7; | |
| 11 | _spawnFire = _this select 8; | |
| 12 | _fadeFire = _this select 9; | |
| 13 | ||
| 14 | ||
| 15 | diag_log("CRASHSPAWNER: Starting spawn logic for Crash Spawner");
| |
| 16 | ||
| 17 | while {true} do {
| |
| 18 | // Allows the variance to act as +/- from the spawn frequency timer | |
| 19 | _timeAdjust = round(random(_variance * 2) - _variance); | |
| 20 | _timeToSpawn = time + _frequency + _timeAdjust; | |
| 21 | ||
| 22 | //Selecting random crash type | |
| 23 | _crashModel = ["UH60Wreck_DZ","UH1Wreck_DZ","Mi8Wreck_DZ"] call BIS_fnc_selectRandom; | |
| 24 | ||
| 25 | //selecting loottable | |
| 26 | //Random lootables? | |
| 27 | //if (_crashModel == "Mi8Wreck_DZ") then {_lootTable = ["MilitaryEAST","HeliCrashEAST"] call BIS_fnc_selectRandom;}
| |
| 28 | //else {_lootTable = ["MilitaryWEST","HeliCrashWEST"] call BIS_fnc_selectRandom;};
| |
| 29 | ||
| 30 | //or just helicrash loottable | |
| 31 | - | if (_crashModel == "Mi8Wreck_DZ") then {_lootTable = "HeliCrashEAST";}
|
| 31 | + | if (_crashModel == "Mi8Wreck_DZ") then {_lootTable = "MilitaryEAST";}
|
| 32 | - | else {_lootTable = "HeliCrashWEST";};
|
| 32 | + | else {_lootTable = "MilitaryEAST";};
|
| 33 | ||
| 34 | _crashName = getText (configFile >> "CfgVehicles" >> _crashModel >> "displayName"); | |
| 35 | ||
| 36 | diag_log(format["CRASHSPAWNER: %1%2 chance to spawn '%3' with loot table '%4' at %5", round(_spawnChance * 100), '%', _crashName, _lootTable, _timeToSpawn]); | |
| 37 | ||
| 38 | // Apprehensive about using one giant long sleep here given server time variances over the life of the server daemon | |
| 39 | while {(_spawnOnStart <= 0) AND {(time < _timeToSpawn)}} do {
| |
| 40 | sleep (_frequency / 4); | |
| 41 | }; | |
| 42 | ||
| 43 | // Percentage roll | |
| 44 | if (random 1 <= _spawnChance) then {
| |
| 45 | _position = [getMarkerPos _spawnMarker,0,_spawnRadius,10,0,2000,0] call BIS_fnc_findSafePos; | |
| 46 | diag_log(format["CRASHSPAWNER: Spawning '%1' with loot table '%2' NOW! (%3) at: %4 - (%5)", _crashName, _lootTable, time, str(_position),mapGridPosition _position]); | |
| 47 | ||
| 48 | _crash = createVehicle [_crashModel,_position, [], 0, "CAN_COLLIDE"]; | |
| 49 | ||
| 50 | // Randomize the direction the wreck is facing | |
| 51 | _crash setDir round(random 360); | |
| 52 | ||
| 53 | // Using "custom" wrecks (using the destruction model of a vehicle vs. a prepared wreck model) will result | |
| 54 | // in the model spawning halfway in the ground. To combat this, an OPTIONAL configuration can be tied to | |
| 55 | // the CfgVehicles class you've created for the custom wreck to define how high above the ground it should | |
| 56 | // spawn. This is optional. | |
| 57 | _config = configFile >> "CfgVehicles" >> _crashModel >> "heightAdjustment"; | |
| 58 | _newHeight = 0; | |
| 59 | if ( isNumber(_config)) then {
| |
| 60 | _newHeight = getNumber(_config); | |
| 61 | }; | |
| 62 | ||
| 63 | // Must setPos after a setDir otherwise the wreck won't level itself with the terrain | |
| 64 | _crash setPos [(_position select 0), (_position select 1), _newHeight]; | |
| 65 | ||
| 66 | // I don't think this is needed (you can't get "in" a crash), but it was in the original DayZ Crash logic | |
| 67 | dayz_serverObjectMonitor set [count dayz_serverObjectMonitor,_crash]; | |
| 68 | _crash setVariable ["ObjectID",1,true]; | |
| 69 | ||
| 70 | if (_spawnFire) then {
| |
| 71 | //["PVDZ_obj_Fire",[_crash,2,time,false,_fadeFire]] call broadcastRpcCallAll; | |
| 72 | PVDZ_obj_Fire = [_crash,2,time,false,_fadeFire]; | |
| 73 | publicVariable "PVDZ_obj_Fire"; | |
| 74 | _crash setvariable ["fadeFire",_fadeFire,true]; | |
| 75 | }; | |
| 76 | //Custom loot table | |
| 77 | //Mark out new and replace with old if not functioning | |
| 78 | // 35 Items | |
| 79 | - | _itemTypes = [["", "food"], ["", "MilitaryEAST"], ["MedBox0", "object"], ["AmmoBoxSmall_556", "object"], ["AmmoBoxSmall_762", "object"], ["Skin_Camo1_DZ", "magazine"], ["Skin_Soldier1_DZ", "magazine"], ["Skin_Sniper1_DZ", "magazine"], ["FN_FAL","weapon"], ["FN_FAL_ANPVS4","weapon"], ["M14_EP1","weapon"], ["Mk_48_DZ","weapon"], ["M249_DZ","weapon"], ["M240_DZ","weapon"], ["DMR","weapon"], ["G36C","weapon"], ["G36K","weapon"], ["G36a","weapon"], ["G36C_camo","weapon"], ["G36A_camo","weapon"], ["G36K_camo","weapon"], ["G36_c_SD_eotech","weapon"], ["SVD_CAMO","weapon"], ["M24","weapon"], ["M4A1_AIM_SD_camo","weapon"], ["Sa58V_CCO_EP1","weapon"], ["m107_DZ","weapon"], ["BAF_AS50_scoped","weapon"], ["MP5SD","weapon"], ["M40A3","weapon"], ["MP5A5","weapon"], ["M4A3_CCO_EP1","weapon"], ["M4A1_HWS_GL","weapon"], ["M4A1_Aim","weapon"], ["m16a4_acg","weapon"], ["M16A2GL","weapon"], ["BAF_L85A2_RIS_Holo","weapon"], ["MG36_camo","weapon"]]; |
| 79 | + | // 35 Chances adding too 1.0 <<---- mast add to 1.0 |
| 80 | - | _itemChance = [0.09, 0.02, 0.02, 0.4, 0.1, 0.02, 0.02, 0.01, 0.08, 0.02, 0.04, 0.01, 0.08, 0.01, 0.06, 0.08, 0.03, 0.04, 0.04, 0.04, 0.01, 0.01, 0.04, 0.04, 0.01, 0.08, 0.01, 0.01, 0.04, 0.01, 0.04, 0.03, 0.06, 0.04, 0.04, 0.05, 0.03, 0.01]; |
| 80 | + | |
| 81 | _itemTypes = [["", "food"], ["", "MilitaryEAST"], ["MedBox0", "object"], ["AmmoBoxSmall_556", "object"], ["AmmoBoxSmall_762", "object"], ["Skin_Camo1_DZ", "magazine"], ["Skin_Soldier1_DZ", "magazine"], ["Skin_Sniper1_DZ", "magazine"], ["FN_FAL","weapon"], ["FN_FAL_ANPVS4","weapon"], ["M14_EP1","weapon"], ["Mk_48_DZ","weapon"], ["M249_DZ","weapon"], ["M240_DZ","weapon"], ["DMR","weapon"], ["G36C","weapon"], ["G36K","weapon"], ["G36a","weapon"], ["G36C_camo","weapon"], ["G36A_camo","weapon"], ["G36K_camo","weapon"], ["SVD_CAMO","weapon"], ["M24","weapon"], ["M4A1_AIM_SD_camo","weapon"], ["Sa58V_CCO_EP1","weapon"], ["m107_DZ","weapon"], ["BAF_AS50_scoped","weapon"], ["MP5SD","weapon"], ["M40A3","weapon"], ["MP5A5","weapon"], ["M4A3_CCO_EP1","weapon"], ["M4A1_Aim","weapon"], ["m16a4_acg","weapon"], ["M16A2GL","weapon"], ["BAF_L85A2_RIS_Holo","weapon"]]; | |
| 82 | _itemChance = [0.06, 0.02, 0.02, 0.01, 0.01, 0.02, 0.02, 0.01, 0.05, 0.01, 0.04, 0.01, 0.06, 0.01, 0.05, 0.06, 0.03, 0.04, 0.03, 0.03, 0.03, 0.04, 0.04, 0.01, 0.08, 0.01, 0.01, 0.03, 0.01, 0.03, 0.03, 0.02, 0.02, 0.04, 0.01,]; | |
| 83 | _weights = []; | |
| 84 | _weights = [_itemType,_itemChance] call fnc_buildWeightedArray; | |
| 85 | _cntWeights = count _weights; | |
| 86 | _index = _weights call BIS_fnc_selectRandom; | |
| 87 | ||
| 88 | //_itemTypes = [] + getArray (configFile >> "CfgBuildingLoot" >> _lootTable >> "lootType"); | |
| 89 | //_index = dayz_CBLBase find _lootTable; | |
| 90 | //_weights = dayz_CBLChances select _index; | |
| 91 | - | for "_x" from 1 to (round(random 4) + 4) do {
|
| 91 | + | |
| 92 | ||
| 93 | for "_x" from 1 to (round(random 3) + 3) do {
| |
| 94 | //create loot | |
| 95 | _index = floor(random _cntWeights); | |
| 96 | _index = _weights select _index; | |
| 97 | _itemType = _itemTypes select _index; | |
| 98 | ||
| 99 | _position = [_position,(sizeOf _crashModel)/2,(sizeOf _crashModel),0,0,0,0] call BIS_fnc_findSafePos; | |
| 100 | _position = [_position select 0,_position select 1,0]; | |
| 101 | ||
| 102 | [_itemType select 0, _itemType select 1, _position, (sizeOf _crashModel)] call spawn_loot; | |
| 103 | ||
| 104 | //Grass clear system uncomment for clear areas around choppers loot. Remove the // from the next two lines to enable | |
| 105 | ||
| 106 | _clutter = createVehicle ["ClutterCutter_small_2_EP1", _position, [], 0, "CAN_COLLIDE"]; | |
| 107 | _clutter setPos _position; | |
| 108 | ||
| 109 | diag_log(format["CRASHSPAWNER: Loot spawn at '%1 - %3' with loot table '%2'", _crashName, str(_itemType),_position]); | |
| 110 | ||
| 111 | // ReammoBox is preferred parent class here, as WeaponHolder wouldn't match MedBox0 and other such items. | |
| 112 | _nearby = _position nearObjects ["ReammoBox", sizeOf(_crashModel)]; | |
| 113 | {
| |
| 114 | _x setVariable ["permaLoot",true]; | |
| 115 | } forEach _nearBy; | |
| 116 | }; | |
| 117 | _spawnOnStart = _spawnOnStart -1; | |
| 118 | } else {
| |
| 119 | diag_log(format["CRASHSPAWNER: %1%2 chance to spawn '%3' with loot table '%4' at %5 FAILED (chance)", round(_spawnChance * 100), '%', _crashName, _lootTable, _timeToSpawn]); | |
| 120 | }; | |
| 121 | }; |