CTakeDamageInfo.GetReportedPosition

From GMod Wiki

Jump to: navigation, search
Function
Syntax CTakeDamageInfo:GetReportedPosition( )
Where is this used?
Description:
Gets the position of where the Entity was damaged.
Returns: Vector
Part of Library: CTakeDamageInfo
Realm: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=CTakeDamageInfo.GetReportedPosition]CTakeDamageInfo.GetReportedPosition [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]


DescriptionInstantly kill on headshots (Even if the killer was a prop)
Used onNewerServer.png
Code
 
local function EntityDamaged(ent, inflictor, attacker, dmginfo)
    if ent:IsPlayer() then
        local dmgpos = dmginfo:GetReportedPosition()
        local headpos = ent:GetBonePosition(6) // 6 is the bone index for the head.
 
        if dmgpos:Distance(headpos) <= 8 then
            dmginfo:ScaleDamage((dmginfo:GetDamage() / ent:Health()) + 1)
        end
    end
end
 
hook.Add("EntityTakeDamage", "HeadshotKills", EntityDamaged)
 
OutputNone.

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox