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 return
end end
-- look for existing powerups -- only handle powerups if we're sync valid
local obj = obj_get_first(OBJ_LIST_LEVEL) np = gNetworkPlayers[0]
while obj ~= nil do if (not np.currAreaSyncValid) or (not np.currLevelSyncValid) then
local behaviorId = get_id_from_behavior(obj.behavior) return
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)
end end
-- spawn missing powerups -- spawn missing powerups

View File

@ -1,6 +1,6 @@
-- name: Shell Rush -- 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. -- 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 DEBUG = false
UNST22 = true -- gotta work around unst 22 bugs :( UNST22 = true -- gotta work around unst 22 bugs :(

View File

@ -261,6 +261,20 @@ function select_powerup()
local s = gPlayerSyncTable[0] local s = gPlayerSyncTable[0]
local pick = math.random(1, POWERUP_MAX-1) local pick = math.random(1, POWERUP_MAX-1)
local luck = math.random() < 0.33 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 if luck then
s.powerup[0] = pick s.powerup[0] = pick
s.powerup[1] = pick s.powerup[1] = pick

View File

@ -123,7 +123,7 @@ function race_update()
end end
local np = gNetworkPlayers[0] 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 np.currLevelNum ~= gGlobalSyncTable.gotoLevel then
if gGlobalSyncTable.gotoLevel == LEVEL_CASTLE_GROUNDS then if gGlobalSyncTable.gotoLevel == LEVEL_CASTLE_GROUNDS then
warp_to_castle(LEVEL_VCUTM) warp_to_castle(LEVEL_VCUTM)