Add encore support

This commit is contained in:
Not 2022-04-04 20:58:35 +02:00
commit ee251b7a44

View File

@ -20,6 +20,7 @@ local FILENAME = "leaderboard.txt"
local nextMap = nil
local Flags = 0
local F_ENCORE = 0x80
-- SPB flags with the least significance first
local F_SPBATK = 0x1
@ -352,6 +353,20 @@ local function changelevel(player, ...)
end
COM_AddCommand("changelevel", changelevel)
local function toggleEncore(player)
if not doyoudare(player) then
return
end
local enc = CV_FindVar("kartencore")
if enc.value then
COM_BufInsertText(server, "kartencore off")
else
COM_BufInsertText(server, "kartencore on")
end
end
COM_AddCommand("encore", toggleEncore)
local function clearcheats(player)
if not player.spectator then
clearcheats = true
@ -616,12 +631,25 @@ local FACERANK_DIM = 16
local FACERANK_SPC = FACERANK_DIM + 4
local function drawScore(v, player, pos, x, y, gui, faceRank, score, drawPos, textVFlags)
textVFlags = textVFlags or V_HUDTRANSHALF
--draw Patch/chili
v.draw(x, y, faceRank, V_HUDTRANS | VFLAGS, v.getColormap("sonic", score["color"]))
if player.name == score["name"] then
v.draw(x, y, PATCH["CHILI"][(leveltime / 4) % 8], V_HUDTRANS | VFLAGS)
end
-- Encore
if score["flags"] & F_ENCORE then
local bob = sin((leveltime + i * 5) * (ANG10))
v.drawScaled(
x * FRACUNIT,
bob + (y + FACERANK_DIM / 2) * FRACUNIT,
FRACUNIT / 6,
PATCH["RUBY"],
V_HUDTRANS
)
end
-- SPB
if score["flags"] & F_SPBATK then
local scale = FRACUNIT / 4
@ -850,6 +878,7 @@ function cachePatches(v)
end
PATCH["BIG"] = v.cachePatch("K_ISGROW")
PATCH["HYUD"] = v.cachePatch("K_ISHYUD")
PATCH["RUBY"] = v.cachePatch("RUBYICON")
end
end
@ -1021,7 +1050,13 @@ local function think()
end
-- Autospec
-- Encore
if leveltime == 1 then
Flags = $ & !F_ENCORE
if encoremode then
Flags = $ | F_ENCORE
end
if p then
for s in players.iterate do
if s.valid and s.spectator then