|
|
|
@ -11,7 +11,7 @@
@@ -11,7 +11,7 @@
|
|
|
|
|
#include "player.h" |
|
|
|
|
|
|
|
|
|
#define HANDGRENADE_PRIMARY_VOLUME 450 |
|
|
|
|
|
|
|
|
|
#define WEAPON_PEPSIGUN 22 |
|
|
|
|
enum handgrenade_e |
|
|
|
|
{ |
|
|
|
|
HANDGRENADE_IDLE = 0, |
|
|
|
@ -22,6 +22,32 @@ enum handgrenade_e
@@ -22,6 +22,32 @@ enum handgrenade_e
|
|
|
|
|
HANDGRENADE_DRAW |
|
|
|
|
|
|
|
|
|
}; |
|
|
|
|
class CPepsigun : public CBasePlayerWeapon |
|
|
|
|
{ |
|
|
|
|
public: |
|
|
|
|
void Spawn( void ); |
|
|
|
|
void Precache( void ); |
|
|
|
|
int iItemSlot( void ) { return 4; } |
|
|
|
|
int GetItemInfo(ItemInfo *p); |
|
|
|
|
|
|
|
|
|
void PrimaryAttack( void ); |
|
|
|
|
void Reload( void ); |
|
|
|
|
BOOL Deploy( void ); |
|
|
|
|
BOOL CanHolster( void ); |
|
|
|
|
void Holster( int skiplocal = 0 ); |
|
|
|
|
void WeaponIdle( void ); |
|
|
|
|
int m_fInReload; |
|
|
|
|
float m_flNextReload; |
|
|
|
|
|
|
|
|
|
virtual BOOL UseDecrement( void ) |
|
|
|
|
{ |
|
|
|
|
#if defined( CLIENT_WEAPONS ) |
|
|
|
|
return TRUE; |
|
|
|
|
#else |
|
|
|
|
return FALSE; |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
LINK_ENTITY_TO_CLASS( weapon_pepsigun, CPepsigun ) |
|
|
|
|
LINK_ENTITY_TO_CLASS( ammo_pepsi, CPepsigun ) |
|
|
|
@ -35,7 +61,7 @@ void CPepsigun::Spawn()
@@ -35,7 +61,7 @@ void CPepsigun::Spawn()
|
|
|
|
|
#ifndef CLIENT_DLL |
|
|
|
|
pev->dmg = 80; |
|
|
|
|
#endif |
|
|
|
|
m_iDefaultAmmo = 10000; |
|
|
|
|
m_iDefaultAmmo = 100; |
|
|
|
|
|
|
|
|
|
FallInit();// get ready to fall down.
|
|
|
|
|
} |
|
|
|
@ -45,6 +71,7 @@ void CPepsigun::Precache( void )
@@ -45,6 +71,7 @@ void CPepsigun::Precache( void )
|
|
|
|
|
PRECACHE_MODEL( "models/w_pepsigun.mdl" ); |
|
|
|
|
PRECACHE_MODEL( "models/v_pepsigun.mdl" ); |
|
|
|
|
PRECACHE_MODEL( "models/p_pepsigun.mdl" ); |
|
|
|
|
PRECACHE_SOUND( "weapons/pepsigun_shoot.wav"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int CPepsigun::GetItemInfo( ItemInfo *p ) |
|
|
|
@ -54,11 +81,11 @@ int CPepsigun::GetItemInfo( ItemInfo *p )
@@ -54,11 +81,11 @@ int CPepsigun::GetItemInfo( ItemInfo *p )
|
|
|
|
|
p->iMaxAmmo1 = 20000; |
|
|
|
|
p->pszAmmo2 = NULL; |
|
|
|
|
p->iMaxAmmo2 = -1; |
|
|
|
|
p->iMaxClip = -1; |
|
|
|
|
p->iMaxClip = 8; |
|
|
|
|
p->iSlot = 2; |
|
|
|
|
p->iPosition = 4; |
|
|
|
|
p->iId = m_iId = WEAPON_PEPSIGUN; |
|
|
|
|
p->iWeight = PEPSIGUN_WEIGHT; |
|
|
|
|
p->iWeight = 10; |
|
|
|
|
p->iFlags = ITEM_FLAG_LIMITINWORLD | ITEM_FLAG_EXHAUSTIBLE; |
|
|
|
|
|
|
|
|
|
return 1; |
|
|
|
@ -97,13 +124,79 @@ void CPepsigun::Holster( int skiplocal /* = 0 */ )
@@ -97,13 +124,79 @@ void CPepsigun::Holster( int skiplocal /* = 0 */ )
|
|
|
|
|
|
|
|
|
|
void CPepsigun::PrimaryAttack() |
|
|
|
|
{ |
|
|
|
|
if(m_iClip > 0) |
|
|
|
|
{ |
|
|
|
|
m_flStartThrow = gpGlobals->time; |
|
|
|
|
m_flReleaseThrow = 0; |
|
|
|
|
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.25; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
void CPepsigun::Reload( void ) |
|
|
|
|
{ |
|
|
|
|
if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 || m_iClip == SHOTGUN_MAX_CLIP ) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
// don't reload until recoil is done
|
|
|
|
|
if( m_flNextPrimaryAttack > UTIL_WeaponTimeBase() ) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
// check to see if we're ready to reload
|
|
|
|
|
if( m_fInSpecialReload == 0 ) |
|
|
|
|
{ |
|
|
|
|
SendWeaponAnim( HANDGRENADE_OPEN ); |
|
|
|
|
m_fInSpecialReload = 1; |
|
|
|
|
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.6; |
|
|
|
|
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.6; |
|
|
|
|
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 1.0; |
|
|
|
|
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1.0; |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
else if( m_fInSpecialReload == 1 ) |
|
|
|
|
{ |
|
|
|
|
if( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() ) |
|
|
|
|
return; |
|
|
|
|
// was waiting for gun to move to side
|
|
|
|
|
m_fInSpecialReload = 2; |
|
|
|
|
|
|
|
|
|
if( RANDOM_LONG( 0, 1 ) ) |
|
|
|
|
EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/reload1.wav", 1, ATTN_NORM, 0, 85 + RANDOM_LONG( 0, 0x1f ) ); |
|
|
|
|
else |
|
|
|
|
EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/reload3.wav", 1, ATTN_NORM, 0, 85 + RANDOM_LONG( 0, 0x1f ) ); |
|
|
|
|
|
|
|
|
|
SendWeaponAnim( HANDGRENADE_INSERT ); |
|
|
|
|
|
|
|
|
|
m_flNextReload = UTIL_WeaponTimeBase() + 0.5; |
|
|
|
|
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
// Add them to the clip
|
|
|
|
|
m_iClip += 1; |
|
|
|
|
m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] -= 1; |
|
|
|
|
m_fInSpecialReload = 1; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void CPepsigun::WeaponIdle( void ) |
|
|
|
|
{ |
|
|
|
|
if( m_iClip == 0 && m_fInSpecialReload == 0 && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] ) |
|
|
|
|
{ |
|
|
|
|
Reload(); |
|
|
|
|
} |
|
|
|
|
else if( m_fInSpecialReload != 0 ) |
|
|
|
|
{ |
|
|
|
|
if( m_iClip != 8 && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] ) |
|
|
|
|
{ |
|
|
|
|
Reload(); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
// reload debounce has timed out
|
|
|
|
|
SendWeaponAnim( HANDGRENADE_CLOSE ); |
|
|
|
|
m_fInSpecialReload = 0; |
|
|
|
|
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.5; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if( m_flReleaseThrow == 0 && m_flStartThrow ) |
|
|
|
|
m_flReleaseThrow = gpGlobals->time; |
|
|
|
|
|
|
|
|
@ -135,17 +228,20 @@ void CPepsigun::WeaponIdle( void )
@@ -135,17 +228,20 @@ void CPepsigun::WeaponIdle( void )
|
|
|
|
|
time = 0; |
|
|
|
|
|
|
|
|
|
CGrenade::ShootTimed( m_pPlayer->pev, vecSrc, vecThrow, time ); |
|
|
|
|
|
|
|
|
|
m_iClip--; |
|
|
|
|
if( flVel < 500 ) |
|
|
|
|
{ |
|
|
|
|
EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/pepsigun_shoot.wav", 1, ATTN_NORM ); |
|
|
|
|
SendWeaponAnim( HANDGRENADE_FIRE ); |
|
|
|
|
} |
|
|
|
|
else if( flVel < 1000 ) |
|
|
|
|
{ |
|
|
|
|
EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/pepsigun_shoot.wav", 1, ATTN_NORM ); |
|
|
|
|
SendWeaponAnim( HANDGRENADE_FIRE ); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/pepsigun_shoot.wav", 1, ATTN_NORM ); |
|
|
|
|
SendWeaponAnim( HANDGRENADE_FIRE ); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -200,6 +296,8 @@ void CPepsigun::WeaponIdle( void )
@@ -200,6 +296,8 @@ void CPepsigun::WeaponIdle( void )
|
|
|
|
|
{ |
|
|
|
|
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 75.0 / 30.0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
if( !m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 ) |
|
|
|
|
// HEV suit - indicate out of ammo condition
|
|
|
|
|
m_pPlayer->SetSuitUpdate( "!HEV_AMO0", FALSE, 0 ); |
|
|
|
|
} |
|
|
|
|
} |