How would I get back damage only or head only damage
Please google your problem or what you’re looking for before making a thread, you’ll be able to find it quicker than we can reply!
Nothing about back
Son can you read? Look at the example and change it a bit:
hook.Add( "ScalePlayerDamage", "chestdamage", function( ply, hitgroup, dmginfo ) --Less damage to chest/back if hitgroup == HITGROUP_CHEST then dmginfo:ScaleDamage( .5 ) end end
you will need the poss of the player attacking and the target, fetch the eyetrace of the target, check if it is looking away and if he is scale the damage up. and could make it into a meta so you can use it more easily.
uh? Just use the dot product, don’t waste your time with ridiculously over-expensive traces. Not really even a point of putting it in a convenience function for such a simple operation.
hook.Add( "ScalePlayerDamage", "backdamage", function( ply, hitgroup, dmginfo ) --Less damage to back only if hitgroup == HITGROUP_CHEST then if ( dmginfo:GetAttacker():GetPos() - ply:GetPos() ):Dot( ply:GetForward() ) < 0 then dmginfo:ScaleDamage( .5 ) end end end )
edit: If it really tickles your fancy, here’s the convenience function:
local Entity = FindMetaTable( "Entity" ) function Entity:IsBehind( ent ) return ( self:GetPos() - ent:GetPos() ):Dot( ent:GetForward() ) < 0 end
Traces in source are very effecient actually, and I believe a trace from the players eyepos to aimpos is done every frame and cached regardless if it’s used (GetEyeTrace()). But the dot product is appropriate to use in this situation.