diff options
| author | hybrid <hybrid@hybridlabs.pro> | 2026-06-11 19:55:04 +0300 |
|---|---|---|
| committer | hybrid <hybrid@hybridlabs.pro> | 2026-06-11 19:55:04 +0300 |
| commit | b06990293397d4b6d0374097f09d1cc5679216e3 (patch) | |
| tree | 5719922562e317a8083250c178f24376b6692569 /Common/Functions/Common_UseStationaryDefense.sqf | |
| download | a2wf_saralite-b06990293397d4b6d0374097f09d1cc5679216e3.tar.gz a2wf_saralite-b06990293397d4b6d0374097f09d1cc5679216e3.tar.bz2 a2wf_saralite-b06990293397d4b6d0374097f09d1cc5679216e3.zip | |
init
Diffstat (limited to '')
| -rw-r--r-- | Common/Functions/Common_UseStationaryDefense.sqf | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/Common/Functions/Common_UseStationaryDefense.sqf b/Common/Functions/Common_UseStationaryDefense.sqf new file mode 100644 index 0000000..6f90f09 --- /dev/null +++ b/Common/Functions/Common_UseStationaryDefense.sqf @@ -0,0 +1,32 @@ +Private["_count","_defense","_defenses","_defenseTypes","_emptyDefenses","_range","_total","_totalDefenses","_unit","_units"];
+
+_units = _this select 0;
+_range = _this select 1;
+
+_total = count _units;
+if (_total < 1) exitWith {diag_log Format["[WFBE (ERROR)][frameno:%1 | ticktime:%2] Common_UseStationaryDefense.sqf: No units were specified",diag_frameno,diag_tickTime]};
+
+_defenseTypes = Format["WFBE_%1DEFENSENAMES",side leader group (_units select 0)] Call GetNamespace;
+_defenses = (leader group (_units select 0)) nearEntities[_defenseTypes,_range];
+
+_emptyDefenses = [];
+
+{if (_x EmptyPositions "gunner" > 0) then {_emptyDefenses = _emptyDefenses + [_x]}} forEach _defenses;
+
+for [{_count = 0},{_count < _total},{_count = _count + 1}] do
+{
+ _unit = _units select _count;
+
+ _totalDefenses = count _emptyDefenses;
+ if (_totalDefenses < 1) exitWith {};
+
+ //If not in a vehicle then check for available defense.
+ if (alive _unit && _unit == vehicle _unit) then
+ {
+ _defense = _emptyDefenses select (_totalDefenses - 1);
+
+ [_unit] allowGetIn true;
+ _unit assignAsGunner _defense;
+ _emptyDefenses = _emptyDefenses - [_defense];
+ };
+};
\ No newline at end of file |
