Skip to content

Commit

Permalink
fix some oversights
Browse files Browse the repository at this point in the history
  • Loading branch information
mckinlee committed Jan 3, 2025
1 parent 37e5f0d commit 3964111
Showing 1 changed file with 32 additions and 34 deletions.
66 changes: 32 additions & 34 deletions mm/2s2h/Enhancements/Timesavers/SwampBoatSkip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,41 @@ extern "C" {
}

#define CVAR_NAME "gEnhancements.Timesavers.SwampBoatSpeed"
#define CVAR CVarGetInteger(CVAR_NAME, 5)
#define CVAR CVarGetInteger(CVAR_NAME, 0)

void RegisterSwampBoatSpeed() {
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnActorUpdate>([](Actor* actor) {
if (actor->id == ACTOR_BG_INGATE) {
BgIngate* boat = (BgIngate*)actor;
if (CVAR >= 1 && DynaPolyActor_IsPlayerOnTop(&boat->dyna)) {
if (!CHECK_EVENTINF(EVENTINF_35)) {
// Pictograph Tour
if (CHECK_BTN_ALL(CONTROLLER1(&gPlayState->state)->cur.button, BTN_Z)) {
boat->timePathTimeSpeed = (s16)(4 * CVAR);
} else {
boat->timePathTimeSpeed = 4; // Default speed
}
} else if (CHECK_EVENTINF(EVENTINF_35) && HS_GET_BOAT_ARCHERY_HIGH_SCORE() >= 20) {
// Archery Minigame
if (CHECK_BTN_ALL(CONTROLLER1(&gPlayState->state)->cur.button, BTN_Z)) {
boat->timePathTimeSpeed = (s16)(1 * CVAR);
} else {
boat->timePathTimeSpeed = 1; // Default speed
}
} else if (CHECK_EVENTINF(EVENTINF_35) && gSaveContext.minigameScore >= 20) { // Current score
// Update boat archery high score early
// Leaving minigame early prevents the score from being updated
if (gSaveContext.minigameScore > HS_GET_BOAT_ARCHERY_HIGH_SCORE()) {
HS_SET_BOAT_ARCHERY_HIGH_SCORE(gSaveContext.minigameScore);
SET_EVENTINF(EVENTINF_37);
}

// Leave the minigame
gPlayState->nextEntrance = ENTRANCE(TOURIST_INFORMATION, 1); // 1 = Koume
gSaveContext.nextCutsceneIndex = 0;
gPlayState->transitionTrigger = TRANS_TRIGGER_START;
gPlayState->transitionType = TRANS_TYPE_FADE_WHITE;
gSaveContext.nextTransitionType = TRANS_TYPE_FADE_WHITE;
return;
COND_ID_HOOK(OnActorUpdate, ACTOR_BG_INGATE, CVAR, [](Actor* actor) {
BgIngate* boat = (BgIngate*)actor;
if (DynaPolyActor_IsPlayerOnTop(&boat->dyna)) {
if (!CHECK_EVENTINF(EVENTINF_35)) {
// Pictograph Tour
if (CHECK_BTN_ALL(CONTROLLER1(&gPlayState->state)->cur.button, BTN_Z)) {
boat->timePathTimeSpeed = (s16)(4 * 5);
} else {
boat->timePathTimeSpeed = 4; // Default speed
}
} else if (CHECK_EVENTINF(EVENTINF_35) && HS_GET_BOAT_ARCHERY_HIGH_SCORE() >= 20) {
// Archery Minigame
if (CHECK_BTN_ALL(CONTROLLER1(&gPlayState->state)->cur.button, BTN_Z)) {
boat->timePathTimeSpeed = (s16)(1 * 5);
} else {
boat->timePathTimeSpeed = 1; // Default speed
}
} else if (CHECK_EVENTINF(EVENTINF_35) && gSaveContext.minigameScore >= 20) { // Current score
// Update boat archery high score early
// Leaving minigame early prevents the score from being updated
if (gSaveContext.minigameScore > HS_GET_BOAT_ARCHERY_HIGH_SCORE()) {
HS_SET_BOAT_ARCHERY_HIGH_SCORE(gSaveContext.minigameScore);
SET_EVENTINF(EVENTINF_37);
}

// Leave the minigame
gPlayState->nextEntrance = ENTRANCE(TOURIST_INFORMATION, 1); // 1 = Koume
gSaveContext.nextCutsceneIndex = 0;
gPlayState->transitionTrigger = TRANS_TRIGGER_START;
gPlayState->transitionType = TRANS_TYPE_FADE_WHITE;
gSaveContext.nextTransitionType = TRANS_TYPE_FADE_WHITE;
return;
}
}
});
Expand Down

0 comments on commit 3964111

Please sign in to comment.