Page MenuHomeFeedback Tracker

getUnitLoadout not returning secondary muzzle magazine information of handguns
Feedback, NormalPublic

Description

SOG and Unsung both add a M79 sidearm. These weapons have 2 muzzles, which cause problems for getUnitLoadout, as it does not return the secondary muzzle magazine.

Details

Severity
Minor
Resolution
Open
Reproducibility
Always
Operating System
Windows 11 x64
Category
General
Steps To Reproduce
  1. Load the SOG DLC
  2. Load into a mission with access to a debug console
  3. Execute this code:
player addWeapon "vn_m79_p";
player addWeaponItem ["vn_m79_p", ["vn_40mm_m576_buck_mag", 1, "vn_m79_p_shot_muzzle"], true];
getUnitLoadout player select 2 // Returns `["vn_m79_p","","","",[],[],""]`, but magazine was added in secondary muzzle
Additional Information

I don't think there is a command that return a unit's handgun secondary muzzle magazine reliably. handgunMagazine exists, but you can't rely on there being a primary magazine.
You could mix both getUnitLoadout and handgunMagazine to cross check and get a workaround, but it feels unnecessarily complicated.

Event Timeline

johnb43 created this task.Jul 12 2023, 6:29 PM

player addWeapon "vn_m79_p";

nothing is added, cannot repro

BIS_fnc_KK changed the task status from New to Need More Info.Jul 20 2023, 11:51 AM

what

weaponsitems player

returns?

Does addHandgunItem add the secondary mag?

johnb43 edited Steps To Reproduce. (Show Details)Jul 20 2023, 5:23 PM
johnb43 added a comment.EditedJul 20 2023, 5:29 PM

player addWeapon "vn_m79_p";

nothing is added, cannot repro

Edited repro steps: You need SOG loaded.

what

weaponsitems player

returns?

If you run the code in the repro, this is what is returned when you run weaponsItems player:

[["vn_m79_p","","","",["vn_40mm_m576_buck_mag",1],[],""]]

However, despite the result above showing the magazine as being in the primary muzzle magazine, in reality it's not.

Does addHandgunItem add the secondary mag?

Yes, it does.

BIS_fnc_KK added a comment.EditedJul 20 2023, 7:45 PM

However, despite the result above showing the magazine as being in the primary muzzle magazine, in reality it's not.

Is this a secondary muzzle mag showing as primary muzzle but not being loaded at all? or is it added to secondary muzzle but shows in primary muzzle array? Is it the only mag in the weapon? What happens if you have both mags

Is this a secondary muzzle mag showing as primary muzzle but not being loaded at all? or is it added to secondary muzzle but shows in primary muzzle array? Is it the only mag in the weapon? What happens if you have both mags

player addWeaponItem ["vn_m79_p", ["vn_40mm_m576_buck_mag", 1, "vn_m79_p_shot_muzzle"], true];

The code above works as intended: It loads vn_40mm_m576_buck_mag into the secondary muzzle of the weapon vn_m79_p. There is no magazine in the primary muzzle and none is expected.
The secondary magazine is shown as a secondary magazine in the inventory, meaning you can't see it inside the inventory screen, as the inventory screen does not display secondary handgun magazines. However, when you cycle through the muzzles of the gun, you see that the magazine is loaded.

getUnitLoadout does not return the secondary muzzle magazine for handguns at all.

I added a primary magazine to the weapon and getUnitLoadout returned:
["vn_m79_p","","","",["vn_40mm_m381_he_mag",1],[],""]

There was a secondary magazine in that weapon, but it didn't return.

Primary weapons and launchers return magazines in both muzzles and in the correct order (so no weird funkiness like weaponsItems), it just seems to be handguns (and perhaps binoculars, but I can't test that as I don't know of any examples) that don't return secondary muzzle magazines at all.

So one more question, does weaponsItems show both magazines for the handgun if both loaded and in the correct order?

So one more question, does weaponsItems show both magazines for the handgun if both loaded and in the correct order?

I first added the secondary muzzle magazine ("vn_40mm_m576_buck_mag"), then the primary magazine ("vn_40mm_m381_he_mag"). weaponsItems player returns:
[["vn_m79_p","","","",["vn_40mm_m576_buck_mag",1],["vn_40mm_m381_he_mag",1],""]]

The order is not correct in this case.

I dropped the weapon to see if weaponsItems player would return something different.
However, when dropping the weapon and picking it up again, it deletes the magazine from the secondary muzzle. I checked, when it's dropped on the ground is still has its secondary magazine. It deletes the magazine when the weapon is picked up (regardless if there is a primary magazine or not).
weaponsItems player returns having picked up the weapon:
[["vn_m79_p","","","",["vn_40mm_m381_he_mag",1],[],""]]

So, with only the primary magazine remaining, I executed player addHandgunItem "vn_40mm_m576_buck_mag", which added "vn_40mm_m576_buck_mag" into the secondary muzzle as expected.

However, weaponsItems player now returns:
[["vn_m79_p","","","",["vn_40mm_m381_he_mag",1],["vn_40mm_m576_buck_mag",1],""]]

So the order is this case correct.

I proceeded to execute player addHandgunItem "vn_40mm_m576_buck_mag" several consecutive times - and the game crashed.
I have no idea if it's related to secondary muzzles on handguns or if it's because I'm on the latest profiling branch. Either way, here are the files:

I have added alternative syntax for weaponsItems and weaponsItemsCargo in 150819 which includes muzzle name in the magazine info because the order of magazines was never guaranteed, now you will know which mag is which. This is idirectly related to this ticket. I will look into getUnitLoadout next

getArray (configFile >> "CfgWeapons" >> "vn_m79_p" >> "muzzles")

what does this return?

Thank you very much.

getArray (configFile >> "CfgWeapons" >> "vn_m79_p" >> "muzzles")

what does this return?

["vn_m79_p_muzzle","vn_m79_p_shot_muzzle"]

could you go to debug console, type

utils 2

local exec

then type

vn_m79_p

generate

then select

  • include inherited
  • classes only
  • unlocalized

copy and paste it here?

i need to see the whole config as it could be the reason for getUnitLoadout not working properly

This comment was removed by BIS_fnc_KK.

ok thanks, I copied and removed it

BIS_fnc_KK added a comment.EditedJul 21 2023, 10:06 PM

yes, both muzzles are treated as primary muzzles so when it looks for secondary muzzle it cannot find it as it is marked as primary. I need to think how we can resolve this

BIS_fnc_KK set Ref Ticket to AIII-55799.Jul 22 2023, 6:33 PM
BIS_fnc_KK added a comment.EditedJul 22 2023, 8:08 PM

please report back next dev Revision: 150820

BIS_fnc_KK removed BIS_fnc_KK as the assignee of this task.Jul 22 2023, 8:08 PM
BIS_fnc_KK changed the task status from Need More Info to Feedback.

2.13.150832

player addWeapon "vn_m79_p";
player addWeaponItem ["vn_m79_p", ["vn_40mm_m576_buck_mag", 1, "vn_m79_p_shot_muzzle"], true];
getUnitLoadout player select 2 // Returns ["vn_m79_p","","","",[],["vn_40mm_m576_buck_mag",1],""]

That's fixed.

weaponsItems and weaponsItemsCargo return also correctly.