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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants