Remove TabulateAmmo calls. Fix weapon ids.

This commit is contained in:
Night Owl 2018-10-25 23:33:52 +05:00
parent 4e4fdf6630
commit f54e7b037b
10 changed files with 28 additions and 144 deletions

View File

@ -726,11 +726,6 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm
pCurrent->m_flNextSecondaryAttack = pfrom->m_flNextSecondaryAttack;
pCurrent->m_flTimeWeaponIdle = pfrom->m_flTimeWeaponIdle;
pCurrent->pev->fuser1 = pfrom->fuser1;
pCurrent->m_flStartThrow = pfrom->fuser2;
pCurrent->m_flReleaseThrow = pfrom->fuser3;
pCurrent->m_chargeReady = pfrom->iuser1;
pCurrent->m_fInAttack = pfrom->iuser2;
pCurrent->m_fireState = pfrom->iuser3;
pCurrent->m_iSecondaryAmmoType = (int)from->client.vuser3[2];
pCurrent->m_iPrimaryAmmoType = (int)from->client.vuser4[0];
@ -769,15 +764,6 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm
player.m_flNextAmmoBurn = from->client.fuser2;
player.m_flAmmoStartCharge = from->client.fuser3;
//Stores all our ammo info, so the client side weapons can use them.
player.ammo_9mm = (int)from->client.vuser1[0];
player.ammo_357 = (int)from->client.vuser1[1];
player.ammo_argrens = (int)from->client.vuser1[2];
player.ammo_bolts = (int)from->client.ammo_nails; //is an int anyways...
player.ammo_buckshot = (int)from->client.ammo_shells;
player.ammo_uranium = (int)from->client.ammo_cells;
player.ammo_hornets = (int)from->client.vuser2[0];
player.ammo_rockets = (int)from->client.ammo_rockets;
// Point to current weapon object
if( from->client.m_iId )
@ -785,11 +771,6 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm
player.m_pActiveItem = g_pWpns[from->client.m_iId];
}
if( player.m_pActiveItem->m_iId == WEAPON_MP5 )
{
player.ammo_ak47 = (int)from->client.vuser2[1];
}
// Don't go firing anything if we have died.
// Or if we don't have a weapon model deployed
if( ( player.pev->deadflag != ( DEAD_DISCARDBODY + 1 ) ) &&
@ -841,22 +822,6 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm
to->client.fuser3 = player.m_flAmmoStartCharge;
to->client.maxspeed = player.pev->maxspeed;
//HL Weapons
to->client.vuser1[0] = player.ammo_9mm;
to->client.vuser1[1] = player.ammo_357;
to->client.vuser1[2] = player.ammo_argrens;
to->client.ammo_nails = player.ammo_bolts;
to->client.ammo_shells = player.ammo_buckshot;
to->client.ammo_cells = player.ammo_uranium;
to->client.vuser2[0] = player.ammo_hornets;
to->client.ammo_rockets = player.ammo_rockets;
if( player.m_pActiveItem->m_iId == WEAPON_MP5 )
{
from->client.vuser2[1] = player.ammo_ak47;
}
// Make sure that weapon animation matches what the game .dll is telling us
// over the wire ( fixes some animation glitches )
if( g_runfuncs && ( HUD_GetWeaponAnim() != to->client.weaponanim ) )
@ -887,11 +852,6 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm
pto->m_flNextSecondaryAttack = pCurrent->m_flNextSecondaryAttack;
pto->m_flTimeWeaponIdle = pCurrent->m_flTimeWeaponIdle;
pto->fuser1 = pCurrent->pev->fuser1;
pto->fuser2 = pCurrent->m_flStartThrow;
pto->fuser3 = pCurrent->m_flReleaseThrow;
pto->iuser1 = pCurrent->m_chargeReady;
pto->iuser2 = pCurrent->m_fInAttack;
pto->iuser3 = pCurrent->m_fireState;
// Decrement weapon counters, server does this at same time ( during post think, after doing everything else )
pto->m_flNextReload -= cmd->msec / 1000.0;

View File

@ -333,28 +333,6 @@ public:
virtual BOOL FVisible( CBaseEntity *pEntity );
virtual BOOL FVisible( const Vector &vecOrigin );
//We use this variables to store each ammo count.
int ammo_9mm;
int ammo_357;
int ammo_bolts;
int ammo_buckshot;
int ammo_rockets;
int ammo_uranium;
int ammo_hornets;
int ammo_argrens;
int ammo_ak47;
//Special stuff for grenades and satchels.
float m_flStartThrow;
float m_flReleaseThrow;
int m_chargeReady;
int m_fInAttack;
enum EGON_FIRESTATE { FIRE_OFF, FIRE_CHARGE };
int m_fireState;
void MuzzleLight( Vector vecSrc, float flRadius, byte r, byte g, byte b, float flTime, float flDecay );
};
// Ugly technique to override base member functions

View File

@ -1666,11 +1666,6 @@ int GetWeaponData( struct edict_s *player, struct weapon_data_s *info )
item->m_fInReload = gun->m_fInReload;
item->m_fInSpecialReload = gun->m_fInSpecialReload;
item->fuser1 = Q_max( gun->pev->fuser1, -0.001 );
item->fuser2 = gun->m_flStartThrow;
item->fuser3 = gun->m_flReleaseThrow;
item->iuser1 = gun->m_chargeReady;
item->iuser2 = gun->m_fInAttack;
item->iuser3 = gun->m_fireState;
//item->m_flPumpTime = max( gun->m_flPumpTime, -0.001 );
}
@ -1761,14 +1756,6 @@ void UpdateClientData( const struct edict_s *ent, int sendweapons, struct client
cd->m_flNextAttack = pl->m_flNextAttack;
cd->fuser2 = pl->m_flNextAmmoBurn;
cd->fuser3 = pl->m_flAmmoStartCharge;
cd->vuser1.x = pl->ammo_9mm;
cd->vuser1.y = pl->ammo_357;
cd->vuser1.z = pl->ammo_argrens;
cd->ammo_nails = pl->ammo_bolts;
cd->ammo_shells = pl->ammo_buckshot;
cd->ammo_rockets = pl->ammo_rockets;
cd->ammo_cells = pl->ammo_uranium;
cd->vuser2.x = pl->ammo_hornets;
if( pl->m_pActiveItem )
{
@ -1785,11 +1772,6 @@ void UpdateClientData( const struct edict_s *ent, int sendweapons, struct client
cd->vuser4.x = gun->m_iPrimaryAmmoType;
cd->vuser4.y = pl->m_rgAmmo[gun->m_iPrimaryAmmoType];
cd->vuser4.z = pl->m_rgAmmo[gun->m_iSecondaryAmmoType];
if( pl->m_pActiveItem->m_iId == WEAPON_MP5 )
{
cd->vuser2.y = pl->ammo_ak47;
}
}
}
}

View File

@ -1467,7 +1467,7 @@ void CBaseEntity::FireBullets( ULONG cShots, Vector vecSrc, Vector vecDirShootin
}
ApplyMultiDamage( pev, pevAttacker );
MuzzleLight( vecSrc, 200, 255, 255, 255, 0.1f, 0 );
UTIL_MuzzleLight( vecSrc, 200, 255, 255, 255, 0.1f, 0 );
}
/*
@ -1555,7 +1555,7 @@ Vector CBaseEntity::FireBulletsPlayer( ULONG cShots, Vector vecSrc, Vector vecDi
}
ApplyMultiDamage( pev, pevAttacker );
MuzzleLight( vecSrc, 200, 255, 255, 255, 0.1f, 0 );
UTIL_MuzzleLight( vecSrc, 200, 255, 255, 255, 0.1f, 0 );
return Vector( x * vecSpread.x, y * vecSpread.y, 0.0 );
}
@ -1678,30 +1678,3 @@ void CBaseMonster::MakeDamageBloodDecal( int cCount, float flNoise, TraceResult
}
}
}
// ==========================================
// Code changes for- Night at the Office:
// ==========================================
//
// -Muzzle light. Light emitted onto maps when guns are fired.
// (both player and enemy)
void CBaseEntity::MuzzleLight( Vector vecSrc, float flRadius, byte r, byte g, byte b, float flTime, float flDecay )
{
int iRadius = (int)( flRadius * 0.1f );
int iTime = (int)( flTime * 10 );
int iDecay = (int)( flDecay * 0.1f );
MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY );
WRITE_BYTE( TE_DLIGHT );
WRITE_COORD( vecSrc.x ); // X
WRITE_COORD( vecSrc.y ); // Y
WRITE_COORD( vecSrc.z ); // Z
WRITE_BYTE( iRadius ); // radius * 0.1
WRITE_BYTE( r ); // r
WRITE_BYTE( g ); // g
WRITE_BYTE( b ); // b
WRITE_BYTE( iTime ); // time * 10
WRITE_BYTE( iDecay ); // decay * 0.1
MESSAGE_END();
}

View File

@ -1116,26 +1116,6 @@ void CBasePlayer::SetAnimation( PLAYER_ANIM playerAnim )
ResetSequenceInfo();
}
/*
===========
TabulateAmmo
This function is used to find and store
all the ammo we have into the ammo vars.
============
*/
void CBasePlayer::TabulateAmmo()
{
ammo_9mm = AmmoInventory( GetAmmoIndex( "9mm" ) );
ammo_357 = AmmoInventory( GetAmmoIndex( "357" ) );
ammo_argrens = AmmoInventory( GetAmmoIndex( "ARgrenades" ) );
ammo_bolts = AmmoInventory( GetAmmoIndex( "bolts" ) );
ammo_buckshot = AmmoInventory( GetAmmoIndex( "buckshot" ) );
ammo_rockets = AmmoInventory( GetAmmoIndex( "rockets" ) );
ammo_uranium = AmmoInventory( GetAmmoIndex( "uranium" ) );
ammo_hornets = AmmoInventory( GetAmmoIndex( "Hornets" ) );
ammo_ak47 = AmmoInventory( GetAmmoIndex( "ak47" ) );
}
/*
===========
WaterMove
@ -3654,8 +3634,6 @@ int CBasePlayer::GiveAmmo( int iCount, const char *szName, int iMax )
MESSAGE_END();
}
TabulateAmmo();
return i;
}

View File

@ -305,8 +305,6 @@ public:
void SetCustomDecalFrames( int nFrames );
int GetCustomDecalFrames( void );
void TabulateAmmo( void );
Vector m_vecLastViewAngles;
float m_flStartCharge;

View File

@ -31,6 +31,22 @@
#include "weapons.h"
#include "gamerules.h"
void UTIL_MuzzleLight( const Vector &vecSrc, float flRadius, byte r, byte g, byte b, float flTime, float flDecay )
{
MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY );
WRITE_BYTE( TE_DLIGHT );
WRITE_COORD( vecSrc.x ); // X
WRITE_COORD( vecSrc.y ); // Y
WRITE_COORD( vecSrc.z ); // Z
WRITE_BYTE( flRadius * 0.1f ); // radius * 0.1
WRITE_BYTE( r ); // r
WRITE_BYTE( g ); // g
WRITE_BYTE( b ); // b
WRITE_BYTE( flTime * 10.0f ); // time * 10
WRITE_BYTE( flDecay * 0.1f ); // decay * 0.1
MESSAGE_END();
}
float UTIL_WeaponTimeBase( void )
{
#if defined( CLIENT_WEAPONS )

View File

@ -577,5 +577,6 @@ void UTIL_UnsetGroupTrace( void );
int UTIL_SharedRandomLong( unsigned int seed, int low, int high );
float UTIL_SharedRandomFloat( unsigned int seed, float low, float high );
void UTIL_MuzzleLight( const Vector &vecSrc, float flRadius, byte r, byte g, byte b, float flTime, float flDecay );
float UTIL_WeaponTimeBase( void );
#endif // UTIL_H

View File

@ -606,8 +606,6 @@ void CBasePlayerWeapon::ItemPostFrame( void )
m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] -= m_iClip; // Remove an entire clip.
}
m_pPlayer->TabulateAmmo();
m_fInReload = FALSE;
}
@ -623,7 +621,6 @@ void CBasePlayerWeapon::ItemPostFrame( void )
m_fFireOnEmpty = TRUE;
}
m_pPlayer->TabulateAmmo();
SecondaryAttack();
m_pPlayer->pev->button &= ~IN_ATTACK2;
}
@ -634,7 +631,6 @@ void CBasePlayerWeapon::ItemPostFrame( void )
m_fFireOnEmpty = TRUE;
}
m_pPlayer->TabulateAmmo();
PrimaryAttack();
}
else if( m_pPlayer->pev->button & IN_RELOAD && iMaxClip() != WEAPON_NOCLIP && !m_fInReload )
@ -939,7 +935,6 @@ BOOL CBasePlayerWeapon::DefaultDeploy( const char *szViewModel, const char *szWe
if( !CanDeploy() )
return FALSE;
m_pPlayer->TabulateAmmo();
m_pPlayer->pev->viewmodel = MAKE_STRING( szViewModel );
m_pPlayer->pev->weaponmodel = MAKE_STRING( szWeaponModel );
strcpy( m_pPlayer->m_szAnimExtention, szAnimExt );

View File

@ -63,12 +63,12 @@ public:
#define ITEM_BATTERY 4
#define WEAPON_NONE 0
#define WEAPON_HOLSTER 1
#define WEAPON_TORCH 2
#define WEAPON_CROWBAR 3
#define WEAPON_GLOCK 4
#define WEAPON_MP5 5
#define WEAPON_SHOTGUN 6
#define WEAPON_CROWBAR 1
#define WEAPON_GLOCK 2
#define WEAPON_TORCH 3
#define WEAPON_MP5 4
#define WEAPON_SHOTGUN 7
#define WEAPON_HOLSTER 17
#define WEAPON_ALLWEAPONS (~(1<<WEAPON_SUIT))
@ -444,6 +444,7 @@ public:
private:
int m_iShell;
int m_fInAttack;
unsigned short m_usFireGlock1;
unsigned short m_usFireGlock2;
};
@ -469,6 +470,8 @@ public:
int m_iSwing;
TraceResult m_trHit;
float m_flReleaseThrow;
float m_flStartThrow;
virtual BOOL UseDecrement( void )
{
#if defined( CLIENT_WEAPONS )