Context: normally, a weapon dropped by a player upon their death (if sv_weapondrop is true), when picked up again, should have the same amounts of ammo in it as the previous owner had in their inventory when they died. However, there is a case where this doesn't turn out to be true.
This seems to be a unintentional side-effect of how sv_weapondrop mechanic works: it doesn't re-use the existing weapon (the one the player has upon death), but creates a new instance instead. Then it checks the AmmoGive1 and AmmoGive2 values on the existing weapon, and if they are greater than 0, then the values of AmmoGive1 and AmmoGive2 on the newly created weapon are replaced with the deceased player's corresponding ammo amounts. Normally, if the weapon uses ammo, then AmmoGive1 is never 0 (at least in vanilla Doom). However, it can become 0 if the weapon has been previously dropped with the "weapdrop" command. In this case, the AmmoGive values on the new weapon instance created upon death will not be replaced with the player's ammo amounts, and the weapon will have its default AmmoGive values instead.
To reproduce this, no test samples are needed. Two testing procedures are given below, one to demonstrate the normal behavior and another one to demonstrate the buggy behavior. The code blocks are console commands.
Normal behavior
1. Load any map, then give / summon a weapon and some ammo, for example, a shotgun and some shells:
Code: Select all
give shotgun
give shell
give shell
Code: Select all
sv_weapondrop 1
Code: Select all
kill
Code: Select all
resurrect; take weapons; take ammo
Buggy behavior
Start a new game, repeat steps 1 and 2 of the above. Then drop the weapon:
Code: Select all
weapdrop
IMO, those AmmoGive checks shouldn't be there, though maybe there is a case when they are actually needed to avoid some other unexpected outcome. Then I have no idea how this may be fixed. Also, speaking of sv_weapondrop mechanic in general, if it is not possible to re-use the existing weapon instance when generating the dropped weapon, I wish that there at least was some function which the newly generated weapon would call on the old weapon instance, so that the old weapon could pass information to the new one. Currently, it is not possible to copy custom state information when the dropped weapon is generated, aside maybe with some gross hack that I have no desire to look for and implement.
Tested in GZDoom 3.6.0, g3.7pre-15-g43c30ff48