summaryrefslogtreecommitdiffstats
path: root/Common/Functions/Common_GetTurretsMags.sqf
diff options
context:
space:
mode:
authorhybrid <hybrid@hybridlabs.pro>2026-06-11 19:55:24 +0300
committerhybrid <hybrid@hybridlabs.pro>2026-06-11 19:55:24 +0300
commit628d33984d9228f1781d13a65fbb80f35facc899 (patch)
treecd909141f87e14f22c3511549a9bc067d9ff8b50 /Common/Functions/Common_GetTurretsMags.sqf
downloada2wf_sara-628d33984d9228f1781d13a65fbb80f35facc899.tar.gz
a2wf_sara-628d33984d9228f1781d13a65fbb80f35facc899.tar.bz2
a2wf_sara-628d33984d9228f1781d13a65fbb80f35facc899.zip
init
Diffstat (limited to '')
-rw-r--r--Common/Functions/Common_GetTurretsMags.sqf42
1 files changed, 42 insertions, 0 deletions
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