-- -- Boss HUD rendering code. -- (c) Inuyasha 2014. -- Permission is granted for you to use this code -- and the associated graphics in your own mods. -- -- Edited slightly by SonicX8000 so it kinda -- mimics the Boss Meter in Sonic Adventure. -- The HP bits disappear from the left instead -- of the right. -- -- -- Storing all boss Mobjs -- local boss_list = {} -- -- HUD Code -- local function hud_draw(v, stplyr) if splitscreen return end -- No bosses in this stage? No drawing. if #boss_list <= 0 return end -- Poll our small list of bosses local bosshealth = 0; local bosspinch = 0; local bossmax = 0; -- (We ignore the index given to us, we only want the object; -- that's why this also uses pairs and not ipairs for order) for _,mobj in pairs(boss_list) if mobj.valid and not (mobj.flags2 & MF2_BOSSDEAD) bossmax = $1 + mobj.info.spawnhealth bosspinch = $1 + mobj.info.damage bosshealth = $1 + mobj.health end end -- No bosses are still alive. if bossmax <= 0 return end local p_startseg = v.cachePatch("BOSS_STA") local p_onseg = v.cachePatch("BOSS_ON") local p_offseg = v.cachePatch("BOSS_OFF") local p_endseg = v.cachePatch("BOSS_END") local p_boss = v.cachePatch("BOSS_HUD") local p_dnseg = v.cachePatch("BOSS_DN") local posx = 320 - 22 local posy = 5 -- Ending segment first and BOSS text v.draw(posx, posy, p_endseg, V_SNAPTOTOP|V_SNAPTORIGHT) v.draw(posx, posy, p_boss, V_SNAPTOTOP|V_SNAPTORIGHT) posx = $1 - 7 -- Step through backwards, to match the way we're drawing. for i = 1, bossmax, 1 if bosshealth >= i v.draw(posx, posy, p_onseg, V_SNAPTOTOP|V_SNAPTORIGHT) else v.draw(posx, posy, p_offseg, V_SNAPTOTOP|V_SNAPTORIGHT) end if bosspinch >= i v.draw(posx, posy, p_dnseg, V_SNAPTOTOP|V_SNAPTORIGHT) else v.draw(posx, posy, p_offseg, V_SNAPTOTOP|V_SNAPTORIGHT) end posx = $1 - 7; end -- Start segment v.draw(posx, posy, p_startseg, V_SNAPTOTOP|V_SNAPTORIGHT); end hud.add(hud_draw)