From d00945ec81710e13a6cb62bccfd7574d108f6b7e Mon Sep 17 00:00:00 2001 From: MysterD Date: Mon, 7 Sep 2020 16:35:42 -0700 Subject: [PATCH] Allow other player to pass through door when it's being opened Also disable the 'walking through door' cutscene when newcam is on --- src/game/behaviors/door.inc.c | 51 +++++++++++++++++++------------ src/game/interaction.c | 2 ++ src/game/mario_actions_cutscene.c | 2 +- 3 files changed, 35 insertions(+), 20 deletions(-) diff --git a/src/game/behaviors/door.inc.c b/src/game/behaviors/door.inc.c index e8e04461..3744f149 100644 --- a/src/game/behaviors/door.inc.c +++ b/src/game/behaviors/door.inc.c @@ -14,11 +14,24 @@ s32 D_8032F330[] = { SOUND_GENERAL_CLOSE_WOOD_DOOR, SOUND_GENERAL_CLOSE_IRON_DOO void door_animation_and_reset(s32 sp18) { cur_obj_init_animation_with_sound(sp18); - if (cur_obj_check_if_near_animation_end()) + if (cur_obj_check_if_near_animation_end()) { o->oAction = 0; + } +} + +u8 door_allow_walk_through(void) { + if (gCurrCourseNum != COURSE_NONE && gMarioStates[0].action == ACT_BUBBLED) { return TRUE; } + if (o->oAction == 0 || o->oAction > 2) { return FALSE; } + s32 cur = o->header.gfx.unk38.animFrame; + s32 max = o->header.gfx.unk38.curAnim->unk08 - 2; + return (cur >= max / 4 && cur <= 7 * max / 8); } void set_door_camera_event(void) { + if (gCamera->mode == CAMERA_MODE_NEWCAM) { + return; + } + if (segmented_to_virtual(bhvDoor) == o->behavior) gPlayerCameraState->cameraEvent = CAM_EVENT_DOOR; else @@ -46,20 +59,22 @@ void play_warp_door_open_noise(void) { void bhv_door_loop(void) { s32 sp1C = 0; - while (D_8032F300[sp1C].flag != (u32)~0) { - if (cur_obj_clear_interact_status_flag(D_8032F300[sp1C].flag)) { - if (gMarioStates[0].usedObj == o) { - u32 marioAction = gMarioStates[0].marioBodyState->action; - u8 inActDoor = marioAction == ACT_PULLING_DOOR - || marioAction == ACT_PUSHING_DOOR - || marioAction == ACT_WARP_DOOR_SPAWN; - if (inActDoor) { - set_door_camera_event(); + if (o->oAction != 100) { + while (D_8032F300[sp1C].flag != (u32)~0) { + if (cur_obj_clear_interact_status_flag(D_8032F300[sp1C].flag)) { + if (gMarioStates[0].usedObj == o) { + u32 marioAction = gMarioStates[0].marioBodyState->action; + u8 inActDoor = marioAction == ACT_PULLING_DOOR + || marioAction == ACT_PUSHING_DOOR + || marioAction == ACT_WARP_DOOR_SPAWN; + if (inActDoor) { + set_door_camera_event(); + } } + cur_obj_change_action(D_8032F300[sp1C].action); } - cur_obj_change_action(D_8032F300[sp1C].action); + sp1C++; } - sp1C++; } switch (o->oAction) { @@ -85,13 +100,11 @@ void bhv_door_loop(void) { } // make doors intangible when you're bubbled - if (o->oAction == 0) { - if (gCurrCourseNum != COURSE_NONE && gMarioStates[0].action == ACT_BUBBLED) { - o->oIntangibleTimer = -1; - } else { - load_object_collision_model(); - o->oIntangibleTimer = 0; - } + if (door_allow_walk_through()) { + o->oIntangibleTimer = -1; + } else { + load_object_collision_model(); + o->oIntangibleTimer = 0; } bhv_star_door_loop_2(); } diff --git a/src/game/interaction.c b/src/game/interaction.c index d5b23b09..afc28ea8 100644 --- a/src/game/interaction.c +++ b/src/game/interaction.c @@ -1059,6 +1059,8 @@ u32 interact_door(struct MarioState *m, UNUSED u32 interactType, struct Object * s16 requiredNumStars = o->oBehParams >> 24; s16 numStars = save_file_get_total_star_count(gCurrSaveFileNum - 1, COURSE_MIN - 1, COURSE_MAX - 1); + if (o->oAction != 0) { return FALSE; } + if (m->action == ACT_WALKING || m->action == ACT_DECELERATING) { if (numStars >= requiredNumStars) { u32 actionArg = should_push_or_pull_door(m, o); diff --git a/src/game/mario_actions_cutscene.c b/src/game/mario_actions_cutscene.c index b16d339a..91b3ddfd 100644 --- a/src/game/mario_actions_cutscene.c +++ b/src/game/mario_actions_cutscene.c @@ -1036,7 +1036,7 @@ s32 act_warp_door_spawn(struct MarioState *m) { m->usedObj->oInteractStatus = 0x00080000; } } - } else if (m->usedObj == NULL || m->usedObj->oAction == 0) { + } else if (m->usedObj == NULL || (m->usedObj->oAction == 0 || m->usedObj->oAction == 100)) { if (gShouldNotPlayCastleMusic == TRUE && gCurrLevelNum == LEVEL_CASTLE) { set_mario_action(m, ACT_READING_AUTOMATIC_DIALOG, DIALOG_021); } else {