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!
[url]http://wiki.garrysmod.com/page/GM/ScalePlayerDamage[/url]
Nothing about back
[QUOTE=log404;46049204]Nothing about back[/QUOTE]
Son can you read? Look at the example and change it a bit:
[CODE]
hook.Add( "ScalePlayerDamage", "chestdamage", function( ply, hitgroup, dmginfo )
--Less damage to chest/back
if hitgroup == HITGROUP_CHEST then
dmginfo:ScaleDamage( .5 )
end
end
[/CODE]
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.
[QUOTE=robbert^^;46054626]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.[/QUOTE]
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.
[CODE]
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 )
[/CODE]
edit: If it really tickles your fancy, here's the convenience function:
[CODE]
local Entity = FindMetaTable( "Entity" )
function Entity:IsBehind( ent )
return ( self:GetPos() - ent:GetPos() ):Dot( ent:GetForward() ) < 0
end
[/CODE]
[QUOTE=CallMePyro;46054788]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.
edit: If it really tickles your fancy, here's the convenience function:
[/QUOTE]
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.
Sorry, you need to Log In to post a reply to this thread.