Browse Source

Update m249

opforfixed
Roman Chistokhodov 5 years ago
parent
commit
ea13d88e37
  1. 2
      cl_dll/ev_hldm.cpp
  2. 10
      cl_dll/hl/hl_weapons.cpp
  3. 71
      dlls/gearbox/m249.cpp
  4. 2
      dlls/weapons.cpp
  5. 9
      dlls/weapons.h

2
cl_dll/ev_hldm.cpp

@ -2018,7 +2018,7 @@ void EV_FireM249( event_args_t *args )
{ {
// Add muzzle flash to current weapon model // Add muzzle flash to current weapon model
EV_MuzzleFlash(); EV_MuzzleFlash();
gEngfuncs.pEventAPI->EV_WeaponAnimation( M249_SHOOT1 + gEngfuncs.pfnRandomLong( 0, 2 ), 1 ); gEngfuncs.pEventAPI->EV_WeaponAnimation( M249_SHOOT1 + gEngfuncs.pfnRandomLong( 0, 2 ), args->iparam2 );
V_PunchAxis( 0, gEngfuncs.pfnRandomFloat( -2, 2 ) ); V_PunchAxis( 0, gEngfuncs.pfnRandomFloat( -2, 2 ) );
} }

10
cl_dll/hl/hl_weapons.cpp

@ -1005,6 +1005,16 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm
if( pWeapon == &g_Python && bIsMultiplayer() ) if( pWeapon == &g_Python && bIsMultiplayer() )
body = 1; body = 1;
if (pWeapon == &g_M249) {
if (g_M249.m_iClip == 0) {
body = 8;
} else if (g_M249.m_iClip > 0 && g_M249.m_iClip < 8) {
body = 9 - g_M249.m_iClip;
} else {
body = 0;
}
}
// Force a fixed anim down to viewmodel // Force a fixed anim down to viewmodel
HUD_SendWeaponAnim( to->client.weaponanim, body, 1 ); HUD_SendWeaponAnim( to->client.weaponanim, body, 1 );
} }

71
dlls/gearbox/m249.cpp

@ -37,8 +37,7 @@ enum m249_e
}; };
LINK_ENTITY_TO_CLASS(weapon_m249, CM249); LINK_ENTITY_TO_CLASS(weapon_m249, CM249)
//========================================================= //=========================================================
//========================================================= //=========================================================
@ -51,7 +50,7 @@ void CM249::Spawn()
m_iDefaultAmmo = M249_DEFAULT_GIVE; m_iDefaultAmmo = M249_DEFAULT_GIVE;
m_iReloadState = RELOAD_STATE_NONE; m_fInSpecialReload = 0;
FallInit();// get ready to fall down. FallInit();// get ready to fall down.
} }
@ -111,9 +110,16 @@ int CM249::AddToPlayer(CBasePlayer *pPlayer)
BOOL CM249::Deploy() BOOL CM249::Deploy()
{ {
m_fInSpecialReload = FALSE;
UpdateTape();
return DefaultDeploy("models/v_saw.mdl", "models/p_saw.mdl", M249_DEPLOY, "m249"); return DefaultDeploy("models/v_saw.mdl", "models/p_saw.mdl", M249_DEPLOY, "m249");
} }
void CM249::Holster(int skiplocal)
{
m_fInSpecialReload = FALSE;
CBasePlayerWeapon::Holster();
}
void CM249::PrimaryAttack() void CM249::PrimaryAttack()
{ {
@ -139,8 +145,7 @@ void CM249::PrimaryAttack()
m_pPlayer->m_iWeaponFlash = NORMAL_GUN_FLASH; m_pPlayer->m_iWeaponFlash = NORMAL_GUN_FLASH;
m_iClip--; m_iClip--;
UpdateTape();
m_pPlayer->pev->effects = (int)(m_pPlayer->pev->effects) | EF_MUZZLEFLASH; m_pPlayer->pev->effects = (int)(m_pPlayer->pev->effects) | EF_MUZZLEFLASH;
// player "shoot" animation // player "shoot" animation
@ -172,7 +177,7 @@ void CM249::PrimaryAttack()
flags = 0; flags = 0;
#endif #endif
PLAYBACK_EVENT_FULL(flags, m_pPlayer->edict(), m_usM249, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, vecDir.x, vecDir.y, 0, 0, 0, 0); PLAYBACK_EVENT_FULL(flags, m_pPlayer->edict(), m_usM249, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, vecDir.x, vecDir.y, 0, pev->body, 0, 0);
#ifndef CLIENT_DLL #ifndef CLIENT_DLL
@ -193,7 +198,7 @@ void CM249::PrimaryAttack()
// HEV suit - indicate out of ammo condition // HEV suit - indicate out of ammo condition
m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0); m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0);
m_flNextPrimaryAttack = GetNextAttackDelay(0.1); m_flNextPrimaryAttack = GetNextAttackDelay(0.067);
if (m_flNextPrimaryAttack < UTIL_WeaponTimeBase()) if (m_flNextPrimaryAttack < UTIL_WeaponTimeBase())
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.1; m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.1;
@ -204,12 +209,31 @@ void CM249::PrimaryAttack()
void CM249::Reload(void) void CM249::Reload(void)
{ {
if (m_pPlayer->ammo_556 <= 0) if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 || m_iClip == M249_MAX_CLIP)
return; return;
DefaultReload(M249_MAX_CLIP, M249_RELOAD1, 1.5); if (DefaultReload(M249_MAX_CLIP, M249_LAUNCH, 1.33, pev->body)) {
m_fInSpecialReload = TRUE;
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 3.78;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 3.78;
}
} }
void CM249::WeaponTick()
{
if ( m_fInSpecialReload )
{
if (m_pPlayer->m_flNextAttack <= UTIL_WeaponTimeBase())
{
UpdateTape();
m_fInSpecialReload = FALSE;
SendWeaponAnim( M249_RELOAD1, UseDecrement(), pev->body );
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 2.4;
}
return;
}
}
void CM249::WeaponIdle(void) void CM249::WeaponIdle(void)
{ {
@ -220,17 +244,14 @@ void CM249::WeaponIdle(void)
if (m_flTimeWeaponIdle > UTIL_WeaponTimeBase()) if (m_flTimeWeaponIdle > UTIL_WeaponTimeBase())
return; return;
float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0.0f, 1.0f );
int iAnim; int iAnim;
switch (RANDOM_LONG(0, 1)) if (flRand <= 0.8) {
{
case 0:
iAnim = M249_SLOWIDLE; iAnim = M249_SLOWIDLE;
break; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 5;
} else {
default:
case 1:
iAnim = M249_IDLE2; iAnim = M249_IDLE2;
break; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 155.0/25.0;
} }
SendWeaponAnim(iAnim); SendWeaponAnim(iAnim);
@ -238,15 +259,15 @@ void CM249::WeaponIdle(void)
m_flTimeWeaponIdle = UTIL_SharedRandomFloat(m_pPlayer->random_seed, 10, 15); // how long till we do this again. m_flTimeWeaponIdle = UTIL_SharedRandomFloat(m_pPlayer->random_seed, 10, 15); // how long till we do this again.
} }
void CM249::UpdateTape()
void CM249::ReloadStart(void)
{ {
SendWeaponAnim(M249_RELOAD1, UseDecrement()); if (m_iClip == 0) {
} pev->body = 8;
} else if (m_iClip > 0 && m_iClip < 8) {
void CM249::ReloadInsert(void) pev->body = 9 - m_iClip;
{ } else {
SendWeaponAnim(M249_RELOAD1, UseDecrement()); pev->body = 0;
}
} }
class CM249AmmoClip : public CBasePlayerAmmo class CM249AmmoClip : public CBasePlayerAmmo

2
dlls/weapons.cpp

@ -1697,7 +1697,7 @@ IMPLEMENT_SAVERESTORE( CBarnacleGrapple, CBasePlayerWeapon )
TYPEDESCRIPTION CM249::m_SaveData[] = TYPEDESCRIPTION CM249::m_SaveData[] =
{ {
DEFINE_FIELD( CM249, m_iReloadState, FIELD_INTEGER ), DEFINE_FIELD( CM249, m_fInSpecialReload, FIELD_INTEGER ),
}; };
IMPLEMENT_SAVERESTORE( CM249, CBasePlayerWeapon ) IMPLEMENT_SAVERESTORE( CM249, CBasePlayerWeapon )

9
dlls/weapons.h

@ -1247,7 +1247,9 @@ public:
void PrimaryAttack(void); void PrimaryAttack(void);
BOOL Deploy(void); BOOL Deploy(void);
void Holster(int skiplocal = 0);
void Reload(void); void Reload(void);
void WeaponTick();
void WeaponIdle(void); void WeaponIdle(void);
virtual BOOL ShouldWeaponIdle(void) { return TRUE; } virtual BOOL ShouldWeaponIdle(void) { return TRUE; }
float m_flNextAnimTime; float m_flNextAnimTime;
@ -1262,12 +1264,7 @@ public:
#endif #endif
} }
void ReloadStart( void ); void UpdateTape();
void ReloadInsert( void );
enum M249_RELOAD_STATE { RELOAD_STATE_NONE = 0, RELOAD_STATE_OPEN, RELOAD_STATE_FILL };
int m_iReloadState;
private: private:
unsigned short m_usM249; unsigned short m_usM249;

Loading…
Cancel
Save