-- PTSR v2.0 gamemode by Jisk, brought back & updated by Green --[[ ~~ 1.7 CHANGELOG ~~ - Increased amount of points stolen on parry: 100 --> 250 - When receiving stolen score, the color of the text is a light red. To show it's evil. MUAHAHAHA - Fixed people being able to spam chat with "Player has died" messages - Improved(?) how ^^^ works in general ]] PTSR.gm_eliminations = PTSR.RegisterGamemode("Elimination", { parry_friendlyfire = true, dustdevil = false, allowrevive = false, eliminationcooldown = 45*TICRATE }) local gm_metadata = PTSR.gamemode_list[PTSR.gm_eliminations] PTSR.default_playervars.eliminated = false local parrypoints = 250 local addtimeondeath = 10*TICRATE PTSR.eliminations_timer = nil local angle_fromportal -- for forcelap local elimboard = {} addHook("NetVars", function(net) PTSR.eliminations_timer = net($) angle_fromportal = net($) elimboard = net($) end) local function GetPlayerCount() local playercount = 0 for player in players.iterate do if player.mo and player.mo.valid and player.playerstate ~= PST_DEAD and not player.ptsr.pizzaface then playercount = $ + 1 end end return playercount end PTSR_AddHook("onpizzatime", function() if PTSR.gamemode ~= PTSR.gm_eliminations then return end PTSR.eliminations_timer = gm_metadata.eliminationcooldown angle_fromportal = mapheaderinfo[gamemap].ptsr_lapangle chatprint("\x85\*Elimination! \x8F\Don't be last.") if DiscordBot then DiscordBot.Data.msgsrb2 = $..":crossed_swords: Elimination! **Don't be last.**\n" end end) -- function PTSR.add_wts_score(player, mobj, score, delay, color) PTSR_AddHook("onparry", function(pmo, foundmobj) if PTSR.gamemode ~= PTSR.gm_eliminations then return end local player = pmo.player local foundplayer = foundmobj.player if foundplayer then foundplayer.score = $ - parrypoints P_AddPlayerScore(player, parrypoints) PTSR.add_wts_score(player, foundmobj, parrypoints, 9, SKINCOLOR_PEPPER) end return false -- continue as normal end) PTSR_AddHook("ongameend", function() if PTSR.gamemode ~= PTSR.gm_eliminations then return end if isserver or isdedicatedserver then CV_Set(CV_PTSR.showdeaths, 1) end if #elimboard == 1 then local player = elimboard[#elimboard] chatprint("\x82\*"..player.name.." won the round!") if DiscordBot then DiscordBot.Data.msgsrb2 = $.."["..#player.."]:trophy: "..player.name.." won the round!\n" end elseif #elimboard == 0 then chatprint("\x8d\*Nobody won the round.") if DiscordBot then DiscordBot.Data.msgsrb2 = $..":wastebasket: Nobody won the round.\n" end elseif #elimboard > 1 then chatprint("\x85\*Cowards.") end end) addHook("MapLoad", function() -- reset eliminated var, to be safe for player in players.iterate do player.ptsr.eliminated = false end if PTSR.gamemode ~= PTSR.gm_eliminations then return end PTSR.eliminations_timer = gm_metadata.eliminationcooldown if isserver or isdedicatedserver then CV_Set(CV_PTSR.showdeaths, 0) end end) addHook("MobjDeath", function(mobj) if PTSR.gamemode ~= PTSR.gm_eliminations then return end local player = mobj.player if player and player.valid and PTSR.pizzatime and not PTSR.gameover then if (not player.ptsr.eliminated) and (not CV_PTSR.showdeaths.value) then PTSR.eliminations_timer = $ + addtimeondeath chatprint("\x82*"..player.name.." has died.") if DiscordBot then DiscordBot.Data.msgsrb2 = $.."["..#player.."]:skull: **"..player.name.."** died.\n" end end end end, MT_PLAYER) addHook("ThinkFrame", function() if PTSR.gamemode ~= PTSR.gm_eliminations then return end -- leaderboard shite to fix one scenario (P rank always winning against S rank) elimboard = {} for player in players.iterate do if player.spectator or player.ptsr.pizzaface or player.playerstate == PST_DEAD then continue end table.insert(elimboard, player) end table.sort(elimboard, function(a,b) return a.score > b.score end) if PTSR.pizzatime and (not PTSR.gameover) and PTSR.eliminations_timer ~= nil then if GetPlayerCount() > 1 then if PTSR.eliminations_timer == 0 then local worstplayer = elimboard[#elimboard] if worstplayer and worstplayer.valid then if (isserver or isdedicatedserver) and CV_PTSR.showdeaths.value then CV_Set(CV_PTSR.showdeaths, 0) end worstplayer.ptsr.eliminated = true P_KillMobj(worstplayer.mo) local output = worstplayer.name.." has been eliminated!" chatprint("\x85\*"..output) S_StartSound(nil, sfx_s3k3b) if DiscordBot then DiscordBot.Data.msgsrb2 = $.."["..#worstplayer.."]:x: "..output.."\n" end end PTSR.eliminations_timer = gm_metadata.eliminationcooldown else PTSR.eliminations_timer = $ - 1 end end end -- ptsr_forcelap on (if it worked) if PTSR.pizzatime and (not PTSR.gameover) then for player in players.iterate do if player.mo and player.mo.valid and player.playerstate ~= PST_DEAD and player.ptsr.outofgame and GetPlayerCount() > 1 then player.ptsr.outofgame = 0 L_SpeedCap(player.mo, 0) -- i have absolutely no idea where this function is from PTSR.StopHitlag(player, true) PTSR:FillCombo(player) PTSR.StartNewLap(player.mo) if angle_fromportal and tonumber(angle_fromportal) ~= nil then player.mo.angle = FixedAngle(tonumber(angle_fromportal)*FRACUNIT) -- copied from pizzaportal.lua, i'm not that smart end end end end end) -- BEWARE! HUD JANK!!! local eliminations_timer_hud = function(v, player) if PTSR.gamemode ~= PTSR.gm_eliminations then return end if PTSR.eliminations_timer ~= nil and PTSR.pizzatime and (not PTSR.gameover) and GetPlayerCount() > 1 then local y = (player.spectator and 146*FU) or 130*FU local output = "NEXT ELIMINATION: " ..tostring(PTSR.eliminations_timer/TICRATE) customhud.CustomFontString(v, 165*FU, y, output, "PTFNT", (V_SNAPTOBOTTOM), "center", FRACUNIT/4, SKINCOLOR_WHITE) end end local eliminations_warning_hud = function(v, player) if PTSR.gamemode ~= PTSR.gm_eliminations then return end if PTSR.eliminations_timer ~= nil and PTSR.pizzatime and (not PTSR.gameover) and elimboard ~= nil and #elimboard ~= 0 then if elimboard[#elimboard] and elimboard[#elimboard].valid then if elimboard[#elimboard] == player and GetPlayerCount() > 1 then local toptext_y = 140*FU local bottomtext_y = 148*FU v.drawString(165*FU, toptext_y, "\x85\You're in last place!", (V_SNAPTOBOTTOM), "thin-fixed-center") if elimboard[(#elimboard) - 1] and elimboard[(#elimboard) - 1].valid then local nextplayer = elimboard[(#elimboard) - 1] local diff = nextplayer.score - player.score v.drawString(165*FU, bottomtext_y, "\x85".. diff .. " score to go.", (V_SNAPTOBOTTOM), "thin-fixed-center") end elseif elimboard[#elimboard] ~= player and GetPlayerCount() > 1 and not player.spectator then local toptext_y = 140*FU local bottomtext_y = 148*FU v.drawString(165*FU, toptext_y, "\x83\You're safe!", (V_SNAPTOBOTTOM), "thin-fixed-center") if elimboard[#elimboard] and elimboard[#elimboard].valid then local lastplayer = elimboard[#elimboard] local diff = player.score - lastplayer.score v.drawString(165*FU, bottomtext_y, "\x87"..diff.." score from last place.", (V_SNAPTOBOTTOM), "thin-fixed-center") end elseif elimboard[#elimboard] == player and GetPlayerCount() == 1 then local toptext_y = 140*FU local bottomtext_y = 148*FU v.drawString(165*FU, toptext_y, "\x82\You're the last person left!", (V_SNAPTOBOTTOM), "thin-fixed-center") v.drawString(165*FU, bottomtext_y, "\x8F\Make it out alive.", (V_SNAPTOBOTTOM), "thin-fixed-center") elseif player.ptsr.pizzaface then -- player pfs aren't counted in elimboard or GetPlayerCount() :> local toptext_y = 120*FU local bottomtext_y = 128*FU v.drawString(165*FU, toptext_y, "\x87\You're a pizzaface!", (V_SNAPTOBOTTOM), "thin-fixed-center") v.drawString(165*FU, bottomtext_y, "\x85\KILL EVERYONE.", (V_SNAPTOBOTTOM), "thin-fixed-center") end end end end customhud.SetupItem("PTSR_eliminations_timer", ptsr_hudmodname, eliminations_timer_hud, "game", 2) customhud.SetupItem("PTSR_eliminations_warning", ptsr_hudmodname, eliminations_warning_hud, "game", 2)