From b2bd29383b4e59728245d6a68891e350df9cd7fe Mon Sep 17 00:00:00 2001 From: MysterD Date: Sat, 26 Sep 2020 19:08:52 -0700 Subject: [PATCH] Continue NPC dialogs after they've started. --- src/game/behaviors/bowser.inc.c | 4 ++-- src/game/behaviors/capswitch.inc.c | 2 +- src/game/behaviors/king_bobomb.inc.c | 13 ++++++++----- src/game/behaviors/koopa.inc.c | 4 ++-- src/game/behaviors/mips.inc.c | 2 +- src/game/behaviors/snowman.inc.c | 4 ++-- src/game/behaviors/whomp.inc.c | 4 ++-- src/game/mario_actions_cutscene.c | 5 +++++ src/game/mario_actions_cutscene.h | 1 + 9 files changed, 24 insertions(+), 15 deletions(-) diff --git a/src/game/behaviors/bowser.inc.c b/src/game/behaviors/bowser.inc.c index 3ccaaf6c..e529f07b 100644 --- a/src/game/behaviors/bowser.inc.c +++ b/src/game/behaviors/bowser.inc.c @@ -942,7 +942,7 @@ s32 bowser_dead_not_bits_end(void) { func_8031FFB4(SEQ_PLAYER_LEVEL, 60, 40); o->oBowserUnkF8++; } - if (marioState->playerIndex == 0 && cur_obj_update_dialog(marioState, 2, 18, sBowserDefeatedDialogText[o->oBehParams2ndByte], 0, bowser_dead_not_bits_end_continue_dialog)) { + if (should_start_or_continue_dialog(marioState, o) && cur_obj_update_dialog(marioState, 2, 18, sBowserDefeatedDialogText[o->oBehParams2ndByte], 0, bowser_dead_not_bits_end_continue_dialog)) { o->oBowserUnkF8++; cur_obj_play_sound_2(SOUND_GENERAL2_BOWSER_EXPLODE); sequence_player_unlower(SEQ_PLAYER_LEVEL, 60); @@ -975,7 +975,7 @@ s32 bowser_dead_bits_end(void) { func_8031FFB4(SEQ_PLAYER_LEVEL, 60, 40); o->oBowserUnkF8++; } - if (marioState->playerIndex == 0 && cur_obj_update_dialog(marioState, 2, 18, dialogID, 0, bowser_dead_bits_end_continue_dialog)) { + if (should_start_or_continue_dialog(marioState, o) && cur_obj_update_dialog(marioState, 2, 18, dialogID, 0, bowser_dead_bits_end_continue_dialog)) { cur_obj_set_model(MODEL_BOWSER2); sequence_player_unlower(SEQ_PLAYER_LEVEL, 60); sequence_player_fade_out(0, 1); diff --git a/src/game/behaviors/capswitch.inc.c b/src/game/behaviors/capswitch.inc.c index 30355828..c8f86f8a 100644 --- a/src/game/behaviors/capswitch.inc.c +++ b/src/game/behaviors/capswitch.inc.c @@ -45,7 +45,7 @@ void cap_switch_act_2(void) { } } else { struct MarioState* marioState = nearest_mario_state_to_object(o); - if (marioState == &gMarioStates[0]) { + if (should_start_or_continue_dialog(marioState, o)) { sp1C = cur_obj_update_dialog_with_cutscene(&gMarioStates[0], 1, 0x0C, CUTSCENE_CAP_SWITCH_PRESS, 0, cap_switch_act_2_continue_dialog); if (sp1C) { o->oAction = 3; } } diff --git a/src/game/behaviors/king_bobomb.inc.c b/src/game/behaviors/king_bobomb.inc.c index b707c488..056128a7 100644 --- a/src/game/behaviors/king_bobomb.inc.c +++ b/src/game/behaviors/king_bobomb.inc.c @@ -50,17 +50,18 @@ void king_bobomb_act_0(void) { o->oForwardVel = 0; o->oVelY = 0; #endif + struct MarioState* marioState = nearest_mario_state_to_object(o); if (o->oSubAction == 0) { cur_obj_become_intangible(); gSecondCameraFocus = o; cur_obj_init_animation_with_sound(5); cur_obj_set_pos_to_home(); o->oHealth = 3; - if (nearest_mario_state_to_object(o) == &gMarioStates[0] && cur_obj_can_mario_activate_textbox_2(&gMarioStates[0], 500.0f, 100.0f)) { + if (should_start_or_continue_dialog(marioState, o) && cur_obj_can_mario_activate_textbox_2(&gMarioStates[0], 500.0f, 100.0f)) { o->oSubAction++; func_8031FFB4(SEQ_PLAYER_LEVEL, 60, 40); } - } else if (nearest_mario_state_to_object(o) == &gMarioStates[0] && cur_obj_update_dialog_with_cutscene(&gMarioStates[0], 2, 1, CUTSCENE_DIALOG, DIALOG_017, king_bobomb_act_0_continue_dialog)) { + } else if (should_start_or_continue_dialog(marioState, o) && cur_obj_update_dialog_with_cutscene(&gMarioStates[0], 2, 1, CUTSCENE_DIALOG, DIALOG_017, king_bobomb_act_0_continue_dialog)) { o->oAction = 2; o->oFlags |= OBJ_FLAG_HOLDABLE; } @@ -216,7 +217,8 @@ u8 king_bobomb_act_7_continue_dialog(void) { return o->oAction == 7; } void king_bobomb_act_7(void) { cur_obj_init_animation_with_sound(2); - u8 updateDialog = (nearest_mario_state_to_object(o) == &gMarioStates[0]) || (gMarioStates[0].pos[1] >= o->oPosY - 100.0f); + struct MarioState* marioState = nearest_mario_state_to_object(o); + u8 updateDialog = should_start_or_continue_dialog(marioState, o) || (gMarioStates[0].pos[1] >= o->oPosY - 100.0f); if (updateDialog && cur_obj_update_dialog_with_cutscene(&gMarioStates[0], 2, 2, CUTSCENE_DIALOG, DIALOG_116, king_bobomb_act_7_continue_dialog)) { o->oAction = 8; network_send_object(o); @@ -273,6 +275,7 @@ void king_bobomb_act_4(void) { // bobomb been thrown u8 king_bobomb_act_5_continue_dialog(void) { return o->oAction == 5 && o->oSubAction == 4; } void king_bobomb_act_5(void) { // bobomb returns home + struct MarioState* marioState = nearest_mario_state_to_object(o); switch (o->oSubAction) { case 0: if (o->oTimer == 0) @@ -310,11 +313,11 @@ void king_bobomb_act_5(void) { // bobomb returns home o->oAction = 0; stop_background_music(SEQUENCE_ARGS(4, SEQ_EVENT_BOSS)); } - if (nearest_mario_state_to_object(o) == &gMarioStates[0] && cur_obj_can_mario_activate_textbox_2(&gMarioStates[0], 500.0f, 100.0f)) + if (should_start_or_continue_dialog(marioState, o) && cur_obj_can_mario_activate_textbox_2(&gMarioStates[0], 500.0f, 100.0f)) o->oSubAction++; break; case 4: - if (nearest_mario_state_to_object(o) == &gMarioStates[0] && cur_obj_update_dialog_with_cutscene(&gMarioStates[0], 2, 1, CUTSCENE_DIALOG, DIALOG_128, king_bobomb_act_5_continue_dialog)) + if (should_start_or_continue_dialog(marioState, o) && cur_obj_update_dialog_with_cutscene(&gMarioStates[0], 2, 1, CUTSCENE_DIALOG, DIALOG_128, king_bobomb_act_5_continue_dialog)) o->oAction = 2; break; } diff --git a/src/game/behaviors/koopa.inc.c b/src/game/behaviors/koopa.inc.c index 4890f7b0..39012f6a 100644 --- a/src/game/behaviors/koopa.inc.c +++ b/src/game/behaviors/koopa.inc.c @@ -588,7 +588,7 @@ u8 koopa_the_quick_act_show_init_text_continue_dialog(void) { return o->oAction static void koopa_the_quick_act_show_init_text(void) { struct MarioState* marioState = nearest_mario_state_to_object(o); s32 response = 0; - if (marioState == &gMarioStates[0]) { + if (should_start_or_continue_dialog(marioState, o)) { response = obj_update_race_proposition_dialog(&gMarioStates[0], sKoopaTheQuickProperties[o->oKoopaTheQuickRaceIndex].initText, koopa_the_quick_act_show_init_text_continue_dialog); } @@ -814,7 +814,7 @@ static void koopa_the_quick_act_after_race(void) { o->oFlags &= ~OBJ_FLAG_ACTIVE_FROM_AFAR; } } else if (o->parentObj->oKoopaRaceEndpointUnk100 > 0) { - if (marioState == &gMarioStates[0]) { + if (should_start_or_continue_dialog(marioState, o)) { s32 dialogResponse = cur_obj_update_dialog_with_cutscene(&gMarioStates[0], 2, 1, CUTSCENE_DIALOG, o->parentObj->oKoopaRaceEndpointUnk100, koopa_the_quick_act_after_race_continue_dialog); if (dialogResponse != 0) { o->parentObj->oKoopaRaceEndpointUnk100 = -1; diff --git a/src/game/behaviors/mips.inc.c b/src/game/behaviors/mips.inc.c index 33b2543d..c760ba44 100644 --- a/src/game/behaviors/mips.inc.c +++ b/src/game/behaviors/mips.inc.c @@ -268,7 +268,7 @@ void bhv_mips_held(void) { else dialogID = DIALOG_162; - if (o->heldByPlayerIndex == 0 && set_mario_npc_dialog(&gMarioStates[0], 1, bhv_mips_held_continue_dialog) == 2) { + if (should_start_or_continue_dialog(&gMarioStates[o->heldByPlayerIndex], o) && set_mario_npc_dialog(&gMarioStates[0], 1, bhv_mips_held_continue_dialog) == 2) { //o->activeFlags |= ACTIVE_FLAG_INITIATED_TIME_STOP; if (cutscene_object_with_dialog(CUTSCENE_DIALOG, o, dialogID)) { o->oInteractionSubtype |= INT_SUBTYPE_DROP_IMMEDIATELY; diff --git a/src/game/behaviors/snowman.inc.c b/src/game/behaviors/snowman.inc.c index 6e159b3d..718a2154 100644 --- a/src/game/behaviors/snowman.inc.c +++ b/src/game/behaviors/snowman.inc.c @@ -132,11 +132,11 @@ static u8 bhv_snowmans_bottom_loop_continue_dialog(void) { void bhv_snowmans_bottom_loop(void) { s16 sp1E; - int distanceToLocal = dist_between_objects(o, gMarioStates[0].marioObj); + struct MarioState* marioState = nearest_mario_state_to_object(o); switch (o->oAction) { case 0: - if (distanceToLocal < 400 && set_mario_npc_dialog(&gMarioStates[0], 1, bhv_snowmans_bottom_loop_continue_dialog) == 2) { + if (should_start_or_continue_dialog(marioState, o) && set_mario_npc_dialog(&gMarioStates[0], 1, bhv_snowmans_bottom_loop_continue_dialog) == 2) { sp1E = cutscene_object_with_dialog(CUTSCENE_DIALOG, o, DIALOG_110); if (sp1E) { o->oForwardVel = 10.0f; diff --git a/src/game/behaviors/whomp.inc.c b/src/game/behaviors/whomp.inc.c index eab8c8fd..6ae73177 100644 --- a/src/game/behaviors/whomp.inc.c +++ b/src/game/behaviors/whomp.inc.c @@ -34,7 +34,7 @@ void whomp_act_0(void) { cur_obj_set_pos_to_home(); o->oHealth = 3; } - } else if (marioState == &gMarioStates[0] && cur_obj_update_dialog_with_cutscene(&gMarioStates[0], 2, 1, CUTSCENE_DIALOG, DIALOG_114, whomp_act_0_continue_dialog)) { + } else if (should_start_or_continue_dialog(marioState, o) && cur_obj_update_dialog_with_cutscene(&gMarioStates[0], 2, 1, CUTSCENE_DIALOG, DIALOG_114, whomp_act_0_continue_dialog)) { o->oAction = 2; network_send_object(o); } @@ -233,7 +233,7 @@ u8 whomp_act_8_continue_dialog(void) { return o->oAction == 8; } void whomp_act_8(void) { if (o->oBehParams2ndByte != 0) { struct MarioState* marioState = nearest_mario_state_to_object(o); - if (marioState == &gMarioStates[0] && cur_obj_update_dialog_with_cutscene(&gMarioStates[0], 2, 2, CUTSCENE_DIALOG, DIALOG_115, whomp_act_8_continue_dialog)) { + if (should_start_or_continue_dialog(marioState, o) && cur_obj_update_dialog_with_cutscene(&gMarioStates[0], 2, 2, CUTSCENE_DIALOG, DIALOG_115, whomp_act_8_continue_dialog)) { obj_set_angle(o, 0, 0, 0); cur_obj_hide(); cur_obj_become_intangible(); diff --git a/src/game/mario_actions_cutscene.c b/src/game/mario_actions_cutscene.c index e562dc62..4240a661 100644 --- a/src/game/mario_actions_cutscene.c +++ b/src/game/mario_actions_cutscene.c @@ -349,6 +349,11 @@ s32 mario_ready_to_speak(struct MarioState* m) { return isReadyToSpeak; } +u8 should_start_or_continue_dialog(struct MarioState* m, struct Object* object) { + if (m->playerIndex == 0) { return TRUE; } + return (gContinueDialogFunctionObject == object); +} + // (can) place Mario in dialog? // initiate dialog? // return values: diff --git a/src/game/mario_actions_cutscene.h b/src/game/mario_actions_cutscene.h index d6d43c3f..73143d01 100644 --- a/src/game/mario_actions_cutscene.h +++ b/src/game/mario_actions_cutscene.h @@ -11,6 +11,7 @@ void bhv_end_peach_loop(void); void bhv_end_toad_loop(void); s32 geo_switch_peach_eyes(s32 run, struct GraphNode *node, UNUSED s32 a2); s32 mario_ready_to_speak(struct MarioState* m); +u8 should_start_or_continue_dialog(struct MarioState* m, struct Object* object); s32 set_mario_npc_dialog(struct MarioState* m, s32 actionArg, u8(*inContinueDialogFunction)(void)); s32 mario_execute_cutscene_action(struct MarioState *m);