mirror of
https://github.com/YGGverse/hlsdk-portable.git
synced 2025-01-23 21:24:27 +00:00
Update pipewrench
This commit is contained in:
parent
aa426660c2
commit
8a28ac5749
@ -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 )
|
||||
|
@ -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
|
||||
{
|
||||
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;
|
||||
|
@ -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;
|
||||
|
@ -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()
|
||||
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)
|
||||
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,142 +103,38 @@ 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;
|
||||
|
||||
SendWeaponAnim(PIPEWRENCH_ATTACKBIGWIND);
|
||||
|
||||
m_flNextPrimaryAttack = m_flNextSecondaryAttack = GetNextAttackDelay(1.0f);
|
||||
pev->nextthink = UTIL_WeaponTimeBase() + 1.0f;
|
||||
|
||||
ALERT( at_console, "CPipeWrench::SecondaryAttack\n" );
|
||||
}
|
||||
|
||||
|
||||
void CPipeWrench::ItemPostFrame(void)
|
||||
{
|
||||
|
||||
if (!(m_pPlayer->pev->button & IN_ATTACK))
|
||||
if (m_iSwingMode != 1)
|
||||
{
|
||||
m_flLastFireTime = 0.0f;
|
||||
}
|
||||
|
||||
if (m_iFirestate != FIRESTATE_NONE)
|
||||
{
|
||||
// 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()))
|
||||
{
|
||||
switch (m_iFirestate)
|
||||
{
|
||||
case FIRESTATE_WINDUP:
|
||||
{
|
||||
ALERT(at_console, "CPipeWrench::FIRESTATE_WINDUP\n");
|
||||
|
||||
m_iFirestate = FIRESTATE_WINDLOOP;
|
||||
|
||||
SendWeaponAnim(PIPEWRENCH_ATTACKBIGLOOP);
|
||||
|
||||
m_flHoldStartTime = gpGlobals->time;
|
||||
|
||||
m_flNextPrimaryAttack = m_flNextSecondaryAttack = GetNextAttackDelay(0.01f);
|
||||
pev->nextthink = UTIL_WeaponTimeBase() + 0.01f;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case FIRESTATE_WINDLOOP:
|
||||
{
|
||||
ALERT(at_console, "CPipeWrench::FIRESTATE_WINDLOOP\n");
|
||||
if (!(m_pPlayer->pev->button & IN_ATTACK2))
|
||||
{
|
||||
ALERT(at_console, "Releasing CPipeWrench\n");
|
||||
m_iFirestate = FIRESTATE_BIGHIT;
|
||||
}
|
||||
else
|
||||
{
|
||||
ALERT(at_console, "Holding CPipeWrench\n");
|
||||
SendWeaponAnim(PIPEWRENCH_ATTACKBIGLOOP);
|
||||
}
|
||||
m_flNextPrimaryAttack = m_flNextSecondaryAttack = GetNextAttackDelay(0.01f);
|
||||
}
|
||||
break;
|
||||
|
||||
case FIRESTATE_BIGHIT:
|
||||
{
|
||||
ALERT(at_console, "CPipeWrench::FIRESTATE_BIGHIT\n");
|
||||
|
||||
Swing(1, FALSE);
|
||||
|
||||
m_iFirestate = FIRESTATE_NONE;
|
||||
|
||||
m_flHoldStartTime = 0.0f;
|
||||
|
||||
m_pPlayer->pev->button &= ~IN_ATTACK2;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
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()))
|
||||
{
|
||||
|
||||
#ifndef CLIENT_DLL
|
||||
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
|
||||
WeaponIdle();
|
||||
return;
|
||||
}
|
||||
|
||||
// catch all
|
||||
if (ShouldWeaponIdle())
|
||||
{
|
||||
WeaponIdle();
|
||||
SendWeaponAnim(PIPEWRENCH_ATTACKBIGWIND);
|
||||
m_flBigSwingStart = gpGlobals->time;
|
||||
}
|
||||
m_iSwingMode = 1;
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.3;
|
||||
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.1;
|
||||
}
|
||||
|
||||
void CPipeWrench::Smack()
|
||||
@ -250,77 +145,71 @@ void CPipeWrench::Smack()
|
||||
|
||||
void CPipeWrench::SwingAgain(void)
|
||||
{
|
||||
Swing(0, TRUE);
|
||||
Swing(0);
|
||||
}
|
||||
|
||||
#define clamp( val, min, max ) ( ((val) > (max)) ? (max) : ( ((val) < (min)) ? (min) : (val) ) )
|
||||
|
||||
int CPipeWrench::Swing(int fFirst, BOOL fIsPrimary)
|
||||
int CPipeWrench::Swing(int fFirst)
|
||||
{
|
||||
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
|
||||
if (fFirst)
|
||||
{
|
||||
PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usPWrench,
|
||||
0.0, (float*)&g_vecZero, (float*)&g_vecZero, 0, 0, 1,
|
||||
0, 0, 0 );
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
|
||||
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
|
||||
m_pPlayer->SetAnimation(PLAYER_ATTACK1);
|
||||
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
|
||||
{
|
||||
if (fIsPrimary)
|
||||
switch( ((m_iSwing++) % 2) + 1 )
|
||||
{
|
||||
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;
|
||||
case 0:
|
||||
SendWeaponAnim( PIPEWRENCH_ATTACK1HIT );
|
||||
break;
|
||||
case 1:
|
||||
SendWeaponAnim( PIPEWRENCH_ATTACK2HIT );
|
||||
break;
|
||||
case 2:
|
||||
SendWeaponAnim( PIPEWRENCH_ATTACK3HIT );
|
||||
break;
|
||||
}
|
||||
|
||||
// player "shoot" animation
|
||||
m_pPlayer->SetAnimation(PLAYER_ATTACK1);
|
||||
m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
|
||||
|
||||
#ifndef CLIENT_DLL
|
||||
|
||||
@ -328,41 +217,19 @@ int CPipeWrench::Swing(int fFirst, BOOL fIsPrimary)
|
||||
fDidHit = TRUE;
|
||||
CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit);
|
||||
|
||||
ClearMultiDamage();
|
||||
// play thwack, smack, or dong sound
|
||||
float flVol = 1.0;
|
||||
int fHitWorld = TRUE;
|
||||
|
||||
float flDamage;
|
||||
|
||||
if (!fIsPrimary)
|
||||
if( pEntity )
|
||||
{
|
||||
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())
|
||||
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;
|
||||
@ -372,14 +239,141 @@ int CPipeWrench::Swing(int fFirst, BOOL fIsPrimary)
|
||||
// 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);
|
||||
|
||||
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;
|
||||
}
|
||||
m_pPlayer->m_iWeaponVolume = MELEE_BODYHIT_VOLUME;
|
||||
if ( !pEntity->IsAlive() )
|
||||
{
|
||||
m_flNextPrimaryAttack = GetNextAttackDelay(0.5);
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
flVol = 0.1;
|
||||
|
||||
fHitWorld = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
ALERT(at_console, "PipeWrench damage: %f\n", flDamage);
|
||||
// play texture hit sound
|
||||
// UNDONE: Calculate the correct point of intersection when we hit with the hull instead of the line
|
||||
|
||||
// Send trace attack to player.
|
||||
pEntity->TraceAttack(m_pPlayer->pev, flDamage, gpGlobals->v_forward, &tr, DMG_CLUB);
|
||||
if( fHitWorld )
|
||||
{
|
||||
float fvolbar = TEXTURETYPE_PlaySound(&tr, vecSrc, vecSrc + (vecEnd-vecSrc)*2, BULLET_PLAYER_CROWBAR );
|
||||
|
||||
ApplyMultiDamage(m_pPlayer->pev, m_pPlayer->pev);
|
||||
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.
|
||||
|
||||
fvolbar = 1;
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
m_pPlayer->m_iWeaponVolume = (int)( flVol * MELEE_WALLHIT_VOLUME );
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
void CPipeWrench::BigSwing(void)
|
||||
{
|
||||
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
|
||||
|
||||
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);
|
||||
|
||||
m_pPlayer->pev->punchangle.x -= 2;
|
||||
if ( tr.flFraction >= 1.0 )
|
||||
{
|
||||
// player "shoot" animation
|
||||
m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
SendWeaponAnim( PIPEWRENCH_ATTACKBIGHIT );
|
||||
|
||||
// player "shoot" animation
|
||||
m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
|
||||
|
||||
#ifndef CLIENT_DLL
|
||||
|
||||
// hit
|
||||
CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit);
|
||||
|
||||
if( pEntity )
|
||||
{
|
||||
ClearMultiDamage();
|
||||
float flDamage = (gpGlobals->time - m_flBigSwingStart) * gSkillData.plrDmgPWrench + 25.0f;
|
||||
if (flDamage > PIPEWRENCH_ATTACK2_MAX_DAMAGE) {
|
||||
flDamage = PIPEWRENCH_ATTACK2_MAX_DAMAGE;
|
||||
}
|
||||
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,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)
|
||||
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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 )
|
||||
|
||||
|
@ -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:
|
||||
|
||||
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:
|
||||
#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…
x
Reference in New Issue
Block a user