Skip to content

Commit

Permalink
Award the #1 player with an extra vote
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiskster committed Oct 10, 2024
1 parent dfc96c5 commit 5ab5e92
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 18 deletions.
9 changes: 9 additions & 0 deletions src/Lua/Functions/end_game.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ function PTSR.EndGame()
mapmusname = RANKMUS[consoleplayer.ptsr.rank]
end

if PTSR.leaderboard and PTSR.leaderboard[1]
and PTSR.leaderboard[1].valid then
local winnerplayer = PTSR.leaderboard[1]

if winnerplayer.ptsr then
winnerplayer.ptsr.isWinner = true
end
end

for p in players.iterate do
if p and p.ptsr and PTSR.PlayerHasCombo(p) then
PTSR:EndCombo(p)
Expand Down
6 changes: 6 additions & 0 deletions src/Lua/HUD/intermission/drawVoteScreenMaps.lua
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,11 @@ function PTSR.drawVoteScreenMaps(v, player)
else
v.drawString(x, y+(8*FU), "\x82"..gamemodename, 0, "thin-fixed")
end

if player.ptsr then
if player.ptsr.isWinner then
v.drawString(160*FU, 180*FU, "\x8B".."Since you were #1, you get an extra vote!", V_SNAPTOBOTTOM|V_50TRANS, "thin-fixed-center")
end
end
end
end
13 changes: 5 additions & 8 deletions src/Lua/Hooks/PlayerThinks.lua
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ local ranktonum = {
}

addHook('ThinkFrame', function()
if gamestate ~= GS_LEVEL
if gamestate ~= GS_LEVEL then
return
end

Expand All @@ -348,24 +348,22 @@ addHook('ThinkFrame', function()
if PTSR.pizzatime
PTSR.leaderboard = {}

for p in players.iterate

for p in players.iterate do
if (PTSR.pizzatime)
local outofgame = p.spectator or p.ptsr.pizzaface or (p.playerstate == PST_DEAD and PTSR.pizzatime)
if not outofgame
if not outofgame then
table.insert(PTSR.leaderboard,p)
end
end

end

table.sort(PTSR.leaderboard, function(a,b)
local p1 = a
local p2 = b

--ALWAYS promote a P rank than an S with higher score
if ranktonum[a.ptsr.rank] ~= ranktonum[b.ptsr.rank]
if ranktonum[a.ptsr.rank] > ranktonum[b.ptsr.rank]
if ranktonum[a.ptsr.rank] ~= ranktonum[b.ptsr.rank] then
if ranktonum[a.ptsr.rank] > ranktonum[b.ptsr.rank] then
return true
end
else
Expand All @@ -374,7 +372,6 @@ addHook('ThinkFrame', function()
end
end
end)

end
end)

Expand Down
26 changes: 17 additions & 9 deletions src/Lua/Hooks/intermission.lua
Original file line number Diff line number Diff line change
Expand Up @@ -198,15 +198,23 @@ addHook("ThinkFrame", do
if player.ptsr.vote_alreadyvoted
and player.ptsr.vote_mapstats["mapnum"] ~= nil
and player.ptsr.vote_mapstats["gamemode"] ~= nil then
table.insert(PTSR.vote_roulettelist, {
mapnum = player.ptsr.vote_mapstats["mapnum"],
gamemode = player.ptsr.vote_mapstats["gamemode"],
voter_info = {
name = player.name,
skin = skins[player.skin].name,
skincolor = player.skincolor,
}
})
local vote_multi = 1

if player.ptsr.isWinner then
vote_multi = $ + 1
end

for i=1,vote_multi do
table.insert(PTSR.vote_roulettelist, {
mapnum = player.ptsr.vote_mapstats["mapnum"],
gamemode = player.ptsr.vote_mapstats["gamemode"],
voter_info = {
name = player.name,
skin = skins[player.skin].name,
skincolor = player.skincolor,
}
})
end
end
end

Expand Down
1 change: 1 addition & 0 deletions src/Lua/PlayerScripts/player_resetplayervars.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ PTSR.ResetPlayerVars = function(player)
player.spectator = false
player.ptsr = PTSR_shallowcopy(PTSR.default_playervars)
player.ptsr.combo_maxtime = CV_PTSR.combotime.value*TICRATE
player.ptsr.isWinner = false

player.ptvote_selection = 0
player.ptvote_voted = false
Expand Down
4 changes: 3 additions & 1 deletion src/Lua/main_game.lua
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,9 @@ PTSR.default_playervars = {

score_deduct_list = {
-- [1] = {score = 50, fuse = 25, startfuse = 25}
}
},

isWinner = false, -- have they won a round (most points surviving)
}
PTSR.gamemode_list = {}

Expand Down

0 comments on commit 5ab5e92

Please sign in to comment.