Skip to content
This repository was archived by the owner on Mar 11, 2021. It is now read-only.

Commit cf5f5c8

Browse files
committed
Readded 'PlayerTraceAttack' code
Now...
1 parent d15710e commit cf5f5c8

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

lua/sv_specdm_overrides.lua

+28-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,34 @@ end
1212

1313
hook.Add("PlayerTraceAttack", "PlayerTraceAttack_SpecDM", function(ply, dmginfo, dir, trace)
1414
if ply:IsGhost() then
15-
ply:TakeDamageInfo(dmginfo)
15+
local _dmginfo = DamageInfo()
16+
_dmginfo:SetDamage(dmginfo:GetDamage())
17+
_dmginfo:SetDamagePosition(dmginfo:GetDamagePosition())
18+
_dmginfo:SetReportedPosition(dmginfo:GetReportedPosition())
19+
if IsValid(dmginfo:GetAttacker()) then
20+
_dmginfo:SetAttacker(dmginfo:GetAttacker())
21+
end
22+
if IsValid(dmginfo:GetInflictor()) then
23+
_dmginfo:SetInflictor(dmginfo:GetInflictor())
24+
end
25+
ply.was_headshot = false
26+
local hg = trace.HitGroup
27+
local hs = hg == HITGROUP_HEAD
28+
if hs then
29+
ply.was_headshot = true
30+
local wep = util.WeaponFromDamage(_dmginfo)
31+
if IsValid(wep) then
32+
local s = wep:GetHeadshotMultiplier(ply, _dmginfo) or 2
33+
if s < 1 then s = 1 end
34+
if hit then s = s-0.2 end
35+
_dmginfo:ScaleDamage(s)
36+
end
37+
elseif (hg == HITGROUP_LEFTARM or hg == HITGROUP_RIGHTARM or hg == HITGROUP_LEFTLEG or hg == HITGROUP_RIGHTLEG or hg == HITGROUP_GEAR) then
38+
_dmginfo:ScaleDamage(0.55)
39+
end
40+
if not hit or hs then
41+
ply:TakeDamageInfo(_dmginfo)
42+
end
1643
return true
1744
end
1845
end)

0 commit comments

Comments
 (0)