After some vigorous testing and some googling on the matter I have found that ScalePlayerDamage is changing the damage a player takes to a number different to what it is supposed to be changing it to.
Have some debug prints of when I bodyshot somebody with the HL2 pistol in sandbox (edited to be more readable)
ScalePlayerDamage DamageAmount 12 EndAmount 12 ScalePlayerDamage DamageAmount 12 EndAmount 12 EntityTakeDamage DamageAmount 24
It appears to be adding the two damages together to make the final damage of 24
Now when I headshot somebody
ScalePlayerDamage DamageAmount 12 EndAmount 36 ScalePlayerDamage DamageAmount 36 EndAmount 108 EntityTakeDamage DamageAmount 120
120? It was supposed to be 36.
It appears to be taking the EndDamage of the first ScalePlayerDamage and using it for the second. It then appears to be taking the result of the second ScalePlayerDamage and adding the base damage to it to make the final damage.
DAMAGE = BASEDAMAGE * HITGROUPSCALE ^ 2 + BASEDAMAGE
in sandbox when you headshot somebody this ends up to be
DAMAGE = 10 * BASEDAMAGE
which is incredibly off the intended 3x damage the headshot is normally supposed to do.
Today while looking at the wiki I found bullet.CallBack, this appeared to be the perfect function for scaling damage based on distance like in TF2, unfortunately I was wrong.
bullet.Callback cannot modify the DamageInfo table, which is kind of annoying because this would be the best way to do it. I wish for this to be implemented so I can scale damage based on distance in a none hacky, easy way.