Skip to content

Commit

Permalink
skip captain defeat cutscene (#201)
Browse files Browse the repository at this point in the history
* first pass

* make sure the captain is gone after he's defeated

* no `|| IS_RANDO`

* clean up

* newline

* clean up again

* clang-format

---------

Co-authored-by: Garrett Cox <[email protected]>
  • Loading branch information
briaguya-ai and garrettjoecox authored Jan 27, 2025
1 parent f11fcca commit 259e7e5
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#include <libultraship/bridge.h>
#include "2s2h/GameInteractor/GameInteractor.h"
#include "2s2h/ShipInit.hpp"

extern "C" {
#include "variables.h"
#include "overlays/actors/ovl_En_Bsb/z_en_bsb.h"
}

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

void SkipDefeatCaptainTextbox(EnBsb* captain) {
// from func_80C0D9B4
gPlayState->nextEntrance = Entrance_CreateFromSpawn(5);
gSaveContext.nextCutsceneIndex = 0;
gPlayState->transitionTrigger = 0x14;
gPlayState->transitionType = 2;
gSaveContext.nextTransitionType = 3;
captain->unk_111A = 0;
}

void SkipDefeatCaptainCutscene() {
Player* player = GET_PLAYER(gPlayState);

// the cutscene sets link's position/rotation to
//
// player->actor.world = { { -100.0f, 474.0f, -2330.0f }, { 0, -16384, 0 } };
//
// but link walks forward when not told not to by the cutscene, so we're
// setting link's position back a little bit so he doesn't walk off the ledge
player->actor.world = { { 64.0f, 488.0f, -2332.0f }, { 0, -16384, 0 } };

// make sure captain's gone
SET_WEEKEVENTREG(WEEKEVENTREG_23_04);

// get rid of the fire from the chest
Flags_SetSwitch(gPlayState, 0x0B);
}

void RegisterSkipDefeatCaptainSequence() {
COND_VB_SHOULD(VB_PLAY_DEFEAT_CAPTAIN_SEQUENCE, CVAR, {
*should = false;
EnBsb* captain = (EnBsb*)va_arg(args, EnBsb*);
SkipDefeatCaptainTextbox(captain);
});

COND_VB_SHOULD(VB_START_CUTSCENE, CVAR, {
s16* csId = va_arg(args, s16*);
if (gPlayState->sceneId == SCENE_BOTI && *csId == 20) {
*should = false;
SkipDefeatCaptainCutscene();
}
});
}

static RegisterShipInitFunc initFunc(RegisterSkipDefeatCaptainSequence, { CVAR_NAME, "IS_RANDO" });
1 change: 1 addition & 0 deletions mm/2s2h/GameInteractor/GameInteractor.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ typedef enum {
VB_GORON_ROLL_INCREASE_SPIKE_LEVEL,
VB_GORON_ROLL_DISABLE_SPIKE_MODE,
VB_DEKU_LINK_SPIN_ON_LAST_HOP,
VB_PLAY_DEFEAT_CAPTAIN_SEQUENCE,
VB_CLAMP_ANIMATION_SPEED,
} GIVanillaBehavior;

Expand Down
11 changes: 7 additions & 4 deletions mm/src/overlays/actors/ovl_En_Bsb/z_en_bsb.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "objects/gameplay_keep/gameplay_keep.h"
#include "z64rumble.h"
#include "z64shrink_window.h"
#include "2s2h/GameInteractor/GameInteractor.h"

#define FLAGS (ACTOR_FLAG_TARGETABLE | ACTOR_FLAG_UNFRIENDLY | ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_2000000)

Expand Down Expand Up @@ -328,7 +329,7 @@ void EnBsb_Init(Actor* thisx, PlayState* play) {

this->actor.targetMode = 0xA;

if (WEEKEVENTREG(0x17) & 4) {
if (CHECK_WEEKEVENTREG(WEEKEVENTREG_23_04)) {
Actor_Kill(&this->actor);
return;
}
Expand Down Expand Up @@ -1073,8 +1074,10 @@ void func_80C0D964(EnBsb* this, PlayState* play) {
this->unk_02A4 = 0;
this->unk_02A8 = 0;
this->actor.textId = 0x1535;
Message_StartTextbox(play, this->actor.textId, &this->actor);
this->actionFunc = func_80C0D9B4;
if (GameInteractor_Should(VB_PLAY_DEFEAT_CAPTAIN_SEQUENCE, true)) {
Message_StartTextbox(play, this->actor.textId, &this->actor);
this->actionFunc = func_80C0D9B4;
}
}

void func_80C0D9B4(EnBsb* this, PlayState* play) {
Expand Down Expand Up @@ -1517,7 +1520,7 @@ s32 func_80C0E9CC(EnBsb* this, PlayState* play) {
break;

case 5:
WEEKEVENTREG(23) |= 4;
SET_WEEKEVENTREG(WEEKEVENTREG_23_04);
Actor_PlaySfx(&this->actor, NA_SE_EN_KITA_BREAK);
break;

Expand Down

0 comments on commit 259e7e5

Please sign in to comment.