Browse Source

Update rpg.

clcampaign
Andrey Akhmichin 11 months ago
parent
commit
c6c6e1a7bd
  1. 6
      cl_dll/ev_hldm.cpp
  2. 70
      dlls/rpg.cpp
  3. 5
      dlls/weapons.h

6
cl_dll/ev_hldm.cpp

@ -1307,6 +1307,7 @@ enum rpg_e
RPG_FIDGET, RPG_FIDGET,
RPG_RELOAD, // to reload RPG_RELOAD, // to reload
RPG_FIRE2, // to empty RPG_FIRE2, // to empty
RPG_FIRE1, // crack-life second fire
RPG_HOLSTER1, // loaded RPG_HOLSTER1, // loaded
RPG_DRAW1, // loaded RPG_DRAW1, // loaded
RPG_HOLSTER2, // unloaded RPG_HOLSTER2, // unloaded
@ -1317,10 +1318,11 @@ enum rpg_e
void EV_FireRpg( event_args_t *args ) void EV_FireRpg( event_args_t *args )
{ {
int idx; int idx, hand;
vec3_t origin; vec3_t origin;
idx = args->entindex; idx = args->entindex;
hand = args->bparam1;
VectorCopy( args->origin, origin ); VectorCopy( args->origin, origin );
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/rocketfire1.wav", 0.9, ATTN_NORM, 0, PITCH_NORM ); gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/rocketfire1.wav", 0.9, ATTN_NORM, 0, PITCH_NORM );
@ -1329,7 +1331,7 @@ void EV_FireRpg( event_args_t *args )
//Only play the weapon anims if I shot it. //Only play the weapon anims if I shot it.
if( EV_IsLocal( idx ) ) if( EV_IsLocal( idx ) )
{ {
gEngfuncs.pEventAPI->EV_WeaponAnimation( RPG_FIRE2, 0 ); gEngfuncs.pEventAPI->EV_WeaponAnimation( RPG_FIRE2 + hand, 0 );
V_PunchAxis( 0, -5.0 ); V_PunchAxis( 0, -5.0 );
} }

70
dlls/rpg.cpp

@ -135,9 +135,9 @@ void CRpgRocket::Spawn( void )
SetThink( &CRpgRocket::IgniteThink ); SetThink( &CRpgRocket::IgniteThink );
SetTouch( &CGrenade::ExplodeTouch ); SetTouch( &CGrenade::ExplodeTouch );
pev->angles.x -= 30.0f; pev->angles.x -= 12.0f;
UTIL_MakeVectors( pev->angles ); 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->velocity = gpGlobals->v_forward * 250.0f;
pev->gravity = 0.5f; pev->gravity = 0.5f;
@ -280,48 +280,6 @@ void CRpgRocket::FollowThink( void )
} }
#endif #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() void CRpg::Spawn()
{ {
Precache(); Precache();
@ -395,7 +353,7 @@ int CRpg::AddToPlayer( CBasePlayer *pPlayer )
BOOL CRpg::Deploy() 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" ); return DefaultDeploy( "models/v_rpg.mdl", "models/p_rpg.mdl", RPG_DRAW_UL, "rpg" );
} }
@ -433,9 +391,8 @@ void CRpg::Holster( int skiplocal /* = 0 */ )
void CRpg::PrimaryAttack() 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_iWeaponVolume = LOUD_GUN_VOLUME;
m_pPlayer->m_iWeaponFlash = BRIGHT_GUN_FLASH; m_pPlayer->m_iWeaponFlash = BRIGHT_GUN_FLASH;
@ -445,10 +402,10 @@ void CRpg::PrimaryAttack()
UTIL_MakeVectors( m_pPlayer->pev->v_angle ); UTIL_MakeVectors( m_pPlayer->pev->v_angle );
Vector vecSrc; Vector vecSrc;
if( gun ) 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; 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 ); CRpgRocket *pRocket = CRpgRocket::CreateRpgRocket( vecSrc, m_pPlayer->pev->v_angle, m_pPlayer, this );
@ -465,13 +422,10 @@ void CRpg::PrimaryAttack()
#else #else
flags = 0; flags = 0;
#endif #endif
//PLAYBACK_EVENT( flags, m_pPlayer->edict(), m_usRpg ); PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usRpg, 0.0, g_vecZero, g_vecZero, 0, 0, 0, 0, m_fInAction, 0 );
EMIT_SOUND_DYN( edict(), CHAN_WEAPON, "weapons/rocketfire1.wav", 0.9, ATTN_NORM, 0, PITCH_NORM ); m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--;
EMIT_SOUND_DYN( edict(), CHAN_ITEM, "weapons/glauncher.wav", 0.7, ATTN_NORM, 0, PITCH_NORM );
SendWeaponAnim( RPG_FIRE2 + 1 - gun );
m_iClip--;
gun = !gun; m_fInAction = !m_fInAction;
m_flNextPrimaryAttack = GetNextAttackDelay( 0.4f ); m_flNextPrimaryAttack = GetNextAttackDelay( 0.4f );
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.5f; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.5f;
} }
@ -512,7 +466,7 @@ void CRpg::WeaponIdle( void )
float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0.0f, 1.0f ); float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0.0f, 1.0f );
if( flRand <= 0.75f || m_fSpotActive ) if( flRand <= 0.75f || m_fSpotActive )
{ {
if( m_iClip == 0 ) if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] == 0 )
iAnim = RPG_IDLE_UL; iAnim = RPG_IDLE_UL;
else else
iAnim = RPG_IDLE; iAnim = RPG_IDLE;
@ -521,7 +475,7 @@ void CRpg::WeaponIdle( void )
} }
else else
{ {
if( m_iClip == 0 ) if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] == 0 )
iAnim = RPG_FIDGET_UL; iAnim = RPG_FIDGET_UL;
else else
iAnim = RPG_FIDGET; iAnim = RPG_FIDGET;

5
dlls/weapons.h

@ -191,7 +191,7 @@ public:
#define AMMO_M203BOX_GIVE 999 #define AMMO_M203BOX_GIVE 999
#define AMMO_BUCKSHOTBOX_GIVE 12 #define AMMO_BUCKSHOTBOX_GIVE 12
#define AMMO_CROSSBOWCLIP_GIVE CROSSBOW_DEFAULT_GIVE #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_URANIUMBOX_GIVE 999
#define AMMO_SNARKBOX_GIVE 5 #define AMMO_SNARKBOX_GIVE 5
#define AMMO_SNIPARSBOX_GIVE 10 #define AMMO_SNIPARSBOX_GIVE 10
@ -712,7 +712,6 @@ public:
#endif #endif
void Spawn( void ); void Spawn( void );
void Precache( void ); void Precache( void );
void Reload( void );
int iItemSlot( void ) { return 4; } int iItemSlot( void ) { return 4; }
int GetItemInfo(ItemInfo *p); int GetItemInfo(ItemInfo *p);
int AddToPlayer( CBasePlayer *pPlayer ); int AddToPlayer( CBasePlayer *pPlayer );
@ -731,7 +730,7 @@ public:
CLaserSpot *m_pSpot; CLaserSpot *m_pSpot;
int m_fSpotActive; int m_fSpotActive;
int m_cActiveRockets;// how many missiles in flight from this launcher right now? int m_cActiveRockets;// how many missiles in flight from this launcher right now?
int m_fInAction;
virtual BOOL UseDecrement( void ) virtual BOOL UseDecrement( void )
{ {
#if CLIENT_WEAPONS #if CLIENT_WEAPONS

Loading…
Cancel
Save