mirror of
https://github.com/YGGverse/hlsdk-portable.git
synced 2025-01-24 05:34:18 +00:00
Fix m249 tape when reloading the empty clip (#232)
This commit is contained in:
parent
d862abafd7
commit
f4f83ca6c0
@ -895,6 +895,7 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm
|
||||
else if( player.m_pActiveItem->m_iId == WEAPON_M249 )
|
||||
{
|
||||
player.ammo_556 = (int)from->client.vuser2[1];
|
||||
( (CM249 *)player.m_pActiveItem )->m_iVisibleClip = (int)from->client.vuser2[2];
|
||||
}
|
||||
else if( player.m_pActiveItem->m_iId == WEAPON_SHOCKRIFLE )
|
||||
{
|
||||
@ -1015,10 +1016,10 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm
|
||||
body = 1;
|
||||
|
||||
if (pWeapon == &g_M249) {
|
||||
if (g_M249.m_iClip == 0) {
|
||||
if (g_M249.m_iVisibleClip == 0) {
|
||||
body = 8;
|
||||
} else if (g_M249.m_iClip > 0 && g_M249.m_iClip < 8) {
|
||||
body = 9 - g_M249.m_iClip;
|
||||
} else if (g_M249.m_iVisibleClip > 0 && g_M249.m_iVisibleClip < 8) {
|
||||
body = 9 - g_M249.m_iVisibleClip;
|
||||
} else {
|
||||
body = 0;
|
||||
}
|
||||
|
@ -1837,6 +1837,7 @@ void UpdateClientData( const struct edict_s *ent, int sendweapons, struct client
|
||||
else if( pl->m_pActiveItem->m_iId == WEAPON_M249 )
|
||||
{
|
||||
cd->vuser2.y = pl->ammo_556;
|
||||
cd->vuser2.z = ( (CM249 *)pl->m_pActiveItem )->m_iVisibleClip;
|
||||
}
|
||||
else if( pl->m_pActiveItem->m_iId == WEAPON_SHOCKRIFLE )
|
||||
{
|
||||
|
@ -221,10 +221,25 @@ void CM249::Reload(void)
|
||||
|
||||
void CM249::ItemPostFrame()
|
||||
{
|
||||
if (!m_fInReload)
|
||||
{
|
||||
m_iVisibleClip = m_iClip;
|
||||
}
|
||||
if ( m_fInSpecialReload )
|
||||
{
|
||||
if (m_pPlayer->m_flNextAttack <= UTIL_WeaponTimeBase())
|
||||
{
|
||||
int maxClip;
|
||||
#ifndef CLIENT_DLL
|
||||
maxClip = iMaxClip();
|
||||
#else
|
||||
ItemInfo itemInfo;
|
||||
GetItemInfo( &itemInfo );
|
||||
maxClip = itemInfo.iMaxClip;
|
||||
#endif
|
||||
m_iVisibleClip = m_iClip + Q_min( maxClip - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] );
|
||||
|
||||
UpdateTape(m_iVisibleClip);
|
||||
m_fInSpecialReload = FALSE;
|
||||
SendWeaponAnim( M249_RELOAD1, UseDecrement(), pev->body );
|
||||
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 2.4;
|
||||
@ -240,6 +255,8 @@ void CM249::WeaponIdle(void)
|
||||
|
||||
m_pPlayer->GetAutoaimVector(AUTOAIM_5DEGREES);
|
||||
|
||||
UpdateTape(m_iVisibleClip);
|
||||
|
||||
if (m_flTimeWeaponIdle > UTIL_WeaponTimeBase())
|
||||
return;
|
||||
|
||||
@ -253,17 +270,23 @@ void CM249::WeaponIdle(void)
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 155.0/25.0;
|
||||
}
|
||||
|
||||
SendWeaponAnim(iAnim);
|
||||
SendWeaponAnim(iAnim, UseDecrement(), pev->body);
|
||||
|
||||
m_flTimeWeaponIdle = UTIL_SharedRandomFloat(m_pPlayer->random_seed, 10, 15); // how long till we do this again.
|
||||
}
|
||||
|
||||
void CM249::UpdateTape()
|
||||
{
|
||||
if (m_iClip == 0) {
|
||||
UpdateTape(m_iClip);
|
||||
m_iVisibleClip = m_iClip;
|
||||
}
|
||||
|
||||
void CM249::UpdateTape(int clip)
|
||||
{
|
||||
if (clip == 0) {
|
||||
pev->body = 8;
|
||||
} else if (m_iClip > 0 && m_iClip < 8) {
|
||||
pev->body = 9 - m_iClip;
|
||||
} else if (m_iClip > 0 && clip < 8) {
|
||||
pev->body = 9 - clip;
|
||||
} else {
|
||||
pev->body = 0;
|
||||
}
|
||||
|
@ -1264,6 +1264,9 @@ public:
|
||||
}
|
||||
|
||||
void UpdateTape();
|
||||
void UpdateTape(int clip);
|
||||
|
||||
int m_iVisibleClip;
|
||||
|
||||
private:
|
||||
unsigned short m_usM249;
|
||||
|
Loading…
x
Reference in New Issue
Block a user