From 90a9e978ccce4c474047ae70f91c0b14b031d38c Mon Sep 17 00:00:00 2001 From: CowQuack Date: Wed, 30 Aug 2023 21:53:04 -0400 Subject: [PATCH] Fix the stationary action and ledgegrab downwarps when pushed off a ledge, and added a special downwarp for grabbing Bowser (#664) * fix stationary/ledge downwarp, special bowser case * Comment clarity Co-authored-by: thecozies <79979276+thecozies@users.noreply.github.com> --------- Co-authored-by: thecozies <79979276+thecozies@users.noreply.github.com> --- src/game/interaction.c | 2 ++ src/game/mario_step.c | 13 ++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/game/interaction.c b/src/game/interaction.c index 9bced36e4..a3bf70e08 100644 --- a/src/game/interaction.c +++ b/src/game/interaction.c @@ -418,6 +418,8 @@ u32 mario_check_object_grab(struct MarioState *m) { if (facingDYaw >= -0x5555 && facingDYaw <= 0x5555) { m->faceAngle[1] = m->interactObj->oMoveAngleYaw; m->usedObj = m->interactObj; + m->pos[1] = m->floorHeight; + m->vel[1] = 0.0f; result = set_mario_action(m, ACT_PICKING_UP_BOWSER, 0); } } else { diff --git a/src/game/mario_step.c b/src/game/mario_step.c index 028d4962d..9b43b9cae 100644 --- a/src/game/mario_step.c +++ b/src/game/mario_step.c @@ -242,8 +242,10 @@ void stop_and_set_height_to_floor(struct MarioState *m) { mario_set_forward_vel(m, 0.0f); m->vel[1] = 0.0f; - //! This is responsible for some downwarps. - m->pos[1] = m->floorHeight; + // HackerSM64 2.1: This check fixes the ledgegrab downwarp after being pushed off a ledge. + if (m->pos[1] <= m->floorHeight + 160.0f) { + m->pos[1] = m->floorHeight; + } vec3f_copy(marioObj->header.gfx.pos, m->pos); vec3s_set(marioObj->header.gfx.angle, 0, m->faceAngle[1], 0); @@ -259,9 +261,10 @@ s32 stationary_ground_step(struct MarioState *m) { if (takeStep) { stepResult = perform_ground_step(m); } else { - //! TODO - This is responsible for many stationary downwarps but is - // important for stuff like catching Bowser in midair, figure out a good way to fix - m->pos[1] = m->floorHeight; + // HackerSM64 2.1: This check prevents the downwarps that plagued stationary actions. + if (m->pos[1] <= m->floorHeight + 160.0f) { + m->pos[1] = m->floorHeight; + } vec3f_copy(marioObj->header.gfx.pos, m->pos); vec3s_set(marioObj->header.gfx.angle, 0, m->faceAngle[1], 0);