Browse Source

Add bullets spread such as in original "Escape from the Darkness".

eftd
Night Owl 7 years ago
parent
commit
4807bfdd91
  1. 19
      dlls/eftd/ak47.cpp
  2. 16
      dlls/eftd/mac10.cpp
  3. 55
      dlls/glock.cpp
  4. 34
      dlls/player.cpp
  5. 3
      dlls/player.h

19
dlls/eftd/ak47.cpp

@ -141,13 +141,26 @@ void CAK47::PrimaryAttack() @@ -141,13 +141,26 @@ void CAK47::PrimaryAttack()
Vector vecSpread;
// Allow for higher accuracy when the player is crouching.
if (m_pPlayer->pev->flags & FL_DUCKING)
if( m_pPlayer->pev->flags & FL_DUCKING )
{
vecSpread = VECTOR_CONE_2DEGREES;
vecSpread = Vector( m_pPlayer->m_flBulletSpreadCoefficient * 1.6 + 0.01, m_pPlayer->m_flBulletSpreadCoefficient * 1.4 + 0.01, 0 );
if( m_pPlayer->m_flBulletSpreadCoefficient < 0.045 )
m_pPlayer->m_flBulletSpreadCoefficient += 0.006;
}
else
{
vecSpread = VECTOR_CONE_5DEGREES;
if( m_pPlayer->pev->button & IN_JUMP )
{
vecSpread = Vector( m_pPlayer->m_flBulletSpreadCoefficient * 2.4 + 0.065, m_pPlayer->m_flBulletSpreadCoefficient * 2.1 + 0.05, 0 );
if( m_pPlayer->m_flBulletSpreadCoefficient < 0.08 )
m_pPlayer->m_flBulletSpreadCoefficient += 0.009;
}
else
{
vecSpread = Vector( m_pPlayer->m_flBulletSpreadCoefficient * 8.0 + 0.3, m_pPlayer->m_flBulletSpreadCoefficient * 6.0 + 0.2, 0 );
if( m_pPlayer->m_flBulletSpreadCoefficient < 0.1 )
m_pPlayer->m_flBulletSpreadCoefficient += 0.012;
}
}
// single player spread

16
dlls/eftd/mac10.cpp

@ -140,15 +140,13 @@ void CMac10::PrimaryAttack() @@ -140,15 +140,13 @@ void CMac10::PrimaryAttack()
Vector vecDir;
Vector vecSpread;
// Allow for higher accuracy when the player is crouching.
if (m_pPlayer->pev->flags & FL_DUCKING)
{
vecSpread = VECTOR_CONE_1DEGREES;
}
else
{
vecSpread = VECTOR_CONE_4DEGREES;
}
vecSpread = Vector( m_pPlayer->m_flBulletSpreadCoefficient * 1.2 + 0.03, m_pPlayer->m_flBulletSpreadCoefficient * 0.9 + 0.02, 0 );
if( m_pPlayer->m_flBulletSpreadCoefficient < 0.06 )
m_pPlayer->m_flBulletSpreadCoefficient += 0.0027;
if( m_pPlayer->m_flBulletSpreadCoefficient < 0.1 )
m_pPlayer->m_flBulletSpreadCoefficient += 0.002;
// single player spread
vecDir = m_pPlayer->FireBulletsPlayer(1, vecSrc, vecAiming, vecSpread, 8192, BULLET_PLAYER_MAC10, 2, 0, m_pPlayer->pev, m_pPlayer->random_seed);

55
dlls/glock.cpp

@ -109,8 +109,6 @@ void CGlock::Holster(int skiplocal /*= 0*/) @@ -109,8 +109,6 @@ void CGlock::Holster(int skiplocal /*= 0*/)
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5;
SendWeaponAnim( GLOCK_HOLSTER );
m_fInAttack = 0;
}
void CGlock::SecondaryAttack( void )
@ -119,17 +117,7 @@ void CGlock::SecondaryAttack( void ) @@ -119,17 +117,7 @@ void CGlock::SecondaryAttack( void )
void CGlock::PrimaryAttack( void )
{
float flSpread;
// Allow for higher accuracy when the player is crouching.
if( m_pPlayer->pev->flags & FL_DUCKING )
{
flSpread = 0.00873;
}
else
{
flSpread = 0.03490;
}
float flSpread = 0;
GlockFire( flSpread, 0.18, TRUE );
}
@ -137,7 +125,7 @@ void CGlock::PrimaryAttack( void ) @@ -137,7 +125,7 @@ void CGlock::PrimaryAttack( void )
void CGlock::GlockFire( float flSpread, float flCycleTime, BOOL fUseAutoAim )
{
// Do not allow attack unless primary attack key was released.
if( m_fInAttack )
if( FBitSet ( m_pPlayer->m_afButtonLast, IN_ATTACK ) )
return;
if( m_iClip <= 0 )
@ -153,9 +141,6 @@ void CGlock::GlockFire( float flSpread, float flCycleTime, BOOL fUseAutoAim ) @@ -153,9 +141,6 @@ void CGlock::GlockFire( float flSpread, float flCycleTime, BOOL fUseAutoAim )
return;
}
// Prevent from continuously refire.
m_fInAttack = 1;
m_iClip--;
m_pPlayer->pev->effects = (int)( m_pPlayer->pev->effects ) | EF_MUZZLEFLASH;
@ -184,6 +169,7 @@ void CGlock::GlockFire( float flSpread, float flCycleTime, BOOL fUseAutoAim ) @@ -184,6 +169,7 @@ void CGlock::GlockFire( float flSpread, float flCycleTime, BOOL fUseAutoAim )
Vector vecSrc = m_pPlayer->GetGunPosition();
Vector vecAiming;
Vector vecSpread;
if( fUseAutoAim )
{
@ -194,8 +180,30 @@ void CGlock::GlockFire( float flSpread, float flCycleTime, BOOL fUseAutoAim ) @@ -194,8 +180,30 @@ void CGlock::GlockFire( float flSpread, float flCycleTime, BOOL fUseAutoAim )
vecAiming = gpGlobals->v_forward;
}
Vector vecDir;
vecDir = m_pPlayer->FireBulletsPlayer( 1, vecSrc, vecAiming, Vector( flSpread, flSpread, flSpread ), 8192, BULLET_PLAYER_9MM, 0, 0, m_pPlayer->pev, m_pPlayer->random_seed );
// Allow for higher accuracy when the player is crouching.
if( m_pPlayer->pev->flags & FL_DUCKING )
{
vecSpread = Vector( m_pPlayer->m_flBulletSpreadCoefficient * 2.3 + 0.012, m_pPlayer->m_flBulletSpreadCoefficient * 1.5 + 0.01, 0 );
if( m_pPlayer->m_flBulletSpreadCoefficient < 0.05 )
m_pPlayer->m_flBulletSpreadCoefficient += 0.003;
}
else
{
if( m_pPlayer->pev->button & IN_JUMP )
{
vecSpread = Vector( m_pPlayer->m_flBulletSpreadCoefficient * 3.0 + 0.065, m_pPlayer->m_flBulletSpreadCoefficient * 2.0 + 0.055, 0 );
if( m_pPlayer->m_flBulletSpreadCoefficient < 0.06 )
m_pPlayer->m_flBulletSpreadCoefficient += 0.0045;
}
else
{
vecSpread = Vector( m_pPlayer->m_flBulletSpreadCoefficient * 8.0 + 0.1, m_pPlayer->m_flBulletSpreadCoefficient * 5.0 + 0.1, 0 );
if( m_pPlayer->m_flBulletSpreadCoefficient < 0.8 )
m_pPlayer->m_flBulletSpreadCoefficient += 0.009;
}
}
Vector vecDir = m_pPlayer->FireBulletsPlayer( 1, vecSrc, vecAiming, vecSpread, 8192, BULLET_PLAYER_9MM, 0, 0, m_pPlayer->pev, m_pPlayer->random_seed );
PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), fUseAutoAim ? m_usFireGlock1 : m_usFireGlock2, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, vecDir.x, vecDir.y, 0, 0, ( m_iClip == 0 ) ? 1 : 0, 0 );
@ -223,9 +231,6 @@ void CGlock::Reload( void ) @@ -223,9 +231,6 @@ void CGlock::Reload( void )
if( iResult )
{
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 );
// Unblock primary attack.
m_fInAttack = 0;
}
}
@ -235,12 +240,6 @@ void CGlock::WeaponIdle( void ) @@ -235,12 +240,6 @@ void CGlock::WeaponIdle( void )
m_pPlayer->GetAutoaimVector( AUTOAIM_10DEGREES );
//
// Unblock primary attack.
// This will only occur if players released primary attack key.
//
m_fInAttack = 0;
if( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() )
return;

34
dlls/player.cpp

@ -2621,6 +2621,40 @@ pt_end: @@ -2621,6 +2621,40 @@ pt_end:
if( m_flAmmoStartCharge < -0.001 )
m_flAmmoStartCharge = -0.001;
}
if( pev->flags & FL_DUCKING )
{
if( gpGlobals->frametime > m_flNextBulletSpreadRandTime + 0.44 )
{
m_flNextBulletSpreadRandTime = gpGlobals->frametime;
m_flBulletSpreadCoefficient -= 0.0025;
if( !( m_afButtonPressed | m_afButtonReleased ) )
m_flBulletSpreadCoefficient -= 0.015;
}
}
else
{
if( pev->button & IN_JUMP )
{
if( gpGlobals->frametime > m_flNextBulletSpreadRandTime + 0.6 )
{
m_flNextBulletSpreadRandTime = gpGlobals->frametime;
m_flBulletSpreadCoefficient -= 0.0015;
if( !( m_afButtonPressed | m_afButtonReleased ) )
m_flBulletSpreadCoefficient -= 0.004;
}
}
else if( gpGlobals->frametime > m_flNextBulletSpreadRandTime + 0.47 )
{
m_flNextBulletSpreadRandTime = gpGlobals->frametime;
m_flBulletSpreadCoefficient -= 0.001;
if( !( m_afButtonPressed | m_afButtonReleased ) )
m_flBulletSpreadCoefficient -= 0.012;
}
}
if( m_flBulletSpreadCoefficient < 0.001 )
m_flBulletSpreadCoefficient = 0.001;
#else
return;
#endif

3
dlls/player.h

@ -325,6 +325,9 @@ public: @@ -325,6 +325,9 @@ public:
float m_flNextChatTime;
float m_flBulletSpreadCoefficient;
float m_flNextBulletSpreadRandTime;
bool m_bSentBhopcap; // If false, the player just joined and needs a bhopcap message.
};

Loading…
Cancel
Save