Skip to content

Commit

Permalink
Fix a softlock when inhaled by Gyorg and dying simultaneously
Browse files Browse the repository at this point in the history
Fixes a possible softlock when dying while being inhaled by Gyorg.

Prior to this fix, the game would softlock because that sequence of
actions causes Link to exit the "held (by Gyorg or Majora's whips)"
state and eventually enter (and stay in) the frozen state after
the fairy revival cutscene.
  • Loading branch information
leoetlino committed Apr 24, 2020
1 parent 83a5f8f commit 81ff580
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion source/rst/fixes/boss.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,15 +318,28 @@ extern "C" RST_HOOK int rst_GetGyorgCollisionResponse(game::act::BossGyorg* gyor
}

void FixGyorg() {
const auto* gctx = GetContext().gctx;
auto* gctx = GetContext().gctx;
auto* gyorg =
gctx->FindActorWithId<game::act::BossGyorg>(game::act::Id::BossGyorg, game::act::Type::Boss);
if (!gyorg)
return;

// Disable the first stun cutscene, which is known to be buggy.
gyorg->field_F24 |= 1;
gyorg->eyeball_flags = 0;
gyorg->eyeball_scale = {0.0, 0.0, 0.0};

// Dying while being inhaled by Gyorg causes Link to exit the "held (by Gyorg or Majora's whips)"
// state. After the fairy revival cutscene, Link enters the Zora swim state (0x21d5b8) and then
// switches to the frozen state (0x20d96c), even though he's supposed to be in the "held" state.
// If this situation is detected, clear the FreezeLink flag.
const auto player = gctx->GetPlayerActor();
const auto gyorg_eating_link = (decltype(gyorg->gyorg_calc))util::GetAddr(0x557900);
const auto link_handle_frozen = (decltype(player->state_handler_fn))util::GetAddr(0x20D96C);
if (gyorg->gyorg_calc == gyorg_eating_link && player->state_handler_fn == link_handle_frozen &&
player->flags1.TestAndClear(game::act::Player::Flag1::FreezeLink)) {
util::Print("%s: clearing FreezeLink flag", __func__);
}
}

struct TwinmoldFixState {
Expand Down

0 comments on commit 81ff580

Please sign in to comment.