--[[
	EXECUTABLE_PATH/Joseph/15.lua
	Joseph | STEAM_0:0:69348930 <2.26.87.183:27005> | [19-10-13 05:31:09PM]
	===BadFile===
]]

--[[
	lua/autorun/client/OubHack/oubhack_esp.lua
	Oubliette | (STEAM_0:1:34029133)
	===DStream===
]]

/******************************************************************************
 .d88888b.  888     888 888888b.   888    888        d8888  .d8888b.  888    d8P  
d88P" "Y88b 888     888 888  "88b  888    888       d88888 d88P  Y88b 888   d8P   
888     888 888     888 888  .88P  888    888      d88P888 888    888 888  d8P    
888     888 888     888 8888888K.  8888888888     d88P 888 888        888d88K     
888     888 888     888 888  "Y88b 888    888    d88P  888 888        8888888b    
888     888 888     888 888    888 888    888   d88P   888 888    888 888  Y88b   
Y88b. .d88P Y88b. .d88P 888   d88P 888    888  d8888888888 Y88b  d88P 888   Y88b  
 "Y88888P"   "Y88888P"  8888888P"  888    888 d88P     888  "Y8888P"  888    Y88b 
 By Oubliete and UnknownAlias
*******************************************************************************/
-- ESP


function oubhack:ESPShouldTarget(ent)
	return ent:IsValid() and ent:GetClass() == "prop_physics"
end

oubhack.espc_alive_player = Color(238,118,0,255)
oubhack.espc_dead_player = Color(20,20,20,190)
oubhack.espc_weapon = Color(0,255,0,255)
oubhack.espc_npc = Color(50,0,0,255)
oubhack.espc_alt = Color(255,255,255,255)
oubhack.espc_custom_ents = Color(0,0,255,255)
oubhack.espc_invalid_entity = Color(255,255,255,100)

function oubhack:GetRenderColor(col)
	local c = Color(0,0,0,0);
	c.r ,c.g , c.b, c.a = (col.r/255),(col.g/255),(col.b/255),(col.a/255);
	return c;
end

function oubhack:ESPGetDrawColor(ent) -- Doesn't return rgba code, rather a 1,1,1,1 code. thats what the render.SetColorModulation() function takes.
	if ent:IsWorld() then return Color(0,0,0,0) end
	if ent:IsValid() then
		if ent:IsPlayer() and ent:Alive() then
			return self:GetRenderColor(self.espc_alive_player)
		elseif ent:IsPlayer() and !ent:Alive() then 
			return self:GetRenderColor(self.espc_dead_player)
		elseif ent:IsWeapon() then
			return self:GetRenderColor(self.espc_weapon)
		elseif ent:IsNPC() then
			return self:GetRenderColor(self.espc_npc)
		elseif self:ESPShouldTarget(ent) then
			return self:GetRenderColor(self.espc_custom_ents)
		else
			return self:GetRenderColor(self.espc_alt)
		end
	else
		return self:GetRenderColor(self.espc_invalid_entity)
	end
end



-- Entity Xray Paint
function oubhack:XrayPaint()
	for k,v in pairs(ents.GetAll()) do
		if ValidEntity(v) then
			if ( v:IsNPC() and !(v:GetMoveType() == 0 or v:GetMoveType() == 5) ) or ( v:IsPlayer() and v:Alive()) or (v:IsWeapon()) or ( self:ESPShouldTarget(v)) or (v:GetClass() == "class C_ClientRagdoll") then
				cam.Start3D( EyePos(), EyeAngles()); 
					cam.IgnoreZ( true );	
						render.SuppressEngineLighting( true )
						
							if self:IsFriend(v) then
								render.SetColorModulation(0,255,0)
							elseif (v:IsNPC() or v:IsPlayer()) and self:Visible(v) then
								render.SetColorModulation(255,255,0)
							else
								local c = self:ESPGetDrawColor(v)
								render.SetColorModulation(c.r,c.g,c.b)
							end
							/*if not v:GetMaterial() == "models/wireframe" then*/ v:SetMaterial("models/wireframe") --end
							v:SetModelScale(Vector(1.1,1.1,1))
							local mat = v:GetMaterial()
							v:DrawModel();
							
							render.SetColorModulation(1,1,1)
							v:SetModelScale(Vector(1,1,1))
							v:SetMaterial(mat)
							v:DrawModel();
							
						render.SuppressEngineLighting( false )					
					cam.IgnoreZ( false );
				cam.End3D(); 
			end
		end
	end	
end
hook.Add("HUDPaint","oh_pdor",function(ent) if oubhack.xray_on and !oubhack.hidemode then oubhack:XrayPaint(ent) end end)


local PMD = _R.Player
local VMD = _R.Vector
local EMD = _R.Entity
local CUserCmdMD = _R.CUserCmd
local AMD = _R.Angle

function oubhack:DrawBoneHighlighter(x,y,count)
	local ct = (CurTime()*-180)
	local length = 8 + 20 * 0.4
	local greenl = true;
	for i = 0 , count do 
		if greenl then surface.SetDrawColor(255,0,0,255) greenl = false else surface.SetDrawColor(0,255,0,255) greenl = true end
		surface.DrawLine(
	        x + (math.sin(math.rad(ct + i * 45)) * length),
	        y + (math.cos(math.rad(ct + i * 45)) * length),
	        x + (math.sin(math.rad(ct + i * 45)) * 8),
	        y + (math.cos(math.rad(ct + i * 45)) * 8)
	    )
	end
end

function oubhack:ESPPaint() -- Uses local meta.
	local targ = oubhack:GetBestTarget()
	local tbl = self:GetTargets()
	local friends = self:GetFriends()
	if not self.vis_targs then return false end -- Give it a second to look for entities.
	table.Add(tbl,friends)
		
		for k,v in pairs(tbl) do
			if ValidEntity(v) and v != LocalPlayer() then
				local colour = Color(255,255,255,255)

				if self:IsFriend(v) then -- He's a friend, he's green.
					colour = Color(0,255,0,255)
				elseif !table.HasValue(self.vis_targs,v) then -- He's a target, but he's not visible, make it yellow.
					colour = Color(255,255,0,255)
				else -- OMG KILL IT!!
					colour = Color(255,0,0,255) 
				end
				
				local centre = EMD["LocalToWorld"](v,EMD["OBBCenter"](v))
				local min,max = EMD["WorldSpaceAABB"](v)
				local avg = max-min
				
				local front = EMD["GetForward"](v)*(avg.y/2)
				local right = EMD["GetRight"](v)*(avg.x/2)
				local top = EMD["GetUp"](v)*(avg.z/2)
				local back = (EMD["GetForward"](v)*-1)*(avg.y/2)
				local left = (EMD["GetRight"](v)*-1)*(avg.x/2)
				local bottom = (EMD["GetUp"](v)*-1)*(avg.z/2)
				
				local FRT = VMD["ToScreen"](centre + front + right + top)
				local BLB = VMD["ToScreen"](centre + back + left + bottom)
				local FLT = VMD["ToScreen"](centre + front + left + top)
				local BRT = VMD["ToScreen"](centre + back + right + top)
				local BLT = VMD["ToScreen"](centre + back + left + top)
				local FRB = VMD["ToScreen"](centre + front + right + bottom)
				local FLB = VMD["ToScreen"](centre + front + left + bottom)
				local BRB = VMD["ToScreen"](centre + back + right + bottom)
				
				local x_max = math.max(FRT.x,BLB.x,FLT.x,BRT.x,BLT.x,FRB.x,FLB.x,BRB.x)
				local x_min = math.min(FRT.x,BLB.x,FLT.x,BRT.x,BLT.x,FRB.x,FLB.x,BRB.x)
				local y_max = math.max(FRT.y,BLB.y,FLT.y,BRT.y,BLT.y,FRB.y,FLB.y,BRB.y)
				local y_min = math.min(FRT.y,BLB.y,FLT.y,BRT.y,BLT.y,FRB.y,FLB.y,BRB.y)

				surface.SetDrawColor(colour)
				surface.DrawLine(x_max,y_max,x_max,y_min)
				surface.DrawLine(x_max,y_min,x_min,y_min)
				surface.DrawLine(x_min,y_min,x_min,y_max)
				surface.DrawLine(x_min,y_max,x_max,y_max)
					
				local hp = v:Health()
				local name = v:Nick()
				local dist = LocalPlayer():GetPos():Distance(v:GetPos())
				local ads = self:TTTIsTraitor(v)
				local acolor = team.GetColor(LocalPlayer():Team())
				local headpos = v:GetBonePosition(6)
				local headposc = headpos:ToScreen()
				draw.SimpleText(name, "Default", x_min + (x_max - (x_min))/2 , (y_min), acolor,TEXT_ALIGN_CENTER, TEXT_ALIGN_BOTTOM)
				draw.SimpleText("HP :" .. hp, "Default", x_min + (x_max - (x_min))/2 , (y_min) - 10, acolor,TEXT_ALIGN_CENTER, TEXT_ALIGN_BOTTOM)

				draw.SimpleText("Dist: "..math.Round(dist/16).."ft","Default", x_min, y_min, acolor,TEXT_ALIGN_RIGHT,0)
				draw.SimpleText(self:GetUserGroup(v),"Default", x_min, y_min+10, acolor,TEXT_ALIGN_RIGHT,0)

				if ads then
					draw.SimpleText(ads,"Default", x_min, y_min+20, Color(255,0,0,255),TEXT_ALIGN_RIGHT,0)
				end
				if dist < 1600 then 
					self:DrawBoneHighlighter(headposc.x,headposc.y,8)
				end
			end
	end
end
hook.Add("HUDPaint","AimbotWallHackPaint2",function() if oubhack.wallhack_on and !oubhack.hidemode then oubhack:ESPPaint() end end)

