Browse Source

Predicted grapple

opforfixed
Roman Chistokhodov 5 years ago
parent
commit
12cd2832d4
  1. 5
      cl_dll/hl/hl_weapons.cpp
  2. 25
      dlls/gearbox/grapple.cpp
  3. 6
      dlls/weapons.h

5
cl_dll/hl/hl_weapons.cpp

@ -76,6 +76,7 @@ CPipeWrench g_PipeWrench;
CShockrifle g_Shock; CShockrifle g_Shock;
CSniperrifle g_Sniper; CSniperrifle g_Sniper;
CSporelauncher g_Spore; CSporelauncher g_Spore;
CBarnacleGrapple g_Grapple;
/* /*
====================== ======================
@ -634,6 +635,7 @@ void HUD_InitClientWeapons( void )
HUD_PrepEntity( &g_Shock, &player ); HUD_PrepEntity( &g_Shock, &player );
HUD_PrepEntity( &g_Sniper, &player ); HUD_PrepEntity( &g_Sniper, &player );
HUD_PrepEntity( &g_Spore, &player ); HUD_PrepEntity( &g_Spore, &player );
HUD_PrepEntity( &g_Grapple, &player );
} }
/* /*
@ -766,6 +768,9 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm
case WEAPON_SPORELAUNCHER: case WEAPON_SPORELAUNCHER:
pWeapon = &g_Spore; pWeapon = &g_Spore;
break; break;
case WEAPON_GRAPPLE:
pWeapon = &g_Grapple;
break;
} }
// Store pointer to our destination entity_state_t so we can get our origin, etc. from it // Store pointer to our destination entity_state_t so we can get our origin, etc. from it

25
dlls/gearbox/grapple.cpp

@ -63,9 +63,6 @@ void CBarnacleGrapple::Precache( void )
PRECACHE_MODEL( "sprites/tongue.spr" ); PRECACHE_MODEL( "sprites/tongue.spr" );
UTIL_PrecacheOther( "grapple_tip" ); UTIL_PrecacheOther( "grapple_tip" );
m_flNextPrimaryAttack = 0;
m_flNextSecondaryAttack = 0;
m_flTimeWeaponIdle = 0;
} }
void CBarnacleGrapple::Spawn( void ) void CBarnacleGrapple::Spawn( void )
@ -110,7 +107,7 @@ int CBarnacleGrapple::AddToPlayer( CBasePlayer* pPlayer )
BOOL CBarnacleGrapple::Deploy() BOOL CBarnacleGrapple::Deploy()
{ {
int r = DefaultDeploy("models/v_bgrap.mdl", "models/p_bgrap.mdl", BGRAPPLE_UP, "gauss" ); int r = DefaultDeploy("models/v_bgrap.mdl", "models/p_bgrap.mdl", BGRAPPLE_UP, "gauss" );
m_flTimeWeaponIdle = gpGlobals->time + 1.1; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.1;
return r; return r;
} }
@ -128,7 +125,7 @@ void CBarnacleGrapple::WeaponIdle( void )
{ {
ResetEmptySound(); ResetEmptySound();
if( m_flTimeWeaponIdle > gpGlobals->time ) if( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() )
return; return;
if( m_fireState != OFF ) if( m_fireState != OFF )
@ -146,19 +143,19 @@ void CBarnacleGrapple::WeaponIdle( void )
if( flNextIdle <= 0.5 ) if( flNextIdle <= 0.5 )
{ {
iAnim = BGRAPPLE_LONGIDLE; iAnim = BGRAPPLE_LONGIDLE;
m_flTimeWeaponIdle = gpGlobals->time + 10.0; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 10.0;
} }
else if( flNextIdle > 0.95 ) else if( flNextIdle > 0.95 )
{ {
EMIT_SOUND_DYN( ENT(m_pPlayer->pev), CHAN_STATIC, "weapons/bgrapple_cough.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM ); EMIT_SOUND_DYN( ENT(m_pPlayer->pev), CHAN_STATIC, "weapons/bgrapple_cough.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM );
iAnim = BGRAPPLE_COUGH; iAnim = BGRAPPLE_COUGH;
m_flTimeWeaponIdle = gpGlobals->time + 4.6; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 4.6;
} }
else else
{ {
iAnim = BGRAPPLE_BREATHE; iAnim = BGRAPPLE_BREATHE;
m_flTimeWeaponIdle = gpGlobals->time + 2.566; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.566;
} }
SendWeaponAnim( iAnim ); SendWeaponAnim( iAnim );
@ -168,7 +165,7 @@ void CBarnacleGrapple::PrimaryAttack( void )
{ {
if( m_bMissed ) if( m_bMissed )
{ {
m_flTimeWeaponIdle = gpGlobals->time + 0.1; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.1;
return; return;
} }
@ -300,7 +297,7 @@ void CBarnacleGrapple::PrimaryAttack( void )
m_pPlayer->m_iWeaponVolume = 450; m_pPlayer->m_iWeaponVolume = 450;
m_flTimeWeaponIdle = gpGlobals->time + 0.1; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.1;
#ifndef CLIENT_DLL #ifndef CLIENT_DLL
if( g_pGameRules->IsMultiplayer() ) if( g_pGameRules->IsMultiplayer() )
{ {
@ -317,7 +314,7 @@ void CBarnacleGrapple::PrimaryAttack( void )
if( !m_pTip ) if( !m_pTip )
{ {
m_flNextPrimaryAttack = gpGlobals->time + 0.01; m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.01;
return; return;
} }
@ -425,7 +422,7 @@ void CBarnacleGrapple::PrimaryAttack( void )
else else
*/ */
{ {
m_flNextPrimaryAttack = gpGlobals->time + 0.01; m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.01;
} }
} }
@ -466,9 +463,9 @@ void CBarnacleGrapple::EndAttack( void )
EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/bgrapple_pull.wav", 0.0, ATTN_NONE, SND_STOP, 100 ); EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/bgrapple_pull.wav", 0.0, ATTN_NONE, SND_STOP, 100 );
m_flTimeWeaponIdle = gpGlobals->time + 0.9; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.9;
m_flNextPrimaryAttack = gpGlobals->time + 0.01; m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.01;
DestroyEffect(); DestroyEffect();

6
dlls/weapons.h

@ -1182,11 +1182,13 @@ public:
void DestroyEffect( void ); void DestroyEffect( void );
virtual BOOL UseDecrement(void) virtual BOOL UseDecrement(void)
{ {
#if defined( CLIENT_WEAPONS )
return TRUE;
#else
return FALSE; return FALSE;
#endif
} }
const char* MyWModel() { return "models/w_bgrap.mdl"; }
private: private:
CBarnacleGrappleTip* m_pTip; CBarnacleGrappleTip* m_pTip;

Loading…
Cancel
Save