mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2025-10-30 08:01:01 +00:00
Added seeker losing state to hide-and-seek mod
This commit is contained in:
parent
ab1e85994e
commit
62d337f794
1 changed files with 49 additions and 7 deletions
|
|
@ -6,14 +6,22 @@
|
||||||
gGlobalSyncTable.hideAndSeek = true
|
gGlobalSyncTable.hideAndSeek = true
|
||||||
|
|
||||||
-- keep track of round info for popup
|
-- keep track of round info for popup
|
||||||
|
ROUND_END_UNKNOWN = 1
|
||||||
|
ROUND_END_SEEKER_WIN = 2
|
||||||
|
ROUND_END_HIDER_WIN = 3
|
||||||
gGlobalSyncTable.roundNumber = 0
|
gGlobalSyncTable.roundNumber = 0
|
||||||
gGlobalSyncTable.roundEnded = true
|
gGlobalSyncTable.roundEnded = ROUND_END_UNKNOWN
|
||||||
|
|
||||||
sRoundEndedTimer = 0
|
sRoundEndedTimer = 0
|
||||||
sRoundIntermissionTime = 5 * 30 -- five seconds
|
sRoundIntermissionTime = 5 * 30 -- five seconds
|
||||||
|
|
||||||
-- server keeps track of last player turned seeker
|
-- server keeps track of last player turned seeker
|
||||||
sLastSeekerIndex = 0
|
sLastSeekerIndex = 0
|
||||||
|
|
||||||
|
-- keep track of the amount of time since someone was turned into seeker
|
||||||
|
sLastSeekerTimer = 0
|
||||||
|
sLastSeekerTimeout = 3 * 60 * 30 -- three minutes
|
||||||
|
|
||||||
-- keep track of distance moved recently (camping detection)
|
-- keep track of distance moved recently (camping detection)
|
||||||
sLastPos = {}
|
sLastPos = {}
|
||||||
sLastPos.x = 0
|
sLastPos.x = 0
|
||||||
|
|
@ -43,13 +51,20 @@ function server_update(m)
|
||||||
-- only change state if there are 2+ players
|
-- only change state if there are 2+ players
|
||||||
if connectedCount < 2 then
|
if connectedCount < 2 then
|
||||||
sRoundEndedTimer = 0
|
sRoundEndedTimer = 0
|
||||||
|
sLastSeekerTimer = 0
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- check to see if the round should end
|
-- check to see if the round should end
|
||||||
if not gGlobalSyncTable.roundEnded then
|
if gGlobalSyncTable.roundEnded == 0 then
|
||||||
if not hasHider or not hasSeeker then
|
if not hasHider or not hasSeeker or sLastSeekerTimer > sLastSeekerTimeout then
|
||||||
gGlobalSyncTable.roundEnded = true
|
if not hasHider then
|
||||||
|
gGlobalSyncTable.roundEnded = ROUND_END_SEEKER_WIN
|
||||||
|
elseif sLastSeekerTimer > sLastSeekerTimeout then
|
||||||
|
gGlobalSyncTable.roundEnded = ROUND_END_HIDER_WIN
|
||||||
|
else
|
||||||
|
gGlobalSyncTable.roundEnded = ROUND_END_UNKNOWN
|
||||||
|
end
|
||||||
sRoundEndedTimer = 0
|
sRoundEndedTimer = 0
|
||||||
else
|
else
|
||||||
return
|
return
|
||||||
|
|
@ -83,7 +98,7 @@ function server_update(m)
|
||||||
|
|
||||||
-- increment round number
|
-- increment round number
|
||||||
gGlobalSyncTable.roundNumber = gGlobalSyncTable.roundNumber + 1
|
gGlobalSyncTable.roundNumber = gGlobalSyncTable.roundNumber + 1
|
||||||
gGlobalSyncTable.roundEnded = false
|
gGlobalSyncTable.roundEnded = 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -130,6 +145,19 @@ function update()
|
||||||
|
|
||||||
-- check if local player is camping
|
-- check if local player is camping
|
||||||
camping_detection(gMarioStates[0])
|
camping_detection(gMarioStates[0])
|
||||||
|
|
||||||
|
-- update sLastSeekerTimer
|
||||||
|
if gGlobalSyncTable.roundEnded == 0 then
|
||||||
|
sLastSeekerTimer = sLastSeekerTimer + 1
|
||||||
|
local timeLeft = sLastSeekerTimeout - sLastSeekerTimer
|
||||||
|
if timeLeft == 60 * 30 then
|
||||||
|
djui_popup_create('\\#ff4040\\Seekers have one minute to get someone!', 3)
|
||||||
|
elseif timeLeft == 30 * 30 then
|
||||||
|
djui_popup_create('\\#ff4040\\Seekers have 30 seconds to get someone!', 3)
|
||||||
|
elseif timeLeft == 10 * 30 then
|
||||||
|
djui_popup_create('\\#ff4040\\Seekers have 10 seconds to get someone!', 3)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function mario_update(m)
|
function mario_update(m)
|
||||||
|
|
@ -247,8 +275,21 @@ end
|
||||||
|
|
||||||
function on_round_ended_changed(tag, oldVal, newVal)
|
function on_round_ended_changed(tag, oldVal, newVal)
|
||||||
-- inform players when a round has ended
|
-- inform players when a round has ended
|
||||||
if newVal and not oldVal then
|
local tColor = '\\#ffa0a0\\'
|
||||||
djui_popup_create('\\#a0a0ff\\the round has ended', 2)
|
if newVal == ROUND_END_UNKNOWN then
|
||||||
|
djui_popup_create(tColor .. 'the round has ended', 2)
|
||||||
|
elseif newVal == ROUND_END_HIDER_WIN then
|
||||||
|
if not gPlayerSyncTable[0].seeking then tColor = '\\#a0ffa0\\' end
|
||||||
|
djui_popup_create(tColor .. 'Hiders win!', 2)
|
||||||
|
elseif newVal == ROUND_END_SEEKER_WIN then
|
||||||
|
if gPlayerSyncTable[0].seeking then tColor = '\\#a0ffa0\\' end
|
||||||
|
djui_popup_create(tColor .. 'Seekers win!', 2)
|
||||||
|
end
|
||||||
|
|
||||||
|
if oldVal == 0 and newVal ~= 0 then
|
||||||
|
sLastSeekerTimer = 0
|
||||||
|
elseif newVal == 0 and oldVal ~= 0 then
|
||||||
|
sLastSeekerTimer = 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -262,6 +303,7 @@ function on_seeking_changed(tag, oldVal, newVal)
|
||||||
playerColor = network_get_player_text_color_string(m.playerIndex)
|
playerColor = network_get_player_text_color_string(m.playerIndex)
|
||||||
djui_popup_create(playerColor .. np.name .. '\\#ffa0a0\\ is now a seeker', 2)
|
djui_popup_create(playerColor .. np.name .. '\\#ffa0a0\\ is now a seeker', 2)
|
||||||
sLastSeekerIndex = m.playerIndex
|
sLastSeekerIndex = m.playerIndex
|
||||||
|
sLastSeekerTimer = 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue