From ef6099ceed2b75597deba1e088212f70168919e0 Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Wed, 28 Mar 2018 17:56:11 +0300 Subject: [PATCH] Fix deagle spread. Don't use m_pEagleLaser in conditions shared between client and server (#18) --- cl_dll/hl/hl_weapons.cpp | 8 ++++++++ dlls/client.cpp | 4 ++++ dlls/gearbox/eagle.cpp | 22 +++++++++------------- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/cl_dll/hl/hl_weapons.cpp b/cl_dll/hl/hl_weapons.cpp index 5e5928a0..270ed8d8 100644 --- a/cl_dll/hl/hl_weapons.cpp +++ b/cl_dll/hl/hl_weapons.cpp @@ -880,6 +880,10 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm ( (CRpg *)player.m_pActiveItem )->m_fSpotActive = (int)from->client.vuser2[1]; ( (CRpg *)player.m_pActiveItem )->m_cActiveRockets = (int)from->client.vuser2[2]; } + else if (player.m_pActiveItem->m_iId == WEAPON_EAGLE) + { + ( (CEagle *)player.m_pActiveItem )->m_fEagleLaserActive = (int)from->client.vuser2[1]; + } else if( player.m_pActiveItem->m_iId == WEAPON_M249 ) { player.ammo_556 = (int)from->client.vuser2[1]; @@ -964,6 +968,10 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm from->client.vuser2[1] = ( (CRpg *)player.m_pActiveItem)->m_fSpotActive; from->client.vuser2[2] = ( (CRpg *)player.m_pActiveItem)->m_cActiveRockets; } + else if ( player.m_pActiveItem->m_iId == WEAPON_EAGLE ) + { + from->client.vuser2[1] = ( (CEagle *)player.m_pActiveItem )->m_fEagleLaserActive;; + } else if( player.m_pActiveItem->m_iId == WEAPON_M249 ) { from->client.vuser2[1] = player.ammo_556; diff --git a/dlls/client.cpp b/dlls/client.cpp index fb4c7ead..bf7a2a81 100644 --- a/dlls/client.cpp +++ b/dlls/client.cpp @@ -1814,6 +1814,10 @@ void UpdateClientData( const struct edict_s *ent, int sendweapons, struct client cd->vuser2.y = ( (CRpg *)pl->m_pActiveItem )->m_fSpotActive; cd->vuser2.z = ( (CRpg *)pl->m_pActiveItem )->m_cActiveRockets; } + else if( pl->m_pActiveItem->m_iId == WEAPON_EAGLE ) + { + cd->vuser2.y = ( (CEagle *)pl->m_pActiveItem )->m_fEagleLaserActive; + } else if( pl->m_pActiveItem->m_iId == WEAPON_M249 ) { cd->vuser2.y = pl->ammo_556; diff --git a/dlls/gearbox/eagle.cpp b/dlls/gearbox/eagle.cpp index 510ab48b..723758f2 100644 --- a/dlls/gearbox/eagle.cpp +++ b/dlls/gearbox/eagle.cpp @@ -100,22 +100,18 @@ void CEagle::Holster( int skiplocal /* = 0 */ ) void CEagle::SecondaryAttack() { - if ((m_pEagleLaser && m_fEagleLaserActive) // don't turn off if it was not created yet - || !m_fEagleLaserActive) + bool wasActive = m_fEagleLaserActive; + m_fEagleLaserActive = !m_fEagleLaserActive; + if (wasActive) { - m_fEagleLaserActive = !m_fEagleLaserActive; - if (!m_fEagleLaserActive && m_pEagleLaser) + if (m_pEagleLaser) { EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/desert_eagle_sight2.wav", 1.0, ATTN_NORM, 0, PITCH_NORM); m_pEagleLaser->Killed( NULL, GIB_NORMAL ); m_pEagleLaser = NULL; } - m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5; - } - else - { - m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.1; } + m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5; } void CEagle::PrimaryAttack() @@ -141,7 +137,7 @@ void CEagle::PrimaryAttack() UpdateSpot( ); - float flSpread = 0.01; + float flSpread = 0.001; m_iClip--; @@ -166,7 +162,7 @@ void CEagle::PrimaryAttack() vecAiming = gpGlobals->v_forward; Vector vecDir; - if (m_pEagleLaser) + if (m_fEagleLaserActive) { vecDir = m_pPlayer->FireBulletsPlayer( 1, vecSrc, vecAiming, Vector( flSpread, flSpread, flSpread ), 8192, BULLET_PLAYER_357, 0, 0, m_pPlayer->pev, m_pPlayer->random_seed ); m_flNextPrimaryAttack = UTIL_WeaponTimeBase()+ 0.5; @@ -178,7 +174,7 @@ void CEagle::PrimaryAttack() else { flSpread = 0.1; - vecDir = m_pPlayer->FireBulletsPlayer( 1, vecSrc, vecAiming, VECTOR_CONE_10DEGREES, 8192, BULLET_PLAYER_357, 0, 0, m_pPlayer->pev, m_pPlayer->random_seed ); + vecDir = m_pPlayer->FireBulletsPlayer( 1, vecSrc, vecAiming, Vector(flSpread, flSpread, flSpread), 8192, BULLET_PLAYER_357, 0, 0, m_pPlayer->pev, m_pPlayer->random_seed ); m_flNextPrimaryAttack = UTIL_WeaponTimeBase()+ 0.22; m_fLaserOn = FALSE; } @@ -260,7 +256,7 @@ void CEagle::WeaponIdle( void ) int iAnim; float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0.0, 1.0 ); - if (m_pEagleLaser) + if (m_fEagleLaserActive) { if (flRand > 0.5 ) {