diff --git a/addons/staticspawn/CfgModuleCategories.hpp b/addons/staticspawn/CfgModuleCategories.hpp index fb350f3..fdb720f 100644 --- a/addons/staticspawn/CfgModuleCategories.hpp +++ b/addons/staticspawn/CfgModuleCategories.hpp @@ -100,15 +100,15 @@ class CfgVehicles typeName = "NUMBER"; control = "EditShort"; }; - class GVAR(checkVisibility): Checkbox - { - displayName = "$STR_MAI_checkVisibility"; - tooltip = "$STR_MAI_checkVisibilityShort"; - property = QGVAR(checkVisibility); - defaultValue = "true"; - expression = "_this setVariable ['%s', _value];"; - typeName = "BOOL"; - }; + // class GVAR(checkVisibility): Checkbox + // { + // displayName = "$STR_MAI_checkVisibility"; + // tooltip = "$STR_MAI_checkVisibilityShort"; + // property = QGVAR(checkVisibility); + // defaultValue = "true"; + // expression = "_this setVariable ['%s', _value];"; + // typeName = "BOOL"; + // }; class GVAR(sphereBackDistance): Default { displayName = "$STR_MAI_sphereBackDistance"; diff --git a/addons/staticspawn/XEH_PREP.hpp b/addons/staticspawn/XEH_PREP.hpp index 8b100e4..dc292d1 100644 --- a/addons/staticspawn/XEH_PREP.hpp +++ b/addons/staticspawn/XEH_PREP.hpp @@ -9,4 +9,5 @@ PREP(waitUntil); PREP(spawnUnit); PREP(checkSpawnConditions); PREP(addEH); -PREP(despawnAddToLogic); \ No newline at end of file +PREP(despawnAddToLogic); +PREP(checkRespawnConditionLoop); \ No newline at end of file diff --git a/addons/staticspawn/functions/fnc_checkRespawnConditionLoop.sqf b/addons/staticspawn/functions/fnc_checkRespawnConditionLoop.sqf new file mode 100644 index 0000000..6dfdcd9 --- /dev/null +++ b/addons/staticspawn/functions/fnc_checkRespawnConditionLoop.sqf @@ -0,0 +1,35 @@ +#include "script_component.hpp" +/* + * Author: + * Function description + * + * Arguments: + * 0: Objects + * 1: All + * + * Return Value: + * None + * + * Example: + * [[bob, ted], false] call afmf_main_fnc_example + * + * Public: No + */ + +params [["_logic", objNull], ["_unitArray", []], ["_groupID", objNull], ["_group", grpNull], ["_groups", []], ["_side", []], ["_pos", [0,0,0]], ["_waitUntil", 0]]; + +private _sphereBackDistance = _logic getVariable [QGVAR(sphereBackDistance), 30]; +private _nearplayers = _pos nearEntities ["allVehicles", _sphereBackDistance]; +private _playerIndex = _nearplayers findIf {isPlayer _x}; +// stop spawn near units if player nearby +if (_playerIndex > -1) exitWith {}; + +if (_waitUntil <= time) exitWith { + [_logic, _unitArray, _groupID, _group, _groups, _side] call FUNC(despawnAddToLogic); +}; + +[ + {_this call FUNC(checkRespawnConditionLoop)}, + _this, + 0.9 + random 0.2 +] call CBA_fnc_waitAndExecute; \ No newline at end of file diff --git a/addons/staticspawn/functions/fnc_checkSpawnConditions.sqf b/addons/staticspawn/functions/fnc_checkSpawnConditions.sqf index e3360d6..297fc4f 100644 --- a/addons/staticspawn/functions/fnc_checkSpawnConditions.sqf +++ b/addons/staticspawn/functions/fnc_checkSpawnConditions.sqf @@ -18,6 +18,12 @@ params [["_logic", objNull], ["_unit", objNull], ["_pos", [0,0,0]], ["_dir", 0]]; +// force spawn when player is nearby +private _sphereBackDistance = _logic getVariable [QGVAR(sphereBackDistance), 30]; +private _nearplayers = _pos nearEntities ["allVehicles", _sphereBackDistance]; +private _playerIndex = _nearplayers findIf {isPlayer _x}; +if (_playerIndex > -1) exitWith {false}; + // check if spawn pos of other units in group is more than set in module private _unitPos = _unit getVariable [QGVAR(pos), getposATL _unit]; private _distance = _unitPos distance _pos; diff --git a/addons/staticspawn/functions/fnc_despawn.sqf b/addons/staticspawn/functions/fnc_despawn.sqf index c506642..2987e90 100644 --- a/addons/staticspawn/functions/fnc_despawn.sqf +++ b/addons/staticspawn/functions/fnc_despawn.sqf @@ -28,15 +28,37 @@ if (_deleteBody) then { deleteVehicle _unit; }; +// _unitArray params [ +// "_type", +// "_loadout", +// "_pos", +// "_dir", +// "_stance", +// "_disabledAiFeatures", +// "_vehicleArray", +// "_building", +// "_buildingStatus", +// "_sphereSizeUnit", +// "_sphereBackDistanceUnit", +// "_sphereDespawnDistanceUnit", +// "_checkVisibilityUnit", +// "_forceSpawnDistanceUnit", +// ["_tickets", 1] +// ]; + private _tickets = _unit getVariable [QGVAR(tickets), 1]; _unitArray set [14, _tickets]; if (_waitTime <= 0) exitWith { [_logic, _unitArray, _groupID, _group, _groups, _side] call FUNC(despawnAddToLogic); }; + +private _pos = _unitArray select 2; +private _waitUntil = time + _waitTime; + [ - {_this call FUNC(despawnAddToLogic)}, - [_logic, _unitArray, _groupID, _group, _groups, _side], + {_this call FUNC(checkRespawnConditionLoop)}, + [_logic, _unitArray, _groupID, _group, _groups, _side, _pos, _waitUntil], _waitTime ] call CBA_fnc_waitAndExecute; diff --git a/addons/staticspawn/functions/fnc_loop.sqf b/addons/staticspawn/functions/fnc_loop.sqf index 567a31d..fedfbd9 100644 --- a/addons/staticspawn/functions/fnc_loop.sqf +++ b/addons/staticspawn/functions/fnc_loop.sqf @@ -22,7 +22,7 @@ params [ if (_logic isEqualTo objNull) exitWith {}; private _groups = _logic getVariable [QGVAR(groups), []]; if (_groups isEqualTo []) exitWith { - systemChat "loop groups isEqualTo []"; + // systemChat "loop groups isEqualTo []"; _logic setVariable [QGVAR(active), false]; }; diff --git a/addons/staticspawn/functions/fnc_waitUntil.sqf b/addons/staticspawn/functions/fnc_waitUntil.sqf index 05133fb..f3454b3 100644 --- a/addons/staticspawn/functions/fnc_waitUntil.sqf +++ b/addons/staticspawn/functions/fnc_waitUntil.sqf @@ -57,7 +57,7 @@ if (_activate) then { } else { [{_this call QFUNC(WaitUntil)}, _this, - random [0.9,1,1.1] + 0.9 + random 0.2 ] call CBA_fnc_waitAndExecute; };