//Helper for the UFO Catcher local UFOMAXHP = 20 local ufo local ufoLastHP local ufoLastHPDisplay local ufoDamTimer rawset(_G, "mapSet", function(mo) ufo = nil ufoLastHP = 100 ufoLastHPDisplay = 100 ufoDamTimer = 0 end) rawset(_G, "getufo", function(mo) if (mo.health <= 0) return end ufo = mo if ufoDamTimer > 0 then ufoDamTimer = $ - 1 if ufoDamTimer == 0 then ufoLastHP = ufoLastHPDisplay end end if ufoLastHPDisplay ~= ufo.health - 1 then if leveltime < TICRATE then ufoLastHPDisplay = ufo.health - 1 ufoLastHP = ufoLastHPDisplay elseif ufoLastHP > ufo.health - 1 then ufoLastHP = ufoLastHPDisplay ufoLastHPDisplay = ufo.health - 1 ufoDamTimer = 2*TICRATE else ufoLastHPDisplay = ufo.health - 1 ufoLastHP = ufoLastHPDisplay ufoDamTimer = 0 end end end) addHook("MapChange", mapSet) addHook("MobjThinker", getufo, MT_SPECIAL_UFO) local function drawUFOHealthBar(v, p, x, y, health, damhealth) //Draw the base health bar v.draw(x-1, y, v.cachePatch("K_BOSB01"), V_HUDTRANS|V_SNAPTOTOP|V_SNAPTORIGHT|V_FLIP) v.draw(x-100, y, v.cachePatch("K_BOSB01"), V_HUDTRANS|V_SNAPTOTOP|V_SNAPTORIGHT) v.drawStretched((x-100)*FRACUNIT, y*FRACUNIT, 100*FRACUNIT, FRACUNIT, v.cachePatch("K_BOSB02"), V_HUDTRANS|V_SNAPTOTOP|V_SNAPTORIGHT) //Draw the current HP if health > 0 then if health > 50 then v.drawStretched((x-health)*FRACUNIT, y*FRACUNIT, health*FRACUNIT, FRACUNIT, v.cachePatch("K_BOSB03"), V_HUDTRANS|V_SNAPTOTOP|V_SNAPTORIGHT) else v.drawStretched((x-health)*FRACUNIT, y*FRACUNIT, health*FRACUNIT, FRACUNIT, v.cachePatch("K_BOSB05"), V_HUDTRANS|V_SNAPTOTOP|V_SNAPTORIGHT) end end if damhealth > 0 then local damhealthtic = damhealth if ufoDamTimer < TICRATE then damhealthtic = ($ * ufoDamTimer) / TICRATE end v.drawStretched((x-(health+damhealthtic))*FRACUNIT, y*FRACUNIT, damhealthtic*FRACUNIT, FRACUNIT, v.cachePatch("K_BOSB07"), V_HUDTRANS|V_SNAPTOTOP|V_SNAPTORIGHT) end end hud.add(function(v, p, c) if (gametyperules & GTR_CATCHER) then local barx = 297 local bary = 40 local textx = barx - 50 local texty = bary + 1 local maxhp = UFOMAXHP local currenthp = 0 local health = 0 local parthealth = false if (ufo) and (ufo.valid) then health = ufoLastHPDisplay currenthp = health / 5 if (health % 5) > 0 then currenthp = $ + 1 parthealth = true end if ufoLastHPDisplay ~= ufoLastHP then local textcol = V_REDMAP local damhealth if ufoLastHPDisplay == 0 then damhealth = "BREAK!" textcol = V_YELLOWMAP else damhealth = "-" .. (abs(ufoLastHPDisplay - ufoLastHP) / 5) .. "HP" end if (ufoDamTimer % 10) < 5 then v.drawString(textx+20, texty+10, damhealth, V_SNAPTOTOP|V_HUDTRANSHALF|textcol, "center") end end drawUFOHealthBar(v, p, barx, bary, health, abs(ufoLastHP-health)) v.drawString(textx, texty, currenthp .. "HP", V_SNAPTOTOP|V_HUDTRANSHALF, "center") else drawUFOHealthBar(v, p, barx, bary, 0, 0) v.drawString(textx, texty, "Emerald Got!", V_SNAPTOTOP|V_HUDTRANSHALF|V_YELLOWMAP, "center") end end end)