diff --git a/src/game/behavior_actions.c b/src/game/behavior_actions.c index 7948e249f..21d459765 100644 --- a/src/game/behavior_actions.c +++ b/src/game/behavior_actions.c @@ -93,6 +93,8 @@ struct OpenableGrill { const Collision *collision; }; +extern u16 gFreezeMario; + s32 D_8032F0C0[] = { SAVE_FLAG_HAVE_WING_CAP, SAVE_FLAG_HAVE_METAL_CAP, SAVE_FLAG_HAVE_VANISH_CAP }; // Boo Roll diff --git a/src/game/behaviors/sparkle_spawn_star.inc.c b/src/game/behaviors/sparkle_spawn_star.inc.c index fea2651d1..7130fb84f 100644 --- a/src/game/behaviors/sparkle_spawn_star.inc.c +++ b/src/game/behaviors/sparkle_spawn_star.inc.c @@ -70,7 +70,10 @@ void slow_star_rotation(void) { void bhv_spawned_star_loop(void) { if (o->oAction == 0) { if (o->oTimer == 0) { - cutscene_object(CUTSCENE_STAR_SPAWN, o); + if (nearest_mario_state_to_object(o) == &gMarioStates[0]) { + cutscene_object(CUTSCENE_STAR_SPAWN, o); + gFreezeMario = 1000; + } //set_time_stop_flags(TIME_STOP_ENABLED | TIME_STOP_MARIO_AND_DOORS); //o->activeFlags |= ACTIVE_FLAG_INITIATED_TIME_STOP; o->oAngleVelYaw = 0x800; @@ -111,6 +114,7 @@ void bhv_spawned_star_loop(void) { spawn_object(o, MODEL_NONE, bhvSparkleSpawn); } else if (o->oAction == 2) { if (gCamera->cutscene == 0 && gRecentCutscene == 0) { + gFreezeMario = 0; clear_time_stop_flags(TIME_STOP_ENABLED | TIME_STOP_MARIO_AND_DOORS); o->activeFlags &= ~ACTIVE_FLAG_INITIATED_TIME_STOP; o->oAction++; diff --git a/src/game/behaviors/spawn_star.inc.c b/src/game/behaviors/spawn_star.inc.c index 6a36841a0..a36b1126b 100644 --- a/src/game/behaviors/spawn_star.inc.c +++ b/src/game/behaviors/spawn_star.inc.c @@ -42,10 +42,13 @@ void bhv_star_spawn_init(void) { o->oVelY = (o->oHomeY - o->oPosY) / 30.0f; o->oForwardVel = o->oStarSpawnDisFromHome / 30.0f; o->oStarSpawnUnkFC = o->oPosY; - if (o->oBehParams2ndByte == 0 || gCurrCourseNum == COURSE_BBH) - cutscene_object(CUTSCENE_STAR_SPAWN, o); - else - cutscene_object(CUTSCENE_RED_COIN_STAR_SPAWN, o); + if (nearest_mario_state_to_object(o) == &gMarioStates[0]) { + if (o->oBehParams2ndByte == 0 || gCurrCourseNum == COURSE_BBH) + cutscene_object(CUTSCENE_STAR_SPAWN, o); + else + cutscene_object(CUTSCENE_RED_COIN_STAR_SPAWN, o); + gFreezeMario = 1000; + } //set_time_stop_flags(TIME_STOP_ENABLED | TIME_STOP_MARIO_AND_DOORS); //o->activeFlags |= ACTIVE_FLAG_INITIATED_TIME_STOP; @@ -96,6 +99,7 @@ void bhv_star_spawn_loop(void) { case 3: o->oFaceAngleYaw += 0x800; if (o->oTimer == 20) { + gFreezeMario = 0; gObjCutsceneDone = TRUE; clear_time_stop_flags(TIME_STOP_ENABLED | TIME_STOP_MARIO_AND_DOORS); o->activeFlags &= ~ACTIVE_FLAG_INITIATED_TIME_STOP; diff --git a/src/game/mario.c b/src/game/mario.c index 4d837d216..487c2eefc 100644 --- a/src/game/mario.c +++ b/src/game/mario.c @@ -40,6 +40,8 @@ #include "bettercamera.h" #endif +u16 gFreezeMario = 0; + u32 unused80339F10; s8 filler80339F1C[20]; @@ -1783,10 +1785,21 @@ s32 execute_mario_action(UNUSED struct Object *o) { return 0; } + // don't update mario when in a cutscene + if (gMarioState->playerIndex == 0) { + extern s16 gDialogID; + if (gFreezeMario > 0) { gFreezeMario--; } + if (gFreezeMario < 1 && gDialogID != -1) { gFreezeMario = 1; } + } + // The function can loop through many action shifts in one frame, // which can lead to unexpected sub-frame behavior. Could potentially hang // if a loop of actions were found, but there has not been a situation found. while (inLoop) { + // don't update mario when in a cutscene + if (gMarioState->playerIndex == 0 && gFreezeMario > 0 && (gMarioState->action & ACT_GROUP_MASK) != ACT_GROUP_CUTSCENE) { + break; + } switch (gMarioState->action & ACT_GROUP_MASK) { case ACT_GROUP_STATIONARY: inLoop = mario_execute_stationary_action(gMarioState); @@ -1856,6 +1869,7 @@ s32 execute_mario_action(UNUSED struct Object *o) { **************************************************/ void init_mario(void) { + gFreezeMario = 0; gInsidePainting = false; bool isLocal = (gMarioState == &gMarioStates[0]); diff --git a/src/game/obj_behaviors.c b/src/game/obj_behaviors.c index d433bf003..b0d647ef9 100644 --- a/src/game/obj_behaviors.c +++ b/src/game/obj_behaviors.c @@ -47,6 +47,8 @@ #define OBJ_COL_FLAG_NO_Y_VEL (1 << 3) #define OBJ_COL_FLAGS_LANDED (OBJ_COL_FLAG_GROUNDED | OBJ_COL_FLAG_NO_Y_VEL) +extern u16 gFreezeMario; + /** * Current object floor as defined in object_step. */ diff --git a/src/game/object_list_processor.c b/src/game/object_list_processor.c index 175581681..f1d6f02fd 100644 --- a/src/game/object_list_processor.c +++ b/src/game/object_list_processor.c @@ -20,7 +20,6 @@ #include "profiler.h" #include "spawn_object.h" - /** * Flags controlling what debug info is displayed. */