Fix not being able to talk to doors twice (#458)

This commit is contained in:
Sunk 2023-08-18 13:25:39 -04:00 committed by GitHub
parent 31c2e23c48
commit df7e469016
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -119,6 +119,7 @@ static u32 sBackwardKnockbackActions[][3] = {
};
static u8 sDisplayingDoorText = FALSE;
u8 sCanInteractDoor = TRUE;
static u8 sJustTeleported = FALSE;
u8 gPssSlideStarted = FALSE;
extern u8 gLastCollectedStarOrKey;
@ -1088,16 +1089,7 @@ u32 interact_warp(struct MarioState *m, UNUSED u32 interactType, struct Object *
u32 display_door_dialog(struct MarioState *m, u32 actionArg) {
if (!m) { return FALSE; }
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);
return sCanInteractDoor ? set_mario_action(m, ACT_READING_AUTOMATIC_DIALOG, actionArg) : FALSE;
}
u8 prevent_interact_door(struct MarioState* m, struct Object* o) {
@ -1131,6 +1123,7 @@ u32 interact_warp_door(struct MarioState *m, UNUSED u32 interactType, struct Obj
if (!(saveFlags & SAVE_FLAG_HAVE_KEY_2)) {
if (display_door_dialog(m, (saveFlags & SAVE_FLAG_HAVE_KEY_1) ? gBehaviorValues.dialogs.KeyDoor1HaveDialog : gBehaviorValues.dialogs.KeyDoor1DontHaveDialog)) {
sDisplayingDoorText = TRUE;
sCanInteractDoor = FALSE;
}
return FALSE;
}
@ -1142,6 +1135,7 @@ u32 interact_warp_door(struct MarioState *m, UNUSED u32 interactType, struct Obj
if (!(saveFlags & SAVE_FLAG_HAVE_KEY_1)) {
if (display_door_dialog(m, (saveFlags & SAVE_FLAG_HAVE_KEY_2) ? gBehaviorValues.dialogs.KeyDoor2HaveDialog : gBehaviorValues.dialogs.KeyDoor2DontHaveDialog)) {
sDisplayingDoorText = TRUE;
sCanInteractDoor = FALSE;
}
return FALSE;
}
@ -1279,6 +1273,7 @@ u32 interact_door(struct MarioState *m, UNUSED u32 interactType, struct Object *
set_mario_action(m, ACT_ENTERING_STAR_DOOR, should_push_or_pull_door(m, o));
}
sDisplayingDoorText = TRUE;
sCanInteractDoor = FALSE;
return TRUE;
}
}
@ -2349,6 +2344,7 @@ void mario_process_interactions(struct MarioState *m) {
if (!(m->marioObj->collidedObjInteractTypes & (INTERACT_WARP_DOOR | INTERACT_DOOR))) {
sDisplayingDoorText = FALSE;
sCanInteractDoor = TRUE;
}
if (!(m->marioObj->collidedObjInteractTypes & INTERACT_WARP)) {
if (m == &gMarioStates[0]) {