Browse Source

More accurate weapons implementation.

clcampaign
Andrey Akhmichin 11 months ago
parent
commit
dc79f4a1a5
  1. 7
      cl_dll/CMakeLists.txt
  2. 283
      cl_dll/ev_hldm.cpp
  3. 29
      cl_dll/ev_hldm.h
  4. 15
      cl_dll/hl/hl_events.cpp
  5. 35
      cl_dll/hl/hl_weapons.cpp
  6. 118
      dlls/clcampaign/hammer.cpp
  7. 157
      dlls/clcampaign/katana.cpp
  8. 41
      dlls/clcampaign/needle.cpp
  9. 169
      dlls/clcampaign/pepsigun.cpp
  10. 107
      dlls/clcampaign/rock.cpp
  11. 258
      dlls/clcampaign/sawnoff.cpp
  12. 291
      dlls/clcampaign/sniper.cpp
  13. 8
      dlls/crossbow.cpp
  14. 26
      dlls/crowbar.cpp
  15. 157
      dlls/ggrenade.cpp
  16. 12
      dlls/hornetgun.cpp
  17. 10
      dlls/mp5.cpp
  18. 8
      dlls/player.cpp
  19. 26
      dlls/rpg.cpp
  20. 42
      dlls/weapons.cpp
  21. 303
      dlls/weapons.h

7
cl_dll/CMakeLists.txt

@ -69,6 +69,13 @@ set (CLDLL_SOURCES @@ -69,6 +69,13 @@ set (CLDLL_SOURCES
../dlls/squeakgrenade.cpp
../dlls/tripmine.cpp
../dlls/glock.cpp
../dlls/clcampaign/hammer.cpp
../dlls/clcampaign/katana.cpp
../dlls/clcampaign/needle.cpp
../dlls/clcampaign/pepsigun.cpp
../dlls/clcampaign/rock.cpp
../dlls/clcampaign/sawnoff.cpp
../dlls/clcampaign/sniper.cpp
ev_hldm.cpp
hl/hl_baseentity.cpp
hl/hl_events.cpp

283
cl_dll/ev_hldm.cpp

@ -70,6 +70,14 @@ void EV_TripmineFire( struct event_args_s *args ); @@ -70,6 +70,14 @@ void EV_TripmineFire( struct event_args_s *args );
void EV_SnarkFire( struct event_args_s *args );
void EV_TrainPitchAdjust( struct event_args_s *args );
void EV_Katana( event_args_t *args );
void EV_FireSnipars( event_args_t *args );
void EV_FirePepsigun( event_args_t *args );
void EV_Hammer( event_args_t *args );
void EV_FireSawnoff( event_args_t *args );
void EV_FireRock( event_args_t *args );
void EV_FireNeedle( event_args_t *args );
}
#define VECTOR_CONE_1DEGREES Vector( 0.00873f, 0.00873f, 0.00873f )
@ -1756,3 +1764,278 @@ int EV_TFC_IsAllyTeam( int iTeam1, int iTeam2 ) @@ -1756,3 +1764,278 @@ int EV_TFC_IsAllyTeam( int iTeam1, int iTeam2 )
{
return 0;
}
//======================
// KATANA START
//======================
enum katana_e
{
KATANA_IDLE = 0,
KATANA_DRAW,
KATANA_HOLSTER,
KATANA_ATTACK1HIT,
KATANA_ATTACK1MISS,
KATANA_ATTACK2MISS,
KATANA_ATTACK2HIT,
KATANA_ATTACK3MISS,
#if !CROWBAR_IDLE_ANIM
KATANA_ATTACK3HIT
#else
KATANA_ATTACK3HIT,
KATANA_IDLE2,
KATANA_IDLE3
#endif
};
// int g_iSwing;
//Only predict the miss sounds, hit sounds are still played
//server side, so players don't get the wrong idea.
void EV_Katana( event_args_t *args )
{
int idx;
vec3_t origin;
//vec3_t angles;
//vec3_t velocity;
idx = args->entindex;
VectorCopy( args->origin, origin );
//Play Swing sound
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/katana_miss1.wav", 1, ATTN_NORM, 0, PITCH_NORM );
if( EV_IsLocal( idx ) )
{
switch( (g_iSwing++) % 3 )
{
case 0:
gEngfuncs.pEventAPI->EV_WeaponAnimation( KATANA_ATTACK1MISS, 0 );
break;
case 1:
gEngfuncs.pEventAPI->EV_WeaponAnimation( KATANA_ATTACK2MISS, 0 );
break;
case 2:
gEngfuncs.pEventAPI->EV_WeaponAnimation( KATANA_ATTACK3MISS, 0 );
break;
}
}
}
//======================
// KATANA END
//======================
//======================
// SNIPARS START
//======================
void EV_FireSnipars( event_args_t *args )
{
int idx;
vec3_t origin;
vec3_t angles;
vec3_t velocity;
vec3_t ShellVelocity;
vec3_t ShellOrigin;
vec3_t vecSrc, vecAiming;
vec3_t up, right, forward;
//float flSpread = 0.01;
idx = args->entindex;
VectorCopy( args->origin, origin );
VectorCopy( args->angles, angles );
VectorCopy( args->velocity, velocity );
AngleVectors( angles, forward, right, up );
if( EV_IsLocal( idx ) )
{
// Add muzzle flash to current weapon model
EV_MuzzleFlash();
gEngfuncs.pEventAPI->EV_WeaponAnimation( SNIPARS_FIRE, 0 );
V_PunchAxis( 0, gEngfuncs.pfnRandomFloat( 0, -10 ) );
}
switch( gEngfuncs.pfnRandomLong( 0, 4 ) )
{
case 0:
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/sniper_shoot1.wav", gEngfuncs.pfnRandomFloat( 0.8f, 0.9f ), ATTN_NORM, 0, PITCH_NORM );
break;
case 1:
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/sniper_shoot2.wav", gEngfuncs.pfnRandomFloat( 0.8f, 0.9f ), ATTN_NORM, 0, PITCH_NORM );
break;
case 2:
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/sniper_shoot3.wav", gEngfuncs.pfnRandomFloat( 0.8f, 0.9f ), ATTN_NORM, 0, PITCH_NORM );
break;
case 3:
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/sniper_shoot4.wav", gEngfuncs.pfnRandomFloat( 0.8f, 0.9f ), ATTN_NORM, 0, PITCH_NORM );
break;
case 4:
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/sniper_shoot5.wav", gEngfuncs.pfnRandomFloat( 0.8f, 0.9f ), ATTN_NORM, 0, PITCH_NORM );
break;
}
EV_GetGunPosition( args, vecSrc, origin );
VectorCopy( forward, vecAiming );
EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_357, 0, &g_tracerCount[idx - 1], args->fparam1, args->fparam2 );
}
//======================
// SNIPARS END
//======================
//======================
// PEPSIGUN START
//======================
void EV_FirePepsigun( event_args_t *args )
{
/*
int idx;
vec3_t origin;
vec3_t angles;
vec3_t velocity;
vec3_t ShellVelocity;
vec3_t ShellOrigin;
int shell;
vec3_t vecSrc, vecAiming;
vec3_t up, right, forward;
idx = args->entindex;
VectorCopy( args->origin, origin );
VectorCopy( args->angles, angles );
VectorCopy( args->velocity, velocity );
AngleVectors( angles, forward, right, up );
EV_GetGunPosition( args, vecSrc, origin );
VectorCopy( forward, vecAiming );
*/
}
//======================
// PEPSIGUN END
//======================
//======================
// HAMMER START
//======================
enum hammer_e
{
HAMMER_IDLE = 0,
HAMMER_DRAW,
HAMMER_ATTACK
};
//Only predict the miss sounds, hit sounds are still played
//server side, so players don't get the wrong idea.
void EV_Hammer( event_args_t *args )
{
int idx;
vec3_t origin;
idx = args->entindex;
VectorCopy( args->origin, origin );
//Play Swing sound
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/cbar_miss1.wav", 1, ATTN_NORM, 0, PITCH_NORM );
if( EV_IsLocal( idx ))
gEngfuncs.pEventAPI->EV_WeaponAnimation( HAMMER_ATTACK, 0 );
}
//======================
// HAMMER END
//======================
//======================
// SAWNOFF START
//======================
void EV_FireSawnoff( event_args_t *args )
{
int idx;
vec3_t origin;
vec3_t angles;
vec3_t velocity;
int j;
vec3_t ShellVelocity;
vec3_t ShellOrigin;
int shell;
vec3_t vecSrc, vecAiming;
vec3_t up, right, forward;
idx = args->entindex;
VectorCopy( args->origin, origin );
VectorCopy( args->angles, angles );
VectorCopy( args->velocity, velocity );
AngleVectors( angles, forward, right, up );
if( EV_IsLocal( idx ) )
{
// Add muzzle flash to current weapon model
EV_MuzzleFlash();
gEngfuncs.pEventAPI->EV_WeaponAnimation( SAWNOFF_FIRE, 0 );
V_PunchAxis( 0, -10.0 );
}
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/sshotgun_shoot.wav", gEngfuncs.pfnRandomFloat( 0.8f, 0.9f ), ATTN_NORM, 0, PITCH_NORM );
EV_GetGunPosition( args, vecSrc, origin );
VectorCopy( forward, vecAiming );
EV_HLDM_FireBullets( idx, forward, right, up, 18, vecSrc, vecAiming, 2048, BULLET_PLAYER_BUCKSHOT, 0, &g_tracerCount[idx - 1], 0.17365, 0.17365 );
}
//======================
// SAWNOFF END
//======================
//======================
// ROCK START
//======================
void EV_FireRock( event_args_t *args )
{
/* int idx;
vec3_t origin;
vec3_t angles;
vec3_t velocity;
vec3_t ShellVelocity;
vec3_t ShellOrigin;
int shell;
vec3_t vecSrc, vecAiming;
vec3_t up, right, forward;
idx = args->entindex;
VectorCopy( args->origin, origin );
VectorCopy( args->angles, angles );
VectorCopy( args->velocity, velocity );
AngleVectors( angles, forward, right, up );
EV_GetGunPosition( args, vecSrc, origin );
VectorCopy( forward, vecAiming );*/
}
//======================
// ROCK END
//======================
//======================
// NEEDLE START
//======================
void EV_FireNeedle( event_args_t *args )
{
int idx;
idx = args->entindex;
if( EV_IsLocal( idx ))
gEngfuncs.pEventAPI->EV_WeaponAnimation( NEEDLE_GIVESHOT, 0 );
}
//======================
// NEEDLE END
//======================

29
cl_dll/ev_hldm.h

@ -92,6 +92,35 @@ enum gauss_e @@ -92,6 +92,35 @@ enum gauss_e
GAUSS_DRAW
};
enum sniper_e
{
SNIPARS_IDLE = 0,
SNIPARS_DRAW,
SNIPARS_FIRE,
SNIPARS_RELOAD
};
enum sawnoff_e
{
SAWNOFF_IDLE = 0,
SAWNOFF_FIRE,
SAWNOFF_FIRE2,
SAWNOFF_RELOAD,
SAWNOFF_PUMP,
SAWNOFF_START_RELOAD,
SAWNOFF_DRAW,
SAWNOFF_HOLSTER,
SAWNOFF_IDLE4,
SAWNOFF_IDLE_DEEP
};
enum needle_e
{
NEEDLE_IDLE1,
NEEDLE_GIVESHOT,
NEEDLE_DRAW
};
void EV_HLDM_GunshotDecalTrace( pmtrace_t *pTrace, char *decalName );
void EV_HLDM_DecalGunshot( pmtrace_t *pTrace, int iBulletType );
int EV_HLDM_CheckTracer( int idx, float *vecSrc, float *end, float *forward, float *right, int iBulletType, int iTracerFreq, int *tracerCount );

15
cl_dll/hl/hl_events.cpp

@ -40,6 +40,14 @@ void EV_TripmineFire( struct event_args_s *args ); @@ -40,6 +40,14 @@ void EV_TripmineFire( struct event_args_s *args );
void EV_SnarkFire( struct event_args_s *args );
void EV_TrainPitchAdjust( struct event_args_s *args );
void EV_Katana( event_args_t *args );
void EV_FireSnipars( event_args_t *args );
void EV_FirePepsigun( event_args_t *args );
void EV_Hammer( event_args_t *args );
void EV_FireSawnoff( event_args_t *args );
void EV_FireRock( event_args_t *args );
void EV_FireNeedle( event_args_t *args );
}
/*
@ -76,4 +84,11 @@ void Game_HookEvents( void ) @@ -76,4 +84,11 @@ void Game_HookEvents( void )
gEngfuncs.pfnHookEvent( "events/firehornet.sc", EV_HornetGunFire );
gEngfuncs.pfnHookEvent( "events/tripfire.sc", EV_TripmineFire );
gEngfuncs.pfnHookEvent( "events/snarkfire.sc", EV_SnarkFire );
gEngfuncs.pfnHookEvent( "events/katana.sc", EV_Katana );
gEngfuncs.pfnHookEvent( "events/snipars.sc", EV_FireSnipars );
gEngfuncs.pfnHookEvent( "events/pepsigun.sc", EV_FirePepsigun );
gEngfuncs.pfnHookEvent( "events/hammer.sc", EV_Hammer );
gEngfuncs.pfnHookEvent( "events/sawnoff.sc", EV_FireSawnoff );
gEngfuncs.pfnHookEvent( "events/rock.sc", EV_FireRock );
gEngfuncs.pfnHookEvent( "events/needle.sc", EV_FireNeedle );
}

35
cl_dll/hl/hl_weapons.cpp

@ -67,6 +67,13 @@ CHandGrenade g_HandGren; @@ -67,6 +67,13 @@ CHandGrenade g_HandGren;
CSatchel g_Satchel;
CTripmine g_Tripmine;
CSqueak g_Snark;
CKatana g_Katana;
CSnipars g_Snipars;
CPepsigun g_Pepsigun;
CHammer g_Hammer;
CSawnoff g_Sawnoff;
CRock g_Rock;
CNeedle g_Needle;
/*
======================
@ -620,6 +627,13 @@ void HUD_InitClientWeapons( void ) @@ -620,6 +627,13 @@ void HUD_InitClientWeapons( void )
HUD_PrepEntity( &g_Satchel, &player );
HUD_PrepEntity( &g_Tripmine, &player );
HUD_PrepEntity( &g_Snark, &player );
HUD_PrepEntity( &g_Katana, &player );
HUD_PrepEntity( &g_Snipars, &player );
HUD_PrepEntity( &g_Pepsigun, &player );
HUD_PrepEntity( &g_Hammer, &player );
HUD_PrepEntity( &g_Sawnoff, &player );
HUD_PrepEntity( &g_Rock, &player );
HUD_PrepEntity( &g_Needle, &player );
}
/*
@ -725,6 +739,27 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm @@ -725,6 +739,27 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm
case WEAPON_SNARK:
pWeapon = &g_Snark;
break;
case WEAPON_KATANA:
pWeapon = &g_Katana;
break;
case WEAPON_SNIPARS:
pWeapon = &g_Snipars;
break;
case WEAPON_PEPSIGUN:
pWeapon = &g_Pepsigun;
break;
case WEAPON_HAMMER:
pWeapon = &g_Hammer;
break;
case WEAPON_SAWNOFF:
pWeapon = &g_Sawnoff;
break;
case WEAPON_ROCK:
pWeapon = &g_Rock;
break;
case WEAPON_NEEDLE:
pWeapon = &g_Needle;
break;
}
// Store pointer to our destination entity_state_t so we can get our origin, etc. from it

118
dlls/clcampaign/hammer.cpp

@ -14,41 +14,13 @@ Dicks @@ -14,41 +14,13 @@ Dicks
#define CROWBAR_BODYHIT_VOLUME 128
#define CROWBAR_WALLHIT_VOLUME 512
class CHammer : public CBasePlayerWeapon
{
public:
void Spawn( void );
void Precache( void );
int iItemSlot( void ) { return 1; }
void EXPORT SwingAgain( void );
void EXPORT Smack( void );
int GetItemInfo(ItemInfo *p);
void PrimaryAttack( void );
int Swing( int fFirst );
BOOL Deploy( void );
void Holster( int skiplocal = 0 );
int m_iSwing;
TraceResult m_trHit;
virtual BOOL UseDecrement( void )
{
#if defined( CLIENT_WEAPONS )
return TRUE;
#else
return FALSE;
#endif
}
private:
};
LINK_ENTITY_TO_CLASS( weapon_hammer, CHammer )
enum crowbar_e
enum hammer_e
{
CROWBAR_IDLE = 0,
CROWBAR_DRAW,
CROWBAR_ATTACK
HAMMER_IDLE = 0,
HAMMER_DRAW,
HAMMER_ATTACK
};
@ -69,6 +41,9 @@ void CHammer::Precache( void ) @@ -69,6 +41,9 @@ void CHammer::Precache( void )
PRECACHE_MODEL( "models/p_hammer.mdl" );
PRECACHE_SOUND( "weapons/hammer_hit.wav" );
PRECACHE_SOUND( "weapons/hammer_hitbod.wav" );
PRECACHE_SOUND( "weapons/cbar_miss1.wav" );
m_usHammer = PRECACHE_EVENT( 1, "events/hammer.sc" );
}
int CHammer::GetItemInfo( ItemInfo *p )
@ -80,15 +55,27 @@ int CHammer::GetItemInfo( ItemInfo *p ) @@ -80,15 +55,27 @@ int CHammer::GetItemInfo( ItemInfo *p )
p->iMaxAmmo2 = -1;
p->iMaxClip = WEAPON_NOCLIP;
p->iSlot = 0;
p->iPosition = 3;
p->iPosition = 2;
p->iId = WEAPON_HAMMER;
p->iWeight = 10;
p->iWeight = HAMMER_WEIGHT;
return 1;
}
int CHammer::AddToPlayer( CBasePlayer *pPlayer )
{
if( CBasePlayerWeapon::AddToPlayer( pPlayer ) )
{
MESSAGE_BEGIN( MSG_ONE, gmsgWeapPickup, NULL, pPlayer->pev );
WRITE_BYTE( m_iId );
MESSAGE_END();
return TRUE;
}
return FALSE;
}
BOOL CHammer::Deploy()
{
return DefaultDeploy( "models/v_hammer.mdl", "models/p_hammer.mdl", CROWBAR_DRAW, "hammer" );
return DefaultDeploy( "models/v_hammer.mdl", "models/p_hammer.mdl", HAMMER_DRAW, "Hammer" );
}
void CHammer::Holster( int skiplocal /* = 0 */ )
@ -96,7 +83,8 @@ void CHammer::Holster( int skiplocal /* = 0 */ ) @@ -96,7 +83,8 @@ void CHammer::Holster( int skiplocal /* = 0 */ )
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1;
}
void FindHullIntersection69( const Vector &vecSrc, TraceResult &tr, float *mins, float *maxs, edict_t *pEntity )
extern void FindHullIntersection( const Vector &vecSrc, TraceResult &tr, float *mins, float *maxs, edict_t *pEntity );
/*void FindHullIntersection( const Vector &vecSrc, TraceResult &tr, float *mins, float *maxs, edict_t *pEntity )
{
int i, j, k;
float distance;
@ -138,14 +126,16 @@ void FindHullIntersection69( const Vector &vecSrc, TraceResult &tr, float *mins, @@ -138,14 +126,16 @@ void FindHullIntersection69( const Vector &vecSrc, TraceResult &tr, float *mins,
}
}
}
}
}*/
void CHammer::PrimaryAttack()
{
if( !Swing( 1 ) )
{
#if !CLIENT_DLL
SetThink( &CCrowbar::SwingAgain );
pev->nextthink = gpGlobals->time + 1;
pev->nextthink = UTIL_WeaponTimeBase() + 0.1f;
#endif
}
}
@ -181,23 +171,25 @@ int CHammer::Swing( int fFirst ) @@ -181,23 +171,25 @@ int CHammer::Swing( int fFirst )
// This is and approximation of the "best" intersection
CBaseEntity *pHit = CBaseEntity::Instance( tr.pHit );
if( !pHit || pHit->IsBSPModel() )
FindHullIntersection69( vecSrc, tr, VEC_DUCK_HULL_MIN, VEC_DUCK_HULL_MAX, m_pPlayer->edict() );
FindHullIntersection( vecSrc, tr, VEC_DUCK_HULL_MIN, VEC_DUCK_HULL_MAX, m_pPlayer->edict() );
vecEnd = tr.vecEndPos; // This is the point on the actual surface (the hull could have hit space)
}
}
#endif
// PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usCrowbar,
//0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0, 0, 0,
// 0.0, 0, 0.0 );
SendWeaponAnim( CROWBAR_ATTACK );
m_pPlayer->pev->effects = (int)(m_pPlayer->pev->effects) | EF_MUZZLEFLASH;
pev->effects |= EF_MUZZLEFLASH;
if( fFirst )
{
PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usHammer,
0.0, g_vecZero, g_vecZero, 0, 0, 0,
0.0, 0, 0.0 );
}
m_pPlayer->pev->effects = (int)(m_pPlayer->pev->effects) | EF_MUZZLEFLASH;
if( tr.flFraction >= 1.0 )
{
if( fFirst )
{
// miss
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 1;
m_flNextPrimaryAttack = GetNextAttackDelay( 1.0f );
// player "shoot" animation
m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
@ -205,7 +197,7 @@ pev->effects |= EF_MUZZLEFLASH; @@ -205,7 +197,7 @@ pev->effects |= EF_MUZZLEFLASH;
}
else
{
SendWeaponAnim( CROWBAR_ATTACK);
SendWeaponAnim( HAMMER_ATTACK );
// player "shoot" animation
m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
@ -215,33 +207,29 @@ pev->effects |= EF_MUZZLEFLASH; @@ -215,33 +207,29 @@ pev->effects |= EF_MUZZLEFLASH;
fDidHit = TRUE;
CBaseEntity *pEntity = CBaseEntity::Instance( tr.pHit );
ClearMultiDamage();
if( ( m_flNextPrimaryAttack + 1 < UTIL_WeaponTimeBase() ) || g_pGameRules->IsMultiplayer() )
{
// first swing does full damage
pEntity->TraceAttack( m_pPlayer->pev, 50, gpGlobals->v_forward, &tr, DMG_CLUB | DMG_ALWAYSGIB );
}
else
{
// subsequent swings do half
pEntity->TraceAttack( m_pPlayer->pev, 50, gpGlobals->v_forward, &tr, DMG_CLUB | DMG_ALWAYSGIB );
}
ApplyMultiDamage( m_pPlayer->pev, m_pPlayer->pev );
// play thwack, smack, or dong sound
float flVol = 1.0;
int fHitWorld = TRUE;
if( pEntity )
{
ClearMultiDamage();
// swing does full damage
pEntity->TraceAttack( m_pPlayer->pev, 400, gpGlobals->v_forward, &tr, DMG_CLUB );
ApplyMultiDamage( m_pPlayer->pev, m_pPlayer->pev );
if( pEntity->Classify() != CLASS_NONE && pEntity->Classify() != CLASS_MACHINE )
{
// play thwack or smack sound
EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/hammer_hitbod.wav", 1, ATTN_NORM );
m_pPlayer->m_iWeaponVolume = CROWBAR_BODYHIT_VOLUME;
if( !pEntity->IsAlive() )
{
#if CROWBAR_FIX_RAPID_CROWBAR
m_flNextPrimaryAttack = GetNextAttackDelay( 1.0f );
#endif
return TRUE;
}
else
flVol = 0.1;
@ -263,18 +251,18 @@ pev->effects |= EF_MUZZLEFLASH; @@ -263,18 +251,18 @@ pev->effects |= EF_MUZZLEFLASH;
fvolbar = 1;
}
EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/hammer_hit.wav", fvolbar, ATTN_NORM, 0, 98 + RANDOM_LONG( 0, 3 ) );
EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/hammer_hit.wav", fvolbar, ATTN_NORM, 0, 98 + RANDOM_LONG( 0, 3 ) );
// delay the decal a bit
m_trHit = tr;
}
m_pPlayer->m_iWeaponVolume = flVol * CROWBAR_WALLHIT_VOLUME;
#endif
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 1;
SetThink( &CCrowbar::Smack );
pev->nextthink = UTIL_WeaponTimeBase() + 0.3;
pev->nextthink = UTIL_WeaponTimeBase() + 1;
#endif
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 1;
}
return fDidHit;
}

157
dlls/clcampaign/katana.cpp

@ -22,45 +22,20 @@ @@ -22,45 +22,20 @@
#include "player.h"
#include "gamerules.h"
#define CROWBAR_BODYHIT_VOLUME 128
#define CROWBAR_WALLHIT_VOLUME 512
#define KATANA_BODYHIT_VOLUME 128
#define KATANA_WALLHIT_VOLUME 512
enum katana_e
{
CROWBAR_IDLE = 0,
CROWBAR_DRAW,
CROWBAR_HOLSTER,
CROWBAR_ATTACK1HIT,
CROWBAR_ATTACK1MISS,
CROWBAR_ATTACK2MISS,
CROWBAR_ATTACK2HIT,
CROWBAR_ATTACK3MISS,
CROWBAR_ATTACK3HIT
};
class CKatana : public CBasePlayerWeapon
{
public:
void Spawn( void );
void Precache( void );
int iItemSlot( void ) { return 1; }
void EXPORT SwingAgain( void );
void EXPORT Smack( void );
int GetItemInfo(ItemInfo *p);
void PrimaryAttack( void );
int Swing( int fFirst );
BOOL Deploy( void );
void Holster( int skiplocal = 0 );
int m_iSwing;
TraceResult m_trHit;
virtual BOOL UseDecrement( void )
{
return FALSE;
}
private:
unsigned short m_usKatana;
KATANA_IDLE = 0,
KATANA_DRAW,
KATANA_HOLSTER,
KATANA_ATTACK1HIT,
KATANA_ATTACK1MISS,
KATANA_ATTACK2MISS,
KATANA_ATTACK2HIT,
KATANA_ATTACK3MISS,
KATANA_ATTACK3HIT
};
LINK_ENTITY_TO_CLASS( weapon_katana, CKatana )
@ -77,19 +52,20 @@ void CKatana::Spawn( ) @@ -77,19 +52,20 @@ void CKatana::Spawn( )
void CKatana::Precache( void )
{
PRECACHE_MODEL( "models/fedora.mdl" );
PRECACHE_MODEL( "models/v_katana.mdl" );
PRECACHE_MODEL( "models/w_katana.mdl" );
PRECACHE_MODEL( "models/p_katana.mdl" );
PRECACHE_SOUND( "weapons/katana_draw.wav" );
PRECACHE_SOUND( "weapons/katana_hit1.wav" );
PRECACHE_SOUND( "weapons/katana_hit2.wav" );
PRECACHE_SOUND( "weapons/katana_hitbod1.wav" );
PRECACHE_SOUND( "weapons/katana_hitbod2.wav" );
PRECACHE_SOUND( "weapons/katana_hitbod3.wav" );
PRECACHE_SOUND( "weapons/katana_tip.wav" );
PRECACHE_SOUND( "weapons/katana_miss1.wav" );
PRECACHE_SOUND( "weapons/katana_draw.wav" );
m_usKatana = PRECACHE_EVENT( 1, "events/crowbar.sc" );
m_usKatana = PRECACHE_EVENT( 1, "events/katana.sc" );
}
int CKatana::GetItemInfo( ItemInfo *p )
@ -101,25 +77,39 @@ int CKatana::GetItemInfo( ItemInfo *p ) @@ -101,25 +77,39 @@ int CKatana::GetItemInfo( ItemInfo *p )
p->iMaxAmmo2 = -1;
p->iMaxClip = WEAPON_NOCLIP;
p->iSlot = 0;
p->iPosition = 2;
p->iPosition = 1;
p->iId = WEAPON_KATANA;
p->iWeight = CROWBAR_WEIGHT;
p->iWeight = KATANA_WEIGHT;
return 1;
}
int CKatana::AddToPlayer( CBasePlayer *pPlayer )
{
if( CBasePlayerWeapon::AddToPlayer( pPlayer ) )
{
MESSAGE_BEGIN( MSG_ONE, gmsgWeapPickup, NULL, pPlayer->pev );
WRITE_BYTE( m_iId );
MESSAGE_END();
return TRUE;
}
return FALSE;
}
BOOL CKatana::Deploy()
{
EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/katana_draw.wav", 1, ATTN_NORM );
return DefaultDeploy( "models/v_katana.mdl", "models/p_katana.mdl", CROWBAR_DRAW, "crowbar" );;
return DefaultDeploy( "models/v_katana.mdl", "models/p_katana.mdl", KATANA_DRAW, "katana" );
}
void CKatana::Holster( int skiplocal /* = 0 */ )
{
m_pPlayer->m_flNextAttack = gpGlobals->time + 0.5;
SendWeaponAnim( CROWBAR_HOLSTER );
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5f;
SendWeaponAnim( KATANA_HOLSTER );
}
void FindHullIntersection3( const Vector &vecSrc, TraceResult &tr, float *mins, float *maxs, edict_t *pEntity )
extern void FindHullIntersection( const Vector &vecSrc, TraceResult &tr, float *mins, float *maxs, edict_t *pEntity );
/*void FindHullIntersection( const Vector &vecSrc, TraceResult &tr, float *mins, float *maxs, edict_t *pEntity )
{
int i, j, k;
float distance;
@ -132,7 +122,7 @@ void FindHullIntersection3( const Vector &vecSrc, TraceResult &tr, float *mins, @@ -132,7 +122,7 @@ void FindHullIntersection3( const Vector &vecSrc, TraceResult &tr, float *mins,
vecHullEnd = vecSrc + ( ( vecHullEnd - vecSrc ) * 2 );
UTIL_TraceLine( vecSrc, vecHullEnd, dont_ignore_monsters, pEntity, &tmpTrace );
if( tmpTrace.flFraction < 1.0 )
if( tmpTrace.flFraction < 1.0f )
{
tr = tmpTrace;
return;
@ -149,7 +139,7 @@ void FindHullIntersection3( const Vector &vecSrc, TraceResult &tr, float *mins, @@ -149,7 +139,7 @@ void FindHullIntersection3( const Vector &vecSrc, TraceResult &tr, float *mins,
vecEnd.z = vecHullEnd.z + minmaxs[k][2];
UTIL_TraceLine( vecSrc, vecEnd, dont_ignore_monsters, pEntity, &tmpTrace );
if( tmpTrace.flFraction < 1.0 )
if( tmpTrace.flFraction < 1.0f )
{
float thisDistance = ( tmpTrace.vecEndPos - vecSrc ).Length();
if( thisDistance < distance )
@ -161,14 +151,16 @@ void FindHullIntersection3( const Vector &vecSrc, TraceResult &tr, float *mins, @@ -161,14 +151,16 @@ void FindHullIntersection3( const Vector &vecSrc, TraceResult &tr, float *mins,
}
}
}
}
}*/
void CKatana::PrimaryAttack()
{
if( !Swing( 1 ) )
{
#if !CLIENT_DLL
SetThink( &CKatana::SwingAgain );
pev->nextthink = gpGlobals->time + 0.1;
pev->nextthink = UTIL_WeaponTimeBase() + 0.6f;
#endif
}
}
@ -195,30 +187,33 @@ int CKatana::Swing( int fFirst ) @@ -195,30 +187,33 @@ int CKatana::Swing( int fFirst )
UTIL_TraceLine( vecSrc, vecEnd, dont_ignore_monsters, ENT( m_pPlayer->pev ), &tr );
#ifndef CLIENT_DLL
if( tr.flFraction >= 1.0 )
if( tr.flFraction >= 1.0f )
{
UTIL_TraceHull( vecSrc, vecEnd, dont_ignore_monsters, head_hull, ENT( m_pPlayer->pev ), &tr );
if( tr.flFraction < 1.0 )
if( tr.flFraction < 1.0f )
{
// Calculate the point of intersection of the line (or hull) and the object we hit
// This is and approximation of the "best" intersection
CBaseEntity *pHit = CBaseEntity::Instance( tr.pHit );
if( !pHit || pHit->IsBSPModel() )
FindHullIntersection3( vecSrc, tr, VEC_DUCK_HULL_MIN, VEC_DUCK_HULL_MAX, m_pPlayer->edict() );
FindHullIntersection( vecSrc, tr, VEC_DUCK_HULL_MIN, VEC_DUCK_HULL_MAX, m_pPlayer->edict() );
vecEnd = tr.vecEndPos; // This is the point on the actual surface (the hull could have hit space)
}
}
#endif
PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usKatana,
0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0, 0, 0,
0.0, 0, 0.0 );
if( fFirst )
{
PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usKatana,
0.0, g_vecZero, g_vecZero, 0, 0, 0,
0.0, 0, 0.0 );
}
if( tr.flFraction >= 1.0 )
{
if( fFirst )
{
// miss
m_flNextPrimaryAttack = gpGlobals->time + 0.5;
m_flNextPrimaryAttack = GetNextAttackDelay( 0.6f );
// player "shoot" animation
m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
@ -229,13 +224,13 @@ int CKatana::Swing( int fFirst ) @@ -229,13 +224,13 @@ int CKatana::Swing( int fFirst )
switch( ( ( m_iSwing++ ) % 2 ) + 1 )
{
case 0:
SendWeaponAnim( CROWBAR_ATTACK1HIT );
SendWeaponAnim( KATANA_ATTACK1HIT );
break;
case 1:
SendWeaponAnim( CROWBAR_ATTACK2HIT );
SendWeaponAnim( KATANA_ATTACK2HIT );
break;
case 2:
SendWeaponAnim( CROWBAR_ATTACK3HIT );
SendWeaponAnim( KATANA_ATTACK3HIT );
break;
}
@ -247,26 +242,18 @@ int CKatana::Swing( int fFirst ) @@ -247,26 +242,18 @@ int CKatana::Swing( int fFirst )
fDidHit = TRUE;
CBaseEntity *pEntity = CBaseEntity::Instance( tr.pHit );
ClearMultiDamage();
if( ( m_flNextPrimaryAttack + 1 < gpGlobals->time ) || g_pGameRules->IsMultiplayer() )
{
// first swing does full damage
pEntity->TraceAttack( m_pPlayer->pev, gSkillData.plrDmgCrowbar, gpGlobals->v_forward, &tr, DMG_CLUB );
}
else
{
// subsequent swings do half
pEntity->TraceAttack( m_pPlayer->pev, 30, gpGlobals->v_forward, &tr, DMG_CLUB );
}
ApplyMultiDamage( m_pPlayer->pev, m_pPlayer->pev );
// play thwack, smack, or dong sound
float flVol = 1.0;
int fHitWorld = TRUE;
if( pEntity )
{
ClearMultiDamage();
// swing does full damage
pEntity->TraceAttack( m_pPlayer->pev, 85, gpGlobals->v_forward, &tr, DMG_CLUB );
ApplyMultiDamage( m_pPlayer->pev, m_pPlayer->pev );
if( pEntity->Classify() != CLASS_NONE && pEntity->Classify() != CLASS_MACHINE )
{
// play thwack or smack sound
@ -282,9 +269,14 @@ int CKatana::Swing( int fFirst ) @@ -282,9 +269,14 @@ int CKatana::Swing( int fFirst )
EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/katana_hitbod3.wav", 1, ATTN_NORM );
break;
}
m_pPlayer->m_iWeaponVolume = CROWBAR_BODYHIT_VOLUME;
m_pPlayer->m_iWeaponVolume = KATANA_BODYHIT_VOLUME;
if( !pEntity->IsAlive() )
{
#if CROWBAR_FIX_RAPID_CROWBAR
m_flNextPrimaryAttack = GetNextAttackDelay( 0.6f );
#endif
return TRUE;
}
else
flVol = 0.1;
@ -322,12 +314,21 @@ int CKatana::Swing( int fFirst ) @@ -322,12 +314,21 @@ int CKatana::Swing( int fFirst )
m_trHit = tr;
}
m_pPlayer->m_iWeaponVolume = flVol * CROWBAR_WALLHIT_VOLUME;
#endif
m_flNextPrimaryAttack = gpGlobals->time + 0.25;
m_pPlayer->m_iWeaponVolume = flVol * KATANA_WALLHIT_VOLUME;
SetThink( &CKatana::Smack );
pev->nextthink = gpGlobals->time + 0.2;
pev->nextthink = UTIL_WeaponTimeBase() + 0.6f;
#endif
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.6f;
}
return fDidHit;
}
void CKatana::SecondaryAttack( void )
{
EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/katana_tip.wav", 1, ATTN_NORM );
#if !CLIENT_DLL
CGrenadeFedora::ShootContact( m_pPlayer->pev, m_pPlayer->pev->origin + m_pPlayer->pev->view_ofs + gpGlobals->v_forward * 15, gpGlobals->v_forward * 512 );
#endif
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 2.0f;
}

41
dlls/clcampaign/needle.cpp

@ -22,33 +22,6 @@ @@ -22,33 +22,6 @@
#include "player.h"
#include "gamerules.h"
#define NEEDLE_BODYHIT_VOLUME 128
#define NEEDLE_WALLHIT_VOLUME 512
class CNeedle : public CBasePlayerWeapon
{
public:
void Spawn( void );
void Precache( void );
int iItemSlot( void ) { return 1; }
int GetItemInfo(ItemInfo *p);
void PrimaryAttack( void );
BOOL Deploy( void );
void Holster( int skiplocal = 0 );
virtual BOOL UseDecrement( void )
{
#if defined( CLIENT_WEAPONS )
return TRUE;
#else
return FALSE;
#endif
}
private:
};
LINK_ENTITY_TO_CLASS( weapon_needle, CNeedle )
enum needle_e
@ -75,6 +48,8 @@ void CNeedle::Precache( void ) @@ -75,6 +48,8 @@ void CNeedle::Precache( void )
PRECACHE_MODEL( "models/w_needle.mdl" );
PRECACHE_MODEL( "models/p_needle.mdl" );
PRECACHE_SOUND( "weapons/needleshot.wav" );
m_usNeedle = PRECACHE_EVENT( 1, "events/needle.sc" );
}
int CNeedle::GetItemInfo( ItemInfo *p )
@ -86,9 +61,9 @@ int CNeedle::GetItemInfo( ItemInfo *p ) @@ -86,9 +61,9 @@ int CNeedle::GetItemInfo( ItemInfo *p )
p->iMaxAmmo2 = -1;
p->iMaxClip = WEAPON_NOCLIP;
p->iSlot = 0;
p->iPosition = 1;
p->iPosition = 3;
p->iId = WEAPON_NEEDLE;
p->iWeight = CROWBAR_WEIGHT;
p->iWeight = NEEDLE_WEIGHT;
return 1;
}
@ -99,15 +74,15 @@ BOOL CNeedle::Deploy() @@ -99,15 +74,15 @@ BOOL CNeedle::Deploy()
void CNeedle::Holster( int skiplocal /* = 0 */ )
{
m_pPlayer->m_flNextAttack = gpGlobals->time + 1;
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5f;
SendWeaponAnim( NEEDLE_IDLE1 );
}
void CNeedle::PrimaryAttack()
{
SendWeaponAnim( NEEDLE_GIVESHOT );
EMIT_SOUND( ENT( pev ), CHAN_ITEM, "weapons/needleshot.wav", 1, ATTN_NORM );
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 8;
EMIT_SOUND( ENT( pev ), CHAN_ITEM, "weapons/needleshot.wav", 1, ATTN_NORM );
m_pPlayer->TakeHealth( 25, DMG_GENERIC );
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 60.0f;
}

169
dlls/clcampaign/pepsigun.cpp

@ -7,43 +7,14 @@ @@ -7,43 +7,14 @@
#include "player.h"
#include "gamerules.h"
#define WEAPON_PEPSIGUN 21
class CPepsigun : public CBasePlayerWeapon
enum pepsigun_e
{
public:
void Spawn( void );
void Precache( void );
int iItemSlot( ) { return 3; }
int GetItemInfo(ItemInfo *p);
int AddToPlayer( CBasePlayer *pPlayer );
void PrimaryAttack( void );
BOOL Deploy( );
void Reload( void );
void WeaponIdle( void );
int m_fInReload;
float m_flNextReload;
virtual BOOL UseDecrement( void )
{
#if defined( CLIENT_WEAPONS )
return TRUE;
#else
return FALSE;
#endif
}
private:
};
enum shotgun_e
{
SHOTGUN_IDLE = 0,
SHOTGUN_FIRE,
SHOTGUN_OPEN,
SHOTGUN_INSERT,
SHOTGUN_CLOSE,
SHOTGUN_DRAW
PEPSIGUN_IDLE = 0,
PEPSIGUN_FIRE,
PEPSIGUN_OPEN,
PEPSIGUN_INSERT,
PEPSIGUN_CLOSE,
PEPSIGUN_DRAW
};
LINK_ENTITY_TO_CLASS( weapon_pepsigun, CPepsigun )
@ -54,7 +25,7 @@ void CPepsigun::Spawn() @@ -54,7 +25,7 @@ void CPepsigun::Spawn()
m_iId = WEAPON_PEPSIGUN;
SET_MODEL( ENT( pev ), "models/w_pepsigun.mdl" );
m_iDefaultAmmo = HANDGRENADE_DEFAULT_GIVE;
m_iDefaultAmmo = PEPSIGUN_DEFAULT_GIVE;
FallInit();// get ready to fall
}
@ -62,27 +33,26 @@ void CPepsigun::Spawn() @@ -62,27 +33,26 @@ void CPepsigun::Spawn()
void CPepsigun::Precache( void )
{
PRECACHE_MODEL( "models/v_pepsigun.mdl" );
PRECACHE_MODEL( "models/w_grenade.mdl" );
PRECACHE_MODEL( "models/w_pepsigun.mdl" );
PRECACHE_MODEL( "models/p_pepsigun.mdl" );
PRECACHE_SOUND( "items/9mmclip1.wav" );
PRECACHE_SOUND( "weapons/dbarrel1.wav" );//shotgun
PRECACHE_SOUND( "weapons/pepsigun_shoot.wav" );//shotgun
PRECACHE_SOUND( "weapons/reload1.wav" ); // shotgun reload
PRECACHE_SOUND( "weapons/reload3.wav" ); // shotgun reload
//PRECACHE_SOUND( "weapons/sshell1.wav" ); // shotgun reload - played on client
//PRECACHE_SOUND( "weapons/sshell3.wav" ); // shotgun reload - played on client
PRECACHE_SOUND( "weapons/357_cock1.wav" ); // gun empty sound
PRECACHE_SOUND( "weapons/scock1.wav" ); // cock gun
m_usPepsigun = PRECACHE_EVENT( 1, "events/pepsigun.sc" );
}
int CPepsigun::AddToPlayer( CBasePlayer *pPlayer )
{
if( CBasePlayerWeapon::AddToPlayer( pPlayer ) )
if( CBasePlayerWeapon::AddToPlayer( pPlayer ))
{
MESSAGE_BEGIN( MSG_ONE, gmsgWeapPickup, NULL, pPlayer->pev );
WRITE_BYTE( m_iId );
@ -96,56 +66,79 @@ int CPepsigun::GetItemInfo( ItemInfo *p ) @@ -96,56 +66,79 @@ int CPepsigun::GetItemInfo( ItemInfo *p )
{
p->pszName = STRING( pev->classname );
p->pszAmmo1 = "Hand Grenade";
p->iMaxAmmo1 = HANDGRENADE_MAX_CARRY;
p->iMaxAmmo1 = PEPSIGUN_MAX_CARRY;
p->pszAmmo2 = NULL;
p->iMaxAmmo2 = -1;
p->iMaxClip = 8;
p->iSlot = 2;
p->iMaxClip = PEPSIGUN_MAX_CLIP;
p->iSlot = 4;
p->iPosition = 4;
p->iFlags = 0;
p->iId = m_iId = WEAPON_PEPSIGUN;
p->iWeight = SHOTGUN_WEIGHT;
p->iWeight = PEPSIGUN_WEIGHT;
return 1;
}
BOOL CPepsigun::Deploy()
{
return DefaultDeploy( "models/v_pepsigun.mdl", "models/p_pepsigun.mdl", SHOTGUN_DRAW, "shotgun" );
return DefaultDeploy( "models/v_pepsigun.mdl", "models/p_pepsigun.mdl", PEPSIGUN_DRAW, "pepsigun" );
}
void CPepsigun::PrimaryAttack()
{
m_iClip--;
Vector angThrow = m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle;
// don't fire underwater
if( m_pPlayer->pev->waterlevel == 3 )
{
PlayEmptySound();
m_flNextPrimaryAttack = GetNextAttackDelay( 0.15f );
return;
}
if( angThrow.x < 0 )
angThrow.x = -10 + angThrow.x * ( ( 90 - 10 ) / 90.0 );
else
angThrow.x = -10 + angThrow.x * ( ( 90 + 10 ) / 90.0 );
if( m_iClip <= 0 )
{
Reload();
if( m_iClip == 0 )
PlayEmptySound();
return;
}
float flVel = ( 90 - angThrow.x ) * 4;
if( flVel > 500 )
flVel = 500;
m_pPlayer->m_iWeaponVolume = LOUD_GUN_VOLUME;
m_pPlayer->m_iWeaponFlash = NORMAL_GUN_FLASH;
m_iClip--;
int flags;
#if CLIENT_WEAPONS
flags = FEV_NOTHOST;
#else
flags = 0;
#endif
m_pPlayer->pev->effects = (int)( m_pPlayer->pev->effects ) | EF_MUZZLEFLASH;
UTIL_MakeVectors( angThrow );
// player "shoot" animation
m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
Vector vecSrc = m_pPlayer->pev->origin + m_pPlayer->pev->view_ofs + gpGlobals->v_forward * 16;
SendWeaponAnim( PEPSIGUN_FIRE );
Vector vecThrow = gpGlobals->v_forward * flVel + m_pPlayer->pev->velocity;
CGrenade::ShootTimed( m_pPlayer->pev, vecSrc, vecThrow*2, 3 );
SendWeaponAnim( SHOTGUN_FIRE );
EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/pepsigun_shoot.wav", 1, ATTN_NORM, 0, 95 + RANDOM_LONG( 0, 0x1f ) );
#if !CLIENT_DLL
CGrenade::ShootTimed( m_pPlayer->pev, m_pPlayer->pev->origin + gpGlobals->v_forward * 34 + Vector( 0, 0, 32 ), gpGlobals->v_forward * 800, 2.5 );
#endif
if( !m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 )
// HEV suit - indicate out of ammo condition
m_pPlayer->SetSuitUpdate( "!HEV_AMO0", FALSE, 0 );
EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/pepsigun_shoot.wav", 1, ATTN_NORM, 0, 85 + RANDOM_LONG( 0, 0x1f ) );
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.75;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.75;
m_flNextPrimaryAttack = GetNextAttackDelay( 0.75f );
if( m_iClip != 0 )
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 5.0f;
else
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.75f;
m_fInSpecialReload = 0;
}
void CPepsigun::Reload( void )
{
if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 || m_iClip == SHOTGUN_MAX_CLIP )
if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 || m_iClip == PEPSIGUN_MAX_CLIP )
return;
// don't reload until recoil is done
@ -155,12 +148,11 @@ void CPepsigun::Reload( void ) @@ -155,12 +148,11 @@ void CPepsigun::Reload( void )
// check to see if we're ready to reload
if( m_fInSpecialReload == 0 )
{
SendWeaponAnim( SHOTGUN_OPEN );
SendWeaponAnim( PEPSIGUN_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;
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.6f;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.6f;
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 1.0f;
return;
}
else if( m_fInSpecialReload == 1 )
@ -175,10 +167,10 @@ void CPepsigun::Reload( void ) @@ -175,10 +167,10 @@ void CPepsigun::Reload( void )
else
EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/reload3.wav", 1, ATTN_NORM, 0, 85 + RANDOM_LONG( 0, 0x1f ) );
SendWeaponAnim( SHOTGUN_INSERT );
SendWeaponAnim( PEPSIGUN_INSERT );
m_flNextReload = UTIL_WeaponTimeBase() + 0.5;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5;
m_flNextReload = UTIL_WeaponTimeBase() + 0.5f;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5f;
}
else
{
@ -195,13 +187,6 @@ void CPepsigun::WeaponIdle( void ) @@ -195,13 +187,6 @@ void CPepsigun::WeaponIdle( void )
m_pPlayer->GetAutoaimVector( AUTOAIM_5DEGREES );
if( m_flPumpTime && m_flPumpTime < gpGlobals->time )
{
// play pumping sound
EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/scock1.wav", 1, ATTN_NORM, 0, 95 + RANDOM_LONG( 0, 0x1f ) );
m_flPumpTime = 0;
}
if( m_flTimeWeaponIdle < UTIL_WeaponTimeBase() )
{
if( m_iClip == 0 && m_fInSpecialReload == 0 && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] )
@ -217,32 +202,32 @@ void CPepsigun::WeaponIdle( void ) @@ -217,32 +202,32 @@ void CPepsigun::WeaponIdle( void )
else
{
// reload debounce has timed out
SendWeaponAnim( SHOTGUN_CLOSE );
SendWeaponAnim( PEPSIGUN_CLOSE );
m_fInSpecialReload = 0;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.5;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.5f;
}
}
else
{
int iAnim;
float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0, 1 );
if( flRand <= 0.8 )
if( flRand <= 0.8f )
{
iAnim = SHOTGUN_IDLE;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + ( 60.0 / 12.0 );// * RANDOM_LONG( 2, 5 );
iAnim = PEPSIGUN_IDLE;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + ( 60.0f / 12.0f );// * RANDOM_LONG( 2, 5 );
}
else if( flRand <= 0.95 )
else if( flRand <= 0.95f )
{
iAnim = SHOTGUN_IDLE;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + ( 20.0 / 9.0 );
iAnim = PEPSIGUN_IDLE;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + ( 20.0f / 9.0f );
}
else
{
iAnim = SHOTGUN_IDLE;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + ( 20.0 / 9.0 );
iAnim = PEPSIGUN_IDLE;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + ( 20.0f / 9.0f );
}
SendWeaponAnim( iAnim );
}
}
}
}

107
dlls/clcampaign/rock.cpp

@ -22,34 +22,14 @@ @@ -22,34 +22,14 @@
#include "player.h"
#include "gamerules.h"
// special deathmatch shotgun spreads
#define VECTOR_CONE_DM_SHOTGUN Vector( 0.08716, 0.04362, 0.00 )// 10 degrees by 5 degrees
#define VECTOR_CONE_DM_DOUBLESHOTGUN Vector( 0.17365, 0.04362, 0.00 ) // 20 degrees by 5 degrees
#define WEAPON_ROCK 20
enum shotgun_e
{
PEPSIGUN_IDLE = 0,
PEPSIGUN_THROW,
PEPSIGUN_DRAW,
PEPSIGUN_FIDGET
};
class CRock : public CBasePlayerWeapon
enum rock_e
{
public:
void Spawn( void );
void Precache( void );
int iItemSlot( void ) { return 4; }
int GetItemInfo(ItemInfo *p);
void PrimaryAttack( void );
BOOL Deploy( void );
void WeaponIdle( void );
virtual BOOL UseDecrement( void ){ return FALSE; }
ROCK_IDLE = 0,
ROCK_THROW,
ROCK_DRAW,
ROCK_FIDGET
};
LINK_ENTITY_TO_CLASS( weapon_rock, CRock )
void CRock::Spawn()
@ -58,7 +38,7 @@ void CRock::Spawn() @@ -58,7 +38,7 @@ void CRock::Spawn()
m_iId = WEAPON_ROCK;
SET_MODEL( ENT( pev ), "models/w_rock.mdl" );
m_iDefaultAmmo = PEPSIGUN_DEFAULT_GIVE;
//m_iDefaultAmmo = PEPSIGUN_DEFAULT_GIVE;
FallInit();// get ready to fall
}
@ -68,6 +48,9 @@ void CRock::Precache( void ) @@ -68,6 +48,9 @@ void CRock::Precache( void )
PRECACHE_MODEL( "models/v_rock.mdl" );
PRECACHE_MODEL( "models/w_rock.mdl" );
PRECACHE_MODEL( "models/p_rock.mdl" );
PRECACHE_SOUND( "items/9mmclip1.wav" );
m_usRock = PRECACHE_EVENT( 1, "events/rock.sc" );
}
@ -75,49 +58,32 @@ int CRock::GetItemInfo( ItemInfo *p ) @@ -75,49 +58,32 @@ int CRock::GetItemInfo( ItemInfo *p )
{
p->pszName = STRING( pev->classname );
p->pszAmmo1 = NULL;
p->iMaxAmmo1 = HANDGRENADE_MAX_CARRY;
p->iMaxAmmo1 = -1;
p->pszAmmo2 = NULL;
p->iMaxAmmo2 = -1;
p->iMaxClip = 8;
p->iSlot = 4;
p->iMaxClip = WEAPON_NOCLIP;
p->iSlot = 3;
p->iPosition = 4;
p->iFlags = 0;
p->iId = m_iId = WEAPON_ROCK;
p->iWeight = 16;
p->iWeight = ROCK_WEIGHT;
return 1;
}
BOOL CRock::Deploy()
{
return DefaultDeploy( "models/v_rock.mdl", "models/p_rock.mdl", PEPSIGUN_DRAW, "crowbar" );
return DefaultDeploy( "models/v_rock.mdl", "models/p_rock.mdl", ROCK_DRAW, "rock" );
}
void CRock::PrimaryAttack()
{
Vector angThrow = m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle;
if( angThrow.x < 0 )
angThrow.x = -10 + angThrow.x * ( ( 90 - 10 ) / 90.0 );
else
angThrow.x = -10 + angThrow.x * ( ( 90 + 10 ) / 90.0 );
float flVel = ( 90 - angThrow.x ) * 4;
if( flVel > 500 )
flVel = 1300;
UTIL_MakeVectors( angThrow );
Vector vecSrc = m_pPlayer->pev->origin + m_pPlayer->pev->view_ofs + gpGlobals->v_forward * 16;
Vector vecThrow = gpGlobals->v_forward * flVel + m_pPlayer->pev->velocity;
CGrenadeRock::ShootTimed( m_pPlayer->pev, vecSrc, vecThrow * 1.5, 300000000000 );
SendWeaponAnim( PEPSIGUN_THROW );
SendWeaponAnim( ROCK_THROW );
m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
m_flNextPrimaryAttack = gpGlobals->time + 0.5;
m_flNextSecondaryAttack = gpGlobals->time + 0.75;
m_flTimeWeaponIdle = gpGlobals->time + 0.75;
m_fInSpecialReload = 0;
#if !CLIENT_DLL
CGrenade::ShootRock( m_pPlayer->pev, m_pPlayer->pev->origin + gpGlobals->v_forward * 34 + Vector( 0, 0, 32 ), gpGlobals->v_forward * 800 );
#endif
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.75f;
}
@ -126,39 +92,6 @@ void CRock::WeaponIdle( void ) @@ -126,39 +92,6 @@ void CRock::WeaponIdle( void )
ResetEmptySound();
m_pPlayer->GetAutoaimVector( AUTOAIM_5DEGREES );
if( m_flPumpTime && m_flPumpTime < gpGlobals->time )
{
m_flPumpTime = 0;
}
if( m_flTimeWeaponIdle < gpGlobals->time )
{
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
{
m_fInSpecialReload = 0;
m_flTimeWeaponIdle = gpGlobals->time + 1.5;
}
}
else
{
int iAnim;
float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0, 1 );
iAnim = PEPSIGUN_IDLE;
m_flTimeWeaponIdle = gpGlobals->time + ( 20.0 / 9.0 );
SendWeaponAnim( iAnim );
}
}
SendWeaponAnim( ROCK_IDLE );
}

258
dlls/clcampaign/sawnoff.cpp

@ -22,10 +22,6 @@ @@ -22,10 +22,6 @@
#include "player.h"
#include "gamerules.h"
// special deathmatch shotgun spreads
#define VECTOR_CONE_DM_SAWNOFF Vector( 1, 0.9, 0.00 )// 10 degrees by 5 degrees
#define VECTOR_CONE_DM_DOUBLESAWNOFF Vector( 1, 0.9, 0.00 ) // 20 degrees by 5 degre
enum sawnoff_e
{
SAWNOFF_IDLE = 0,
@ -40,35 +36,6 @@ enum sawnoff_e @@ -40,35 +36,6 @@ enum sawnoff_e
SAWNOFF_IDLE_DEEP
};
class CSawnoff : public CBasePlayerWeapon
{
public:
void Spawn( void );
void Precache( void );
int iItemSlot( ) { return 3; }
int GetItemInfo(ItemInfo *p);
int AddToPlayer( CBasePlayer *pPlayer );
void PrimaryAttack( void );
void SecondaryAttack( void );
BOOL Deploy( );
void Reload( void );
void WeaponIdle( void );
int m_fInReload;
float m_flNextReload;
int m_iShell;
virtual BOOL UseDecrement( void )
{
return FALSE;
}
private:
unsigned short m_usDoubleFire;
unsigned short m_usSingleFire;
};
LINK_ENTITY_TO_CLASS( weapon_sawnoff, CSawnoff )
void CSawnoff::Spawn()
@ -87,25 +54,20 @@ void CSawnoff::Precache( void ) @@ -87,25 +54,20 @@ void CSawnoff::Precache( void )
PRECACHE_MODEL( "models/v_sawnoff.mdl" );
PRECACHE_MODEL( "models/w_sawnoff.mdl" );
PRECACHE_MODEL( "models/p_sawnoff.mdl" );
m_iShell = PRECACHE_MODEL( "models/shotgunshell.mdl" );// shotgun shell
PRECACHE_MODEL( "models/w_shotbox.mdl" );
PRECACHE_SOUND( "items/9mmclip1.wav" );
PRECACHE_SOUND( "weapons/dbarrel1.wav" );//shotgun
PRECACHE_SOUND( "weapons/sbarrel1.wav" );//shotgun
PRECACHE_SOUND( "weapons/reload1.wav" ); // shotgun reload
PRECACHE_SOUND( "weapons/reload3.wav" ); // shotgun reload
//PRECACHE_SOUND( "weapons/sshell1.wav" ); // shotgun reload - played on client
//PRECACHE_SOUND( "weapons/sshell3.wav" ); // shotgun reload - played on client
PRECACHE_SOUND( "weapons/sshotgun_shoot.wav" );//shotgun
PRECACHE_SOUND( "weapons/sshotgun_reload.wav" );//shotgun reload
PRECACHE_SOUND( "weapons/sshotgun_cock1.wav" );
PRECACHE_SOUND( "weapons/sshotgun_cock2.wav" );
PRECACHE_SOUND( "weapons/sshotgun_cock3.wav" );
PRECACHE_SOUND( "weapons/357_cock1.wav" ); // gun empty sound
PRECACHE_SOUND( "weapons/scock1.wav" ); // cock gun
//PRECACHE_SOUND( "weapons/357_cock1.wav" ); // gun empty sound
//PRECACHE_SOUND( "weapons/scock1.wav" ); // cock gun
m_usSingleFire = PRECACHE_EVENT( 1, "events/shotgun1.sc" );
m_usDoubleFire = PRECACHE_EVENT( 1, "events/shotgun2.sc" );
m_usSawnoff = PRECACHE_EVENT( 1, "events/sawnoff.sc" );
}
int CSawnoff::AddToPlayer( CBasePlayer *pPlayer )
@ -123,7 +85,7 @@ int CSawnoff::AddToPlayer( CBasePlayer *pPlayer ) @@ -123,7 +85,7 @@ int CSawnoff::AddToPlayer( CBasePlayer *pPlayer )
int CSawnoff::GetItemInfo( ItemInfo *p )
{
p->pszName = STRING( pev->classname );
p->pszAmmo1 = "BUCKSHOT";
p->pszAmmo1 = "buckshot";
p->iMaxAmmo1 = BUCKSHOT_MAX_CARRY;
p->pszAmmo2 = NULL;
p->iMaxAmmo2 = -1;
@ -139,7 +101,7 @@ int CSawnoff::GetItemInfo( ItemInfo *p ) @@ -139,7 +101,7 @@ int CSawnoff::GetItemInfo( ItemInfo *p )
BOOL CSawnoff::Deploy()
{
return DefaultDeploy( "models/v_sawnoff.mdl", "models/p_sawnoff.mdl", SAWNOFF_DRAW, "shotgun" );
return DefaultDeploy( "models/v_sawnoff.mdl", "models/p_sawnoff.mdl", SAWNOFF_DRAW, "Sawnoff" );
}
void CSawnoff::PrimaryAttack()
@ -148,82 +110,15 @@ void CSawnoff::PrimaryAttack() @@ -148,82 +110,15 @@ void CSawnoff::PrimaryAttack()
if( m_pPlayer->pev->waterlevel == 3 )
{
PlayEmptySound();
m_flNextPrimaryAttack = gpGlobals->time + 0.15;
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.15f;
return;
}
if( m_iClip <= 0 )
{
Reload();
if( m_iClip == 0 )
PlayEmptySound();
return;
}
m_pPlayer->m_iWeaponVolume = LOUD_GUN_VOLUME;
m_pPlayer->m_iWeaponFlash = NORMAL_GUN_FLASH;
m_iClip--;
int flags;
#if defined( CLIENT_WEAPONS )
flags = FEV_NOTHOST;
#else
flags = 0;
#endif
m_pPlayer->pev->effects = (int)( m_pPlayer->pev->effects ) | EF_MUZZLEFLASH;
Vector vecSrc = m_pPlayer->GetGunPosition();
Vector vecAiming = m_pPlayer->GetAutoaimVector( AUTOAIM_5DEGREES );
Vector vecDir;
#ifdef CLIENT_DLL
if( bIsMultiplayer() )
#else
if( g_pGameRules->IsMultiplayer() )
#endif
{
vecDir = m_pPlayer->FireBulletsPlayer( 10, vecSrc, vecAiming, VECTOR_CONE_DM_SAWNOFF, 2048, BULLET_PLAYER_BUCKSHOT, 0, 0, m_pPlayer->pev, m_pPlayer->random_seed );
}
else
{
// regular old, untouched spread.
vecDir = m_pPlayer->FireBulletsPlayer( 10, vecSrc, vecAiming, VECTOR_CONE_10DEGREES, 2048, BULLET_PLAYER_BUCKSHOT, 0, 0, m_pPlayer->pev, m_pPlayer->random_seed );
}
PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usSingleFire, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, vecDir.x, vecDir.y, 0, 0, 0, 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 );
if( m_iClip != 0 )
m_flPumpTime = gpGlobals->time + 0.5;
m_flNextPrimaryAttack = gpGlobals->time + 0.75;
m_flNextSecondaryAttack = gpGlobals->time + 0.75;
if( m_iClip != 0 )
m_flTimeWeaponIdle = gpGlobals->time + 5.0;
else
m_flTimeWeaponIdle = gpGlobals->time + 0.75;
m_fInSpecialReload = 0;
}
void CSawnoff::SecondaryAttack( void )
{
// don't fire underwater
if( m_pPlayer->pev->waterlevel == 3 )
{
PlayEmptySound();
m_flNextPrimaryAttack = gpGlobals->time + 0.15;
return;
}
if( m_iClip <= 1 )
{
Reload();
PlayEmptySound();
EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/sshotgun_cock3.wav", 0.8, ATTN_NORM );
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.15f;
return;
}
@ -238,56 +133,40 @@ void CSawnoff::SecondaryAttack( void ) @@ -238,56 +133,40 @@ void CSawnoff::SecondaryAttack( void )
#else
flags = 0;
#endif
m_pPlayer->pev->effects = (int)( m_pPlayer->pev->effects ) | EF_MUZZLEFLASH;
// player "shoot" animation
m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
m_pPlayer->pev->effects = (int)( m_pPlayer->pev->effects ) | EF_MUZZLEFLASH;
Vector vecSrc = m_pPlayer->GetGunPosition();
Vector vecAiming = m_pPlayer->GetAutoaimVector( AUTOAIM_5DEGREES );
Vector vecAiming = m_pPlayer->GetAutoaimVector( AUTOAIM_10DEGREES );
Vector vecDir;
SendWeaponAnim( SAWNOFF_FIRE );
#ifdef CLIENT_DLL
if( bIsMultiplayer() )
#else
if( g_pGameRules->IsMultiplayer() )
#endif
{
// tuned for deathmatch
vecDir = m_pPlayer->FireBulletsPlayer( 20, vecSrc, vecAiming, VECTOR_CONE_DM_DOUBLESAWNOFF, 2048, BULLET_PLAYER_BUCKSHOT, 0, 0, m_pPlayer->pev, m_pPlayer->random_seed );
}
else
{
// untouched default single player
vecDir = m_pPlayer->FireBulletsPlayer( 20, vecSrc, vecAiming, VECTOR_CONE_10DEGREES, 2048, BULLET_PLAYER_BUCKSHOT, 0, 0, m_pPlayer->pev, m_pPlayer->random_seed );
}
Vector vecDir = m_pPlayer->FireBulletsPlayer( 18, vecSrc, vecAiming, VECTOR_CONE_20DEGREES, 2048, BULLET_PLAYER_BUCKSHOT, 0, 0, m_pPlayer->pev, m_pPlayer->random_seed );
PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usDoubleFire, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, vecDir.x, vecDir.y, 0, 0, 0, 0 );
PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usSawnoff, 0.0, g_vecZero, g_vecZero, vecDir.x, vecDir.y, 0, 0, 0, 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 );
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.5f;
if( m_iClip != 0 )
m_flPumpTime = gpGlobals->time + 0.95;
m_flNextPrimaryAttack = gpGlobals->time + 1.5;
m_flNextSecondaryAttack = gpGlobals->time + 1.5;
if( m_iClip != 0 )
m_flTimeWeaponIdle = gpGlobals->time + 6.0;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 5.0;
else
m_flTimeWeaponIdle = 1.5;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.75;
m_fInSpecialReload = 0;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 );
}
void CSawnoff::Reload( void )
{
if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 || m_iClip == SHOTGUN_MAX_CLIP )
if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 || m_iClip == SAWNOFF_MAX_CLIP )
return;
DefaultReload( SAWNOFF_MAX_CLIP, SAWNOFF_RELOAD, 1.5 );
EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/reload1.wav", 1, ATTN_NORM, 0, 85 + RANDOM_LONG( 0, 0x1f ) );
DefaultReload( SAWNOFF_MAX_CLIP, SAWNOFF_RELOAD, 1.3 );
EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_ITEM, "sshotgun_reload.wav", 1, ATTN_NORM );
}
@ -296,85 +175,12 @@ void CSawnoff::WeaponIdle( void ) @@ -296,85 +175,12 @@ void CSawnoff::WeaponIdle( void )
{
ResetEmptySound();
m_pPlayer->GetAutoaimVector( AUTOAIM_5DEGREES );
m_pPlayer->GetAutoaimVector( AUTOAIM_10DEGREES );
if( m_flPumpTime && m_flPumpTime < gpGlobals->time )
{
// play pumping sound
EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/scock1.wav", 1, ATTN_NORM, 0, 95 + RANDOM_LONG( 0, 0x1f ) );
m_flPumpTime = 0;
}
if( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() )
return;
if( m_flTimeWeaponIdle < gpGlobals->time )
{
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( SAWNOFF_PUMP );
// play cocking sound
EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/scock1.wav", 1, ATTN_NORM, 0, 95 + RANDOM_LONG( 0, 0x1f ) );
m_fInSpecialReload = 0;
m_flTimeWeaponIdle = gpGlobals->time + 1.5;
}
}
else
{
int iAnim;
float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0, 1 );
if( flRand <= 0.8 )
{
iAnim = SAWNOFF_IDLE_DEEP;
m_flTimeWeaponIdle = gpGlobals->time + ( 60.0 / 12.0 );// * RANDOM_LONG( 2, 5 );
}
else if( flRand <= 0.95 )
{
iAnim = SAWNOFF_IDLE;
m_flTimeWeaponIdle = gpGlobals->time + ( 20.0 / 9.0 );
}
else
{
iAnim = SAWNOFF_IDLE4;
m_flTimeWeaponIdle = gpGlobals->time + ( 20.0 / 9.0 );
}
SendWeaponAnim( iAnim );
}
}
m_flTimeWeaponIdle = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10.0f, 15.0f );
SendWeaponAnim( SAWNOFF_IDLE );
}
class CSawnoffAmmo : public CBasePlayerAmmo
{
void Spawn( void )
{
Precache();
SET_MODEL( ENT( pev ), "models/w_shotbox.mdl" );
CBasePlayerAmmo::Spawn();
}
void Precache( void )
{
PRECACHE_MODEL( "models/w_shotbox.mdl" );
PRECACHE_SOUND( "items/9mmclip1.wav" );
}
BOOL AddAmmo( CBaseEntity *pOther )
{
if( pOther->GiveAmmo( AMMO_BUCKSHOTBOX_GIVE, "BUCKSHOT", BUCKSHOT_MAX_CARRY ) != -1 )
{
EMIT_SOUND( ENT( pev ), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM );
return TRUE;
}
return FALSE;
}
};
LINK_ENTITY_TO_CLASS( ammo_cockshot, CSawnoffAmmo )

291
dlls/clcampaign/sniper.cpp

@ -1,4 +1,3 @@ @@ -1,4 +1,3 @@
//fixed (maybe)
#if !defined( OEM_BUILD ) && !defined( HLDEMO_BUILD )
#include "extdll.h"
@ -8,54 +7,8 @@ @@ -8,54 +7,8 @@
#include "monsters.h"
#include "player.h"
#include "gamerules.h"
#include "shake.h"
#include "nodes.h"
#include "soundent.h"
#define WEAPON_SNIPARS 18
class CSnipars : public CBasePlayerWeapon
{
public:
#ifndef CLIENT_DLL
int Save( CSave &save );
int Restore( CRestore &restore );
static TYPEDESCRIPTION m_SaveData[];
#endif
void Spawn( void );
void Precache( void );
int iItemSlot( void ) { return 2; }
int GetItemInfo(ItemInfo *p);
int AddToPlayer( CBasePlayer *pPlayer );
void PrimaryAttack( void );
void SecondaryAttack( void );
BOOL Deploy( void );
void Holster( int skiplocal = 0 );
void Reload( void );
void WeaponIdle( void );
void Shoot( float flSpread, float flCycleTime, BOOL fUseAutoAim );
float m_flSoundDelay;
BOOL m_fInZoom;// don't save this.
virtual BOOL UseDecrement( void )
{
return FALSE;
}
private:
//unsigned short m_usFireSniper;
};
TYPEDESCRIPTION CSnipars::m_SaveData[] =
{
DEFINE_FIELD( CSnipars, m_flSoundDelay, FIELD_FLOAT ),
DEFINE_FIELD( CSnipars, m_fInZoom, FIELD_INTEGER ),
};
IMPLEMENT_SAVERESTORE( CSnipars, CBasePlayerWeapon )
enum sniper_e
enum snipars_e
{
SNIPARS_IDLE = 0,
SNIPARS_DRAW,
@ -65,218 +18,188 @@ enum sniper_e @@ -65,218 +18,188 @@ enum sniper_e
LINK_ENTITY_TO_CLASS( weapon_snipars, CSnipars );
int CSnipars::GetItemInfo(ItemInfo *p)
{
p->pszName = STRING(pev->classname);
int CSnipars::GetItemInfo( ItemInfo *p )
{
p->pszName = STRING( pev->classname );
p->pszAmmo1 = "snipars";
p->iMaxAmmo1 = 50;
p->iMaxAmmo1 = SNIPARS_MAX_CARRY;
p->pszAmmo2 = NULL;
p->iMaxAmmo2 = -1;
p->iMaxClip = 10;
p->iMaxClip = SNIPARS_MAX_CLIP;
p->iFlags = 0;
p->iSlot = 3;
p->iSlot = 2;
p->iPosition = 4;
p->iId = m_iId = WEAPON_SNIPARS;
p->iWeight = 10;
p->iWeight = SNIPARS_WEIGHT;
return 1;
}
}
int CSnipars::AddToPlayer( CBasePlayer *pPlayer )
{
if ( CBasePlayerWeapon::AddToPlayer( pPlayer ) )
{
if( CBasePlayerWeapon::AddToPlayer( pPlayer ))
{
MESSAGE_BEGIN( MSG_ONE, gmsgWeapPickup, NULL, pPlayer->pev );
WRITE_BYTE( m_iId );
WRITE_BYTE( m_iId );
MESSAGE_END();
return TRUE;
}
return FALSE;
}
}
void CSnipars::Spawn( )
{
pev->classname = MAKE_STRING("weapon_snipars");
Precache( );
void CSnipars::Spawn( void )
{
pev->classname = MAKE_STRING( "weapon_snipars" );
Precache();
m_iId = WEAPON_SNIPARS;
SET_MODEL(ENT(pev), "models/w_sniper.mdl");
SET_MODEL( ENT( pev ), "models/w_sniper.mdl" );
m_iDefaultAmmo = 10;
m_iDefaultAmmo = SNIPARS_DEFAULT_GIVE;
FallInit();
}
void CSnipars::Precache( void )
{
PRECACHE_MODEL("models/v_sniper.mdl");
PRECACHE_MODEL("models/w_sniper.mdl");
PRECACHE_MODEL("models/p_sniper.mdl");
PRECACHE_MODEL("models/w_357ammo.mdl");
PRECACHE_SOUND("items/9mmclip1.wav");
PRECACHE_SOUND ("weapons/sniper_shoot1.wav");
PRECACHE_SOUND ("weapons/sniper_shoot2.wav");
PRECACHE_SOUND ("weapons/sniper_shoot3.wav");
PRECACHE_SOUND ("weapons/sniper_shoot4.wav");
PRECACHE_SOUND ("weapons/sniper_shoot5.wav");
//m_usFireSniper = PRECACHE_EVENT( 1, "events/glock1.sc" );
{
PRECACHE_MODEL( "models/v_sniper.mdl" );
PRECACHE_MODEL( "models/w_sniper.mdl" );
PRECACHE_MODEL( "models/p_sniper.mdl" );
PRECACHE_MODEL( "models/w_357ammobox.mdl" );
PRECACHE_MODEL( "models/w_357ammo.mdl" );
PRECACHE_SOUND( "items/9mmclip1.wav" );
PRECACHE_SOUND( "weapons/357_reload1.wav" );
PRECACHE_SOUND( "weapons/357_cock1.wav" );
PRECACHE_SOUND( "weapons/sniper_shoot1.wav" );
PRECACHE_SOUND( "weapons/sniper_shoot1.wav" );
PRECACHE_SOUND( "weapons/sniper_shoot2.wav" );
PRECACHE_SOUND( "weapons/sniper_shoot3.wav" );
PRECACHE_SOUND( "weapons/sniper_shoot4.wav" );
PRECACHE_SOUND( "weapons/sniper_shoot5.wav" );
m_usFireSniper = PRECACHE_EVENT( 1, "events/snipars.sc" );
}
BOOL CSnipars::Deploy( )
{
return DefaultDeploy( "models/v_sniper.mdl", "models/p_sniper.mdl", SNIPARS_DRAW, "snipars", UseDecrement() );
BOOL CSnipars::Deploy( void )
{
return DefaultDeploy( "models/v_sniper.mdl", "models/p_sniper.mdl", SNIPARS_DRAW, "snipars" );
}
void CSnipars::Holster( int skiplocal /* = 0 */ )
{
{
m_fInReload = FALSE;
if ( m_fInZoom )
if( m_fInZoom )
{
SecondaryAttack();
}
m_pPlayer->m_flNextAttack = gpGlobals->time + 1.0;
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1.0f;
m_flTimeWeaponIdle = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 );
}
void CSnipars::SecondaryAttack( void )
{
if ( m_pPlayer->pev->fov != 0 )
if( m_pPlayer->pev->fov != 0 )
{
m_pPlayer->pev->fov = m_pPlayer->m_iFOV = 0;
m_fInZoom = 0;
UTIL_ScreenFade( m_pPlayer, Vector(0,0,0), 0.5, 0.25, 255, FFADE_IN );
}
else if ( m_pPlayer->pev->fov != 15 )
else if( m_pPlayer->pev->fov != 40 )
{
m_pPlayer->pev->fov = m_pPlayer->m_iFOV = 15;
m_pPlayer->pev->fov = m_pPlayer->m_iFOV = 40;
m_fInZoom = 1;
UTIL_ScreenFade( m_pPlayer, Vector(0,0,0), 0.5, 0.25, 255, FFADE_IN );
}
pev->nextthink = gpGlobals->time + 0.1;
m_flNextSecondaryAttack = gpGlobals->time + 1.0;
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5f;
}
void CSnipars::PrimaryAttack( void )
{
if(m_iClip > 0)
{
Shoot( 0.0001, 1.5, TRUE );
switch( RANDOM_LONG( 0, 3 ) )
{
case 0:
EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/sniper_shoot1.wav", 1, ATTN_NORM );
break;
case 1:
EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/sniper_shoot2.wav", 1, ATTN_NORM );
break;
case 2:
EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/sniper_shoot3.wav", 1, ATTN_NORM );
break;
case 3:
EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/sniper_shoot4.wav", 1, ATTN_NORM );
break;
case 4:
EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/sniper_shoot5.wav", 1, ATTN_NORM );
break;
};
}
}
void CSnipars::Shoot( float flSpread , float flCycleTime, BOOL fUseAutoAim )
{
if (m_pPlayer->pev->waterlevel == 3)
// don't fire underwater
if( m_pPlayer->pev->waterlevel == 3 )
{
EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_WEAPON, "weapons/sniper_cock1.wav", 0.8, ATTN_NORM);
m_flNextPrimaryAttack = 0.15; return;
PlayEmptySound();
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.15f;
return;
}
if (m_iClip <= 0)
if( m_iClip <= 0 )
{
if (m_fFireOnEmpty)
if( !m_fFireOnEmpty )
Reload();
else
{
m_flNextPrimaryAttack = gpGlobals->time + 0.2;
PlayEmptySound();
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.15f;
}
return;
return;
}
SendWeaponAnim( SNIPARS_FIRE );
m_pPlayer->m_iWeaponVolume = LOUD_GUN_VOLUME;
m_pPlayer->m_iWeaponFlash = BRIGHT_GUN_FLASH;
m_iClip--;
m_pPlayer->pev->effects = (int)(m_pPlayer->pev->effects) | EF_MUZZLEFLASH;
m_pPlayer->pev->effects = (int)( m_pPlayer->pev->effects ) | EF_MUZZLEFLASH;
int flags;
#if CLIENT_WEAPONS
flags = FEV_NOTHOST;
#else
flags = 0;
#endif
// player "shoot" animation
m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
m_pPlayer->m_iWeaponVolume = NORMAL_GUN_VOLUME;
m_pPlayer->m_iWeaponFlash = NORMAL_GUN_FLASH;
Vector vecSrc = m_pPlayer->GetGunPosition();
Vector vecAiming = m_pPlayer->GetAutoaimVector( AUTOAIM_10DEGREES );
Vector vecSrc = m_pPlayer->GetGunPosition( );
Vector vecAiming;
Vector vecDir = m_pPlayer->FireBulletsPlayer( 1, vecSrc, vecAiming, VECTOR_CONE_1DEGREES, 8192, BULLET_PLAYER_357, 0, 0, m_pPlayer->pev, m_pPlayer->random_seed );
PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usFireSniper, 0.0, g_vecZero, g_vecZero, vecDir.x, vecDir.y, 0, 0, 0, 0 );
if ( fUseAutoAim )
{
vecAiming = m_pPlayer->GetAutoaimVector( AUTOAIM_10DEGREES );
}
else
{
vecAiming = gpGlobals->v_forward;
}
Vector vecDir = m_pPlayer->FireBulletsPlayer( 3, vecSrc, vecAiming, Vector( flSpread, flSpread, flSpread ), 8192, BULLET_PLAYER_9MM, 0, 50, m_pPlayer->pev, m_pPlayer->random_seed );
//PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usFireSniper, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, vecDir.x, vecDir.y, 0, 0, ( m_iClip == 0 ) ? 1 : 0, 0 );
pev->effects |= EF_MUZZLEFLASH;
m_flNextPrimaryAttack = m_flNextSecondaryAttack = gpGlobals->time + flCycleTime;
if( !m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 )
// HEV suit - indicate out of ammo condition
m_pPlayer->SetSuitUpdate( "!HEV_AMO0", FALSE, 0 );
if (!m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0)
m_flTimeWeaponIdle = RANDOM_FLOAT( 10, 15 );
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 1.5f;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10.0f, 15.0f );
}
void CSnipars::Reload( void )
{
if ( m_fInZoom )
{
SecondaryAttack();
}
if ( m_pPlayer->ammo_snipars <= 0 )
if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 || m_iClip == SNIPARS_MAX_CLIP )
return;
if ( m_pPlayer->pev->fov != 0 )
if( m_pPlayer->pev->fov != 0 )
{
m_fInZoom = FALSE;
m_pPlayer->pev->fov = m_pPlayer->m_iFOV = 0; // 0 means reset to default fov
m_pPlayer->pev->fov = m_pPlayer->m_iFOV = 0; // 0 means reset to default fov
}
if( DefaultReload( SNIPARS_MAX_CLIP, SNIPARS_RELOAD, 2.0f ))
{
m_flSoundDelay = UTIL_WeaponTimeBase() + 1.5f;
}
//if (m_iClip == 0)
//DefaultReload( 5, SNIPARS_RELOAD, 1.5 );
//else
DefaultReload( 5, SNIPARS_RELOAD, 1.5 );
}
void CSnipars::WeaponIdle( void )
{
m_pPlayer->GetAutoaimVector( AUTOAIM_2DEGREES );
ResetEmptySound();
if ( m_flTimeWeaponIdle < gpGlobals->time )
m_pPlayer->GetAutoaimVector( AUTOAIM_10DEGREES );
// ALERT( at_console, "%.2f\n", gpGlobals->time - m_flSoundDelay );
if( m_flSoundDelay != 0 && m_flSoundDelay <= UTIL_WeaponTimeBase() )
{
float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0, 1 );
if (flRand <= 0.75)
{
if (m_iClip)
{
SendWeaponAnim( SNIPARS_IDLE );
}
else
{
SendWeaponAnim( SNIPARS_IDLE );
}
m_flTimeWeaponIdle = gpGlobals->time + 60.0 / 12.0;
}
EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/357_reload1.wav", RANDOM_FLOAT( 0.8f, 0.9f ), ATTN_NORM );
m_flSoundDelay = 0.0f;
}
if( m_flTimeWeaponIdle < UTIL_WeaponTimeBase() )
{
SendWeaponAnim( SNIPARS_IDLE );
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + ( 170.0f / 30.0f );
}
}
@ -284,20 +207,20 @@ class CSniparsAmmo : public CBasePlayerAmmo @@ -284,20 +207,20 @@ class CSniparsAmmo : public CBasePlayerAmmo
{
void Spawn( void )
{
Precache( );
SET_MODEL(ENT(pev), "models/w_357ammo.mdl");
CBasePlayerAmmo::Spawn( );
Precache();
SET_MODEL( ENT( pev ), "models/w_357ammo.mdl" );
CBasePlayerAmmo::Spawn();
}
void Precache( void )
{
PRECACHE_MODEL ("models/w_357ammo.mdl");
PRECACHE_SOUND("items/9mmclip1.wav");
PRECACHE_MODEL( "models/w_357ammo.mdl" );
PRECACHE_SOUND( "items/9mmclip1.wav" );
}
BOOL AddAmmo( CBaseEntity *pOther )
{
if (pOther->GiveAmmo( 10, "snipars", 50 ) != -1)
if( pOther->GiveAmmo( AMMO_SNIPARSBOX_GIVE, "snipars", SNIPARS_MAX_CARRY ) != -1 )
{
EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM);
EMIT_SOUND( ENT( pev ), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM );
return TRUE;
}
return FALSE;

8
dlls/crossbow.cpp

@ -354,7 +354,7 @@ void CCrossbow::PrimaryAttack( void ) @@ -354,7 +354,7 @@ void CCrossbow::PrimaryAttack( void )
// this function only gets called in multiplayer
void CCrossbow::FireSniperBolt()
{
m_flNextPrimaryAttack = GetNextAttackDelay( 0.1f );
m_flNextPrimaryAttack = GetNextAttackDelay( 0.75f );
if( m_iClip == 0 )
{
@ -453,14 +453,14 @@ void CCrossbow::FireBolt() @@ -453,14 +453,14 @@ void CCrossbow::FireBolt()
// HEV suit - indicate out of ammo condition
m_pPlayer->SetSuitUpdate( "!HEV_AMO0", FALSE, 0 );
m_flNextPrimaryAttack = GetNextAttackDelay( 0.1f );
m_flNextPrimaryAttack = GetNextAttackDelay( 0.075f );
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.1f;
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.075f;
if( m_iClip != 0 )
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 5.0f;
else
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.75f;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.075f;
}
void CCrossbow::SecondaryAttack()

26
dlls/crowbar.cpp

@ -62,11 +62,6 @@ void CCrowbar::Precache( void ) @@ -62,11 +62,6 @@ void CCrowbar::Precache( void )
PRECACHE_SOUND( "weapons/cbar_hitbod2.wav" );
PRECACHE_SOUND( "weapons/cbar_hitbod3.wav" );
PRECACHE_SOUND( "weapons/cbar_miss1.wav" );
PRECACHE_SOUND( "taunts/taunt1.wav" );
PRECACHE_SOUND( "taunts/taunt2.wav" );
PRECACHE_SOUND( "taunts/taunt3.wav" );
PRECACHE_SOUND( "taunts/taunt4.wav" );
m_usCrowbar = PRECACHE_EVENT( 1, "events/crowbar.sc" );
}
@ -163,25 +158,14 @@ void CCrowbar::PrimaryAttack() @@ -163,25 +158,14 @@ void CCrowbar::PrimaryAttack()
#endif
}
}
void CCrowbar::SecondaryAttack( void )
{
#if !CLIENT_DLL
SENTENCEG_PlayRndSz( ENT( pev ), "PL_TAUNT", 1, ATTN_NORM, 0, PITCH_NORM );
#endif
SendWeaponAnim( CROWBAR_TAUNT );
switch( RANDOM_LONG( 0, 3 ) )
{
case 0:
EMIT_SOUND( ENT( pev ), CHAN_ITEM, "taunts/taunt3", 1, ATTN_NORM );
break;
case 1:
EMIT_SOUND( ENT( pev ), CHAN_ITEM, "taunts/taunt2.wav", 1, ATTN_NORM );
break;
case 2:
EMIT_SOUND( ENT( pev ), CHAN_ITEM, "taunts/taunt4.wav", 1, ATTN_NORM );
break;
case 3:
EMIT_SOUND( ENT( pev ), CHAN_ITEM, "taunts/taunt1.wav", 1, ATTN_NORM );
break;
};
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 2.5;
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 3.0f;
}
void CCrowbar::Smack()

157
dlls/ggrenade.cpp

@ -387,45 +387,6 @@ CGrenade *CGrenade::ShootContact( entvars_t *pevOwner, Vector vecStart, Vector v @@ -387,45 +387,6 @@ CGrenade *CGrenade::ShootContact( entvars_t *pevOwner, Vector vecStart, Vector v
return pGrenade;
}
CGrenade *CGrenadeRock::ShootTimed( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, float time )
{
CGrenade *pGrenade = GetClassPtr( (CGrenade *)NULL );
pGrenade->Spawn();
UTIL_SetOrigin( pGrenade->pev, vecStart );
pGrenade->pev->velocity = vecVelocity;
pGrenade->pev->angles = UTIL_VecToAngles( pGrenade->pev->velocity );
pGrenade->pev->owner = ENT( pevOwner );
pGrenade->SetTouch( &CGrenadeRock::BounceTouch ); // Bounce if touched
// Take one second off of the desired detonation time and set the think to PreDetonate. PreDetonate
// will insert a DANGER sound into the world sound list and delay detonation for one second so that
// the grenade explodes after the exact amount of time specified in the call to ShootTimed().
pGrenade->pev->dmgtime = gpGlobals->time + time;
pGrenade->SetThink( &CGrenade::TumbleThink );
pGrenade->pev->nextthink = gpGlobals->time + 0.1;
if( time < 0.1 )
{
pGrenade->pev->nextthink = gpGlobals->time;
pGrenade->pev->velocity = Vector( 0, 0, 0 );
}
pGrenade->pev->sequence = RANDOM_LONG( 3, 6 );
pGrenade->pev->framerate = 1.0;
// Tumble through the air
// pGrenade->pev->avelocity.x = -400;
pGrenade->pev->gravity = 0.5;
pGrenade->pev->friction = 0.8;
SET_MODEL( ENT( pGrenade->pev ), "models/w_rock.mdl" );
pGrenade->pev->dmg = 100;
return pGrenade;
}
CGrenade *CGrenade::ShootTimed( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, float time )
{
CGrenade *pGrenade = GetClassPtr( (CGrenade *)NULL );
@ -493,65 +454,6 @@ CGrenade *CGrenade::ShootSatchelCharge( entvars_t *pevOwner, Vector vecStart, Ve @@ -493,65 +454,6 @@ CGrenade *CGrenade::ShootSatchelCharge( entvars_t *pevOwner, Vector vecStart, Ve
return pGrenade;
}
void CGrenadeRock::BounceTouch( CBaseEntity *pOther )
{
// don't hit the guy that launched this grenade
if( pOther->edict() == pev->owner )
return;
// only do damage if we're moving fairly fast
if( m_flNextAttack < gpGlobals->time && pev->velocity.Length() > 100 )
{
entvars_t *pevOwner = VARS( pev->owner );
if( pevOwner )
{
TraceResult tr = UTIL_GetGlobalTrace();
ClearMultiDamage();
pOther->TraceAttack( pevOwner, 10, gpGlobals->v_forward, &tr, DMG_CLUB);
ApplyMultiDamage( pev, pevOwner );
}
m_flNextAttack = gpGlobals->time + 1.0; // debounce
}
Vector vecTestVelocity;
// pev->avelocity = Vector( 300, 300, 300 );
// this is my heuristic for modulating the grenade velocity because grenades dropped purely vertical
// or thrown very far tend to slow down too quickly for me to always catch just by testing velocity.
// trimming the Z velocity a bit seems to help quite a bit.
vecTestVelocity = pev->velocity;
vecTestVelocity.z *= 0.45;
if( !m_fRegisteredSound && vecTestVelocity.Length() <= 60 )
{
//ALERT( at_console, "Grenade Registered!: %f\n", vecTestVelocity.Length() );
// grenade is moving really slow. It's probably very close to where it will ultimately stop moving.
// go ahead and emit the danger sound.
// register a radius louder than the explosion, so we make sure everyone gets out of the way
CSoundEnt::InsertSound( bits_SOUND_DANGER, pev->origin, pev->dmg / 0.4, 0.3 );
m_fRegisteredSound = TRUE;
}
if( pev->flags & FL_ONGROUND )
{
// add a bit of static friction
pev->velocity = pev->velocity * 0.8;
pev->sequence = RANDOM_LONG( 1, 1 );
}
else
{
// play bounce sound
BounceSound();
}
pev->framerate = pev->velocity.Length() / 200.0;
if( pev->framerate > 1.0 )
pev->framerate = 1;
else if( pev->framerate < 0.5 )
pev->framerate = 0;
}
@ -585,5 +487,64 @@ void CGrenade::UseSatchelCharges( entvars_t *pevOwner, SATCHELCODE code ) @@ -585,5 +487,64 @@ void CGrenade::UseSatchelCharges( entvars_t *pevOwner, SATCHELCODE code )
}
}
CGrenade *CGrenade::ShootRock( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity )
{
CGrenade *pGrenade = GetClassPtr( (CGrenade *)NULL );
pGrenade->Spawn();
UTIL_SetOrigin( pGrenade->pev, vecStart );
pGrenade->pev->velocity = vecVelocity;
pGrenade->pev->angles = UTIL_VecToAngles( pGrenade->pev->velocity );
pGrenade->pev->owner = ENT( pevOwner );
pGrenade->SetTouch( &CGrenade::BounceTouch ); // Bounce if touched
// Take one second off of the desired detonation time and set the think to PreDetonate. PreDetonate
// will insert a DANGER sound into the world sound list and delay detonation for one second so that
// the grenade explodes after the exact amount of time specified in the call to ShootTimed().
pGrenade->pev->sequence = RANDOM_LONG( 3, 6 );
pGrenade->pev->framerate = 1.0;
// Tumble through the air
// pGrenade->pev->avelocity.x = -400;
pGrenade->pev->gravity = 0.5;
pGrenade->pev->friction = 0.8;
SET_MODEL( ENT( pGrenade->pev ), "models/w_rock.mdl" );
return pGrenade;
}
void CGrenadeFedora::Spawn( void )
{
pev->movetype = MOVETYPE_BOUNCE;
pev->classname = MAKE_STRING( "fedora" );
pev->solid = SOLID_BBOX;
SET_MODEL( ENT( pev ), "models/fedora.mdl" );
UTIL_SetSize( pev, Vector( 0, 0, 0 ), Vector( 0, 0, 0 ) );
m_fRegisteredSound = FALSE;
}
CGrenade *CGrenadeFedora::ShootContact( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity )
{
CGrenade *pGrenade = GetClassPtr( (CGrenadeFedora *)NULL );
pGrenade->Spawn();
// contact grenades arc lower
pGrenade->pev->gravity = 0.4;// lower gravity since grenade is aerodynamic and engine doesn't know it.
UTIL_SetOrigin( pGrenade->pev, vecStart );
pGrenade->pev->velocity = vecVelocity;
pGrenade->pev->angles = UTIL_VecToAngles( pGrenade->pev->velocity );
pGrenade->pev->owner = ENT( pevOwner );
// make monsters afraid of it while in the air
pGrenade->SetThink( &CGrenade::DangerSoundThink );
pGrenade->pev->nextthink = gpGlobals->time;
return pGrenade;
}
//======================end grenade

12
dlls/hornetgun.cpp

@ -113,7 +113,7 @@ BOOL CHgun::Deploy() @@ -113,7 +113,7 @@ BOOL CHgun::Deploy()
void CHgun::Holster( int skiplocal /* = 0 */ )
{
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.1f;
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.05f;
SendWeaponAnim( HGUN_DOWN );
//!!!HACKHACK - can't select hornetgun if it's empty! no way to get ammo for it, either.
@ -137,7 +137,7 @@ void CHgun::PrimaryAttack() @@ -137,7 +137,7 @@ void CHgun::PrimaryAttack()
CBaseEntity *pHornet = CBaseEntity::Create( "hornet", m_pPlayer->GetGunPosition() + gpGlobals->v_forward * 16.0f + gpGlobals->v_right * 8.0f + gpGlobals->v_up * -12.0f, m_pPlayer->pev->v_angle, m_pPlayer->edict() );
pHornet->pev->velocity = gpGlobals->v_forward * 300.0f;
m_flRechargeTime = gpGlobals->time + 0.1f;
m_flRechargeTime = gpGlobals->time + 0.05f;
#endif
m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--;
@ -155,11 +155,11 @@ void CHgun::PrimaryAttack() @@ -155,11 +155,11 @@ void CHgun::PrimaryAttack()
// player "shoot" animation
m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
m_flNextPrimaryAttack = m_flNextPrimaryAttack + 0.1f;
m_flNextPrimaryAttack = m_flNextPrimaryAttack + 0.025f;
if( m_flNextPrimaryAttack < UTIL_WeaponTimeBase() )
{
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.1f;
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.025f;
}
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 );
@ -223,7 +223,7 @@ void CHgun::SecondaryAttack( void ) @@ -223,7 +223,7 @@ void CHgun::SecondaryAttack( void )
pHornet->SetThink( &CHornet::StartDart );
m_flRechargeTime = gpGlobals->time + 0.1f;
m_flRechargeTime = gpGlobals->time + 0.05f;
#endif
int flags;
#if CLIENT_WEAPONS
@ -252,7 +252,7 @@ void CHgun::Reload( void ) @@ -252,7 +252,7 @@ void CHgun::Reload( void )
while( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] < HORNET_MAX_CARRY && m_flRechargeTime < gpGlobals->time )
{
m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]++;
m_flRechargeTime += 0.1f;
m_flRechargeTime += 0.5f;
}
}

10
dlls/mp5.cpp

@ -126,14 +126,14 @@ void CMP5::PrimaryAttack() @@ -126,14 +126,14 @@ void CMP5::PrimaryAttack()
if( m_pPlayer->pev->waterlevel == 3 )
{
PlayEmptySound();
m_flNextPrimaryAttack = 0.02f;
m_flNextPrimaryAttack = 0.01f;
return;
}
if( m_iClip <= 0 )
{
PlayEmptySound();
m_flNextPrimaryAttack = 0.02f;
m_flNextPrimaryAttack = 0.01f;
return;
}
@ -177,10 +177,10 @@ void CMP5::PrimaryAttack() @@ -177,10 +177,10 @@ void CMP5::PrimaryAttack()
// HEV suit - indicate out of ammo condition
m_pPlayer->SetSuitUpdate( "!HEV_AMO0", FALSE, 0 );
m_flNextPrimaryAttack = GetNextAttackDelay( 0.05f );
m_flNextPrimaryAttack = GetNextAttackDelay( 0.01f );
if( m_flNextPrimaryAttack < UTIL_WeaponTimeBase() )
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.05f;
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.01f;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 );
}
@ -228,7 +228,7 @@ void CMP5::SecondaryAttack( void ) @@ -228,7 +228,7 @@ void CMP5::SecondaryAttack( void )
PLAYBACK_EVENT( flags, m_pPlayer->edict(), m_usMP52 );
m_flNextPrimaryAttack = GetNextAttackDelay( 0.1f );
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.15f;
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.1f;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 5.0f;// idle pretty soon after shooting.
if( !m_pPlayer->m_rgAmmo[m_iSecondaryAmmoType] )

8
dlls/player.cpp

@ -3468,16 +3468,12 @@ void CBasePlayer::CheatImpulseCommands( int iImpulse ) @@ -3468,16 +3468,12 @@ void CBasePlayer::CheatImpulseCommands( int iImpulse )
GiveNamedItem( "item_suit" );
GiveNamedItem( "item_battery" );
GiveNamedItem( "weapon_crowbar" );
GiveNamedItem( "weapon_hammer" );
GiveNamedItem( "weapon_9mmhandgun" );
GiveNamedItem( "ammo_9mmclip" );
GiveNamedItem( "weapon_shotgun" );
GiveNamedItem( "ammo_buckshot" );
GiveNamedItem( "weapon_9mmAR" );
GiveNamedItem( "ammo_9mmAR" );
GiveNamedItem( "weapon_rock" );
GiveNamedItem( "weapon_katana" );
GiveNamedItem( "weapon_pepsigun" );
GiveNamedItem( "ammo_ARgrenades" );
GiveNamedItem( "weapon_handgrenade" );
GiveNamedItem( "weapon_tripmine" );
@ -3487,13 +3483,9 @@ void CBasePlayer::CheatImpulseCommands( int iImpulse ) @@ -3487,13 +3483,9 @@ void CBasePlayer::CheatImpulseCommands( int iImpulse )
GiveNamedItem( "weapon_crossbow" );
GiveNamedItem( "ammo_crossbow" );
GiveNamedItem( "weapon_egon" );
GiveNamedItem( "weapon_needle" );
GiveNamedItem( "weapon_gauss" );
GiveNamedItem( "weapon_sawnoff" );
GiveNamedItem( "weapon_rpg" );
GiveNamedItem( "weapon_snipars" );
GiveNamedItem( "ammo_gaussclip" );
GiveNamedItem( "ammo_snipars" );
GiveNamedItem( "ammo_rpgclip" );
GiveNamedItem( "weapon_satchel" );
GiveNamedItem( "weapon_snark" );

26
dlls/rpg.cpp

@ -142,7 +142,7 @@ void CRpgRocket::Spawn( void ) @@ -142,7 +142,7 @@ void CRpgRocket::Spawn( void )
pev->velocity = gpGlobals->v_forward * 250.0f;
pev->gravity = 0.5f;
pev->nextthink = gpGlobals->time + 0.4f;
pev->nextthink = gpGlobals->time + 0.01f;
pev->dmg = gSkillData.plrDmgRPG;
}
@ -337,11 +337,11 @@ void CRpg::Spawn() @@ -337,11 +337,11 @@ void CRpg::Spawn()
#endif
{
// more default ammo in multiplay.
m_iDefaultAmmo = 128 * 2;
m_iDefaultAmmo = RPG_DEFAULT_GIVE * 2;
}
else
{
m_iDefaultAmmo = 128;
m_iDefaultAmmo = RPG_DEFAULT_GIVE;
}
FallInit();// get ready to fall down.
@ -368,10 +368,10 @@ int CRpg::GetItemInfo( ItemInfo *p ) @@ -368,10 +368,10 @@ int CRpg::GetItemInfo( ItemInfo *p )
{
p->pszName = STRING( pev->classname );
p->pszAmmo1 = "rockets";
p->iMaxAmmo1 = 2560;
p->iMaxAmmo1 = ROCKET_MAX_CARRY;
p->pszAmmo2 = NULL;
p->iMaxAmmo2 = -1;
p->iMaxClip = -1;
p->iMaxClip = RPG_MAX_CLIP;
p->iSlot = 3;
p->iPosition = 0;
p->iId = m_iId = WEAPON_RPG;
@ -418,7 +418,7 @@ void CRpg::Holster( int skiplocal /* = 0 */ ) @@ -418,7 +418,7 @@ void CRpg::Holster( int skiplocal /* = 0 */ )
{
m_fInReload = FALSE;// cancel any reload in progress.
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.65f;
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5f;
SendWeaponAnim( RPG_HOLSTER1 );
@ -469,16 +469,16 @@ void CRpg::PrimaryAttack() @@ -469,16 +469,16 @@ void CRpg::PrimaryAttack()
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_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--;
m_iClip--;
gun = !gun;
m_flNextPrimaryAttack = GetNextAttackDelay( 0.45f );
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.45f;
m_flNextPrimaryAttack = GetNextAttackDelay( 0.4f );
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.5f;
}
else
{
PlayEmptySound();
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.5f;
// m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.5f;
}
UpdateSpot();
}
@ -588,14 +588,14 @@ class CRpgAmmo : public CBasePlayerAmmo @@ -588,14 +588,14 @@ class CRpgAmmo : public CBasePlayerAmmo
#endif
{
// hand out more ammo per rocket in multiplayer.
iGive = 128 * 2;
iGive = AMMO_RPGCLIP_GIVE * 2;
}
else
{
iGive = 128;
iGive = AMMO_RPGCLIP_GIVE;
}
if( pOther->GiveAmmo( iGive, "rockets", 2560 ) != -1 )
if( pOther->GiveAmmo( iGive, "rockets", ROCKET_MAX_CARRY ) != -1 )
{
EMIT_SOUND( ENT( pev ), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM );
return TRUE;

42
dlls/weapons.cpp

@ -303,43 +303,43 @@ void W_Precache( void ) @@ -303,43 +303,43 @@ void W_Precache( void )
// shotgun
UTIL_PrecacheOtherWeapon( "weapon_shotgun" );
UTIL_PrecacheOtherWeapon( "weapon_hammer");
UTIL_PrecacheOtherWeapon( "weapon_pepsigun" );
UTIL_PrecacheOther( "ammo_buckshot" );
//needle
UTIL_PrecacheOtherWeapon( "weapon_needle");
// sawnoff
UTIL_PrecacheOtherWeapon( "weapon_sawnoff");
// crowbar
UTIL_PrecacheOtherWeapon( "weapon_crowbar" );
UTIL_PrecacheOtherWeapon( "weapon_snipars" );
UTIL_PrecacheOther( "ammo_snipars" );
// rock
UTIL_PrecacheOtherWeapon( "weapon_rock" );
// hammer
UTIL_PrecacheOtherWeapon( "weapon_hammer" );
// needle
UTIL_PrecacheOtherWeapon( "weapon_needle" );
UTIL_PrecacheOtherWeapon( "weapon_snipars" );
UTIL_PrecacheOther( "ammo_snipars" );
// glock
UTIL_PrecacheOtherWeapon( "weapon_9mmhandgun" );
UTIL_PrecacheOther( "ammo_9mmclip" );
// sawnoff
UTIL_PrecacheOtherWeapon( "weapon_sawnoff" );
UTIL_PrecacheOther( "ammo_cockshot" );
// mp5
UTIL_PrecacheOtherWeapon( "weapon_9mmAR" );
UTIL_PrecacheOther( "ammo_9mmAR" );
UTIL_PrecacheOther( "ammo_ARgrenades" );
//Sawnoff
UTIL_PrecacheOtherWeapon( "weapon_sawnoff" );
// 9mm ammo box
UTIL_PrecacheOther( "ammo_9mmbox" );
#if !OEM_BUILD && !HLDEMO_BUILD
// python
UTIL_PrecacheOtherWeapon( "weapon_357" );
UTIL_PrecacheOtherWeapon( "weapon_katana" );
UTIL_PrecacheOther( "ammo_357" );
UTIL_PrecacheOtherWeapon( "weapon_rock" );
UTIL_PrecacheOtherWeapon( "weapon_snipars" );
// gauss
UTIL_PrecacheOtherWeapon( "weapon_gauss" );
@ -364,6 +364,9 @@ UTIL_PrecacheOther( "ammo_snipars" ); @@ -364,6 +364,9 @@ UTIL_PrecacheOther( "ammo_snipars" );
#endif
// hand grenade
UTIL_PrecacheOtherWeapon("weapon_handgrenade");
// pepsigun
UTIL_PrecacheOtherWeapon("weapon_pepsigun");
#if !OEM_BUILD && !HLDEMO_BUILD
// squeak grenade
UTIL_PrecacheOtherWeapon( "weapon_snark" );
@ -371,6 +374,7 @@ UTIL_PrecacheOther( "ammo_snipars" ); @@ -371,6 +374,7 @@ UTIL_PrecacheOther( "ammo_snipars" );
// hornetgun
UTIL_PrecacheOtherWeapon( "weapon_hornetgun" );
UTIL_PrecacheOtherWeapon( "weapon_katana" );
if( g_pGameRules->IsDeathmatch() )
{
UTIL_PrecacheOther( "weaponbox" );// container for dropped deathmatch weapons
@ -1664,3 +1668,11 @@ TYPEDESCRIPTION CSatchel::m_SaveData[] = @@ -1664,3 +1668,11 @@ TYPEDESCRIPTION CSatchel::m_SaveData[] =
};
IMPLEMENT_SAVERESTORE( CSatchel, CBasePlayerWeapon )
TYPEDESCRIPTION CSnipars::m_SaveData[] =
{
DEFINE_FIELD( CSnipars, m_flSoundDelay, FIELD_FLOAT ),
DEFINE_FIELD( CSnipars, m_fInZoom, FIELD_INTEGER ),
};
IMPLEMENT_SAVERESTORE( CSnipars, CBasePlayerWeapon )

303
dlls/weapons.h

@ -34,6 +34,7 @@ public: @@ -34,6 +34,7 @@ public:
static CGrenade *ShootTimed( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, float time );
static CGrenade *ShootContact( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity );
static CGrenade *ShootSatchelCharge( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity );
static CGrenade *ShootRock( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity);
static void UseSatchelCharges( entvars_t *pevOwner, SATCHELCODE code );
void Explode( Vector vecSrc, Vector vecAim );
@ -55,20 +56,12 @@ public: @@ -55,20 +56,12 @@ public:
BOOL m_fRegisteredSound;// whether or not this grenade has issued its DANGER sound to the world sound list yet.
};
class CGrenadeRock : public CBaseMonster
class CGrenadeFedora : public CGrenade
{
public:
void Spawn( void );
typedef enum { SATCHEL_DETONATE = 0, SATCHEL_RELEASE } SATCHELCODE;
static CGrenade *ShootTimed( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, float time );
void EXPORT BounceTouch( CBaseEntity *pOther );
virtual void BounceSound( void );
BOOL m_fRegisteredSound;// whether or not this grenade has issued its DANGER sound to the world sound list yet.
static CGrenade *ShootContact( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity );
};
@ -94,11 +87,13 @@ public: @@ -94,11 +87,13 @@ public:
#define WEAPON_TRIPMINE 13
#define WEAPON_SATCHEL 14
#define WEAPON_SNARK 15
#define WEAPON_SAWNOFF 16
#define WEAPON_NEEDLE 17
#define WEAPON_KATANA 24
#define WEAPON_HAMMER 23
#define WEAPON_KATANA 16
#define WEAPON_SNIPARS 17
#define WEAPON_PEPSIGUN 18
#define WEAPON_HAMMER 19
#define WEAPON_SAWNOFF 20
#define WEAPON_ROCK 21
#define WEAPON_NEEDLE 22
#define WEAPON_ALLWEAPONS (~(1<<WEAPON_SUIT))
@ -121,25 +116,29 @@ public: @@ -121,25 +116,29 @@ public:
#define SNARK_WEIGHT 5
#define SATCHEL_WEIGHT -10
#define TRIPMINE_WEIGHT -10
#define SAWNOFF_WEIGHT 16
#define SNIPARS_WEIGHT 10
#define PEPSIGUN_WEIGHT 10
#define KATANA_WEIGHT 0
#define NEEDLE_WEIGHT 0
#define SAWNOFF_WEIGHT 15
#define SNIPARS_WEIGHT 15
#define PEPSIGUN_WEIGHT 15
#define ROCK_WEIGHT 15
#define HAMMER_WEIGHT 0
// weapon clip/carry ammo capacities
#define URANIUM_MAX_CARRY 10000
#define _9MM_MAX_CARRY 25000
#define URANIUM_MAX_CARRY 999
#define _9MM_MAX_CARRY 999
#define _357_MAX_CARRY 36
#define BUCKSHOT_MAX_CARRY 200
#define BOLT_MAX_CARRY 500
#define ROCKET_MAX_CARRY WEAPON_NOCLIP
#define HANDGRENADE_MAX_CARRY 200
#define ROCKET_MAX_CARRY 125
#define HANDGRENADE_MAX_CARRY 60
#define SATCHEL_MAX_CARRY 5
#define TRIPMINE_MAX_CARRY 5
#define SNARK_MAX_CARRY 15
#define HORNET_MAX_CARRY 50
#define M203_GRENADE_MAX_CARRY 10000
#define _SNIPARS_MAX_CARRY 30
#define PEPSIGUN_MAX_CARRY 200
#define HORNET_MAX_CARRY 999
#define M203_GRENADE_MAX_CARRY 999
#define SNIPARS_MAX_CARRY 100
#define PEPSIGUN_MAX_CARRY 60
// the maximum amount of ammo each weapon's clip can hold
#define WEAPON_NOCLIP -1
@ -147,10 +146,10 @@ public: @@ -147,10 +146,10 @@ public:
//#define CROWBAR_MAX_CLIP WEAPON_NOCLIP
#define GLOCK_MAX_CLIP 17
#define PYTHON_MAX_CLIP 6
#define MP5_MAX_CLIP 5000
#define MP5_MAX_CLIP 999
#define SHOTGUN_MAX_CLIP 8
#define CROSSBOW_MAX_CLIP 50
#define RPG_MAX_CLIP 500000
#define CROSSBOW_MAX_CLIP 500
#define RPG_MAX_CLIP WEAPON_NOCLIP
#define GAUSS_MAX_CLIP WEAPON_NOCLIP
#define EGON_MAX_CLIP WEAPON_NOCLIP
#define HORNETGUN_MAX_CLIP WEAPON_NOCLIP
@ -159,42 +158,43 @@ public: @@ -159,42 +158,43 @@ public:
#define TRIPMINE_MAX_CLIP WEAPON_NOCLIP
#define SNARK_MAX_CLIP WEAPON_NOCLIP
#define SAWNOFF_MAX_CLIP 4
#define SNIPARS_MAX_CLIP 5
#define PEPSIGUN_MAX_CLIP 8
#define SNIPARS_MAX_CLIP 10
#define PEPSIGUN_MAX_CLIP 8
// the default amount of ammo that comes with each gun when it spawns
#define GLOCK_DEFAULT_GIVE 17
#define PYTHON_DEFAULT_GIVE 6
#define MP5_DEFAULT_GIVE 2500
#define MP5_M203_DEFAULT_GIVE 1000
#define MP5_DEFAULT_GIVE 999
#define MP5_M203_DEFAULT_GIVE 999
#define SHOTGUN_DEFAULT_GIVE 12
#define CROSSBOW_DEFAULT_GIVE 50
#define RPG_DEFAULT_GIVE 10000
#define GAUSS_DEFAULT_GIVE 1000
#define EGON_DEFAULT_GIVE 1000
#define HANDGRENADE_DEFAULT_GIVE 50
#define RPG_DEFAULT_GIVE 25
#define GAUSS_DEFAULT_GIVE 999
#define EGON_DEFAULT_GIVE 999
#define HANDGRENADE_DEFAULT_GIVE 12
#define SATCHEL_DEFAULT_GIVE 1
#define TRIPMINE_DEFAULT_GIVE 1
#define SNARK_DEFAULT_GIVE 5
#define HIVEHAND_DEFAULT_GIVE 8
#define SAWNOFF_DEFAULT_GIVE 125
#define SNIPARS_DEFAULT_GIVE 10
#define PEPSIGUN_DEFAULT_GIVE 24
#define SAWNOFF_DEFAULT_GIVE 4
#define SNIPARS_DEFAULT_GIVE 10
#define PEPSIGUN_DEFAULT_GIVE 12
// The amount of ammo given to a player by an ammo item.
#define AMMO_URANIUMBOX_GIVE 2000
#define AMMO_GLOCKCLIP_GIVE GLOCK_MAX_CLIP
#define AMMO_357BOX_GIVE PYTHON_MAX_CLIP
#define AMMO_MP5CLIP_GIVE MP5_MAX_CLIP
#define AMMO_URANIUMBOX_GIVE 999
#define AMMO_GLOCKCLIP_GIVE GLOCK_DEFAULT_GIVE
#define AMMO_357BOX_GIVE PYTHON_DEFAULT_GIVE
#define AMMO_MP5CLIP_GIVE MP5_DEFAULT_GIVE
#define AMMO_CHAINBOX_GIVE 200
#define AMMO_M203BOX_GIVE 999
#define AMMO_BUCKSHOTBOX_GIVE 12
#define AMMO_CROSSBOWCLIP_GIVE CROSSBOW_MAX_CLIP
#define AMMO_RPGCLIP_GIVE RPG_MAX_CLIP
#define AMMO_URANIUMBOX_GIVE 2000
#define AMMO_CROSSBOWCLIP_GIVE CROSSBOW_DEFAULT_GIVE
#define AMMO_RPGCLIP_GIVE RPG_DEFAULT_GIVE
#define AMMO_URANIUMBOX_GIVE 999
#define AMMO_SNARKBOX_GIVE 5
#define AMMO_SNIPARSBOX_GIVE SNIPARS_MAX_CLIP
#define AMMO_SNIPARSBOX_GIVE 10
// bullet types
typedef enum
@ -1034,5 +1034,208 @@ private: @@ -1034,5 +1034,208 @@ private:
};
class CKatana : public CBasePlayerWeapon
{
public:
void Spawn( void );
void Precache( void );
int iItemSlot( void ) { return 1; }
void EXPORT SwingAgain( void );
void EXPORT Smack( void );
int GetItemInfo( ItemInfo *p );
int AddToPlayer( CBasePlayer *pPlayer );
void PrimaryAttack( void );
void SecondaryAttack( void );
int Swing( int fFirst );
BOOL Deploy( void );
void Holster( int skiplocal = 0 );
int m_iSwing;
TraceResult m_trHit;
virtual BOOL UseDecrement( void )
{
#if CLIENT_WEAPONS
return TRUE;
#else
return FALSE;
#endif
}
private:
unsigned short m_usKatana;
};
class CSnipars : public CBasePlayerWeapon
{
public:
#ifndef CLIENT_DLL
int Save( CSave &save );
int Restore( CRestore &restore );
static TYPEDESCRIPTION m_SaveData[];
#endif
void Spawn( void );
void Precache( void );
int iItemSlot( void ) { return 3; }
int GetItemInfo( ItemInfo *p );
int AddToPlayer( CBasePlayer *pPlayer );
void PrimaryAttack( void );
void SecondaryAttack( void );
BOOL Deploy( void );
void Holster( int skiplocal = 0 );
void Reload( void );
void WeaponIdle( void );
void Shoot( float flSpread, float flCycleTime, BOOL fUseAutoAim );
float m_flSoundDelay;
BOOL m_fInZoom;// don't save this.
virtual BOOL UseDecrement( void )
{
#if CLIENT_WEAPONS
return TRUE;
#else
return FALSE;
#endif
}
private:
unsigned short m_usFireSniper;
};
class CPepsigun : public CBasePlayerWeapon
{
public:
void Spawn( void );
void Precache( void );
int iItemSlot( ) { return 4; }
int GetItemInfo( ItemInfo *p );
int AddToPlayer( CBasePlayer *pPlayer );
void PrimaryAttack( void );
BOOL Deploy( void );
void Reload( void );
void WeaponIdle( void );
int m_fInReload;
float m_flNextReload;
virtual BOOL UseDecrement( void )
{
#if defined( CLIENT_WEAPONS )
return TRUE;
#else
return FALSE;
#endif
}
private:
unsigned short m_usPepsigun;
};
class CHammer : public CBasePlayerWeapon
{
public:
void Spawn( void );
void Precache( void );
int iItemSlot( void ) { return 1; }
void EXPORT SwingAgain( void );
void EXPORT Smack( void );
int GetItemInfo( ItemInfo *p );
int AddToPlayer( CBasePlayer *pPlayer );
void PrimaryAttack( void );
int Swing( int fFirst );
BOOL Deploy( void );
void Holster( int skiplocal = 0 );
int m_iSwing;
TraceResult m_trHit;
virtual BOOL UseDecrement( void )
{
#if defined( CLIENT_WEAPONS )
return TRUE;
#else
return FALSE;
#endif
}
private:
unsigned short m_usHammer;
};
class CSawnoff : public CBasePlayerWeapon
{
public:
void Spawn( void );
void Precache( void );
int iItemSlot( void ) { return 3; }
int GetItemInfo( ItemInfo *p );
int AddToPlayer( CBasePlayer *pPlayer );
void PrimaryAttack( void );
BOOL Deploy( void );
void Reload( void );
void WeaponIdle( void );
int m_fInReload;
float m_flNextReload;
int m_iShell;
virtual BOOL UseDecrement( void )
{
#if defined( CLIENT_WEAPONS )
return TRUE;
#else
return FALSE;
#endif
}
private:
unsigned short m_usSawnoff;
};
class CRock : public CBasePlayerWeapon
{
public:
void Spawn( void );
void Precache( void );
int iItemSlot( void ) { return 5; }
int GetItemInfo( ItemInfo *p );
void PrimaryAttack( void );
BOOL Deploy( void );
void WeaponIdle( void );
virtual BOOL UseDecrement( void )
{
#if defined( CLIENT_WEAPONS )
return TRUE;
#else
return FALSE;
#endif
}
private:
unsigned short m_usRock;
};
class CNeedle : public CBasePlayerWeapon
{
public:
void Spawn( void );
void Precache( void );
int iItemSlot( void ) { return 1; }
int GetItemInfo( ItemInfo *p );
void PrimaryAttack( void );
BOOL Deploy( void );
void Holster( int skiplocal = 0 );
virtual BOOL UseDecrement( void )
{
#if defined( CLIENT_WEAPONS )
return TRUE;
#else
return FALSE;
#endif
}
private:
unsigned short m_usNeedle;
};
#endif // WEAPONS_H

Loading…
Cancel
Save