Add crowbar idle animations under CROWBAR_IDLE_ANIM macro.

This commit is contained in:
Night Owl 2017-10-15 14:22:14 +05:00
parent f78471ad1d
commit 8e799fcf6d
3 changed files with 51 additions and 1 deletions

View File

@ -1138,7 +1138,13 @@ enum crowbar_e
CROWBAR_ATTACK2MISS,
CROWBAR_ATTACK2HIT,
CROWBAR_ATTACK3MISS,
#ifndef CROWBAR_IDLE_ANIM
CROWBAR_ATTACK3HIT
#else
CROWBAR_ATTACK3HIT,
CROWBAR_IDLE2,
CROWBAR_IDLE3
#endif
};
int g_iSwing;

View File

@ -37,7 +37,13 @@ enum crowbar_e
CROWBAR_ATTACK2MISS,
CROWBAR_ATTACK2HIT,
CROWBAR_ATTACK3MISS,
#ifndef CROWBAR_IDLE_ANIM
CROWBAR_ATTACK3HIT
#else
CROWBAR_ATTACK3HIT,
CROWBAR_IDLE2,
CROWBAR_IDLE3
#endif
};
void CCrowbar::Spawn()
@ -208,7 +214,9 @@ int CCrowbar::Swing( int fFirst )
{
// miss
m_flNextPrimaryAttack = GetNextAttackDelay( 0.5 );
#ifdef CROWBAR_IDLE_ANIM
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 );
#endif
// player "shoot" animation
m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
}
@ -324,5 +332,38 @@ int CCrowbar::Swing( int fFirst )
#endif
m_flNextPrimaryAttack = GetNextAttackDelay( 0.25 );
}
#ifdef CROWBAR_IDLE_ANIM
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 );
#endif
return fDidHit;
}
#ifdef CROWBAR_IDLE_ANIM
void CCrowbar::WeaponIdle( void )
{
if( m_flTimeWeaponIdle < UTIL_WeaponTimeBase() )
{
int iAnim;
float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0, 1 );
if( flRand > 0.9 )
{
iAnim = CROWBAR_IDLE2;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 160.0 / 30.0;
}
else
{
if( flRand > 0.5 )
{
iAnim = CROWBAR_IDLE;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 70.0 / 30.0;
}
else
{
iAnim = CROWBAR_IDLE3;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 160.0 / 30.0;
}
}
SendWeaponAnim( iAnim );
}
}
#endif

View File

@ -504,6 +504,9 @@ public:
int Swing( int fFirst );
BOOL Deploy( void );
void Holster( int skiplocal = 0 );
#ifdef CROWBAR_IDLE_ANIM
void WeaponIdle();
#endif
int m_iSwing;
TraceResult m_trHit;