mirror of
https://github.com/YGGverse/hlsdk-portable.git
synced 2025-01-23 21:24:27 +00:00
Update knife
This commit is contained in:
parent
1fe1a7fcec
commit
0565893283
@ -1957,8 +1957,6 @@ void EV_Knife( event_args_t *args )
|
||||
|
||||
if( EV_IsLocal( idx ) )
|
||||
{
|
||||
gEngfuncs.pEventAPI->EV_WeaponAnimation( KNIFE_ATTACK1MISS, 1 );
|
||||
|
||||
switch( ( g_iSwing++ ) % 3 )
|
||||
{
|
||||
case 0:
|
||||
|
@ -27,7 +27,7 @@ void FindHullIntersection(const Vector &vecSrc, TraceResult &tr, float *mins, fl
|
||||
#define KNIFE_BODYHIT_VOLUME 128
|
||||
#define KNIFE_WALLHIT_VOLUME 512
|
||||
|
||||
LINK_ENTITY_TO_CLASS(weapon_knife, CKnife);
|
||||
LINK_ENTITY_TO_CLASS(weapon_knife, CKnife)
|
||||
|
||||
enum knife_e {
|
||||
KNIFE_IDLE1 = 0,
|
||||
@ -105,8 +105,10 @@ void CKnife::PrimaryAttack()
|
||||
{
|
||||
if (!Swing(1))
|
||||
{
|
||||
#ifndef CLIENT_DLL
|
||||
SetThink(&CKnife::SwingAgain);
|
||||
pev->nextthink = gpGlobals->time + 0.1;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -188,26 +190,32 @@ int CKnife::Swing(int fFirst)
|
||||
fDidHit = TRUE;
|
||||
CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit);
|
||||
|
||||
ClearMultiDamage();
|
||||
|
||||
if ((m_flNextPrimaryAttack + 1 < UTIL_WeaponTimeBase()) || g_pGameRules->IsMultiplayer())
|
||||
{
|
||||
// first swing does full damage
|
||||
pEntity->TraceAttack(m_pPlayer->pev, gSkillData.plrDmgKnife, gpGlobals->v_forward, &tr, DMG_CLUB);
|
||||
}
|
||||
else
|
||||
{
|
||||
// subsequent swings do half
|
||||
pEntity->TraceAttack(m_pPlayer->pev, gSkillData.plrDmgKnife / 2, gpGlobals->v_forward, &tr, DMG_CLUB);
|
||||
}
|
||||
ApplyMultiDamage(m_pPlayer->pev, m_pPlayer->pev);
|
||||
|
||||
// play thwack, smack, or dong sound
|
||||
float flVol = 1.0;
|
||||
int fHitWorld = TRUE;
|
||||
|
||||
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
|
||||
pEntity->TraceAttack(m_pPlayer->pev, gSkillData.plrDmgKnife, gpGlobals->v_forward, &tr, DMG_CLUB);
|
||||
}
|
||||
else
|
||||
{
|
||||
// subsequent swings do half
|
||||
pEntity->TraceAttack(m_pPlayer->pev, gSkillData.plrDmgKnife / 2, 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
|
||||
@ -259,13 +267,11 @@ int CKnife::Swing(int fFirst)
|
||||
}
|
||||
|
||||
m_pPlayer->m_iWeaponVolume = flVol * KNIFE_WALLHIT_VOLUME;
|
||||
#endif
|
||||
m_flNextPrimaryAttack = GetNextAttackDelay(0.25);
|
||||
|
||||
SetThink(&CKnife::Smack);
|
||||
pev->nextthink = UTIL_WeaponTimeBase() + 0.2;
|
||||
|
||||
|
||||
#endif
|
||||
m_flNextPrimaryAttack = GetNextAttackDelay(0.25);
|
||||
}
|
||||
return fDidHit;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user