From 088dbbdd2b799e31fccc5caa3bba02c248844590 Mon Sep 17 00:00:00 2001 From: Reonu Date: Thu, 3 Nov 2022 00:25:24 +0100 Subject: [PATCH] Make warp surfaces use the force parameter if set (#525) --- include/config/config_collision.h | 1 + include/surface_terrains.h | 6 +++--- src/game/level_update.c | 20 ++++++++++++-------- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/include/config/config_collision.h b/include/config/config_collision.h index 83e2782ef..41288a361 100644 --- a/include/config/config_collision.h +++ b/include/config/config_collision.h @@ -17,6 +17,7 @@ /** * Allows all surfaces types to have force, (doesn't require setting force, just allows it to be optional). + * Also allows you to pass a warp node to warp floors (SURFACE_WARP, SURFACE_DEATH_PLANE, SURFACE_VERTICAL_WIND) via the second byte of the force parameter. */ #define ALL_SURFACES_HAVE_FORCE diff --git a/include/surface_terrains.h b/include/surface_terrains.h index 67eb64511..908a73eb9 100644 --- a/include/surface_terrains.h +++ b/include/surface_terrains.h @@ -16,7 +16,7 @@ enum SurfaceTypes { SURFACE_0007, // 0x0007 // Unused SURFACE_0008, // 0x0008 // Unused SURFACE_SLOW, // 0x0009 // Slow down Mario, unused - SURFACE_DEATH_PLANE, // 0x000A // Death floor + SURFACE_DEATH_PLANE, // 0x000A // Death floor. Warps to ID of force parameter's second byte if set, otherwise warps to 0xF3 if it exists, otherwise defaults to ID 0xF1. SURFACE_CLOSE_CAMERA, // 0x000B // Close camera SURFACE_000C, // 0x000C // unused SURFACE_WATER, // 0x000D // Water, has no action, used on some waterboxes below @@ -56,13 +56,13 @@ enum SurfaceTypes { SURFACE_LOOK_UP_WARP, // 0x002F // Look up and warp (Wing cap entrance) SURFACE_HARD, // 0x0030 // Hard floor (Always has fall damage) SURFACE_0031, // 0x0031 // Unused - SURFACE_WARP, // 0x0032 // Surface warp + SURFACE_WARP, // 0x0032 // Surface warp. Warps to ID of force parameter's second byte if set, otherwise defaults to ID 0xF3. SURFACE_TIMER_START, // 0x0033 // Timer start (Peach's secret slide) SURFACE_TIMER_END, // 0x0034 // Timer stop (Peach's secret slide) SURFACE_HARD_SLIPPERY, // 0x0035 // Hard and slippery (Always has fall damage) SURFACE_HARD_VERY_SLIPPERY, // 0x0036 // Hard and very slippery (Always has fall damage) SURFACE_HARD_NOT_SLIPPERY, // 0x0037 // Hard and Non-slippery (Always has fall damage) - SURFACE_VERTICAL_WIND, // 0x0038 // Death at bottom with vertical wind + SURFACE_VERTICAL_WIND, // 0x0038 // Death at bottom with vertical wind. Warps to ID of force parameter's second byte if set, otherwise warps to 0xF3 if it exists, otherwise defaults to ID 0xF1. SURFACE_0039, // 0x0039 // Unused SURFACE_003A, // 0x003A // Unused SURFACE_003B, // 0x003B // Unused diff --git a/src/game/level_update.c b/src/game/level_update.c index db1f5a7aa..7fdd412e9 100644 --- a/src/game/level_update.c +++ b/src/game/level_update.c @@ -743,17 +743,21 @@ s16 level_trigger_warp(struct MarioState *m, s32 warpOp) { break; case WARP_OP_WARP_FLOOR: - sSourceWarpNodeId = WARP_NODE_WARP_FLOOR; - if (area_get_warp_node(sSourceWarpNodeId) == NULL) { + if ((m->floor) && (m->floor->force & 0xFF)) { + sSourceWarpNodeId = m->floor->force & 0xFF; + } else { + sSourceWarpNodeId = WARP_NODE_WARP_FLOOR; + if (area_get_warp_node(sSourceWarpNodeId) == NULL) { #ifdef ENABLE_LIVES - if (m->numLives == 0) { - sDelayedWarpOp = WARP_OP_GAME_OVER; - } else { - sSourceWarpNodeId = WARP_NODE_DEATH; - } + if (m->numLives == 0) { + sDelayedWarpOp = WARP_OP_GAME_OVER; + } else { + sSourceWarpNodeId = WARP_NODE_DEATH; + } #else - sSourceWarpNodeId = WARP_NODE_DEATH; + sSourceWarpNodeId = WARP_NODE_DEATH; #endif + } } sDelayedWarpTimer = 20;