diff --git a/addons/common/functions/fnc_getRandomPos.sqf b/addons/common/functions/fnc_getRandomPos.sqf index d362ebba..4e73277a 100644 --- a/addons/common/functions/fnc_getRandomPos.sqf +++ b/addons/common/functions/fnc_getRandomPos.sqf @@ -9,6 +9,7 @@ * 2: Position can be on road * 3: Position must be near house * 4: Search radius for empty position + * 5: Blacklisted areas > * * Return Value: * 0: Random position on the map @@ -19,14 +20,20 @@ * Public: No */ -params [["_objectType", ""], ["_nearRoad", false], ["_allowOnRoad", true], ["_nearHouse", false], ["_emptyPosSearchRadius", 25]]; +params [ + ["_objectType", ""], + ["_nearRoad", false], + ["_allowOnRoad", true], + ["_nearHouse", false], + ["_emptyPosSearchRadius", 25], + ["_blacklistedAreas", []]]; // Function returns random position private _fnc_randomPos = { - params ["_nearRoad", "_allowOnRoad", "_nearHouse"]; + params ["_nearRoad", "_allowOnRoad", "_nearHouse", "_blacklistedAreas"]; private _randomPos = []; while {_randomPos isEqualTo []} do { - _randomPos = [] call BIS_fnc_randomPos; + _randomPos = [nil, _blacklistedAreas] call BIS_fnc_randomPos; if (!(_randomPos isEqualTo []) && {_nearHouse && {!([_randomPos] call FUNC(isHouseNearby))}}) then { _randomPos = []; }; @@ -50,13 +57,13 @@ if (!(_objectType isEqualType "")) then { }; // If no object is given, just random position is enough -if (_objectType isEqualTo "") exitWith {[_nearRoad, _allowOnRoad, _nearHouse] call _fnc_randomPos}; +if (_objectType isEqualTo "") exitWith {[_nearRoad, _allowOnRoad, _nearHouse, _blacklistedAreas] call _fnc_randomPos}; private _randomPos = []; private _loopLimit = 250; // Loop until acquired random empty pos is within location area (or loop limit reached) while {(_loopLimit >= 0) && {(_randomPos isEqualTo [])}} do { - _randomPos = [_nearRoad, _allowOnRoad, _nearHouse] call _fnc_randomPos; + _randomPos = [_nearRoad, _allowOnRoad, _nearHouse, _blacklistedAreas] call _fnc_randomPos; _randomPos = _randomPos findEmptyPosition [0, _emptyPosSearchRadius, _objectType]; _loopLimit = _loopLimit - 1; }; diff --git a/addons/police/config.cpp b/addons/police/config.cpp index 0a92f8d8..e4c46542 100644 --- a/addons/police/config.cpp +++ b/addons/police/config.cpp @@ -8,7 +8,8 @@ class CfgPatches { requiredVersion = REQUIRED_VERSION; requiredAddons[] = { "afsk_equipment", - "afsk_modules" + "afsk_modules", + "afsk_vehicles" }; author = "ArmaForces"; VERSION_CONFIG; diff --git a/addons/police/functions/fnc_initPoliceStation.sqf b/addons/police/functions/fnc_initPoliceStation.sqf index a8f85dea..92e3d8b6 100644 --- a/addons/police/functions/fnc_initPoliceStation.sqf +++ b/addons/police/functions/fnc_initPoliceStation.sqf @@ -45,3 +45,6 @@ _logic setVariable ["Marker", _marker]; // Create teleporter _logic setVariable ["Teleporter", _flag, true]; [QGVAR(createTeleport), [_flag]] call CBA_fnc_globalEventJIP; + +private _stationArea = _logic getVariable ["objectArea", []]; +[QGVAR(policeStationInitialized), [_logic]] call CBA_fnc_localEvent; diff --git a/addons/vehicles/XEH_postInit.sqf b/addons/vehicles/XEH_postInit.sqf index dad32fb1..d7d78e02 100644 --- a/addons/vehicles/XEH_postInit.sqf +++ b/addons/vehicles/XEH_postInit.sqf @@ -1,6 +1,13 @@ #include "script_component.hpp" if (isServer) then { + [FUNC(initVehicles)] call CBA_fnc_execNextFrame; + + [QEGVAR(police,policeStationInitialized), { + params ["_policeStationArea"]; + // Register as blacklisted area for civilian vehicle spawn + GVAR(vehicleBlacklistedAreas) pushBackUnique _policeStationArea; + }] call CBA_fnc_addEventHandler; [QGVAR(carAlarm), FUNC(carAlarm)] call CBA_fnc_addEventHandler; [QGVAR(disableCarAlarm), FUNC(disableCarAlarm)] call CBA_fnc_addEventHandler; diff --git a/addons/vehicles/XEH_preInit.sqf b/addons/vehicles/XEH_preInit.sqf index c20929f5..9cb68a66 100644 --- a/addons/vehicles/XEH_preInit.sqf +++ b/addons/vehicles/XEH_preInit.sqf @@ -2,13 +2,13 @@ ADDON = false; #include "XEH_PREP.hpp" -#include "initSettings.sqf" +#include "initSettings.inc.sqf" // We need some improvements in determining civilian vehicles limit GVAR(emptyVehiclesLimit) = 500; if (isServer) then { - call FUNC(initVehicles); + GVAR(vehicleBlacklistedAreas) = []; }; ADDON = true; diff --git a/addons/vehicles/functions/fnc_initVehicles.sqf b/addons/vehicles/functions/fnc_initVehicles.sqf index 3a69fd55..27f2de05 100644 --- a/addons/vehicles/functions/fnc_initVehicles.sqf +++ b/addons/vehicles/functions/fnc_initVehicles.sqf @@ -26,7 +26,7 @@ private _civilianCarTypes = "( (getNumber (_x >> 'scope') >= 2) while {_i > 0} do { private _carType = selectRandom _civilianCarTypes; - private _pos = [_carType, true, false, true] call EFUNC(common,getRandomPos); + private _pos = [_carType, true, false, true, nil, GVAR(vehicleBlacklistedAreas)] call EFUNC(common,getRandomPos); if (!(_pos isEqualTo [])) then { // Check if there are other vehicles nearby to prevent creating too much vehicles in one area private _distance = 100 * (4 - GVAR(emptyVehiclesLimitMultiplier)); diff --git a/addons/vehicles/initSettings.sqf b/addons/vehicles/initSettings.inc.sqf similarity index 100% rename from addons/vehicles/initSettings.sqf rename to addons/vehicles/initSettings.inc.sqf