Other solution for weapon animation.

This commit is contained in:
Night Owl 2017-02-13 00:12:28 +05:00
parent d2257de3bf
commit 56b2a6bc4c
4 changed files with 49 additions and 51 deletions

View File

@ -102,7 +102,7 @@ void CBradnailer::Holster(int skiplocal /*= 0*/)
{ {
m_fInReload = FALSE;// cancel any reload in progress. m_fInReload = FALSE;// cancel any reload in progress.
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; m_pPlayer->m_flNextAttack = gpGlobals->time + 0.5;
SendWeaponAnim(BRADNAILER_HOLSTER); SendWeaponAnim(BRADNAILER_HOLSTER);
m_fInAttack = 0; m_fInAttack = 0;
@ -117,7 +117,7 @@ void CBradnailer::SecondaryAttack(void)
return; return;
} }
if (m_flNextSecondaryAttack > UTIL_WeaponTimeBase()) if (m_flNextSecondaryAttack > gpGlobals->time)
return; return;
if (m_fInAttack == 0) if (m_fInAttack == 0)
@ -130,14 +130,14 @@ void CBradnailer::SecondaryAttack(void)
m_fInAttack = 1; m_fInAttack = 1;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.7; m_flTimeWeaponIdle = gpGlobals->time + 0.7;
m_flNextSecondaryAttack = GetNextAttackDelay(0.7); m_flNextSecondaryAttack = gpGlobals->time + 0.7;
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 2.0; m_flNextPrimaryAttack = gpGlobals->time + 2.0;
return; return;
} }
else if (m_fInAttack == 1) else if (m_fInAttack == 1)
{ {
if (m_flTimeWeaponIdle < UTIL_WeaponTimeBase()) if (m_flTimeWeaponIdle < gpGlobals->time)
{ {
#ifndef CLIENT_DLL #ifndef CLIENT_DLL
//ALERT(at_console, "Fire\n"); //ALERT(at_console, "Fire\n");
@ -146,8 +146,8 @@ void CBradnailer::SecondaryAttack(void)
m_fInAttack = 1; m_fInAttack = 1;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.2f; m_flTimeWeaponIdle = gpGlobals->time + 0.2f;
m_flNextPrimaryAttack = GetNextAttackDelay(0.5); m_flNextPrimaryAttack = gpGlobals->time + 0.5;
} }
} }
} }
@ -156,7 +156,7 @@ void CBradnailer::PrimaryAttack(void)
{ {
if (m_fInAttack != 0) if (m_fInAttack != 0)
{ {
m_flNextPrimaryAttack = GetNextAttackDelay(0.5); m_flNextPrimaryAttack = gpGlobals->time + 0.5;
return; return;
} }
@ -169,9 +169,9 @@ void CBradnailer::PrimaryAttack(void)
Fire(0.01f, 0.3f, TRUE, FALSE); Fire(0.01f, 0.3f, TRUE, FALSE);
m_flNextPrimaryAttack = m_flNextSecondaryAttack = GetNextAttackDelay(0.3f); m_flNextPrimaryAttack = m_flNextSecondaryAttack = gpGlobals->time + 0.3f;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat(m_pPlayer->random_seed, 10, 15); m_flTimeWeaponIdle = gpGlobals->time + UTIL_SharedRandomFloat(m_pPlayer->random_seed, 10, 15);
} }
void CBradnailer::Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim, BOOL fFastShoot) void CBradnailer::Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim, BOOL fFastShoot)
@ -182,11 +182,11 @@ void CBradnailer::Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim, BOOL
int flags; int flags;
#if defined( CLIENT_WEAPONS ) //#if defined( CLIENT_WEAPONS )
flags = FEV_NOTHOST; // flags = FEV_NOTHOST;
#else //#else
flags = 0; flags = 0;
#endif //#endif
// player "shoot" animation // player "shoot" animation
m_pPlayer->SetAnimation(PLAYER_ATTACK1); m_pPlayer->SetAnimation(PLAYER_ATTACK1);
@ -253,7 +253,7 @@ void CBradnailer::Reload(void)
if (m_fInAttack != 0) if (m_fInAttack != 0)
return; return;
if (m_flNextPrimaryAttack > UTIL_WeaponTimeBase()) if (m_flNextPrimaryAttack > gpGlobals->time)
return; return;
if (m_pPlayer->ammo_nails <= 0) if (m_pPlayer->ammo_nails <= 0)
@ -282,7 +282,7 @@ void CBradnailer::WeaponIdle(void)
m_pPlayer->GetAutoaimVector(AUTOAIM_10DEGREES); m_pPlayer->GetAutoaimVector(AUTOAIM_10DEGREES);
if (m_flTimeWeaponIdle > UTIL_WeaponTimeBase()) if (m_flTimeWeaponIdle > gpGlobals->time)
return; return;
if (m_fInAttack != 0) if (m_fInAttack != 0)
@ -294,8 +294,8 @@ void CBradnailer::WeaponIdle(void)
SendWeaponAnim(BRADNAILER_TILT_TO_UPRIGHT, UseDecrement()); SendWeaponAnim(BRADNAILER_TILT_TO_UPRIGHT, UseDecrement());
m_fInAttack = 0; m_fInAttack = 0;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5f; m_flTimeWeaponIdle = gpGlobals->time + 0.5f;
m_flNextPrimaryAttack = m_flNextSecondaryAttack = GetNextAttackDelay(0.5f); m_flNextPrimaryAttack = m_flNextSecondaryAttack = gpGlobals->time + 0.5f;
} }
else else
{ {
@ -308,17 +308,17 @@ void CBradnailer::WeaponIdle(void)
if (flRand <= 0.3 + 0 * 0.75) if (flRand <= 0.3 + 0 * 0.75)
{ {
iAnim = BRADNAILER_IDLE3; iAnim = BRADNAILER_IDLE3;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 49.0 / 16; m_flTimeWeaponIdle = gpGlobals->time + 49.0 / 16;
} }
else if (flRand <= 0.6 + 0 * 0.875) else if (flRand <= 0.6 + 0 * 0.875)
{ {
iAnim = BRADNAILER_IDLE1; iAnim = BRADNAILER_IDLE1;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 60.0 / 16.0; m_flTimeWeaponIdle = gpGlobals->time + 60.0 / 16.0;
} }
else else
{ {
iAnim = BRADNAILER_IDLE2; iAnim = BRADNAILER_IDLE2;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 40.0 / 16.0; m_flTimeWeaponIdle = gpGlobals->time + 40.0 / 16.0;
} }
SendWeaponAnim(iAnim, 1); SendWeaponAnim(iAnim, 1);
} }

View File

@ -168,7 +168,7 @@ void CXenSquasher::PrimaryAttack()
StartFire(); StartFire();
m_fInAttack = 0; m_fInAttack = 0;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0; m_flTimeWeaponIdle = gpGlobals->time + 1.0;
// m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.2; // m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.2;
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.45; m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.45;
} }
@ -205,24 +205,24 @@ void CXenSquasher::SecondaryAttack()
m_fPrimaryFire = FALSE; m_fPrimaryFire = FALSE;
m_iClip--;// take one ammo just to start the spin m_iClip--;// take one ammo just to start the spin
m_pPlayer->m_flNextAmmoBurn = UTIL_WeaponTimeBase(); m_pPlayer->m_flNextAmmoBurn = gpGlobals->time;
// spin up // spin up
m_pPlayer->m_iWeaponVolume = XS_PRIMARY_CHARGE_VOLUME; m_pPlayer->m_iWeaponVolume = XS_PRIMARY_CHARGE_VOLUME;
SendWeaponAnim(XS_SPINUP); SendWeaponAnim(XS_SPINUP);
m_fInAttack = 1; m_fInAttack = 1;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5; m_flTimeWeaponIdle = gpGlobals->time + 0.5;
m_pPlayer->m_flStartCharge = gpGlobals->time; m_pPlayer->m_flStartCharge = gpGlobals->time;
m_pPlayer->m_flAmmoStartCharge = UTIL_WeaponTimeBase() + GetFullChargeTime(); m_pPlayer->m_flAmmoStartCharge = gpGlobals->time + GetFullChargeTime();
PLAYBACK_EVENT_FULL(FEV_NOTHOST, m_pPlayer->edict(), m_usXSSpin, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, 110, 0, 0, 0); PLAYBACK_EVENT_FULL(0, m_pPlayer->edict(), m_usXSSpin, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, 110, 0, 0, 0);
m_iSoundState = SND_CHANGE_PITCH; m_iSoundState = SND_CHANGE_PITCH;
} }
else if (m_fInAttack == 1) else if (m_fInAttack == 1)
{ {
if (m_flTimeWeaponIdle < UTIL_WeaponTimeBase()) if (m_flTimeWeaponIdle < gpGlobals->time)
{ {
SendWeaponAnim(XS_SPIN); SendWeaponAnim(XS_SPIN);
m_fInAttack = 2; m_fInAttack = 2;
@ -231,10 +231,10 @@ void CXenSquasher::SecondaryAttack()
else else
{ {
// during the charging process, eat one bit of ammo every once in a while // during the charging process, eat one bit of ammo every once in a while
if (UTIL_WeaponTimeBase() >= m_pPlayer->m_flNextAmmoBurn && m_pPlayer->m_flNextAmmoBurn != 1000) if (gpGlobals->time >= m_pPlayer->m_flNextAmmoBurn && m_pPlayer->m_flNextAmmoBurn != 1000)
{ {
m_iClip--; m_iClip--;
m_pPlayer->m_flNextAmmoBurn = UTIL_WeaponTimeBase() + 0.3; m_pPlayer->m_flNextAmmoBurn = gpGlobals->time + 0.3;
} }
if (m_iClip <= 0) if (m_iClip <= 0)
@ -242,12 +242,12 @@ void CXenSquasher::SecondaryAttack()
// out of ammo! force the gun to fire // out of ammo! force the gun to fire
StartFire(); StartFire();
m_fInAttack = 0; m_fInAttack = 0;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0; m_flTimeWeaponIdle = gpGlobals->time + 1.0;
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1; m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1;
return; return;
} }
if (UTIL_WeaponTimeBase() >= m_pPlayer->m_flAmmoStartCharge) if (gpGlobals->time >= m_pPlayer->m_flAmmoStartCharge)
{ {
// don't eat any more ammo after gun is fully charged. // don't eat any more ammo after gun is fully charged.
m_pPlayer->m_flNextAmmoBurn = 1000; m_pPlayer->m_flNextAmmoBurn = 1000;
@ -262,7 +262,7 @@ void CXenSquasher::SecondaryAttack()
if (m_iSoundState == 0) if (m_iSoundState == 0)
ALERT(at_console, "sound state %d\n", m_iSoundState); ALERT(at_console, "sound state %d\n", m_iSoundState);
PLAYBACK_EVENT_FULL(FEV_NOTHOST, m_pPlayer->edict(), m_usXSSpin, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, pitch, 0, (m_iSoundState == SND_CHANGE_PITCH) ? 1 : 0, 0); PLAYBACK_EVENT_FULL(0, m_pPlayer->edict(), m_usXSSpin, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, pitch, 0, (m_iSoundState == SND_CHANGE_PITCH) ? 1 : 0, 0);
m_iSoundState = SND_CHANGE_PITCH; // hack for going through level transitions m_iSoundState = SND_CHANGE_PITCH; // hack for going through level transitions
@ -276,7 +276,7 @@ void CXenSquasher::SecondaryAttack()
EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/xs_moan3.wav", 1.0, ATTN_NORM, 0, 75 + RANDOM_LONG(0, 0x3f)); EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/xs_moan3.wav", 1.0, ATTN_NORM, 0, 75 + RANDOM_LONG(0, 0x3f));
m_fInAttack = 0; m_fInAttack = 0;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0; m_flTimeWeaponIdle = gpGlobals->time + 1.0;
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1.0; m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1.0;
#ifndef CLIENT_DLL #ifndef CLIENT_DLL
@ -376,13 +376,13 @@ void CXenSquasher::Fire(Vector vecOrigSrc, Vector vecDir, float flDamage)
// The main firing event is sent unreliably so it won't be delayed. // The main firing event is sent unreliably so it won't be delayed.
PLAYBACK_EVENT_FULL(FEV_NOTHOST, m_pPlayer->edict(), m_usXSFire, 0.0, (float *)&m_pPlayer->pev->origin, (float *)&m_pPlayer->pev->angles, flDamage, 0.0, 0, 0, m_fPrimaryFire ? 1 : 0, 0); PLAYBACK_EVENT_FULL(0, m_pPlayer->edict(), m_usXSFire, 0.0, (float *)&m_pPlayer->pev->origin, (float *)&m_pPlayer->pev->angles, flDamage, 0.0, 0, 0, m_fPrimaryFire ? 1 : 0, 0);
// This reliable event is used to stop the spinning sound // This reliable event is used to stop the spinning sound
// It's delayed by a fraction of second to make sure it is delayed by 1 frame on the client // It's delayed by a fraction of second to make sure it is delayed by 1 frame on the client
// It's sent reliably anyway, which could lead to other delays // It's sent reliably anyway, which could lead to other delays
PLAYBACK_EVENT_FULL(FEV_NOTHOST | FEV_RELIABLE, m_pPlayer->edict(), m_usXSFire, 0.01, (float *)&m_pPlayer->pev->origin, (float *)&m_pPlayer->pev->angles, 0.0, 0.0, 0, 0, 0, 1); PLAYBACK_EVENT_FULL(0 | FEV_RELIABLE, m_pPlayer->edict(), m_usXSFire, 0.01, (float *)&m_pPlayer->pev->origin, (float *)&m_pPlayer->pev->angles, 0.0, 0.0, 0, 0, 0, 1);
/*ALERT( at_console, "%f %f %f\n%f %f %f\n", /*ALERT( at_console, "%f %f %f\n%f %f %f\n",
@ -463,14 +463,14 @@ void CXenSquasher::WeaponIdle(void)
m_pPlayer->m_flPlayAftershock = 0.0; m_pPlayer->m_flPlayAftershock = 0.0;
} }
if (m_flTimeWeaponIdle > UTIL_WeaponTimeBase()) if (m_flTimeWeaponIdle > gpGlobals->time)
return; return;
if (m_fInAttack != 0) if (m_fInAttack != 0)
{ {
StartFire(); StartFire();
m_fInAttack = 0; m_fInAttack = 0;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.0; m_flTimeWeaponIdle = gpGlobals->time + 2.0;
} }
else else
{ {
@ -479,17 +479,17 @@ void CXenSquasher::WeaponIdle(void)
if (flRand <= 0.5) if (flRand <= 0.5)
{ {
iAnim = XS_IDLE; iAnim = XS_IDLE;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + (63.0f / 15.0f); m_flTimeWeaponIdle = gpGlobals->time + (63.0f / 15.0f);
} }
else if (flRand <= 0.75) else if (flRand <= 0.75)
{ {
iAnim = XS_IDLE2; iAnim = XS_IDLE2;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + (63.0f / 15.0f); m_flTimeWeaponIdle = gpGlobals->time + (63.0f / 15.0f);
} }
else else
{ {
iAnim = XS_FIDGET; iAnim = XS_FIDGET;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + (93.0f / 30.0f); m_flTimeWeaponIdle = gpGlobals->time + (93.0f / 30.0f);
} }
//return; //return;

View File

@ -1000,11 +1000,11 @@ public:
virtual BOOL UseDecrement( void ) virtual BOOL UseDecrement( void )
{ {
#if defined( CLIENT_WEAPONS ) //#if defined( CLIENT_WEAPONS )
return TRUE; // return TRUE;
#else //#else
return FALSE; return FALSE;
#endif //#endif
} }
void Fire( float flSpread, float flCycleTime, BOOL fUseAutoAim, BOOL fFastShoot ); void Fire( float flSpread, float flCycleTime, BOOL fUseAutoAim, BOOL fFastShoot );
@ -1135,11 +1135,11 @@ public:
virtual BOOL UseDecrement( void ) virtual BOOL UseDecrement( void )
{ {
#if defined( CLIENT_WEAPONS ) //#if defined( CLIENT_WEAPONS )
return TRUE; // return TRUE;
#else //#else
return FALSE; return FALSE;
#endif //#endif
} }
private: private:

View File

@ -654,8 +654,6 @@ void CWorld::Precache( void )
CVAR_SET_FLOAT( "mp_defaultteam", 0 ); CVAR_SET_FLOAT( "mp_defaultteam", 0 );
} }
CVAR_SET_FLOAT( "cl_lw", 0 ); //Temporary solution for weapon animation.
// g-cont. moved here so cheats will working on restore level // g-cont. moved here so cheats will working on restore level
g_flWeaponCheat = CVAR_GET_FLOAT( "sv_cheats" ); // Is the impulse 101 command allowed? g_flWeaponCheat = CVAR_GET_FLOAT( "sv_cheats" ); // Is the impulse 101 command allowed?
} }