This commit is contained in:
A Clark
2013-01-12 20:59:54 -06:00
parent 7e52d6ee28
commit b893b72b72
2 changed files with 70 additions and 60 deletions

View File

@@ -182,19 +182,17 @@ RoadList = MarkerPosition nearRoads DynamicVehicleArea;
BuildingList = MarkerPosition nearObjects ["House",DynamicVehicleArea];
spawn_vehicles = {
private["_vehicle","_isAir","_isShip","_position","_roadlist","_buildinglist","_istoomany","_marker","_veh","_objPosition","_weights","_index","_uid","_velimit","_counter"];
private["_weights","_isOverLimit","_isAbort","_counter","_index","_vehicle","_velimit","_qty","_isAir","_isShip","_position","_dir","_istoomany","_veh","_objPosition"];
if (isDedicated) then {
_counter = _this select 0;
waituntil {!isnil "fnc_buildWeightedArray"};
_weights = [];
_weights = [AllowedVehiclesList,AllowedVehiclesChance] call fnc_buildWeightedArray;
_isOverLimit = true;
_isAbort = false;
_counter = 0;
while {_isOverLimit} do {
waitUntil{!isNil "BIS_fnc_selectRandom"};
@@ -203,7 +201,7 @@ spawn_vehicles = {
_vehicle = AllowedVehiclesList select _index;
_velimit = AllowedVehiclesLimit select _index;
_qty = {_x == _vehicle} count _counter;
_qty = {_x == _vehicle} count serverVehicleCounter;
// If under limit allow to proceed
if(_qty < _velimit) then {
@@ -211,15 +209,25 @@ spawn_vehicles = {
};
// TODO add counter to stop after X attempts
_counter = _counter + 1;
if(_counter > 5) then {
_isOverLimit = false;
_isAbort = true;
};
};
if (_isAbort) then {
diag_log("DEBUG: unable to find sutable vehicle");
} else {
// add vehicle to counter for next pass
serverVehicleCounter set [count serverVehicleCounter,_vehicle];
// Find Vehicle Type to better control spawns
_isAir = _vehicle isKindOf "Air";
_isShip = _vehicle isKindOf "Ship";
if(_isShip || _isAir) then {
if(_isShip) then {
// Spawn anywhere on coast on water
@@ -288,6 +296,7 @@ spawn_vehicles = {
[_veh,[_dir,_objPosition],_vehicle,true,"0"] call server_publishVeh;
};
};
};
};
spawn_roadblocks = {

View File

@@ -3,7 +3,7 @@
dayz_versionNo = getText(configFile >> "CfgMods" >> "DayZ" >> "version");
dayz_hiveVersionNo = getNumber(configFile >> "CfgMods" >> "DayZ" >> "hiveVersion");
_serverVehicleCounter = [];
serverVehicleCounter = [];
if ((count playableUnits == 0) and !isDedicated) then {
isSinglePlayer = true;
@@ -169,7 +169,7 @@ diag_log "HIVE: Starting";
_totalvehicles = _totalvehicles + 1;
// total each vehicle
_serverVehicleCounter set [count _serverVehicleCounter,_type];
serverVehicleCounter set [count _serverVehicleCounter,_type];
};
@@ -226,13 +226,14 @@ _vehLimit = MaxVehicleLimit - _totalvehicles;
diag_log ("HIVE: Spawning # of Vehicles: " + str(_vehLimit));
if(_vehLimit > 0) then {
for "_x" from 1 to _vehLimit do {
_id = [_serverVehicleCounter] spawn spawn_vehicles; // Needs setup
_id = [] spawn spawn_vehicles; // Needs setup
waitUntil{scriptDone _id};
};
};
// spawn_roadblocks
diag_log ("HIVE: Spawning # of Debris: " + str(MaxDynamicDebris));
for "_x" from 1 to MaxDynamicDebris do {
_id = [] spawn spawn_roadblocks;
//waitUntil{scriptDone _id};