Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ending camera sequence #4

Merged
merged 3 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions src/Lua/Functions/Scripts/endGame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,26 @@ return function(self, endType)
MM_N.endType = endType
MM_N.gameover = true

S_StopMusic(consoleplayer)

for mo in mobjs.iterate()
if not (mo and mo.valid) then continue end
if (mo == MM_N.end_camera) then continue end

if mo.flags & MF_NOTHINK
mo.notthinking = true
continue
end

mo.flags = $|MF_NOTHINK
end

/*
MM_N.mapVote = {}

mapmusname = "_INTER"
S_ChangeMusic(mapmusname)

local addedMaps = 0
while addedMaps < 3 do
local map = P_RandomRange(1, 1024)
Expand All @@ -48,7 +63,7 @@ return function(self, endType)
})
addedMaps = $+1
end

for p in players.iterate do
if not (p and p.mm) then continue end

Expand All @@ -58,4 +73,6 @@ return function(self, endType)
end
table.insert(MM_N.innocents, p)
end
*/

end
6 changes: 5 additions & 1 deletion src/Lua/Functions/Scripts/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ local randomPlayer = MM.require "Libs/getRandomPlayer"

return function(self)
MM_N = shallowCopy(matchVars)

if (MM_N.end_camera and MM_N.end_camera.valid)
P_RemoveMobj(MM_N.end_camera)
MM_N.end_camera = nil
end

for p in players.iterate do
self:playerInit(p, true)
end
Expand Down
84 changes: 84 additions & 0 deletions src/Lua/Functions/Scripts/startEndCamera.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
local function intervalhelper(t, d)
return (min(t,d)*FU) / (max(d,1))
end

local function interval(t, s, d)
return intervalhelper(max(t,s) - s, d)
end

local function follow(mobj, mul)
P_MoveOrigin(mobj,
mobj.origin[1] + P_ReturnThrustX(nil,mobj.angle,-mobj.lerpradius),
mobj.origin[2] + P_ReturnThrustY(nil,mobj.angle,-mobj.lerpradius),
mobj.z
)
end

return function(self, origin, focusang, finalradius, panduration, panspeed)
if not (MM_N.end_camera and MM_N.end_camera.valid)
local angle = AngleFixed(focusang)

MM_N.end_camera = P_SpawnMobjFromMobj(origin,
P_ReturnThrustX(nil,focusang,-finalradius),
P_ReturnThrustY(nil,focusang,-finalradius),
origin.height,
MT_THOK
)
MM_N.end_camera.tics = -1
MM_N.end_camera.fuse = -1
MM_N.end_camera.flags2 = $|MF2_DONTDRAW

MM_N.end_camera.origin = {origin.x,origin.y,origin.z + origin.height}
MM_N.end_camera.startradius = {1200*FU,800*FU}
MM_N.end_camera.endradius = {finalradius, finalradius/2}
MM_N.end_camera.lerpradius = finalradius

MM_N.end_camera.swirldur = 3*TICRATE
MM_N.end_camera.startangle = angle + 90*FU
MM_N.end_camera.endangle = angle + 990*FU --720*FU

MM_N.end_camera.target = origin

MM_N.end_camera.panduration = panduration
MM_N.end_camera.panspeed = panspeed

MM_N.end_camera.ticker = 0
--Move
else
local time = MM_N.end_camera.ticker
local pan = ease.outquint(
interval(time, MM_N.end_camera.swirldur, MM_N.end_camera.panduration),
FU, 0
)

if time <= MM_N.end_camera.swirldur
local swirl = intervalhelper(time, MM_N.end_camera.swirldur)

local ang = FixedAngle(swirl < FU/2 and
ease.inoutquint(swirl, MM_N.end_camera.startangle, MM_N.end_camera.endangle) or
ease.inoutquad(swirl, MM_N.end_camera.startangle, MM_N.end_camera.endangle)
)
local hdist = ease.outquad(swirl, MM_N.end_camera.startradius[1], MM_N.end_camera.endradius[1])

/*
local p = {
x = MM_N.end_camera.origin[1] - FixedMul(cos(ang), hdist),
y = MM_N.end_camera.origin[2] - FixedMul(sin(ang), hdist),
z = MM_N.end_camera.origin[3] + ease.outquad(swirl, MM_N.end_camera.startradius[2], MM_N.end_camera.endradius[2])
}
*/

MM_N.end_camera.lerpradius = hdist

MM_N.end_camera.angle = ang - ANGLE_90
MM_N.end_camera.ticker = $+1
end
follow(MM_N.end_camera, FixedMul(pan, MM_N.end_camera.panspeed))

end

for p in players.iterate
p.awayviewmobj = MM_N.end_camera
p.awayviewtics = 10*TICRATE
end
end
46 changes: 46 additions & 0 deletions src/Lua/Functions/Scripts/startVote.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
return function(self)
if MM_N.voting then return end

MM_N.voting = true
MM_N.end_ticker = 0

MM_N.mapVote = {}

mapmusname = "_INTER"
S_ChangeMusic(mapmusname)

local addedMaps = 0
while addedMaps < 3 do
local map = P_RandomRange(1, 1024)
if not mapheaderinfo[map] then continue end

local data = mapheaderinfo[map]

local mapWasIn = false
for _,oldmap in ipairs(MM_N.mapVote) do
if map == oldmap.map then mapWasIn = true break end
end
if mapWasIn then continue end

if not (data.typeoflevel & TOL_MATCH) then
continue
end
if data.bonustype then continue end

table.insert(MM_N.mapVote, {
map = map,
votes = 0
})
addedMaps = $+1
end

for p in players.iterate do
if not (p and p.mm) then continue end

if p.mm.role == 2 then
table.insert(MM_N.murderers, p)
continue
end
table.insert(MM_N.innocents, p)
end
end
4 changes: 3 additions & 1 deletion src/Lua/Functions/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ doAndInsert("init")
doAndInsert("playerInit")
doAndInsert("endGame")
doAndInsert("pingMurderers")
doAndInsert("playerWithGun")
doAndInsert("playerWithGun")
doAndInsert("startVote")
doAndInsert("startEndCamera")
52 changes: 39 additions & 13 deletions src/Lua/Hooks/Game/Manager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,44 @@ addHook("ThinkFrame", function()
if not MM:isMM() then return end

if MM_N.gameover then
MM_N.end_ticker = $+1
if MM_N.end_ticker > 15*TICRATE then
local selected_map = 1
local most_votes = 0
for _,map in ipairs(MM_N.mapVote) do
if map.votes < most_votes then continue end

selected_map = map.map
most_votes = map.votes
if MM_N.voting
MM_N.end_ticker = $+1
if MM_N.end_ticker > 15*TICRATE then
local selected_map = 1
local most_votes = 0
for _,map in ipairs(MM_N.mapVote) do
if map.votes < most_votes then continue end

selected_map = map.map
most_votes = map.votes
end
G_SetCustomExitVars(selected_map, 2)
G_ExitLevel()
end
else
MM_N.end_ticker = $+1

if (MM_N.end_camera and MM_N.end_camera.valid)
MM:startEndCamera()
end

if MM_N.end_ticker == 3*TICRATE
for mo in mobjs.iterate()
if not (mo and mo.valid) then continue end

if mo.notthinking
continue
end

mo.flags = $ &~MF_NOTHINK
end
end

if MM_N.end_ticker >= 5*TICRATE
MM:startVote()
end
G_SetCustomExitVars(selected_map, 2)
G_ExitLevel()
end

return
end

Expand Down Expand Up @@ -93,11 +117,13 @@ addHook("ThinkFrame", function()

innocents = $+1
end


--innocents win
if not (murderers) then
MM:endGame(1)
return
end
--murderers win
if not (innocents) then
MM:endGame(2)
return
Expand Down
4 changes: 2 additions & 2 deletions src/Lua/Hooks/HUD/Drawers/intermission.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ end
local MAX_FADE = 20

return function(v)
if not MM.gameover then return end
if MM.end_ticker == nil then return end
if not MM_N.voting then return end
if MM_N.end_ticker == nil then return end

// DEFINITION

Expand Down
7 changes: 6 additions & 1 deletion src/Lua/Hooks/HUD/Drawers/showdownicon.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ return function(v,p,c)
return
end

v.drawString(6, 30, "SHOWDOWN!", V_SNAPTOTOP|V_SNAPTOLEFT|V_REDMAP, "thin")
v.drawString(6*FU - MMHUD.xoffset,
30*FU,
"SHOWDOWN!",
V_SNAPTOTOP|V_SNAPTOLEFT|V_REDMAP,
"thin-fixed"
)

if not (p and p.mo and p.mm and p.mm.role == 2) then return end

Expand Down
2 changes: 1 addition & 1 deletion src/Lua/Hooks/HUD/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ addHook("HUD", function(v,p,c)
MMHUD.xoffset = ease.inquart(FU*9/10,$,0)
end
else
MMHUD.xoffset = ease.inquart(FU*9/10,$,HUD_BEGINNINGXOFF)
MMHUD.xoffset = ease.inexpo(FU*7/10,$,HUD_BEGINNINGXOFF)
end

hudwasmm = true
Expand Down
22 changes: 22 additions & 0 deletions src/Lua/Hooks/Player/corpse.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,28 @@ addHook("MobjDeath", function(target, inflictor, source)

target.player.mm.whokilledme = source

--TODO: make this better and determine if this kill is a winning kill
local headcount = 0
for p in players.iterate
if p.spectator
or not (p.mo and p.mo.valid and p.mo.health)
or (p.mm and p.mm.spectator)
continue
end
headcount = $+1
end

if headcount == 2
S_StartSound(nil,sfx_buzz3)
S_StartSound(nil,sfx_s253)
MM:startEndCamera(target,
target.player.drawangle + ANGLE_180,
200*FU,
6*TICRATE,
FU/16
)
end


local corpse = P_SpawnMobjFromMobj(target, 0,0,0, MT_THOK)

Expand Down
1 change: 1 addition & 0 deletions src/Lua/Variables/Data/Match.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ return {
maxtime = match_time,
waiting_for_players = false,
gameover = false,
voting = false,
showdown = false,
end_ticker = 0,
showdown_ticker = 0,
Expand Down
Loading