Added BOT support & Text above players & bug fixes

master
AlmTech Software 5 years ago
parent fca3ad0654
commit b7a4433236
  1. 6
      gamemode/engine/core/client/cl_fonts.lua
  2. 56
      gamemode/engine/core/client/cl_hud.lua
  3. 14
      gamemode/engine/core/server/sv_player_init.lua
  4. 8
      gamemode/engine/lib/server/sv_character.lua
  5. 9
      gamemode/settings/sh_settings.lua
  6. 11
      gamemode/settings/sv_settings.lua

@ -150,3 +150,9 @@ surface.CreateFont( "q_item_hud_soulbound", {
size = 20 * Quantum.Client.ResolutionScale,
antialias = true
})
surface.CreateFont( "q_char_hud_name", {
font = "Cambria",
size = 28 * Quantum.Client.ResolutionScale,
antialias = true
})

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

@ -42,6 +42,7 @@ end
function GM:PlayerSpawn( ply )
if( !ply:IsBot() ) then
if( ply.isloaded == true ) then -- replace logic ( reversed )
ply:UnSpectate()
setUpPlayer( ply )
@ -49,5 +50,16 @@ function GM:PlayerSpawn( ply )
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
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

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

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

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

Loading…
Cancel
Save