From e806297ad77b09a9619fd9092eda48da2d84765f Mon Sep 17 00:00:00 2001 From: lahm86 <33758420+lahm86@users.noreply.github.com> Date: Fri, 21 Feb 2025 16:30:33 +0000 Subject: [PATCH] rooms: use calculated max abyss height Rather than hardcoding the maximum abyss height to 16384, we calculate it based on the OG difference between this and Floating Islands abyss height. This avoids potential collision issues near the top of the level. --- src/libtrx/game/rooms/common.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/libtrx/game/rooms/common.c b/src/libtrx/game/rooms/common.c index b82e2d058..a2fd63f9d 100644 --- a/src/libtrx/game/rooms/common.c +++ b/src/libtrx/game/rooms/common.c @@ -33,7 +33,8 @@ static bool m_FlipStatus = false; static int32_t m_FlipEffect = -1; static int32_t m_FlipTimer = 0; static int32_t m_FlipSlotFlags[MAX_FLIP_MAPS] = {}; -static int16_t m_AbyssHeight = 0; +static int16_t m_AbyssMinHeight = 0; +static int32_t m_AbyssMaxHeight = 0; static HEIGHT_TYPE m_HeightType = HT_WALL; static const int16_t *M_ReadTrigger( @@ -511,12 +512,17 @@ SECTOR *Room_GetSkySector( void Room_SetAbyssHeight(const int16_t height) { - m_AbyssHeight = height; + // Once Lara reaches the min abyss height, she will be killed; she will + // continue to fall however, so the max height is needed until the inventory + // is shown, otherwise Lara will hit the floor. + m_AbyssMinHeight = height; + m_AbyssMaxHeight = height == 0 ? 0 : m_AbyssMinHeight + 26 * STEP_L; + CLAMPG(m_AbyssMaxHeight, MAX_HEIGHT - STEP_L); } bool Room_IsAbyssHeight(const int16_t height) { - return m_AbyssHeight != 0 && height >= m_AbyssHeight; + return m_AbyssMinHeight != 0 && height >= m_AbyssMinHeight; } HEIGHT_TYPE Room_GetHeightType(void) @@ -533,7 +539,7 @@ int16_t Room_GetHeight( int32_t height = pit_sector->floor.height; if (Room_IsAbyssHeight(height)) { - height = 0x4000; + height = m_AbyssMaxHeight; } else { height = M_GetFloorTiltHeight(pit_sector, x, z); }