summaryrefslogtreecommitdiff
path: root/gamemode/cl_hud/draw_playercircle.lua
blob: 68498aab0d70050697ecce426e2dd14d36fc1e6c (plain)
1
local CIRCLE = surface.GetTextureID("SGM/playercircle")
local CIROFF = Vector(0,0,1)
local CIROF2 = Vector(0,0,10)
local CIRDOW = Vector(0,0,150)
local CIRANG = Angle(0,0,0)
local CIRENA = true
local CIRCOL = MAIN_COLOR

function GM:SetEnableMawCircle(bool)
	CIRENA = bool
end

function GM:SetMawCircleTexture(TexID)
	CIRCLE = TexID
end

function GM:SetMawCircleColor(Col)	
	CIRCOL = Col
end

hook.Add("PostPlayerDraw","DrawingPlayerCircle",function(pl)
	if (!CIRENA) then return end
	
	local p = pl:GetPos()
	local t = {
		start 	= p+CIROF2,
		endpos 	= p-CIRDOW,
		filter 	= pl,
		mask 	= MASK_SOLID_BRUSHONLY,
	}
	
	t = util.TraceLine(t)
	
	local B = CIRCOL.a*1
	CIRCOL.a = math.Clamp(140-p:Distance(t.HitPos),0,250)
	
	if (t.Hit) then
		cam.Start3D2D(t.HitPos+CIROFF,CIRANG,0.2)
			DrawTexturedRect( -100, -100, 200, 200, CIRCOL, CIRCLE)
		cam.End3D2D()
	end
	
	CIRCOL.a = B
end)