From dc79f4a1a585709d1bee5011be010576e3bed3cd Mon Sep 17 00:00:00 2001 From: Andrey Akhmichin <15944199+nekonomicon@users.noreply.github.com> Date: Tue, 2 Jan 2024 10:14:27 +0500 Subject: [PATCH] More accurate weapons implementation. --- cl_dll/CMakeLists.txt | 7 + cl_dll/ev_hldm.cpp | 283 ++++++++++++++++++++++++++++++++ cl_dll/ev_hldm.h | 29 ++++ cl_dll/hl/hl_events.cpp | 15 ++ cl_dll/hl/hl_weapons.cpp | 35 ++++ dlls/clcampaign/hammer.cpp | 118 ++++++-------- dlls/clcampaign/katana.cpp | 157 +++++++++--------- dlls/clcampaign/needle.cpp | 41 +---- dlls/clcampaign/pepsigun.cpp | 169 +++++++++---------- dlls/clcampaign/rock.cpp | 107 +++---------- dlls/clcampaign/sawnoff.cpp | 258 ++++------------------------- dlls/clcampaign/sniper.cpp | 291 +++++++++++++-------------------- dlls/crossbow.cpp | 8 +- dlls/crowbar.cpp | 26 +-- dlls/ggrenade.cpp | 157 +++++++----------- dlls/hornetgun.cpp | 12 +- dlls/mp5.cpp | 10 +- dlls/player.cpp | 8 - dlls/rpg.cpp | 26 +-- dlls/weapons.cpp | 42 +++-- dlls/weapons.h | 303 +++++++++++++++++++++++++++++------ 21 files changed, 1117 insertions(+), 985 deletions(-) diff --git a/cl_dll/CMakeLists.txt b/cl_dll/CMakeLists.txt index 45c24b91..e0aa7ff8 100644 --- a/cl_dll/CMakeLists.txt +++ b/cl_dll/CMakeLists.txt @@ -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 diff --git a/cl_dll/ev_hldm.cpp b/cl_dll/ev_hldm.cpp index 166f86bd..e1a62900 100644 --- a/cl_dll/ev_hldm.cpp +++ b/cl_dll/ev_hldm.cpp @@ -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 ) { 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 +//====================== diff --git a/cl_dll/ev_hldm.h b/cl_dll/ev_hldm.h index 8a836762..102d10cc 100644 --- a/cl_dll/ev_hldm.h +++ b/cl_dll/ev_hldm.h @@ -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 ); diff --git a/cl_dll/hl/hl_events.cpp b/cl_dll/hl/hl_events.cpp index c79279dd..fe693aea 100644 --- a/cl_dll/hl/hl_events.cpp +++ b/cl_dll/hl/hl_events.cpp @@ -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 ) 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 ); } diff --git a/cl_dll/hl/hl_weapons.cpp b/cl_dll/hl/hl_weapons.cpp index 4f119f02..28b5840f 100644 --- a/cl_dll/hl/hl_weapons.cpp +++ b/cl_dll/hl/hl_weapons.cpp @@ -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 ) 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 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 diff --git a/dlls/clcampaign/hammer.cpp b/dlls/clcampaign/hammer.cpp index 890e46b8..21495db6 100644 --- a/dlls/clcampaign/hammer.cpp +++ b/dlls/clcampaign/hammer.cpp @@ -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 ) 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 ) 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 */ ) 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, } } } -} +}*/ 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 ) // 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; } else { - SendWeaponAnim( CROWBAR_ATTACK); + SendWeaponAnim( HAMMER_ATTACK ); // player "shoot" animation m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); @@ -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; 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; } diff --git a/dlls/clcampaign/katana.cpp b/dlls/clcampaign/katana.cpp index 5bc62c08..1cfe2d0b 100644 --- a/dlls/clcampaign/katana.cpp +++ b/dlls/clcampaign/katana.cpp @@ -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( ) 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 ) 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, 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, 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, } } } -} +}*/ 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 ) 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 ) 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 ) 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 ) 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 ) 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; +} diff --git a/dlls/clcampaign/needle.cpp b/dlls/clcampaign/needle.cpp index 419c9e9b..04801822 100644 --- a/dlls/clcampaign/needle.cpp +++ b/dlls/clcampaign/needle.cpp @@ -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 ) 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 ) 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() 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; } diff --git a/dlls/clcampaign/pepsigun.cpp b/dlls/clcampaign/pepsigun.cpp index f9c9d7f2..bd6b43d9 100644 --- a/dlls/clcampaign/pepsigun.cpp +++ b/dlls/clcampaign/pepsigun.cpp @@ -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() 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() 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 ) { 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 ) // 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 ) 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 ) 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 ) 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 ); } } -} \ No newline at end of file +} diff --git a/dlls/clcampaign/rock.cpp b/dlls/clcampaign/rock.cpp index 9fc01f61..93ffacd3 100644 --- a/dlls/clcampaign/rock.cpp +++ b/dlls/clcampaign/rock.cpp @@ -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() 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 ) 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 ) { 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 ) 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 ); } diff --git a/dlls/clcampaign/sawnoff.cpp b/dlls/clcampaign/sawnoff.cpp index 18d5cd03..366800d5 100644 --- a/dlls/clcampaign/sawnoff.cpp +++ b/dlls/clcampaign/sawnoff.cpp @@ -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 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 ) 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 ) 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 ) 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() 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 ) #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 ) { 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 ) - diff --git a/dlls/clcampaign/sniper.cpp b/dlls/clcampaign/sniper.cpp index 3f74bff4..5699889c 100644 --- a/dlls/clcampaign/sniper.cpp +++ b/dlls/clcampaign/sniper.cpp @@ -1,4 +1,3 @@ -//fixed (maybe) #if !defined( OEM_BUILD ) && !defined( HLDEMO_BUILD ) #include "extdll.h" @@ -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 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 { 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; diff --git a/dlls/crossbow.cpp b/dlls/crossbow.cpp index a139f4d3..1075a0e3 100644 --- a/dlls/crossbow.cpp +++ b/dlls/crossbow.cpp @@ -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() // 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() diff --git a/dlls/crowbar.cpp b/dlls/crowbar.cpp index e22a3da2..a61bff8e 100644 --- a/dlls/crowbar.cpp +++ b/dlls/crowbar.cpp @@ -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() #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() diff --git a/dlls/ggrenade.cpp b/dlls/ggrenade.cpp index 08d17d50..e87154f5 100644 --- a/dlls/ggrenade.cpp +++ b/dlls/ggrenade.cpp @@ -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 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 ) } } +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 diff --git a/dlls/hornetgun.cpp b/dlls/hornetgun.cpp index dc7fb1c9..a76584ec 100644 --- a/dlls/hornetgun.cpp +++ b/dlls/hornetgun.cpp @@ -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() 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() // 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 ) 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 ) 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; } } diff --git a/dlls/mp5.cpp b/dlls/mp5.cpp index 0c6b6072..f3f794de 100644 --- a/dlls/mp5.cpp +++ b/dlls/mp5.cpp @@ -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() // 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 ) 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] ) diff --git a/dlls/player.cpp b/dlls/player.cpp index d26e2410..fc13c827 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -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 ) 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" ); diff --git a/dlls/rpg.cpp b/dlls/rpg.cpp index 16eb0168..03c7cf0a 100644 --- a/dlls/rpg.cpp +++ b/dlls/rpg.cpp @@ -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() #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 ) { 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 */ ) { 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() 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 #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; diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index 31456e37..463893a1 100644 --- a/dlls/weapons.cpp +++ b/dlls/weapons.cpp @@ -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" ); #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" ); // 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[] = }; 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 ) diff --git a/dlls/weapons.h b/dlls/weapons.h index 2a88a348..62a1bbab 100644 --- a/dlls/weapons.h +++ b/dlls/weapons.h @@ -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: 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: #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<