Benny/gamemodes/benny/gamemode/hud.lua

933 lines
26 KiB
Lua

---------------------
-- Your Name is Benny
---------------------
-- Stack related
function xy( x, y )
return {x, y}
end
function hXY( x, y )
local rx, ry = 0, 0
for key, value in ipairs(stack) do
rx = rx + value[1]
ry = ry + value[2]
end
if x then rx = rx + x end
if y then ry = ry + y end
return rx, ry
end
function S_Push( x, y )
stack:Push( xy( x, y ) )
end
function S_Pop( x, y )
stack:Pop()
end
function hCol( r, g, b, a )
if IsColor(r) and g then
return surface.SetDrawColor( ColorAlpha( r, g ) )
end
return surface.SetDrawColor( r, g, b, a )
end
function hRect( x, y, w, h )
gx, gy = hXY()
x = (x or 0) + gx
y = (y or 0) + gy
surface.DrawRect( x, y, w, h )
end
function hRRect( x, y, w, h, r )
gx, gy = hXY()
x = (x or 0) + gx
y = (y or 0) + gy
draw.RoundedBox( r, x, y, w, h, surface.GetDrawColor() )
end
function hTRect( x, y, w, h )
gx, gy = hXY()
x = (x or 0) + gx
y = (y or 0) + gy
surface.DrawTexturedRect( x, y, w, h )
end
function hTrRect( x, y, w, h, d )
gx, gy = hXY()
x = (x or 0) + gx
y = (y or 0) + gy
surface.DrawTexturedRectRotated( x, y, w, h, d )
end
function hORect( x, y, w, h, r )
gx, gy = hXY()
x = (x or 0) + gx
y = (y or 0) + gy
surface.DrawOutlinedRect( x, y, w, h, r )
end
function hScis( x, y, w, h )
gx, gy = hXY()
x = (x or 0) + gx
y = (y or 0) + gy
render.SetScissorRect( x, y, x+w, y+h, true )
end
function hScisoff()
render.SetScissorRect( 0, 0, 0, 0, false )
end
function qt( text, font, x, y, col, xalign, yalign, col2 )
draw.SimpleText( text, font, x-1, y-1, col2, xalign, yalign )
draw.SimpleText( text, font, x, y-1, col2, xalign, yalign )
draw.SimpleText( text, font, x+1, y-1, col2, xalign, yalign )
draw.SimpleText( text, font, x-1, y, col2, xalign, yalign )
draw.SimpleText( text, font, x+1, y, col2, xalign, yalign )
draw.SimpleText( text, font, x-1, y+1, col2, xalign, yalign )
draw.SimpleText( text, font, x, y+1, col2, xalign, yalign )
draw.SimpleText( text, font, x+1, y+1, col2, xalign, yalign )
draw.SimpleText( text, font, x, y, col, xalign, yalign )
end
function hText( text, font, x, y, col, xalign, yalign )
local x, y = hXY( x, y )
draw.SimpleText( text, font, x, y, col, xalign, yalign )
end
function hTextQ( text, font, x, y, col, xalign, yalign, col2 )
local x, y = hXY( x, y )
qt( text, font, x, y, col, xalign, yalign, col2 )
end
function hTextS( text, font, x, y, col, xalign, yalign, col2 )
local x, y = hXY( x, y )
draw.SimpleText( text, font, x+1, y+1, col2, xalign, yalign )
draw.SimpleText( text, font, x, y, col, xalign, yalign )
end
local sizes = {
8, 10, 16, 24, 36, 48
}
local function regenfonts()
for index, scale in ipairs( sizes ) do
surface.CreateFont("HUD_" .. scale, {
font = "Carbon Plus Bold",
size = scale,
weight = 0,
extended = false,
italic = false,
antialias = true,
})
end
end
regenfonts()
FACTIONS = {
["benny"] = {
COLOR_MAIN = Color( 255, 238, 169 ),
COLOR_DARK = Color( 54, 44, 39 ),
CHARNAME = "BENNY",
},
["nikki"] = {
COLOR_MAIN = Color( 255, 174, 210 ),
COLOR_DARK = Color(37, 12, 40 ),
CHARNAME = "NIKKI",
},
["igor"] = {
COLOR_MAIN = Color( 253, 208, 207 ),
COLOR_DARK = Color( 32, 14, 12 ),
CHARNAME = "IGOR",
},
["yanghao"] = {
COLOR_MAIN = Color( 157, 187, 253 ),
COLOR_DARK = Color( 19, 21, 28 ),
CHARNAME = "YANG-HAO",
},
-- MP
["mp_cia"] = {
COLOR_MAIN = Color( 255, 255, 255),
COLOR_DARK = Color( 25, 23, 47 ),
CHARNAME = "CIA",
},
["mp_halo"] = {
COLOR_MAIN = Color( 130, 255, 255 ),
COLOR_DARK = Color( 40, 40, 58 ),
CHARNAME = "HALO",
},
["mp_plasof"] = {
COLOR_MAIN = Color( 255, 153, 153 ),
COLOR_DARK = Color( 45, 10, 10 ),
CHARNAME = "PLASOF",
},
["mp_arng"] = {
COLOR_MAIN = Color( 198, 255, 192 ),
COLOR_DARK = Color( 23, 32, 23 ),
CHARNAME = "NATGUARD",
},
["mp_militia"] = {
COLOR_MAIN = Color( 255, 219, 153 ),
COLOR_DARK = Color( 33, 18, 18 ),
CHARNAME = "MILITIA",
},
["mp_viper"] = {
COLOR_MAIN = Color( 248, 191, 225 ),
COLOR_DARK = Color( 50, 20, 50 ),
CHARNAME = "VIPER",
},
["unassigned"] = {
COLOR_MAIN = Color( 220, 220, 220 ),
COLOR_DARK = Color( 40, 40, 40),
CHARNAME = "Unassigned...",
},
}
local CURRCHAR = "mp_arng"
local COLOR_MAIN = FACTIONS[CURRCHAR].COLOR_MAIN
local COLOR_DARK = FACTIONS[CURRCHAR].COLOR_DARK
local CHARNAME = FACTIONS[CURRCHAR].CHARNAME
local COLOR_BRIGHT = Color( 94, 94, 94 )
local alphabet = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"}
local xhair_dot = Material( "benny/hud/xhair/dotx.png", "mips smooth" )
local xhair_dot_shadow = Material( "benny/hud/xhair/dot_s.png", "mips smooth" )
local fmlookup = {
[1] = "SEMI",
[math.huge] = "AUTO",
}
local function QuickDrawBar( BARWIDE, BARTALL, RealTeamID, TeamID, way )
local faction_info = FACTIONS[ TEAMS[RealTeamID].factionid ]
hCol( faction_info.COLOR_DARK )
hRect( 0, 0, BARWIDE, BARTALL )
hCol( faction_info.COLOR_MAIN )
hORect( 1, 1, BARWIDE-2, BARTALL-2, 1 )
local count = 6
local Score_Current = BennyGame:GetScoreForTeam( RealTeamID )
local Score_ToWin = BennyGame:GetScoreLimit()
local perc = Score_Current/Score_ToWin
local width = math.ceil( (BARWIDE-6)*perc )
if way then
hRect( BARWIDE - 3 - width, 3, width, BARTALL-6 )
else
hRect( 3, 3, width, BARTALL-6 )
end
for i=1, count-1 do
local bleh
if way then
bleh = (i/count)<(1-perc)
else
bleh = (i/count)>perc
end
hCol( bleh and faction_info.COLOR_MAIN or faction_info.COLOR_DARK )
hRect( 3 + (BARWIDE-7)*(i/count), 4, 1, BARTALL-8 )
end
if way then
hTextQ( faction_info.CHARNAME, "HUD_36", BARWIDE - 5, 0, faction_info.COLOR_DARK, TEXT_ALIGN_RIGHT, nil, faction_info.COLOR_MAIN )
hTextQ( Score_Current .. " / " .. Score_ToWin, "HUD_24", BARWIDE, BARTALL, faction_info.COLOR_MAIN, TEXT_ALIGN_RIGHT, nil, faction_info.COLOR_DARK )
else
hTextQ( faction_info.CHARNAME, "HUD_36", 5, 0, faction_info.COLOR_DARK, nil, nil, faction_info.COLOR_MAIN )
hTextQ( Score_Current .. " / " .. Score_ToWin, "HUD_24", 0, BARTALL, faction_info.COLOR_MAIN, nil, nil, faction_info.COLOR_DARK )
end
-- Players alive
if false then
for i=1, 6 do
local o = i-1
local lol = i>=3
if way then
S_Push( BARWIDE - i*(16+2), BARTALL + 2 )
else
S_Push( o*(16+2), BARTALL + 2 )
end
hCol( lol and faction_info.COLOR_DARK or faction_info.COLOR_MAIN )
hRect( 0, 0, 16, 16 )
hCol( lol and faction_info.COLOR_MAIN or faction_info.COLOR_DARK )
hORect( 1, 1, 16-2, 16-2, 1 )
S_Pop()
end
end
end
-- Drawing
function GM:HUDPaint()
local p = LocalPlayer()
local w, h = ScrW(), ScrH()
local handler = p:HandlerCheck()
stack = util.Stack()
local myteam = p:Team()
local CURRCHAR
if BennyGame:GetType() == BG_GTYPE_CAMPAIGN then
CURRCHAR = "benny"
else
CURRCHAR = TEAMS[myteam].factionid
end
local COLOR_MAIN = FACTIONS[CURRCHAR].COLOR_MAIN
local COLOR_DARK = FACTIONS[CURRCHAR].COLOR_DARK
local CHARNAME = FACTIONS[CURRCHAR].CHARNAME
local MP = BennyGame:GetType() == BG_GTYPE_MP
-- S_Push( math.random( -4, 4 ), math.random( -4, 4 ) )
S_Push( 20, h - 20 - 65 )
hCol( COLOR_DARK )
hRect( 0, 0, 328, 65 )
hTextQ( CHARNAME, "HUD_48", 10, 4, COLOR_DARK, nil, nil, COLOR_MAIN )
local HEALTHPER = p:GetHealth_Blood()/1000
--HEALTHPER = 11/100
hCol( COLOR_MAIN )
hRect( 8, 8, (320-4-4) * HEALTHPER, 41-4-4 )
hORect( 8, 8, (320-4-4), 41-4-4, 1 )
hCol( COLOR_DARK )
hORect( 8+1, 8+1, (320-4-4)-2, 41-4-4-2, 1 )
hCol( COLOR_MAIN )
hScis( 8, 8, (320-4-4) * HEALTHPER, 41-4-4 )
hText( CHARNAME, "HUD_48", 10, 4, COLOR_DARK )
hScisoff()
local slen = (320-4-4-4-4-4)
hCol( COLOR_MAIN )
hRect( 8, 45, slen*0.25, 12 )
hRect( 8 + (slen*0.25+4), 45, slen*0.25, 12 )
hRect( 8 + (slen*0.25+4)*2, 45, slen*0.25, 12 )
hRect( 8 + (slen*0.25+4)*3, 45, slen*0.25, 12 )
hCol( COLOR_DARK )
hORect( 8+1, 45+1, slen*0.25 - 2, 12-2, 1 )
hORect( 8+1 + (slen*0.25+4), 45+1, slen*0.25 - 2, 12-2, 1 )
hORect( 8+1 + (slen*0.25+4)*2, 45+1, slen*0.25 - 2, 12-2, 1 )
hORect( 8+1 + (slen*0.25+4)*3, 45+1, slen*0.25 - 2, 12-2, 1 )
if MP then -- MP
S_Push( 0, -8 - 2 )
local targetlength = 328
local segments = 10
local gap = 2
targetlength = targetlength - gap*(segments-1)
local chunk = 1/segments
for i=1, segments do
local z = i-1
local chunk0, chunk1 = chunk*z, chunk*i
local filled = math.Remap( p:GetLevel_XP()/15000, chunk0, chunk1, 0, 1 )
filled = math.Clamp( filled, 0, 1 )
local a1, a2, a3, a4 = ( (targetlength/segments) * z ) + (gap*z), 0, (targetlength/segments), 8
if i == segments then a3 = math.ceil(a3) end
if filled == 1 then
hCol( COLOR_MAIN )
hRect( a1, a2, a3, a4 )
hCol( COLOR_DARK )
hORect( a1, a2, a3, a4, 1 )
elseif filled == 0 then
hCol( COLOR_DARK )
hRect( a1, a2, a3, a4 )
else
hCol( COLOR_DARK )
hRect( a1, a2, a3, a4 )
hCol( COLOR_MAIN )
hRect( a1, a2, a3*filled, a4 )
hCol( COLOR_DARK )
hORect( a1, a2, a3, a4, 1 )
end
end
hTextQ( p:GetLevel_XP() .. " / 15000", "HUD_16", 0, -14, COLOR_MAIN, nil, nil, COLOR_DARK )
S_Pop()
end
S_Pop()
if handler then
-- Inventory
local Pw, Ph, Pg = 110, 30, 10
local thespace = 0
for i, v in ipairs( p:GetInventory():GetWeighted() ) do
thespace = thespace + Pw + Pg
end
thespace = thespace - Pg
thespace = thespace/2
S_Push( ScrW()/2 - thespace, ScrH() - 20 - Ph )
for i, v in ipairs( p:GetInventory():GetWeighted() ) do
hCol( v == handler:GetDesireR() and COLOR_BRIGHT or COLOR_DARK )
hRect( (i-1)*(Pw+Pg), 0, Pw, Ph )
if v == handler:GetActiveR() then
hCol( COLOR_MAIN )
hORect( (i-1)*(Pw+Pg)+1, 1, Pw-2, Ph-2, 1 )
end
local x, y = (i-1)*(Pw+Pg), 0
hText( l8( v.Class.PrintName ), "HUD_24", x + Pw/2, y + 5, COLOR_MAIN, TEXT_ALIGN_CENTER )
hText( i, "HUD_16", x + 4, y + 2, COLOR_MAIN )
end
S_Pop()
local wep = handler:GetDesireR()
if wep and wep.GetClip then
local Bw, Bh = 8+(8+2)*30-2+8, 160
S_Push( w - 20 - Bw, h - 20 - Bh )
hCol( COLOR_DARK )
hRect( 0, 0, Bw, Bh )
S_Push( 0, 0 )
hCol( COLOR_MAIN )
local leng = Bw-8-8
hRect( 8, 8, leng-70, 26 )
hRect( 8 + leng - 70 + 4, 8, leng-(leng-70)-4, 26 )
hText( l8( wep.Class.PrintName ), "HUD_36", 12, 6, COLOR_DARK )
local bc = wep.Class.BurstCount
hText( fmlookup[bc] or bc .. "RND", "HUD_24", 10 + (leng - 70) + 70/2, 11, COLOR_DARK, TEXT_ALIGN_CENTER )
S_Pop()
local Tw, Th = 6, 18
if wep.Class.ClipSize>45 then
Tw = 3
Th = 13
elseif wep.Class.ClipSize<14 then
Tw = 8
Th = 22
end
S_Push( Bw - Tw - 8, Bh - Th - 8 )
for i=0, wep.Class.ClipSize-1 do
if i>29 then
hCol( COLOR_DARK )
hRect( (0 - Tw - 2)*i-4, -4, Tw+2, Th+8 )
end
end
for i=0, wep.Class.ClipSize-1 do
if wep:GetClip() >= (i+1) then
hCol( COLOR_MAIN )
hRect( (0 - Tw - 2)*i, 0, Tw, Th )
hCol( COLOR_DARK )
hRect( (0 - Tw - 2)*i, Th-4, Tw, 2 )
else
hCol( COLOR_BRIGHT )
hORect( (0 - Tw - 2)*i, 0, Tw, Th )
--hORect( (0 - 8 - 2)*i+1, 1, 8-2, 18-2 )
end
end
S_Pop()
S_Pop()
end
end
if MP then S_Push( w/2, 20 )
local BARWIDE, BARTALL, GAP = 240, 30, 100
-- Score
local count = 1
if BennyGame.RTeamID[myteam] then -- My team
local o = count-1
S_Push( count%2==1 and (-BARWIDE - 1 - GAP) or (0 + 1 + GAP), (BARTALL+2+16+2)*math.floor(o/2) )
QuickDrawBar( BARWIDE, BARTALL, myteam, BennyGame.RTeamID[myteam], count%2==0 )
S_Pop()
count = count + 1
end
-- Every other team
for TeamID, RealTeamID in ipairs( BennyGame.TeamsInPlay ) do
if RealTeamID == myteam then continue end
local o = count-1
S_Push( count%2==1 and (-BARWIDE - 1 - GAP) or (0 + 1 + GAP), (BARTALL+2+16+2)*math.floor(o/2) )
QuickDrawBar( BARWIDE, BARTALL, RealTeamID, TeamID, count%2==0 )
S_Pop()
count = count + 1
end
-- Timer
local DISPLAYWIDE, DISPLAYTALL = 150, 48
S_Push( -DISPLAYWIDE/2, 0 )
hCol( COLOR_DARK )
hRect( 0, 0, DISPLAYWIDE, DISPLAYTALL )
hCol( COLOR_MAIN )
hORect( 2, 2, DISPLAYWIDE-4, DISPLAYTALL-4, 1 )
local stupidtime = CurTime()
if BennyGame:GetState() == BG_STATE_ACTIVE then
stupidtime = BennyGame:GetRoundStartedAt() + BennyGame:GetTimeLimit() - CurTime()
elseif BennyGame:GetState() == BG_STATE_PRE then
stupidtime = BennyGame:GetPregameStartedAt() + BennyGame:GetPregameTime() - CurTime()
elseif BennyGame:GetState() == BG_STATE_POST then
stupidtime = BennyGame:GetRoundFinishedAt() + BennyGame:GetPostgameTime() - CurTime()
end
if BennyGame:GetState() != BG_STATE_WAITINGFORPLAYERS then
local d1, d2
local tt = string.FormattedTime( math.max( stupidtime, 0 ) )
if tt.h > 0 then
d1 = string.format( "%01i:%02i:%02i", tt.h, tt.m, tt.s )
elseif tt.m > 0 then
d1 = string.format( "%01i:%02i", tt.m, tt.s )
else
d1 = string.format( "%02i", tt.s )
d2 = string.format( ".%02i", tt.ms )
end
surface.SetFont("HUD_48")
local twid = surface.GetTextSize(d1)
if d2 then
surface.SetFont("HUD_36")
twid = twid + surface.GetTextSize(".00")
end
hText( d1, "HUD_48", DISPLAYWIDE/2 + 0 - twid/2, 4, COLOR_MAIN )
local twid2 = surface.GetTextSize(d1)
if d2 then
hText( d2, "HUD_36", DISPLAYWIDE/2 + twid2 - twid/2, 11, COLOR_MAIN )
end
end
local TITLE
if BennyGame:GetState() == BG_STATE_PRE then
TITLE = "PREGAME"
elseif BennyGame:GetState() == BG_STATE_POST then
TITLE = "POSTGAME"
elseif BennyGame:GetState() == BG_STATE_WAITINGFORPLAYERS then
TITLE = "WAITING FOR PLAYERS"
end
if TITLE then
hTextS( TITLE, "HUD_24", DISPLAYWIDE/2, -18, COLOR_MAIN, TEXT_ALIGN_CENTER, nil, COLOR_DARK )
end
if false then
local myteamwins = 2
local enemywins = 3
local count = 7
-- Round counter
local wideness = (20+2)*count-2
for i=1, count do
local o = i-1
S_Push( DISPLAYWIDE/2 - wideness/2 + o*(20+2), DISPLAYTALL+4 )
local COLOR_DARK = COLOR_DARK
local COLOR_MAIN = COLOR_MAIN
local filled = false
if i<=myteamwins then
filled = true
elseif (count-o)<=enemywins then
COLOR_DARK = E_COLOR_DARK
COLOR_MAIN = E_COLOR_MAIN
filled = true
else
COLOR_DARK = Color( 040, 040, 040 )
COLOR_MAIN = Color( 080, 080, 080 )
filled = true
end
hCol( filled and COLOR_MAIN or COLOR_DARK )
hRect( 0, 0, 20, 8 )
hCol( filled and COLOR_DARK or COLOR_MAIN )
hORect( 1, 1, 20-2, 8-2, 1 )
S_Pop()
end
end
-- Domination flag status
if true then
local AllFlags = ents.FindByClass("benny_domflag")
S_Push( 0, 0 )
local count = #AllFlags
local wideness = (48+2)*count-2
for i, ent in ipairs( AllFlags ) do--for i=1, count do
local o = i-1
local faction_name = TEAMS[ent:GetTeamOwned()].factionid
local faction_info = FACTIONS[faction_name]
local taking_faction_name = TEAMS[ent:GetTeamTaking()].factionid
local taking_faction_info = FACTIONS[taking_faction_name]
local capturepercent = ent:GetCapturePercent()--math.Remap( CurTime()%4, 0, 3, 0, 1 )
--capturepercent = math.Clamp(capturepercent, 0, 1)
local mine, enemy = false, true
--if i==3 then mine = !mine enemy = !enemy end
if (capturepercent>=1) then
mine = !mine
enemy = !enemy
end
S_Push( DISPLAYWIDE/2 - wideness/2 + o*(48+2), DISPLAYTALL+4 )
hCol( faction_info.COLOR_DARK )
hRect( 0, 0, 48, 48 )
hCol( faction_info.COLOR_MAIN )
hRect( 1, 1, 48-2, 48-2, 1 )
if capturepercent<1 then
hCol( taking_faction_info.COLOR_MAIN )
hORect( 1, 1, 48-2, 48-2, math.floor(23 * capturepercent) )
end
hTextQ( alphabet[i] or i, "HUD_36", 48/2, 9, faction_info.COLOR_MAIN, TEXT_ALIGN_CENTER, nil, faction_info.COLOR_DARK )
S_Pop()
end
S_Pop()
end
S_Pop()
do
local AllFlags = ents.FindByClass("benny_domflag")
local AllFlagFlip = table.Flip(AllFlags)
-- Current Objective
local obj = p:GetTouchedObjective()
if obj:IsValid() then
S_Push( 0, 200 )
local TITLE = "CAPTURING"
local PERCENT = obj:GetCapturePercent()
if obj:GetContested() then
TITLE = "CONTESTED"
elseif obj:GetTeamOwned() == myteam then
if obj:GetCapturePercent() > 0 then
TITLE = "CLEARING"
else
TITLE = "SECURE"
PERCENT = 1
end
elseif obj:GetTeamOwned() == 0 and obj:GetTeamTaking() != myteam then
TITLE = "CLEARING"
end
local BARCOLOR = FACTIONS[ TEAMS[obj:GetTeamOwned()].factionid ]
local TAKCOLOR = FACTIONS[ TEAMS[obj:GetTeamTaking()].factionid ]
local CONTOLER = FACTIONS[ "unassigned" ]
BARCOLOR_MAIN = BARCOLOR.COLOR_MAIN
BARCOLOR_DARK = BARCOLOR.COLOR_DARK
TAKCOLOR_MAIN = TAKCOLOR.COLOR_MAIN
TAKCOLOR_DARK = TAKCOLOR.COLOR_DARK
CONTOLER_MAIN = CONTOLER.COLOR_MAIN
CONTOLER_DARK = CONTOLER.COLOR_DARK
local BWIDE, BTALL = 180, 16
hCol( BARCOLOR_DARK )
hRect( -80, 0, 160, 38 )
hCol( BARCOLOR_DARK )
hRect( -100, 35, 200, 76 )
hCol( BARCOLOR_MAIN )
hORect( -100+1, 35+1, 200-2, 76-2 )
hCol( BARCOLOR_MAIN )
hORect( -80+1, 1, 160-2, 38-2, 1 )
hTextQ( "POINT " .. (alphabet[ AllFlagFlip[obj] ] or AllFlagFlip[obj]), "HUD_36", 0, 4, BARCOLOR_MAIN, TEXT_ALIGN_CENTER, nil, BARCOLOR_DARK )
hTextQ( TITLE, "HUD_24", 0, TITLE=="SECURE" and 62 or 40, obj:GetContested() and CONTOLER_MAIN or COLOR_MAIN, TEXT_ALIGN_CENTER, nil, COLOR_DARK )
if TITLE!="SECURE" then
S_Push( -BWIDE/2, 62 )
hCol( TAKCOLOR_DARK )
hRect( 0, 0, 180, BTALL )
hCol( TAKCOLOR_MAIN )
hORect( 1, 1, 180-2, BTALL-2 )
hCol( TAKCOLOR_MAIN )
hRect( 3, 3, math.floor((BWIDE-6) * PERCENT), BTALL-6 )
S_Pop()
hTextQ( math.floor(PERCENT*100) .. "%", "HUD_36", 0, 78, obj:GetContested() and CONTOLER_MAIN or COLOR_MAIN, TEXT_ALIGN_CENTER, nil, obj:GetContested() and CONTOLER_DARK or COLOR_DARK )
end
S_Pop()
end
end
S_Pop() end
--local itemcheck = handler:ItemCheckTrace()
-- Hints
if true then
S_Push( w - 20, 20 )
local hints = {}
table.insert( hints, { "[SHIFT]", "DIVE" } )
table.insert( hints, { "", "INTO PRONE", "HOLD" } )
if handler:ItemR() then
table.insert( hints, { "", "- - - - - - - - - - - -" } )
table.insert( hints, { "[M1]", "FIRE" } )
table.insert( hints, { "[C]", "FIREMODE" } )
table.insert( hints, { "[E]", "THROW" } )
table.insert( hints, { "[R]", "RELOAD" } )
table.insert( hints, { "", "RETAIN MAG", "HOLD" } )
--elseif itemcheck.Entity:IsValid() and itemcheck.Entity.BennyItem then
-- table.insert( hints, { "", "- - - - - - - - - - - -" } )
-- table.insert( hints, { "[E]", "PICK UP" } )
end
for i, v in ipairs( hints ) do
hTextS( v[1], "HUD_24", -150, (24*(i-1)), COLOR_MAIN, TEXT_ALIGN_CENTER, nil, COLOR_DARK )
hTextS( v[2], "HUD_24", 0, (24*(i-1)), COLOR_MAIN, TEXT_ALIGN_RIGHT, nil, COLOR_DARK )
if v[3] then
hTextS( v[3], "HUD_16", -150, 3 + (24*(i-1)), COLOR_MAIN, TEXT_ALIGN_CENTER, nil, COLOR_DARK )
end
end
S_Pop()
end
-- S_Pop()
--local trac = p:GetEyeTrace().HitPos:ToScreen()
local trac = util.TraceLine( {
start = p:GetPos() + Vector( 0, 0, 52 ),
endpos = p:GetPos() + Vector( 0, 0, 52 ) + p:EyeAngles():Forward()*(2^31),
filter = p,
} ).HitPos
local trac2 = util.TraceLine( {
start = CamSpot(),
endpos = CamSpot() + TPSOverride:Forward()*(2^31),
filter = p,
} ).HitPos
local tol = false
if trac:IsEqualTol( trac2, 2 ) then -- within two inches
trac2 = trac2:ToScreen()
trac = trac2
tol = true
else
trac = trac:ToScreen()
trac2 = trac2:ToScreen()
end
for i=1, 2 do
local shadowtime = i==1
local traac = shadowtime and trac2 or trac
local cx, cy = math.Round(traac.x), math.Round(traac.y)
local gap = 4
local length = 4
S_Push( cx, cy )
local lol = shadowtime and 0 or 255
local lol2 = shadowtime and 127 or 255
local Shadow_Gap = shadowtime and 1 or 0
local Shadow_Thickness = shadowtime and 2 or 0
surface.SetDrawColor( lol, lol, lol, lol2 )
--surface.SetMaterial( shadowtime and xhair_dot_shadow or xhair_dot )
hRect( -1 - Shadow_Gap, gap - Shadow_Gap, 2 + Shadow_Thickness, length + Shadow_Thickness )
hRect( gap - Shadow_Gap, -1 - Shadow_Gap, length + Shadow_Thickness, 2 + Shadow_Thickness )
-- top and left
hRect( -1 - Shadow_Gap, -length - gap - Shadow_Gap, 2 + Shadow_Thickness, length + Shadow_Thickness )
hRect( -length - gap - Shadow_Gap, -1 - Shadow_Gap, length + Shadow_Thickness, 2 + Shadow_Thickness )
if !shadowtime and !tol then
surface.SetDrawColor( 255, 0, 0 )
hRect( -1, -1, 2, 2 )
end
S_Pop()
end
if stack:Size() != 0 then print("Stack unfinished.") end
return
end
-- Not drawing
local hide = {
["CHudHealth"] = true,
["CHudBattery"] = true,
["CHudAmmo"] = true,
["CHudSecondaryAmmo"] = true,
["CHudDamageIndicator"] = true,
["CHudCloseCaption"] = true,
["CHudCrosshair"] = true,
["CHudSuitPower"] = true,
["CHUDQuickInfo"] = true,
["CHudZoom"] = true,
}
function GM:HUDShouldDraw( name )
if hide[ name ] then
return false
else
return true
end
end
--local players = {
-- { name = "Jim", Team = "mp_arng" },
-- { name = "Sas", Team = "mp_arng" },
-- { name = "Greg", Team = "mp_arng" },
-- { name = "Nate", Team = "mp_arng" },
--
-- { name = "Ion", Team = "mp_plasof" },
-- { name = "Beo", Team = "mp_plasof" },
-- { name = "Poe", Team = "mp_plasof" },
-- { name = "Zio", Team = "mp_plasof" },
--}
local things = {
{ name = "Score", size = 100,
get = function( ply )
return 0
end,},
{ name = "Kills", size = 50,
get = function( ply )
return ply:Frags()
end,},
{ name = "Deaths", size = 50,
get = function( ply )
return ply:Deaths()
end,},
{ name = "Time", size = 50,
get = function( ply )
return ":00"
end,},
{ name = "Ping", size = 50,
get = function( ply )
return ply:Ping()
end,} -- Ping
}
local function QuickDrawStat( wide, data, first )
local gap = 0
local teamd = TEAMS[data.id]
local faction = FACTIONS[teamd.factionid]
local TeamName = l8( teamd.name )
hTextQ( TeamName, "HUD_36", 0, 0, faction.COLOR_MAIN, nil, nil, faction.COLOR_DARK )
gap = gap + 30
hCol( faction.COLOR_DARK )
hRect( -5+1, gap+1, wide+10, 2 )
hCol( faction.COLOR_MAIN )
hRect( -5, gap, wide+10, 2 )
gap = gap + 6
local blep = wide
for i, v in ipairs(things) do blep = blep - v.size end
if first then
local bloop = 0
for i, v in ipairs(things) do
hCol( 127, 127, 127, 80 )
local x, y = blep+bloop, 12
if v.name then
hTextS( v.name, "HUD_16", x+(v.size/2), y, color_white, TEXT_ALIGN_CENTER, nil, color_black )
end
bloop = bloop + v.size
end
end
for i, ply in ipairs( data.players ) do
local bloop = 0
hCol( faction.COLOR_MAIN, 30 )
hRect( 0, gap, wide, 30 )
hCol( faction.COLOR_DARK )
hORect( 3, gap+3, wide-4, 30-4, 1 )
hCol( faction.COLOR_MAIN )
hORect( 2, gap+2, wide-4, 30-4, 1 )
hTextQ( ply:GetLevel(), "HUD_16", 18, gap+8, Color( 255, 255, 0 ), TEXT_ALIGN_CENTER, nil, color_black )
hTextQ( ply:Nick(), "HUD_24", 32, gap+5, color_white, nil, nil, color_black )
local bloop = 0
for i, v in ipairs(things) do
hCol( 255, 0, 0 )
local x, y = blep+bloop, gap+8
hTextS( v.get( ply ), "HUD_16", x+(v.size/2), y, color_white, TEXT_ALIGN_CENTER, nil, color_black )
bloop = bloop + v.size
end
gap = gap + 32
end
return gap
end
local ScoreWide = 600
function GM:ScoreboardShow()
drawscoreboard = true
end
function GM:ScoreboardHide()
drawscoreboard = false
end
function GM:HUDDrawScoreBoard()
if !drawscoreboard then return end
local p = LocalPlayer()
local w, h = ScrW(), ScrH()
local handler = p:HandlerCheck()
stack = util.Stack()
local myteam = p:Team()
local CURRCHAR
if BennyGame:GetType() == BG_GTYPE_CAMPAIGN then
CURRCHAR = "benny"
else
CURRCHAR = TEAMS[myteam].factionid
end
local COLOR_MAIN = FACTIONS[CURRCHAR].COLOR_MAIN
local COLOR_DARK = FACTIONS[CURRCHAR].COLOR_DARK
local CHARNAME = FACTIONS[CURRCHAR].CHARNAME
local MP = BennyGame:GetType() == BG_GTYPE_MP
if MP then
S_Push( w/2 - ScoreWide/2, h/2 - 400/2 )
local OrganizedTeams = {}
local IDtoOrg = {}
local MyCreation = { id = myteam, players = {} }
table.insert( OrganizedTeams, MyCreation )
IDtoOrg[myteam] = MyCreation
for TeamID, RealTeamID in ipairs( BennyGame.TeamsInPlay ) do
if RealTeamID == myteam then continue end
local MyCreation = { id = RealTeamID, players = {} }
table.insert( OrganizedTeams, MyCreation )
IDtoOrg[RealTeamID] = MyCreation
end
for _, ply in player.Iterator() do
local thisteam = ply:Team()
if !IDtoOrg[thisteam] then
local MyCreation = { id = thisteam, players = {} }
table.insert( OrganizedTeams, MyCreation )
IDtoOrg[thisteam] = MyCreation
end
table.insert( IDtoOrg[thisteam].players, ply )
end
local gap = 0
for index, data in ipairs( OrganizedTeams ) do
S_Push( 0, 0 + gap )
gap = gap + QuickDrawStat( ScoreWide, data, index==1 )
S_Pop()
end
S_Pop()
else
-- Timer, player & team score
end
if stack:Size() != 0 then print("Stack unfinished.") end
return
end