diff --git a/gamemode/engine/core/client/cl_fonts.lua b/gamemode/engine/core/client/cl_fonts.lua index 104ff96..8dac180 100644 --- a/gamemode/engine/core/client/cl_fonts.lua +++ b/gamemode/engine/core/client/cl_fonts.lua @@ -149,4 +149,10 @@ surface.CreateFont( "q_item_hud_soulbound", { font = "Cambria", size = 20 * Quantum.Client.ResolutionScale, antialias = true +}) + +surface.CreateFont( "q_char_hud_name", { + font = "Cambria", + size = 28 * Quantum.Client.ResolutionScale, + antialias = true }) \ 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 4523494..f075bbb 100644 --- a/gamemode/engine/core/client/cl_hud.lua +++ b/gamemode/engine/core/client/cl_hud.lua @@ -87,6 +87,61 @@ local function renderItemInfoHUD() end end +local handle + +local function renderCharNamesHUD() + local trace = LocalPlayer():GetEyeTraceNoCursor() + + + local entsNear = ents.FindInSphere( LocalPlayer():GetPos(), Quantum.CharInfoDisplayDistance ) + + for i, ent in pairs( entsNear ) do + if( ent:IsPlayer() && ent != LocalPlayer() ) then + local distance = LocalPlayer():GetPos():Distance( ent:GetPos() ) + local distFrac = Lerp( distance/Quantum.CharInfoDisplayDistance, 1, 0 ) + + if( distance <= Quantum.CharInfoDisplayDistance ) then + handle = util.GetPixelVisibleHandle() + local pixelVis = util.PixelVisible( ent:GetPos(), 20, handle ) + print( ent:Nick(), pixelVis, ent:GetPos() ) + --if( util.PixelVisible( ent:GetPos(), 5, handle ) > 0 ) then + local name = ent:GetNWString( "q_char_name" ) + local pos = ent:GetPos() + pos.z = pos.z + 75 + + local screenPos = pos:ToScreen() + + local txtPadding = 20 * scale + local alphaFrac = distFrac + + + draw.SimpleText( name, "q_char_hud_name", screenPos.x, screenPos.y, Color( 225, 225, 225, 255 * distFrac ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER ) + --end + end + end + end + + -- local ent = trace.Entity + -- if( ent:IsPlayer() ) then + -- local distance = LocalPlayer():GetPos():Distance( ent:GetPos() ) + -- local distFrac = Lerp( distance/Quantum.CharInfoDisplayDistance, 1, 0 ) + + -- if( distance <= Quantum.CharInfoDisplayDistance ) then + -- local name = ent:GetNWString( "q_char_name" ) + -- local pos = ent:GetPos() + -- pos.z = pos.z + 20 + + -- local screenPos = pos:ToScreen() + + -- local txtPadding = 20 * scale + -- local alphaFrac = distFrac + + + -- draw.SimpleText( name, "q_char_hud_name", screenPos.x, screenPos.y, Color( 225, 225, 225, 255 * distFrac ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER ) + -- end + -- end +end + local showRarities = { [Quantum.Rarity.Rare] = true, [Quantum.Rarity.Epic] = true, @@ -122,6 +177,7 @@ function GM:HUDPaint() if( LocalPlayer():Alive() ) then renderStatHUD() renderItemInfoHUD() + renderCharNamesHUD() end end end diff --git a/gamemode/engine/core/server/sv_player_init.lua b/gamemode/engine/core/server/sv_player_init.lua index 4c1055c..c9124a2 100644 --- a/gamemode/engine/core/server/sv_player_init.lua +++ b/gamemode/engine/core/server/sv_player_init.lua @@ -42,12 +42,24 @@ end function GM:PlayerSpawn( ply ) - if( ply.isloaded == true ) then -- replace logic ( reversed ) - ply:UnSpectate() - setUpPlayer( ply ) + if( !ply:IsBot() ) then + if( ply.isloaded == true ) then -- replace logic ( reversed ) + ply:UnSpectate() + setUpPlayer( ply ) + else + ply:SetPos( Vector( -8936.411133, 8244.439453, 7744.031250 ) ) + Quantum.Net.OpenMenu( ply, "main", { chars = Quantum.Server.Char.GetPlayerChars_cl( ply ) } ) -- make the player open the main menu + end else - ply:SetPos( Vector( -8936.411133, 8244.439453, 7744.031250 ) ) - Quantum.Net.OpenMenu( ply, "main", { chars = Quantum.Server.Char.GetPlayerChars_cl( ply ) } ) -- make the player open the main menu + if( !ply.isloaded ) then + local selectedChar = table.Random( Quantum.Server.Settings.BotChars ) + ply.isbot = true + ply.isloaded = true + local botCharCount = table.Count(Quantum.Server.Char.GetPlayerChars( ply )) + Quantum.Server.Char.Load( ply, botCharCount + 1, selectedChar ) + Quantum.Server.Char.SetCurrentCharacter( ply, botCharCount + 1 ) + else + setUpPlayer( ply ) + end end - end \ No newline at end of file diff --git a/gamemode/engine/lib/server/sv_character.lua b/gamemode/engine/lib/server/sv_character.lua index 9b0b8fd..87aa5bd 100644 --- a/gamemode/engine/lib/server/sv_character.lua +++ b/gamemode/engine/lib/server/sv_character.lua @@ -9,12 +9,17 @@ Quantum.Server.Char = {} Quantum.Server.Char.Players = {} local function CreateCharTable( args ) + local rand = table.Random(Quantum.Classes) + local randMdl = rand.Models[ args.gender ][ math.random(1, #rand.Models[ args.gender ]) ] + local setMdl + if( args.class == nil ) then setMdl = randMdl end + return { name = args.name || "UNKNOWN", class = Quantum.Classes[args.class] || Quantum.Classes[1], maxhealth = Quantum.Server.Settings.MaxHealth, health = args.health || Quantum.Server.Settings.MaxHealth, - model = Quantum.Classes[args.class].Models[args.gender][args.modelIndex] || Quantum.Classes[args.class].Models[args.gender][1] || "models/player.mdl", + model = setMdl || "models/player.mdl", money = args.money || Quantum.Server.Settings.StarterMoney, inventory = args.inventory || {}, -- create new inventory later jobs = args.jobs || { @@ -72,6 +77,7 @@ function Quantum.Server.Char.SetCurrentCharacter( pl, index ) if( Quantum.Server.Char.Players[ id ] ) then pl.character = Quantum.Server.Char.Players[ id ] pl.charindex = index + pl:SetNWString( "q_char_name", pl.character.name ) Quantum.Net.Inventory.Update( pl ) -- update the players inventory on char change setupCharacter( pl, pl.character ) return pl.character diff --git a/gamemode/settings/sh_settings.lua b/gamemode/settings/sh_settings.lua index 4f80547..00adc37 100644 --- a/gamemode/settings/sh_settings.lua +++ b/gamemode/settings/sh_settings.lua @@ -18,10 +18,19 @@ Quantum.Inventory = { MaxStackSize = 20 -- NOTE: MAX MaxStackSize=99 } +Quantum.EquipSlots = { + Head = "", + Chest = "", + Legs = "", + Boots = "" +} + Quantum.InventoryOpenDelay = 0.35 Quantum.ItemPickupTime = 0.5 -- seconds Quantum.ItemInfoDisplayMaxDistance = 200 +Quantum.CharInfoDisplayDistance = 400 + Quantum.Money = { Prefix = "$", Surfix = "" diff --git a/gamemode/settings/sv_settings.lua b/gamemode/settings/sv_settings.lua index dcf7644..0a5604c 100644 --- a/gamemode/settings/sv_settings.lua +++ b/gamemode/settings/sv_settings.lua @@ -49,6 +49,17 @@ Quantum.Server.Settings.DamageScale = { -- The scale of the damage for each hitg [HITGROUP_RIGHTLEG] = 1 } +Quantum.Server.Settings.BotChars = { + civ1 = { + name = "John Doe", + gender = "Male" + }, + civ2 = { + name = "Jane Doe", + gender = "Female" + } +} + Quantum.Server.Settings.PainSounds = {} Quantum.Server.Settings.PainSounds.Male = { "vo/npc/male01/pain01.wav",