From 396f58e94171e1f9e5a3a3b8d687258bfb3603e1 Mon Sep 17 00:00:00 2001 From: vbawol Date: Wed, 14 Oct 2015 16:27:09 -0500 Subject: [PATCH] fixes and less debug --- .../@epochhive/addons/a3_epoch_server.pbo | Bin 360647 -> 361780 bytes .../sc/battleye/createvehicle.txt | 2 +- .../epoch_bases/EPOCH_server_saveBuilding.sqf | 2 +- .../epoch_server/EPOCH_localCleanup.sqf | 18 +- .../EPOCH_server_loadTraders.sqf | 3 +- .../EPOCH_server_makeNPCTrade.sqf | 43 ++++- .../epoch_vehicle/EPOCH_load_storage.sqf | 4 +- .../epoch_vehicle/EPOCH_load_vehicles.sqf | 3 +- .../epoch_vehicle/EPOCH_save_storage.sqf | 2 +- .../EPOCH_server_lockStorage.sqf | 6 +- .../EPOCH_server_packStorage.sqf | 2 +- .../epoch_vehicle/EPOCH_spawn_vehicle.sqf | 169 +++++++++--------- .../epoch_vehicle/EPOCH_spawn_vehicles.sqf | 168 +++++++++-------- .../epoch_server/system/server_monitor.fsm | 6 +- 14 files changed, 229 insertions(+), 199 deletions(-) diff --git a/Server_Install_Pack/@epochhive/addons/a3_epoch_server.pbo b/Server_Install_Pack/@epochhive/addons/a3_epoch_server.pbo index 488401bfbde647a38f510f82a3c8887cee7df641..20dee4069579a2759aadb96d30627cf7705bb795 100644 GIT binary patch delta 3823 zcmb7HdvKFg7WdwKNlDVQNs~5xrnhNR`+}Ah2c^mwX@L%<6v3!;OZZ5>wvjK7CMj63 zJQOJ7V^_T3#T68hb=~nTtKW)>6d5YWitg+TGs?QMvootRK5)nNv7qj`_e&wW|7~WP zd+#~FbIv`_n@(;i`u)8{556lsI^YTHJhND=l%PMGIHAx^&l{@Q#^-PzZNxS~J8TuS z=(E_uE3xQC zLa1aK2o*i(}9}uWon?UtHg>&gy$sr7U zN|%~yX|t(9hxVE}1++|}=S}s8j+rH1us*g~B-4nbQxjnn7@ z=GCUXaOpX<0&@6OTtFKw`z21JXDoif^yUH6N87Ds;&|3hhjT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hly!AdwBIsDjK&p%vJ|J(# zMdqVd4*ZttekN5^(0b+9+VH3Z zPjU5KVk@21=caf5YIK{8W+Tg^PK*iV?A)7TAt}P{L`yr&;{`#3N}Jqxq#ex09zhI8 zMM1qYr`sXT)x%DA(zjNMh9+JA+YSPzcd)8fsz?wIybwni=yK z!b}oa2h}!dWcWiF@=%tcz{8wcSY1t0Sdyc{I$3IC`^dUbi`hsEdgkKSGGwAP3h9^^ zg&@8hg*LnsWr+(hm<57>pU&szqQrzmL9JR~4=&E-W+hAs4CqB+2H28Ro7xWz^YdJ; zRQ11_%cWpVClq;9lU8W3xml3eOT}^tOHwS#3f$KTDV!jL*5OZn3~nqLBBr|mKJSEu zHpYCn^BRA47ZkCGDruY;2aXUgF6(63Tv`DM_{%P^jc@_0qOqXT@YYS7gIYqi*0n3Ok9uly(o4s_k`ym;(c7uhF$WY2Q z!D<~2?qsOLJ7N2R9Bpc?@>K`hM0O9@q{%50#4ul`kN&8xd4*Dw|+;5z3Zl;5i+VtuO<#cEbt`ZG%jwdL+UewWcLfC#$pM2SPqJ z?}idowt-h|>L0d&Kzfv+-S9Ps;a4FM-y48y`1W>az?b&2q;qzF182Mj>AX5@dy4U7 zo!+ffy$0I}zHWdroc{vMq`xR^#8 _limit) then { (_arr select 1) set [_forEachIndex,_limit]; _currentStock = _limit; diff --git a/Sources/epoch_server/compile/epoch_trading/EPOCH_server_makeNPCTrade.sqf b/Sources/epoch_server/compile/epoch_trading/EPOCH_server_makeNPCTrade.sqf index 83abc489..703a3ba8 100644 --- a/Sources/epoch_server/compile/epoch_trading/EPOCH_server_makeNPCTrade.sqf +++ b/Sources/epoch_server/compile/epoch_trading/EPOCH_server_makeNPCTrade.sqf @@ -15,6 +15,7 @@ _vehicleBought = false; _returnIn = []; _returnOut = []; +_final_location = []; if (isNull _trader) exitWith{}; if !([_plyr,_this select 4] call EPOCH_server_getPToken) exitWith {}; @@ -34,7 +35,7 @@ if (_slot != -1) then { _current_crypto = _vars select _cIndex; _current_cryptoRaw = _current_crypto; - // diag_log format["_current_crypto: %1 _cIndex:%2", _current_crypto, _cIndex]; + //diag_log format["_current_crypto: %1 _cIndex:%2 %3", _current_crypto, _cIndex, _this]; // SELL ITEMS TO TRADER _aiItems = _trader getVariable["AI_ITEMS", [[], []]]; @@ -113,14 +114,14 @@ if (_slot != -1) then { _item = _x; _itemQty = 1; - // diag_log format["_item: %1", _item]; + //diag_log format["_item: %1", _item]; if (isClass (_config >> _item)) then{ _itemWorth = getNumber(_config >> _item >> "price"); _itemTax = getNumber(_config >> _item >> "tax"); _tax = _itemWorth * (EPOCH_taxRate + _itemTax); _itemWorth = ceil(_itemWorth + _tax); - // diag_log format["_itemWorth: %1", _itemWorth]; + //diag_log format["_itemWorth: %1", _itemWorth]; _qtyIndex = _itemClasses find _item; // add items to array @@ -128,7 +129,7 @@ if (_slot != -1) then { _currQty = _itemQtys select _qtyIndex; - // diag_log format["_currQty: %1 >= %2", _currQty, _itemQty]; + //diag_log format["_currQty: %1 >= %2", _currQty, _itemQty]; if (_currQty >= _itemQty) then { @@ -142,14 +143,30 @@ if (_slot != -1) then { _position = getPosATL _plyr; _helipad = nearestObjects[_position, ["Land_HelipadEmpty_F", "Land_HelipadCircle_F"], 100]; + _helipads = []; _smoke = nearestObject[_position, "SmokeShell"]; if (!isNull _smoke) then { _helipad pushBack _smoke; }; + // water check + if (_item isKindOf "Ship") then { + { + if (surfaceIsWater (getposATL _x)) then { + _helipads pushBack _x; + } + } forEach _helipad; + } else { + { + if !(surfaceIsWater (getposATL _x)) then { + _helipads pushBack _x; + } + } forEach _helipad; + }; + // diag_log format["DEBUG: helipad: %1", _helipad]; - if !(_helipad isEqualTo[]) then { + if !(_helipads isEqualTo[]) then { _foundSmoke = false; { @@ -168,9 +185,9 @@ if (_slot != -1) then { }; }; if (_foundSmoke) exitWith {}; - } forEach _helipad; + } forEach _helipads; if !(_foundSmoke) then { - _position = getPosATL (_helipad select 0); + _position = getPosATL (_helipads select 0); }; } else { _tmpposition = []; @@ -181,6 +198,10 @@ if (_slot != -1) then { _tmpposition = [_position, 20, 120, 20, 0, 2000, 0] call BIS_fnc_findSafePos; }; if ((count _tmpposition) == 2) then { + _tmpposition set [2, 0]; + if (surfaceIsWater _tmpposition) then { + _tmpposition = ATLtoASL _tmpposition; + }; _position = _tmpposition; }; }; @@ -204,7 +225,11 @@ if (_slot != -1) then { }; _vehObj = [_item,_position,random 360,true,_vehslot,_lockOwner,"NONE",false] call EPOCH_fnc_spawn_vehicle; - + _final_location = getPosATL _vehObj; + + _group = group _plyr; + _wp = _group addWaypoint [_final_location, 0]; + deleteWaypoint [_group, 0]; _returnOut pushBack _item; @@ -212,6 +237,8 @@ if (_slot != -1) then { _tradeTotal = _tradeTotal - _itemWorth; _current_crypto = _current_crypto - _itemWorth; _tradeQtyTotal = _tradeQtyTotal + _itemQty; + } else { + diag_log "DEBUG: no slots found to spawn vehicle"; }; }; } else { diff --git a/Sources/epoch_server/compile/epoch_vehicle/EPOCH_load_storage.sqf b/Sources/epoch_server/compile/epoch_vehicle/EPOCH_load_storage.sqf index 45a05357..787d1674 100644 --- a/Sources/epoch_server/compile/epoch_vehicle/EPOCH_load_storage.sqf +++ b/Sources/epoch_server/compile/epoch_vehicle/EPOCH_load_storage.sqf @@ -31,7 +31,7 @@ for "_i" from 1 to _this do { _worldspace = _arr select 1; _wsCount = count _worldspace; - diag_log format ["DEBUG: _wsCount %1 _worldspace %2", _wsCount, _worldspace]; + //diag_log format ["DEBUG: _wsCount %1 _worldspace %2", _wsCount, _worldspace]; // new worldspace format if (_wsCount == 3) then { @@ -94,7 +94,7 @@ for "_i" from 1 to _this do { // missionNamespace setVariable [format ["EPOCH_STORAGE_%1", _i], _vehicle]; - diag_log format ["STORAGE: created storage %1 at %2", _class, _location]; + // diag_log format ["STORAGE: created storage %1 at %2", _class, _location]; _vehicle call EPOCH_server_storageInit; diff --git a/Sources/epoch_server/compile/epoch_vehicle/EPOCH_load_vehicles.sqf b/Sources/epoch_server/compile/epoch_vehicle/EPOCH_load_vehicles.sqf index dabf1199..9161472b 100644 --- a/Sources/epoch_server/compile/epoch_vehicle/EPOCH_load_vehicles.sqf +++ b/Sources/epoch_server/compile/epoch_vehicle/EPOCH_load_vehicles.sqf @@ -248,7 +248,6 @@ if (_immuneVehicleSpawn) then{ addToRemainsCollector _allVehicles; -diag_log format ["VEH SPAWN TIMER %1", diag_tickTime - _diag]; -// diag_log (EPOCH_VehicleSlots); +diag_log format ["VEH SPAWN TIMER %1, LOADED 2% VEHICLES", diag_tickTime - _diag, count _allVehicles]; true diff --git a/Sources/epoch_server/compile/epoch_vehicle/EPOCH_save_storage.sqf b/Sources/epoch_server/compile/epoch_vehicle/EPOCH_save_storage.sqf index 588a0d3a..67bb62e5 100644 --- a/Sources/epoch_server/compile/epoch_vehicle/EPOCH_save_storage.sqf +++ b/Sources/epoch_server/compile/epoch_vehicle/EPOCH_save_storage.sqf @@ -67,7 +67,7 @@ if (!isNull _this) then { ["Storage", _vehHiveKey, EPOCH_expiresBuilding, _VAL] call EPOCH_fnc_server_hiveSETEX; //["Storage", _vehHiveKey, _VAL] call EPOCH_fnc_server_hiveSET; - diag_log format["STORAGE: saved to hive %1 Pos %2 Owners %3 Parent %4 Locked %5", _class, _worldspace, _storageOwners, _storageParent, _locked]; + diag_log format["STORAGE: saved to hive %1 Pos %2 Owners %3 Locked %4", _class, _worldspace, _storageOwners, _locked]; }; }; diff --git a/Sources/epoch_server/compile/epoch_vehicle/EPOCH_server_lockStorage.sqf b/Sources/epoch_server/compile/epoch_vehicle/EPOCH_server_lockStorage.sqf index 9274994c..6ace542a 100644 --- a/Sources/epoch_server/compile/epoch_vehicle/EPOCH_server_lockStorage.sqf +++ b/Sources/epoch_server/compile/epoch_vehicle/EPOCH_server_lockStorage.sqf @@ -36,7 +36,7 @@ if (getNumber(configFile >> "CfgVehicles" >> _type >> "isSecureStorage") == 1) t if (_type isKindOf "Secure_Storage_Proxy") then { _owners = _unit getVariable["STORAGE_OWNERS", []]; - diag_log format["_owners2 %1", _owners]; + //diag_log format["_owners2 %1", _owners]; // allow group members and owner access if (_plyrGroup != "") then { @@ -68,11 +68,11 @@ if (getNumber(configFile >> "CfgVehicles" >> _type >> "isSecureStorage") == 1) t } else { _weaponHolder = _unit getVariable["EPOCH_secStorParent", objNull]; - diag_log format["DEBUG: SecStor _weaponHolder %1", _weaponHolder]; + //diag_log format["DEBUG: SecStor _weaponHolder %1", _weaponHolder]; if (!isNull _weaponHolder) then { _owners = _weaponHolder getVariable["STORAGE_OWNERS", []]; - diag_log format["_owners %1", _owners]; + //diag_log format["_owners %1", _owners]; // allow group members and owner access if (_plyrGroup != "") then { diff --git a/Sources/epoch_server/compile/epoch_vehicle/EPOCH_server_packStorage.sqf b/Sources/epoch_server/compile/epoch_vehicle/EPOCH_server_packStorage.sqf index 6b1de866..6d44f5bd 100644 --- a/Sources/epoch_server/compile/epoch_vehicle/EPOCH_server_packStorage.sqf +++ b/Sources/epoch_server/compile/epoch_vehicle/EPOCH_server_packStorage.sqf @@ -9,7 +9,7 @@ _class = typeOf _unit; if (_class isKindOf 'Constructions_lockedstatic_F') then{ _weaponHolder = _unit getVariable["EPOCH_secStorParent", objNull]; - diag_log format["DEBUG: Pack _weaponHolder %1", _weaponHolder]; + //diag_log format["DEBUG: Pack _weaponHolder %1", _weaponHolder]; if (!isNull _weaponHolder) then { _owners = _weaponHolder getVariable["STORAGE_OWNERS", []]; diff --git a/Sources/epoch_server/compile/epoch_vehicle/EPOCH_spawn_vehicle.sqf b/Sources/epoch_server/compile/epoch_vehicle/EPOCH_spawn_vehicle.sqf index 68180c8e..6dcd706d 100644 --- a/Sources/epoch_server/compile/epoch_vehicle/EPOCH_spawn_vehicle.sqf +++ b/Sources/epoch_server/compile/epoch_vehicle/EPOCH_spawn_vehicle.sqf @@ -12,92 +12,99 @@ _lockOwner = param [5, ""]; _can_collide = param [6, "CAN_COLLIDE"]; _spawnLoot = param [7, false]; - +//diag_log format["DEBUG: spawn_vehicle %1", _this]; //place vehicle _vehObj = createVehicle[_vehClass, _position, [], 0, _can_collide]; -_vehObj call EPOCH_server_setVToken; -// Set Direction -if (typeName _direction == "ARRAY") then{ - _vehObj setVectorDirAndUp _direction; +if !(isNull _vehObj) then{ + + _vehObj call EPOCH_server_setVToken; + + // Set Direction + if (typeName _direction == "ARRAY") then{ + _vehObj setVectorDirAndUp _direction; + } else { + _vehObj setdir _direction; + }; + // Set Position + _vehObj setposATL _position; + + // Normalize vehicle inventory + clearWeaponCargoGlobal _vehObj; + clearMagazineCargoGlobal _vehObj; + clearBackpackCargoGlobal _vehObj; + clearItemCargoGlobal _vehObj; + + // Disable Termal Equipment + _vehObj disableTIEquipment true; + + // Vehicle Lock + _vehObj lock _locked; + + // randomize fuel TODO push min max to config + _vehObj setFuel ((random 1 max 0.1) min 0.9); + + // get colors from config + _config = (configFile >> "CfgVehicles" >> _vehClass >> "availableColors"); + + if (isArray(_config)) then{ + + _textureSelectionIndex = configFile >> "CfgVehicles" >> _vehClass >> "textureSelectionIndex"; + _selections = if (isArray(_textureSelectionIndex)) then{ getArray(_textureSelectionIndex) } else { [0] }; + _colors = getArray(_config); + _textures = _colors select 0; + _color = floor(random(count _textures)); + _count = (count _colors) - 1; + { + if (_count >= _forEachIndex) then{ + _textures = _colors select _forEachIndex; + }; + _vehObj setObjectTextureGlobal[_x, (_textures select _color)]; + } forEach _selections; + _vehObj setVariable["VEHICLE_TEXTURE", _color]; + }; + + // add random loots + if (_spawnLoot) then { + if (_vehClass isKindOf "Ship") then{ + [_vehObj, "VehicleBoat"] call EPOCH_serverLootObject; + } else { + [_vehObj, "Vehicle"] call EPOCH_serverLootObject; + }; + }; + + // Set slot used by vehicle + _vehObj setVariable["VEHICLE_SLOT", _slot, true]; + + // Lock vehicle for owner + if (_locked && _lockOwner != "") then { + _vehLockHiveKey = format["%1:%2", (call EPOCH_fn_InstanceID), _slot]; + ["VehicleLock", _vehLockHiveKey, EPOCH_vehicleLockTime, [_lockOwner]] call EPOCH_fnc_server_hiveSETEX; + } else { + _vehLockHiveKey = format["%1:%2", (call EPOCH_fn_InstanceID), _slot]; + ["VehicleLock", _vehLockHiveKey] call EPOCH_fnc_server_hiveDEL; + }; + + // SAVE VEHICLE + _vehObj call EPOCH_server_save_vehicle; + + // Event Handlers + _vehObj call EPOCH_server_vehicleInit; + + // Markers + if (EPOCH_DEBUG_VEH) then{ + _marker = createMarker[str(_position), _position]; + _marker setMarkerShape "ICON"; + _marker setMarkerType "mil_dot"; + _marker setMarkerText _vehClass; + }; + + // Add to A3 remains collector + addToRemainsCollector[_vehObj]; + } else { - _vehObj setdir _direction; + diag_log format["DEBUG: Failed to create vehicle: %1", _this]; }; -// Set Position -_vehObj setposATL _position; - -// Normalize vehicle inventory -clearWeaponCargoGlobal _vehObj; -clearMagazineCargoGlobal _vehObj; -clearBackpackCargoGlobal _vehObj; -clearItemCargoGlobal _vehObj; - -// Disable Termal Equipment -_vehObj disableTIEquipment true; - -// Vehicle Lock -_vehObj lock _locked; - -// randomize fuel TODO push min max to config -_vehObj setFuel ((random 1 max 0.1) min 0.9); - -// get colors from config -_config = (configFile >> "CfgVehicles" >> _vehClass >> "availableColors"); - -if (isArray(_config)) then{ - - _textureSelectionIndex = configFile >> "CfgVehicles" >> _vehClass >> "textureSelectionIndex"; - _selections = if (isArray(_textureSelectionIndex)) then{ getArray(_textureSelectionIndex) } else { [0] }; - _colors = getArray(_config); - _textures = _colors select 0; - _color = floor(random(count _textures)); - _count = (count _colors) - 1; - { - if (_count >= _forEachIndex) then{ - _textures = _colors select _forEachIndex; - }; - _vehObj setObjectTextureGlobal[_x, (_textures select _color)]; - } forEach _selections; - _vehObj setVariable["VEHICLE_TEXTURE", _color]; -}; - -// add random loots -if (_spawnLoot) then { - if (_vehClass isKindOf "Ship") then{ - [_vehObj, "VehicleBoat"] call EPOCH_serverLootObject; - } else { - [_vehObj, "Vehicle"] call EPOCH_serverLootObject; - }; -}; - -// Set slot used by vehicle -_vehObj setVariable["VEHICLE_SLOT", _slot, true]; - -// Lock vehicle for owner -if (_locked && _lockOwner != "") then { - _vehLockHiveKey = format["%1:%2", (call EPOCH_fn_InstanceID), _slot]; - ["VehicleLock", _vehLockHiveKey, EPOCH_vehicleLockTime, [_lockOwner]] call EPOCH_fnc_server_hiveSETEX; -} else { - _vehLockHiveKey = format["%1:%2", (call EPOCH_fn_InstanceID), _slot]; - ["VehicleLock", _vehLockHiveKey] call EPOCH_fnc_server_hiveDEL; -}; - -// SAVE VEHICLE -_vehObj call EPOCH_server_save_vehicle; - -// Event Handlers -_vehObj call EPOCH_server_vehicleInit; - -// Markers -if (EPOCH_DEBUG_VEH) then{ - _marker = createMarker[str(_position), _position]; - _marker setMarkerShape "ICON"; - _marker setMarkerType "mil_dot"; - _marker setMarkerText _vehClass; -}; - -// Add to A3 remains collector -addToRemainsCollector[_vehObj]; _vehObj diff --git a/Sources/epoch_server/compile/epoch_vehicle/EPOCH_spawn_vehicles.sqf b/Sources/epoch_server/compile/epoch_vehicle/EPOCH_spawn_vehicles.sqf index 495aaaca..1c362a34 100644 --- a/Sources/epoch_server/compile/epoch_vehicle/EPOCH_spawn_vehicles.sqf +++ b/Sources/epoch_server/compile/epoch_vehicle/EPOCH_spawn_vehicles.sqf @@ -24,17 +24,17 @@ if (_allowedVehiclesList isEqualTo []) exitWith { }; _spawnPositionSizeDefaults = [ - ["FlatAreaCity",1], - ["FlatAreaCitySmall",1], - ["NameCity",2], - ["NameVillage",1], - ["NameCityCapital",4], - ["Airport",5], - ["NameLocal",2], - ["StrongpointArea",1], - ["VegetationBroadleaf",1], - ["VegetationFir",1], - ["ViewPoint",1] + ["FlatAreaCity",1], + ["FlatAreaCitySmall",1], + ["NameCity",2], + ["NameVillage",1], + ["NameCityCapital",4], + ["Airport",5], + ["NameLocal",2], + ["StrongpointArea",1], + ["VegetationBroadleaf",1], + ["VegetationFir",1], + ["ViewPoint",1] ]; _serverMapConfig = configFile >> "CfgEpoch" >> worldName; _spawnPositionSize = [_serverMapConfig, "vehicleSpawnTypes", _spawnPositionSizeDefaults] call EPOCH_fnc_returnConfigEntry; @@ -61,93 +61,87 @@ _allCitysDync = []; }; } forEach _allCitys; - _position = [0,0,0]; +_spawnCount = (count EPOCH_VehicleSlots - EPOCH_storedVehicleCount) - 1; -{ - if (count EPOCH_VehicleSlots <= EPOCH_storedVehicleCount) exitWith{}; +diag_log format["DEBUG: count EPOCH_VehicleSlots: %1 EPOCH_storedVehicleCount: %2 _spawnCount %3", (count EPOCH_VehicleSlots), EPOCH_storedVehicleCount, _spawnCount]; - _vehCount = count _allowedVehiclesList; - if (_vehCount <= 0) exitWith{}; +for "_i" from 1 to _spawnCount do { - _vehClass = _allowedVehiclesList deleteAt(floor(random(_vehCount))); - if (isNil "_vehClass") exitWith{}; + _slot = EPOCH_VehicleSlots deleteAt 0; - _direction = random 360; - _position = [0,0,0]; - _getRandomPos = true; + _vehCount = count _allowedVehiclesList; + _vehClass = _allowedVehiclesList deleteAt(floor(random(_vehCount))); + if (isNil "_vehClass") exitWith{diag_log "DEBUG: Failed to find vehicle class"}; + _direction = random 360; + _position = [0,0,0]; + _getRandomPos = true; - _preferedPos = getArray(configFile >> "CfgEpoch" >> worldname >> "whitelistedVehiclePos" >> _vehClass); - if !(_preferedPos isEqualTo []) then{ - _newPosition = _preferedPos select(floor(random(count _preferedPos))); - if ((nearestObjects[(_newPosition select 0), ["LandVehicle", "Ship", "Air", "Tank"], 50]) isEqualTo []) then{ - _position = _newPosition select 0; - _direction = _newPosition select 1; - _getRandomPos = false; - }; - }; - - - if (_getRandomPos) then{ - _isShip = _vehClass isKindOf "Ship"; - if (_isShip || (_vehClass isKindOf "Air")) then{ - if (_isShip) then{ - _position = [epoch_centerMarkerPosition, 0, EPOCH_dynamicVehicleArea, 10, 0, 4000, 1] call BIS_fnc_findSafePos; - _position = [_position, 0, 100, 10, 2, 4000, 0] call BIS_fnc_findSafePos; - } else { - _position = [epoch_centerMarkerPosition, 0, EPOCH_dynamicVehicleArea, 10, 0, 1000, 0] call BIS_fnc_findSafePos; - }; - } else { - - if (_allCitysDync isEqualTo []) then { - _position = [epoch_centerMarkerPosition, 0, EPOCH_dynamicVehicleArea, 10, 0, 1000, 0] call BIS_fnc_findSafePos; - } else { - _selectedCity = _allCitysDync deleteAt (floor random(count _allCitysDync)); - _cityPos = getArray(_selectedCity >> "position"); - _range = getNumber(_selectedCity >> "radiusA") * 1.3; - - _roads = _cityPos nearRoads _range; - if !(_roads isEqualTo []) then { - _road = _roads select(floor random(count _roads)); - _position = getPosATL _road; - _position deleteAt 2; - }; - }; - }; - }; - - if ((count _position == 2 && _getRandomPos) || !_getRandomPos) then{ - - - _collide = "CAN_COLLIDE"; - if (_getRandomPos) then{ - _collide = "NONE"; - _position set[2, 0]; - if (surfaceIsWater _position) then{ - _position = ASLToATL _position; - }; - }; - - _vehObj = [_vehClass,_position,_direction,true,_x,"",_collide,true] call EPOCH_fnc_spawn_vehicle; - - - if (EPOCH_DEBUG_VEH) then { - _marker = createMarker [str(_position) , _position]; - _marker setMarkerShape "ICON"; - _marker setMarkerType "mil_dot"; - _marker setMarkerText _vehClass; - _marker setMarkerColor "ColorBlue"; - }; - - - EPOCH_VehicleSlots set[_forEachIndex, "REM"]; + _preferedPos = getArray(configFile >> "CfgEpoch" >> worldname >> "whitelistedVehiclePos" >> _vehClass); + if !(_preferedPos isEqualTo []) then{ + _newPosition = _preferedPos select(floor(random(count _preferedPos))); + if ((nearestObjects[(_newPosition select 0), ["LandVehicle", "Ship", "Air", "Tank"], 50]) isEqualTo []) then{ + _position = _newPosition select 0; + _direction = _newPosition select 1; + _getRandomPos = false; + }; }; -} forEach EPOCH_VehicleSlots; -EPOCH_VehicleSlots = EPOCH_VehicleSlots - ["REM"]; + if (_getRandomPos) then{ + _isShip = _vehClass isKindOf "Ship"; + if (_isShip || (_vehClass isKindOf "Air")) then{ + if (_isShip) then{ + _position = [epoch_centerMarkerPosition, 0, EPOCH_dynamicVehicleArea, 10, 0, 4000, 1] call BIS_fnc_findSafePos; + _position = [_position, 0, 100, 10, 2, 4000, 0] call BIS_fnc_findSafePos; + } else { + _position = [epoch_centerMarkerPosition, 0, EPOCH_dynamicVehicleArea, 10, 0, 1000, 0] call BIS_fnc_findSafePos; + }; + } else { + + if (_allCitysDync isEqualTo []) then { + _position = [epoch_centerMarkerPosition, 0, EPOCH_dynamicVehicleArea, 10, 0, 1000, 0] call BIS_fnc_findSafePos; + } else { + _selectedCity = _allCitysDync deleteAt (floor random(count _allCitysDync)); + _cityPos = getArray(_selectedCity >> "position"); + _range = getNumber(_selectedCity >> "radiusA") * 1.3; + + _roads = _cityPos nearRoads _range; + if !(_roads isEqualTo []) then { + _road = _roads select(floor random(count _roads)); + _position = getPosATL _road; + _position deleteAt 2; + }; + }; + }; + }; + + if ((count _position == 2 && _getRandomPos) || !_getRandomPos) then{ + + _collide = "CAN_COLLIDE"; + if (_getRandomPos) then{ + _collide = "NONE"; + _position set[2, 0]; + if (surfaceIsWater _position) then{ + _position = ASLToATL _position; + }; + }; + + _vehObj = [_vehClass,_position,_direction,true,_slot,"",_collide,true] call EPOCH_fnc_spawn_vehicle; + + if (EPOCH_DEBUG_VEH) then { + _marker = createMarker [str(_position) , _position]; + _marker setMarkerShape "ICON"; + _marker setMarkerType "mil_dot"; + _marker setMarkerText _vehClass; + _marker setMarkerColor "ColorBlue"; + }; + + }; + +}; EPOCH_VehicleSlotCount = count EPOCH_VehicleSlots; publicVariable "EPOCH_VehicleSlotCount"; diff --git a/Sources/epoch_server/system/server_monitor.fsm b/Sources/epoch_server/system/server_monitor.fsm index 812de4dc..5ffa508c 100644 --- a/Sources/epoch_server/system/server_monitor.fsm +++ b/Sources/epoch_server/system/server_monitor.fsm @@ -126,7 +126,7 @@ class FSM " _list = _this nearEntities[[""Epoch_Male_F"", ""Epoch_Female_F"", ""LandVehicle"", ""Ship"", ""Air"", ""Tank""], 45];" \n " if ({ isPlayer _x }count _list == 0) then {" \n " _this setVariable [""LAST_CHECK"",nil];" \n - " diag_log format[""DEBUG: _cleanIT del %1"", _this];" \n + " //diag_log format[""DEBUG: _cleanIT del %1"", _this];" \n " deleteVehicle _this;" \n "" \n " };" \n @@ -149,7 +149,7 @@ class FSM " deleteVehicle _x;" \n " }forEach nearestObjects[_this, [""WeaponHolder""], 2];" \n " _this setVariable [""LAST_CHECK"",nil];" \n - " diag_log format[""DEBUG: _cleanIT2 del %1"", _this];" \n + " //diag_log format[""DEBUG: _cleanIT2 del %1"", _this];" \n " deleteVehicle _this;" \n " _removed = true;" \n " };" \n @@ -328,7 +328,7 @@ class FSM " _activeVehicles pushBack _x;" \n " };" \n " } else {" \n - " diag_log format[""DEBUG: vtoken del %1"",_x];" \n + " //diag_log format[""DEBUG: vtoken del %1"",_x];" \n " deleteVehicle _x;" \n " };" \n " };" \n