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 )
break; break;
} }
gEngfuncs.pEventAPI->EV_WeaponAnimation( PIPEWRENCH_ATTACK1MISS, 1 ); //gEngfuncs.pEventAPI->EV_WeaponAnimation( PIPEWRENCH_ATTACK1MISS, 1 );
// Send weapon anim. // Send weapon anim.
switch( ( g_iSwing++ ) % 3 ) 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
{ {
( (CEagle *)player.m_pActiveItem )->m_fEagleLaserActive = (int)from->client.vuser2[1]; ( (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 ) else if( player.m_pActiveItem->m_iId == WEAPON_M249 )
{ {
player.ammo_556 = (int)from->client.vuser2[1]; 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
{ {
from->client.vuser2[1] = ( (CEagle *)player.m_pActiveItem )->m_fEagleLaserActive;; 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 ) else if( player.m_pActiveItem->m_iId == WEAPON_M249 )
{ {
from->client.vuser2[1] = player.ammo_556; 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
{ {
cd->vuser2.y = ( (CEagle *)pl->m_pActiveItem )->m_fEagleLaserActive; 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 ) else if( pl->m_pActiveItem->m_iId == WEAPON_M249 )
{ {
cd->vuser2.y = pl->ammo_556; cd->vuser2.y = pl->ammo_556;

443
dlls/gearbox/pipewrench.cpp

@ -24,14 +24,13 @@
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);
#define PIPEWRENCH_BODYHIT_VOLUME 128 #define MELEE_WALLHIT_VOLUME 512
#define PIPEWRENCH_WALLHIT_VOLUME 512 #define MELEE_BODYHIT_VOLUME 128
#define PIPEWRENCH_ATTACK2_MIN_DAMAGE 45 #define PIPEWRENCH_ATTACK2_MIN_DAMAGE 45
#define PIPEWRENCH_ATTACK2_MAX_DAMAGE 200 #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 { enum pwrench_e {
PIPEWRENCH_IDLE1 = 0, PIPEWRENCH_IDLE1 = 0,
@ -57,10 +56,9 @@ void CPipeWrench::Spawn()
Precache(); Precache();
m_iId = WEAPON_PIPEWRENCH; m_iId = WEAPON_PIPEWRENCH;
SET_MODEL(ENT(pev), "models/w_pipe_wrench.mdl"); SET_MODEL(ENT(pev), "models/w_pipe_wrench.mdl");
m_iSwingMode = 0;
m_iClip = -1; m_iClip = -1;
m_iFirestate = FIRESTATE_NONE;
FallInit();// get ready to fall down. FallInit();// get ready to fall down.
} }
@ -77,6 +75,7 @@ void CPipeWrench::Precache(void)
PRECACHE_SOUND("weapons/pwrench_hitbod2.wav"); PRECACHE_SOUND("weapons/pwrench_hitbod2.wav");
PRECACHE_SOUND("weapons/pwrench_hitbod3.wav"); PRECACHE_SOUND("weapons/pwrench_hitbod3.wav");
PRECACHE_SOUND("weapons/pwrench_miss1.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_hitbod1.wav");
PRECACHE_SOUND("weapons/pwrench_big_hitbod2.wav"); PRECACHE_SOUND("weapons/pwrench_big_hitbod2.wav");
@ -104,161 +103,216 @@ int CPipeWrench::GetItemInfo(ItemInfo *p)
BOOL CPipeWrench::Deploy() 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"); return DefaultDeploy("models/v_pipe_wrench.mdl", "models/p_pipe_wrench.mdl", PIPEWRENCH_DRAW, "pipewrench");
} }
void CPipeWrench::Holster(int skiplocal /* = 0 */) void CPipeWrench::Holster(int skiplocal /* = 0 */)
{ {
m_iFirestate = FIRESTATE_NONE; m_iSwingMode = 0;
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5;
SendWeaponAnim(PIPEWRENCH_HOLSTER); SendWeaponAnim(PIPEWRENCH_HOLSTER);
} }
void CPipeWrench::PrimaryAttack() void CPipeWrench::PrimaryAttack()
{ {
if (!Swing(1, TRUE)) if (!m_iSwingMode && !Swing(1))
{ {
#ifndef CLIENT_DLL
SetThink(&CPipeWrench::SwingAgain); SetThink(&CPipeWrench::SwingAgain);
pev->nextthink = gpGlobals->time + 0.1; pev->nextthink = gpGlobals->time + 0.1;
#endif
} }
} }
void CPipeWrench::SecondaryAttack(void) void CPipeWrench::SecondaryAttack(void)
{ {
if (m_iFirestate != FIRESTATE_NONE) if (m_iSwingMode != 1)
return; {
m_iFirestate = FIRESTATE_WINDUP;
SendWeaponAnim(PIPEWRENCH_ATTACKBIGWIND); SendWeaponAnim(PIPEWRENCH_ATTACKBIGWIND);
m_flBigSwingStart = gpGlobals->time;
m_flNextPrimaryAttack = m_flNextSecondaryAttack = GetNextAttackDelay(1.0f); }
pev->nextthink = UTIL_WeaponTimeBase() + 1.0f; m_iSwingMode = 1;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.3;
ALERT( at_console, "CPipeWrench::SecondaryAttack\n" ); m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.1;
} }
void CPipeWrench::Smack()
void CPipeWrench::ItemPostFrame(void)
{ {
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 int fDidHit = FALSE;
// attack while the secondary attack sequence is incomplete.
m_pPlayer->pev->button &= ~IN_ATTACK;
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); // hit
pev->nextthink = UTIL_WeaponTimeBase() + 0.01f; fDidHit = TRUE;
} CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit);
break;
// 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"); ClearMultiDamage();
if (!(m_pPlayer->pev->button & IN_ATTACK2)) 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"); // first swing does full damage
m_iFirestate = FIRESTATE_BIGHIT; flDamage = gSkillData.plrDmgPWrench;
} }
else else
{ {
ALERT(at_console, "Holding CPipeWrench\n"); // subsequent swings do half
SendWeaponAnim(PIPEWRENCH_ATTACKBIGLOOP); flDamage = gSkillData.plrDmgPWrench / 2;
}
m_flNextPrimaryAttack = m_flNextSecondaryAttack = GetNextAttackDelay(0.01f);
} }
break; // Send trace attack to player.
pEntity->TraceAttack(m_pPlayer->pev, flDamage, gpGlobals->v_forward, &tr, DMG_CLUB);
case FIRESTATE_BIGHIT:
{
ALERT(at_console, "CPipeWrench::FIRESTATE_BIGHIT\n");
Swing(1, FALSE);
m_iFirestate = FIRESTATE_NONE;
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())) // play texture hit sound
{ // UNDONE: Calculate the correct point of intersection when we hit with the hull instead of the line
#ifndef CLIENT_DLL
m_pPlayer->TabulateAmmo(); if( fHitWorld )
#endif
SecondaryAttack();
m_pPlayer->pev->button &= ~IN_ATTACK2;
}
else if ((m_pPlayer->pev->button & IN_ATTACK) && CanAttack(m_flNextPrimaryAttack, gpGlobals->time, UseDecrement()))
{ {
float fvolbar = TEXTURETYPE_PlaySound(&tr, vecSrc, vecSrc + (vecEnd-vecSrc)*2, BULLET_PLAYER_CROWBAR );
#ifndef CLIENT_DLL if ( g_pGameRules->IsMultiplayer() )
m_pPlayer->TabulateAmmo();
#endif
PrimaryAttack();
m_pPlayer->pev->button &= ~IN_ATTACK;
}
else if (!(m_pPlayer->pev->button & (IN_ATTACK | IN_ATTACK2)))
{ {
// no fire buttons down // override the volume here, cause we don't play texture sounds in multiplayer,
WeaponIdle(); // and fvolbar is going to be 0 from the above call.
return;
fvolbar = 1;
} }
// catch all // also play pipe wrench strike
if (ShouldWeaponIdle()) 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() // delay the decal a bit
{ m_trHit = tr;
DecalGunshot(&m_trHit, BULLET_PLAYER_CROWBAR);
} }
m_pPlayer->m_iWeaponVolume = (int)( flVol * MELEE_WALLHIT_VOLUME );
void CPipeWrench::SwingAgain(void) SetThink( &CPipeWrench::Smack );
{ pev->nextthink = UTIL_WeaponTimeBase() + 0.2;
Swing(0, TRUE); #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) ) ) void CPipeWrench::BigSwing(void)
int CPipeWrench::Swing(int fFirst, BOOL fIsPrimary)
{ {
int fDidHit = FALSE;
TraceResult tr; TraceResult tr;
UTIL_MakeVectors( m_pPlayer->pev->v_angle ); UTIL_MakeVectors( m_pPlayer->pev->v_angle );
@ -284,102 +338,42 @@ int CPipeWrench::Swing(int fFirst, BOOL fIsPrimary)
#endif #endif
PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usPWrench, 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 ) if ( tr.flFraction >= 1.0 )
{ {
// miss
m_flNextPrimaryAttack = m_flNextSecondaryAttack = (fIsPrimary)
? GetNextAttackDelay(0.35f)
: GetNextAttackDelay(1.0f);
// player "shoot" animation // player "shoot" animation
m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
} }
else 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 ); SendWeaponAnim( PIPEWRENCH_ATTACKBIGHIT );
m_pPlayer->pev->punchangle.x = -5;
}
// player "shoot" animation // player "shoot" animation
m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
#ifndef CLIENT_DLL #ifndef CLIENT_DLL
// hit // hit
fDidHit = TRUE;
CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit); CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit);
ClearMultiDamage(); if( pEntity )
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
{ {
// subsequent swings do half ClearMultiDamage();
flDamage = gSkillData.plrDmgPWrench / 2; 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); pEntity->TraceAttack(m_pPlayer->pev, flDamage, gpGlobals->v_forward, &tr, DMG_CLUB);
ApplyMultiDamage(m_pPlayer->pev, m_pPlayer->pev); ApplyMultiDamage(m_pPlayer->pev, m_pPlayer->pev);
}
// play thwack, smack, or dong sound // play thwack, smack, or dong sound
float flVol = 1.0; float flVol = 1.0;
@ -390,40 +384,26 @@ int CPipeWrench::Swing(int fFirst, BOOL fIsPrimary)
if (pEntity->Classify() != CLASS_NONE && pEntity->Classify() != CLASS_MACHINE) if (pEntity->Classify() != CLASS_NONE && pEntity->Classify() != CLASS_MACHINE)
{ {
// play thwack or smack sound // 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) ) 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 0:
case 1: EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/pwrench_big_hitbod2.wav", 1, ATTN_NORM); break; 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 = MELEE_BODYHIT_VOLUME;
m_pPlayer->m_iWeaponVolume = PIPEWRENCH_BODYHIT_VOLUME;
if ( !pEntity->IsAlive() ) if ( !pEntity->IsAlive() )
return TRUE; return;
else else
flVol = 0.1; flVol = 0.1;
fHitWorld = FALSE; fHitWorld = false;
} }
} }
// play texture hit sound // play texture hit sound
// UNDONE: Calculate the correct point of intersection when we hit with the hull instead of the line
if( fHitWorld ) if( fHitWorld )
{ {
float fvolbar = TEXTURETYPE_PlaySound(&tr, vecSrc, vecSrc + (vecEnd-vecSrc)*2, BULLET_PLAYER_CROWBAR ); float fvolbar = TEXTURETYPE_PlaySound(&tr, vecSrc, vecSrc + (vecEnd-vecSrc)*2, BULLET_PLAYER_CROWBAR );
@ -436,17 +416,13 @@ int CPipeWrench::Swing(int fFirst, BOOL fIsPrimary)
fvolbar = 1; fvolbar = 1;
} }
// also play crowbar strike
//
// Shared between both primary and secondary attack.
//
switch( RANDOM_LONG(0,1) ) switch( RANDOM_LONG(0,1) )
{ {
case 0: case 0:
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_hit1.wav", fvolbar, ATTN_NORM, 0, 98 + RANDOM_LONG(0,3));
break; break;
case 1: 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; break;
} }
@ -454,69 +430,50 @@ int CPipeWrench::Swing(int fFirst, BOOL fIsPrimary)
m_trHit = tr; m_trHit = tr;
} }
m_pPlayer->m_iWeaponVolume = flVol * PIPEWRENCH_WALLHIT_VOLUME; m_pPlayer->m_iWeaponVolume = (int)( flVol * MELEE_WALLHIT_VOLUME );
#endif #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); if ( m_iSwingMode == 1 )
SetThink(&CPipeWrench::WindLoop);
m_flNextSecondaryAttack = GetNextAttackDelay(1.0f);
pev->nextthink = UTIL_WeaponTimeBase() + 1.0f;
}
void CPipeWrench::WindLoop(void)
{ {
if (m_flNextSecondaryAttack < UTIL_WeaponTimeBase() && !(m_pPlayer->pev->button & IN_ATTACK2)) if ( gpGlobals->time > m_flBigSwingStart + 1.0 )
{ {
if (!Swing(1, FALSE)) m_iSwingMode = 2;
{
SetThink(&CPipeWrench::SwingAgain2);
pev->nextthink = UTIL_WeaponTimeBase() + 0.1f;
}
return;
} }
SendWeaponAnim( PIPEWRENCH_ATTACKBIGLOOP );
pev->nextthink = UTIL_WeaponTimeBase() + 0.1f;
} }
else if (m_iSwingMode == 2)
void CPipeWrench::SwingAgain2(void)
{ {
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 );
if ( flRand <= 0.3 )
//=========================================================
// Purpose:
//=========================================================
BOOL CPipeWrench::CanAttack(float attack_time, float curtime, BOOL isPredicted)
{ {
#if defined( CLIENT_WEAPONS ) iAnim = PIPEWRENCH_IDLE1;
if (!isPredicted) m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.0;
#else }
if (1) else if ( flRand <= 0.6 )
#endif
{ {
return (attack_time <= curtime) ? TRUE : FALSE; iAnim = PIPEWRENCH_IDLE2;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 3.0;
} }
else 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 )
TYPEDESCRIPTION CPipeWrench::m_SaveData[] = TYPEDESCRIPTION CPipeWrench::m_SaveData[] =
{ {
DEFINE_FIELD( CPipeWrench, m_iFirestate, FIELD_INTEGER ), DEFINE_FIELD( CPipeWrench, m_flBigSwingStart, FIELD_TIME ),
DEFINE_FIELD( CPipeWrench, m_flHoldStartTime, FIELD_TIME ), DEFINE_FIELD( CPipeWrench, m_iSwing, FIELD_INTEGER ),
DEFINE_FIELD( CPipeWrench, m_iSwingMode, FIELD_INTEGER ),
}; };
IMPLEMENT_SAVERESTORE( CPipeWrench, CBasePlayerWeapon ) IMPLEMENT_SAVERESTORE( CPipeWrench, CBasePlayerWeapon )

20
dlls/weapons.h

@ -1345,7 +1345,6 @@ public:
static TYPEDESCRIPTION m_SaveData[]; static TYPEDESCRIPTION m_SaveData[];
#endif #endif
void Spawn(void); void Spawn(void);
void Precache(void); void Precache(void);
int iItemSlot(void) { return 1; } int iItemSlot(void) { return 1; }
@ -1355,13 +1354,16 @@ public:
void PrimaryAttack(void); void PrimaryAttack(void);
void SecondaryAttack(void); void SecondaryAttack(void);
void ItemPostFrame(void); int Swing(int fFirst);
virtual BOOL ShouldWeaponIdle(void) { return FALSE; };
int Swing(int fFirst, BOOL fIsPrimary);
BOOL Deploy(void); BOOL Deploy(void);
void WeaponIdle(void);
void Holster(int skiplocal = 0); void Holster(int skiplocal = 0);
void BigSwing(void);
int m_iSwing; int m_iSwing;
TraceResult m_trHit; TraceResult m_trHit;
int m_iSwingMode;
float m_flBigSwingStart;
virtual BOOL UseDecrement(void) virtual BOOL UseDecrement(void)
{ {
@ -1372,17 +1374,7 @@ public:
#endif #endif
} }
private: private:
unsigned short m_usPWrench; 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