Fix not being able to talk to doors twice (#458)
This commit is contained in:
parent
cdc1b30c6f
commit
a976077697
|
@ -119,6 +119,7 @@ static u32 sBackwardKnockbackActions[][3] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static u8 sDisplayingDoorText = FALSE;
|
static u8 sDisplayingDoorText = FALSE;
|
||||||
|
u8 sCanInteractDoor = TRUE;
|
||||||
static u8 sJustTeleported = FALSE;
|
static u8 sJustTeleported = FALSE;
|
||||||
u8 gPssSlideStarted = FALSE;
|
u8 gPssSlideStarted = FALSE;
|
||||||
extern u8 gLastCollectedStarOrKey;
|
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) {
|
u32 display_door_dialog(struct MarioState *m, u32 actionArg) {
|
||||||
if (!m) { return FALSE; }
|
if (!m) { return FALSE; }
|
||||||
if (m != &gMarioStates[0]) { return FALSE; }
|
if (m != &gMarioStates[0]) { return FALSE; }
|
||||||
// ugly hack: save the last place we opened a dialog to prevent dialog spam
|
return sCanInteractDoor ? set_mario_action(m, ACT_READING_AUTOMATIC_DIALOG, actionArg) : FALSE;
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
u8 prevent_interact_door(struct MarioState* m, struct Object* o) {
|
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 (!(saveFlags & SAVE_FLAG_HAVE_KEY_2)) {
|
||||||
if (display_door_dialog(m, (saveFlags & SAVE_FLAG_HAVE_KEY_1) ? gBehaviorValues.dialogs.KeyDoor1HaveDialog : gBehaviorValues.dialogs.KeyDoor1DontHaveDialog)) {
|
if (display_door_dialog(m, (saveFlags & SAVE_FLAG_HAVE_KEY_1) ? gBehaviorValues.dialogs.KeyDoor1HaveDialog : gBehaviorValues.dialogs.KeyDoor1DontHaveDialog)) {
|
||||||
sDisplayingDoorText = TRUE;
|
sDisplayingDoorText = TRUE;
|
||||||
|
sCanInteractDoor = FALSE;
|
||||||
}
|
}
|
||||||
return 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 (!(saveFlags & SAVE_FLAG_HAVE_KEY_1)) {
|
||||||
if (display_door_dialog(m, (saveFlags & SAVE_FLAG_HAVE_KEY_2) ? gBehaviorValues.dialogs.KeyDoor2HaveDialog : gBehaviorValues.dialogs.KeyDoor2DontHaveDialog)) {
|
if (display_door_dialog(m, (saveFlags & SAVE_FLAG_HAVE_KEY_2) ? gBehaviorValues.dialogs.KeyDoor2HaveDialog : gBehaviorValues.dialogs.KeyDoor2DontHaveDialog)) {
|
||||||
sDisplayingDoorText = TRUE;
|
sDisplayingDoorText = TRUE;
|
||||||
|
sCanInteractDoor = FALSE;
|
||||||
}
|
}
|
||||||
return 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));
|
set_mario_action(m, ACT_ENTERING_STAR_DOOR, should_push_or_pull_door(m, o));
|
||||||
}
|
}
|
||||||
sDisplayingDoorText = TRUE;
|
sDisplayingDoorText = TRUE;
|
||||||
|
sCanInteractDoor = FALSE;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2349,6 +2344,7 @@ void mario_process_interactions(struct MarioState *m) {
|
||||||
|
|
||||||
if (!(m->marioObj->collidedObjInteractTypes & (INTERACT_WARP_DOOR | INTERACT_DOOR))) {
|
if (!(m->marioObj->collidedObjInteractTypes & (INTERACT_WARP_DOOR | INTERACT_DOOR))) {
|
||||||
sDisplayingDoorText = FALSE;
|
sDisplayingDoorText = FALSE;
|
||||||
|
sCanInteractDoor = TRUE;
|
||||||
}
|
}
|
||||||
if (!(m->marioObj->collidedObjInteractTypes & INTERACT_WARP)) {
|
if (!(m->marioObj->collidedObjInteractTypes & INTERACT_WARP)) {
|
||||||
if (m == &gMarioStates[0]) {
|
if (m == &gMarioStates[0]) {
|
||||||
|
|
Loading…
Reference in New Issue