diff --git a/entities/entities/q_crafting_station/cl_init.lua b/entities/entities/q_crafting_station/cl_init.lua index d615b1b..2c91012 100644 --- a/entities/entities/q_crafting_station/cl_init.lua +++ b/entities/entities/q_crafting_station/cl_init.lua @@ -7,6 +7,26 @@ include( "shared.lua" ) +local pos +local ang +local mdlHeight +local p, q + function ENT:Draw() self:DrawModel() + + pos, ang = self:GetPos(), self:GetAngles() + + p, q = self:GetRenderBounds() + mdlHeight = q.z - p.z + + pos = pos + ang:Up() * (mdlHeight + 10) + + -- rotate around axis + + cam.Start3D2D( pos, ang, 0.15 ) + surface.SetTextColor( Color( 255, 255, 255 ) ) + surface.SetFont( "q_title" ) + surface.DrawText( "aihofhsdifhiosdfh" ) + cam.End3D2D() end \ No newline at end of file diff --git a/gamemode/engine/core/client/cl_character_net.lua b/gamemode/engine/core/client/cl_character_net.lua index 3cd34ae..35f0bbc 100644 --- a/gamemode/engine/core/client/cl_character_net.lua +++ b/gamemode/engine/core/client/cl_character_net.lua @@ -127,4 +127,16 @@ function Quantum.Client.InventoryNet.UnequipItem( equipindex ) -- end -- end +end + +function Quantum.Client.InventoryNet.CraftRecipe( itemid ) + local res = Quantum.Recipe.Get( itemid ) + + if( res != nil ) then + net.Start( "quantum_item_action" ) + Quantum.WriteIntcode( Quantum.IntCode.CRAFT_RECIPE ) + net.WriteInt( 1, Quantum.calculateNeededBits( Quantum.Inventory.Size ) ) + net.WriteString( res.creates ) + net.SendToServer() + end end \ No newline at end of file diff --git a/gamemode/engine/core/client/cl_hud.lua b/gamemode/engine/core/client/cl_hud.lua index f371550..d1751f0 100644 --- a/gamemode/engine/core/client/cl_hud.lua +++ b/gamemode/engine/core/client/cl_hud.lua @@ -38,8 +38,8 @@ local function renderStatHUD() surface.SetDrawColor( 20, 20, 20, 200 ) surface.DrawRect( sw/2 - barW/2, sh*0.9, barW, barH ) - -- Border bars - surface.SetDrawColor( 52, 180, 235, 200, 220 ) + -- Armor bar + surface.SetDrawColor( 52, 180, 255, 200, 200 ) 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 ) @@ -111,6 +111,14 @@ local function createCraftPanel() craft.w, craft.h = craft:GetSize() craft:SetPos( sw/2 - craft.w/2, sh*0.65 - craft.h/2 ) + craft.Paint = function( self, w, h ) + surface.SetDrawColor( Color( 0, 0, 0, 180 ) ) + surface.DrawOutlinedRect( 0, 0, w, h ) + + surface.SetDrawColor( Color( 255, 255, 255, 50 ) ) + surface.DrawOutlinedRect( 0, 0, w, h ) + end + craft.frac = 0 craft.fadein = true craft.startTime = CurTime() diff --git a/gamemode/engine/core/client/cl_sounds.lua b/gamemode/engine/core/client/cl_sounds.lua index 032cef4..584bd25 100644 --- a/gamemode/engine/core/client/cl_sounds.lua +++ b/gamemode/engine/core/client/cl_sounds.lua @@ -10,4 +10,11 @@ sound.Add( { channel = CHAN_STATIC, volume = 0.75, sound = "music/HL2_song23_SuitSong3.mp3" +} ) + +sound.Add( { + name = "Quantum_Crafting_Loop", + channel = CHAN_STATIC, + volume = 0.75, + sound = "physics/cardboard/cardboard_box_scrape_rough_loop1.wav" } ) \ No newline at end of file diff --git a/gamemode/engine/derma/menus/menu_crafting.lua b/gamemode/engine/derma/menus/menu_crafting.lua index 05cae99..ac584fe 100644 --- a/gamemode/engine/derma/menus/menu_crafting.lua +++ b/gamemode/engine/derma/menus/menu_crafting.lua @@ -343,7 +343,8 @@ function menu.open( dt ) if( self.enabled ) then surface.PlaySound( "UI/buttonclick.wav" ) f:Close() - -- SEND NET CRAFT HERE -- + -- NET CRAFT -- + Quantum.Client.InventoryNet.CraftRecipe( resBars[resID].resTbl.creates ) else surface.PlaySound( "common/wpn_denyselect.wav" ) end diff --git a/gamemode/engine/lib/server/sv_crafting.lua b/gamemode/engine/lib/server/sv_crafting.lua index ba287e1..98f28fb 100644 --- a/gamemode/engine/lib/server/sv_crafting.lua +++ b/gamemode/engine/lib/server/sv_crafting.lua @@ -27,6 +27,9 @@ local function cancelCrafting( pl ) if( timer.Exists( "Quantum_Crafting_" .. pl:SteamID64() ) ) then timer.Stop( "Quantum_Crafting_" .. pl:SteamID64() ) setPlayerIsCrafting( pl, false ) + if( pl.craftSound != nil ) then + pl.craftSound:Stop() + end end end @@ -47,7 +50,11 @@ function Quantum.Server.Crafting.MakeItem( pl, itemid ) -- and then craft this item instead setPlayerIsCrafting( pl, true ) + pl.craftSound = CreateSound( pl, "physics/cardboard/cardboard_box_scrape_rough_loop1.wav" ) + if( isPlayerCrafting( pl ) ) then + pl.craftSound:Play() + pl.craftSound:ChangeVolume( 0.2 ) timer.Create( "Quantum_Crafting_" .. pl:SteamID64(), recipe.delay, 1, function() -- remove the ingridients from the players inv @@ -62,7 +69,6 @@ function Quantum.Server.Crafting.MakeItem( pl, itemid ) for i, slot in pairs( slots ) do if( itemCount < reqItem.amount ) then itemCount = itemCount + inv[slot][2] - print( inv[slot][2] ) Quantum.Server.Inventory.RemoveSlotItem( pl, char, slot, inv[slot][2] ) end @@ -76,6 +82,7 @@ function Quantum.Server.Crafting.MakeItem( pl, itemid ) Quantum.Notify.ItemCrafted( pl, Quantum.Item.Get( recipe.creates ), recipe.amount ) setPlayerIsCrafting( pl, false ) -- when everything is done then set this to false + pl.craftSound:Stop() pl:EmitSound( Quantum.Server.Settings.ItemPickupSound ) -- make a sound on craft end) diff --git a/gamemode/engine/lib/server/sv_networking.lua b/gamemode/engine/lib/server/sv_networking.lua index 820e2a3..48338f3 100644 --- a/gamemode/engine/lib/server/sv_networking.lua +++ b/gamemode/engine/lib/server/sv_networking.lua @@ -164,6 +164,7 @@ function Quantum.Net.Inventory.Update( pl ) end local intcodeFunctions = { + ---- INVENTORY NETWORKING ---- [Quantum.IntCode.SET_ITEM] = function( pl, index, itemid, amount ) -- if the client is trying to set an item then kick the player Quantum.Warn( "Player [" .. pl:Nick() .. " | " .. pl:SteamID() .. "] tried to use a blacklisted Intcode function called from the client!" ) pl:Kick( "[Quantum Security] Tried to use a invalid Intcode function. Nice try." ) @@ -182,6 +183,11 @@ local intcodeFunctions = { end, [Quantum.IntCode.UNEQUIP_ITEM] = function( pl, equipslot, itemid, amount ) Quantum.Server.Inventory.UnEquipItem( pl, equipslot ) + end, + + ---- CRAFTING NETWORKING ---- + [Quantum.IntCode.CRAFT_RECIPE] = function( pl, index, itemid, amount ) + Quantum.Server.Crafting.MakeItem( pl, itemid ) end } diff --git a/gamemode/engine/vars/sh_vars.lua b/gamemode/engine/vars/sh_vars.lua index 54ec5c7..9951f9d 100644 --- a/gamemode/engine/vars/sh_vars.lua +++ b/gamemode/engine/vars/sh_vars.lua @@ -44,6 +44,7 @@ Quantum.IntCode = { UNEQUIP_ITEM = 5, DESTROY_ITEM = 6, -- to be added UPDATE = 7, + CRAFT_RECIPE = 8, BIT_SIZE = 5 } diff --git a/gamemode/settings/sh_items.lua b/gamemode/settings/sh_items.lua index 153a804..cb7a2d4 100644 --- a/gamemode/settings/sh_items.lua +++ b/gamemode/settings/sh_items.lua @@ -16,8 +16,8 @@ Quantum.Item.Create( "test", { } ) Quantum.Item.Create( "test2", { - name = "Trash Item Test", - desc = "This is literall trash\nLine breaker test :D\n\nTest :D", + name = "Scrap", + desc = "A pile of scrap parts.", model = "models/props_phx/gears/bevel12.mdl", stack = 10, soulbound = false, diff --git a/gamemode/settings/sh_recipes.lua b/gamemode/settings/sh_recipes.lua index 5451784..8ac2643 100644 --- a/gamemode/settings/sh_recipes.lua +++ b/gamemode/settings/sh_recipes.lua @@ -33,3 +33,21 @@ Quantum.Recipe.Add( "test2", "barrel", { { item = "potatoe", amount = 1 } } }) + +Quantum.Recipe.Add( "m9k_colt1911", "barrel", { + name = "Colt 1911", + amount = 1, + delay = 5, + recipe = { + { item = "test2", amount = 5 } + } +}) + +Quantum.Recipe.Add( "jetpack", "barrel", { + name = "A Jet Engine & Duct Tape", + amount = 1, + delay = 5, + recipe = { + { item = "test2", amount = 5 } + } +})