HUD update & effects bug fixes & added item effects

master
AlmTech Software 5 years ago
parent b47603c9ea
commit a24c763b75
  1. 20
      gamemode/engine/core/client/cl_hud.lua
  2. 25
      gamemode/engine/derma/lib/cl_menu_iteminfo.lua
  3. 22
      gamemode/engine/derma/menus/menu_crafting.lua
  4. 36
      gamemode/settings/sh_effects.lua
  5. 6
      gamemode/settings/sh_items.lua

@ -19,6 +19,7 @@ local scale = Quantum.Client.ResolutionScale
local barW, barH = 400 * scale, 25 * scale local barW, barH = 400 * scale, 25 * scale
local radius = 1.05 * scale local radius = 1.05 * scale
local padding = 5 * scale local padding = 5 * scale
local padding_s = padding/2
local sw, sh = ScrW(), ScrH() local sw, sh = ScrW(), ScrH()
local function SetAlpha( color, alpha ) local function SetAlpha( color, alpha )
@ -30,18 +31,29 @@ local function renderStatHUD()
local lasthp = hp local lasthp = hp
local maxhp = LocalPlayer():GetMaxHealth() local maxhp = LocalPlayer():GetMaxHealth()
local armor = LocalPlayer():Armor()
local maxarmor = 200
-- Health border -- Health border
surface.SetDrawColor( 0, 0, 0, 200 ) surface.SetDrawColor( 20, 20, 20, 200 )
surface.DrawRect( sw/2 - barW/2, sh*0.9, barW, barH ) surface.DrawRect( sw/2 - barW/2, sh*0.9, barW, barH )
-- Border bars
surface.SetDrawColor( 52, 180, 235, 200, 220 )
local armorWidth = math.Clamp( (barW - padding_s) * armor/maxarmor, 0, barW - padding_s )
surface.DrawRect( ( sw/2 - armorWidth/2 ), (sh*0.9) + padding_s/2, armorWidth, barH - padding_s )
-- Health bar -- Health bar
surface.SetDrawColor( 168, 62, 50, 255 ) surface.SetDrawColor( 168, 62, 50, 255 )
surface.DrawRect( ( sw/2 - barW/2 ) + padding/2, (sh*0.9) + padding/2, math.Clamp( (barW - padding) * hp/maxhp, 0, barW - padding ), barH - padding )
local healthWidth = math.Clamp( (barW - padding) * hp/maxhp, 0, barW - padding )
surface.DrawRect( ( sw/2 - healthWidth/2 ), (sh*0.9) + padding/2, healthWidth, barH - padding )
-- Health Text -- Health Text
surface.SetFont( "q_HUD" ) surface.SetFont( "q_HUD" )
surface.SetTextColor( 255, 255, 255, 255 ) surface.SetTextColor( 255, 255, 255, 255 )
local hptxt = tostring( 100 * (hp/maxhp) .. "%" ) local hptxt = tostring( hp )
local txtW, txtH = surface.GetTextSize( hptxt ) local txtW, txtH = surface.GetTextSize( hptxt )
surface.SetTextPos( ( ( sw/2 - txtW/2 ) + padding/2 ), ( ( sh*0.9 - txtH/3 ) ) ) surface.SetTextPos( ( ( sw/2 - txtW/2 ) + padding/2 ), ( ( sh*0.9 - txtH/3 ) ) )
surface.DrawText( hptxt ) surface.DrawText( hptxt )

@ -192,7 +192,6 @@ function iteminfo.giveoptions( p, page )
if( item.equipslot != nil ) then -- Equip if( item.equipslot != nil ) then -- Equip
if( page.equippanels[item.equipslot].GetCurrentEquipedIndex() != index ) then if( page.equippanels[item.equipslot].GetCurrentEquipedIndex() != index ) then
print( "TRUE", page.equippanels[item.equipslot].GetCurrentEquipedIndex(), index )
op.equip = vgui.Create( "DButton", options ) op.equip = vgui.Create( "DButton", options )
op.equip:SetText( "Equip (" .. Quantum.EquipSlotsNames[item.equipslot] .. ")" ) op.equip:SetText( "Equip (" .. Quantum.EquipSlotsNames[item.equipslot] .. ")" )
op.equip:SetFont( "q_item_option_button" ) op.equip:SetFont( "q_item_option_button" )
@ -454,7 +453,7 @@ function iteminfo.givetooltip( p, page, addW )
use:SetPos( title.x, yposBase ) use:SetPos( title.x, yposBase )
use.x, use.y = use:GetPos() use.x, use.y = use:GetPos()
yposBase = yposBase + use.y + padding_s yposBase = yposBase + use.h + padding_s
end end
end end
@ -472,7 +471,27 @@ function iteminfo.givetooltip( p, page, addW )
eat:SetPos( title.x, yposBase ) eat:SetPos( title.x, yposBase )
eat.x, eat.y = eat:GetPos() eat.x, eat.y = eat:GetPos()
yposBase = yposBase + eat.y + padding_s yposBase = yposBase + eat.h + padding_s
end
end
if( self.item.equipeffect != nil ) then
if( self.item.equipslot != nil ) then
local effectTbl = Quantum.Effect.Get( self.item.equipeffect )
if( effectTbl.desc != nil ) then
local equipDesc = vgui.Create( "DLabel", self )
equipDesc:SetText( "Equip: " .. effectTbl.desc || "ERROR DESC EQUIP" )
equipDesc:SetFont( "q_tooltip_desc" )
equipDesc:SetTextColor( Color( 18, 224, 66, 255 ) )
equipDesc:SizeToContents()
equipDesc.w, equipDesc.h = equipDesc:GetSize()
equipDesc:SetPos( title.x, yposBase )
equipDesc.x, equipDesc.y = equipDesc:GetPos()
yposBase = yposBase + equipDesc.h + padding_s
end
end end
end end

@ -325,6 +325,7 @@ function menu.open( dt )
resBars[resID].cont.title.x, resBars[resID].cont.title.y = resBars[resID].cont.title:GetPos() resBars[resID].cont.title.x, resBars[resID].cont.title.y = resBars[resID].cont.title:GetPos()
resBars[resID].cont.craft = vgui.Create( "DButton", resBars[resID].cont ) resBars[resID].cont.craft = vgui.Create( "DButton", resBars[resID].cont )
resBars[resID].cont.craft.enabled = true
resBars[resID].cont.craft:SetText( "Create Item" ) resBars[resID].cont.craft:SetText( "Create Item" )
resBars[resID].cont.craft:SetFont( "q_button_m" ) resBars[resID].cont.craft:SetFont( "q_button_m" )
resBars[resID].cont.craft:SetTextColor( Color( 255, 255, 255 ) ) resBars[resID].cont.craft:SetTextColor( Color( 255, 255, 255 ) )
@ -332,12 +333,20 @@ function menu.open( dt )
resBars[resID].cont.craft.w, resBars[resID].cont.craft.h = resBars[resID].cont.craft:GetSize() resBars[resID].cont.craft.w, resBars[resID].cont.craft.h = resBars[resID].cont.craft:GetSize()
resBars[resID].cont.craft:SetPos( resBars[resID].cont.title.x, resBars[resID].cont.title.y + resBars[resID].cont.craft.h + padding ) resBars[resID].cont.craft:SetPos( resBars[resID].cont.title.x, resBars[resID].cont.title.y + resBars[resID].cont.craft.h + padding )
resBars[resID].cont.craft.Paint = function( self ) resBars[resID].cont.craft.Paint = function( self )
theme.sharpblurrbutton( self ) if( self.enabled ) then
theme.sharpblurrbutton( self, Color( 110, 255, 110, 120 ) )
else
theme.sharpblurrbutton( self, Color( 255, 110, 110, 120 ) )
end
end end
resBars[resID].cont.craft.DoClick = function( self ) resBars[resID].cont.craft.DoClick = function( self )
surface.PlaySound( "UI/buttonclick.wav" ) if( self.enabled ) then
f:Close() surface.PlaySound( "UI/buttonclick.wav" )
-- SEND NET CRAFT HERE -- f:Close()
-- SEND NET CRAFT HERE --
else
surface.PlaySound( "common/wpn_denyselect.wav" )
end
end end
resBars[resID].cont.craft.OnCursorEntered = function() surface.PlaySound( "UI/buttonrollover.wav" ) end resBars[resID].cont.craft.OnCursorEntered = function() surface.PlaySound( "UI/buttonrollover.wav" ) end
@ -378,7 +387,7 @@ function menu.open( dt )
count = count + 1 count = count + 1
itemPanels[count] = vgui.Create( "DPanel", resBars[resID].cont.reagents ) itemPanels[count] = vgui.Create( "DPanel", resBars[resID].cont.reagents )
itemPanels[count]:SetSize( 600 * resScale, itemHeight*regScale + padding*2 ) itemPanels[count]:SetSize( 750 * resScale, itemHeight*regScale + padding*2 )
itemPanels[count].w, itemPanels[count].h = itemPanels[count]:GetSize() -- itemPanels[count].w, itemPanels[count].h = itemPanels[count]:GetSize() --
itemPanels[count]:SetPos( resBars[resID].cont.reagentsTXT.x + padding, itemPanels[count].h*(count-1) + padding*(count-1) ) itemPanels[count]:SetPos( resBars[resID].cont.reagentsTXT.x + padding, itemPanels[count].h*(count-1) + padding*(count-1) )
itemPanels[count].Paint = function( self, w, h ) itemPanels[count].Paint = function( self, w, h )
@ -406,6 +415,9 @@ function menu.open( dt )
itemamount:SetTextColor( Color( 255, 255, 255, 220 ) ) itemamount:SetTextColor( Color( 255, 255, 255, 220 ) )
else else
itemamount:SetTextColor( Color( 255, 155, 155, 220 ) ) itemamount:SetTextColor( Color( 255, 155, 155, 220 ) )
if( resBars[resID].cont.craft.enabled == true ) then
resBars[resID].cont.craft.enabled = false
end
end end
itemamount:SizeToContents() itemamount:SizeToContents()
itemamount.w, itemamount.h = itemamount:GetSize() itemamount.w, itemamount.h = itemamount:GetSize()

@ -19,6 +19,30 @@ Quantum.Effect.Create( "eat_potatoe", {
end end
} ) } )
Quantum.Effect.Create( "equip_potatoe", {
title = "Potatoe Powers",
desc = "Increases your max health by 100 and\nheales you with 5 health every second.",
rarity = Quantum.Rarity.Legendary,
startfunc = function( pl )
pl:SetMaxHealth( pl:GetMaxHealth() + 100 )
pl.runtimeEffect_timerActive_equip_potatoe = false
end,
runtimefunc = function( pl )
if( !pl.runtimeEffect_timerActive_equip_potatoe ) then
pl.runtimeEffect_timerActive_equip_potatoe = true
timer.Simple( 1, function()
pl:SetHealth( math.Clamp( pl:Health() + 5, 1, pl:GetMaxHealth() ) )
pl.runtimeEffect_timerActive_equip_potatoe = false
end)
end
end,
stopfunc = function( pl )
pl:SetMaxHealth( math.Clamp( pl:GetMaxHealth() - 100, 1, pl:GetMaxHealth() ) )
pl.runtimeEffect_timerActive_equip_potatoe = nil
end
} )
Quantum.Effect.Create( "eat_trash", { Quantum.Effect.Create( "eat_trash", {
title = "Bad Health", title = "Bad Health",
desc = "You die.", desc = "You die.",
@ -26,4 +50,16 @@ Quantum.Effect.Create( "eat_trash", {
startfunc = function( pl ) startfunc = function( pl )
pl:Kill() pl:Kill()
end end
} )
Quantum.Effect.Create( "test_chest", {
title = "Protective Shield",
desc = "You gain 100 armor while the chestpiece is on.",
rarity = Quantum.Rarity.Rare,
startfunc = function( pl )
pl:SetArmor( 100 )
end,
stopfunc = function( pl )
pl:SetArmor( 0 )
end
} ) } )

@ -11,7 +11,8 @@ Quantum.Item.Create( "test", {
model = "models/props_phx/gears/bevel12.mdl", model = "models/props_phx/gears/bevel12.mdl",
soulbound = true, soulbound = true,
rarity = Quantum.Rarity.Rare, rarity = Quantum.Rarity.Rare,
equipslot = Quantum.EquipSlots.Chest equipslot = Quantum.EquipSlots.Chest,
equipeffect = "test_chest"
} ) } )
Quantum.Item.Create( "test2", { Quantum.Item.Create( "test2", {
@ -42,7 +43,8 @@ Quantum.Item.Create( "potatoe", {
soulbound = false, soulbound = false,
rarity = Quantum.Rarity.Legendary, rarity = Quantum.Rarity.Legendary,
equipslot = Quantum.EquipSlots.Head, equipslot = Quantum.EquipSlots.Head,
consumeeffect = "eat_potatoe" consumeeffect = "eat_potatoe",
equipeffect = "equip_potatoe"
} ) } )
-- weapon_gta_sa_jetpack.lua -- weapon_gta_sa_jetpack.lua

Loading…
Cancel
Save