Added item halos & item pickup delay & bug fixes

master
AlmTech Software 5 years ago
parent a916c3fb78
commit 307972ea61
  1. 51
      gamemode/engine/core/client/cl_hud.lua
  2. 21
      gamemode/engine/derma/menus/menu_charinfo.lua
  3. 2
      gamemode/engine/lib/sh_items.lua
  4. 10
      gamemode/settings/sh_items.lua
  5. 5
      gamemode/settings/sh_settings.lua

@ -20,16 +20,14 @@ local radius = 1.05 * scale
local padding = 5 * scale
local sw, sh = ScrW(), ScrH()
local client = LocalPlayer()
local function SetAlpha( color, alpha )
return Color( color.r, color.g, color.b, alpha )
end
local function renderStatHUD()
local hp = client:Health()
local hp = LocalPlayer():Health()
local lasthp = hp
local maxhp = client:GetMaxHealth()
local maxhp = LocalPlayer():GetMaxHealth()
-- Health border
surface.SetDrawColor( 0, 0, 0, 200 )
@ -55,16 +53,19 @@ local function renderStatHUD()
end
local function renderItemInfoHUD()
local trace = client:GetEyeTraceNoCursor()
if( trace.Entity:GetClass() == "q_item" ) then
local distance = client:GetPos():Distance( trace.Entity:GetPos() )
local trace = LocalPlayer():GetEyeTraceNoCursor()
local entsNear = ents.FindInSphere( LocalPlayer():GetPos(), Quantum.ItemInfoDisplayMaxDistance )
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 )
if( distance <= Quantum.ItemInfoDisplayMaxDistance ) then
local item = Quantum.Item.Get( trace.Entity:GetNWString( "q_item_id" ) ) || { name="ERROR" }
local amount = trace.Entity:GetNWInt( "q_item_amount" ) || 1
local item = Quantum.Item.Get( ent:GetNWString( "q_item_id" ) ) || { name = "", rarity = { txt = "", color = Color( 0, 0, 0, 0 ) } }
local amount = ent:GetNWInt( "q_item_amount" ) || 1
local pos = trace.Entity:GetPos()
local pos = ent:GetPos()
pos.z = pos.z + 20
local screenPos = pos:ToScreen()
@ -83,22 +84,48 @@ local function renderItemInfoHUD()
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()
if( LocalPlayer():IsValid() ) then
if( !Quantum.Client.IsInMenu ) then
if( !client:Alive() ) then
if( !LocalPlayer():Alive() ) then
surface.SetDrawColor( 0, 0, 0, 255 )
surface.DrawRect( 0, 0, sw, sh )
end
if( Quantum.Client.Config.EnableHUD ) then
if( client:Alive() ) then
if( LocalPlayer():Alive() ) then
renderStatHUD()
renderItemInfoHUD()
end
end
end
end
end
function GM:Think()

@ -145,7 +145,7 @@ function menu.open( dt )
itempanels[ii].index = ii -- set the vars
if( items[ii] ) then
itempanels[ii].item = Quantum.Item.Get( items[ii][1]) -- get the items info through its id
itempanels[ii].item = Quantum.Item.Get( items[ii][1] ) -- get the items info through its id
itempanels[ii].item.amount = items[ii][2] || 1 -- get the amount
end
@ -292,10 +292,27 @@ hook.Add("ScoreboardShow", "Quantum_Menu_CharInfo_Open", function()
-- InventoryStartTime = nil
-- end -- open the menu
menu.open()
-- menu.open()
return false
end)
local startTime
hook.Add( "Think", "Quantum_Menu_CharInfo_Think", function()
if( !Quantum.Client.IsInMenu ) then
if( input.IsButtonDown( Quantum.Bind.OpenInventory ) ) then
startTime = startTime || CurTime()
if( CurTime() - startTime >= Quantum.InventoryOpenDelay ) then
startTime = nil
menu.open()
end
else
startTime = nil
end
end
end)
return menu

@ -55,7 +55,7 @@ if SERVER then
end
end
function Quantum.Server.Item.SpawnItemAtPlayer( pl, itemid, amount ) --
function Quantum.Server.Item.SpawnItemAtPlayer( pl, itemid, amount ) -- Quantum.Server.Item.SpawnItemAtPlayer( Entity(1), "test2", 5 )
Quantum.Server.Item.SpawnItem( pl:GetPos() + ( pl:GetForward() * 40 ) + Vector( 0, 0, 40 ), itemid, amount )
end
end

@ -39,3 +39,13 @@ Quantum.Item.Create( "bomb", {
equipable = false,
rarity = Quantum.Rarity.Epic
} )
Quantum.Item.Create( "potatoe", {
name = "Legendary Potatoe",
desc = "The most legendary potatoe in existance. Don't eat it!",
model = "models/props_phx/misc/potato.mdl",
stack = 1,
soulbound = false,
equipable = false,
rarity = Quantum.Rarity.Legendary
} )

@ -18,6 +18,7 @@ Quantum.Inventory = {
MaxStackSize = 20 -- NOTE: MAX MaxStackSize=99
}
Quantum.InventoryOpenDelay = 0.35
Quantum.ItemPickupTime = 0.5 -- seconds
Quantum.ItemInfoDisplayMaxDistance = 200
@ -35,6 +36,10 @@ Quantum.Rarity = {
Legendary = { txt = "Legendary", color = Color( 235, 125, 52, 40 ) }
}
Quantum.Bind = {
OpenInventory = KEY_TAB
}
Quantum.Models = {
NPC = {},
Player = {

Loading…
Cancel
Save