-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Push B to Toggle Running Shoes
voloved edited this page Jan 22, 2023
·
1 revision
By devolov
Goal: Make pushing B toggle the running shoes so the don't have to be held.
-------------------------- include/constants/flags.h --------------------------
#define FLAG_ITEM_MAGMA_HIDEOUT_2F_2R_FULL_RESTORE 0x48D
#define FLAG_ITEM_MAGMA_HIDEOUT_3F_1R_NUGGET 0x48E
#define FLAG_ITEM_MAGMA_HIDEOUT_3F_2R_PP_MAX 0x48F
#define FLAG_ITEM_MAGMA_HIDEOUT_4F_THIEF_BALL 0x490
#define FLAG_ITEM_SAFARI_ZONE_NORTH_EAST_NUGGET 0x491
#define FLAG_ITEM_SAFARI_ZONE_SOUTH_EAST_BIG_PEARL 0x492
-#define FLAG_UNUSED_0x493 0x493 // Unused Flag
+#define FLAG_RUNNING_SHOES_TOGGLE 0x493
------------------------ include/field_player_avatar.h ------------------------
index f487c7e2a..093be21cb 100644
@@ -68,6 +68,7 @@ void SetPlayerInvisibility(bool8 invisible);
u8 player_get_pos_including_state_based_drift(s16 *x, s16 *y);
void StartFishing(u8 rod);
+extern bool8 gRunToggleBtnSet;
#endif // GUARD_FIELD_PLAYER_AVATAR_H
-------------------------- src/field_control_avatar.c --------------------------
if (forcedMove == FALSE)
{
if (tileTransitionState == T_TILE_CENTER && runningState == MOVING)
input->tookStep = TRUE;
if (forcedMove == FALSE && tileTransitionState == T_TILE_CENTER)
input->checkStandardWildEncounter = TRUE;
}
SetDirectionFromHeldKeys(heldKeys);
input->dpadDirection = sCurrentDirection;
+ // If B is pressed, field controls are allowed, and the player is either running or walking.
+ if ((newKeys & B_BUTTON) && (!ArePlayerFieldControlsLocked())
+ && (gPlayerAvatar.flags & (PLAYER_AVATAR_FLAG_DASH | PLAYER_AVATAR_FLAG_ON_FOOT)))
+ {
+ gRunToggleBtnSet = TRUE;
+ }
-------------------------- src/field_player_avatar.c --------------------------
index a8f092ab5..950b31536 100644
@@ -33,8 +33,10 @@
#include "constants/region_map_sections.h"
#include "constants/songs.h"
#include "constants/trainer_types.h"
+EWRAM_DATA bool8 gRunToggleBtnSet = FALSE;
+
#if DEBUG
EWRAM_DATA bool8 gWalkThroughWalls = 0;
#endif
static EWRAM_DATA u8 sSpinStartFacingDir = 0;
@@ -643,18 +645,44 @@ static void PlayerNotOnBikeMoving(u8 direction, u16 heldKeys)
// speed 2 is fast, same speed as running
PlayerGoSpeed2(direction);
return;
}
-
- if (!(gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_UNDERWATER) && (heldKeys & B_BUTTON) && FlagGet(FLAG_SYS_B_DASH)
- && IsRunningDisallowed(gObjectEvents[gPlayerAvatar.objectEventId].currentMetatileBehavior) == 0)
+ if (!(gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_UNDERWATER) && (gRunToggleBtnSet || FlagGet(FLAG_RUNNING_SHOES_TOGGLE) || (heldKeys & B_BUTTON))
+ && FlagGet(FLAG_SYS_B_DASH) && IsRunningDisallowed(gObjectEvents[gPlayerAvatar.objectEventId].currentMetatileBehavior) == 0)
+ {
+ if (gRunToggleBtnSet)
+ {
+ gRunToggleBtnSet = FALSE;
+ if (FlagGet(FLAG_RUNNING_SHOES_TOGGLE) == FALSE)
+ {
+ FlagSet(FLAG_RUNNING_SHOES_TOGGLE);
+ PlayerRun(direction);
+ gPlayerAvatar.flags |= PLAYER_AVATAR_FLAG_DASH;
+ return;
+ }
+ else
+ {
+ FlagClear(FLAG_RUNNING_SHOES_TOGGLE);
+ gRunToggleBtnSet = FALSE;
+ if (!(heldKeys & B_BUTTON))
+ {
+ PlayerWalkNormal(direction);
+ }
+ else
+ {
+ PlayerRun(direction);
+ gPlayerAvatar.flags |= PLAYER_AVATAR_FLAG_DASH;
+ }
+ return;
+ }
+ }
+ PlayerRun(direction);
+ gPlayerAvatar.flags |= PLAYER_AVATAR_FLAG_DASH;
+ return;
+ }
+ PlayerRun(direction);
gPlayerAvatar.flags |= PLAYER_AVATAR_FLAG_DASH;
return;
}
else
{
+ gRunToggleBtnSet = FALSE;
PlayerWalkNormal(direction);
}
}