mirror of
https://github.com/YGGverse/hlsdk-portable.git
synced 2025-03-13 05:51:19 +00:00
Add bullets spread such as in original "Escape from the Darkness".
This commit is contained in:
parent
9fba28f6e7
commit
4807bfdd91
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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 )
|
||||
|
||||
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 )
|
||||
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 )
|
||||
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 )
|
||||
|
||||
Vector vecSrc = m_pPlayer->GetGunPosition();
|
||||
Vector vecAiming;
|
||||
Vector vecSpread;
|
||||
|
||||
if( 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 )
|
||||
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 )
|
||||
|
||||
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;
|
||||
|
||||
|
@ -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
|
||||
|
@ -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…
x
Reference in New Issue
Block a user