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.
Description
Details
- Severity
- Minor
- Resolution
- Open
- Reproducibility
- Always
- Operating System
- Windows 11 x64
- Category
- General
- Load the SOG DLC
- Load into a mission with access to a debug console
- 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
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
Edited repro steps: You need SOG loaded.
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.
Yes, it does.
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?
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?
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
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
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.