From dee52083d359434fc3ac51a871c1b836d092d2ac Mon Sep 17 00:00:00 2001 From: hybrid Date: Thu, 11 Jun 2026 19:55:41 +0300 Subject: init --- Common/Functions/Common_GetTurretsMags.sqf | 42 ++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Common/Functions/Common_GetTurretsMags.sqf (limited to 'Common/Functions/Common_GetTurretsMags.sqf') diff --git a/Common/Functions/Common_GetTurretsMags.sqf b/Common/Functions/Common_GetTurretsMags.sqf new file mode 100644 index 0000000..f226567 --- /dev/null +++ b/Common/Functions/Common_GetTurretsMags.sqf @@ -0,0 +1,42 @@ +/* Adapted from BIS turret's function. */ +private ['_entry','_turrets','_turretIndex']; +_entry = _this select 0; + +_turrets = []; +_turretIndex = 0; + +//Explore all turrets and sub-turrets recursively. +for '_i' from 0 to ((count _entry) - 1) do +{ + private ['_subEntry']; + _subEntry = _entry select _i; + + if (isClass _subEntry) then + { + private ['_hasGunner']; + _hasGunner = [_subEntry, 'hasGunner'] call BIS_fnc_returnConfigEntry; + + //Make sure the entry was found. + if !(isNil '_hasGunner') then + { + if (_hasGunner == 1) then + { + _turrets = _turrets + [[_turretIndex],getArray(_subEntry >> 'magazines')]; + + //Include sub-turrets, if present. + if (isClass (_subEntry >> 'Turrets')) then + { + _turrets = _turrets + [[_subEntry >> 'Turrets'] call GetTurretsMags]; + } + else + { + _turrets = _turrets + [[]]; + }; + }; + }; + + _turretIndex = _turretIndex + 1; + }; +}; + +_turrets \ No newline at end of file -- cgit v1.3.1