mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2025-12-14 04:02:37 +03:00
Fix SpawnVehicle #821
This commit is contained in:
@@ -211,38 +211,31 @@ BuildingList = [];
|
|||||||
} forEach (MarkerPosition nearObjects ["building",DynamicVehicleArea]);
|
} forEach (MarkerPosition nearObjects ["building",DynamicVehicleArea]);
|
||||||
|
|
||||||
spawn_vehicles = {
|
spawn_vehicles = {
|
||||||
private ["_weights","_isOverLimit","_isAbort","_counter","_index","_vehicle","_velimit","_qty","_isAir","_isShip","_position","_dir","_istoomany","_veh","_objPosition","_marker","_iClass","_itemTypes","_cntWeights","_itemType","_num","_allCfgLoots"];
|
private ["_weights","_index","_vehicle","_velimit","_qty","_isAir","_isShip","_position","_dir","_istoomany","_veh","_objPosition","_marker","_iClass","_itemTypes","_cntWeights","_itemType","_num","_allCfgLoots"];
|
||||||
|
|
||||||
if (isDedicated) then {
|
if (isDedicated) then {
|
||||||
|
|
||||||
_isOverLimit = true;
|
while {count AllowedVehiclesList > 0} do {
|
||||||
_isAbort = false;
|
// BIS_fnc_selectRandom replaced because the index may be needed to remove the element
|
||||||
_counter = 0;
|
_index = floor random count AllowedVehiclesList;
|
||||||
while {_isOverLimit} do {
|
_random = AllowedVehiclesList select _index;
|
||||||
|
|
||||||
waitUntil{!isNil "BIS_fnc_selectRandom"};
|
_vehicle = _random select 0;
|
||||||
_index = AllowedVehiclesList call BIS_fnc_selectRandom;
|
_velimit = _random select 1;
|
||||||
|
|
||||||
_vehicle = _index select 0;
|
|
||||||
_velimit = _index select 1;
|
|
||||||
|
|
||||||
_qty = {_x == _vehicle} count serverVehicleCounter;
|
_qty = {_x == _vehicle} count serverVehicleCounter;
|
||||||
|
|
||||||
// If under limit allow to proceed
|
// If under limit allow to proceed
|
||||||
if(_qty <= _velimit) then {
|
if (_qty <= _velimit) exitWith {};
|
||||||
_isOverLimit = false;
|
|
||||||
|
// vehicle limit reached, remove vehicle from list
|
||||||
|
// since elements cannot be removed from an array, overwrite it with the last element and cut the last element of (as long as order is not important)
|
||||||
|
_lastIndex = (count AllowedVehiclesList) - 1;
|
||||||
|
AllowedVehiclesList set [_index, AllowedVehiclesList select _lastIndex];
|
||||||
|
AllowedVehiclesList resize _lastIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
// counter to stop after 5 attempts
|
if (count AllowedVehiclesList == 0) then {
|
||||||
_counter = _counter + 1;
|
|
||||||
|
|
||||||
if(_counter >= 5) then {
|
|
||||||
_isOverLimit = false;
|
|
||||||
_isAbort = true;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
if (_isAbort) then {
|
|
||||||
diag_log("DEBUG: unable to find suitable vehicle to spawn");
|
diag_log("DEBUG: unable to find suitable vehicle to spawn");
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user