Browse Source

Update pipewrench

opforfixed
Roman Chistokhodov 5 years ago
parent
commit
8a28ac5749
  1. 2
      cl_dll/ev_hldm.cpp
  2. 8
      cl_dll/hl/hl_weapons.cpp
  3. 4
      dlls/client.cpp
  4. 443
      dlls/gearbox/pipewrench.cpp
  5. 5
      dlls/weapons.cpp
  6. 20
      dlls/weapons.h

2
cl_dll/ev_hldm.cpp

@ -2157,7 +2157,7 @@ void EV_PipeWrench( event_args_t *args ) @@ -2157,7 +2157,7 @@ void EV_PipeWrench( event_args_t *args )
break;
}
gEngfuncs.pEventAPI->EV_WeaponAnimation( PIPEWRENCH_ATTACK1MISS, 1 );
//gEngfuncs.pEventAPI->EV_WeaponAnimation( PIPEWRENCH_ATTACK1MISS, 1 );
// Send weapon anim.
switch( ( g_iSwing++ ) % 3 )

8
cl_dll/hl/hl_weapons.cpp

@ -884,6 +884,10 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm @@ -884,6 +884,10 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm
{
( (CEagle *)player.m_pActiveItem )->m_fEagleLaserActive = (int)from->client.vuser2[1];
}
if( player.m_pActiveItem->m_iId == WEAPON_PIPEWRENCH )
{
( (CPipeWrench *)player.m_pActiveItem )->m_iSwingMode = (int)from->client.vuser2[1];
}
else if( player.m_pActiveItem->m_iId == WEAPON_M249 )
{
player.ammo_556 = (int)from->client.vuser2[1];
@ -972,6 +976,10 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm @@ -972,6 +976,10 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm
{
from->client.vuser2[1] = ( (CEagle *)player.m_pActiveItem )->m_fEagleLaserActive;;
}
else if( player.m_pActiveItem->m_iId == WEAPON_PIPEWRENCH )
{
from->client.vuser2[1] = ( (CPipeWrench *)player.m_pActiveItem )->m_iSwingMode;
}
else if( player.m_pActiveItem->m_iId == WEAPON_M249 )
{
from->client.vuser2[1] = player.ammo_556;

4
dlls/client.cpp

@ -1823,6 +1823,10 @@ void UpdateClientData( const struct edict_s *ent, int sendweapons, struct client @@ -1823,6 +1823,10 @@ void UpdateClientData( const struct edict_s *ent, int sendweapons, struct client
{
cd->vuser2.y = ( (CEagle *)pl->m_pActiveItem )->m_fEagleLaserActive;
}
else if( pl->m_pActiveItem->m_iId == WEAPON_PIPEWRENCH )
{
cd->vuser2.y = ( (CPipeWrench *)pl->m_pActiveItem )->m_iSwingMode;
}
else if( pl->m_pActiveItem->m_iId == WEAPON_M249 )
{
cd->vuser2.y = pl->ammo_556;

443
dlls/gearbox/pipewrench.cpp

@ -24,14 +24,13 @@ @@ -24,14 +24,13 @@
void FindHullIntersection(const Vector &vecSrc, TraceResult &tr, float *mins, float *maxs, edict_t *pEntity);
#define PIPEWRENCH_BODYHIT_VOLUME 128
#define PIPEWRENCH_WALLHIT_VOLUME 512
#define MELEE_WALLHIT_VOLUME 512
#define MELEE_BODYHIT_VOLUME 128
#define PIPEWRENCH_ATTACK2_MIN_DAMAGE 45
#define PIPEWRENCH_ATTACK2_MAX_DAMAGE 200
#define PIPEWRENCH_ATTACK2_MAX_DAMAGE_HOLD_TIME 4
LINK_ENTITY_TO_CLASS(weapon_pipewrench, CPipeWrench);
LINK_ENTITY_TO_CLASS(weapon_pipewrench, CPipeWrench)
enum pwrench_e {
PIPEWRENCH_IDLE1 = 0,
@ -57,10 +56,9 @@ void CPipeWrench::Spawn() @@ -57,10 +56,9 @@ void CPipeWrench::Spawn()
Precache();
m_iId = WEAPON_PIPEWRENCH;
SET_MODEL(ENT(pev), "models/w_pipe_wrench.mdl");
m_iSwingMode = 0;
m_iClip = -1;
m_iFirestate = FIRESTATE_NONE;
FallInit();// get ready to fall down.
}
@ -77,6 +75,7 @@ void CPipeWrench::Precache(void) @@ -77,6 +75,7 @@ void CPipeWrench::Precache(void)
PRECACHE_SOUND("weapons/pwrench_hitbod2.wav");
PRECACHE_SOUND("weapons/pwrench_hitbod3.wav");
PRECACHE_SOUND("weapons/pwrench_miss1.wav");
PRECACHE_SOUND("weapons/pwrench_miss2.wav");
PRECACHE_SOUND("weapons/pwrench_big_hitbod1.wav");
PRECACHE_SOUND("weapons/pwrench_big_hitbod2.wav");
@ -104,161 +103,216 @@ int CPipeWrench::GetItemInfo(ItemInfo *p) @@ -104,161 +103,216 @@ int CPipeWrench::GetItemInfo(ItemInfo *p)
BOOL CPipeWrench::Deploy()
{
m_iFirestate = FIRESTATE_NONE;
m_iSwingMode = 0;
return DefaultDeploy("models/v_pipe_wrench.mdl", "models/p_pipe_wrench.mdl", PIPEWRENCH_DRAW, "pipewrench");
}
void CPipeWrench::Holster(int skiplocal /* = 0 */)
{
m_iFirestate = FIRESTATE_NONE;
m_iSwingMode = 0;
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5;
SendWeaponAnim(PIPEWRENCH_HOLSTER);
}
void CPipeWrench::PrimaryAttack()
{
if (!Swing(1, TRUE))
if (!m_iSwingMode && !Swing(1))
{
#ifndef CLIENT_DLL
SetThink(&CPipeWrench::SwingAgain);
pev->nextthink = gpGlobals->time + 0.1;
#endif
}
}
void CPipeWrench::SecondaryAttack(void)
{
if (m_iFirestate != FIRESTATE_NONE)
return;
m_iFirestate = FIRESTATE_WINDUP;
if (m_iSwingMode != 1)
{
SendWeaponAnim(PIPEWRENCH_ATTACKBIGWIND);
m_flNextPrimaryAttack = m_flNextSecondaryAttack = GetNextAttackDelay(1.0f);
pev->nextthink = UTIL_WeaponTimeBase() + 1.0f;
ALERT( at_console, "CPipeWrench::SecondaryAttack\n" );
m_flBigSwingStart = gpGlobals->time;
}
m_iSwingMode = 1;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.3;
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.1;
}
void CPipeWrench::ItemPostFrame(void)
void CPipeWrench::Smack()
{
DecalGunshot(&m_trHit, BULLET_PLAYER_CROWBAR);
}
if (!(m_pPlayer->pev->button & IN_ATTACK))
void CPipeWrench::SwingAgain(void)
{
m_flLastFireTime = 0.0f;
Swing(0);
}
if (m_iFirestate != FIRESTATE_NONE)
int CPipeWrench::Swing(int fFirst)
{
// Set primary attack flag off, in case the player is thinking of doing a primary
// attack while the secondary attack sequence is incomplete.
m_pPlayer->pev->button &= ~IN_ATTACK;
int fDidHit = FALSE;
if (CanAttack(m_flNextSecondaryAttack, gpGlobals->time, UseDecrement()))
TraceResult tr;
UTIL_MakeVectors( m_pPlayer->pev->v_angle );
Vector vecSrc = m_pPlayer->GetGunPosition( );
Vector vecEnd = vecSrc + gpGlobals->v_forward * 32;
UTIL_TraceLine( vecSrc, vecEnd, dont_ignore_monsters, ENT( m_pPlayer->pev ), &tr );
#ifndef CLIENT_DLL
if ( tr.flFraction >= 1.0 )
{
switch (m_iFirestate)
UTIL_TraceHull( vecSrc, vecEnd, dont_ignore_monsters, head_hull, ENT( m_pPlayer->pev ), &tr );
if ( tr.flFraction < 1.0 )
{
case FIRESTATE_WINDUP:
// 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() )
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
if (fFirst)
{
ALERT(at_console, "CPipeWrench::FIRESTATE_WINDUP\n");
PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usPWrench,
0.0, (float*)&g_vecZero, (float*)&g_vecZero, 0, 0, 1,
0, 0, 0 );
}
m_iFirestate = FIRESTATE_WINDLOOP;
if ( tr.flFraction >= 1.0 )
{
// miss
if ( fFirst ) {
m_flNextPrimaryAttack = GetNextAttackDelay(0.7);
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.7;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 5.0;
// player "shoot" animation
m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
}
}
else
{
switch( ((m_iSwing++) % 2) + 1 )
{
case 0:
SendWeaponAnim( PIPEWRENCH_ATTACK1HIT );
break;
case 1:
SendWeaponAnim( PIPEWRENCH_ATTACK2HIT );
break;
case 2:
SendWeaponAnim( PIPEWRENCH_ATTACK3HIT );
break;
}
SendWeaponAnim(PIPEWRENCH_ATTACKBIGLOOP);
// player "shoot" animation
m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
m_flHoldStartTime = gpGlobals->time;
#ifndef CLIENT_DLL
m_flNextPrimaryAttack = m_flNextSecondaryAttack = GetNextAttackDelay(0.01f);
pev->nextthink = UTIL_WeaponTimeBase() + 0.01f;
}
break;
// hit
fDidHit = TRUE;
CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit);
// play thwack, smack, or dong sound
float flVol = 1.0;
int fHitWorld = TRUE;
case FIRESTATE_WINDLOOP:
if( pEntity )
{
ALERT(at_console, "CPipeWrench::FIRESTATE_WINDLOOP\n");
if (!(m_pPlayer->pev->button & IN_ATTACK2))
ClearMultiDamage();
float flDamage;
#ifdef CLIENT_WEAPONS
if( ( m_flNextPrimaryAttack + 1 == UTIL_WeaponTimeBase() ) || g_pGameRules->IsMultiplayer() )
#else
if( ( m_flNextPrimaryAttack + 1 < UTIL_WeaponTimeBase() ) || g_pGameRules->IsMultiplayer() )
#endif
{
ALERT(at_console, "Releasing CPipeWrench\n");
m_iFirestate = FIRESTATE_BIGHIT;
// first swing does full damage
flDamage = gSkillData.plrDmgPWrench;
}
else
{
ALERT(at_console, "Holding CPipeWrench\n");
SendWeaponAnim(PIPEWRENCH_ATTACKBIGLOOP);
}
m_flNextPrimaryAttack = m_flNextSecondaryAttack = GetNextAttackDelay(0.01f);
// subsequent swings do half
flDamage = gSkillData.plrDmgPWrench / 2;
}
break;
case FIRESTATE_BIGHIT:
{
ALERT(at_console, "CPipeWrench::FIRESTATE_BIGHIT\n");
Swing(1, FALSE);
m_iFirestate = FIRESTATE_NONE;
// Send trace attack to player.
pEntity->TraceAttack(m_pPlayer->pev, flDamage, gpGlobals->v_forward, &tr, DMG_CLUB);
m_flHoldStartTime = 0.0f;
ApplyMultiDamage(m_pPlayer->pev, m_pPlayer->pev);
m_pPlayer->pev->button &= ~IN_ATTACK2;
if ( pEntity->Classify() != CLASS_NONE && pEntity->Classify() != CLASS_MACHINE )
{
// play thwack or smack sound
switch( RANDOM_LONG(0,2) )
{
case 0:
EMIT_SOUND( ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/pwrench_hitbod1.wav", 1, ATTN_NORM); break;
case 1:
EMIT_SOUND( ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/pwrench_hitbod2.wav", 1, ATTN_NORM); break;
case 2:
EMIT_SOUND( ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/pwrench_hitbod3.wav", 1, ATTN_NORM); break;
}
break;
m_pPlayer->m_iWeaponVolume = MELEE_BODYHIT_VOLUME;
if ( !pEntity->IsAlive() )
{
m_flNextPrimaryAttack = GetNextAttackDelay(0.5);
return TRUE;
}
else
flVol = 0.1;
fHitWorld = FALSE;
}
return;
}
if ((m_pPlayer->pev->button & IN_ATTACK2) && CanAttack(m_flNextSecondaryAttack, gpGlobals->time, UseDecrement()))
{
#ifndef CLIENT_DLL
m_pPlayer->TabulateAmmo();
#endif
SecondaryAttack();
m_pPlayer->pev->button &= ~IN_ATTACK2;
}
else if ((m_pPlayer->pev->button & IN_ATTACK) && CanAttack(m_flNextPrimaryAttack, gpGlobals->time, UseDecrement()))
// play texture hit sound
// UNDONE: Calculate the correct point of intersection when we hit with the hull instead of the line
if( fHitWorld )
{
float fvolbar = TEXTURETYPE_PlaySound(&tr, vecSrc, vecSrc + (vecEnd-vecSrc)*2, BULLET_PLAYER_CROWBAR );
#ifndef CLIENT_DLL
m_pPlayer->TabulateAmmo();
#endif
PrimaryAttack();
m_pPlayer->pev->button &= ~IN_ATTACK;
}
else if (!(m_pPlayer->pev->button & (IN_ATTACK | IN_ATTACK2)))
if ( g_pGameRules->IsMultiplayer() )
{
// no fire buttons down
WeaponIdle();
return;
// override the volume here, cause we don't play texture sounds in multiplayer,
// and fvolbar is going to be 0 from the above call.
fvolbar = 1;
}
// catch all
if (ShouldWeaponIdle())
// also play pipe wrench strike
switch( RANDOM_LONG(0,1) )
{
WeaponIdle();
}
case 0:
EMIT_SOUND_DYN( ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/pwrench_hit1.wav", fvolbar, ATTN_NORM, 0, 98 + RANDOM_LONG(0,3));
break;
case 1:
EMIT_SOUND_DYN( ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/pwrench_hit2.wav", fvolbar, ATTN_NORM, 0, 98 + RANDOM_LONG(0,3));
break;
}
void CPipeWrench::Smack()
{
DecalGunshot(&m_trHit, BULLET_PLAYER_CROWBAR);
// delay the decal a bit
m_trHit = tr;
}
m_pPlayer->m_iWeaponVolume = (int)( flVol * MELEE_WALLHIT_VOLUME );
void CPipeWrench::SwingAgain(void)
{
Swing(0, TRUE);
SetThink( &CPipeWrench::Smack );
pev->nextthink = UTIL_WeaponTimeBase() + 0.2;
#endif
m_flNextPrimaryAttack = GetNextAttackDelay(0.5);
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5;
}
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 5.0;
return fDidHit;
}
#define clamp( val, min, max ) ( ((val) > (max)) ? (max) : ( ((val) < (min)) ? (min) : (val) ) )
int CPipeWrench::Swing(int fFirst, BOOL fIsPrimary)
void CPipeWrench::BigSwing(void)
{
int fDidHit = FALSE;
TraceResult tr;
UTIL_MakeVectors( m_pPlayer->pev->v_angle );
@ -284,102 +338,42 @@ int CPipeWrench::Swing(int fFirst, BOOL fIsPrimary) @@ -284,102 +338,42 @@ int CPipeWrench::Swing(int fFirst, BOOL fIsPrimary)
#endif
PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usPWrench,
0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0, 0, fIsPrimary,
0.0, 0, 0.0);
0.0,
(float*)&g_vecZero,
(float*)&g_vecZero,
0, 0, 0, 0, 0, 0 );
//EMIT_SOUND( ENT(m_pPlayer->pev), CHAN_WEAPON, "weapons/pwrench_big_miss.wav", 0.8, ATTN_NORM);
m_pPlayer->pev->punchangle.x -= 2;
if ( tr.flFraction >= 1.0 )
{
// miss
m_flNextPrimaryAttack = m_flNextSecondaryAttack = (fIsPrimary)
? GetNextAttackDelay(0.35f)
: GetNextAttackDelay(1.0f);
// player "shoot" animation
m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
}
else
{
if (fIsPrimary)
{
switch (((m_iSwing++) % 2) + 1)
{
case 0:
SendWeaponAnim(PIPEWRENCH_ATTACK1HIT); break;
case 1:
SendWeaponAnim(PIPEWRENCH_ATTACK2HIT); break;
case 2:
SendWeaponAnim(PIPEWRENCH_ATTACK3HIT); break;
}
}
else
{
SendWeaponAnim( PIPEWRENCH_ATTACKBIGHIT );
m_pPlayer->pev->punchangle.x = -5;
}
// player "shoot" animation
m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
#ifndef CLIENT_DLL
// hit
fDidHit = TRUE;
CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit);
ClearMultiDamage();
float flDamage;
if (!fIsPrimary)
{
float flRealDamage, flTotalDamageSpan;
float flRealHoldTimeDelta, flNormHoldTimeDelta;
float flNormHoldTimeProp;
// Get the total damge to be dealt with, excluding the starting minimum.
flTotalDamageSpan = PIPEWRENCH_ATTACK2_MAX_DAMAGE - PIPEWRENCH_ATTACK2_MIN_DAMAGE;
// Get the time delta since we hold the secondary attack button.
flRealHoldTimeDelta = clamp(gpGlobals->time - m_flHoldStartTime, 0, PIPEWRENCH_ATTACK2_MAX_DAMAGE_HOLD_TIME);
// Normalize the value, between 0. and 1.0
flNormHoldTimeProp = clamp(flRealHoldTimeDelta / PIPEWRENCH_ATTACK2_MAX_DAMAGE_HOLD_TIME, 0.0f, 1.0f);
// Establish a proportion between normalized value and total hold time
// for maximum damage.
flNormHoldTimeDelta = flNormHoldTimeProp * PIPEWRENCH_ATTACK2_MAX_DAMAGE_HOLD_TIME;
// Convert the computed proportion relative to maximum hold time, to damage.
flRealDamage = (flTotalDamageSpan * flNormHoldTimeDelta) / PIPEWRENCH_ATTACK2_MAX_DAMAGE_HOLD_TIME;
// Add the desired extra damage to the minimum.
flDamage = PIPEWRENCH_ATTACK2_MIN_DAMAGE + flRealDamage;
// Clamp the new desired damage value between min and max.
flDamage = clamp(flDamage, PIPEWRENCH_ATTACK2_MIN_DAMAGE, PIPEWRENCH_ATTACK2_MAX_DAMAGE);
}
else
{
if ((m_flNextPrimaryAttack + 1 < UTIL_WeaponTimeBase()) || g_pGameRules->IsMultiplayer())
{
// first swing does full damage
flDamage = gSkillData.plrDmgPWrench;
}
else
if( pEntity )
{
// subsequent swings do half
flDamage = gSkillData.plrDmgPWrench / 2;
}
ClearMultiDamage();
float flDamage = (gpGlobals->time - m_flBigSwingStart) * gSkillData.plrDmgPWrench + 25.0f;
if (flDamage > PIPEWRENCH_ATTACK2_MAX_DAMAGE) {
flDamage = PIPEWRENCH_ATTACK2_MAX_DAMAGE;
}
ALERT(at_console, "PipeWrench damage: %f\n", flDamage);
// Send trace attack to player.
pEntity->TraceAttack(m_pPlayer->pev, flDamage, gpGlobals->v_forward, &tr, DMG_CLUB);
ApplyMultiDamage(m_pPlayer->pev, m_pPlayer->pev);
}
// play thwack, smack, or dong sound
float flVol = 1.0;
@ -390,40 +384,26 @@ int CPipeWrench::Swing(int fFirst, BOOL fIsPrimary) @@ -390,40 +384,26 @@ int CPipeWrench::Swing(int fFirst, BOOL fIsPrimary)
if (pEntity->Classify() != CLASS_NONE && pEntity->Classify() != CLASS_MACHINE)
{
// play thwack or smack sound
if (fIsPrimary)
{
// Primary attack body hit sound.
switch (RANDOM_LONG(0, 2))
{
case 0: EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/pwrench_hitbod1.wav", 1, ATTN_NORM); break;
case 1: EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/pwrench_hitbod2.wav", 1, ATTN_NORM); break;
case 2: EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/pwrench_hitbod3.wav", 1, ATTN_NORM); break;
}
}
else
{
// Secondary attack body hit sound.
switch( RANDOM_LONG(0,1) )
{
case 0: EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/pwrench_big_hitbod1.wav", 1, ATTN_NORM); break;
case 1: EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/pwrench_big_hitbod2.wav", 1, ATTN_NORM); break;
}
case 0:
EMIT_SOUND( ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/pwrench_big_hitbod1.wav", 1, ATTN_NORM);
break;
case 1:
EMIT_SOUND( ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/pwrench_big_hitbod2.wav", 1, ATTN_NORM);
break;
}
m_pPlayer->m_iWeaponVolume = PIPEWRENCH_BODYHIT_VOLUME;
m_pPlayer->m_iWeaponVolume = MELEE_BODYHIT_VOLUME;
if ( !pEntity->IsAlive() )
return TRUE;
return;
else
flVol = 0.1;
fHitWorld = FALSE;
fHitWorld = false;
}
}
// play texture hit sound
// UNDONE: Calculate the correct point of intersection when we hit with the hull instead of the line
if( fHitWorld )
{
float fvolbar = TEXTURETYPE_PlaySound(&tr, vecSrc, vecSrc + (vecEnd-vecSrc)*2, BULLET_PLAYER_CROWBAR );
@ -436,17 +416,13 @@ int CPipeWrench::Swing(int fFirst, BOOL fIsPrimary) @@ -436,17 +416,13 @@ int CPipeWrench::Swing(int fFirst, BOOL fIsPrimary)
fvolbar = 1;
}
// also play crowbar strike
//
// Shared between both primary and secondary attack.
//
switch( RANDOM_LONG(0,1) )
{
case 0:
EMIT_SOUND_DYN( ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/pwrench_hit1.wav", fvolbar, ATTN_NORM, 0, 98 + RANDOM_LONG(0,3));
break;
case 1:
EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/pwrench_hit1.wav", fvolbar, ATTN_NORM, 0, 98 + RANDOM_LONG(0, 3));
EMIT_SOUND_DYN( ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/pwrench_hit2.wav", fvolbar, ATTN_NORM, 0, 98 + RANDOM_LONG(0,3));
break;
}
@ -454,69 +430,50 @@ int CPipeWrench::Swing(int fFirst, BOOL fIsPrimary) @@ -454,69 +430,50 @@ int CPipeWrench::Swing(int fFirst, BOOL fIsPrimary)
m_trHit = tr;
}
m_pPlayer->m_iWeaponVolume = flVol * PIPEWRENCH_WALLHIT_VOLUME;
m_pPlayer->m_iWeaponVolume = (int)( flVol * MELEE_WALLHIT_VOLUME );
#endif
m_flNextPrimaryAttack = m_flNextSecondaryAttack = (fIsPrimary)
? GetNextAttackDelay(0.5f)
: GetNextAttackDelay(1.0f);
SetThink(&CPipeWrench::Smack);
pev->nextthink = UTIL_WeaponTimeBase() + 0.2;
}
return fDidHit;
}
void CPipeWrench::WindUp(void)
void CPipeWrench::WeaponIdle(void)
{
SendWeaponAnim(PIPEWRENCH_ATTACKBIGWIND);
SetThink(&CPipeWrench::WindLoop);
m_flNextSecondaryAttack = GetNextAttackDelay(1.0f);
pev->nextthink = UTIL_WeaponTimeBase() + 1.0f;
}
void CPipeWrench::WindLoop(void)
if ( m_iSwingMode == 1 )
{
if (m_flNextSecondaryAttack < UTIL_WeaponTimeBase() && !(m_pPlayer->pev->button & IN_ATTACK2))
if ( gpGlobals->time > m_flBigSwingStart + 1.0 )
{
if (!Swing(1, FALSE))
{
SetThink(&CPipeWrench::SwingAgain2);
pev->nextthink = UTIL_WeaponTimeBase() + 0.1f;
}
return;
m_iSwingMode = 2;
}
SendWeaponAnim( PIPEWRENCH_ATTACKBIGLOOP );
pev->nextthink = UTIL_WeaponTimeBase() + 0.1f;
}
void CPipeWrench::SwingAgain2(void)
else if (m_iSwingMode == 2)
{
Swing(0, FALSE);
m_flNextSecondaryAttack = m_flNextPrimaryAttack = m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.1;
BigSwing();
m_iSwingMode = 0;
return;
}
else
{
m_iSwingMode = 0;
if ( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() )
return;
int iAnim;
float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0.0, 1.0 );
//=========================================================
// Purpose:
//=========================================================
BOOL CPipeWrench::CanAttack(float attack_time, float curtime, BOOL isPredicted)
if ( flRand <= 0.3 )
{
#if defined( CLIENT_WEAPONS )
if (!isPredicted)
#else
if (1)
#endif
iAnim = PIPEWRENCH_IDLE1;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.0;
}
else if ( flRand <= 0.6 )
{
return (attack_time <= curtime) ? TRUE : FALSE;
iAnim = PIPEWRENCH_IDLE2;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 3.0;
}
else
{
return (attack_time <= 0.0) ? TRUE : FALSE;
iAnim = PIPEWRENCH_IDLE3;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 3.0;
}
SendWeaponAnim( iAnim );
}
}

5
dlls/weapons.cpp

@ -1707,8 +1707,9 @@ IMPLEMENT_SAVERESTORE( CM249, CBasePlayerWeapon ) @@ -1707,8 +1707,9 @@ IMPLEMENT_SAVERESTORE( CM249, CBasePlayerWeapon )
TYPEDESCRIPTION CPipeWrench::m_SaveData[] =
{
DEFINE_FIELD( CPipeWrench, m_iFirestate, FIELD_INTEGER ),
DEFINE_FIELD( CPipeWrench, m_flHoldStartTime, FIELD_TIME ),
DEFINE_FIELD( CPipeWrench, m_flBigSwingStart, FIELD_TIME ),
DEFINE_FIELD( CPipeWrench, m_iSwing, FIELD_INTEGER ),
DEFINE_FIELD( CPipeWrench, m_iSwingMode, FIELD_INTEGER ),
};
IMPLEMENT_SAVERESTORE( CPipeWrench, CBasePlayerWeapon )

20
dlls/weapons.h

@ -1345,7 +1345,6 @@ public: @@ -1345,7 +1345,6 @@ public:
static TYPEDESCRIPTION m_SaveData[];
#endif
void Spawn(void);
void Precache(void);
int iItemSlot(void) { return 1; }
@ -1355,13 +1354,16 @@ public: @@ -1355,13 +1354,16 @@ public:
void PrimaryAttack(void);
void SecondaryAttack(void);
void ItemPostFrame(void);
virtual BOOL ShouldWeaponIdle(void) { return FALSE; };
int Swing(int fFirst, BOOL fIsPrimary);
int Swing(int fFirst);
BOOL Deploy(void);
void WeaponIdle(void);
void Holster(int skiplocal = 0);
void BigSwing(void);
int m_iSwing;
TraceResult m_trHit;
int m_iSwingMode;
float m_flBigSwingStart;
virtual BOOL UseDecrement(void)
{
@ -1372,17 +1374,7 @@ public: @@ -1372,17 +1374,7 @@ public:
#endif
}
private:
unsigned short m_usPWrench;
void EXPORT WindUp(void);
void EXPORT WindLoop(void);
void EXPORT SwingAgain2(void);
BOOL CanAttack(float attack_time, float curtime, BOOL isPredicted);
enum PWRENCH_FIRESTATE { FIRESTATE_NONE = 0, FIRESTATE_WINDUP, FIRESTATE_WINDLOOP, FIRESTATE_BIGHIT };
int m_iFirestate;
float m_flHoldStartTime;
};

Loading…
Cancel
Save