AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Approved Plugins (https://forums.alliedmods.net/forumdisplay.php?f=8)
-   -   Reload Animation Fix (https://forums.alliedmods.net/showthread.php?t=174898)

MPNumB 12-27-2011 07:00

Reload Animation Fix
 
1 Attachment(s)
Description:
This plugin fixes a glitch when your weapon reload animation isn't shown, even though you are currently reloading your weapon. Also this plugin fixes shotgun reload resume glitch, when you are deploying m3 or xm1014. And when shotgun is deployed while having 0 bullets, reload animation is always accurate. Last, but not least, when spectating a person who has deagle, you don't get deploy or reload animation when you shouldn't.

Requires:
FakeMeta
HamSandWich


Additional info:
Tested in Counter-Strike 1.6 with amxmodx 1.8.2 (dev build hg21). If you want to execute and test this bug, buy an automatic weapon (mp5, ak47, m4a1..), with 2 backup clips, fire one clip until you hit reload, then once reload is done, start firing second clip, until you reach 0 ammunition and start reload again - that's when animation glitch happens. There are more scenarios when this bug happens, however this plugin should fix all of them.


Warnings:
Animations are client-side, therefor there may be firing animation issue just when reload ended for people who are playing with high ping and are holding attack button at that moment.


Credits:
Thanks to FOUTA for requesting this bug-fix.


Change-Log:

* 1.1
- Fixed: When deploying shotguns they don't resume previous reload.
- Fixed: When switching to shotgun with 0 bullets, reload animation is always accurate.
- Fixed: Shotguns lost their reload-stop animations.
- Removed: No need to fix main glitch for shotguns - they don't have this bug anyway.

* 1.0
- First release.

Devil259 12-27-2011 07:23

Re: Reload Animation Fix
 
Code:
    RegisterHam(Ham_Item_PostFrame, "weapon_glock18",      "Ham_Item_PostFrame_Pre", 0);     RegisterHam(Ham_Item_PostFrame, "weapon_usp",          "Ham_Item_PostFrame_Pre", 0);     RegisterHam(Ham_Item_PostFrame, "weapon_deagle",       "Ham_Item_PostFrame_Pre", 0);     RegisterHam(Ham_Item_PostFrame, "weapon_p228",         "Ham_Item_PostFrame_Pre", 0);     RegisterHam(Ham_Item_PostFrame, "weapon_elite",        "Ham_Item_PostFrame_Pre", 0);     RegisterHam(Ham_Item_PostFrame, "weapon_fiveseven",    "Ham_Item_PostFrame_Pre", 0);     RegisterHam(Ham_Item_PostFrame, "weapon_m3",           "Ham_Item_PostFrame_sgs_Pre", 0);     RegisterHam(Ham_Item_PostFrame, "weapon_xm1014",       "Ham_Item_PostFrame_sgs_Pre", 0);     RegisterHam(Ham_Item_PostFrame, "weapon_mp5navy",      "Ham_Item_PostFrame_Pre", 0);     RegisterHam(Ham_Item_PostFrame, "weapon_mac10",        "Ham_Item_PostFrame_Pre", 0);     RegisterHam(Ham_Item_PostFrame, "weapon_tmp",          "Ham_Item_PostFrame_Pre", 0);     RegisterHam(Ham_Item_PostFrame, "weapon_p90",          "Ham_Item_PostFrame_Pre", 0);     RegisterHam(Ham_Item_PostFrame, "weapon_ump45",        "Ham_Item_PostFrame_Pre", 0);     RegisterHam(Ham_Item_PostFrame, "weapon_galil",        "Ham_Item_PostFrame_Pre", 0);     RegisterHam(Ham_Item_PostFrame, "weapon_famas",        "Ham_Item_PostFrame_Pre", 0);     RegisterHam(Ham_Item_PostFrame, "weapon_ak47",         "Ham_Item_PostFrame_Pre", 0);     RegisterHam(Ham_Item_PostFrame, "weapon_m4a1",         "Ham_Item_PostFrame_Pre", 0);     RegisterHam(Ham_Item_PostFrame, "weapon_sg552",        "Ham_Item_PostFrame_Pre", 0);     RegisterHam(Ham_Item_PostFrame, "weapon_aug",          "Ham_Item_PostFrame_Pre", 0);     RegisterHam(Ham_Item_PostFrame, "weapon_g3sg1",        "Ham_Item_PostFrame_Pre", 0);     RegisterHam(Ham_Item_PostFrame, "weapon_sg550",        "Ham_Item_PostFrame_Pre", 0);     RegisterHam(Ham_Item_PostFrame, "weapon_scout",        "Ham_Item_PostFrame_Pre", 0);     RegisterHam(Ham_Item_PostFrame, "weapon_awp",          "Ham_Item_PostFrame_Pre", 0);     RegisterHam(Ham_Item_PostFrame, "weapon_m249",         "Ham_Item_PostFrame_Pre", 0);

->

Code:
new bitAllowWeapons = (1<<CSW_FLASHBANG)|(1<<CSW_SMOKEGRENADE)|(1<<CSW_KNIFE)|(1<<CSW_HEGRENADE) new szWeaponsName[ 20 ] for( new i = CSW_P228 ; i <= CSW_P90 ; i++ ) {     if( ~bitAllowWeapons & 1<<i && get_weaponname( i , szWeaponName , charsmax( szWeaponName ) ) )     {         RegisterHam( Ham_Item_PostFrame , szWeaponsName , "Ham_Item_PostFrame_Pre" , false )     } }

MPNumB 12-27-2011 08:29

Re: Reload Animation Fix
 
My method requires less CPU usage, while still remaining readable.

Gam3ronE 12-27-2011 08:54

Re: Reload Animation Fix
 
Thank you for sharing MPNumB and very good job.

You were given some credit on the website too: http://gamerone.net/showthread.php?tid=792

I have noticed this bug a lot and it is good to see a fix congratulations.

Devil259 12-27-2011 12:00

Re: Reload Animation Fix
 
Quote:

Originally Posted by MPNumB (Post 1620441)
My method requires less CPU usage, while still remaining readable.

Are you sure ?

nikhilgupta345 12-27-2011 12:20

Re: Reload Animation Fix
 
Quote:

Originally Posted by Devil259 (Post 1620525)
Are you sure ?

MPNumb's way uses slightly less CPU because of the non-existent for-loop in his code. He also doesn't have any get_weaponname natives which would use some CPU.

ConnorMcLeod 12-28-2011 01:34

Re: Reload Animation Fix
 
Generally a bad idea to cache alive players status because switch plugins easily mess up your plugin.
Also, if you keep it, you can directly pass g_iAlive in the macro since it is the only variable you use.

MPNumB 12-28-2011 06:55

Re: Reload Animation Fix
 
Quote:

Originally Posted by ConnorMcLeod (Post 1620822)
Generally a bad idea to cache alive players status because switch plugins easily mess up your plugin.
Also, if you keep it, you can directly pass g_iAlive in the macro since it is the only variable you use.

Switch plugins? You mean g_iAlive thing and pause/unpause? I know that, that's why I refresh all that info in public plugin_unpause(). Macro? What you mean by that?

---

Updated to 1.1
Fixed: When deploying shotguns they don't resume previous reload.
Fixed: When switching to shotgun with 0 bullets, reload animation is always accurate.
Fixed: Shotguns lost their reload-stop animations.
Removed: No need to fix main glitch for shotguns - they don't have this bug anyway.

FOUTA 12-28-2011 07:48

Re: Reload Animation Fix
 
awesome work mpnumb :D
thanks for taking some time and make this plugin... :D

ConnorMcLeod 12-28-2011 12:39

Re: Reload Animation Fix
 
For example a plugin that would switch a player from Ts to Spectator, your plugin could think he is still alive.


Just saying that
PHP Code:

new g_iAlive;
#define SetPlayerBit(%1,%2)    ( %1 |=  ( 1 << ( %2 & 31 ) ) )
#define ClearPlayerBit(%1,%2)  ( %1 &= ~( 1 << ( %2 & 31 ) ) )
#define CheckPlayerBit(%1,%2)  ( %1 &   ( 1 << ( %2 & 31 ) ) ) 

Would be better like :
PHP Code:

new g_iAlive;
#define MarkPlayerAlive(%0)    ( g_iAlive |=  ( 1 << ( %0 & 31 ) ) )
#define ClearPlayerAlive(%0)  ( g_iAlive &= ~( 1 << ( %0 & 31 ) ) )
#define CheckPlayerAlive(%0)  ( g_iAlive &   ( 1 << ( %0 & 31 ) ) ) 



All times are GMT -4. The time now is 02:25.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.