Night Owl 7 years ago
parent
commit
70c6e42907
  1. 2
      cl_dll/hl/hl_baseentity.cpp
  2. 3
      dlls/handgrenade.cpp
  3. 16
      dlls/player.cpp
  4. 2
      dlls/player.h
  5. 53
      dlls/satchel.cpp
  6. 3
      dlls/squeakgrenade.cpp
  7. 3
      dlls/tripmine.cpp
  8. 16
      dlls/weapons.cpp

2
cl_dll/hl/hl_baseentity.cpp

@ -277,7 +277,7 @@ void CBasePlayer::ForceClientDllUpdate( void ) { }
void CBasePlayer::ImpulseCommands() { } void CBasePlayer::ImpulseCommands() { }
void CBasePlayer::CheatImpulseCommands( int iImpulse ) { } void CBasePlayer::CheatImpulseCommands( int iImpulse ) { }
int CBasePlayer::AddPlayerItem( CBasePlayerItem *pItem ) { return FALSE; } int CBasePlayer::AddPlayerItem( CBasePlayerItem *pItem ) { return FALSE; }
int CBasePlayer::RemovePlayerItem( CBasePlayerItem *pItem ) { return FALSE; } int CBasePlayer::RemovePlayerItem( CBasePlayerItem *pItem, bool bCallHoster ) { return FALSE; }
void CBasePlayer::ItemPreFrame() { } void CBasePlayer::ItemPreFrame() { }
void CBasePlayer::ItemPostFrame() { } void CBasePlayer::ItemPostFrame() { }
int CBasePlayer::AmmoInventory( int iAmmoIndex ) { return -1; } int CBasePlayer::AmmoInventory( int iAmmoIndex ) { return -1; }

3
dlls/handgrenade.cpp

@ -99,8 +99,7 @@ void CHandGrenade::Holster( int skiplocal /* = 0 */ )
{ {
// no more grenades! // no more grenades!
m_pPlayer->pev->weapons &= ~( 1 << WEAPON_HANDGRENADE ); m_pPlayer->pev->weapons &= ~( 1 << WEAPON_HANDGRENADE );
SetThink( &CBasePlayerItem::DestroyItem ); DestroyItem();
pev->nextthink = gpGlobals->time + 0.1;
} }
if( m_flStartThrow ) if( m_flStartThrow )

16
dlls/player.cpp

@ -666,8 +666,8 @@ void CBasePlayer::PackDeadPlayerItems( void )
int iWeaponRules; int iWeaponRules;
int iAmmoRules; int iAmmoRules;
int i; int i;
CBasePlayerWeapon *rgpPackWeapons[20] = {0};// 20 hardcoded for now. How to determine exactly how many weapons we have? CBasePlayerWeapon *rgpPackWeapons[MAX_WEAPONS] = {};
int iPackAmmo[MAX_AMMO_SLOTS + 1]; int iPackAmmo[MAX_AMMO_SLOTS];
int iPW = 0;// index into packweapons array int iPW = 0;// index into packweapons array
int iPA = 0;// index into packammo array int iPA = 0;// index into packammo array
@ -685,14 +685,14 @@ void CBasePlayer::PackDeadPlayerItems( void )
} }
// go through all of the weapons and make a list of the ones to pack // go through all of the weapons and make a list of the ones to pack
for( i = 0; i < MAX_ITEM_TYPES; i++ ) for( i = 0; i < MAX_ITEM_TYPES && iPW < MAX_WEAPONS; i++ )
{ {
if( m_rgpPlayerItems[i] ) if( m_rgpPlayerItems[i] )
{ {
// there's a weapon here. Should I pack it? // there's a weapon here. Should I pack it?
CBasePlayerItem *pPlayerItem = m_rgpPlayerItems[i]; CBasePlayerItem *pPlayerItem = m_rgpPlayerItems[i];
while( pPlayerItem ) while( pPlayerItem && iPW < MAX_WEAPONS )
{ {
switch( iWeaponRules ) switch( iWeaponRules )
{ {
@ -3640,14 +3640,16 @@ int CBasePlayer::AddPlayerItem( CBasePlayerItem *pItem )
return FALSE; return FALSE;
} }
int CBasePlayer::RemovePlayerItem( CBasePlayerItem *pItem ) int CBasePlayer::RemovePlayerItem( CBasePlayerItem *pItem, bool bCallHolster )
{ {
pItem->pev->nextthink = 0;// crowbar may be trying to swing again, etc.
pItem->SetThink( NULL );
if( m_pActiveItem == pItem ) if( m_pActiveItem == pItem )
{ {
ResetAutoaim(); ResetAutoaim();
if( bCallHolster )
pItem->Holster(); pItem->Holster();
pItem->pev->nextthink = 0;// crowbar may be trying to swing again, etc.
pItem->SetThink( NULL );
m_pActiveItem = NULL; m_pActiveItem = NULL;
pev->viewmodel = 0; pev->viewmodel = 0;
pev->weaponmodel = 0; pev->weaponmodel = 0;

2
dlls/player.h

@ -259,7 +259,7 @@ public:
void AddPoints( int score, BOOL bAllowNegativeScore ); void AddPoints( int score, BOOL bAllowNegativeScore );
void AddPointsToTeam( int score, BOOL bAllowNegativeScore ); void AddPointsToTeam( int score, BOOL bAllowNegativeScore );
BOOL AddPlayerItem( CBasePlayerItem *pItem ); BOOL AddPlayerItem( CBasePlayerItem *pItem );
BOOL RemovePlayerItem( CBasePlayerItem *pItem ); BOOL RemovePlayerItem( CBasePlayerItem *pItem, bool bCallHoster );
void DropPlayerItem ( char *pszItemName ); void DropPlayerItem ( char *pszItemName );
BOOL HasPlayerItem( CBasePlayerItem *pCheckItem ); BOOL HasPlayerItem( CBasePlayerItem *pCheckItem );
BOOL HasNamedPlayerItem( const char *pszItemName ); BOOL HasNamedPlayerItem( const char *pszItemName );

53
dlls/satchel.cpp

@ -23,6 +23,13 @@
#include "player.h" #include "player.h"
#include "gamerules.h" #include "gamerules.h"
enum satchel_state
{
SATCHEL_IDLE = 0,
SATCHEL_READY,
SATCHEL_RELOAD
};
enum satchel_e enum satchel_e
{ {
SATCHEL_IDLE1 = 0, SATCHEL_IDLE1 = 0,
@ -194,7 +201,7 @@ int CSatchel::AddDuplicate( CBasePlayerItem *pOriginal )
{ {
pSatchel = (CSatchel *)pOriginal; pSatchel = (CSatchel *)pOriginal;
if( pSatchel->m_chargeReady != 0 ) if( pSatchel->m_chargeReady != SATCHEL_IDLE )
{ {
// player has some satchels deployed. Refuse to add more. // player has some satchels deployed. Refuse to add more.
return FALSE; return FALSE;
@ -211,7 +218,7 @@ int CSatchel::AddToPlayer( CBasePlayer *pPlayer )
int bResult = CBasePlayerItem::AddToPlayer( pPlayer ); int bResult = CBasePlayerItem::AddToPlayer( pPlayer );
pPlayer->pev->weapons |= ( 1 << m_iId ); pPlayer->pev->weapons |= ( 1 << m_iId );
m_chargeReady = 0;// this satchel charge weapon now forgets that any satchels are deployed by it. m_chargeReady = SATCHEL_IDLE;// this satchel charge weapon now forgets that any satchels are deployed by it.
if( bResult ) if( bResult )
{ {
@ -263,19 +270,7 @@ int CSatchel::GetItemInfo( ItemInfo *p )
//========================================================= //=========================================================
BOOL CSatchel::IsUseable( void ) BOOL CSatchel::IsUseable( void )
{ {
if( m_pPlayer->m_rgAmmo[PrimaryAmmoIndex()] > 0 ) return CanDeploy();
{
// player is carrying some satchels
return TRUE;
}
if( m_chargeReady != 0 )
{
// player isn't carrying any satchels, but has some out
return TRUE;
}
return FALSE;
} }
BOOL CSatchel::CanDeploy( void ) BOOL CSatchel::CanDeploy( void )
@ -286,7 +281,7 @@ BOOL CSatchel::CanDeploy( void )
return TRUE; return TRUE;
} }
if( m_chargeReady != 0 ) if( m_chargeReady )
{ {
// player isn't carrying any satchels, but has some out // player isn't carrying any satchels, but has some out
return TRUE; return TRUE;
@ -322,11 +317,10 @@ void CSatchel::Holster( int skiplocal /* = 0 */ )
} }
EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "common/null.wav", 1.0, ATTN_NORM ); EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "common/null.wav", 1.0, ATTN_NORM );
if( !m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] && !m_chargeReady ) if( !m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] && m_chargeReady != SATCHEL_READY )
{ {
m_pPlayer->pev->weapons &= ~( 1 << WEAPON_SATCHEL ); m_pPlayer->pev->weapons &= ~( 1 << WEAPON_SATCHEL );
SetThink( &CBasePlayerItem::DestroyItem ); DestroyItem();
pev->nextthink = gpGlobals->time + 0.1;
} }
} }
@ -334,12 +328,12 @@ void CSatchel::PrimaryAttack()
{ {
switch( m_chargeReady ) switch( m_chargeReady )
{ {
case 0: case SATCHEL_IDLE:
{ {
Throw(); Throw();
} }
break; break;
case 1: case SATCHEL_READY:
{ {
SendWeaponAnim( SATCHEL_RADIO_FIRE ); SendWeaponAnim( SATCHEL_RADIO_FIRE );
@ -354,18 +348,17 @@ void CSatchel::PrimaryAttack()
if( pSatchel->pev->owner == pPlayer ) if( pSatchel->pev->owner == pPlayer )
{ {
pSatchel->Use( m_pPlayer, m_pPlayer, USE_ON, 0 ); pSatchel->Use( m_pPlayer, m_pPlayer, USE_ON, 0 );
m_chargeReady = 2;
} }
} }
} }
m_chargeReady = 2; m_chargeReady = SATCHEL_RELOAD;
m_flNextPrimaryAttack = GetNextAttackDelay( 0.5 ); m_flNextPrimaryAttack = GetNextAttackDelay( 0.5 );
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5; m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5;
break; break;
} }
case 2: case SATCHEL_RELOAD:
// we're reloading, don't allow fire // we're reloading, don't allow fire
break; break;
} }
@ -373,7 +366,7 @@ void CSatchel::PrimaryAttack()
void CSatchel::SecondaryAttack( void ) void CSatchel::SecondaryAttack( void )
{ {
if( m_chargeReady != 2 ) if( m_chargeReady != SATCHEL_RELOAD )
{ {
Throw(); Throw();
} }
@ -403,7 +396,7 @@ void CSatchel::Throw( void )
// player "shoot" animation // player "shoot" animation
m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
m_chargeReady = 1; m_chargeReady = SATCHEL_READY;
m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--; m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--;
@ -419,17 +412,17 @@ void CSatchel::WeaponIdle( void )
switch( m_chargeReady ) switch( m_chargeReady )
{ {
case 0: case SATCHEL_IDLE:
SendWeaponAnim( SATCHEL_FIDGET1 ); SendWeaponAnim( SATCHEL_FIDGET1 );
// use tripmine animations // use tripmine animations
strcpy( m_pPlayer->m_szAnimExtention, "trip" ); strcpy( m_pPlayer->m_szAnimExtention, "trip" );
break; break;
case 1: case SATCHEL_READY:
SendWeaponAnim( SATCHEL_RADIO_FIDGET1 ); SendWeaponAnim( SATCHEL_RADIO_FIDGET1 );
// use hivehand animations // use hivehand animations
strcpy( m_pPlayer->m_szAnimExtention, "hive" ); strcpy( m_pPlayer->m_szAnimExtention, "hive" );
break; break;
case 2: case SATCHEL_RELOAD:
if( !m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] ) if( !m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] )
{ {
m_chargeReady = 0; m_chargeReady = 0;
@ -450,7 +443,7 @@ void CSatchel::WeaponIdle( void )
m_flNextPrimaryAttack = GetNextAttackDelay( 0.5 ); m_flNextPrimaryAttack = GetNextAttackDelay( 0.5 );
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5; m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5;
m_chargeReady = 0; m_chargeReady = SATCHEL_IDLE;
break; break;
} }
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 );// how long till we do this again. m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 );// how long till we do this again.

3
dlls/squeakgrenade.cpp

@ -475,8 +475,7 @@ void CSqueak::Holster( int skiplocal /* = 0 */ )
if( !m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] ) if( !m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] )
{ {
m_pPlayer->pev->weapons &= ~( 1 << WEAPON_SNARK ); m_pPlayer->pev->weapons &= ~( 1 << WEAPON_SNARK );
SetThink( &CBasePlayerItem::DestroyItem ); DestroyItem();
pev->nextthink = gpGlobals->time + 0.1;
return; return;
} }

3
dlls/tripmine.cpp

@ -418,8 +418,7 @@ void CTripmine::Holster( int skiplocal /* = 0 */ )
{ {
// out of mines // out of mines
m_pPlayer->pev->weapons &= ~( 1 << WEAPON_TRIPMINE ); m_pPlayer->pev->weapons &= ~( 1 << WEAPON_TRIPMINE );
SetThink( &CBasePlayerItem::DestroyItem ); DestroyItem();
pev->nextthink = gpGlobals->time + 0.1;
} }
SendWeaponAnim( TRIPMINE_HOLSTER ); SendWeaponAnim( TRIPMINE_HOLSTER );

16
dlls/weapons.cpp

@ -689,7 +689,7 @@ void CBasePlayerItem::DestroyItem( void )
if( m_pPlayer ) if( m_pPlayer )
{ {
// if attached to a player, remove. // if attached to a player, remove.
m_pPlayer->RemovePlayerItem( this ); m_pPlayer->RemovePlayerItem( this, false );
} }
Kill(); Kill();
@ -1140,7 +1140,17 @@ void CBasePlayerWeapon::RetireWeapon( void )
m_pPlayer->pev->weaponmodel = iStringNull; m_pPlayer->pev->weaponmodel = iStringNull;
//m_pPlayer->pev->viewmodelindex = NULL; //m_pPlayer->pev->viewmodelindex = NULL;
g_pGameRules->GetNextBestWeapon( m_pPlayer, this ); if( !g_pGameRules->GetNextBestWeapon( m_pPlayer, this ) )
{
// Another weapon wasn't selected. Get rid of current one
if( m_pPlayer->m_pActiveItem == this )
{
m_pPlayer->ResetAutoaim();
m_pPlayer->m_pActiveItem->Holster();
m_pPlayer->m_pLastItem = NULL;
m_pPlayer->m_pActiveItem = NULL;
}
}
} }
//========================================================================= //=========================================================================
@ -1340,7 +1350,7 @@ BOOL CWeaponBox::PackWeapon( CBasePlayerItem *pWeapon )
if( pWeapon->m_pPlayer ) if( pWeapon->m_pPlayer )
{ {
if( !pWeapon->m_pPlayer->RemovePlayerItem( pWeapon ) ) if( !pWeapon->m_pPlayer->RemovePlayerItem( pWeapon, true ) )
{ {
// failed to unhook the weapon from the player! // failed to unhook the weapon from the player!
return FALSE; return FALSE;

Loading…
Cancel
Save