|
|
@ -20,16 +20,14 @@ local radius = 1.05 * scale |
|
|
|
local padding = 5 * scale |
|
|
|
local padding = 5 * scale |
|
|
|
local sw, sh = ScrW(), ScrH() |
|
|
|
local sw, sh = ScrW(), ScrH() |
|
|
|
|
|
|
|
|
|
|
|
local client = LocalPlayer() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local function SetAlpha( color, alpha ) |
|
|
|
local function SetAlpha( color, alpha ) |
|
|
|
return Color( color.r, color.g, color.b, alpha ) |
|
|
|
return Color( color.r, color.g, color.b, alpha ) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
local function renderStatHUD() |
|
|
|
local function renderStatHUD() |
|
|
|
local hp = client:Health() |
|
|
|
local hp = LocalPlayer():Health() |
|
|
|
local lasthp = hp |
|
|
|
local lasthp = hp |
|
|
|
local maxhp = client:GetMaxHealth() |
|
|
|
local maxhp = LocalPlayer():GetMaxHealth() |
|
|
|
|
|
|
|
|
|
|
|
-- Health border |
|
|
|
-- Health border |
|
|
|
surface.SetDrawColor( 0, 0, 0, 200 ) |
|
|
|
surface.SetDrawColor( 0, 0, 0, 200 ) |
|
|
@ -55,16 +53,19 @@ local function renderStatHUD() |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
local function renderItemInfoHUD() |
|
|
|
local function renderItemInfoHUD() |
|
|
|
local trace = client:GetEyeTraceNoCursor() |
|
|
|
local trace = LocalPlayer():GetEyeTraceNoCursor() |
|
|
|
if( trace.Entity:GetClass() == "q_item" ) then |
|
|
|
local entsNear = ents.FindInSphere( LocalPlayer():GetPos(), Quantum.ItemInfoDisplayMaxDistance ) |
|
|
|
local distance = client:GetPos():Distance( trace.Entity:GetPos() ) |
|
|
|
|
|
|
|
|
|
|
|
for i, ent in pairs( entsNear ) do |
|
|
|
|
|
|
|
if( ent:GetClass() == "q_item" ) then |
|
|
|
|
|
|
|
local distance = LocalPlayer():GetPos():Distance( ent:GetPos() ) |
|
|
|
local distFrac = Lerp( distance/Quantum.ItemInfoDisplayMaxDistance, 1, 0 ) |
|
|
|
local distFrac = Lerp( distance/Quantum.ItemInfoDisplayMaxDistance, 1, 0 ) |
|
|
|
|
|
|
|
|
|
|
|
if( distance <= Quantum.ItemInfoDisplayMaxDistance ) then |
|
|
|
if( distance <= Quantum.ItemInfoDisplayMaxDistance ) then |
|
|
|
local item = Quantum.Item.Get( trace.Entity:GetNWString( "q_item_id" ) ) || { name="ERROR" } |
|
|
|
local item = Quantum.Item.Get( ent:GetNWString( "q_item_id" ) ) || { name = "", rarity = { txt = "", color = Color( 0, 0, 0, 0 ) } } |
|
|
|
local amount = trace.Entity:GetNWInt( "q_item_amount" ) || 1 |
|
|
|
local amount = ent:GetNWInt( "q_item_amount" ) || 1 |
|
|
|
|
|
|
|
|
|
|
|
local pos = trace.Entity:GetPos() |
|
|
|
local pos = ent:GetPos() |
|
|
|
pos.z = pos.z + 20 |
|
|
|
pos.z = pos.z + 20 |
|
|
|
|
|
|
|
|
|
|
|
local screenPos = pos:ToScreen() |
|
|
|
local screenPos = pos:ToScreen() |
|
|
@ -83,22 +84,48 @@ local function renderItemInfoHUD() |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local showRarities = { |
|
|
|
|
|
|
|
[Quantum.Rarity.Rare] = true, |
|
|
|
|
|
|
|
[Quantum.Rarity.Epic] = true, |
|
|
|
|
|
|
|
[Quantum.Rarity.Legendary] = true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local function renderHaloAroundItems() |
|
|
|
|
|
|
|
for i, item in pairs( ents.FindByClass( "q_item" ) ) do |
|
|
|
|
|
|
|
local itemid = item:GetNWString( "q_item_id" ) |
|
|
|
|
|
|
|
local itemTbl = Quantum.Item.Get(itemid) || { rarity = Quantum.Rarity.Rare } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( itemTbl != nil ) then |
|
|
|
|
|
|
|
if( showRarities[itemTbl.rarity] ) then |
|
|
|
|
|
|
|
halo.Add( { item }, SetAlpha( itemTbl.rarity.color, 255 ), 0, 0, 2, true, false ) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hook.Add( "PreDrawHalos", "Quantum_Item_Halos", function() |
|
|
|
|
|
|
|
renderHaloAroundItems() |
|
|
|
|
|
|
|
end) |
|
|
|
|
|
|
|
|
|
|
|
function GM:HUDPaint() |
|
|
|
function GM:HUDPaint() |
|
|
|
|
|
|
|
if( LocalPlayer():IsValid() ) then |
|
|
|
if( !Quantum.Client.IsInMenu ) then |
|
|
|
if( !Quantum.Client.IsInMenu ) then |
|
|
|
if( !client:Alive() ) then |
|
|
|
if( !LocalPlayer():Alive() ) then |
|
|
|
surface.SetDrawColor( 0, 0, 0, 255 ) |
|
|
|
surface.SetDrawColor( 0, 0, 0, 255 ) |
|
|
|
surface.DrawRect( 0, 0, sw, sh ) |
|
|
|
surface.DrawRect( 0, 0, sw, sh ) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
if( Quantum.Client.Config.EnableHUD ) then |
|
|
|
if( Quantum.Client.Config.EnableHUD ) then |
|
|
|
if( client:Alive() ) then |
|
|
|
if( LocalPlayer():Alive() ) then |
|
|
|
renderStatHUD() |
|
|
|
renderStatHUD() |
|
|
|
renderItemInfoHUD() |
|
|
|
renderItemInfoHUD() |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
function GM:Think() |
|
|
|
function GM:Think() |
|
|
|