Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement] Add Moon Crash Cutscene Skip to Story Cutscenes time savers #970

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions mm/2s2h/Enhancements/Cutscenes/MiscInteractions/SkipMoonCrash.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include <libultraship/bridge.h>
#include <libultraship/luslog.h>
#include "2s2h/GameInteractor/GameInteractor.h"
#include "2s2h/ShipInit.hpp"

extern "C" {
#include "variables.h"
}

#define CVAR_NAME "gEnhancements.Cutscenes.SkipStoryCutscenes"
#define CVAR CVarGetInteger(CVAR_NAME, 0)

#define TERMINA_FIELD_MOON_CRASH_CS_ENTRANCE 0x54C0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a fan of these defines, instead we should just compare against the entrance values using the entrance macro.

If you really want the define, then it should contain the ENTRANCE value instead of these hardcoded numbers

In this case its ENTRANCE(TERMINA_FIELD, 12)


#define MOON_CRASH_NEW_CYCLE_CS_ID 13
#define MOON_CRASH_NEW_CYCLE_ENTRANCE_ID 0xC030
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above, but this value is ENTRANCE(CLOCK_TOWER_INTERIOR, 3)


/**
* Skips only the visible cutscenes (Clock Tower destruction and Link's terrible fate with the Fire Wall).
* Note: There is a cutscene command SPECIFICALLY for resetting game state related to the moon crash,
* CS_MISC_RESET_SAVE_FROM_MOON_CRASH, that MUST NOT be skipped, or else
* it would break the vanilla functionality of a Moon Crash reset.
*/
void RegisterSkipMoonCrash() {
// Skips initial cutscene in Termina Field where the moon falls, goes straight to clock tower cutscene
COND_VB_SHOULD(VB_PLAY_TRANSITION_CS, CVAR, {
if (gSaveContext.save.cutsceneIndex == 0x0 &&
gSaveContext.save.entrance == TERMINA_FIELD_MOON_CRASH_CS_ENTRANCE) {
// This cutscene command would otherwise be run as part of the Fire Wall cutscene that gets skipped.
// IT MUST BE CALLED HERE IF THAT CUTSCENE IS SKIPPED OR ELSE THE GAME STATE WILL NOT RESET CORRECTLY!
Sram_ResetSaveFromMoonCrash(&gPlayState->sramCtx);

gSaveContext.save.cutsceneIndex = MOON_CRASH_NEW_CYCLE_CS_ID;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gSaveContext.save.cutsceneIndex should remain at 0 for the clock tower interior entrance.

This value MOON_CRASH_NEW_CYCLE_CS_ID being 13 appears to be a misunderstanding with the cutscene ID used by the salesman when the salesman inits. His logic handles choosing the right cs ID based on the players inventory.

gSaveContext.save.entrance = MOON_CRASH_NEW_CYCLE_ENTRANCE_ID;
}
});
}

static RegisterShipInitFunc initFunc(RegisterSkipMoonCrash, { CVAR_NAME });
Loading