Melee can hit hitboxes

Temporary workaround for melee not being able to hit crouched hitboxes.
This commit is contained in:
William Moodhe / JetBoom 2015-10-22 03:52:29 -04:00
parent 53055b46df
commit b4b3442e1c

View file

@ -1,6 +1,56 @@
local meta = FindMetaTable("Entity")
if not meta then return end
local LASTHITCLIPHULL = false
local ClipHullBulletsResult
local ClipHullBulletsReturn = {effects = false, damage = false}
local ClipHullBullets = {
Damage = 0,
Force = 0,
Tracer = 0,
Callback = function(from, tr, dmginfo)
ClipHullBulletsResult = tr
return ClipHullBulletsReturn
end
}
function meta:ClipHullTraceHull(distance, size, start, dir)
start = start or self:GetShootPos()
dir = dir or self:GetAimVector()
ClipHullBullets.Src = start
ClipHullBullets.Dir = dir
ClipHullBullets.HullSize = size
ClipHullBulletsResult = nil
self:FireBullets(ClipHullBullets)
LASTHITCLIPHULL = false
if ClipHullBulletsResult and ClipHullBulletsResult.HitNonWorld and ClipHullBulletsResult.Entity:IsValid() and ClipHullBulletsResult.Entity:IsPlayer() and ClipHullBulletsResult.HitPos:Distance(start) <= distance then
LASTHITCLIPHULL = true
return ClipHullBulletsResult
end
return self:TraceHull(distance, mask, size, filter, start)
end
function meta:ClipHullMeleeTrace(distance, size, start)
return self:ClipHullTraceHull(distance, size, start)
end
-- Extremely shitty workaround for util trace functions not using clip hulls
function meta:PenetratingClipHullMeleeTrace(distance, size, prehit, start, dir)
local t
local cliphullpretrace = self:ClipHullTraceHull(distance, size, start, dir)
self:LagCompensation(true)
t = self:PenetratingMeleeTrace(distance, size, prehit, start, dir)
if cliphullpretrace and LASTHITCLIPHULL and cliphullpretrace.Entity ~= prehit then
table.insert(t, 1, cliphullpretrace)
end
self:LagCompensation(false)
return t
end
function meta:ApplyPlayerProperties(ply)
self.GetPlayerColor = function() return ply:GetPlayerColor() end
self:SetBodygroup( ply:GetBodygroup(1), 1 )