From da067dedfe353014d2f97ba389dcef8930a71418 Mon Sep 17 00:00:00 2001 From: AlmTech Software Date: Mon, 30 Dec 2019 01:54:46 +0100 Subject: [PATCH] Added item system & item rarity --- gamemode/engine/derma/lib/cl_menu_theme.lua | 4 ++-- gamemode/engine/derma/menus/menu_charinfo.lua | 7 ++----- gamemode/engine/lib/sh_items.lua | 10 +++++----- gamemode/settings/sh_items.lua | 6 ++++++ gamemode/settings/sh_settings.lua | 8 ++++++++ 5 files changed, 23 insertions(+), 12 deletions(-) create mode 100644 gamemode/settings/sh_items.lua diff --git a/gamemode/engine/derma/lib/cl_menu_theme.lua b/gamemode/engine/derma/lib/cl_menu_theme.lua index ac05564..476a285 100644 --- a/gamemode/engine/derma/lib/cl_menu_theme.lua +++ b/gamemode/engine/derma/lib/cl_menu_theme.lua @@ -135,9 +135,9 @@ function theme.pagetext( p ) surface.DrawRect( 0, 0, w, h ) end -function theme.itempanel( p ) +function theme.itempanel( p, rarecolor ) local w, h = p:GetSize() - surface.SetDrawColor( 0, 0, 0, 120 ) + surface.SetDrawColor( rarecolor || Color( 0, 0, 0, 120 ) ) surface.DrawRect( 0, 0, w, h ) if( p:IsHovered() ) then diff --git a/gamemode/engine/derma/menus/menu_charinfo.lua b/gamemode/engine/derma/menus/menu_charinfo.lua index 7713a20..6e29a28 100644 --- a/gamemode/engine/derma/menus/menu_charinfo.lua +++ b/gamemode/engine/derma/menus/menu_charinfo.lua @@ -105,10 +105,7 @@ function menu.open( dt ) local itemframe = vgui.Create( "DPanel", inv ) -- container for all of the item panels itemframe:SetSize( inv:GetSize() ) itemframe:SetPos( 0, 0 ) - itemframe.Paint = function( self, w, h ) - surface.SetDrawColor( 0, 0, 0, 0 ) - surface.DrawRect( 0, 0, w, h ) - end + itemframe.Paint = function( self, w, h ) end for ii=1, maxW * maxH, 1 do -- create all of the item panels if( ii != 1 ) then count = count + 1 end @@ -131,7 +128,7 @@ function menu.open( dt ) itempanels[ii].x, itempanels[ii].y = itempanels[ii]:GetPos() itempanels[ii].Paint = function( self ) - theme.itempanel( self ) + theme.itempanel( self, Quantum.Rarity.Rare.color ) end end diff --git a/gamemode/engine/lib/sh_items.lua b/gamemode/engine/lib/sh_items.lua index c965b9c..30b179d 100644 --- a/gamemode/engine/lib/sh_items.lua +++ b/gamemode/engine/lib/sh_items.lua @@ -10,12 +10,12 @@ Quantum.Items = {} function Quantum.Item.Create( id, args ) local item = { - name = args.name, -- items name - desc = args.desc, -- items description + name = args.name || "ERROR", -- items name + desc = args.desc || "ERROR: Some idiot forgot to give this item a description.", -- items description icon = args.icon, -- items icon - stack = args.stack, -- items max stack size - soulbound = args.soulbound, -- if item could be dropped/traded to other players - rarity = args.rarity, -- rarity of the item + stack = args.stack || false, -- items max stack size + soulbound = args.soulbound || true, -- if item could be dropped/traded to other players + rarity = args.rarity || Quantum.Rarity.Trash, -- rarity of the item usefunction = args.usefunction, -- use function consumefunction = args.consumefunction, --consume function equipfunction = args.equipfunction -- equip function diff --git a/gamemode/settings/sh_items.lua b/gamemode/settings/sh_items.lua new file mode 100644 index 0000000..77fd27b --- /dev/null +++ b/gamemode/settings/sh_items.lua @@ -0,0 +1,6 @@ +-- __ _ _______ _ __ +-- / / /\ | | |__ __| | | \ \ +-- / / / \ | |_ __ ___ | | ___ ___| |__ \ \ +-- < < / /\ \ | | '_ ` _ \| |/ _ \/ __| '_ \ > > +-- \ \ / ____ \| | | | | | | | __/ (__| | | | / / +-- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/ \ No newline at end of file diff --git a/gamemode/settings/sh_settings.lua b/gamemode/settings/sh_settings.lua index 13f91c9..9d3dc2c 100644 --- a/gamemode/settings/sh_settings.lua +++ b/gamemode/settings/sh_settings.lua @@ -22,6 +22,14 @@ Quantum.Money = { Surfix = "" } +Quantum.Rarity = { + Trash = { txt = "Trash", color = Color( 100, 100, 100, 100 ) }, + Common = { txt = "Common", color = Color( 250, 250, 250, 100 ) }, + Rare = { txt = "Rare", color = Color( 48, 163, 230, 100 ) }, + Epic = { txt = "Epic", color = Color( 220, 90, 90, 100 ) }, + Legendary = { txt = "Legendary", color = Color( 235, 125, 52, 100 ) } +} + Quantum.Models = { NPC = {}, Player = {