Merge branch 'master' into opfor

This commit is contained in:
Andrey Akhmichin 2021-06-06 04:13:23 +05:00
commit efa2dae589
9 changed files with 50 additions and 48 deletions

View File

@ -382,7 +382,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;

View File

@ -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 );
}

View File

@ -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.0f;
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
{

View File

@ -516,6 +516,7 @@ void CHoundeye::WriteBeamColor( void )
bBlue = 255;
break;
case 4:
case 5:
bRed = 62;
bGreen = 33;
bBlue = 211;

View File

@ -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 )

View File

@ -304,7 +304,7 @@ void CShotgun::Reload( void )
}
}
void CShotgun::WeaponTick()
void CShotgun::ItemPostFrame( void )
{
if( m_flPumpTime && m_flPumpTime < gpGlobals->time )
{
@ -312,6 +312,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 )

View File

@ -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;
@ -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 )
{

View File

@ -646,8 +646,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.
@ -943,16 +941,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 )

View File

@ -367,7 +367,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 );
@ -624,7 +623,6 @@ public:
BOOL Deploy( void );
void Reload( void );
void WeaponIdle( void );
BOOL IsUseable();
float m_flNextAnimTime;
int m_iShell;
@ -694,8 +692,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;
@ -802,7 +800,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 );