local hide = { ["CHudHealth"] = true, ["CHudBattery"] = true, ["CHudAmmo"] = true, ["CHudSecondaryAmmo"] = true, ["CHudWeaponSelection"] = true, } hook.Add( "HUDShouldDraw", "HideHUD", function( name ) if ( hide[ name ] ) then return false end end ) local sizes = { 48, 28, 24, 18, 14, 10 } for _, size in ipairs(sizes) do surface.CreateFont( "CNR_HUD_" .. size, { font = "Bahnschrift Light", size = ScreenScaleH(size), weight = 0, }) surface.CreateFont( "CNR_HUD_" .. size .. "B", { font = "Bahnschrift Bold", size = ScreenScaleH(size), weight = 0, }) end local special1 = { normal = 12, colon = 5, clean1 = 2, } local special2 = { normal = 16+4, colon = 0, clean1 = 6, } local baby = Color( 0, 0, 0, 50 ) local baby2 = Color( 0, 0, 0, 100 ) function qt( text, font, x, y, color, xalign, yalign ) draw.SimpleText( text, font, x-1, y-1, baby2, xalign, yalign ) draw.SimpleText( text, font, x, y-1, baby2, xalign, yalign ) draw.SimpleText( text, font, x+1, y-1, baby2, xalign, yalign ) draw.SimpleText( text, font, x-1, y, baby2, xalign, yalign ) draw.SimpleText( text, font, x+1, y, baby2, xalign, yalign ) draw.SimpleText( text, font, x-1, y+1, baby2, xalign, yalign ) draw.SimpleText( text, font, x, y+1, baby2, xalign, yalign ) draw.SimpleText( text, font, x+1, y+1, baby2, xalign, yalign ) draw.SimpleText( text, font, x, y, color, xalign, yalign ) end local s = function( inp ) return math.Round( inp * ( ScrH() / 480 ) ) end function MonoDraw( text, font, x, y, color, rightalign, special ) local bump = 0 text = tostring(text) if rightalign then local ogbump = 0 for i=1, #text do local td = text[i] if td == ":" or td == "," or td == "." then ogbump = ogbump + special.colon else ogbump = ogbump + special.normal end end x = x - s(ogbump) end for i=1, #text do local td = text[i] local clean = 0 if td == "1" then clean = special.clean1 end draw.SimpleText( td, font, x + s(bump) + s(clean), y, color ) if td == ":" or td == "," or td == "." then bump = bump + special.colon else bump = bump + special.normal end end end -- State Look-up Table local slut = { [0] = "UNINIT", [1] = "WAITING", [2] = "PREGAME", [3] = "TIME", [4] = "POSTGAME", } local gamelogic = NULL hook.Add("HUDPaint", "CNR_HUD", function() local p, sw, sh = LocalPlayer(), ScrW(), ScrH() local c = sw/2 local c1 = sw*0.125 local c2 = sw*(1-0.125) local b = s(8) local w = p:GetActiveWeapon() w = IsValid(w) and w or false if !gamelogic:IsValid() then for i, ent in ents.Iterator() do if ( ent:GetClass() == "cnr_logic" ) then gamelogic = ent print("Located CNR game logic entity") break end end if !gamelogic:IsValid() then print("Couldn't locate CNR game logic entity!") end end do local b_w, b_h = s(64+8), s(64) local b_x, b_y = c1, sh - b_h - s(16) surface.SetDrawColor( color_white ) surface.DrawRect( b_x, b_y, b_w, b_h ) draw.SimpleText( "HP", "CNR_HUD_24", c1 + b, sh - s(64+12), color_black ) local dumbfuck = tostring(p:Health()):Left(1) == "1" and s(4) or 0 MonoDraw( p:Health(), "CNR_HUD_48B", c1 + b - dumbfuck, sh - s(64), color_black, false, special2 ) end if w then local b_w, b_h = s(64+8), s(64) local b_x, b_y = c2 - b_w, sh - b_h - s(16) surface.SetDrawColor( color_white ) surface.DrawRect( b_x, b_y, b_w, b_h ) draw.SimpleText( "AMMO", "CNR_HUD_24", c2 - b, sh - s(64+12), color_black, TEXT_ALIGN_RIGHT ) MonoDraw( w:Clip1(), "CNR_HUD_48B", c2 - b, sh - s(64), color_black, true, special2 ) end local state = gamelogic:GetState() do local b_w, b_h = s(64+12), s(42) local b_x, b_y = c1, s(16) surface.SetDrawColor( color_white ) surface.DrawRect( b_x, b_y, b_w, b_h ) draw.SimpleText( slut[ gamelogic:GetState() ], "CNR_HUD_14", b_x + b, b_y + s(4), color_black, TEXT_ALIGN_LEFT ) local fuckhead = "" local ltime = LOGIC:GetTimeLeft() if ltime > 60 then fuckhead = string.FormattedTime( LOGIC:GetTimeLeft(), "%02i:%02i") else fuckhead = string.FormattedTime( ltime ) fuckhead = string.format( "%02i.%02i", fuckhead.s, fuckhead.ms ) end MonoDraw( fuckhead, "CNR_HUD_28B", b_x + b, b_y + s(12), color_black, false, special1 ) do local n_w, n_h = s(56), s(42) local n_x, n_y = b_x + b + b_w, b_y surface.SetDrawColor( color_white ) surface.DrawRect( n_x, n_y, n_w, n_h ) draw.SimpleText( "ROUND", "CNR_HUD_14", n_x + b, n_y + s(4), color_black ) draw.SimpleText( gamelogic:GetRound() .. "/" .. CONVARS["rounds_max"]:GetInt(), "CNR_HUD_28B", n_x + b, n_y + s(12), color_black ) end end if state == STATE_INGAME or state == STATE_POSTGAME then local b_w, b_h = s(172), s(30) local b_x, b_y = c1, s(16) + b + s(42) surface.SetDrawColor( color_white ) surface.DrawRect( b_x, b_y, b_w, b_h ) draw.SimpleText( "$", "CNR_HUD_14", b_x + b, b_y + s(8), color_black, TEXT_ALIGN_LEFT ) local fuckhead = gamelogic:GetMoney() fuckhead = string.Comma( fuckhead ) MonoDraw( fuckhead, "CNR_HUD_28B", b_x + b_w - b, b_y, color_black, true, special1 ) end if DeathNotices then local b_w, b_h = s(172), s(16) for i, Data in pairs(DeathNotices) do if (Data.Time+3) <= CurTime() then DeathNotices[i] = nil end end table.sort(DeathNotices, function(a, b) if !a then return true end if !b then return true end return (a.Time > b.Time) end) local spacing = 0 for i, Data in ipairs(DeathNotices) do local stupidfuck = math.Clamp( math.TimeFraction( Data.Time, Data.Time+0.25, CurTime()), 0, 1 ) local stupidfuck2 = math.Clamp( math.TimeFraction( Data.Time, Data.Time+0.5, CurTime()), 0, 1 ) if (Data.Time+2.5) <= CurTime() then stupidfuck = 1 - math.Clamp( math.TimeFraction( Data.Time+2.75, Data.Time+3, CurTime()), 0, 1 ) stupidfuck2 = 1 - math.Clamp( math.TimeFraction( Data.Time+2.5, Data.Time+3, CurTime()), 0, 1 ) end local b_x, b_y = c2 - b_w, s(16) + spacing spacing = spacing + s(4) + (b_h) * stupidfuck render.SetScissorRect( b_x, b_y, b_x + (b_w * stupidfuck2), b_y + (b_h * stupidfuck), true ) surface.SetDrawColor( color_white ) surface.DrawRect( b_x, b_y, b_w * stupidfuck2, b_h * stupidfuck ) qt( Data.AttackerName, "CNR_HUD_10", b_x + s(4), b_y + s(3), Data.AttackerColor, TEXT_ALIGN_LEFT ) draw.SimpleText( Data.InflictorName, "CNR_HUD_14B", b_x + b_w/2, b_y + s(1), color_black, TEXT_ALIGN_CENTER ) qt( Data.VictimName, "CNR_HUD_10", b_x + b_w - s(4), b_y + s(3), Data.VictimColor, TEXT_ALIGN_RIGHT ) render.SetScissorRect( 0, 0, 0, 0, false ) end end -- Weapon selection do local OrganizedWeapons = {} for i, v in ipairs( p:GetWeapons() ) do if !OrganizedWeapons[v:GetSlot()+1] then OrganizedWeapons[v:GetSlot()+1] = {} end local OrgSlot = OrganizedWeapons[v:GetSlot()+1] table.insert( OrgSlot, v ) end local c_w, c_h = s(64), s(24) local booster = 0 booster = booster + c_h + s(4) for i, v in ipairs( OrganizedWeapons ) do booster = booster + c_h + s(4) end for SlotNumber, SlotData in ipairs( OrganizedWeapons ) do booster = booster - c_h - s(4) local c_x, c_y = c2 - c_w, sh - s(64+16) - booster for i=#SlotData, 1, -1 do local v = SlotData[i] local eqp = p:GetActiveWeapon() == v surface.SetDrawColor( eqp and color_black or color_white ) surface.DrawRect( c_x, c_y, c_w, c_h ) draw.SimpleText( v:GetPrintName(), "CNR_HUD_10B", c_x + c_w - s(4), c_y + s(10+2), eqp and color_white or color_black, TEXT_ALIGN_RIGHT ) c_x = c_x - c_w - s(4) end end end end) local function OW_GetOrganizedWeapons() local p = LocalPlayer() local OrganizedWeapons = {} for i, v in ipairs( p:GetWeapons() ) do if !OrganizedWeapons[v:GetSlot()+1] then OrganizedWeapons[v:GetSlot()+1] = {} end local OrgSlot = OrganizedWeapons[v:GetSlot()+1] table.insert( OrgSlot, v ) end return OrganizedWeapons end local function OW_Reorganize() local OW = OW_GetOrganizedWeapons() local NEW = {} for SlotNum, SlotData in ipairs(OW) do for WeaponIndex, WeaponEntity in ipairs(SlotData) do table.insert( NEW, WeaponEntity ) end end return NEW end local slottocode = { [1] = "slot1", [2] = "slot2", [3] = "slot3", [4] = "slot4", [5] = "slot5", [6] = "slot6", [7] = "slot7", [8] = "slot8", [9] = "slot9", [0] = "slot0", } local codetoslot = table.Flip( slottocode ) hook.Add("PlayerBindPress", "CNR_PlayerBindPress", function(p, bind, pressed, code) if pressed then if bind == "invnext" or bind == "invprev" then local w = p:GetActiveWeapon() local OW = OW_Reorganize() local FlippedOrgSlot = table.Flip( OW ) local CurPos = FlippedOrgSlot[ w ] local toadvance = CurPos if bind == "invnext" then toadvance = toadvance + 1 if toadvance > #OW then toadvance = 1 end input.SelectWeapon( OW[toadvance] ) elseif bind == "invprev" then toadvance = toadvance - 1 if toadvance <= 0 then toadvance = #OW end input.SelectWeapon( OW[toadvance] ) end elseif codetoslot[bind] then local w = p:GetActiveWeapon() local ws = w:GetSlot()+1 local OW = OW_Reorganize() local OW1 = OW_GetOrganizedWeapons()[ ws ] local FlippedOrgSlot = table.Flip( OW1 ) local toadvance = FlippedOrgSlot[ w ] if slottocode[ws] != bind then OW1 = OW_GetOrganizedWeapons()[ codetoslot[bind] ] toadvance = 1 else toadvance = toadvance + 1 end do if toadvance > #OW1 then toadvance = 1 end input.SelectWeapon( OW1[toadvance] ) end elseif bind == "lastinv" then local prev = p:GetPreviousWeapon() if prev:IsValid() and prev:IsWeapon() then input.SelectWeapon( prev ) end end end end)