From d55f8a39ef0cc4d76efb36eb42bae21422db6887 Mon Sep 17 00:00:00 2001 From: MysterD Date: Mon, 9 May 2022 08:28:30 -0700 Subject: [PATCH] Possible fixes to shell race level desyncs, prevent first place from getting mushrooms --- mods/shell-rush/level.lua | 24 ++++-------------------- mods/shell-rush/main.lua | 2 +- mods/shell-rush/powerup.lua | 14 ++++++++++++++ mods/shell-rush/race.lua | 2 +- 4 files changed, 20 insertions(+), 22 deletions(-) diff --git a/mods/shell-rush/level.lua b/mods/shell-rush/level.lua index 72644f9d..ea281717 100644 --- a/mods/shell-rush/level.lua +++ b/mods/shell-rush/level.lua @@ -95,26 +95,10 @@ function spawn_custom_level_objects() return end - -- look for existing powerups - local obj = obj_get_first(OBJ_LIST_LEVEL) - while obj ~= nil do - local behaviorId = get_id_from_behavior(obj.behavior) - - if behaviorId == id_bhvItemBox then - -- find closest position to put it in - local objPos = { x = obj.oPosX, y = obj.oPosY, z = obj.oPosZ } - for i in pairs(gLevelData.powerups) do - local powPos = gLevelData.powerups[i].pos - local tempPos = { x = powPos.x, y = objPos.y, z = powPos.z } - local dist = vec3f_dist(objPos, tempPos) - if dist < 5 then - gLevelData.powerups[i].obj = obj - end - end - end - - -- iterate - obj = obj_get_next(obj) + -- only handle powerups if we're sync valid + np = gNetworkPlayers[0] + if (not np.currAreaSyncValid) or (not np.currLevelSyncValid) then + return end -- spawn missing powerups diff --git a/mods/shell-rush/main.lua b/mods/shell-rush/main.lua index a14090ae..e1dd570b 100644 --- a/mods/shell-rush/main.lua +++ b/mods/shell-rush/main.lua @@ -1,6 +1,6 @@ -- name: Shell Rush -- description: Race around SM64 levels on shells.\n\nCollect powerups such as red shells, green shells, bananas, and mushrooms.\n\nOnly use a save that has lowered the water in the moat. --- incompatible: gamemode +-- incompatible: gamemode moveset DEBUG = false UNST22 = true -- gotta work around unst 22 bugs :( diff --git a/mods/shell-rush/powerup.lua b/mods/shell-rush/powerup.lua index 5b77e81a..3383a7ec 100644 --- a/mods/shell-rush/powerup.lua +++ b/mods/shell-rush/powerup.lua @@ -261,6 +261,20 @@ function select_powerup() local s = gPlayerSyncTable[0] local pick = math.random(1, POWERUP_MAX-1) local luck = math.random() < 0.33 + + -- don't give mushrooms when first place + local rank = 0 + for i in pairs(gRankings) do + if gRankings[i].playerIndex == 0 then + rank = i + end + end + if rank <= 1 then + if pick == POWERUP_MUSHROOM then + pick = POWERUP_GREEN_SHELL + end + end + if luck then s.powerup[0] = pick s.powerup[1] = pick diff --git a/mods/shell-rush/race.lua b/mods/shell-rush/race.lua index 8e653cbf..c89665ba 100644 --- a/mods/shell-rush/race.lua +++ b/mods/shell-rush/race.lua @@ -123,7 +123,7 @@ function race_update() end local np = gNetworkPlayers[0] - if gGlobalSyncTable.gotoLevel ~= -1 then + if gGlobalSyncTable.gotoLevel ~= -1 and np.currAreaSyncValid and np.currLevelSyncValid then if np.currLevelNum ~= gGlobalSyncTable.gotoLevel then if gGlobalSyncTable.gotoLevel == LEVEL_CASTLE_GROUNDS then warp_to_castle(LEVEL_VCUTM)