Modifed arena mod (#115)

* Modifed arena mod to make levels cycle and add a change level command
This commit is contained in:
EmeraldLoc 2022-05-25 20:48:20 -04:00 committed by GitHub
parent d1bb79f4a0
commit fcba78b69e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 42 additions and 1 deletions

View File

@ -224,8 +224,26 @@ function round_begin()
end end
if roundShuffle then if roundShuffle then
local curLevel = nil
for i, gl in ipairs(gGameLevels) do
if gGlobalSyncTable.currentLevel == gl.level then
curLevel = i
end
end
if curLevel ~= nil then
if curLevel >= 3 then
curLevel = 1
else
curLevel = curLevel + 1
end
gGlobalSyncTable.currentLevel = gGameLevels[curLevel].level
else
gGlobalSyncTable.currentLevel = gGameLevels[math.random(#gGameLevels)].level gGlobalSyncTable.currentLevel = gGameLevels[math.random(#gGameLevels)].level
end end
end
for i = 0, (MAX_PLAYERS - 1) do for i = 0, (MAX_PLAYERS - 1) do
player_reset_sync_table(gMarioStates[i]) player_reset_sync_table(gMarioStates[i])
@ -408,6 +426,7 @@ function on_update()
end end
function on_gamemode_command(msg) function on_gamemode_command(msg)
local setMode = nil local setMode = nil
for i, gm in ipairs(gGameModes) do for i, gm in ipairs(gGameModes) do
@ -438,6 +457,27 @@ function on_gamemode_command(msg)
return false return false
end end
function on_level_command(msg)
local setLevel = nil
for i, gl in ipairs(gGameLevels) do
if msg == gl.name then
setLevel = i
end
end
if setLevel ~= nil then
gGlobalSyncTable.currentLevel = gGameLevels[setLevel].level
round_end()
sWaitTimer = 1
sRoundCount = 0
return true
end
return false
end
hook_event(HOOK_ON_SYNC_VALID, on_sync_valid) hook_event(HOOK_ON_SYNC_VALID, on_sync_valid)
hook_event(HOOK_ON_PAUSE_EXIT, on_pause_exit) hook_event(HOOK_ON_PAUSE_EXIT, on_pause_exit)
hook_event(HOOK_UPDATE, on_update) hook_event(HOOK_UPDATE, on_update)
@ -452,4 +492,5 @@ end
if network_is_server() then if network_is_server() then
hook_chat_command('arena-gamemode', string.format("[%s|random] sets gamemode", sGameModeShortTimes), on_gamemode_command) hook_chat_command('arena-gamemode', string.format("[%s|random] sets gamemode", sGameModeShortTimes), on_gamemode_command)
hook_chat_command('arena-level', '[Origin|Sky Beach|Pillars] sets level', on_level_command)
end end