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. 521
      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;

521
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,282 +103,277 @@ int CPipeWrench::GetItemInfo(ItemInfo *p) @@ -104,282 +103,277 @@ 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_flBigSwingStart = gpGlobals->time;
}
m_iSwingMode = 1;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.3;
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.1;
}
SendWeaponAnim(PIPEWRENCH_ATTACKBIGWIND);
void CPipeWrench::Smack()
{
DecalGunshot(&m_trHit, BULLET_PLAYER_CROWBAR);
}
m_flNextPrimaryAttack = m_flNextSecondaryAttack = GetNextAttackDelay(1.0f);
pev->nextthink = UTIL_WeaponTimeBase() + 1.0f;
ALERT( at_console, "CPipeWrench::SecondaryAttack\n" );
void CPipeWrench::SwingAgain(void)
{
Swing(0);
}
void CPipeWrench::ItemPostFrame(void)
int CPipeWrench::Swing(int fFirst)
{
if (!(m_pPlayer->pev->button & IN_ATTACK))
int fDidHit = FALSE;
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 )
{
UTIL_TraceHull( vecSrc, vecEnd, dont_ignore_monsters, head_hull, ENT( m_pPlayer->pev ), &tr );
if ( tr.flFraction < 1.0 )
{
// 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)
{
m_flLastFireTime = 0.0f;
PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usPWrench,
0.0, (float*)&g_vecZero, (float*)&g_vecZero, 0, 0, 1,
0, 0, 0 );
}
if (m_iFirestate != FIRESTATE_NONE)
if ( tr.flFraction >= 1.0 )
{
// 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;
if (CanAttack(m_flNextSecondaryAttack, gpGlobals->time, UseDecrement()))
// 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 )
{
switch (m_iFirestate)
{
case FIRESTATE_WINDUP:
{
ALERT(at_console, "CPipeWrench::FIRESTATE_WINDUP\n");
case 0:
SendWeaponAnim( PIPEWRENCH_ATTACK1HIT );
break;
case 1:
SendWeaponAnim( PIPEWRENCH_ATTACK2HIT );
break;
case 2:
SendWeaponAnim( PIPEWRENCH_ATTACK3HIT );
break;
}
m_iFirestate = FIRESTATE_WINDLOOP;
// player "shoot" animation
m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
SendWeaponAnim(PIPEWRENCH_ATTACKBIGLOOP);
#ifndef CLIENT_DLL
m_flHoldStartTime = gpGlobals->time;
// hit
fDidHit = TRUE;
CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit);
m_flNextPrimaryAttack = m_flNextSecondaryAttack = GetNextAttackDelay(0.01f);
pev->nextthink = UTIL_WeaponTimeBase() + 0.01f;
// play thwack, smack, or dong sound
float flVol = 1.0;
int fHitWorld = TRUE;
if( pEntity )
{
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
{
// first swing does full damage
flDamage = gSkillData.plrDmgPWrench;
}
break;
else
{
// subsequent swings do half
flDamage = gSkillData.plrDmgPWrench / 2;
}
// Send trace attack to player.
pEntity->TraceAttack(m_pPlayer->pev, flDamage, gpGlobals->v_forward, &tr, DMG_CLUB);
ApplyMultiDamage(m_pPlayer->pev, m_pPlayer->pev);
case FIRESTATE_WINDLOOP:
if ( pEntity->Classify() != CLASS_NONE && pEntity->Classify() != CLASS_MACHINE )
{
ALERT(at_console, "CPipeWrench::FIRESTATE_WINDLOOP\n");
if (!(m_pPlayer->pev->button & IN_ATTACK2))
// play thwack or smack sound
switch( RANDOM_LONG(0,2) )
{
ALERT(at_console, "Releasing CPipeWrench\n");
m_iFirestate = FIRESTATE_BIGHIT;
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
m_pPlayer->m_iWeaponVolume = MELEE_BODYHIT_VOLUME;
if ( !pEntity->IsAlive() )
{
ALERT(at_console, "Holding CPipeWrench\n");
SendWeaponAnim(PIPEWRENCH_ATTACKBIGLOOP);
m_flNextPrimaryAttack = GetNextAttackDelay(0.5);
return TRUE;
}
m_flNextPrimaryAttack = m_flNextSecondaryAttack = GetNextAttackDelay(0.01f);
}
break;
else
flVol = 0.1;
case FIRESTATE_BIGHIT:
{
ALERT(at_console, "CPipeWrench::FIRESTATE_BIGHIT\n");
fHitWorld = FALSE;
}
}
Swing(1, FALSE);
// play texture hit sound
// UNDONE: Calculate the correct point of intersection when we hit with the hull instead of the line
m_iFirestate = FIRESTATE_NONE;
if( fHitWorld )
{
float fvolbar = TEXTURETYPE_PlaySound(&tr, vecSrc, vecSrc + (vecEnd-vecSrc)*2, BULLET_PLAYER_CROWBAR );
m_flHoldStartTime = 0.0f;
if ( g_pGameRules->IsMultiplayer() )
{
// override the volume here, cause we don't play texture sounds in multiplayer,
// and fvolbar is going to be 0 from the above call.
m_pPlayer->pev->button &= ~IN_ATTACK2;
fvolbar = 1;
}
break;
// also play pipe wrench strike
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_hit2.wav", fvolbar, ATTN_NORM, 0, 98 + RANDOM_LONG(0,3));
break;
}
// delay the decal a bit
m_trHit = tr;
}
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()))
{
m_pPlayer->m_iWeaponVolume = (int)( flVol * MELEE_WALLHIT_VOLUME );
#ifndef CLIENT_DLL
m_pPlayer->TabulateAmmo();
SetThink( &CPipeWrench::Smack );
pev->nextthink = UTIL_WeaponTimeBase() + 0.2;
#endif
PrimaryAttack();
m_pPlayer->pev->button &= ~IN_ATTACK;
}
else if (!(m_pPlayer->pev->button & (IN_ATTACK | IN_ATTACK2)))
{
// no fire buttons down
WeaponIdle();
return;
}
// catch all
if (ShouldWeaponIdle())
{
WeaponIdle();
m_flNextPrimaryAttack = GetNextAttackDelay(0.5);
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5;
}
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 5.0;
return fDidHit;
}
void CPipeWrench::Smack()
{
DecalGunshot(&m_trHit, BULLET_PLAYER_CROWBAR);
}
void CPipeWrench::SwingAgain(void)
{
Swing(0, TRUE);
}
#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);
Vector vecSrc = m_pPlayer->GetGunPosition();
Vector vecEnd = vecSrc + gpGlobals->v_forward * 32;
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);
UTIL_TraceLine( vecSrc, vecEnd, dont_ignore_monsters, ENT( m_pPlayer->pev ), &tr );
#ifndef CLIENT_DLL
if (tr.flFraction >= 1.0)
if ( tr.flFraction >= 1.0 )
{
UTIL_TraceHull(vecSrc, vecEnd, dont_ignore_monsters, head_hull, ENT(m_pPlayer->pev), &tr);
if (tr.flFraction < 1.0)
UTIL_TraceHull( vecSrc, vecEnd, dont_ignore_monsters, head_hull, ENT( m_pPlayer->pev ), &tr );
if ( tr.flFraction < 1.0 )
{
// 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());
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
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);
PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usPWrench,
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);
if (tr.flFraction >= 1.0)
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);
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;
}
SendWeaponAnim( PIPEWRENCH_ATTACKBIGHIT );
// player "shoot" animation
m_pPlayer->SetAnimation(PLAYER_ATTACK1);
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( pEntity )
{
if ((m_flNextPrimaryAttack + 1 < UTIL_WeaponTimeBase()) || g_pGameRules->IsMultiplayer())
{
// first swing does full damage
flDamage = gSkillData.plrDmgPWrench;
ClearMultiDamage();
float flDamage = (gpGlobals->time - m_flBigSwingStart) * gSkillData.plrDmgPWrench + 25.0f;
if (flDamage > PIPEWRENCH_ATTACK2_MAX_DAMAGE) {
flDamage = PIPEWRENCH_ATTACK2_MAX_DAMAGE;
}
else
{
// subsequent swings do half
flDamage = gSkillData.plrDmgPWrench / 2;
}
}
ALERT(at_console, "PipeWrench damage: %f\n", flDamage);
pEntity->TraceAttack(m_pPlayer->pev, flDamage, gpGlobals->v_forward, &tr, DMG_CLUB);
// Send trace attack to player.
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
float flVol = 1.0;
@ -390,63 +384,45 @@ int CPipeWrench::Swing(int fFirst, BOOL fIsPrimary) @@ -390,63 +384,45 @@ int CPipeWrench::Swing(int fFirst, BOOL fIsPrimary)
if (pEntity->Classify() != CLASS_NONE && pEntity->Classify() != CLASS_MACHINE)
{
// play thwack or smack sound
if (fIsPrimary)
switch( RANDOM_LONG(0,1) )
{
// 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;
}
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 = MELEE_BODYHIT_VOLUME;
if ( !pEntity->IsAlive() )
return;
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;
}
}
flVol = 0.1;
m_pPlayer->m_iWeaponVolume = PIPEWRENCH_BODYHIT_VOLUME;
if (!pEntity->IsAlive())
return TRUE;
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)
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 );
if (g_pGameRules->IsMultiplayer())
if ( g_pGameRules->IsMultiplayer() )
{
// override the volume here, cause we don't play texture sounds in multiplayer,
// 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;
}
// also play crowbar strike
//
// Shared between both primary and secondary attack.
//
switch (RANDOM_LONG(0, 1))
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));
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_flNextSecondaryAttack < UTIL_WeaponTimeBase() && !(m_pPlayer->pev->button & IN_ATTACK2))
if ( m_iSwingMode == 1 )
{
if (!Swing(1, FALSE))
if ( gpGlobals->time > m_flBigSwingStart + 1.0 )
{
SetThink(&CPipeWrench::SwingAgain2);
pev->nextthink = UTIL_WeaponTimeBase() + 0.1f;
m_iSwingMode = 2;
}
return;
}
SendWeaponAnim( PIPEWRENCH_ATTACKBIGLOOP );
pev->nextthink = UTIL_WeaponTimeBase() + 0.1f;
}
void CPipeWrench::SwingAgain2(void)
{
Swing(0, FALSE);
}
//=========================================================
// Purpose:
//=========================================================
BOOL CPipeWrench::CanAttack(float attack_time, float curtime, BOOL isPredicted)
{
#if defined( CLIENT_WEAPONS )
if (!isPredicted)
#else
if (1)
#endif
else if (m_iSwingMode == 2)
{
return (attack_time <= curtime) ? TRUE : FALSE;
m_flNextSecondaryAttack = m_flNextPrimaryAttack = m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.1;
BigSwing();
m_iSwingMode = 0;
return;
}
else
{
return (attack_time <= 0.0) ? TRUE : FALSE;
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 )
{
iAnim = PIPEWRENCH_IDLE1;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.0;
}
else if ( flRand <= 0.6 )
{
iAnim = PIPEWRENCH_IDLE2;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 3.0;
}
else
{
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