Half-Life Updated (custom SDK) Created 1 week ago2021-01-13 21:05:33 UTC by Solokiller Solokiller

Created 1 week ago2021-01-13 21:05:33 UTC by Solokiller Solokiller

Posted 1 week ago2021-01-13 21:05:33 UTC Post #345215
I've updated Half-Life Updated to include a couple bug fixes:
  • Add null check to bullsquid spit attack animation event to prevent crash if enemy pointer is cleared between animation start and animation event occurrence (halflife issue #2834)
  • Fix crash when switching back to last item when item was removed (halflife issue #1815)
  • Add call to TabulateAmmo (halflife issue #1707)
  • Change CRpgRocket m_pLauncher to EHANDLE (halflife issue #1719)
  • Use fps-independent frametime for NPC pitch & yaw adjustments (halflife issue #2458)
  • Fix chainsaw crowbar effect when hitting corpse (halflife issue #2590)
  • Fix server not staying in sync with client when handling weapon attack times (halflife issue #1621)
  • Fix m_rawinput 1 getting mouse stuck in box (halflife issue #1377)
  • Fix shotgun pump sound not playing when holding down attack or when shooting last shell (halflife issue #617)
The CMake version has also been updated to include these fixes.

I've also looked into the well known bug where turning on raw mouse input in a mod causes the mouse to get stuck in a box, which prevents you from looking around. Turns out it's happening because the engine can't tell that the mod is using SDL's raw input, so it doesn't turn on required functionality. Once the engine recognizes that it does (i tricked it into recognizing it using a hack that isn't usable for actual mods) it works perfectly.

More information here: https://github.com/ValveSoftware/halflife/issues/1377#issuecomment-759627720

As soon as someone at Valve can get around to implementing the fix and updating the SDK to include the required new API the fix can be merged in, and anyone making mods can integrate it to opt in to the correct behavior.

You can find the Updated source code here: https://github.com/Solokiller/halflife-updated
And the CMake version here: https://github.com/Solokiller/halflife-updated-cmake

The old thread about this lists other changes: https://twhl.info/thread/view/19592

An unlisted change is that this also supports VS2019 out of the box.
Posted 1 week ago2021-01-14 00:55:22 UTC Post #345216
This is really interesting stuff! Does this fix the fast crowbar gib bug and the double shot bug from the glock's secondary fire?
Posted 1 week ago2021-01-14 09:55:15 UTC Post #345219
This is really interesting stuff! Does this fix the fast crowbar gib bug and the double shot bug from the glock's secondary fire?
No for both.
Posted 1 week ago2021-01-14 10:54:42 UTC Post #345220
This is really interesting stuff! Does this fix the fast crowbar gib bug and the double shot bug from the glock's secondary fire?
I can fix the crowbar bug, but what's the double shot bug exactly? Just so i know what to look for.
Posted 1 week ago2021-01-14 11:34:22 UTC Post #345221
Just as an aside, the crowbar fix is in SOHL - it's just 1 new line to add:
https://github.com/LogicAndTrick/halflife-updated/blob/spirit/spirit-1.0/dlls/crowbar.cpp#L268

Before:
if ( !pEntity->IsAlive() )
      return TRUE;
else
      flVol = 0.1;
After:
if ( !pEntity->IsAlive() ) { m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.25; //LRC: corrected half-life bug return TRUE; } else flVol = 0.1;
Penguinboy PenguinboyHaha, I died again!
Posted 1 week ago2021-01-14 12:20:12 UTC Post #345222
I can fix the crowbar bug, but what's the double shot bug exactly? Just so i know what to look for.
Probably the fact that client prediction can call events twice, I opened this related issue back in 2015.

Mods can compile the SDK without the CLIENT_WEAPONS pre-processor define enabled. This will however require the programmer to move the client sided stuff back to the server for weapons. In other words: revert what Valve did when they introduced the client prediction system. An alternative is to set the cl_lw CVAR (Console VARiable) to 0 (false).

However, I strongly advise to not do that since they are more "workarounds" rather than "proper fixes", especially if the mod supports multiplayer.
Posted 1 week ago2021-01-14 12:48:38 UTC Post #345223
I've fixed the crowbar issue using the fix i suggested on Github a while back, it'll be pushed soon.

I'm looking into the double shot issue. So far i've determined that the issue is caused by the client prediction code firing off a shot locally when the server isn't, which results in a simulated shot that never happens on the server side.

See this console output. There are 3 log calls, 2 of them are the client and server versions of the mp5's attack code, right below the event playback call, the other is in the event callback:
cl:  client fired mp5 1 times
server fired mp5 1 times
client event fired mp5 1 times

cl:  client fired mp5 2 times
server fired mp5 2 times
client event fired mp5 2 times

cl:  client fired mp5 3 times
client event fired mp5 3 times

cl:  client fired mp5 4 times
server fired mp5 3 times
client event fired mp5 4 times
The third shot only happens on the client due to prediction code running it, but never on the server side. I ended up with 4 shots too many after a full 50 rounds fired.

I think this is just a timing issue in the prediction code, so i'll see if i can isolate the cause, and perhaps find a way to make it run on the same timing logic as the server.
Posted 1 week ago2021-01-14 15:31:07 UTC Post #345224
I think i found the cause of it, i've provided an explanation and the fix here: https://github.com/ValveSoftware/halflife/issues/1621#issuecomment-760270846
Posted 1 week ago2021-01-14 17:50:48 UTC Post #345226
I've added the crowbar and the weapon timing fixes.
Posted 1 week ago2021-01-14 22:45:41 UTC Post #345228
I know i'm late but i've made a video showing the issue:
I'm currently working on a Half-Life project and i would like to ask if its ok if i get the fixed code for that issue and compile it with my SDK. I also want to congrats you guys for this fantastic work, it's nice to see that after all these years people is still giving this game the love it deserves.
Just as an aside, the crowbar fix is in SOHL - it's just 1 new line to add: https://github.com/LogicAndTrick/halflife-updated/blob/spirit/spirit-1.0/dlls/crowbar.cpp#L268
Nice! Thank you! I should try it out.
Posted 1 week ago2021-01-14 23:16:03 UTC Post #345231
It looks like that's the same bug. The fix i posted earlier doesn't seem to work for the glock so i'll have to look into that.

You have permission to use my work for your project.

EDIT: i've fixed the prediction sync issues entirely. It's consistent now, at least as far as ballistic weapons go.
Posted 1 week ago2021-01-15 00:12:28 UTC Post #345232
Wow, good work! I was just checking your explanation of the issue and when i updated the page the fix was already there. Compiled my SDK with the fixes made for the crowbar and the prediction sync issue of the weapons and it worked just fine.
Posted 1 week ago2021-01-18 04:05:59 UTC Post #345239
Nice.

I reverted your crowbar change in my code though. :cool:
Posted 1 week ago2021-01-18 13:41:24 UTC Post #345242
@Cabo Fiambre
You're welcome, good to hear it's working.

@Unq
Guess you prefer chainsaws over crowbars eh :P

I've added two new fixes: the raw mouse input fix from Half-Nuked and the shotgun pump sound fix. Thanks jay! for letting me know about these.
You must be logged in to post a response.