View Single Post
Author Message
Mikusch
AlliedModders Donor
Join Date: Oct 2019
Location: Germany
Old 12-23-2019 , 14:06   [TF2] Make every weapon headshot
Reply With Quote #1

I'm trying to allow all bullet-based weapons in TF2 to do headshots with the same method that sniper rifles, bows and the revolver hitlocation attribute use. Quite a bit of searching and the source code for CTFSniperRifle::GetDamageType and CTFProjectile_Arrow::GetDamageType lead me to believe that OR-ing in the DMG_USE_HITLOCATIONS damagebit would do the trick but of course I was wrong. The damagetype changed but the game still doesn't use hit location damage.

I simply can't figure out how to get this to work. The bits get modified but the weapon won't headshot. Tested with SMG, Pistol and Minigun.

PHP Code:
public Action Client_OnTakeDamage(int victimint &attackerint &inflictorfloat &damageint &damagetypeint &weaponfloat damageForce[3], float damagePosition[3], int damagecustom)
{
    if (
damagetype DMG_BULLET)
    {
        
damagetype |= DMG_USE_HITLOCATIONS;
        return 
Plugin_Changed;
    }
    
    return 
Plugin_Continue;

The above function is hooked to all clients.

Yes, I am aware that SDKHook_TraceAttack and the head hitgroup exists, however this comes with its own quirks and I'd rather use TF2's built in hitlocation damage.

Last edited by Mikusch; 12-23-2019 at 14:13.
Mikusch is offline