Possible fixes to shell race level desyncs, prevent first place from getting mushrooms

This commit is contained in:
MysterD 2022-05-09 08:28:30 -07:00
parent c71273cb60
commit d55f8a39ef
4 changed files with 20 additions and 22 deletions

View file

@ -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

View file

@ -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 :(

View file

@ -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

View file

@ -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)