Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 5 commits into from
Sep 28, 2023

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.

@SergeyShorokhov SergeyShorokhov 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
4 checks passed
@dystopm dystopm deleted the fix-maxclip-reload-anim branch October 11, 2023 15:08
@Vaqtincha Vaqtincha mentioned this pull request Aug 16, 2024
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