Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Health = 0
- local av
- local name
- local oldName
- local function DrawPlayerAvatar( p )
- oldName = LocalPlayer():Name()
- print( oldName )
- av = vgui.Create("AvatarImage")
- av:SetPos(64,ScrH() - 130)
- av:SetSize(56, 56)
- av:SetPlayer( p, 64 )
- end
- -- My fancy new HUD
- -- Colors & Fonts
- local col1 = Color( 102,102,102, 255 )
- local col2 = Color( 51, 51, 51, 255 )
- local col3 = Color( 82, 82, 82, 255 )
- local col4 = Color(0,0,0,200)
- surface.CreateFont( "pname", {
- font = "Perspective Sans",
- size = 26,
- weight = 500,
- blursize = 0,
- scanlines = 0,
- antialias = true
- } )
- surface.CreateFont( "tname", {
- font = "Capture Smallz",
- size = 20,
- weight = 500,
- blursize = 0,
- scanlines = 0,
- antialias = true
- } )
- surface.CreateFont( "tname_s", {
- font = "Capture Smallz",
- size = 16,
- weight = 500,
- blursize = 0,
- scanlines = 0,
- antialias = true
- } )
- surface.SetTextPos( 34, ScrH()/2+ScrH()/4 )
- surface.CreateFont( "money", {
- font = "Bebas Neue",
- size = 22,
- weight = 500,
- blursize = 0,
- scanlines = 0,
- antialias = true
- } )
- surface.CreateFont("exp", {
- size = 17,
- weight = 800,
- antialias = true,
- additive = false
- })
- surface.CreateFont("ammo", {
- size = 17,
- weight = 800,
- antialias = true,
- additive = false
- })
- surface.CreateFont( "small", {
- font = "Capture Smallz",
- size = 17,
- blursize = 0,
- scanlines = 0,
- antialias = true
- } )
- surface.CreateFont( "small2", {
- font = "Helvetica",
- size = 18,
- weight = 800,
- blursize = 0,
- scanlines = 0,
- antialias = true
- } )
- surface.CreateFont( "desc", {
- font = "Bebas Neue",
- size = ScreenScale( 6 ),
- weight = 500,
- blursize = 0,
- scanlines = 0,
- antialias = true
- } )
- -- Avatar func
- local av
- local function DrawPlayerAvatar0( x,y,w,h )
- av = vgui.Create("AvatarImage")
- av:SetPos(x,y)
- av:SetSize(w,h)
- av:SetPlayer( LocalPlayer(), 64 )
- --draw.RoundedBox( 0, x, y, w, h, Color(0,100,0,255) )
- end
- function GM:DrawBasewarsHUD()
- --local w = ScrW() / 4.5
- local w = 380
- --local h = ScrW() / 10
- local h = 160
- local x = 5
- local y = ScrH() - h - 5
- local offsetx, offsety
- -- Main box
- --surface.SetDrawColor( col1 )
- --surface.DrawRect( x, y, w, h )
- draw.RoundedBox( 4, x-1, y-1, w+2, h+2, Color(0,0,0,255) )
- draw.RoundedBox( 4, x, y, w, h, col1 )
- --surface.SetDrawColor( col2 )
- --surface.DrawOutlinedRect( x, y, w+2, h )
- --draw.RoundedBox( 4, x, y, w, h, col2 )
- -- Background boxes
- draw.RoundedBox( 4, x, y, 47, h, col2 ) -- Drugmeter
- draw.RoundedBox( 4, x+46, y+85, w-46, h-85, col3 ) -- Bars
- -- 3D effect lines
- -- Drugbar
- surface.SetDrawColor( 200, 200, 200, 20 )
- surface.DrawLine( x+2, y, x+45, y )
- surface.DrawLine( x, y+2, x, y+h-2 )
- surface.SetDrawColor( 0, 0, 0, 255 )
- surface.DrawLine( x+46, y, x+46, y+h )
- surface.SetDrawColor( 0, 0, 0, 255 )
- surface.DrawLine( x+46, y+84, w+6, y+84 )
- surface.SetDrawColor( 0, 0, 0, 100 )
- surface.DrawLine( x+46, y+85, w+6, y+85 )
- -- Testing line
- --surface.SetDrawColor( 0, 0, 0, 255 )
- --surface.DrawLine( x+115, y+35, x+320, y+35 )
- -- Simple concave polygon vertices
- local concave = {}
- concave[1] = { x = (ScrW() / 2) - 200, y = (ScrH() / 2) }
- concave[2] = { x = (ScrW() / 2) + 200, y = (ScrH() / 2) }
- concave[3] = { x = (ScrW() / 2) + 200, y = (ScrH() / 2) - 150 }
- concave[4] = { x = (ScrW() / 2), y = (ScrH() / 2) - 100 }
- concave[5] = { x = (ScrW() / 2) - 200, y = (ScrH() / 2) - 150 }
- surface.SetDrawColor(255, 255, 255, 255)
- surface.DrawPoly(concave)
- -- Buffs/Drugmeter
- draw.RoundedBox(4, x + 10, y+10, 26, h-40, Color(0,0,0,200))
- draw.SimpleText( "?", "desc", 27, y+h-25, Color( 255, 255, 255, 255 ), TEXT_ALIGN_CENTER )
- -- Player Name
- local font
- surface.SetFont( "pname" )
- local PlayerName = LocalPlayer():Name()
- local wi, hi = surface.GetTextSize(PlayerName)
- if wi > 320 then
- PlayerName = string.sub( LocalPlayer():Name(), 1, 24 )..".."
- else
- local PlayerName = LocalPlayer():Name()
- end
- offsetx = x+115
- draw.SimpleText( PlayerName, "pname", offsetx+2, y+5+2, Color(50,50,50,255) )
- draw.SimpleText( PlayerName, "pname", offsetx, y+5, Color( 255, 255, 255 ) )
- -- Team Name
- surface.SetFont( "tname" )
- local PlayerTeam = team.GetName(LocalPlayer():Team())
- local wi, hi = surface.GetTextSize(PlayerTeam)
- font = "tname"
- if wi > 230 then
- PlayerTeam = string.sub( team.GetName(LocalPlayer():Team()), 1, 21 ).."..."
- --font = "tname_s"
- -- else
- --font = "tname"
- end
- draw.SimpleText( PlayerTeam, font, offsetx+1, y+33+2, Color(222,222,222,150) )
- draw.SimpleText( PlayerTeam, font, offsetx, y+33, team.GetColor( LocalPlayer():Team() ) )
- -- Life
- local x2, y2 = x+105,y+120
- local w2, h2 = w-107,16
- local localplayer = LocalPlayer()
- Health = math.min(100, (Health == localplayer:Health() and Health) or Lerp(0.1, Health, localplayer:Health()))
- local DrawHealth = math.Min(Health / 50, 1)
- local Border = math.Min(6, math.pow(2, math.Round(3*DrawHealth)))
- draw.RoundedBox(4, x2-1, y2-1, w2 - 7, h2, Color(0,0,0,200))
- if LocalPlayer():Health() > 0 then
- draw.RoundedBox(4, x2, y2, (w2 - 9) * DrawHealth, h2-2, Color(255,40,40,180))
- end
- draw.DrawText(math.Max(0, math.Round(localplayer:Health())), "small", x2+w2/2, y2-2, Color(255,255,255,200), 1, TEXT_ALIGN_CENTER)
- draw.SimpleText("HP", "small2", x2-8, y2-2, Color(255,255,255,255), TEXT_ALIGN_RIGHT)
- -- Armor
- local x3, y3 = x2,y2+20
- local armor = LocalPlayer():Armor()
- draw.RoundedBox(4, x3-1, y3-1, w2 - 7, h2, Color(0,0,0,200))
- if armor > 0 then
- draw.RoundedBox(4, x3, y3, armor/100*(w2 - 9), 14, Color(40,40,255,255))
- end
- draw.SimpleText(armor, "small", x3+w2/2,y3-2, Color(255,255,255,200), TEXT_ALIGN_CENTER)
- draw.SimpleText("Armor", "small2", x3-8, y3-2, Color(255,255,255,255), TEXT_ALIGN_RIGHT)
- -- Raidstatus
- local box_r = 46
- draw.RoundedBox(4, w-box_r, y+4, box_r, box_r, col3)
- -- Get raidstatus
- -- Money
- surface.SetFont( "money" )
- --local PlayerMoney = formatNumber(LocalPlayer():GetTable().Money)
- local PlayerMoney = BW_Comma(LocalPlayer():GetTable().Money)
- local wl, hl = surface.GetTextSize(PlayerMoney)
- -- Draw Icon
- surface.SetDrawColor( 255, 255, 255, 255 )
- surface.SetMaterial( Material( "icon16/money.png" ) )
- surface.DrawTexturedRect( w-wl-36, y+60, 16, 16 )
- draw.SimpleText( PlayerMoney.." $", "money", w+1, y+56+2, Color( 0, 0, 0, 255 ), TEXT_ALIGN_RIGHT )
- draw.SimpleText( PlayerMoney.." $", "money", w, y+56, Color( 255, 255, 255, 255 ), TEXT_ALIGN_RIGHT )
- -- Exp bar
- --XP/Level
- local XPPos = x+105
- local XPPosy = y+91
- local XPwidth = w2-8
- local XPheight = 20
- -- Level box
- draw.RoundedBox(4, x + 56, XPPosy-1, XPheight*2, XPheight+2, Color(0,0,0,200))
- draw.SimpleText( localplayer.Level, "small2", x+77, XPPosy+1, Color( 220, 220, 220, 255 ), TEXT_ALIGN_CENTER )
- localplayer.Exp = localplayer.Exp or 1
- localplayer.Level = localplayer.Level or 1
- -- Calc Level and xp bar
- local XPmax
- --local function getExp(ply)
- for k,v in ipairs(xp["exp"]) do
- local diff = v/localplayer.Exp
- if diff >= 1 then
- --print(v)
- -- Set exp and level
- XPmax = tonumber(v)
- --localplayer.Level = k
- break
- end
- end
- --end
- local vars = (localplayer.Level or 1) -1
- if vars == 0 then vars = 1 end
- local lastep = xp["exp"][vars] or 0
- local diff = XPmax-lastep
- local XPprocent = (100*((localplayer.Exp-lastep)/diff))
- local XPbarwidth = XPprocent*((XPwidth)/100)
- draw.RoundedBox( 4, XPPos-1, XPPosy-1, XPwidth+2, XPheight+2, Color(0,0,0, 150))
- draw.RoundedBox( 4, XPPos, XPPosy, XPwidth, XPheight, Color(0,0,0, 150))
- draw.RoundedBox( 4, XPPos, XPPosy, XPbarwidth, XPheight, Color(0,200,0,255))
- if localplayer.Exp >= table.GetLastValue(xp["exp"]) then
- draw.DrawText("ULTIMATE-RAID-MASTER", "exp", XPPos+(XPwidth/2), XPPosy+1, col4,TEXT_ALIGN_CENTER)
- else
- draw.DrawText(" XP: "..localplayer.Exp.."/"..XPmax, "exp", XPPos+(XPwidth/2), XPPosy+2, col4,TEXT_ALIGN_CENTER)
- end
- --draw.RoundedBox(4, x + 110, XPPosy, w-200, 45, Color(0,0,0,200))
- -- Player Avatar
- local x,y = x +52, y+5
- local w,h = 58, 58
- draw.RoundedBox(4, x, y, 57, 57, Color(0,0,0,200))
- if !av then
- DrawPlayerAvatar0( x+5, y+5, w-11, w-11 )
- end
- surface.SetDrawColor( 200, 200, 200, 100 )
- surface.DrawLine( x+5, y+4, x+w-6, y+4 )
- surface.DrawLine( x+5, y+4, x+5, y+h-6 )
- local w = 200
- local h = 40
- local x = ScrW() - w - 5
- local y = ScrH() - h - 5
- -- This prevents client crash on death. LOL
- -- Dont draw weapon hud if the players wears no valid sweap
- if !LocalPlayer():GetActiveWeapon():IsValid() then return true end
- wep_name = LocalPlayer():GetActiveWeapon():GetPrintName() or LocalPlayer():GetActiveWeapon():GetClass()
- local mag_left = LocalPlayer():GetActiveWeapon():Clip1()
- local mag_extra = LocalPlayer():GetAmmoCount(LocalPlayer():GetActiveWeapon():GetPrimaryAmmoType())
- local secondary_ammo = LocalPlayer():GetAmmoCount(LocalPlayer():GetActiveWeapon():GetSecondaryAmmoType())
- local mag_all
- -- Weapon has no ammo
- if mag_left <= 0 && mag_extra <= 0 then
- -- Main box
- draw.RoundedBox( 4, x-1, y-1, w+2, h+2, Color(0,0,0,255) )
- draw.RoundedBox( 4, x, y, w, h, col1 )
- draw.RoundedBox( 4, x+15, y+8, w-30, h/2, col3 )
- draw.DrawText(wep_name, "ammo", x+w/2+1, y+10+2, Color(0, 0, 0, 255),TEXT_ALIGN_CENTER)
- draw.DrawText(wep_name, "ammo", x+w/2, y+10, Color(255, 255, 255, 255),TEXT_ALIGN_CENTER)
- -- Weapon has ammo
- else
- local x_ammo, y_ammo = x+10, y+5
- local w_ammo
- local h_ammo = 10
- if (LocalPlayer():GetActiveWeapon().Primary == nil || LocalPlayer():GetActiveWeapon().Primary.ClipSize == nil) then
- -- Fallback for other weapons
- w_ammo=180
- mag_left = LocalPlayer():GetActiveWeapon():GetClass()
- mag_all = LocalPlayer():GetActiveWeapon():Clip1()
- else
- -- M9K Weapons
- w_ammo=mag_left/LocalPlayer():GetActiveWeapon().Primary.ClipSize*180
- --mag_left = mag_left/LocalPlayer():GetActiveWeapon().Primary.ClipSize*180
- mag_all = LocalPlayer():GetActiveWeapon().Primary.ClipSize
- end
- -- Has secondary ammo?
- if secondary_ammo <= 0 then
- -- Only primary ammo
- -- Main box
- draw.RoundedBox( 4, x-1, y-1, w+2, h+2, Color(0,0,0,255) )
- draw.RoundedBox( 4, x, y, w, h, col1 )
- --draw.SimpleText("Mag: "..mag_left, "ammo", x_ammo+10, y_ammo, Color(0, 220, 0, 255), 0, 0)
- draw.SimpleText("Mag: "..mag_left.." / "..mag_all , "ammo", x_ammo+10, y_ammo, Color(0, 220, 0, 255), 0, 0)
- draw.SimpleText(mag_extra , "ammo", x_ammo+130, y_ammo, Color(0, 220, 0, 255), 0, 0)
- draw.RoundedBox(4, x_ammo, y_ammo+20, w_ammo, h_ammo, Color(0,180,0,255), 0, 0)
- draw.RoundedBox(4, x_ammo, y_ammo+20, w_ammo, h_ammo-6, Color(120,180,120,175), 0, 0)
- else
- -- Draw primary and secondary ammo
- end
- end
- end
- -- Raidtimer HUD
- function GM:DrawRaidtimer()
- -- check raidtimer table for running raids
- -- Draw timer hud for each raid running
- local w = ScrW() / 12
- local h = ScrW() / 22
- local x = 5
- local y = ScrH() - h*22 + 5
- local w_bar = ScrW() / 8
- local h_bar = ScrW() / 80
- local x_bar = x + w + 5
- local bar_spacing = ScrW() / 300
- surface.SetDrawColor( BasewarsBackgroundColor )
- surface.DrawRect( x, y, w, h )
- surface.SetDrawColor( BasewarsBorderColor )
- surface.DrawOutlinedRect( x, y, w, h )
- -- Raidtimer
- local raidColor = BasewarsTextColor
- -- get data from tables...
- local attacker = test1
- local defender = test2
- draw.SimpleTextOutlined( tostring( LocalPlayer():Health() ), "DefaultHealth", x + w / 2, y + h / 2, hpColor, 1, 1, 0.5, BasewarsBorderColor )
- end
- function TestDrawHud()
- local struc = {}
- struc.pos = {}
- --struc.pos[1] = ScrW()*.5 -- x pos
- struc.pos[1] = 580 -- x pos
- --struc.pos[2] = ScrH()*.005 -- y pos
- struc.pos[2] = ScrH()-10 -- y pos
- struc.color = Color(0,0,0,255)
- struc.text = "--- Baswars PreAlpha "..GAMEMODE.Version.." for GMOD13 by .delay ---"
- struc.font = "DefaultFixed" -- Font
- struc.xalign = TEXT_ALIGN_CENTER -- Horizontal Alignment
- struc.yalign = TEXT_ALIGN_LEFT -- Vertical Alignment
- draw.Text( struc )
- end
- hook.Add("HUDPaint", "HUD_TEST", TestDrawHud)
- -- Door HUD
- function BW_DoorHUD()
- --local ply = LocalPlayer()
- --local entity = ply:GetEyeTrace().Entity
- --if entity:IsValid() and door_classes[entity:GetClass()] then
- --for k,v in pairs(ents.GetAll()) do
- --for k,v in pairs(ents.FindByClass("prop_door_rotating")) do
- for k,v in pairs(ents.FindInSphere(LocalPlayer():GetPos(),550)) do
- if v:GetClass() == "prop_door_rotating" then
- --local distance = entity:LocalToWorld( entity:OBBCenter() ):Distance( LocalPlayer():EyePos() )
- --if (distance <= 500) then
- if LocalPlayer():GetPos():Distance(v:GetPos()) < 550 then
- if v.Owner == "nil" then continue end
- local function doorstuff(pos,ang)
- cam.Start3D2D(pos, ang, 0.1)
- draw.RoundedBox( 10, 5, 5, 450, 50, Color(255,255,255, 30) )
- local owner
- local teamid
- local tname
- local tcol = Color(0, 0, 0, 180)
- -- Door Owner is player?
- if v.Owner:IsPlayer() then
- owner = v.Owner:Nick()
- teamid = v.Owner:Team()
- tname = team.GetName(teamid)
- tname = BW_StrUp(tname)
- -- Is in basic team?
- if teamid > 0 then
- local col = team.GetColor(teamid)
- tcol = Color(col.r, col.g, col.b, 100)
- draw.RoundedBox( 10, 0, 0, 460, 60, tcol )
- draw.SimpleText(tname, "font_17", 230, 20, Color(255, 255, 255, 180), 1, 1)
- draw.SimpleText(tname, "font_17", 229, 19, Color(0, 0, 0, 255), 1, 1)
- else
- draw.SimpleText("Door owner:", "font_20", 230, 20, Color(0, 0, 0, 180), 1, 1)
- draw.SimpleText("Door owner:", "font_20", 229, 18, Color(255, 255, 255, 255), 1, 1)
- end
- draw.SimpleText(owner, "font_17", 230, 40, Color(0, 0, 0, 180), 1, 1)
- draw.SimpleText(owner, "font_17", 229, 38, Color(255, 255, 255, 255), 1, 1)
- -- Door is free to buy
- else
- -- only draw valid/spawned doors
- owner = "Door"
- draw.SimpleText("Free Door", "font_20", 230, 30, Color(0, 0, 0, 180), 1, 1)
- draw.SimpleText("Free Door", "font_20", 229, 28, Color(255, 255, 255, 255), 1, 1)
- end
- cam.End3D2D()
- end
- local angles = v:GetAngles()
- local position = v:GetPos()
- local offset = angles:Up()*-7.3 + angles:Forward() * -1.2 + angles:Right() * - 46
- local offset2 = angles:Up()*-7.3 + angles:Forward() * 1.2 + angles:Right() * - 0
- -- One Side
- angles:RotateAroundAxis(angles:Forward(), 90)
- angles:RotateAroundAxis(angles:Right(), 90)
- angles:RotateAroundAxis(angles:Up(), 0)
- doorstuff(position + offset, angles)
- --cam.Start3D2D(position + offset, angles, 0.1)
- -- draw.SimpleText("Door", "font_11", 80.5, 46, Color(255, 255, 255, 255), 1, 1)
- -- draw.SimpleText("Door", "font_11", 80.5, 46, Color(255, 255, 255, 255), 1, 1)
- --cam.End3D2D()
- -- The other side
- angles:RotateAroundAxis(angles:Forward(), 0)
- angles:RotateAroundAxis(angles:Right(), 180)
- angles:RotateAroundAxis(angles:Up(), 0)
- doorstuff(position + offset2, angles)
- end
- end
- end
- end
- -- Test a few hooks for performance
- hook.Add("PostDrawOpaqueRenderables", "cam_door_test", BW_DoorHUD)
- --hook.Add("RenderScreenspaceEffects", "cam_door_test", BW_DoorHUD)
- --hook.Add( "PreDrawHalos", "AddHalos", function()
- -- halo.Add( ents.FindByClass( "prop_door_rotating" ), Color( 255, 0, 0 ), 5, 5, 2 )
- --end )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement