Skip to content

Commit

Permalink
Update rpg.
Browse files Browse the repository at this point in the history
  • Loading branch information
nekonomicon committed Jan 3, 2024
1 parent 9bc4676 commit c6c6e1a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 63 deletions.
6 changes: 4 additions & 2 deletions cl_dll/ev_hldm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1307,6 +1307,7 @@ enum rpg_e
RPG_FIDGET,
RPG_RELOAD, // to reload
RPG_FIRE2, // to empty
RPG_FIRE1, // crack-life second fire
RPG_HOLSTER1, // loaded
RPG_DRAW1, // loaded
RPG_HOLSTER2, // unloaded
Expand All @@ -1317,10 +1318,11 @@ enum rpg_e

void EV_FireRpg( event_args_t *args )
{
int idx;
int idx, hand;
vec3_t origin;

idx = args->entindex;
hand = args->bparam1;
VectorCopy( args->origin, origin );

gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/rocketfire1.wav", 0.9, ATTN_NORM, 0, PITCH_NORM );
Expand All @@ -1329,7 +1331,7 @@ void EV_FireRpg( event_args_t *args )
//Only play the weapon anims if I shot it.
if( EV_IsLocal( idx ) )
{
gEngfuncs.pEventAPI->EV_WeaponAnimation( RPG_FIRE2, 0 );
gEngfuncs.pEventAPI->EV_WeaponAnimation( RPG_FIRE2 + hand, 0 );

V_PunchAxis( 0, -5.0 );
}
Expand Down
70 changes: 12 additions & 58 deletions dlls/rpg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ void CRpgRocket::Spawn( void )
SetThink( &CRpgRocket::IgniteThink );
SetTouch( &CGrenade::ExplodeTouch );

pev->angles.x -= 30.0f;
pev->angles.x -= 12.0f;
UTIL_MakeVectors( pev->angles );
pev->angles.x = -( pev->angles.x + 30.0f );
pev->angles.x = -( pev->angles.x + 12.0f );

pev->velocity = gpGlobals->v_forward * 250.0f;
pev->gravity = 0.5f;
Expand Down Expand Up @@ -280,48 +280,6 @@ void CRpgRocket::FollowThink( void )
}
#endif

void CRpg::Reload( void )
{
int iResult = 0;

// don't bother with any of this if don't need to reload.
if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 || m_iClip == RPG_MAX_CLIP )
return;

// because the RPG waits to autoreload when no missiles are active while the LTD is on, the
// weapons code is constantly calling into this function, but is often denied because
// a) missiles are in flight, but the LTD is on
// or
// b) player is totally out of ammo and has nothing to switch to, and should be allowed to
// shine the designator around
//
// Set the next attack time into the future so that WeaponIdle will get called more often
// than reload, allowing the RPG LTD to be updated

m_flNextPrimaryAttack = GetNextAttackDelay( 0.7f );

if( m_cActiveRockets && m_fSpotActive )
{
// no reloading when there are active missiles tracking the designator.
// ward off future autoreload attempts by setting next attack time into the future for a bit.
return;
}

#if !CLIENT_DLL
if( m_pSpot && m_fSpotActive )
{
m_pSpot->Suspend( 2.1f );
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 2.1f;
}
#endif

if( m_iClip == 0 )
iResult = DefaultReload( RPG_MAX_CLIP, RPG_RELOAD, 2 );

if( iResult )
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 );
}

void CRpg::Spawn()
{
Precache();
Expand Down Expand Up @@ -395,7 +353,7 @@ int CRpg::AddToPlayer( CBasePlayer *pPlayer )

BOOL CRpg::Deploy()
{
if( m_iClip == 0 )
if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] == 0 )
{
return DefaultDeploy( "models/v_rpg.mdl", "models/p_rpg.mdl", RPG_DRAW_UL, "rpg" );
}
Expand Down Expand Up @@ -433,9 +391,8 @@ void CRpg::Holster( int skiplocal /* = 0 */ )

void CRpg::PrimaryAttack()
{
if( m_iClip )
if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] )
{
static int gun = 0;
m_pPlayer->m_iWeaponVolume = LOUD_GUN_VOLUME;
m_pPlayer->m_iWeaponFlash = BRIGHT_GUN_FLASH;

Expand All @@ -445,10 +402,10 @@ void CRpg::PrimaryAttack()

UTIL_MakeVectors( m_pPlayer->pev->v_angle );
Vector vecSrc;
if( gun )
vecSrc = m_pPlayer->GetGunPosition() + gpGlobals->v_forward * 16 + gpGlobals->v_right * 8 + gpGlobals->v_up * -8;
else
if( m_fInAction )
vecSrc = m_pPlayer->GetGunPosition() + gpGlobals->v_forward * 16 + gpGlobals->v_right * -8 + gpGlobals->v_up * -8;
else
vecSrc = m_pPlayer->GetGunPosition() + gpGlobals->v_forward * 16 + gpGlobals->v_right * 8 + gpGlobals->v_up * -8;

CRpgRocket *pRocket = CRpgRocket::CreateRpgRocket( vecSrc, m_pPlayer->pev->v_angle, m_pPlayer, this );

Expand All @@ -465,13 +422,10 @@ void CRpg::PrimaryAttack()
#else
flags = 0;
#endif
//PLAYBACK_EVENT( flags, m_pPlayer->edict(), m_usRpg );
EMIT_SOUND_DYN( edict(), CHAN_WEAPON, "weapons/rocketfire1.wav", 0.9, ATTN_NORM, 0, PITCH_NORM );
EMIT_SOUND_DYN( edict(), CHAN_ITEM, "weapons/glauncher.wav", 0.7, ATTN_NORM, 0, PITCH_NORM );
SendWeaponAnim( RPG_FIRE2 + 1 - gun );
m_iClip--;
PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usRpg, 0.0, g_vecZero, g_vecZero, 0, 0, 0, 0, m_fInAction, 0 );
m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--;

gun = !gun;
m_fInAction = !m_fInAction;
m_flNextPrimaryAttack = GetNextAttackDelay( 0.4f );
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.5f;
}
Expand Down Expand Up @@ -512,7 +466,7 @@ void CRpg::WeaponIdle( void )
float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0.0f, 1.0f );
if( flRand <= 0.75f || m_fSpotActive )
{
if( m_iClip == 0 )
if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] == 0 )
iAnim = RPG_IDLE_UL;
else
iAnim = RPG_IDLE;
Expand All @@ -521,7 +475,7 @@ void CRpg::WeaponIdle( void )
}
else
{
if( m_iClip == 0 )
if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] == 0 )
iAnim = RPG_FIDGET_UL;
else
iAnim = RPG_FIDGET;
Expand Down
5 changes: 2 additions & 3 deletions dlls/weapons.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ class CGrenadeFedora : public CGrenade
#define AMMO_M203BOX_GIVE 999
#define AMMO_BUCKSHOTBOX_GIVE 12
#define AMMO_CROSSBOWCLIP_GIVE CROSSBOW_DEFAULT_GIVE
#define AMMO_RPGCLIP_GIVE RPG_DEFAULT_GIVE
#define AMMO_RPGCLIP_GIVE WEAPON_NOCLIP
#define AMMO_URANIUMBOX_GIVE 999
#define AMMO_SNARKBOX_GIVE 5
#define AMMO_SNIPARSBOX_GIVE 10
Expand Down Expand Up @@ -712,7 +712,6 @@ class CRpg : public CBasePlayerWeapon
#endif
void Spawn( void );
void Precache( void );
void Reload( void );
int iItemSlot( void ) { return 4; }
int GetItemInfo(ItemInfo *p);
int AddToPlayer( CBasePlayer *pPlayer );
Expand All @@ -731,7 +730,7 @@ class CRpg : public CBasePlayerWeapon
CLaserSpot *m_pSpot;
int m_fSpotActive;
int m_cActiveRockets;// how many missiles in flight from this launcher right now?

int m_fInAction;
virtual BOOL UseDecrement( void )
{
#if CLIENT_WEAPONS
Expand Down

0 comments on commit c6c6e1a

Please sign in to comment.