Browse Source

Update knife

opforfixed
Roman Chistokhodov 5 years ago
parent
commit
0565893283
  1. 2
      cl_dll/ev_hldm.cpp
  2. 32
      dlls/gearbox/knife.cpp

2
cl_dll/ev_hldm.cpp

@ -1957,8 +1957,6 @@ void EV_Knife( event_args_t *args )
if( EV_IsLocal( idx ) ) if( EV_IsLocal( idx ) )
{ {
gEngfuncs.pEventAPI->EV_WeaponAnimation( KNIFE_ATTACK1MISS, 1 );
switch( ( g_iSwing++ ) % 3 ) switch( ( g_iSwing++ ) % 3 )
{ {
case 0: case 0:

32
dlls/gearbox/knife.cpp

@ -27,7 +27,7 @@ void FindHullIntersection(const Vector &vecSrc, TraceResult &tr, float *mins, fl
#define KNIFE_BODYHIT_VOLUME 128 #define KNIFE_BODYHIT_VOLUME 128
#define KNIFE_WALLHIT_VOLUME 512 #define KNIFE_WALLHIT_VOLUME 512
LINK_ENTITY_TO_CLASS(weapon_knife, CKnife); LINK_ENTITY_TO_CLASS(weapon_knife, CKnife)
enum knife_e { enum knife_e {
KNIFE_IDLE1 = 0, KNIFE_IDLE1 = 0,
@ -105,8 +105,10 @@ void CKnife::PrimaryAttack()
{ {
if (!Swing(1)) if (!Swing(1))
{ {
#ifndef CLIENT_DLL
SetThink(&CKnife::SwingAgain); SetThink(&CKnife::SwingAgain);
pev->nextthink = gpGlobals->time + 0.1; pev->nextthink = gpGlobals->time + 0.1;
#endif
} }
} }
@ -188,9 +190,21 @@ int CKnife::Swing(int fFirst)
fDidHit = TRUE; fDidHit = TRUE;
CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit); CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit);
ClearMultiDamage(); // play thwack, smack, or dong sound
float flVol = 1.0;
int fHitWorld = TRUE;
if ((m_flNextPrimaryAttack + 1 < UTIL_WeaponTimeBase()) || g_pGameRules->IsMultiplayer()) if (pEntity)
{
ClearMultiDamage();
// If building with the clientside weapon prediction system,
// UTIL_WeaponTimeBase() is always 0 and m_flNextPrimaryAttack is >= -1.0f, thus making
// m_flNextPrimaryAttack + 1 < UTIL_WeaponTimeBase() always evaluate to false.
#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 // first swing does full damage
pEntity->TraceAttack(m_pPlayer->pev, gSkillData.plrDmgKnife, gpGlobals->v_forward, &tr, DMG_CLUB); pEntity->TraceAttack(m_pPlayer->pev, gSkillData.plrDmgKnife, gpGlobals->v_forward, &tr, DMG_CLUB);
@ -202,12 +216,6 @@ int CKnife::Swing(int fFirst)
} }
ApplyMultiDamage(m_pPlayer->pev, m_pPlayer->pev); ApplyMultiDamage(m_pPlayer->pev, m_pPlayer->pev);
// play thwack, smack, or dong sound
float flVol = 1.0;
int fHitWorld = TRUE;
if (pEntity)
{
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
@ -259,13 +267,11 @@ int CKnife::Swing(int fFirst)
} }
m_pPlayer->m_iWeaponVolume = flVol * KNIFE_WALLHIT_VOLUME; m_pPlayer->m_iWeaponVolume = flVol * KNIFE_WALLHIT_VOLUME;
#endif
m_flNextPrimaryAttack = GetNextAttackDelay(0.25);
SetThink(&CKnife::Smack); SetThink(&CKnife::Smack);
pev->nextthink = UTIL_WeaponTimeBase() + 0.2; pev->nextthink = UTIL_WeaponTimeBase() + 0.2;
#endif
m_flNextPrimaryAttack = GetNextAttackDelay(0.25);
} }
return fDidHit; return fDidHit;
} }
Loading…
Cancel
Save