april fools

This commit is contained in:
Not 2022-04-01 20:23:59 +02:00
parent c49702c33b
commit aabc4bdaee
1 changed files with 149 additions and 0 deletions

View File

@ -12,6 +12,10 @@ local splits = {}
local PATCH = nil
local help = true
local LIFE = {}
local faceranks = {}
local dvd = {}
local UNCLAIMED = "Unclaimed Record"
local HELP_MESSAGE = "\x89Leaderboard Commands:\nretry exit findmap changelevel spba_clearcheats lb_gui rival scroll"
local FILENAME = "leaderboard.txt"
@ -531,6 +535,23 @@ COM_AddCommand("rival", findRival)
-- end
--end
local cellSize = 16
local function spawnCells(n)
local p = leveltime
for i = 0,n do
local x = (i * p) % (320/cellSize)
p = p + 7
local y = (i * p) % (200/cellSize)
p = p % 42 + 1
if not(LIFE[x] and LIFE[y]) then
LIFE[x] = $ or {}
LIFE[x][y] = true
end
end
end
addHook("MapLoad", function()
timeFinished = 0
splits = {}
@ -541,9 +562,18 @@ addHook("MapLoad", function()
allowJoin(true)
--printTable(lb)
LIFE = {}
dvd = {}
end
)
local function life(player, ...)
local n = ...
spawnCells(n)
end
COM_AddCommand("life", life)
function ticsToTime(tics, pure)
if tics == 0 and pure then
return "-:--:--"
@ -557,6 +587,111 @@ function ticsToTime(tics, pure)
)
end
local function ticLife()
local neigh = {}
local new = {}
for x, t in pairs(LIFE) do
for y, v in pairs(t) do
neigh[x-1] = $ or {}
neigh[x] = $ or {}
neigh[x+1] = $ or {}
neigh[x-1][y-1] = $ and $ + 1 or 1
neigh[x-1][y] = $ and $ + 1 or 1
neigh[x-1][y+1] = $ and $ + 1 or 1
neigh[x][y-1] = $ and $ + 1 or 1
neigh[x][y+1] = $ and $ + 1 or 1
neigh[x+1][y-1] = $ and $ + 1 or 1
neigh[x+1][y] = $ and $ + 1 or 1
neigh[x+1][y+1] = $ and $ + 1 or 1
end
end
for x, t in pairs(neigh) do
if x >= 0 and x * cellSize < 320 then
for y, v in pairs(t) do
if y >= 0 and y * cellSize < 200 then
-- 3 neighbours dead cell
if v == 3 and (LIFE[x] == nil or LIFE[x][y] == nil) then
new[x] = $ or {}
new[x][y] = true
elseif v >= 2 and v <= 3 and (LIFE[x] and LIFE[x][y] != nil) then
new[x] = $ or {}
new[x][y] = true
end
end
end
end
end
LIFE = new
end
local function drawLife(v, player)
for x, t in pairs(LIFE) do
for y, _ in pairs(t) do
v.drawScaled(
x * cellSize * FRACUNIT,
y * cellSize * FRACUNIT,
FixedDiv(cellSize * FRACUNIT, 16 * FRACUNIT),
PATCH["FACERANK"][faceranks[((x + y) % #faceranks) + 1]],
0,
v.getColormap("sonic", player.skincolor)
)
end
end
end
local function spawnDvd(p)
local size = (((p + leveltime) % 3) + 1) * 16
local rank = (#faceranks and faceranks[((p + leveltime) % #faceranks) + 1]) or "sonic"
local d = {
["x"] = max(((p + leveltime % 320) - size), 0) * FRACUNIT,
["y"] = max(((p + leveltime % 200) - size), 0) * FRACUNIT,
["xvel"] = (((p + leveltime) % 7) + 1) * FRACUNIT / 2,
["yvel"] = (((p + leveltime) % 5) + 1) * FRACUNIT / 2,
["rank"] = rank,
["color"] = ((p + leveltime) % MAXSKINCOLORS - 1) + 1,
["size"] = size,
}
table.insert(dvd, d)
end
local function ticDvd()
for i, d in ipairs(dvd) do
d.x = $ + d.xvel
d.y = $ + d.yvel
if d.x < 0 or d.x + d.size * FRACUNIT > 320 * FRACUNIT then
d.xvel = -$
clamp(0, d.x, 320 * FRACUNIT)
end
if d.y < 0 or d.y + d.size * FRACUNIT > 200 * FRACUNIT then
d.yvel = -$
clamp(0, d.y, 200 * FRACUNIT)
end
end
end
local function drawDvd(v, player)
for i, d in ipairs(dvd) do
v.drawScaled(
d.x,
d.y,
FixedDiv(d.size * FRACUNIT, 16 * FRACUNIT),
PATCH["FACERANK"][d.rank],
0,
v.getColormap("sonic", d.color)
)
end
end
-- Item patches have the amazing property of being displaced 12x 13y pixels
local iXoffset = 13 * FRACUNIT
local iYoffset = 12 * FRACUNIT
@ -813,6 +948,9 @@ local function drawScoreboard(v, player)
if player != displayplayers[0] then return end
cachePatches(v)
drawLife(v, player)
drawDvd(v, player)
local scoreTable = getScoreTable(gamemap, Flags)
@ -841,6 +979,7 @@ function cachePatches(v)
PATCH["FACERANK"] = {}
for skin in skins.iterate do
PATCH["FACERANK"][skin.name] = v.cachePatch(skin.facerank)
table.insert(faceranks, skin.name)
end
PATCH["SPB"] = v.cachePatch("K_ISSPB")
@ -959,6 +1098,10 @@ end
local function regLap(player)
if player.laps > prevLap and timeFinished == 0 then
spawnCells(1000)
for i = 0,player.laps * 3 do
spawnDvd((i + 1) + 7)
end
prevLap = player.laps
table.insert(splits, player.realtime)
showSplit = 5 * TICRATE
@ -1006,6 +1149,12 @@ local function think()
showSplit = max(0, showSplit - 1)
if leveltime % 10 == 0 then
ticLife()
end
ticDvd()
local p = getGamer()
if leveltime < START_TIME then
-- Help message