Finished crafting system & UI stuff

master v0.4-beta
AlmTech Software 5 years ago
parent 8639a91009
commit a3cc002b8c
  1. 20
      entities/entities/q_crafting_station/cl_init.lua
  2. 12
      gamemode/engine/core/client/cl_character_net.lua
  3. 12
      gamemode/engine/core/client/cl_hud.lua
  4. 7
      gamemode/engine/core/client/cl_sounds.lua
  5. 3
      gamemode/engine/derma/menus/menu_crafting.lua
  6. 9
      gamemode/engine/lib/server/sv_crafting.lua
  7. 6
      gamemode/engine/lib/server/sv_networking.lua
  8. 1
      gamemode/engine/vars/sh_vars.lua
  9. 4
      gamemode/settings/sh_items.lua
  10. 18
      gamemode/settings/sh_recipes.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

@ -128,3 +128,15 @@ 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

@ -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()

@ -11,3 +11,10 @@ sound.Add( {
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"
} )

@ -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

@ -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)

@ -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
}

@ -44,6 +44,7 @@ Quantum.IntCode = {
UNEQUIP_ITEM = 5,
DESTROY_ITEM = 6, -- to be added
UPDATE = 7,
CRAFT_RECIPE = 8,
BIT_SIZE = 5
}

@ -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,

@ -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 }
}
})

Loading…
Cancel
Save