MantisBT - Zandronum
View Issue Details
0002282Zandronum[All Projects] Bugpublic2015-06-03 15:582024-03-21 15:04
Pawlacz 
 
normalminoralways
closedno change required 
MicrosoftWindowsXP/Vista/7
2.0 
 
0002282: Ammo Switching is bugged in MP with my mod
I tried making 2 items which "simulates" ammo cycling,
one uses Var Int User_X; which for some reason doesn't work when I host my mod on Best-Ever and TSPG-Britsteel.

Which is why I made the other Item uses only (Custom-)Inventory to achieve the same effect which works both in my dedicated server and on TSPG-Britsteel, but when the player "toys" around with the cannon and the ammo switcher all the items the player has disappears.


Mod File:'http://www73.zippyshare.com/v/7kGhrkPy/file.html [^]'
Files containing those actors:
Internal/Cannon_AmmoSwitch.txt
Weapon/75mmWeapon.txt

This bug does not happen at all on Singleplayer and works as intended.
1. Host a dedicated server and join it.
2. Bind the "Switch Cannon Ammo" under Customize Controls.
3. Spawn as Heavy Tank.
4. select the cannon.
5. "toy" around with the fire button and the ammo switch bind.
6. select weapons manually by pushing 1 .
7. when it doesn't work type in printinv command.
8. all the Items the player has is gone.

1. zandronum -file inventory_01.wad -host
2. zandronum -file inventory_01.wad -connect localhost
3. Join the game.
4. Fire with the pistol and wait for approx. 4 seconds.
No tags attached.
? inventory_01.wad (1,754) 2015-06-07 19:16
/tracker/file_download.php?file_id=1533&type=bug
Issue History
2015-06-03 15:58PawlaczNew Issue
2015-06-07 19:16unknownnaStatusnew => confirmed
2015-06-07 19:16unknownnaFile Added: inventory_01.wad
2015-06-07 19:19unknownnaSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=7308#r7308
2015-06-07 19:27unknownnaNote Added: 0012588
2015-06-08 06:22PawlaczNote Added: 0012592
2015-06-08 06:23PawlaczNote Edited: 0012592bug_revision_view_page.php?bugnote_id=12592#r7310
2015-06-08 15:24unknownnaNote Added: 0012594
2015-06-08 15:25unknownnaNote Edited: 0012594bug_revision_view_page.php?bugnote_id=12594#r7316
2015-06-08 17:22PawlaczNote Added: 0012598
2024-03-21 15:03Ru5tK1ngNote Added: 0023450
2024-03-21 15:04Ru5tK1ngStatusconfirmed => closed
2024-03-21 15:04Ru5tK1ngResolutionopen => no change required

Notes
(0012588)
unknownna   
2015-06-07 19:27   
It's a weird issue that seems to have something to do with the "Held" state in the inventory item that is given to the player when firing a weapon.

I'd say that this issue is caused by undefined behavior, but I could be wrong. If I remove the tic duration from the first frame in the state, Zandronum crashes.

From:
Held:
 TNT1 A 145
 TNT1 A 0 A_GiveInventory("MT_Sound_GunLoaded5")
 TNT1 A 0 A_TakeInventory("75mmReloadTime",1)
 TNT1 A 0
 stop

To:
Held:
 TNT1 A 0
 TNT1 A 0 A_GiveInventory("MT_Sound_GunLoaded5")
 TNT1 A 0 A_TakeInventory("75mmReloadTime",1)
 TNT1 A 0
 stop
(0012592)
Pawlacz   
2015-06-08 06:22   
(edited on: 2015-06-08 06:23)
" If I remove the tic duration from the first frame in the state, Zandronum crashes."

It is because my weapon fires very fast, and I limit this speed by a inventory item. I have to do so that the player can immediately use the Coax-MG/Altfire after firing the gun.

The second reason why the weapon firing state is always 0 tic is because some of those ammo types
have a 2nd firing mode and the weapon bugs when the tic duration is larger than 0.
Like the HEAT ammo can fire a HEI shell instead

So basically if the firing state has tics larger than 0 and the player tries to
switch the weapon mode, the weapon doesn't function properly read: it is bugging.

(0012594)
unknownna   
2015-06-08 15:24   
(edited on: 2015-06-08 15:25)
Quote from Pawlacz
So basically if the firing state has tics larger than 0 and the player tries to switch the weapon mode, the weapon doesn't function properly read: it is bugging.

FYI, the mod still bugs up without switching the weapon mode, i.e., without using the MT_AmmoSwitcher actor. It all seems to boil down to the "Held" state in the 75mmReloadTime inventory item that is given to the player. Here's how it goes:

* Player fires the weapon and is given (A_Giveinventory) 75mmReloadTime.
* 75mmReloadTime goes to the "Held" state and gives (A_Giveinventory) MT_Sound_GunLoaded5 to the player before removing (A_TakeInventory) itself from the player's inventory.
* MT_Sound_GunLoaded5 goes to the "Use" state and triggers A_PlaySound before removing (A_TakeInventory) itself from the player's inventory.

For some reason the client removes all of its inventory when MT_Sound_GunLoaded5 removes itself from the player's inventory, and only when MT_Sound_GunLoaded5 is given to the player through 75mmReloadTime. Giving it directly to the player doesn't cause it to happen.

(0012598)
Pawlacz   
2015-06-08 17:22   
Thanks for pin pointing the problem and the detailed explanation.

I changed the 75mmReloadTime

From:
ACTOR 75mmReloadTime : MT_A_BooleanValue
{
States
{
 Held:
 TNT1 A 145
 TNT1 A 0 A_GiveInventory("MT_Sound_GunLoaded5",1)
 TNT1 A 0 A_TakeInventory("75mmReloadTime",1)
 TNT1 A 0
 stop
}}

To:

ACTOR 75mmReloadTime : MT_A_BooleanValue
{
States
{
 Held:
 TNT1 A 145
// TNT1 A 0 A_GiveInventory("MT_Sound_GunLoaded5",1)
// TNT1 A 0 A_TakeInventory("75mmReloadTime",1)
 TNT1 A 0
 stop
}}


then I did another test by hosting a dedicated server and mashing all 4 buttons
(Fire , AltFire , Switch Cannon Mode and Switch Weapon Mode (Primary) )
and no bug is appearing.


So I need then find a other way to let the player know he can use the weapon now.
(0023450)
Ru5tK1ng   
2024-03-21 15:03   
In the example wad, added a 1 tic delay in the Held state before 'stop' resolved the issue of the player losing their inventory:

 Held:
 TNT1 A 145
 TNT1 A 0 A_GiveInventory("MT_Sound_GunLoaded5")
 TNT1 A 0 A_TakeInventory("75mmReloadTime",1)
 TNT1 A 1
 stop

It's just best practice to avoid using a bunch of TNT1 A 0 with actions repeatedly without a delay to avoid issues like this.