Renamed and refactored FieldInput_HandleCancelSignpost into CancelSignPostMessageBox

This commit is contained in:
pkmnsnfrn 2024-07-15 22:13:33 -07:00
parent 8445d44fb6
commit b54cf221d8
5 changed files with 41 additions and 31 deletions

View file

@ -3,7 +3,7 @@
// Movement config // Movement config
#define OW_RUNNING_INDOORS GEN_LATEST // In Gen4+, players are allowed to run indoors. #define OW_RUNNING_INDOORS GEN_LATEST // In Gen4+, players are allowed to run indoors.
#define OW_AUTO_SIGNPOST FALSE // When enabled, if the tile that the player is facing has MB_SIGNPOST, the player will automatically read the signpost. #define OW_AUTO_SIGNPOST TRUE // When enabled, if the tile that the player is facing has MB_SIGNPOST, the player will automatically read the signpost.
// Other settings // Other settings
#define OW_POISON_DAMAGE GEN_LATEST // In Gen4, Pokémon no longer faint from Poison in the overworld. In Gen5+, they no longer take damage at all. #define OW_POISON_DAMAGE GEN_LATEST // In Gen4, Pokémon no longer faint from Poison in the overworld. In Gen5+, they no longer take damage at all.

View file

@ -28,6 +28,9 @@ extern const u8 EventScript_FollowerFaceUp[];
extern const u8 EventScript_FollowerFaceResult[]; extern const u8 EventScript_FollowerFaceResult[];
extern const u8 EnterPokeballMovement[]; extern const u8 EnterPokeballMovement[];
extern const u8 Common_Movement_FollowerSafeStart[];
extern const u8 Common_Movement_FollowerSafeEnd[];
extern const u8 EventScript_TestSignpostMsg[]; extern const u8 EventScript_TestSignpostMsg[];
extern const u8 EventScript_TryGetTrainerScript[]; extern const u8 EventScript_TryGetTrainerScript[];
extern const u8 EventScript_StartTrainerApproach[]; extern const u8 EventScript_StartTrainerApproach[];
@ -643,10 +646,6 @@ extern const u8 VSSeeker_Text_BatteryNotChargedNeedXSteps[];
extern const u8 VSSeeker_Text_NoTrainersWithinRange[]; extern const u8 VSSeeker_Text_NoTrainersWithinRange[];
extern const u8 VSSeeker_Text_TrainersNotReady[]; extern const u8 VSSeeker_Text_TrainersNotReady[];
extern const u8 EventScript_VsSeekerChargingDone[]; extern const u8 EventScript_VsSeekerChargingDone[];
extern const u8 Common_Movement_FollowerSafeStart[];
extern const u8 Common_Movement_FollowerSafeEnd[];
extern const u8 EventScript_CancelMessageBox[]; extern const u8 EventScript_CancelMessageBox[];
#endif // GUARD_EVENT_SCRIPTS_H #endif // GUARD_EVENT_SCRIPTS_H

View file

@ -34,6 +34,6 @@ u8 TrySetDiveWarp(void);
const u8 *GetInteractedLinkPlayerScript(struct MapPosition *position, u8 metatileBehavior, u8 direction); const u8 *GetInteractedLinkPlayerScript(struct MapPosition *position, u8 metatileBehavior, u8 direction);
const u8 *GetCoordEventScriptAtMapPosition(struct MapPosition *position); const u8 *GetCoordEventScriptAtMapPosition(struct MapPosition *position);
void ClearPoisonStepCounter(void); void ClearPoisonStepCounter(void);
void FieldInput_HandleCancelSignpost(struct FieldInput *input); void CancelSignPostMessageBox(struct FieldInput *input);
#endif // GUARD_FIELDCONTROLAVATAR_H #endif // GUARD_FIELDCONTROLAVATAR_H

View file

@ -1167,29 +1167,40 @@ static void Task_OpenStartMenu(u8 taskId)
} }
} }
void FieldInput_HandleCancelSignpost(struct FieldInput *input) bool32 IsDpadPushedToTurnOrMovePlayer(struct FieldInput *input)
{ {
if (ScriptContext_IsEnabled() == TRUE) return (input->dpadDirection != 0 && GetPlayerFacingDirection() != input->dpadDirection);
{ }
if (gWalkAwayFromSignInhibitTimer != 0)
void CancelSignPostMessageBox(struct FieldInput *input)
{
if (!ScriptContext_IsEnabled())
return;
if (gWalkAwayFromSignInhibitTimer)
{ {
gWalkAwayFromSignInhibitTimer--; gWalkAwayFromSignInhibitTimer--;
return;
} }
else if (CanWalkAwayToCancelMsgBox() == TRUE)
{ if (!CanWalkAwayToCancelMsgBox())
//ClearMsgBoxCancelableState(); return;
if (input->dpadDirection != 0 && GetPlayerFacingDirection() != input->dpadDirection)
if (IsDpadPushedToTurnOrMovePlayer(input))
{ {
ScriptContext_SetupScript(EventScript_CancelMessageBox); ScriptContext_SetupScript(EventScript_CancelMessageBox);
LockPlayerFieldControls(); LockPlayerFieldControls();
return;
} }
else if (input->pressedStartButton)
{ if (!input->pressedStartButton)
return;
ScriptContext_SetupScript(EventScript_CancelMessageBox); ScriptContext_SetupScript(EventScript_CancelMessageBox);
LockPlayerFieldControls(); LockPlayerFieldControls();
if (!FuncIsActiveTask(Task_OpenStartMenu))
if (FuncIsActiveTask(Task_OpenStartMenu))
return;
CreateTask(Task_OpenStartMenu, 8); CreateTask(Task_OpenStartMenu, 8);
}
}
}
} }

View file

@ -1489,7 +1489,7 @@ static void DoCB1_Overworld(u16 newKeys, u16 heldKeys)
UpdatePlayerAvatarTransitionState(); UpdatePlayerAvatarTransitionState();
FieldClearPlayerInput(&inputStruct); FieldClearPlayerInput(&inputStruct);
FieldGetPlayerInput(&inputStruct, newKeys, heldKeys); FieldGetPlayerInput(&inputStruct, newKeys, heldKeys);
FieldInput_HandleCancelSignpost(&inputStruct); CancelSignPostMessageBox(&inputStruct);
if (!ArePlayerFieldControlsLocked()) if (!ArePlayerFieldControlsLocked())
{ {
if (ProcessPlayerFieldInput(&inputStruct) == 1) if (ProcessPlayerFieldInput(&inputStruct) == 1)