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
#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
#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 EnterPokeballMovement[];
extern const u8 Common_Movement_FollowerSafeStart[];
extern const u8 Common_Movement_FollowerSafeEnd[];
extern const u8 EventScript_TestSignpostMsg[];
extern const u8 EventScript_TryGetTrainerScript[];
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_TrainersNotReady[];
extern const u8 EventScript_VsSeekerChargingDone[];
extern const u8 Common_Movement_FollowerSafeStart[];
extern const u8 Common_Movement_FollowerSafeEnd[];
extern const u8 EventScript_CancelMessageBox[];
#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 *GetCoordEventScriptAtMapPosition(struct MapPosition *position);
void ClearPoisonStepCounter(void);
void FieldInput_HandleCancelSignpost(struct FieldInput *input);
void CancelSignPostMessageBox(struct FieldInput *input);
#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)
{
if (gWalkAwayFromSignInhibitTimer != 0)
{
gWalkAwayFromSignInhibitTimer--;
}
else if (CanWalkAwayToCancelMsgBox() == TRUE)
{
//ClearMsgBoxCancelableState();
if (input->dpadDirection != 0 && GetPlayerFacingDirection() != input->dpadDirection)
{
ScriptContext_SetupScript(EventScript_CancelMessageBox);
LockPlayerFieldControls();
}
else if (input->pressedStartButton)
{
ScriptContext_SetupScript(EventScript_CancelMessageBox);
LockPlayerFieldControls();
if (!FuncIsActiveTask(Task_OpenStartMenu))
CreateTask(Task_OpenStartMenu, 8);
}
}
}
return (input->dpadDirection != 0 && GetPlayerFacingDirection() != input->dpadDirection);
}
void CancelSignPostMessageBox(struct FieldInput *input)
{
if (!ScriptContext_IsEnabled())
return;
if (gWalkAwayFromSignInhibitTimer)
{
gWalkAwayFromSignInhibitTimer--;
return;
}
if (!CanWalkAwayToCancelMsgBox())
return;
if (IsDpadPushedToTurnOrMovePlayer(input))
{
ScriptContext_SetupScript(EventScript_CancelMessageBox);
LockPlayerFieldControls();
return;
}
if (!input->pressedStartButton)
return;
ScriptContext_SetupScript(EventScript_CancelMessageBox);
LockPlayerFieldControls();
if (FuncIsActiveTask(Task_OpenStartMenu))
return;
CreateTask(Task_OpenStartMenu, 8);
}

View file

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