TTT-2 / TTT2

Trouble in Terrorist Town 2 for Garry's Mod (gmod)
https://steamcommunity.com/sharedfiles/filedetails/?id=1357204556
178 stars 74 forks source link

Weapon Switch Bug #407

Closed ThePlatinumGhost closed 4 years ago

ThePlatinumGhost commented 4 years ago

Video https://www.youtube.com/watch?v=bHaO20lVRvs

Describe the bug So, we found out about some bugs with the new pick-up system for the weapons, the first and most common one (even if it doesn't happen often) basically makes weapons disappear when someone tries to pick them up but sometimes they do reappear when you try to get another one; the second one is more confusing and may be client-side, with this one some players couldn't pick up specific weapons from the floor while others could but it happened very rarely.

To Reproduce These bugs were very random and hard to replicate

Expected behaviour The weapon should not disappear and be usable

Desktop (please complete the following information):

TimGoll commented 4 years ago
  1. Yes this is known and can't be changed since we have to use an internal hook which we can't influence when it is called. When picking up a new weapon, the old one drops to the ground to remove the problem of disappearing weapons. Sadly this is a workaround to a gmod limitation. (See this featurerequest: https://github.com/Facepunch/garrysmod-requests/issues/1235)

  2. This is strange. I can't see a reason why this could happen.

There are still a few minor bugs that I will fix before the update gets released. This might fix your 2nd bug as well. I don't know. (See 0.6: https://trello.com/b/KVz1VKWm/ttt2)

TimGoll commented 4 years ago

Ok. Your second scenario: did you try to pickup a weapon and this failed before you tried to autopickup the other weapon?

If so, I know why your bug happens. Caused by the same reason as 1, sometimes the pickup hook is a bit unpredictable. Therefore I disabled autopickup for the player that attempts a weapon switch, until the weapon of his desire is in his inventory. If this fails and the weapon stays floating, he can't pickup another weapon with autopickup until he successfully added a weapon into his inventory with the new weapon switch. I could add a timeout though

ThePlatinumGhost commented 4 years ago

I don't remember but I was trying to replicate bug 1# and after a couple of weapon switches with other weapons i found out this weapon to be unpickable and without outline Before this bug every weapon switch worked fine

TimGoll commented 4 years ago

Without outline? Hmm. I will look at the code but if there is no outline it seems like there is an issue independent of the new weapon switch system. Sometimes in vanilla TTT players were also unable to pick up certain weapons. This might be connected to this issue

ThePlatinumGhost commented 4 years ago

Yes i remember a similar bug in vanilla TTT, i usually fix it by moving the weapon a little bit with the magneto stick But in the case of the recorded video it didn't work, i must do more test

TimGoll commented 4 years ago

Okay, I investigated things further. In cases when the weapon can't be picked up, it is because the Pickup hook isn't called at all. Sadly, I don't know why it isn't called. At some point a weapon starts bugging and it can't be picked up anymore.

If someone reading this issue has an idea, please let me know

I tried teleporting the weapon to random positions next to the player but it did not help.

The Weapon Metatables are identical as well (comparing one Mac10 that can be picked up with another mac 10 that can not)

ThePlatinumGhost commented 4 years ago

1#) I'm pretty sure I found out how this disappearing weapon bug happens, and was able to replicate it 90% of the time, I'm not sure it is linked to the other bugs reported as well but it seems to behave differently

https://youtu.be/heXC0OeIf2g

TimGoll commented 4 years ago

The disappearing thing is because of the error handling. But I see you mean the problem with picking up the weapons, am I right? And it looks like this problem happens when being crouched?

TimGoll commented 4 years ago

The thing is, it is entirely possible that the weapons get stuck in thge ammo boyes when crouching and I don't know if there is anything i could do about this. GMOD is just stupid tbh

ThePlatinumGhost commented 4 years ago

About https://youtu.be/heXC0OeIf2g I think I understand, it happens when there isn't enough room to drop the weapon, so it disappears. For example when you crouch or in specific locations. I think if this is the problem the solution might be similar to a function that's already present in Vanilla TTT, that is setting an "IF" that checks if there's enough space when you exchange weapons. Half Life  Source Screenshot 2019 12 06 - 16 58 34 49 I'm no expert in the subject so I might be wrong but maybe it can help figure this out.

TimGoll commented 4 years ago

I implemented some workarounds to improve the mentioned problems in https://github.com/TTT-2/TTT2/commit/59b6a0342d60736411b37367528f548110c9e7d3

TimGoll commented 4 years ago

Huh, is this issue fixed for you? Because we got a better grasp of the problem. It seems to happen when you drop the picked up weapon too early.

ThePlatinumGhost commented 4 years ago

Yes i closed the issue because the major bug it's fixed for me but if you want I can keep the issue open

TimGoll commented 4 years ago

doesn't matter too much. We'll try our best to improve this further

TimGoll commented 4 years ago

Should be fixed with #424 Please reopen if this problem still exists after the merge.