flash score on finish

This commit is contained in:
Not 2022-07-19 20:30:30 +02:00
parent 5a74a428b1
commit d7955feaf8

View File

@ -15,6 +15,21 @@ local EncoreInitial = nil
local cv_teamchange
local scoreTable
-- Text flash on finish
local FlashTics = 0
local FlashRate
local FlashVFlags
local YellowFlash = {
[0] = V_YELLOWMAP,
[1] = V_ORANGEMAP,
[2] = 0
}
local RedFlash = {
[0] = V_REDMAP,
[1] = 0
}
-- Tracks if stats have been written or not
local StatTrack = false
@ -706,6 +721,7 @@ addHook("MapLoad", function()
drawState = DS_DEFAULT
scrollY = 50 * FRACUNIT
scrollAcc = 0
FlashTics = 0
allowJoin(true)
--printTable(lb)
@ -798,10 +814,11 @@ 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
local me = player.name == score["name"]
--draw Patch/chili
v.draw(x, y, faceRank, V_HUDTRANS | VFLAGS, v.getColormap("sonic", score["color"]))
if player.name == score["name"] then
if me then
v.draw(x, y, PATCH["CHILI"][(leveltime / 4) % 8], V_HUDTRANS | VFLAGS)
end
@ -897,11 +914,16 @@ local function drawScore(v, player, pos, x, y, gui, faceRank, score, drawPos, te
end
end
local flashV = 0
if me and FlashTics > leveltime then
flashV = FlashVFlags[leveltime / FlashRate % (#FlashVFlags + 1)]
end
v.drawString(
x + FACERANK_DIM + px,
y + py,
name,
textVFlags | V_ALLOWLOWERCASE | VFLAGS,
textVFlags | V_ALLOWLOWERCASE | VFLAGS | flashV,
stralign
)
@ -919,7 +941,7 @@ local function drawScore(v, player, pos, x, y, gui, faceRank, score, drawPos, te
x + px + FACERANK_DIM,
y + 8,
ticsToTime(score["time"], true),
textVFlags | bodium[min(pos, 4)] | VFLAGS
textVFlags | bodium[min(pos, 4)] | VFLAGS | flashV
)
end
end
@ -1116,10 +1138,16 @@ local function saveTime(player)
if lbComp(newscore, scoreTable[i]) then
table.remove(scoreTable, i)
S_StartSound(nil, 130)
FlashTics = leveltime + TICRATE * 3
FlashRate = 1
FlashVFlags = YellowFlash
break
else
-- You suck lol
S_StartSound(nil, 201)
FlashTics = leveltime + TICRATE * 3
FlashRate = 3
FlashVFlags = RedFlash
scroll_to(player)
return
end