From 9fecfb50f352764f13266117b5882e2d33a996c8 Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Tue, 16 Mar 2021 18:53:50 +0300 Subject: [PATCH 1/9] Merge https://github.com/Solokiller/halflife-updated/commit/2ca64e11b05b1f3f62af9640636f891b7c38cc8c --- dlls/buttons.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/buttons.cpp b/dlls/buttons.cpp index 8344c814..87e08ce7 100644 --- a/dlls/buttons.cpp +++ b/dlls/buttons.cpp @@ -637,7 +637,7 @@ void DoSpark( entvars_t *pev, const Vector &location ) void CBaseButton::ButtonSpark( void ) { SetThink( &CBaseButton::ButtonSpark ); - pev->nextthink = gpGlobals->time + 0.1f + RANDOM_FLOAT( 0.0f, 1.5f );// spark again at random interval + pev->nextthink = pev->ltime + 0.1f + RANDOM_FLOAT( 0.0f, 1.5f );// spark again at random interval DoSpark( pev, pev->mins ); } From 397286021c1e1c6c67dca45f3420c0fb8c8d28fb Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Thu, 11 Feb 2021 02:34:07 +0300 Subject: [PATCH 2/9] Try fixing occasional bug with missing mp5 reload animation when holding primary attack after clip was depleted --- cl_dll/hl/hl_weapons.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cl_dll/hl/hl_weapons.cpp b/cl_dll/hl/hl_weapons.cpp index 754fd594..43485100 100644 --- a/cl_dll/hl/hl_weapons.cpp +++ b/cl_dll/hl/hl_weapons.cpp @@ -372,7 +372,7 @@ void CBasePlayerWeapon::ItemPostFrame( void ) m_fFireOnEmpty = FALSE; // weapon is useable. Reload if empty and weapon has waited as long as it has to after firing - if( m_iClip == 0 && !( iFlags() & ITEM_FLAG_NOAUTORELOAD ) && m_flNextPrimaryAttack < 0.0f ) + if( m_iClip == 0 && !( iFlags() & ITEM_FLAG_NOAUTORELOAD ) && m_flNextPrimaryAttack <= 0.0f ) { Reload(); return; From 464a678b3311b18d31c8d628ac53c930f819e46c Mon Sep 17 00:00:00 2001 From: Andrey Akhmichin Date: Sun, 6 Jun 2021 02:40:52 +0500 Subject: [PATCH 3/9] Remove WeaponTick and override ItemPostFrame instead. --- dlls/shotgun.cpp | 4 +++- dlls/weapons.cpp | 2 -- dlls/weapons.h | 3 +-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/dlls/shotgun.cpp b/dlls/shotgun.cpp index 90ec7e8c..9c84c5c2 100644 --- a/dlls/shotgun.cpp +++ b/dlls/shotgun.cpp @@ -302,7 +302,7 @@ void CShotgun::Reload( void ) } } -void CShotgun::WeaponTick() +void CShotgun::ItemPostFrame( void ) { if( m_flPumpTime && m_flPumpTime < gpGlobals->time ) { @@ -310,6 +310,8 @@ void CShotgun::WeaponTick() EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/scock1.wav", 1, ATTN_NORM, 0, 95 + RANDOM_LONG( 0, 0x1f ) ); m_flPumpTime = 0; } + + CBasePlayerWeapon::ItemPostFrame(); } void CShotgun::WeaponIdle( void ) diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index a69ba196..42e1f6ce 100644 --- a/dlls/weapons.cpp +++ b/dlls/weapons.cpp @@ -602,8 +602,6 @@ BOOL CanAttack( float attack_time, float curtime, BOOL isPredicted ) void CBasePlayerWeapon::ItemPostFrame( void ) { - WeaponTick(); - if( ( m_fInReload ) && ( m_pPlayer->m_flNextAttack <= UTIL_WeaponTimeBase() ) ) { // complete the reload. diff --git a/dlls/weapons.h b/dlls/weapons.h index 312f5531..d1051883 100644 --- a/dlls/weapons.h +++ b/dlls/weapons.h @@ -319,7 +319,6 @@ public: virtual void PrimaryAttack( void ) { return; } // do "+ATTACK" virtual void SecondaryAttack( void ) { return; } // do "+ATTACK2" virtual void Reload( void ) { return; } // do "+RELOAD" - virtual void WeaponTick() {} // Always called at beginning of ItemPostFrame. - Solokiller virtual void WeaponIdle( void ) { return; } // called when no buttons pressed virtual int UpdateClientData( CBasePlayer *pPlayer ); // sends hud info to client dll, if things have changed virtual void RetireWeapon( void ); @@ -639,8 +638,8 @@ public: void SecondaryAttack( void ); BOOL Deploy( ); void Reload( void ); - void WeaponTick(); void WeaponIdle( void ); + void ItemPostFrame( void ); int m_fInReload; float m_flNextReload; int m_iShell; From 593c9185aa2d43d56bacd67599a0843342bea02d Mon Sep 17 00:00:00 2001 From: Andrey Akhmichin Date: Sun, 6 Jun 2021 02:48:22 +0500 Subject: [PATCH 4/9] Do not override IsUseable for mp5. Merge https://github.com/Solokiller/halflife-updated/commit/a9b1d9cda8e063258fc9291ada671c09ef71472b. --- dlls/mp5.cpp | 6 ------ dlls/weapons.cpp | 32 +++++++++++++++++++++++++++----- dlls/weapons.h | 1 - 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/dlls/mp5.cpp b/dlls/mp5.cpp index fcfbd179..47d0a24d 100644 --- a/dlls/mp5.cpp +++ b/dlls/mp5.cpp @@ -270,12 +270,6 @@ void CMP5::WeaponIdle( void ) m_flTimeWeaponIdle = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); // how long till we do this again. } -BOOL CMP5::IsUseable() -{ - //Can be used if the player has AR grenades. - Solokiller - return CBasePlayerWeapon::IsUseable() || m_pPlayer->m_rgAmmo[m_iSecondaryAmmoType] > 0; -} - class CMP5AmmoClip : public CBasePlayerAmmo { void Spawn( void ) diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index 42e1f6ce..88c91a36 100644 --- a/dlls/weapons.cpp +++ b/dlls/weapons.cpp @@ -897,16 +897,38 @@ BOOL CBasePlayerWeapon::AddSecondaryAmmo( int iCount, char *szName, int iMax ) //========================================================= BOOL CBasePlayerWeapon::IsUseable( void ) { - if( m_iClip <= 0 ) + if( m_iClip > 0 ) { - if( m_pPlayer->m_rgAmmo[PrimaryAmmoIndex()] <= 0 && iMaxAmmo1() != -1 ) + return TRUE; + } + + // Player has unlimited ammo for this weapon or does not use magazines + if( iMaxAmmo1() == WEAPON_NOCLIP ) + { + return TRUE; + } + + if( m_pPlayer->m_rgAmmo[PrimaryAmmoIndex()] > 0 ) + { + return TRUE; + } + + if( pszAmmo2() ) + { + // Player has unlimited ammo for this weapon or does not use magazines + if( iMaxAmmo2() == WEAPON_NOCLIP ) { - // clip is empty (or nonexistant) and the player has no more ammo of this type. - return FALSE; + return TRUE; + } + + if( m_pPlayer->m_rgAmmo[SecondaryAmmoIndex()] > 0 ) + { + return TRUE; } } - return TRUE; + // clip is empty (or nonexistant) and the player has no more ammo of this type. + return FALSE; } BOOL CBasePlayerWeapon::CanDeploy( void ) diff --git a/dlls/weapons.h b/dlls/weapons.h index d1051883..a3870299 100644 --- a/dlls/weapons.h +++ b/dlls/weapons.h @@ -568,7 +568,6 @@ public: BOOL Deploy( void ); void Reload( void ); void WeaponIdle( void ); - BOOL IsUseable(); float m_flNextAnimTime; int m_iShell; From 2c9cb0c645b8e8b4014760063406e8c447929d91 Mon Sep 17 00:00:00 2001 From: Andrey Akhmichin Date: Sun, 6 Jun 2021 03:48:55 +0500 Subject: [PATCH 5/9] Revert "Merge https://github.com/SamVanheer/HLEnhanced/commit/33413807d0ca23f3d9121e45f5584cb5be98751b" This reverts commit 19bdc1d01b7287cd61b58fb7b7bdb6953caa50a8. --- dlls/gauss.cpp | 36 ++++++++++-------------------------- dlls/weapons.h | 2 +- 2 files changed, 11 insertions(+), 27 deletions(-) diff --git a/dlls/gauss.cpp b/dlls/gauss.cpp index 96345ad2..50707dfe 100644 --- a/dlls/gauss.cpp +++ b/dlls/gauss.cpp @@ -124,12 +124,6 @@ int CGauss::GetItemInfo( ItemInfo *p ) return 1; } -BOOL CGauss::IsUseable() -{ - // Currently charging, allow the player to fire it first. - Solokiller - return CBasePlayerWeapon::IsUseable() || m_fInAttack != 0; -} - BOOL CGauss::Deploy() { m_pPlayer->m_flPlayAftershock = 0.0; @@ -231,22 +225,6 @@ void CGauss::SecondaryAttack() } else { - // Moved to before the ammo burn. - // Because we drained 1 when m_InAttack == 0, then 1 again now before checking if we're out of ammo, - // this resuled in the player having -1 ammo, which in turn caused CanDeploy to think it could be deployed. - // This will need to be fixed further down the line by preventing negative ammo unless explicitly required (infinite ammo?), - // But this check will prevent the problem for now. - Solokiller - // TODO: investigate further. - if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 ) - { - // out of ammo! force the gun to fire - StartFire(); - m_fInAttack = 0; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0f; - m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1; - return; - } - // 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 ) { @@ -266,6 +244,16 @@ void CGauss::SecondaryAttack() } } + if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 ) + { + // out of ammo! force the gun to fire + StartFire(); + m_fInAttack = 0; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0; + m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1; + return; + } + if( UTIL_WeaponTimeBase() >= m_pPlayer->m_flAmmoStartCharge ) { // don't eat any more ammo after gun is fully charged. @@ -583,10 +571,6 @@ void CGauss::WeaponIdle( void ) StartFire(); m_fInAttack = 0; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.0f; - - // Need to set m_flNextPrimaryAttack so the weapon gets a chance to complete its secondary fire animation. - Solokiller - if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 ) - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.5f; } else { diff --git a/dlls/weapons.h b/dlls/weapons.h index a3870299..ad8f2fe4 100644 --- a/dlls/weapons.h +++ b/dlls/weapons.h @@ -745,7 +745,7 @@ public: int iItemSlot( void ) { return 4; } int GetItemInfo(ItemInfo *p); int AddToPlayer( CBasePlayer *pPlayer ); - BOOL IsUseable(); + BOOL Deploy( void ); void Holster( int skiplocal = 0 ); From 7a999bf987becaa268e50c6e40a609c949fff699 Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Wed, 2 Jun 2021 02:10:30 +0300 Subject: [PATCH 6/9] Check before SetEnemy in squad monster --- dlls/squadmonster.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dlls/squadmonster.cpp b/dlls/squadmonster.cpp index cbf3f19f..60479878 100644 --- a/dlls/squadmonster.cpp +++ b/dlls/squadmonster.cpp @@ -256,7 +256,10 @@ void CSquadMonster::SquadMakeEnemy( CBaseEntity *pEnemy ) if( pMember ) { // reset members who aren't activly engaged in fighting - if( pMember->m_hEnemy != pEnemy && !pMember->HasConditions( bits_COND_SEE_ENEMY ) ) + if( pMember->m_hEnemy != pEnemy && !pMember->HasConditions( bits_COND_SEE_ENEMY ) + && ( pMember->m_pSchedule && (pMember->m_pSchedule->iInterruptMask & bits_COND_NEW_ENEMY) ) + // My enemy might be not an enemy for member of my squad, e.g. if I was provoked by player. + && pMember->IRelationship(pEnemy) >= R_DL ) { if( pMember->m_hEnemy != 0 ) { From 59508d66da0ce01f596d43573dbf46a4c43c8111 Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Thu, 13 May 2021 01:27:10 +0300 Subject: [PATCH 7/9] Allow special beam color for houndeye squad of size 5 --- dlls/houndeye.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/dlls/houndeye.cpp b/dlls/houndeye.cpp index ba388b63..0333ca21 100644 --- a/dlls/houndeye.cpp +++ b/dlls/houndeye.cpp @@ -514,6 +514,7 @@ void CHoundeye::WriteBeamColor( void ) bBlue = 255; break; case 4: + case 5: bRed = 62; bGreen = 33; bBlue = 211; From b4502f71336a08f3f2c72b7b061b2838a149a11b Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Sun, 9 May 2021 04:36:02 +0300 Subject: [PATCH 8/9] Fix removing squad member --- dlls/squadmonster.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/squadmonster.cpp b/dlls/squadmonster.cpp index 60479878..d168d732 100644 --- a/dlls/squadmonster.cpp +++ b/dlls/squadmonster.cpp @@ -167,7 +167,7 @@ void CSquadMonster::SquadRemove( CSquadMonster *pRemove ) { for( int i = 0; i < MAX_SQUAD_MEMBERS - 1; i++ ) { - if( pSquadLeader->m_hSquadMember[i] == this ) + if( pSquadLeader->m_hSquadMember[i] == pRemove ) { pSquadLeader->m_hSquadMember[i] = NULL; break; From 06dd8a63cd2999e401fe03ce00dcfcabad3820a1 Mon Sep 17 00:00:00 2001 From: Andrey Akhmichin Date: Sun, 6 Jun 2021 04:11:36 +0500 Subject: [PATCH 9/9] Double promotion fix. --- dlls/gauss.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/gauss.cpp b/dlls/gauss.cpp index 50707dfe..c9352e8e 100644 --- a/dlls/gauss.cpp +++ b/dlls/gauss.cpp @@ -249,7 +249,7 @@ void CGauss::SecondaryAttack() // out of ammo! force the gun to fire StartFire(); m_fInAttack = 0; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0f; m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1; return; }