Skip to content

Commit

Permalink
Early returns for VB_ENEMY_CUTSCENE_ACTION calls
Browse files Browse the repository at this point in the history
  • Loading branch information
Eblo committed Mar 3, 2025
1 parent f575d41 commit 6ba5c8e
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 63 deletions.
10 changes: 6 additions & 4 deletions mm/src/overlays/actors/ovl_Boss_06/z_boss_06.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,13 @@ void func_809F23CC(Boss06* this) {
}

void func_809F24A8(Boss06* this) {
if (GameInteractor_Should(VB_ENEMY_CUTSCENE_ACTION, true, this)) {
this->actionFunc = func_809F24C8;
this->unk_A28 = 0.0f;
this->unk_1AC = 0.0f;
if (!GameInteractor_Should(VB_ENEMY_CUTSCENE_ACTION, true, this)) {
return;
}

this->actionFunc = func_809F24C8;
this->unk_A28 = 0.0f;
this->unk_1AC = 0.0f;
}

void func_809F24C8(Boss06* this, PlayState* play) {
Expand Down
58 changes: 33 additions & 25 deletions mm/src/overlays/actors/ovl_En_Bigslime/z_en_bigslime.c
Original file line number Diff line number Diff line change
Expand Up @@ -820,28 +820,32 @@ void EnBigslime_JerkCameraPlayerHit(EnBigslime* this, PlayState* play) {
* then zooms into the Gekko until the Gekko calls the minislimes down from the ceiling
*/
void EnBigslime_UpdateCameraIntroCs(EnBigslime* this, PlayState* play, s32 noticeTimer) {
if (GameInteractor_Should(VB_ENEMY_CUTSCENE_ACTION, true, this)) {
Camera* subCam = Play_GetCamera(play, this->subCamId);
Vec3f subCamEye;
f32 zoom = (noticeTimer * 19.0f) + 67.0f;
s16 yawOffset = this->actor.yawTowardsPlayer + (noticeTimer * 0x31);
if (!GameInteractor_Should(VB_ENEMY_CUTSCENE_ACTION, true, this)) {
return;
}

subCamEye.x = Math_SinS(yawOffset) * zoom + subCam->at.x;
subCamEye.z = Math_CosS(yawOffset) * zoom + subCam->at.z;
subCamEye.y = subCam->at.y + -4.0f + (noticeTimer * 2.0f);
Camera* subCam = Play_GetCamera(play, this->subCamId);
Vec3f subCamEye;
f32 zoom = (noticeTimer * 19.0f) + 67.0f;
s16 yawOffset = this->actor.yawTowardsPlayer + (noticeTimer * 0x31);

Play_SetCameraAtEye(play, this->subCamId, &subCam->at, &subCamEye);
}
subCamEye.x = Math_SinS(yawOffset) * zoom + subCam->at.x;
subCamEye.z = Math_CosS(yawOffset) * zoom + subCam->at.z;
subCamEye.y = subCam->at.y + -4.0f + (noticeTimer * 2.0f);

Play_SetCameraAtEye(play, this->subCamId, &subCam->at, &subCamEye);
}

/**
* Takes the camera and makes the focus point (at) point at bigslime, who is on the
* center of the roof. This is used when the minislimes merges into bigslime.
*/
void EnBigslime_UpdateCameraFormingBigslime(EnBigslime* this, PlayState* play) {
if (GameInteractor_Should(VB_ENEMY_CUTSCENE_ACTION, true, this)) {
Play_SetCameraAtEye(play, this->subCamId, &this->actor.focus.pos, &Play_GetCamera(play, this->subCamId)->eye);
if (!GameInteractor_Should(VB_ENEMY_CUTSCENE_ACTION, true, this)) {
return;
}

Play_SetCameraAtEye(play, this->subCamId, &this->actor.focus.pos, &Play_GetCamera(play, this->subCamId)->eye);
}

void EnBigslime_EndCutscene(EnBigslime* this, PlayState* play) {
Expand Down Expand Up @@ -2377,13 +2381,15 @@ void EnBigslime_CutsceneDefeat(EnBigslime* this, PlayState* play) {
EnBigslime_SetupGekkoDespawn(this, play);
} else {
// Continue for the camera to follow Gekko as it spins in defeat
if (GameInteractor_Should(VB_ENEMY_CUTSCENE_ACTION, true, this)) {
subCam = Play_GetCamera(play, this->subCamId);
subCamAt.x = this->actor.world.pos.x;
subCamAt.y = this->actor.world.pos.y + 40.0f;
subCamAt.z = this->actor.world.pos.z;
Play_SetCameraAtEye(play, this->subCamId, &subCamAt, &subCam->eye);
if (!GameInteractor_Should(VB_ENEMY_CUTSCENE_ACTION, true, this)) {
return;
}

subCam = Play_GetCamera(play, this->subCamId);
subCamAt.x = this->actor.world.pos.x;
subCamAt.y = this->actor.world.pos.y + 40.0f;
subCamAt.z = this->actor.world.pos.z;
Play_SetCameraAtEye(play, this->subCamId, &subCamAt, &subCam->eye);
}
}

Expand Down Expand Up @@ -2418,14 +2424,16 @@ void EnBigslime_GekkoDespawn(EnBigslime* this, PlayState* play) {
if (this->despawnTimer == 0) {
EnBigslime_SetupFrogSpawn(this, play);
} else {
if (GameInteractor_Should(VB_ENEMY_CUTSCENE_ACTION, true, this)) {
subCam = Play_GetCamera(play, this->subCamId);
Math_Vec3f_Copy(&subCamAt, &subCam->at);
Math_Vec3f_Diff(&subCam->eye, &this->subCamDistToFrog, &subCamEye);
subCamEye.y -= 1.8f;
subCamAt.y -= 1.7f;
Play_SetCameraAtEye(play, this->subCamId, &subCamAt, &subCamEye);
if (!GameInteractor_Should(VB_ENEMY_CUTSCENE_ACTION, true, this)) {
return;
}

subCam = Play_GetCamera(play, this->subCamId);
Math_Vec3f_Copy(&subCamAt, &subCam->at);
Math_Vec3f_Diff(&subCam->eye, &this->subCamDistToFrog, &subCamEye);
subCamEye.y -= 1.8f;
subCamAt.y -= 1.7f;
Play_SetCameraAtEye(play, this->subCamId, &subCamAt, &subCamEye);
}
}

Expand Down
42 changes: 23 additions & 19 deletions mm/src/overlays/actors/ovl_En_Pametfrog/z_en_pametfrog.c
Original file line number Diff line number Diff line change
Expand Up @@ -326,30 +326,34 @@ s32 func_8086A2CC(EnPametfrog* this, CollisionPoly* floorPoly) {
}

void EnPametfrog_ShakeCamera(EnPametfrog* this, PlayState* play, f32 magShakeXZ, f32 magShakeY) {
if (GameInteractor_Should(VB_ENEMY_CUTSCENE_ACTION, true, this)) {
Camera* subCam = Play_GetCamera(play, this->subCamId);
s16 subCamYaw;
Vec3f subCamEye;

subCamYaw = BINANG_ROT180(Camera_GetCamDirYaw(subCam));
subCamEye.x = (Math_SinS(subCamYaw) * magShakeXZ) + subCam->at.x;
subCamEye.y = subCam->at.y + magShakeY;
subCamEye.z = (Math_CosS(subCamYaw) * magShakeXZ) + subCam->at.z;
Play_SetCameraAtEye(play, this->subCamId, &subCam->at, &subCamEye);
if (!GameInteractor_Should(VB_ENEMY_CUTSCENE_ACTION, true, this)) {
return;
}

Camera* subCam = Play_GetCamera(play, this->subCamId);
s16 subCamYaw;
Vec3f subCamEye;

subCamYaw = BINANG_ROT180(Camera_GetCamDirYaw(subCam));
subCamEye.x = (Math_SinS(subCamYaw) * magShakeXZ) + subCam->at.x;
subCamEye.y = subCam->at.y + magShakeY;
subCamEye.z = (Math_CosS(subCamYaw) * magShakeXZ) + subCam->at.z;
Play_SetCameraAtEye(play, this->subCamId, &subCam->at, &subCamEye);
}

void EnPametfrog_StopCutscene(EnPametfrog* this, PlayState* play) {
if (GameInteractor_Should(VB_ENEMY_CUTSCENE_ACTION, true, this)) {
Camera* subCam;
if (!GameInteractor_Should(VB_ENEMY_CUTSCENE_ACTION, true, this)) {
return;
}

if (this->subCamId != SUB_CAM_ID_DONE) {
subCam = Play_GetCamera(play, this->subCamId);
Play_SetCameraAtEye(play, CAM_ID_MAIN, &subCam->at, &subCam->eye);
this->subCamId = SUB_CAM_ID_DONE;
CutsceneManager_Stop(this->csId);
Player_SetCsAction(play, &this->actor, PLAYER_CSACTION_END);
}
Camera* subCam;

if (this->subCamId != SUB_CAM_ID_DONE) {
subCam = Play_GetCamera(play, this->subCamId);
Play_SetCameraAtEye(play, CAM_ID_MAIN, &subCam->at, &subCam->eye);
this->subCamId = SUB_CAM_ID_DONE;
CutsceneManager_Stop(this->csId);
Player_SetCsAction(play, &this->actor, PLAYER_CSACTION_END);
}
}

Expand Down
32 changes: 17 additions & 15 deletions mm/src/overlays/actors/ovl_En_Wiz/z_en_wiz.c
Original file line number Diff line number Diff line change
Expand Up @@ -833,22 +833,24 @@ void EnWiz_Dance(EnWiz* this, PlayState* play) {
}

void EnWiz_SetupSecondPhaseCutscene(EnWiz* this, PlayState* play) {
if (GameInteractor_Should(VB_ENEMY_CUTSCENE_ACTION, true, this)) {
s16 secondPhaseCsId = CutsceneManager_GetAdditionalCsId(this->actor.csId);
if (!GameInteractor_Should(VB_ENEMY_CUTSCENE_ACTION, true, this)) {
return;
}

if (!CutsceneManager_IsNext(secondPhaseCsId)) {
CutsceneManager_Queue(secondPhaseCsId);
} else {
CutsceneManager_StartWithPlayerCsAndSetFlag(secondPhaseCsId, &this->actor);
this->subCamId = CutsceneManager_GetCurrentSubCamId(secondPhaseCsId);
this->actor.flags |= ACTOR_FLAG_100000;
EnWiz_ChangeAnim(this, EN_WIZ_ANIM_DANCE, false);
this->action = EN_WIZ_ACTION_RUN_BETWEEN_PLATFORMS;
this->nextPlatformIndex = 1;
this->hasRunToEveryPlatform = false;
Math_SmoothStepToS(&this->alpha, 255, 1, 5, 0);
this->actionFunc = EnWiz_SecondPhaseCutscene;
}
s16 secondPhaseCsId = CutsceneManager_GetAdditionalCsId(this->actor.csId);

if (!CutsceneManager_IsNext(secondPhaseCsId)) {
CutsceneManager_Queue(secondPhaseCsId);
} else {
CutsceneManager_StartWithPlayerCsAndSetFlag(secondPhaseCsId, &this->actor);
this->subCamId = CutsceneManager_GetCurrentSubCamId(secondPhaseCsId);
this->actor.flags |= ACTOR_FLAG_100000;
EnWiz_ChangeAnim(this, EN_WIZ_ANIM_DANCE, false);
this->action = EN_WIZ_ACTION_RUN_BETWEEN_PLATFORMS;
this->nextPlatformIndex = 1;
this->hasRunToEveryPlatform = false;
Math_SmoothStepToS(&this->alpha, 255, 1, 5, 0);
this->actionFunc = EnWiz_SecondPhaseCutscene;
}
}

Expand Down

0 comments on commit 6ba5c8e

Please sign in to comment.