Skip to content

[TF2] Melee weapons with very fast firing speed won't register hits when holding primary attack #6223

@naydef

Description

@naydef

Basically If one gives any of the melee weapons (except spy knives tf_weapon_knife) a fire speed bonus and holds primary attack button, then once the delay between fires becomes 0.2 or less the weapon will never register hits until you release the fire button when it'll register one hit.

The reason
All melee weapons except spy knives have a small delay before they actually do the action of hitting the target. This delay is controlled with m_flSmackTime netprop. Problem occurs when m_flNextPrimaryAttack < m_flSmackTime. In this case new attack occurs before the previous attack ends, the new attack sets m_flSmackTime to higher value and thus the old attack is "forgotten".

Fix
My solution consists of:
In function CTFWeaponBaseMelee::Swing putting the following code at the end:

+    if(m_flSmackTime >= m_flNextPrimaryAttack)
+    {
+        m_flSmackTime = m_flNextPrimaryAttack - 0.01;
+        //m_flSmackTime = m_flNextPrimaryAttack //This might work as well, but not sure
+    }
}

Sourcemod plugin link

Edit: Changed the condition to equal or greater for the edge case where m_flSmackTime = m_flNextPrimaryAttack = curtime

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions