-- 320x200 -- Don't mind my variable names local coolCounter = 0 local goRed = false local speedometerEnabled = true local bossHealthEnabled = true local showMultiplayerName = false local iconSize = 10; -- Boss stuff local boss = nil local bossMaxHealth = 0 local bossHealth = 0 -- Width and Height local width = 130; local height = 10; -- X and Y offsets local ypos = 1 local xpos = 0 local targetxpos = 0 -- Text X and Y offsets local txoffset = 2 local tyoffset = 0 local rtxoffset = 0 local rtyoffset = 0 local hudEnabled = true local a = 0x00090000 -- Water/Space timer X offsets local timerxoffset = 1; addHook("BossThinker", function (mob) boss = mob bossHealth = mob.health bossMaxHealth = mob.info.spawnhealth end) local animspeed = 10 local started = false local curspeed = animspeed addHook("MapLoad", function () boss = nil bossHealth = 0 bossMaxHealth = 0 curspeed = 0 started = false xpos = -width a = 0x00090000 end) local function disableHudElements() if hudEnabled then if hud.enabled("textspectator") then hud.disable("textspectator") end if hud.enabled("score") then hud.disable("score") end if hud.enabled("time") then hud.disable("time") end if hud.enabled("rings") then hud.disable("rings") end if hud.enabled("lives") then hud.disable("lives") end else if not hud.enabled("textspectator") then hud.enable("textspectator") end if not hud.enabled("score") then hud.enable("score") end if not hud.enabled("time") then hud.enable("time") end if not hud.enabled("rings") then hud.enable("rings") end if not hud.enabled("lives") then hud.enable("lives") end end end addHook("PreThinkFrame", disableHudElements) CV_RegisterVar({name="hudwidth", defaultValue="" + width, flags=CV_CALL, pv={MIN=100,MAX=320}, func=function (var) width = var.value; end}) CV_RegisterVar({name="hudxpos", defaultValue="" + xpos, flags=CV_CALL, pv={MIN=100,MAX=320}, func=function (var) targetxpos = var.value end}) CV_RegisterVar({name="hudypos", defaultValue="" + ypos, flags=CV_CALL, pv={MIN=100,MAX=320}, func=function (var) ypos = var.value end}) CV_RegisterVar({name="showname", defaultValue="Off", flags=CV_CALL, pv=CV_OnOff, func=function (var) if var.string == "On" then showMultiplayerName = true else showMultiplayerName = false end end}) CV_RegisterVar({name="speedometer", defaultValue="On", flags=CV_CALL, pv=CV_OnOff, func=function (var) if var.string == "On" then speedometerEnabled = true else speedometerEnabled = false end end}) CV_RegisterVar({name="bosshealth", defaultValue="On", flags=CV_CALL, pv=CV_OnOff, func=function (var) if var.string == "On" then bossHealthEnabled = true else bossHealthEnabled = false end end}) CV_RegisterVar({name="hud", defaultValue="On", flags=CV_CALL, pv=CV_OnOff, func=function (var) if var.string == "On" then hudEnabled = true else hudEnabled = false end end}) local deccel = FRACUNIT local accelAdd = -1 local minSpeed = 1 local function hudHandler(v, p, cam) if not hudEnabled then return end if p.mo.skin == "modernsonic" then return end if v.renderer() == "none" then return end if p.mo == nil or not p.valid then return end if p.powers[pw_carry] == CR_NIGHTSMODE then return end xpos = xpos + (max(min(targetxpos - xpos, curspeed), -curspeed)) if a > 0 and xpos == targetxpos then a = a - 0x00010000 end coolCounter = coolCounter + 1 local timer = 0 local timerMax = 0 if not started and p.speed > FRACUNIT/10 then started = true curspeed = animspeed end if p.powers[pw_underwater] then timerMax = 1050 timer = min(p.powers[pw_underwater], timerMax) elseif p.powers[pw_spacetime] then timerMax = 405 timer = min(p.powers[pw_spacetime], timerMax) end local col = 29 if v.RandomChance(deccel) then if curspeed > minSpeed then curspeed = curspeed - accelAdd end end if coolCounter > 7 then coolCounter = 0 if not goRed then goRed = true else goRed = false end end if p.rings > 0 then goRed = false end if goRed then col = 38 end local txpos = 5; local rpos = -5; --Rings v.drawFill(xpos, ypos, width, height, col|a|V_SNAPTOTOP|a|V_SNAPTOLEFT) local ramp = skincolors[p.mo.color].ramp; local i = 0 local step = width / 16 v.drawFill(xpos, ypos + height, width, 1, ramp[15]|a|V_SNAPTOTOP|a|V_SNAPTOLEFT) while i < 16 do local c = ramp[i] local x = 0 while x < step do v.drawFill(xpos + (i * step) + x, ypos + height, 1, 1, c|a|V_SNAPTOTOP|a|V_SNAPTOLEFT) x = x + 1 end i = i + 1 end v.drawString(xpos + txpos + rtxoffset, 1 + ypos, "Rings", V_YELLOWMAP|a|V_SNAPTOTOP|a|V_SNAPTOLEFT, "left") local twidth = v.stringWidth("" + p.rings, V_SNAPTOTOP|a|V_SNAPTOLEFT) v.drawString(xpos + width + txpos - twidth + rpos, 1 + ypos, "" + p.rings, V_YELLOWMAP|a|V_SNAPTOTOP|a|V_SNAPTOLEFT, "left") --Time v.drawString(xpos + txpos + txoffset, 4 + ypos + height, "Time", V_SNAPTOTOP|a|V_SNAPTOLEFT, "left") local f = "%02d" local str = string.format(f, G_TicsToMinutes(p.realtime, true)) + ":" + string.format(f, G_TicsToSeconds(p.realtime)) + ":" + string.format(f, G_TicsToCentiseconds(p.realtime)) local twidth = v.stringWidth(str, V_SNAPTOTOP|a|V_SNAPTOLEFT) v.drawString(xpos + width + txpos - twidth + rpos, 4 + ypos + height, str, V_YELLOWMAP|a|V_SNAPTOTOP|a|V_SNAPTOLEFT, "left") --Score v.drawString(xpos + txpos + txoffset, 4 + ypos + height + 10, "Score", V_SNAPTOTOP|a|V_SNAPTOLEFT, "left") local str = "" + p.score local twidth = v.stringWidth(str, V_SNAPTOTOP|a|V_SNAPTOLEFT) v.drawString(xpos + width + txpos - twidth + rpos, 4 + ypos + height + 10, str, V_YELLOWMAP|a|V_SNAPTOTOP|a|V_SNAPTOLEFT, "left") --Underwater/Space timer if timerMax > 0 then v.drawFill(xpos + timerxoffset, 4 + ypos + height + 20, width - timerxoffset - 1, 2, 159|a|V_SNAPTOTOP|a|V_SNAPTOLEFT) v.drawFill(xpos + timerxoffset, 4 + ypos + height + 20, FixedInt(FixedMul(FixedDiv(timer*FRACUNIT, timerMax*FRACUNIT), width*FRACUNIT)) - timerxoffset - 1, 2, 131|a|V_SNAPTOTOP|a|V_SNAPTOLEFT) end --Boss health local h = 3; if not (boss == nil) and bossMaxHealth > 0 and P_CheckSight(p.mo, boss) and bossHealthEnabled then local off = 32 + 4; v.drawString(320 - xpos - width - xpos - off, ypos, "BOSS", V_REDMAP|a|V_SNAPTOTOP|a|V_SNAPTORIGHT) v.drawFill(320 - xpos - width - xpos, ypos, width, height, 29|a|V_SNAPTOTOP|a|V_SNAPTORIGHT) local w = width - (h * 2) v.drawFill(320 - xpos - width - xpos + h, ypos + h, w, height - (h * 2), 40|a|V_SNAPTOTOP|a|V_SNAPTORIGHT) v.drawFill(320 - xpos - width - xpos + h, ypos + h, min(FixedInt(FixedMul(FixedDiv((bossHealth*FRACUNIT),(bossMaxHealth*FRACUNIT)), w*FRACUNIT)), w), height - (h * 2), 35|a|V_SNAPTOTOP|a|V_SNAPTORIGHT) end if G_GametypeUsesLives() then --Life counter local lname = "placeholder" local lives = p.lives if showMultiplayerName then lname = p.name else lname = skins[p.skin].hudname end local xwidth = v.stringWidth("x", V_SNAPTOBOTTOM|a|V_SNAPTOLEFT, "small") local lifeWidth = v.stringWidth(lname, V_SNAPTOBOTTOM|a|V_SNAPTOLEFT) + 32 + iconSize + 8; v.drawFill(xpos, 200 - 2, lifeWidth, 2, ramp[15]|a|V_SNAPTOBOTTOM|a|V_SNAPTOLEFT) local i = 0 local lstep = lifeWidth / 16 while i < 16 do local c = ramp[i] local x = 0 while x < lstep do v.drawFill(xpos + (i * lstep) + x, 200 - 2, 1, 2, c|a|V_SNAPTOBOTTOM|a|V_SNAPTOLEFT) x = x + 1 end i = i + 1 end local s = v.getSprite2Patch(p.realmo.skin, SPR2_LIFE, false, 0) local scaleMul = FRACUNIT; local colormap = v.getColormap(p.mo.skin, p.mo.color); if not s then s = v.getSpritePatch("TV1U", A) scaleMul = FRACUNIT/3 end local off = 10; local nyoff = -2; local lyoff = -2; v.drawScaled((xpos + iconSize)*FRACUNIT, (200 - iconSize + 4)*FRACUNIT, FixedMul(FRACUNIT + (2/FRACUNIT), scaleMul), s, V_SNAPTOBOTTOM|a|V_SNAPTOLEFT, colormap) v.drawString(xpos + iconSize + off, nyoff + 200 - 10, lname, skincolors[p.mo.color].chatcolor|a|V_SNAPTOBOTTOM|a|V_SNAPTOLEFT) v.drawString(xpos + lifeWidth - 18, lyoff + 200 - 10, string.format("%02d", lives), V_YELLOWMAP|a|V_SNAPTOBOTTOM|a|V_SNAPTOLEFT) v.drawString((xpos + lifeWidth - (18 - (-xwidth) - -1)), lyoff + 200 - 10 + xwidth, "x", V_YELLOWMAP|a|V_SNAPTOBOTTOM|a|V_SNAPTOLEFT, "small") end --Speedometer if not speedometerEnabled then return end local off = (8 * 5) + 4; v.drawString(320 - xpos - width - off, 200 - height, "SPEED", skincolors[p.mo.color].chatcolor|a|V_SNAPTOBOTTOM|a|V_SNAPTORIGHT) v.drawFill(320 - xpos - width, 200 - height, width, height, 29|a|V_SNAPTOBOTTOM|a|V_SNAPTORIGHT) local w = width - (h * 2) v.drawFill(320 - xpos - width + h, 200 - height + h, w, height - (h * 2), ramp[15]|a|V_SNAPTOBOTTOM|a|V_SNAPTORIGHT) v.drawFill(320 - xpos - width + h, 200 - height + h, min(FixedInt(FixedMul(FixedDiv((p.speed),(skins[0].runspeed*2 + (skins[0].runspeed/2))), w*FRACUNIT)), w), height - (h * 2), ramp[4]|a|V_SNAPTOBOTTOM|a|V_SNAPTORIGHT) if p.powers[pw_tailsfly] > 0 then v.drawFill(320 - xpos - width + h, 200 - height + h + (height - (h * 2)), w, 1, ramp[13]|a|V_SNAPTOBOTTOM|a|V_SNAPTORIGHT) v.drawFill(320 - xpos - width + h, 200 - height + h + (height - (h * 2)), min(FixedInt(FixedMul(FixedDiv((p.powers[pw_tailsfly]*FRACUNIT),280*FRACUNIT), w*FRACUNIT)), w), 1, ramp[0]|a|V_SNAPTOBOTTOM|a|V_SNAPTORIGHT) end local i = 0; local sstep = width / 16; v.drawFill(320 - xpos - width, (200 - 1), width, 1, ramp[15]|a|V_SNAPTOBOTTOM|a|V_SNAPTORIGHT) while i < 16 do local c = ramp[i] local x = 0 while x < sstep do v.drawFill(320 - xpos - width + (i * sstep) + x, (200 - 1), 1, 1, c|a|V_SNAPTOBOTTOM|a|V_SNAPTORIGHT) x = x + 1 end i = i + 1 end end hud.add(hudHandler, "game")