Page MenuHomeFeedback Tracker

magazineTurretAmmo and setMagazineTurretAmmo do not function as expected if there are multiple magazines of the same type
New, WishlistPublic

Description

In Slammer Up for example there are 3 mags of 2000Rnd_65x39_Belt, lets call then mag#1, mag#2, mag#3

Initially magazineTurretAmmo reports ammo in mag#1 and setMagazineTurretAmmo will also set new ammo count in mag#1

But when the mag is finished and new mag#2 is reloaded, magazineTurretAmmo is still reporting ammo for mag#1 even though it is discarded. If you try to set ammo again setMagazineTurretAmmo sets it for mag#3 instead and magazineTurretAmmo starts reporting ammo for mag#3 as well.

mag#2 that is currently loaded therefore cannot be read or altered in any way.

Details

Legacy ID
581806029
Severity
None
Resolution
Open
Reproducibility
Always
Operating System
Windows 7
Category
Scripting
Steps To Reproduce

get in slammer up as commander, execute

vehicle player setMagazineTurretAmmo ["500Rnd_127x99_mag_Tracer_Red", 1, [0,0]];
hint str (vehicle player magazineTurretAmmo ["500Rnd_127x99_mag_Tracer_Red",[0,0]]);

ammo count shows 1 and so is hint

fire away and reload

execute

hint str (vehicle player magazineTurretAmmo ["500Rnd_127x99_mag_Tracer_Red",[0,0]]);

it shows 0, however the loaded mag is full, it still shows ammo for used mag.

execute

vehicle player setMagazineTurretAmmo ["500Rnd_127x99_mag_Tracer_Red", 1, [0,0]];
hint str (vehicle player magazineTurretAmmo ["500Rnd_127x99_mag_Tracer_Red",[0,0]]);

the loaded mag is still full but hint shows 1, which means it set ammo on 3rd mag not on 2nd.

Event Timeline

Killzone_Kid edited Additional Information. (Show Details)
Killzone_Kid set Category to Scripting.
Killzone_Kid set Reproducibility to Always.
Killzone_Kid set Severity to None.
Killzone_Kid set Resolution to Open.
Killzone_Kid set Legacy ID to 581806029.May 7 2016, 7:40 PM
Killzone_Kid edited a custom field.
Killzone_Kid added a subscriber: Killzone_Kid.

Also see this ticket http://feedback.arma3.com/view.php?id=22179 setMagazineTurretAmmo locality is also broken

Did some tests on this and it seems there has been some changes, there are now only 2 mags of 500Rnd_127x99_mag_Tracer_Red in slammer up commander turret (TurretPath:[0,0]) which actually means there is a workaround now:

When you empty a mag (or both mags) this will brake magazineTurretAmmo function as you said, but it reports all mags has a ammocount of 0, like this:
["500Rnd_127x99_mag_Tracer_Red:0","500Rnd_127x99_mag_Tracer_Red:0","SmokeLauncherMag:2"]

So when magazineTurretAmmo reports 0 rounds in all mags we know at least 1 full mag has been used, we can always get the ammo Count (and set it) of the current magazine with the ammo function (tank ammo "LMG_M200"), that way we can actually get all the info we need. However if there is more than 2 mags of the same magazine type this workaround wont Work, for example in the mortar, but there are very few vehicles that have more than 2 mags of same type in the same turretPath.

Encountered this bug with a modded vehicle I'm building. Have 4 turrets with the same weapon and magazine and can not get their ammo count as the command reads only the one magazine.

Actually got it working! :

		_magazine_01 = _walker magazinesTurret [0,0];
		_magazine_02 = _walker magazinesTurret [0,1];
		_magazine_03 = _walker magazinesTurret [0,2];
		_magazine_04 = _walker magazinesTurret [0,3];
		
		_ammoCount_01 = _walker magazineTurretAmmo [_magazine_01 select 0, [0,0]];
		_ammoCount_02 = _walker magazineTurretAmmo [_magazine_02 select 0, [0,1]];
		_ammoCount_03 = _walker magazineTurretAmmo [_magazine_03 select 0, [0,2]];
		_ammoCount_04 = _walker magazineTurretAmmo [_magazine_04 select 0, [0,3]];

It actually does read the ammo from right magazines!

SaMatra added a subscriber: SaMatra.Sep 7 2022, 3:33 PM

Maybe its time to finally fix this command. Lets be honest, 99% of usages of this command are to get currently loaded magazine. Who needs *random* magazine ammo count? Lets make this command prioritize loaded magazines.

Alternatively, add third parameter to return magazine by index of whatever internal magazine list is,

_vehicle magazineTurretAmmo [_magazine, _path, _index]

_index = -1 => loaded magazine (what about two muzzles on the turret loading same class of magazine though?
_index >= 0 => magazine index, including empty ones, (nil if this index doesn't exist?)

Even more complex idea to solve several muzzles loading same magazine issue:

_vehicle magazineTurretAmmo [_magazine, _path, _loaded, _index]

_loaded = true => indexes of loaded magazines of this class
_loaded = false => indexes of any magazines of this class
_vehicle magazineTurretAmmo [_magazine, _path] => old behaviour, whatever first magazine is found
_vehicle magazineTurretAmmo [_magazine, _path, _loaded] => first found loaded magazine of supplied class
_vehicle magazineTurretAmmo [_magazine, _path, _loaded, _index] => _index found loaded magazine of this class (nil if none found?)
_vehicle magazineTurretAmmo [_magazine, _path, false, _index] => _index of all magazines of this class (nil if none found?)
To make this idea backwards compatible, return nils only if supplied right operand array is larger than 2 arguments.

SaMatra added a comment.EditedSep 7 2022, 3:35 PM

nils for out of bounds _index might not be really needed as there is

vehicle magazinesTurret [turretPath, includeEmpty]

to get empty magazines so you can find the count yourself.

I’m going to talk to OP

BIS_fnc_KK updated the task description. (Show Details)
BIS_fnc_KK edited Steps To Reproduce. (Show Details)
BIS_fnc_KK edited Additional Information. (Show Details)
BIS_fnc_KK set Operating System to Windows 7.
h- added a subscriber: h-.Sep 8 2022, 8:23 AM