Dialog to toad/signs/doors no longer soft-locks or stops time

This commit is contained in:
MysterD 2020-08-03 23:23:09 -07:00
parent ec2199892f
commit 6d0d7ffbaa
6 changed files with 53 additions and 34 deletions

View file

@ -30,7 +30,7 @@ void play_door_open_noise(void) {
s32 sp1C = cur_obj_has_model(MODEL_HMC_METAL_DOOR);
if (o->oTimer == 0) {
cur_obj_play_sound_2(D_8032F328[sp1C]);
gTimeStopState |= TIME_STOP_MARIO_OPENED_DOOR;
//gTimeStopState |= TIME_STOP_MARIO_OPENED_DOOR;
}
if (o->oTimer == 70) {
cur_obj_play_sound_2(D_8032F330[sp1C]);

View file

@ -186,10 +186,10 @@ void hoot_action_loop(void) {
o->oMoveAnglePitch = 0x71C;
if (o->oPosY < 2700.0f) {
set_time_stop_flags(TIME_STOP_ENABLED | TIME_STOP_MARIO_AND_DOORS);
//set_time_stop_flags(TIME_STOP_ENABLED | TIME_STOP_MARIO_AND_DOORS);
if (cutscene_object_with_dialog(CUTSCENE_DIALOG, o, DIALOG_045)) {
clear_time_stop_flags(TIME_STOP_ENABLED | TIME_STOP_MARIO_AND_DOORS);
//clear_time_stop_flags(TIME_STOP_ENABLED | TIME_STOP_MARIO_AND_DOORS);
o->oAction = HOOT_ACT_TIRED;
}

View file

@ -8973,7 +8973,7 @@ BAD_RETURN(s32) cutscene_dialog_start(struct Camera *c) {
cutscene_soften_music(c);
set_time_stop_flags(TIME_STOP_ENABLED | TIME_STOP_DIALOG);
//set_time_stop_flags(TIME_STOP_ENABLED | TIME_STOP_DIALOG);
#ifndef VERSION_JP
if (c->mode == CAMERA_MODE_BOSS_FIGHT) {
@ -9092,7 +9092,7 @@ BAD_RETURN(s32) cutscene_dialog_set_flag(UNUSED struct Camera *c) {
BAD_RETURN(s32) cutscene_dialog_end(struct Camera *c) {
sStatusFlags |= CAM_FLAG_UNUSED_CUTSCENE_ACTIVE;
c->cutscene = 0;
clear_time_stop_flags(TIME_STOP_ENABLED | TIME_STOP_DIALOG);
//clear_time_stop_flags(TIME_STOP_ENABLED | TIME_STOP_DIALOG);
}
/**
@ -9135,7 +9135,7 @@ BAD_RETURN(s32) cutscene_read_message(struct Camera *c) {
case 0:
if (get_dialog_id() != -1) {
sCutsceneVars[0].angle[0] += 1;
set_time_stop_flags(TIME_STOP_ENABLED | TIME_STOP_DIALOG);
//set_time_stop_flags(TIME_STOP_ENABLED | TIME_STOP_DIALOG);
}
break;
// Leave the dialog.
@ -9150,7 +9150,7 @@ BAD_RETURN(s32) cutscene_read_message(struct Camera *c) {
retrieve_info_star(c);
transition_next_state(c, 15);
sStatusFlags |= CAM_FLAG_UNUSED_CUTSCENE_ACTIVE;
clear_time_stop_flags(TIME_STOP_ENABLED | TIME_STOP_DIALOG);
//clear_time_stop_flags(TIME_STOP_ENABLED | TIME_STOP_DIALOG);
// Retrieve previous state
sCUpCameraPitch = sCutsceneVars[1].angle[0];
sModeOffsetYaw = sCutsceneVars[1].angle[1];

View file

@ -1,4 +1,5 @@
#include <PR/ultratypes.h>
#include <string.h>
#include "area.h"
#include "actors/common1.h"
@ -896,6 +897,20 @@ u32 interact_warp(struct MarioState *m, UNUSED u32 interactType, struct Object *
return FALSE;
}
u32 display_door_dialog(struct MarioState *m, u32 actionArg) {
if (m != &gMarioStates[0]) { return FALSE; }
// ugly hack: save the last place we opened a dialog to prevent dialog spam
static f32 lastDialogPosition[3] = { 0 };
f32 dx = m->pos[0] - lastDialogPosition[0]; dx *= dx;
f32 dy = m->pos[1] - lastDialogPosition[1]; dy *= dy;
f32 dz = m->pos[2] - lastDialogPosition[2]; dz *= dz;
f32 dist = sqrt(dx + dy + dz);
if (dist < 300) { return FALSE; }
memcpy(lastDialogPosition, &m->pos[0], sizeof(f32) * 3);
return set_mario_action(m, ACT_READING_AUTOMATIC_DIALOG, actionArg);
}
u32 interact_warp_door(struct MarioState *m, UNUSED u32 interactType, struct Object *o) {
u32 doorAction = 0;
u32 saveFlags = save_file_get_flags();
@ -905,12 +920,9 @@ u32 interact_warp_door(struct MarioState *m, UNUSED u32 interactType, struct Obj
if (m->action == ACT_WALKING || m->action == ACT_DECELERATING) {
if (warpDoorId == 1 && !(saveFlags & SAVE_FLAG_UNLOCKED_UPSTAIRS_DOOR)) {
if (!(saveFlags & SAVE_FLAG_HAVE_KEY_2)) {
if (!sDisplayingDoorText) {
set_mario_action(m, ACT_READING_AUTOMATIC_DIALOG,
(saveFlags & SAVE_FLAG_HAVE_KEY_1) ? DIALOG_023 : DIALOG_022);
if (display_door_dialog(m, (saveFlags & SAVE_FLAG_HAVE_KEY_1) ? DIALOG_023 : DIALOG_022)) {
sDisplayingDoorText = TRUE;
}
sDisplayingDoorText = TRUE;
return FALSE;
}
@ -919,13 +931,9 @@ u32 interact_warp_door(struct MarioState *m, UNUSED u32 interactType, struct Obj
if (warpDoorId == 2 && !(saveFlags & SAVE_FLAG_UNLOCKED_BASEMENT_DOOR)) {
if (!(saveFlags & SAVE_FLAG_HAVE_KEY_1)) {
if (!sDisplayingDoorText) {
// Moat door skip was intended confirmed
set_mario_action(m, ACT_READING_AUTOMATIC_DIALOG,
(saveFlags & SAVE_FLAG_HAVE_KEY_2) ? DIALOG_023 : DIALOG_022);
if (display_door_dialog(m, (saveFlags & SAVE_FLAG_HAVE_KEY_2) ? DIALOG_023 : DIALOG_022)) {
sDisplayingDoorText = TRUE;
}
sDisplayingDoorText = TRUE;
return FALSE;
}
@ -1047,8 +1055,10 @@ u32 interact_door(struct MarioState *m, UNUSED u32 interactType, struct Object *
text += requiredNumStars - numStars;
sDisplayingDoorText = TRUE;
return set_mario_action(m, ACT_READING_AUTOMATIC_DIALOG, text);
if (display_door_dialog(m, text)) {
sDisplayingDoorText = TRUE;
return TRUE;
}
}
} else if (m->action == ACT_IDLE && sDisplayingDoorText == TRUE && requiredNumStars == 70) {
m->interactObj = o;

View file

@ -395,7 +395,7 @@ s32 act_reading_npc_dialog(struct MarioState *m) {
headTurnAmount = 384;
}
if (m->actionState < 8) {
if (m->actionState < 8 && m->usedObj != NULL) {
// turn to NPC
angleToNPC = mario_obj_angle_to_object(m, m->usedObj);
m->faceAngle[1] =
@ -454,7 +454,7 @@ s32 act_reading_automatic_dialog(struct MarioState *m) {
m->actionState++;
if (m->actionState == 2) {
enable_time_stop();
//enable_time_stop();
}
if (m->actionState < 9) {
set_mario_animation(m, m->prevAction == ACT_STAR_DANCE_WATER ? MARIO_ANIM_WATER_IDLE
@ -464,11 +464,15 @@ s32 act_reading_automatic_dialog(struct MarioState *m) {
} else {
// set Mario dialog
if (m->actionState == 9) {
actionArg = m->actionArg;
if (GET_HIGH_U16_OF_32(actionArg) == 0) {
create_dialog_box(GET_LOW_U16_OF_32(actionArg));
} else {
create_dialog_box_with_var(GET_HIGH_U16_OF_32(actionArg), GET_LOW_U16_OF_32(actionArg));
// only show dialog for local player
if (m == &gMarioStates[0]) {
actionArg = m->actionArg;
if (GET_HIGH_U16_OF_32(actionArg) == 0) {
create_dialog_box(GET_LOW_U16_OF_32(actionArg));
}
else {
create_dialog_box_with_var(GET_HIGH_U16_OF_32(actionArg), GET_LOW_U16_OF_32(actionArg));
}
}
}
// wait until dialog is done
@ -483,7 +487,7 @@ s32 act_reading_automatic_dialog(struct MarioState *m) {
}
// finished action
else if (m->actionState == 25) {
disable_time_stop();
//disable_time_stop();
if (gShouldNotPlayCastleMusic) {
gShouldNotPlayCastleMusic = FALSE;
play_cutscene_music(SEQUENCE_ARGS(0, SEQ_LEVEL_INSIDE_CASTLE));
@ -503,6 +507,7 @@ s32 act_reading_automatic_dialog(struct MarioState *m) {
}
s32 act_reading_sign(struct MarioState *m) {
struct Object *marioObj = m->marioObj;
play_sound_if_no_flag(m, SOUND_ACTION_READ_SIGN, MARIO_ACTION_SOUND_PLAYED);
@ -510,8 +515,10 @@ s32 act_reading_sign(struct MarioState *m) {
switch (m->actionState) {
// start dialog
case 0:
trigger_cutscene_dialog(1);
enable_time_stop();
if (m == &gMarioStates[0]) {
trigger_cutscene_dialog(1);
}
//enable_time_stop();
// reading sign
set_mario_animation(m, MARIO_ANIM_FIRST_PERSON);
m->actionState = 1;
@ -523,7 +530,9 @@ s32 act_reading_sign(struct MarioState *m) {
m->pos[2] += marioObj->oMarioReadingSignDPosZ / 11.0f;
// create the text box
if (m->actionTimer++ == 10) {
create_dialog_inverted_box(m->usedObj->oBehParams2ndByte);
if (m == &gMarioStates[0]) {
create_dialog_inverted_box(m->usedObj->oBehParams2ndByte);
}
m->actionState = 2;
}
break;
@ -531,7 +540,7 @@ s32 act_reading_sign(struct MarioState *m) {
case 2:
// dialog finished
if (gCamera->cutscene == 0) {
disable_time_stop();
//disable_time_stop();
set_mario_action(m, ACT_IDLE, 0);
}
break;

View file

@ -2632,7 +2632,7 @@ s32 cur_obj_update_dialog(s32 actionArg, s32 dialogFlags, s32 dialogID, UNUSED s
// Patched :(
// Wait for Mario to be ready to speak, and then enable time stop
if (mario_ready_to_speak() || gMarioState->action == ACT_READING_NPC_DIALOG) {
gTimeStopState |= TIME_STOP_ENABLED;
//gTimeStopState |= TIME_STOP_ENABLED;
o->activeFlags |= ACTIVE_FLAG_INITIATED_TIME_STOP;
o->oDialogState++;
} else {
@ -2709,7 +2709,7 @@ s32 cur_obj_update_dialog_with_cutscene(s32 actionArg, s32 dialogFlags, s32 cuts
case DIALOG_UNK2_ENABLE_TIME_STOP:
// Wait for Mario to be ready to speak, and then enable time stop
if (mario_ready_to_speak() || gMarioState->action == ACT_READING_NPC_DIALOG) {
gTimeStopState |= TIME_STOP_ENABLED;
//gTimeStopState |= TIME_STOP_ENABLED;
o->activeFlags |= ACTIVE_FLAG_INITIATED_TIME_STOP;
o->oDialogState++;
o->oDialogResponse = 0;