diff options
| author | hybrid <hybrid@hybridlabs.pro> | 2026-06-11 19:58:31 +0300 |
|---|---|---|
| committer | hybrid <hybrid@hybridlabs.pro> | 2026-06-11 19:58:31 +0300 |
| commit | e670b4ed55c459a21090bd0178ceaaaf12d87989 (patch) | |
| tree | b6833d5e842475f0ee27f5f617096445fdd4e4a1 /Common/Functions/Common_UseStationaryDefense.sqf | |
| download | a2wf_fallujah-e670b4ed55c459a21090bd0178ceaaaf12d87989.tar.gz a2wf_fallujah-e670b4ed55c459a21090bd0178ceaaaf12d87989.tar.bz2 a2wf_fallujah-e670b4ed55c459a21090bd0178ceaaaf12d87989.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 |
