Running setUnitLoadout on a player that is in the middle of switching weapons, creates a potential that their weapon will be considered "Throw" or similar for every client that is not local to the player, even while shooting.
This makes the bullets they shoot silent for everyone except themselves..
Description
Details
- Severity
- Minor
- Resolution
- Open
- Reproducibility
- Always
- Operating System
- Windows 10 x64
- Category
- Engine
- Load a server
- Log in 2 clients (Doesn't matter if its on the same computer or not)
- Run this script on one client
[]spawn{ _clothing = getUnitLoadout player; player action ["SwitchWeapon", player, player, 100]; player switchCamera cameraView; uiSleep 0.5; player setUnitLoadout _clothing; };
- The other client will see the player that set the loadout with the proper loadout, however their bullets will be silent and their weapons will return as follows;
(Current weapon in hands is a Mk-1 ("srifle_DMR_03_tan_F"), while standing still)
getUnitLoadout _player select 0 select 0
"srifle_DMR_03_tan_F"
currentWeapon _player
"Throw"
weaponState _player
["Throw","HandGrenadeMuzzle","HandGrenadeMuzzle","",0,-1,0]
It seems that the issue sometimes will resolve itself after a few minutes, but not confirmed that it will all the time.
Video of bug and supplied mission
https://www.dropbox.com/s/0g1tg15elsdxi7t/Silent_Bullet_Test.Altis.pbo?dl=0
Event Timeline
I've added a video of the issue (with timestamps) as well as a mission that the bug happens on. I couldn't reproduce on a brand new empty mission made in editor, so I found a random mission and removed a bunch of scripts that weren't required for the mission to start.
I've tried on
Current stable branch (2.08.149102)
Current profiling build (2.08.149743)
This issue is still present it seems. However, I can't' provide proper steps to replicate, as the server where it occurred is modded. All I know is that upon exiting the ACE Arsenal, some code (written by me, not ACE) which boils down to player setUnitLoadout getUnitLoadout player is run, which I believe causes the desync issue.
I'm running the latest profiling branch (2.12.150954).
However, what I believe is a variation of this issue is present and I have the steps to reproduce:
- Create mission with 2 playable characters. Units should have loadouts assigned to them.
- 1 client is the host, the other connects to the mission.
- Run these commands
// In the case of where the client is of type "B_Soldier_A_F": currentWeapon cursorTarget // returns "arifle_MX_ACO_pointer_F" weaponState cursorTarget // returns ["arifle_MX_ACO_pointer_F","arifle_MX_ACO_pointer_F","Single","30Rnd_65x39_caseless_mag",30,0,0] cursorTarget ammo currentWeapon cursorTarget // returns 30 // all returns are ok and expected
- Once in mission, have client fire weapon once.
// In the case of where the client is of type "B_Soldier_A_F": currentWeapon cursorTarget // returns "arifle_MX_ACO_pointer_F" weaponState cursorTarget // returns ["arifle_MX_ACO_pointer_F","arifle_MX_ACO_pointer_F","Single","30Rnd_65x39_caseless_mag",29,0,0] cursorTarget ammo currentWeapon cursorTarget // returns 29 // all returns are ok and expected
- Run the following on the server whilst looking at the client:
cursorTarget setUnitLoadout getUnitLoadout cursorTarget
However, you could also run the following code on the client:
player setUnitLoadout getUnitLoadout player
- On the client, fire the weapon once again
// In the case of where the client is of type "B_Soldier_A_F": currentWeapon cursorTarget // returns "arifle_MX_ACO_pointer_F" weaponState cursorTarget // returns ["arifle_MX_ACO_pointer_F","arifle_MX_ACO_pointer_F","Single","30Rnd_65x39_caseless_mag",29,0,0] cursorTarget ammo currentWeapon cursorTarget // returns 29 // all ammo counts are out of sync // interestingly, the round reloadphase from `weaponState` seems to return properly, despite the ammo count being wrong
- See that is takes a considerable amount of time for the ammo count to synchronize. If you change firemodes on the client, it forces a sync.
Revision: 152363
setUnitLoadout will now fail if unit is switching weapon
isSwitchingWeapon command added
while I could not repro it, replacing loadout during weapon switching should not be possible as it could theoretically lead to desync