--[[ deaths counter.lua Author: birbhorse, aka EeveeEuphoria replaces the lives counter with a death counter, while also giving the player infinite lives does not apply to game modes where lives aren't applicable ]]-- -- [[ player logic ]] -- addHook("PlayerThink", function(player) if not ((gametyperules & GTR_LIVES) or (gametyperules & GTR_RACE)) hud.enable("lives") return end if player.playerstate == PST_DEAD and not player.DCMod.timer player.DCMod.deaths = $ + 1 end if player.playerstate == PST_DEAD and not player.DCMod.reverse player.DCMod.timer = $ + 1 player.DCMod.Died = true end if player.DCMod.reverse if player.playerstate != PST_DEAD player.DCMod.timer2 = $ + 1 if player.DCMod.timer2 > TICRATE*2 if player.DCMod.timer < TICRATE player.DCMod.timer = $ + 1 else player.DCMod.reverse = false player.DCMod.timer = 0 end end else player.DCMod.reverse = false player.DCMod.timer = 0 end end if (player.pflags & PF_FINISHED) or stoppedclock player.DCMod.timer = $ + 1 end end) addHook("PlayerSpawn", function(player) if not ((gametyperules & GTR_LIVES) or (gametyperules & GTR_RACE)) hud.enable("lives") return end hud.disable("lives") player.lives = INFLIVES if not player.DCMod player.DCMod = {} player.DCMod.deaths = 0 player.DCMod.Died = true player.DCMod.CurrentLevel = gamemap end if player.DCMod.CurrentLevel != gamemap player.DCMod.CurrentLevel = gamemap player.DCMod.deaths = 0 player.DCMod.Died = true end if not player.DCMod.Died -- detects if a player hit the "retry" button in single player player.DCMod.deaths = $ + 1 else player.DCMod.Died = false end player.DCMod.timer = 0 player.DCMod.timer2 = 0 player.DCMod.reverse = true end) -- [[ hud logic ]] -- hud.add(function(v, player, cam) if not ((gametyperules & GTR_LIVES) or (gametyperules & GTR_RACE)) hud.enable("lives") return end if player.bot return end if not (player.mo and player.mo.valid and player and player.valid) return end -- just for in case, srb2 can be weird about this local function CheckPause() -- detect if game is paused, if so, halt all operations, unless the game is alt-tabbed for some fucking reason if menuactive and not netgame return true end if paused return true end --if focuslost return true end return false end v.TickDownValue = 20 -- after this amount of tics, assuming it's less than TICRATE, the sine formula will start to go in reverse, aka negative values v.TimerPlus = 65 -- additional value added to sinmath value, to increase the amount of time it's actually been since things started for that value alone if v.xoffset == nil v.xoffset = 0 v.yoffset = 176*FRACUNIT end if not CheckPause() if player.DCMod.timer == 0 if player.DCMod.reverse v.yoffset = 176*FRACUNIT else v.yoffset = 200*FRACUNIT end else if player.DCMod.reverse if player.DCMod.timer <= TICRATE v.tickerdown = 15 - player.DCMod.timer v.SinMath = (FRACUNIT/3)*(player.DCMod.timer+(v.TimerPlus*2)) v.yoffset = $ - (v.tickerdown * 100)*sin(v.SinMath) end else if player.DCMod.timer <= TICRATE v.tickerdown = v.TickDownValue - player.DCMod.timer v.SinMath = (FRACUNIT)*(player.DCMod.timer+v.TimerPlus) v.yoffset = $ - (v.tickerdown * 85)*sin(v.SinMath) if player.DCMod.timer > v.TickDownValue if v.yoffset > 176*FRACUNIT v.yoffset = 176*FRACUNIT end end end end end end local lifeicon = v.getSprite2Patch(player.mo.skin, "XTRA", A) local colormap = v.getColormap(player.mo.skin, player.mo.color) local xicon = v.cachePatch("stlivex") v.drawScaled((16+v.xoffset)*FRACUNIT, v.yoffset, FRACUNIT/2, lifeicon, V_SNAPTOLEFT|V_SNAPTOBOTTOM, colormap) -- life icon v.drawScaled((38+v.xoffset)*FRACUNIT, v.yoffset + (9*FRACUNIT), FRACUNIT, xicon, V_SNAPTOLEFT|V_SNAPTOBOTTOM) -- "X" v.drawString((34+v.xoffset), (v.yoffset/FRACUNIT) + 0, "DEATHS", V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_YELLOWMAP) -- text v.drawString((58+v.xoffset), (v.yoffset/FRACUNIT) + 8, player.DCMod.deaths, V_SNAPTOLEFT|V_SNAPTOBOTTOM) -- number end, "game")