Skip to content

FIX: Reloading animation bug while holding weapon with altered Maxclip#861

Merged
s1lentq merged 5 commits intorehlds:masterfrom
dystopm:fix-maxclip-reload-anim
Sep 28, 2023
Merged

FIX: Reloading animation bug while holding weapon with altered Maxclip#861
s1lentq merged 5 commits intorehlds:masterfrom
dystopm:fix-maxclip-reload-anim

Conversation

@dystopm
Copy link
Contributor

@dystopm dystopm commented Sep 11, 2023

Sort of an old bug. If client prediction is activated (cl_lw 1), player is holding a weapon whose maxclip was altered (easily nowadays with rg_set_iteminfo natives), active weapon's clip is equal to altered maxclip, and then presses the reload button, it will reproduce a client-side reload animation which stops until player releases the button, because client thinks you met the conditions to reload the weapon considering its clip differs from its maxclip.

This fixes that weapon animation by faking the weapon's current clip in case the weapon has a different maxclip from its original, and is actually holding the gun with clip == newmaxclip.

You can see the conditions in the files changed.

I might say it needs tests 👍

@RauliTop
Copy link
Contributor

Just for documentation, same fix from a metamod plugin: https://goldsrc.ru/threads/4165/

Also we have a video: https://www.youtube.com/watch?v=k_jGf7mLYBo
Bug happen when the weapon has 35 ammo and tries to reload.

@Vaqtincha

This comment was marked as off-topic.

@dystopm
Copy link
Contributor Author

dystopm commented Sep 12, 2023

Спиздил мой метод и даже не указал на кредитах. 😀

Excuse me? I don't even know that forum 😆

I discovered this in a +10 year old plugin that describes this bug behaviour, which I was using in my weapon addons: https://forums.alliedmods.net/showthread.php?t=82093

	if( iButton & IN_RELOAD && !fInReload )
	{
		if( iClip >= iMaxClip )
		{
			set_pev(id, pev_button, iButton & ~IN_RELOAD)
			if( SILENT_BS & (1<<iId) && !get_pdata_int(iEnt, m_fSilent, XTRA_OFS_WEAPON) )
			{
				SendWeaponAnim( id, iId == CSW_USP ? 8 : 7 )
			}
			else
			{
				SendWeaponAnim(id, 0)
			}
		}

The only way to fake client weapon data is by GetWeaponData function, which is way better than resetting weaponanim.

Sorry for not reading the entire internet to avoid a kid's cry. I suggest you to be polite, this isn't a forum, nor a plugin submission system.

@wopox1337 wopox1337 added Type: 🧬 bug in original GameDLL An error that could not be fixed by GameDLL. Priority: 🕒 low Low priority tasks that can be postponed for the future. Status: ✅ done The issue done and closed. labels Sep 14, 2023
@s1lentq s1lentq merged commit 67e7d87 into rehlds:master Sep 28, 2023
@dystopm dystopm deleted the fix-maxclip-reload-anim branch October 11, 2023 15:08
@Vaqtincha Vaqtincha mentioned this pull request Aug 16, 2024
yohimik pushed a commit to yohimik/ReGameDLL_CS that referenced this pull request Jun 5, 2025
…lip (rehlds#861)

* Add functions for default weaponinfo array
* Whitespace cleaning and pointer safety check
* Added reload condition to enhance conditions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Priority: 🕒 low Low priority tasks that can be postponed for the future. Status: ✅ done The issue done and closed. Type: 🧬 bug in original GameDLL An error that could not be fixed by GameDLL.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants