From 929bf2322e775af996112584d10b786bbae68b64 Mon Sep 17 00:00:00 2001 From: MysterD Date: Fri, 11 Mar 2022 21:43:54 -0800 Subject: [PATCH] Removed spawn offset when you're the only player there (speedrunners) --- src/game/mario.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/game/mario.c b/src/game/mario.c index fdc88d10..62531e8a 100644 --- a/src/game/mario.c +++ b/src/game/mario.c @@ -2129,8 +2129,24 @@ static void init_single_mario(struct MarioState* m) { u16 spawnAngle = m->faceAngle[1] + 0x4000 + 0x10000 * ((f32)globalIndex / ((f32)connectedPlayers + 1)); f32 spawnMag = 60.0f * ((connectedPlayers + 1) / 2.0f); if (spawnMag > 120) { spawnMag = 120; } - m->pos[0] -= spawnMag * sins(spawnAngle); - m->pos[2] -= spawnMag * coss(spawnAngle); + + // figure out if we should apply offset + u8 nearbyPlayers = 1; + for (int i = 1; i < MAX_PLAYERS; i++) { + struct NetworkPlayer* np = &gNetworkPlayers[i]; + if (!np->connected) { continue; } + if (np->currCourseNum == gCurrCourseNum && np->currLevelNum == gCurrLevelNum && np->currActNum == gCurrActStarNum && np->currAreaIndex == gCurrAreaIndex) { + nearbyPlayers++; + } + } + + if (nearbyPlayers > 1) { + m->pos[0] -= spawnMag * sins(spawnAngle); + m->pos[2] -= spawnMag * coss(spawnAngle); + LOG_INFO("spawn offset!, %u", nearbyPlayers); + } else { + LOG_INFO("no spawn offset!, %u", nearbyPlayers); + } m->floorHeight = find_floor(m->pos[0], m->pos[1], m->pos[2], &m->floor);