Freeze mario in place when star spawning or dialog box pops up

This commit is contained in:
MysterD 2020-08-12 21:47:07 -07:00
parent 6e4c39eabe
commit 6629b5493d
6 changed files with 31 additions and 6 deletions

View file

@ -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

View file

@ -70,7 +70,10 @@ void slow_star_rotation(void) {
void bhv_spawned_star_loop(void) {
if (o->oAction == 0) {
if (o->oTimer == 0) {
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++;

View file

@ -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 (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;

View file

@ -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]);

View file

@ -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.
*/

View file

@ -20,7 +20,6 @@
#include "profiler.h"
#include "spawn_object.h"
/**
* Flags controlling what debug info is displayed.
*/