From 33dfa321b04420e8b213408dde0afbf07a647587 Mon Sep 17 00:00:00 2001 From: Evan Date: Sun, 31 May 2020 23:16:15 -0600 Subject: [PATCH 01/27] init branch --- include/constants/metatile_behaviors.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/include/constants/metatile_behaviors.h b/include/constants/metatile_behaviors.h index 94cb0ffcaa18..7fe10a7d201a 100755 --- a/include/constants/metatile_behaviors.h +++ b/include/constants/metatile_behaviors.h @@ -236,10 +236,14 @@ #define MB_WIRELESS_BOX_RESULTS 0xE8 #define MB_TRAINER_HILL_TIMER 0xE9 #define MB_SKY_PILLAR_CLOSED_DOOR 0xEA -#define MB_UNUSED_EB 0xEB -#define MB_UNUSED_EC 0xEC -#define MB_UNUSED_ED 0xED -#define MB_UNUSED_EE 0xEE -#define MB_UNUSED_EF 0xEF + +//sideways stairs +#define MB_SIDEWAYS_STAIRS_0 0xEB +#define MB_SIDEWAYS_STAIRS_1 0xEC +#define MB_SIDEWAYS_STAIRS_2 0xED +#define MB_SIDEWAYS_STAIRS_3 0xEE +#define MB_SIDEWAYS_STAIRS_4 0xEF +#define MB_SIDEWAYS_STAIRS_5 0xF0 + #endif // GUARD_METATILE_BEHAVIORS From 31e9f97d52d4b82b9e75b4a86c699ea57d463fdf Mon Sep 17 00:00:00 2001 From: Evan Date: Wed, 3 Jun 2020 14:23:28 -0600 Subject: [PATCH 02/27] cherry pick 4eb7fcc261934c0f9f10985761cd3e7b7abf0dab --- include/constants/event_object_movement.h | 24 + include/constants/metatile_behaviors.h | 19 +- include/event_object_movement.h | 12 + include/field_player_avatar.h | 10 + include/global.fieldmap.h | 5 + include/metatile_behavior.h | 4 + src/bike.c | 75 ++- .../movement_action_func_tables.h | 156 +++++++ src/event_object_movement.c | 441 ++++++++++++++++-- src/field_player_avatar.c | 198 +++++++- src/metatile_behavior.c | 30 +- 11 files changed, 909 insertions(+), 65 deletions(-) diff --git a/include/constants/event_object_movement.h b/include/constants/event_object_movement.h index 2236500810c2..9bd3e87c6c93 100755 --- a/include/constants/event_object_movement.h +++ b/include/constants/event_object_movement.h @@ -1,6 +1,8 @@ #ifndef GUARD_CONSTANTS_EVENT_OBJECT_MOVEMENT_H #define GUARD_CONSTANTS_EVENT_OBJECT_MOVEMENT_H +#define SLOW_MOVEMENT_ON_STAIRS TRUE // change to false to keep emerald's normal movement speed on outdoor stairs + #define MOVEMENT_TYPE_NONE 0x0 #define MOVEMENT_TYPE_LOOK_AROUND 0x1 #define MOVEMENT_TYPE_WANDER_AROUND 0x2 @@ -241,6 +243,28 @@ #define MOVEMENT_ACTION_FIGURE_8 0x9B #define MOVEMENT_ACTION_FLY_UP 0x9C #define MOVEMENT_ACTION_FLY_DOWN 0x9D +// slow running (for stairs) +#define MOVEMENT_ACTION_RUN_DOWN_SLOW 0x9E +#define MOVEMENT_ACTION_RUN_UP_SLOW 0x9F +#define MOVEMENT_ACTION_RUN_LEFT_SLOW 0xA0 +#define MOVEMENT_ACTION_RUN_RIGHT_SLOW 0xA1 +// sideways stairs - walking +#define MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_UP_LEFT 0xA2 +#define MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_UP_RIGHT 0xA3 +#define MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_DOWN_LEFT 0xA4 +#define MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_DOWN_RIGHT 0xA5 +// sideways stairs - running +#define MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_UP_LEFT_RUNNING 0xA6 +#define MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_UP_RIGHT_RUNNING 0xA7 +#define MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_DOWN_LEFT_RUNNING 0xA8 +#define MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_DOWN_RIGHT_RUNNING 0xA9 +// sideways stairs - acro bike +#define MOVEMENT_ACTION_RIDE_WATER_CURRENT_UP_LEFT 0xAA +#define MOVEMENT_ACTION_RIDE_WATER_CURRENT_UP_RIGHT 0xAB +#define MOVEMENT_ACTION_RIDE_WATER_CURRENT_DOWN_LEFT 0xAC +#define MOVEMENT_ACTION_RIDE_WATER_CURRENT_DOWN_RIGHT 0xAD +//sideways stairs - mach bike + #define MOVEMENT_ACTION_STEP_END 0xFE diff --git a/include/constants/metatile_behaviors.h b/include/constants/metatile_behaviors.h index 7fe10a7d201a..ef79f0b6d3ae 100755 --- a/include/constants/metatile_behaviors.h +++ b/include/constants/metatile_behaviors.h @@ -74,9 +74,9 @@ #define MB_SLIDE_NORTH 0x46 #define MB_SLIDE_SOUTH 0x47 #define MB_TRICK_HOUSE_PUZZLE_8_FLOOR 0x48 -#define MB_UNUSED_49 0x49 -#define MB_UNUSED_4A 0x4A -#define MB_UNUSED_4B 0x4B +#define MB_SIDEWAYS_STAIRS_RIGHT 0x49 +#define MB_SIDEWAYS_STAIRS_LEFT 0x4A +#define MB_ROCK_STAIRS 0x4B #define MB_UNUSED_4C 0x4C #define MB_UNUSED_4D 0x4D #define MB_UNUSED_4E 0x4E @@ -236,14 +236,11 @@ #define MB_WIRELESS_BOX_RESULTS 0xE8 #define MB_TRAINER_HILL_TIMER 0xE9 #define MB_SKY_PILLAR_CLOSED_DOOR 0xEA - -//sideways stairs -#define MB_SIDEWAYS_STAIRS_0 0xEB -#define MB_SIDEWAYS_STAIRS_1 0xEC -#define MB_SIDEWAYS_STAIRS_2 0xED -#define MB_SIDEWAYS_STAIRS_3 0xEE -#define MB_SIDEWAYS_STAIRS_4 0xEF -#define MB_SIDEWAYS_STAIRS_5 0xF0 +#define MB_UNUSED_EB 0xEB +#define MB_UNUSED_EC 0xEC +#define MB_UNUSED_ED 0xED +#define MB_UNUSED_EE 0xEE +#define MB_UNUSED_EF 0xEF #endif // GUARD_METATILE_BEHAVIORS diff --git a/include/event_object_movement.h b/include/event_object_movement.h index 1e754dcd938d..e8f8df1a4b91 100644 --- a/include/event_object_movement.h +++ b/include/event_object_movement.h @@ -428,4 +428,16 @@ void SetObjectEventSpriteGraphics(u8 objectEventId, u8 graphicsId); void SetObjectEventSpriteAnim(u8 objectEventId, u8 animNum); bool32 IsObjectEventSpriteAnimating(u8 objectEventId); +// run slow +u8 GetPlayerRunSlowMovementAction(u32); +//sideways stairs +u8 GetSidewaysStairsToRightDirection(s16, s16, u8); +u8 GetSidewaysStairsToLeftDirection(s16, s16, u8); +u8 GetDiagonalRightStairsMovement(u32); +u8 GetDiagonalLeftStairsMovement(u32); +u8 GetDiagonalRightStairsRunningMovement(u32); +u8 GetDiagonalLeftStairsRunningMovement(u32); +u8 GetDiagonalLeftAcroBikeMovement(u32); +u8 GetDiagonalRightAcroBikeMovement(u32); + #endif //GUARD_EVENT_OBJECT_MOVEMENT_H diff --git a/include/field_player_avatar.h b/include/field_player_avatar.h index c30ce0b6fb87..3177a887ce75 100644 --- a/include/field_player_avatar.h +++ b/include/field_player_avatar.h @@ -64,5 +64,15 @@ bool32 IsPlayerSpinExitActive(void); void SetPlayerInvisibility(bool8 invisible); u8 player_get_pos_including_state_based_drift(s16 *x, s16 *y); void StartFishing(u8 rod); +bool32 PlayerIsMovingOnRockStairs(u8 direction); +//sideways stairs +u8 GetRightStairsDirection(u8 direction); +u8 GetLeftStairsDirection(u8 direction); +void PlayerSidewaysStairsToRight(u8 direction); +void PlayerSidewaysStairsToLeft(u8 direction); +void PlayerSidewaysStairsToRightRunning(u8 direction); +void PlayerSidewaysStairsToLeftRunning(u8 direction); +void PlayerSidewaysStairsToAcroBikeLeft(u8 direction); +void PlayerSidewaysStairsToAcroBikeRight(u8 direction); #endif // GUARD_FIELD_PLAYER_AVATAR_H diff --git a/include/global.fieldmap.h b/include/global.fieldmap.h index c4d7be35da3a..baedb9bf3750 100644 --- a/include/global.fieldmap.h +++ b/include/global.fieldmap.h @@ -278,6 +278,11 @@ enum COLLISION_ISOLATED_HORIZONTAL_RAIL, COLLISION_VERTICAL_RAIL, COLLISION_HORIZONTAL_RAIL, + //sideways_stairs + COLLISION_SIDEWAYS_STAIRS_TO_RIGHT_WALKING, + COLLISION_SIDEWAYS_STAIRS_TO_LEFT_WALKING, + COLLISION_SIDEWAYS_STAIRS_TO_RIGHT_RUNNING, + COLLISION_SIDEWAYS_STAIRS_TO_LEFT_RUNNING, }; // player running states diff --git a/include/metatile_behavior.h b/include/metatile_behavior.h index d4bd9e683248..f5781a337110 100644 --- a/include/metatile_behavior.h +++ b/include/metatile_behavior.h @@ -145,5 +145,9 @@ bool8 MetatileBehavior_IsQuestionnaire(u8); bool8 MetatileBehavior_IsLongGrass_Duplicate(u8); bool8 MetatileBehavior_IsLongGrassSouthEdge(u8); bool8 MetatileBehavior_IsTrainerHillTimer(u8); +bool8 MetatileBehavior_IsRockStairs(u8 metatileBehavior); +//sideways stairs +bool8 MetatileBehavior_IsSidewaysStairsRight(u8); +bool8 MetatileBehavior_IsSidewaysStairsLeft(u8); #endif // GUARD_METATILE_BEHAVIOR diff --git a/src/bike.c b/src/bike.c index bbcda989c93b..18dbda6ba3db 100644 --- a/src/bike.c +++ b/src/bike.c @@ -179,6 +179,9 @@ static u8 GetMachBikeTransition(u8 *dirTraveling) // the difference between face direction and turn direction is that one changes direction while the other does the animation of turning as well as changing direction. static void MachBikeTransition_FaceDirection(u8 direction) { + //if (direction > DIR_EAST) + // direction -= DIR_EAST; + PlayerFaceDirection(direction); Bike_SetBikeStill(); } @@ -187,6 +190,9 @@ static void MachBikeTransition_TurnDirection(u8 direction) { struct ObjectEvent *playerObjEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; + //if (direction > DIR_EAST) + // direction -= DIR_EAST; + if (CanBikeFaceDirOnMetatile(direction, playerObjEvent->currentMetatileBehavior)) { PlayerTurnInPlace(direction); @@ -194,6 +200,9 @@ static void MachBikeTransition_TurnDirection(u8 direction) } else { + //if (playerObjEvent->facingDirection > DIR_EAST) + // playerObjEvent->facingDirection -= DIR_EAST; + MachBikeTransition_FaceDirection(playerObjEvent->facingDirection); } } @@ -231,9 +240,28 @@ static void MachBikeTransition_TrySpeedUp(u8 direction) PlayerOnBikeCollide(direction); } } + else if (collision == COLLISION_SIDEWAYS_STAIRS_TO_LEFT_WALKING) + { + gPlayerAvatar.bikeFrameCounter = 0; + gPlayerAvatar.bikeSpeed = SPEED_STANDING; + PlayerGoSpeed2(GetLeftStairsDirection(direction)); + //PlayerSidewaysStairsToAcroBikeLeft(direction); + return; + } + else if (collision == COLLISION_SIDEWAYS_STAIRS_TO_RIGHT_WALKING) + { + gPlayerAvatar.bikeFrameCounter = 0; + gPlayerAvatar.bikeSpeed = SPEED_STANDING; + //PlayerSidewaysStairsToAcroBikeRight(direction); + PlayerGoSpeed2(GetRightStairsDirection(direction)); + return; + } else { - // we did not hit anything that can slow us down, so perform the advancement callback depending on the bikeFrameCounter and try to increase the mach bike's speed. + // to do: this sometimes crashes based on the metatile behaviours (eg. holding up while traveling down sideways stairs to sw) + if (PlayerIsMovingOnRockStairs(direction)) + gPlayerAvatar.bikeFrameCounter--; + sMachBikeSpeedCallbacks[gPlayerAvatar.bikeFrameCounter](direction); gPlayerAvatar.bikeSpeed = gPlayerAvatar.bikeFrameCounter + (gPlayerAvatar.bikeFrameCounter >> 1); // same as dividing by 2, but compiler is insistent on >> 1 if (gPlayerAvatar.bikeFrameCounter < 2) // do not go faster than the last element in the mach bike array @@ -268,6 +296,18 @@ static void MachBikeTransition_TrySlowDown(u8 direction) } else { + /* + if (collision == COLLISION_SIDEWAYS_STAIRS_TO_LEFT_WALKING) + { + return PlayerGoSpeed2(GetLeftStairsDirection(direction)); + //return PlayerSidewaysStairsToLeftMachBike(direction); + } + else if (collision == COLLISION_SIDEWAYS_STAIRS_TO_RIGHT_WALKING) + { + return PlayerGoSpeed2(GetRightStairsDirection(direction)); + //return PlayerSidewaysStairsToRightMachBike(direction); + }*/ + sMachBikeSpeedCallbacks[gPlayerAvatar.bikeFrameCounter](direction); } } @@ -563,7 +603,27 @@ static void AcroBikeTransition_Moving(u8 direction) } else { - PlayerRideWaterCurrent(direction); + if (collision == COLLISION_SIDEWAYS_STAIRS_TO_RIGHT_WALKING) + return PlayerGoSpeed2(GetRightStairsDirection(direction)); + else if (collision == COLLISION_SIDEWAYS_STAIRS_TO_LEFT_WALKING) + return PlayerGoSpeed2(GetLeftStairsDirection(direction)); + + if (PlayerIsMovingOnRockStairs(direction)) + PlayerGoSpeed2(direction); + else + PlayerRideWaterCurrent(direction); + + /* works, but might be better to keep rock stairs to up/down for mach bike + if (collision == COLLISION_SIDEWAYS_STAIRS_TO_RIGHT_WALKING) + direction = GetRightStairsDirection(direction); + else if (collision == COLLISION_SIDEWAYS_STAIRS_TO_LEFT_WALKING) + direction = GetLeftStairsDirection(direction); + + if (PlayerIsMovingOnRockStairs(direction)) + PlayerGoSpeed2(direction); + else + PlayerRideWaterCurrent(direction); + */ } } @@ -632,6 +692,11 @@ static void AcroBikeTransition_WheelieHoppingMoving(u8 direction) else { derp: + /*if (collision == COLLISION_SIDEWAYS_STAIRS_TO_LEFT_WALKING) + direction = GetLeftStairsDirection(direction); + else if (collision == COLLISION_SIDEWAYS_STAIRS_TO_RIGHT_WALKING) + direction = GetRightStairsDirection(direction); + */ PlayerMovingHoppingWheelie(direction); } } @@ -699,6 +764,12 @@ static void AcroBikeTransition_WheelieMoving(u8 direction) } return; } + + /*if (collision == COLLISION_SIDEWAYS_STAIRS_TO_LEFT_WALKING) + direction = GetLeftStairsDirection(direction); + else if (collision == COLLISION_SIDEWAYS_STAIRS_TO_RIGHT_WALKING) + direction = GetRightStairsDirection(direction);*/ + PlayerWheelieMove(direction); gPlayerAvatar.runningState = MOVING; } diff --git a/src/data/object_events/movement_action_func_tables.h b/src/data/object_events/movement_action_func_tables.h index 8cf7d1699f49..cc1b522159aa 100755 --- a/src/data/object_events/movement_action_func_tables.h +++ b/src/data/object_events/movement_action_func_tables.h @@ -261,6 +261,26 @@ u8 MovementAction_FlyUp_Step1(struct ObjectEvent *, struct Sprite *); u8 MovementAction_Fly_Finish(struct ObjectEvent *, struct Sprite *); u8 MovementAction_FlyDown_Step0(struct ObjectEvent *, struct Sprite *); u8 MovementAction_FlyDown_Step1(struct ObjectEvent *, struct Sprite *); +//slow running +u8 MovementActionFunc_RunSlowDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite); +u8 MovementActionFunc_RunSlowUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite); +u8 MovementActionFunc_RunSlowLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite); +u8 MovementActionFunc_RunSlowRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite); +u8 MovementActionFunc_RunSlow_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite); +//sideways stairs +u8 MovementAction_WalkStairDiagonalUpLeft_Step0(struct ObjectEvent *, struct Sprite *); +u8 MovementAction_WalkStairDiagonalUpRight_Step0(struct ObjectEvent *, struct Sprite *); +u8 MovementAction_WalkStairDiagonalDownLeft_Step0(struct ObjectEvent *, struct Sprite *); +u8 MovementAction_WalkStairDiagonalDownRight_Step0(struct ObjectEvent *, struct Sprite *); +u8 MovementAction_RunStairDiagonalUpLeft_Step0(struct ObjectEvent *, struct Sprite *); +u8 MovementAction_RunStairDiagonalUpRight_Step0(struct ObjectEvent *, struct Sprite *); +u8 MovementAction_RunStairDiagonalDownLeft_Step0(struct ObjectEvent *, struct Sprite *); +u8 MovementAction_RunStairDiagonalDownRight_Step0(struct ObjectEvent *, struct Sprite *); +u8 MovementAction_RunStairDiagonal_Step1(struct ObjectEvent *, struct Sprite *); +u8 MovementAction_AcroBikeDiagonalUpLeft_Step0(struct ObjectEvent *, struct Sprite *); +u8 MovementAction_AcroBikeDiagonalDownLeft_Step0(struct ObjectEvent *, struct Sprite *); +u8 MovementAction_AcroBikeDiagonalUpRight_Step0(struct ObjectEvent *, struct Sprite *); +u8 MovementAction_AcroBikeDiagonalDownRight_Step0(struct ObjectEvent *, struct Sprite *); u8 (*const gMovementActionFuncs_FaceDown[])(struct ObjectEvent *, struct Sprite *); u8 (*const gMovementActionFuncs_FaceUp[])(struct ObjectEvent *, struct Sprite *); @@ -420,6 +440,24 @@ u8 (*const gMovementActionFuncs_DestroyExtraTaskIfAtTop[])(struct ObjectEvent *, u8 (*const gMovementActionFuncs_Figure8[])(struct ObjectEvent *, struct Sprite *); u8 (*const gMovementActionFuncs_FlyUp[])(struct ObjectEvent *, struct Sprite *); u8 (*const gMovementActionFuncs_FlyDown[])(struct ObjectEvent *, struct Sprite *); +//run slow +u8 (*const gMovementActionFuncs_RunDownSlow[])(struct ObjectEvent *, struct Sprite *); +u8 (*const gMovementActionFuncs_RunUpSlow[])(struct ObjectEvent *, struct Sprite *); +u8 (*const gMovementActionFuncs_RunLeftSlow[])(struct ObjectEvent *, struct Sprite *); +u8 (*const gMovementActionFuncs_RunRightSlow[])(struct ObjectEvent *, struct Sprite *); +//sideways stairs +u8 (*const gMovementActionFuncs_WalkStairDiagonalUpLeft[])(struct ObjectEvent *, struct Sprite *); +u8 (*const gMovementActionFuncs_WalkStairDiagonalUpRight[])(struct ObjectEvent *, struct Sprite *); +u8 (*const gMovementActionFuncs_WalkStairDiagonalDownLeft[])(struct ObjectEvent *, struct Sprite *); +u8 (*const gMovementActionFuncs_WalkStairDiagonalDownRight[])(struct ObjectEvent *, struct Sprite *); +u8 (*const gMovementActionFuncs_RunStairDiagonalUpLeft[])(struct ObjectEvent *, struct Sprite *); +u8 (*const gMovementActionFuncs_RunStairDiagonalUpRight[])(struct ObjectEvent *, struct Sprite *); +u8 (*const gMovementActionFuncs_RunStairDiagonalDownLeft[])(struct ObjectEvent *, struct Sprite *); +u8 (*const gMovementActionFuncs_RunStairDiagonalDownRight[])(struct ObjectEvent *, struct Sprite *); +u8 (*const gMovementActionFuncs_AcroBikeDiagonalUpLeft[])(struct ObjectEvent *, struct Sprite *); +u8 (*const gMovementActionFuncs_AcroBikeDiagonalDownLeft[])(struct ObjectEvent *, struct Sprite *); +u8 (*const gMovementActionFuncs_AcroBikeDiagonalUpRight[])(struct ObjectEvent *, struct Sprite *); +u8 (*const gMovementActionFuncs_AcroBikeDiagonalDownRight[])(struct ObjectEvent *, struct Sprite *); u8 (*const *const gMovementActionFuncs[])(struct ObjectEvent *, struct Sprite *) = { [MOVEMENT_ACTION_FACE_DOWN] = gMovementActionFuncs_FaceDown, @@ -580,6 +618,24 @@ u8 (*const *const gMovementActionFuncs[])(struct ObjectEvent *, struct Sprite *) [MOVEMENT_ACTION_FIGURE_8] = gMovementActionFuncs_Figure8, [MOVEMENT_ACTION_FLY_UP] = gMovementActionFuncs_FlyUp, [MOVEMENT_ACTION_FLY_DOWN] = gMovementActionFuncs_FlyDown, + //run slow + [MOVEMENT_ACTION_RUN_DOWN_SLOW] = gMovementActionFuncs_RunDownSlow, + [MOVEMENT_ACTION_RUN_UP_SLOW] = gMovementActionFuncs_RunUpSlow, + [MOVEMENT_ACTION_RUN_LEFT_SLOW] = gMovementActionFuncs_RunLeftSlow, + [MOVEMENT_ACTION_RUN_RIGHT_SLOW] = gMovementActionFuncs_RunRightSlow, + //sideways stairs + [MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_UP_LEFT] = gMovementActionFuncs_WalkStairDiagonalUpLeft, + [MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_UP_RIGHT] = gMovementActionFuncs_WalkStairDiagonalUpRight, + [MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_DOWN_LEFT] = gMovementActionFuncs_WalkStairDiagonalDownLeft, + [MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_DOWN_RIGHT] = gMovementActionFuncs_WalkStairDiagonalDownRight, + [MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_UP_LEFT_RUNNING] = gMovementActionFuncs_RunStairDiagonalUpLeft, + [MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_UP_RIGHT_RUNNING] = gMovementActionFuncs_RunStairDiagonalUpRight, + [MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_DOWN_LEFT_RUNNING] = gMovementActionFuncs_RunStairDiagonalDownLeft, + [MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_DOWN_RIGHT_RUNNING] = gMovementActionFuncs_RunStairDiagonalDownRight, + [MOVEMENT_ACTION_RIDE_WATER_CURRENT_UP_LEFT] = gMovementActionFuncs_AcroBikeDiagonalUpLeft, + [MOVEMENT_ACTION_RIDE_WATER_CURRENT_UP_RIGHT] = gMovementActionFuncs_AcroBikeDiagonalUpRight, + [MOVEMENT_ACTION_RIDE_WATER_CURRENT_DOWN_LEFT] = gMovementActionFuncs_AcroBikeDiagonalDownLeft, + [MOVEMENT_ACTION_RIDE_WATER_CURRENT_DOWN_RIGHT] = gMovementActionFuncs_AcroBikeDiagonalDownRight, }; u8 (*const gMovementActionFuncs_FaceDown[])(struct ObjectEvent *, struct Sprite *) = { @@ -1511,3 +1567,103 @@ u8 (*const gMovementActionFuncs_DestroyExtraTaskIfAtTop[])(struct ObjectEvent *, MovementAction_DestroyExtraTaskIfAtTop_Step0, MovementAction_Finish, }; + +//slow running +u8 (*const gMovementActionFuncs_RunDownSlow[])(struct ObjectEvent *, struct Sprite *) = { + MovementActionFunc_RunSlowDown_Step0, + MovementActionFunc_RunSlow_Step1, + MovementAction_PauseSpriteAnim, +}; + +u8 (*const gMovementActionFuncs_RunUpSlow[])(struct ObjectEvent *, struct Sprite *) = { + MovementActionFunc_RunSlowUp_Step0, + MovementActionFunc_RunSlow_Step1, + MovementAction_PauseSpriteAnim, +}; + +u8 (*const gMovementActionFuncs_RunLeftSlow[])(struct ObjectEvent *, struct Sprite *) = { + MovementActionFunc_RunSlowLeft_Step0, + MovementActionFunc_RunSlow_Step1, + MovementAction_PauseSpriteAnim, +}; + +u8 (*const gMovementActionFuncs_RunRightSlow[])(struct ObjectEvent *, struct Sprite *) = { + MovementActionFunc_RunSlowRight_Step0, + MovementActionFunc_RunSlow_Step1, + MovementAction_PauseSpriteAnim, +}; + +//sideways stairs +u8 (*const gMovementActionFuncs_WalkStairDiagonalUpLeft[])(struct ObjectEvent *, struct Sprite *) = { + MovementAction_WalkStairDiagonalUpLeft_Step0, + MovementAction_WalkSlowDiagonalUpLeft_Step1, + MovementAction_PauseSpriteAnim, +}; + +u8 (*const gMovementActionFuncs_WalkStairDiagonalUpRight[])(struct ObjectEvent *, struct Sprite *) = { + MovementAction_WalkStairDiagonalUpRight_Step0, + MovementAction_WalkSlowDiagonalUpRight_Step1, + MovementAction_PauseSpriteAnim, +}; + +u8 (*const gMovementActionFuncs_WalkStairDiagonalDownLeft[])(struct ObjectEvent *, struct Sprite *) = { + MovementAction_WalkStairDiagonalDownLeft_Step0, + MovementAction_WalkSlowDiagonalDownLeft_Step1, + MovementAction_PauseSpriteAnim, +}; + +u8 (*const gMovementActionFuncs_WalkStairDiagonalDownRight[])(struct ObjectEvent *, struct Sprite *) = { + MovementAction_WalkStairDiagonalDownRight_Step0, + MovementAction_WalkSlowDiagonalDownRight_Step1, + MovementAction_PauseSpriteAnim, +}; + +u8 (*const gMovementActionFuncs_RunStairDiagonalUpLeft[])(struct ObjectEvent *, struct Sprite *) = { + MovementAction_RunStairDiagonalUpLeft_Step0, + MovementAction_RunStairDiagonal_Step1, + MovementAction_PauseSpriteAnim, +}; + +u8 (*const gMovementActionFuncs_RunStairDiagonalUpRight[])(struct ObjectEvent *, struct Sprite *) = { + MovementAction_RunStairDiagonalUpRight_Step0, + MovementAction_RunStairDiagonal_Step1, + MovementAction_PauseSpriteAnim, +}; + +u8 (*const gMovementActionFuncs_RunStairDiagonalDownLeft[])(struct ObjectEvent *, struct Sprite *) = { + MovementAction_RunStairDiagonalDownLeft_Step0, + MovementAction_RunStairDiagonal_Step1, + MovementAction_PauseSpriteAnim, +}; + +u8 (*const gMovementActionFuncs_RunStairDiagonalDownRight[])(struct ObjectEvent *, struct Sprite *) = { + MovementAction_RunStairDiagonalDownRight_Step0, + MovementAction_RunStairDiagonal_Step1, + MovementAction_PauseSpriteAnim, +}; + +u8 (*const gMovementActionFuncs_AcroBikeDiagonalUpLeft[])(struct ObjectEvent *, struct Sprite *) = { + MovementAction_AcroBikeDiagonalUpLeft_Step0, + MovementAction_RideWaterCurrentLeft_Step1, + MovementAction_PauseSpriteAnim, +}; + +u8 (*const gMovementActionFuncs_AcroBikeDiagonalDownLeft[])(struct ObjectEvent *, struct Sprite *) = { + MovementAction_AcroBikeDiagonalDownLeft_Step0, + MovementAction_RideWaterCurrentLeft_Step1, + MovementAction_PauseSpriteAnim, +}; + +u8 (*const gMovementActionFuncs_AcroBikeDiagonalUpRight[])(struct ObjectEvent *, struct Sprite *) = { + MovementAction_AcroBikeDiagonalUpRight_Step0, + MovementAction_RideWaterCurrentRight_Step1, + MovementAction_PauseSpriteAnim, +}; + +u8 (*const gMovementActionFuncs_AcroBikeDiagonalDownRight[])(struct ObjectEvent *, struct Sprite *) = { + MovementAction_AcroBikeDiagonalDownRight_Step0, + MovementAction_RideWaterCurrentRight_Step1, + MovementAction_PauseSpriteAnim, +}; + + diff --git a/src/event_object_movement.c b/src/event_object_movement.c index 1a7d08db2721..edbc20acb9d5 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -841,6 +841,18 @@ const u8 gRunningDirectionAnimNums[] = { [DIR_NORTHEAST] = 21, }; +const u8 gStairsRunningDirectionAnimNums[] = { + [DIR_NONE] = 20, + [DIR_SOUTH] = 20, + [DIR_NORTH] = 21, + [DIR_WEST] = 22, + [DIR_EAST] = 23, + [DIR_SOUTHWEST] = 22, + [DIR_SOUTHEAST] = 23, + [DIR_NORTHWEST] = 22, + [DIR_NORTHEAST] = 23, +}; + const u8 gTrainerFacingDirectionMovementTypes[] = { [DIR_NONE] = MOVEMENT_TYPE_FACE_DOWN, [DIR_SOUTH] = MOVEMENT_TYPE_FACE_DOWN, @@ -876,50 +888,78 @@ static const struct Coords16 sDirectionToVectors[] = { {-1, 1}, { 1, 1}, {-1, -1}, - { 1, -1} + { 1, -1}, + {-2, 1}, + { 2, 1}, + {-2, -1}, + { 2, -1} }; const u8 gFaceDirectionMovementActions[] = { - MOVEMENT_ACTION_FACE_DOWN, - MOVEMENT_ACTION_FACE_DOWN, - MOVEMENT_ACTION_FACE_UP, - MOVEMENT_ACTION_FACE_LEFT, - MOVEMENT_ACTION_FACE_RIGHT, + [DIR_NONE] = MOVEMENT_ACTION_FACE_DOWN, + [DIR_SOUTH] = MOVEMENT_ACTION_FACE_DOWN, + [DIR_NORTH] = MOVEMENT_ACTION_FACE_UP, + [DIR_WEST] = MOVEMENT_ACTION_FACE_LEFT, + [DIR_EAST] = MOVEMENT_ACTION_FACE_RIGHT, + [DIR_SOUTHWEST] = MOVEMENT_ACTION_FACE_LEFT, + [DIR_SOUTHEAST] = MOVEMENT_ACTION_FACE_RIGHT, + [DIR_NORTHWEST] = MOVEMENT_ACTION_FACE_LEFT, + [DIR_NORTHEAST] = MOVEMENT_ACTION_FACE_RIGHT }; const u8 gWalkSlowMovementActions[] = { - MOVEMENT_ACTION_WALK_SLOW_DOWN, - MOVEMENT_ACTION_WALK_SLOW_DOWN, - MOVEMENT_ACTION_WALK_SLOW_UP, - MOVEMENT_ACTION_WALK_SLOW_LEFT, - MOVEMENT_ACTION_WALK_SLOW_RIGHT, + [DIR_NONE] = MOVEMENT_ACTION_WALK_SLOW_DOWN, + [DIR_SOUTH] = MOVEMENT_ACTION_WALK_SLOW_DOWN, + [DIR_NORTH] = MOVEMENT_ACTION_WALK_SLOW_UP, + [DIR_WEST] = MOVEMENT_ACTION_WALK_SLOW_LEFT, + [DIR_EAST] = MOVEMENT_ACTION_WALK_SLOW_RIGHT, + [DIR_SOUTHWEST] = MOVEMENT_ACTION_WALK_SLOW_DIAGONAL_DOWN_LEFT, + [DIR_SOUTHEAST] = MOVEMENT_ACTION_WALK_SLOW_DIAGONAL_DOWN_RIGHT, + [DIR_NORTHWEST] = MOVEMENT_ACTION_WALK_SLOW_DIAGONAL_UP_LEFT, + [DIR_NORTHEAST] = MOVEMENT_ACTION_WALK_SLOW_DIAGONAL_UP_RIGHT }; const u8 gWalkNormalMovementActions[] = { - MOVEMENT_ACTION_WALK_NORMAL_DOWN, - MOVEMENT_ACTION_WALK_NORMAL_DOWN, - MOVEMENT_ACTION_WALK_NORMAL_UP, - MOVEMENT_ACTION_WALK_NORMAL_LEFT, - MOVEMENT_ACTION_WALK_NORMAL_RIGHT, + [DIR_NONE] = MOVEMENT_ACTION_WALK_NORMAL_DOWN, + [DIR_SOUTH] = MOVEMENT_ACTION_WALK_NORMAL_DOWN, + [DIR_NORTH] = MOVEMENT_ACTION_WALK_NORMAL_UP, + [DIR_WEST] = MOVEMENT_ACTION_WALK_NORMAL_LEFT, + [DIR_EAST] = MOVEMENT_ACTION_WALK_NORMAL_RIGHT, + [DIR_SOUTHWEST] = MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_DOWN_LEFT, + [DIR_SOUTHEAST] = MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_DOWN_RIGHT, + [DIR_NORTHWEST] = MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_UP_LEFT, + [DIR_NORTHEAST] = MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_UP_RIGHT }; const u8 gWalkFastMovementActions[] = { - MOVEMENT_ACTION_WALK_FAST_DOWN, - MOVEMENT_ACTION_WALK_FAST_DOWN, - MOVEMENT_ACTION_WALK_FAST_UP, - MOVEMENT_ACTION_WALK_FAST_LEFT, - MOVEMENT_ACTION_WALK_FAST_RIGHT, + [DIR_NONE] = MOVEMENT_ACTION_WALK_FAST_DOWN, + [DIR_SOUTH] = MOVEMENT_ACTION_WALK_FAST_DOWN, + [DIR_NORTH] = MOVEMENT_ACTION_WALK_FAST_UP, + [DIR_WEST] = MOVEMENT_ACTION_WALK_FAST_LEFT, + [DIR_EAST] = MOVEMENT_ACTION_WALK_FAST_RIGHT, + [DIR_SOUTHWEST] = MOVEMENT_ACTION_RIDE_WATER_CURRENT_DOWN_LEFT, + [DIR_SOUTHEAST] = MOVEMENT_ACTION_RIDE_WATER_CURRENT_DOWN_RIGHT, + [DIR_NORTHWEST] = MOVEMENT_ACTION_RIDE_WATER_CURRENT_UP_LEFT, + [DIR_NORTHEAST] = MOVEMENT_ACTION_RIDE_WATER_CURRENT_UP_RIGHT, }; const u8 gRideWaterCurrentMovementActions[] = { - MOVEMENT_ACTION_RIDE_WATER_CURRENT_DOWN, - MOVEMENT_ACTION_RIDE_WATER_CURRENT_DOWN, - MOVEMENT_ACTION_RIDE_WATER_CURRENT_UP, - MOVEMENT_ACTION_RIDE_WATER_CURRENT_LEFT, - MOVEMENT_ACTION_RIDE_WATER_CURRENT_RIGHT, + [DIR_NONE] = MOVEMENT_ACTION_RIDE_WATER_CURRENT_DOWN, + [DIR_SOUTH] = MOVEMENT_ACTION_RIDE_WATER_CURRENT_DOWN, + [DIR_NORTH] = MOVEMENT_ACTION_RIDE_WATER_CURRENT_UP, + [DIR_WEST] = MOVEMENT_ACTION_RIDE_WATER_CURRENT_LEFT, + [DIR_EAST] = MOVEMENT_ACTION_RIDE_WATER_CURRENT_RIGHT, + [DIR_SOUTHWEST] = MOVEMENT_ACTION_RIDE_WATER_CURRENT_DOWN_LEFT, + [DIR_SOUTHEAST] = MOVEMENT_ACTION_RIDE_WATER_CURRENT_DOWN_RIGHT, + [DIR_NORTHWEST] = MOVEMENT_ACTION_RIDE_WATER_CURRENT_UP_LEFT, + [DIR_NORTHEAST] = MOVEMENT_ACTION_RIDE_WATER_CURRENT_UP_RIGHT }; const u8 gWalkFastestMovementActions[] = { - MOVEMENT_ACTION_WALK_FASTEST_DOWN, - MOVEMENT_ACTION_WALK_FASTEST_DOWN, - MOVEMENT_ACTION_WALK_FASTEST_UP, - MOVEMENT_ACTION_WALK_FASTEST_LEFT, - MOVEMENT_ACTION_WALK_FASTEST_RIGHT, + [DIR_NONE] = MOVEMENT_ACTION_WALK_FASTEST_DOWN, + [DIR_SOUTH] = MOVEMENT_ACTION_WALK_FASTEST_DOWN, + [DIR_NORTH] = MOVEMENT_ACTION_WALK_FASTEST_UP, + [DIR_WEST] = MOVEMENT_ACTION_WALK_FASTEST_LEFT, + [DIR_EAST] = MOVEMENT_ACTION_WALK_FASTEST_RIGHT, + [DIR_SOUTHWEST] = MOVEMENT_ACTION_RIDE_WATER_CURRENT_DOWN_LEFT, + [DIR_SOUTHEAST] = MOVEMENT_ACTION_RIDE_WATER_CURRENT_DOWN_RIGHT, + [DIR_NORTHWEST] = MOVEMENT_ACTION_RIDE_WATER_CURRENT_UP_LEFT, + [DIR_NORTHEAST] = MOVEMENT_ACTION_RIDE_WATER_CURRENT_UP_RIGHT }; const u8 gSlideMovementActions[] = { MOVEMENT_ACTION_SLIDE_DOWN, @@ -999,11 +1039,11 @@ const u8 gWalkInPlaceFastestMovementActions[] = { MOVEMENT_ACTION_WALK_IN_PLACE_FASTEST_RIGHT, }; const u8 gAcroWheelieFaceDirectionMovementActions[] = { - MOVEMENT_ACTION_ACRO_WHEELIE_FACE_DOWN, - MOVEMENT_ACTION_ACRO_WHEELIE_FACE_DOWN, - MOVEMENT_ACTION_ACRO_WHEELIE_FACE_UP, - MOVEMENT_ACTION_ACRO_WHEELIE_FACE_LEFT, - MOVEMENT_ACTION_ACRO_WHEELIE_FACE_RIGHT, + [DIR_NONE] = MOVEMENT_ACTION_ACRO_WHEELIE_FACE_DOWN, + [DIR_SOUTH] = MOVEMENT_ACTION_ACRO_WHEELIE_FACE_DOWN, + [DIR_NORTH] = MOVEMENT_ACTION_ACRO_WHEELIE_FACE_UP, + [DIR_WEST] = MOVEMENT_ACTION_ACRO_WHEELIE_FACE_LEFT, + [DIR_EAST] = MOVEMENT_ACTION_ACRO_WHEELIE_FACE_RIGHT, }; const u8 gAcroPopWheelieFaceDirectionMovementActions[] = { MOVEMENT_ACTION_ACRO_POP_WHEELIE_DOWN, @@ -1027,11 +1067,15 @@ const u8 gAcroWheelieHopFaceDirectionMovementActions[] = { MOVEMENT_ACTION_ACRO_WHEELIE_HOP_FACE_RIGHT, }; const u8 gAcroWheelieHopDirectionMovementActions[] = { - MOVEMENT_ACTION_ACRO_WHEELIE_HOP_DOWN, - MOVEMENT_ACTION_ACRO_WHEELIE_HOP_DOWN, - MOVEMENT_ACTION_ACRO_WHEELIE_HOP_UP, - MOVEMENT_ACTION_ACRO_WHEELIE_HOP_LEFT, - MOVEMENT_ACTION_ACRO_WHEELIE_HOP_RIGHT, + [DIR_NONE] = MOVEMENT_ACTION_ACRO_WHEELIE_HOP_DOWN, + [DIR_SOUTH] = MOVEMENT_ACTION_ACRO_WHEELIE_HOP_DOWN, + [DIR_NORTH] = MOVEMENT_ACTION_ACRO_WHEELIE_HOP_UP, + [DIR_WEST] = MOVEMENT_ACTION_ACRO_WHEELIE_HOP_LEFT, + [DIR_EAST] = MOVEMENT_ACTION_ACRO_WHEELIE_HOP_RIGHT, + /*[DIR_SOUTHWEST] = MOVEMENT_ACTION_ACRO_WHEELIE_HOP_LEFT, + [DIR_SOUTHEAST] = MOVEMENT_ACTION_ACRO_WHEELIE_HOP_RIGHT, + [DIR_NORTHWEST] = MOVEMENT_ACTION_ACRO_WHEELIE_HOP_LEFT, + [DIR_NORTHEAST] = MOVEMENT_ACTION_ACRO_WHEELIE_HOP_RIGHT*/ }; const u8 gAcroWheelieJumpDirectionMovementActions[] = { MOVEMENT_ACTION_ACRO_WHEELIE_JUMP_DOWN, @@ -1068,6 +1112,59 @@ const u8 gAcroEndWheelieMoveDirectionMovementActions[] = { MOVEMENT_ACTION_ACRO_END_WHEELIE_MOVE_LEFT, MOVEMENT_ACTION_ACRO_END_WHEELIE_MOVE_RIGHT, }; +// run slow +const u8 gRunSlowMovementActions[] = { + [DIR_NONE] = MOVEMENT_ACTION_RUN_DOWN_SLOW, + [DIR_SOUTH] = MOVEMENT_ACTION_RUN_DOWN_SLOW, + [DIR_NORTH] = MOVEMENT_ACTION_RUN_UP_SLOW, + [DIR_WEST] = MOVEMENT_ACTION_RUN_LEFT_SLOW, + [DIR_EAST] = MOVEMENT_ACTION_RUN_RIGHT_SLOW, +}; + +// sideways stairs +const u8 gDiagonalStairRightMovementActions[] = { + [DIR_NONE] = MOVEMENT_ACTION_JUMP_2_RIGHT, + [DIR_SOUTH] = MOVEMENT_ACTION_JUMP_2_DOWN, + [DIR_NORTH] = MOVEMENT_ACTION_JUMP_2_UP, + [DIR_WEST] = MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_DOWN_LEFT, + [DIR_EAST] = MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_UP_RIGHT, +}; +const u8 gDiagonalStairLeftMovementActions[] = { + [DIR_NONE] = MOVEMENT_ACTION_JUMP_2_LEFT, + [DIR_SOUTH] = MOVEMENT_ACTION_JUMP_2_DOWN, + [DIR_NORTH] = MOVEMENT_ACTION_JUMP_2_UP, + [DIR_WEST] = MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_UP_LEFT, + [DIR_EAST] = MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_DOWN_RIGHT, +}; +const u8 gDiagonalStairRightRunningMovementActions[] = { + [DIR_NONE] = MOVEMENT_ACTION_JUMP_2_RIGHT, + [DIR_SOUTH] = MOVEMENT_ACTION_JUMP_2_DOWN, + [DIR_NORTH] = MOVEMENT_ACTION_JUMP_2_UP, + [DIR_WEST] = MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_DOWN_LEFT_RUNNING, + [DIR_EAST] = MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_UP_RIGHT_RUNNING, +}; +const u8 gDiagonalStairLeftRunningMovementActions[] = { + [DIR_NONE] = MOVEMENT_ACTION_JUMP_2_LEFT, + [DIR_SOUTH] = MOVEMENT_ACTION_JUMP_2_DOWN, + [DIR_NORTH] = MOVEMENT_ACTION_JUMP_2_UP, + [DIR_WEST] = MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_UP_LEFT_RUNNING, + [DIR_EAST] = MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_DOWN_RIGHT_RUNNING, +}; +const u8 gDiagonalStairLeftAcroBikeMovementActions[] = { + [DIR_NONE] = MOVEMENT_ACTION_RIDE_WATER_CURRENT_LEFT, + [DIR_SOUTH] = MOVEMENT_ACTION_RIDE_WATER_CURRENT_LEFT, + [DIR_NORTH] = MOVEMENT_ACTION_RIDE_WATER_CURRENT_LEFT, + [DIR_WEST] = MOVEMENT_ACTION_RIDE_WATER_CURRENT_UP_LEFT, + [DIR_EAST] = MOVEMENT_ACTION_RIDE_WATER_CURRENT_DOWN_RIGHT, + +}; +const u8 gDiagonalStairRightAcroBikeMovementActions[] = { + [DIR_NONE] = MOVEMENT_ACTION_RIDE_WATER_CURRENT_RIGHT, + [DIR_SOUTH] = MOVEMENT_ACTION_RIDE_WATER_CURRENT_RIGHT, + [DIR_NORTH] = MOVEMENT_ACTION_RIDE_WATER_CURRENT_RIGHT, + [DIR_WEST] = MOVEMENT_ACTION_RIDE_WATER_CURRENT_DOWN_LEFT, + [DIR_EAST] = MOVEMENT_ACTION_RIDE_WATER_CURRENT_UP_RIGHT, +}; const u8 gOppositeDirections[] = { DIR_NORTH, @@ -5058,12 +5155,21 @@ u8 name(u32 idx)\ u8 animIds[sizeof(table)];\ direction = idx;\ memcpy(animIds, (table), sizeof(table));\ - if (direction > DIR_EAST) direction = 0;\ + if (direction > sizeof(table)) direction = 0;\ return animIds[direction];\ } +//sideways stairs +dirn_to_anim(GetDiagonalRightStairsMovement, gDiagonalStairRightMovementActions); +dirn_to_anim(GetDiagonalLeftStairsMovement, gDiagonalStairLeftMovementActions); +dirn_to_anim(GetDiagonalRightStairsRunningMovement, gDiagonalStairRightRunningMovementActions); +dirn_to_anim(GetDiagonalLeftStairsRunningMovement, gDiagonalStairLeftRunningMovementActions); +dirn_to_anim(GetDiagonalLeftAcroBikeMovement, gDiagonalStairLeftAcroBikeMovementActions); +dirn_to_anim(GetDiagonalRightAcroBikeMovement, gDiagonalStairRightAcroBikeMovementActions); + dirn_to_anim(GetFaceDirectionMovementAction, gFaceDirectionMovementActions); dirn_to_anim(GetWalkSlowMovementAction, gWalkSlowMovementActions); +dirn_to_anim(GetPlayerRunSlowMovementAction, gRunSlowMovementActions); dirn_to_anim(GetWalkNormalMovementAction, gWalkNormalMovementActions); dirn_to_anim(GetWalkFastMovementAction, gWalkFastMovementActions); dirn_to_anim(GetRideWaterCurrentMovementAction, gRideWaterCurrentMovementActions); @@ -9044,3 +9150,254 @@ u8 MovementAction_Fly_Finish(struct ObjectEvent *objectEvent, struct Sprite *spr { return TRUE; } + +// running slow +static void StartSlowRunningAnim(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 direction) +{ + sub_8093AF0(objectEvent, sprite, direction); + npc_apply_anim_looping(objectEvent, sprite, GetRunningDirectionAnimNum(objectEvent->facingDirection)); +} + +#define tDirection data[3] +#define tDelay data[4] +#define tStepNo data[5] +static bool8 obj_npc_ministep_slow(struct Sprite *sprite) +{ + if ((++sprite->tDelay) & 1) + { + Step1(sprite, sprite->tDirection); + sprite->tStepNo++; + } + else + { + Step2(sprite, sprite->tDirection); + sprite->tStepNo += 2; + } + + if (sprite->tStepNo > 15) + return TRUE; + else + return FALSE; +} +static bool8 npc_obj_ministep_stop_on_arrival_slow(struct ObjectEvent *objectEvent, struct Sprite *sprite) +{ + if (obj_npc_ministep_slow(sprite)) + { + ShiftStillObjectEventCoords(objectEvent); + objectEvent->triggerGroundEffectsOnStop = TRUE; + sprite->animPaused = TRUE; + return TRUE; + } + return FALSE; +} + + +bool8 MovementActionFunc_RunSlowDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) +{ + StartSlowRunningAnim(objectEvent, sprite, DIR_SOUTH); + return MovementActionFunc_RunSlow_Step1(objectEvent, sprite); +} + +bool8 MovementActionFunc_RunSlowUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) +{ + StartSlowRunningAnim(objectEvent, sprite, DIR_NORTH); + return MovementActionFunc_RunSlow_Step1(objectEvent, sprite); +} + +bool8 MovementActionFunc_RunSlowLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) +{ + StartSlowRunningAnim(objectEvent, sprite, DIR_WEST); + return MovementActionFunc_RunSlow_Step1(objectEvent, sprite); +} + +bool8 MovementActionFunc_RunSlowRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) +{ + StartSlowRunningAnim(objectEvent, sprite, DIR_EAST); + return MovementActionFunc_RunSlow_Step1(objectEvent, sprite); +} + +bool8 MovementActionFunc_RunSlow_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) +{ + if (npc_obj_ministep_stop_on_arrival_slow(objectEvent, sprite)) + { + sprite->data[2] = 2; + return TRUE; + } + return FALSE; +} + +//sideways stairs +u8 GetSidewaysStairsToRightDirection(s16 x, s16 y, u8 z) +{ + static bool8 (*const direction[])(u8) = { + MetatileBehavior_IsWalkSouth, + MetatileBehavior_IsWalkNorth, + MetatileBehavior_IsSidewaysStairsRight, + MetatileBehavior_IsSidewaysStairsRight, + }; + + u8 b; + u8 index = z; + + if (index == 0) + return 0; + else if (index > 4) + index -= 4; + + index--; + b = MapGridGetMetatileBehaviorAt(x, y); + + if (direction[index](b) == 1) + return index + 1; + + return 0; +} + +u8 GetSidewaysStairsToLeftDirection(s16 x, s16 y, u8 z) +{ + static bool8 (*const direction[])(u8) = { + MetatileBehavior_IsWalkSouth, + MetatileBehavior_IsWalkNorth, + MetatileBehavior_IsSidewaysStairsLeft, + MetatileBehavior_IsSidewaysStairsLeft, + }; + + u8 b; + u8 index = z; + + if (index == 0) + return 0; + else if (index > 4) + index -= 4; + + index--; + b = MapGridGetMetatileBehaviorAt(x, y); + + if (direction[index](b) == 1) + return index + 1; + + return 0; +} + +bool8 MovementAction_WalkStairDiagonalUpLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) +{ + objectEvent->facingDirection = DIR_WEST; + objectEvent->facingDirectionLocked = TRUE; + sub_8093B60(objectEvent, sprite, DIR_NORTHWEST); + return MovementAction_WalkSlowDiagonalUpLeft_Step1(objectEvent, sprite); +} + +bool8 MovementAction_WalkStairDiagonalUpRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) +{ + objectEvent->facingDirection = DIR_EAST; + objectEvent->facingDirectionLocked = TRUE; + sub_8093B60(objectEvent, sprite, DIR_NORTHEAST); + return MovementAction_WalkSlowDiagonalUpRight_Step1(objectEvent, sprite); +} + +bool8 MovementAction_WalkStairDiagonalDownLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) +{ + objectEvent->facingDirection = DIR_WEST; + objectEvent->facingDirectionLocked = TRUE; + sub_8093B60(objectEvent, sprite, DIR_SOUTHWEST); + return MovementAction_WalkSlowDiagonalDownLeft_Step1(objectEvent, sprite); +} + +bool8 MovementAction_WalkStairDiagonalDownRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) +{ + objectEvent->facingDirection = DIR_EAST; + objectEvent->facingDirectionLocked = TRUE; + sub_8093B60(objectEvent, sprite, DIR_SOUTHEAST); + return MovementAction_WalkSlowDiagonalDownRight_Step1(objectEvent, sprite); +} + +bool8 MovementAction_RunStairDiagonalUpLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) +{ + objectEvent->facingDirection = DIR_WEST; + objectEvent->facingDirectionLocked = TRUE; + StartSlowRunningAnim(objectEvent, sprite, DIR_NORTHWEST); + return MovementAction_RunStairDiagonal_Step1(objectEvent, sprite); +} + +bool8 MovementAction_RunStairDiagonalUpRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) +{ + objectEvent->facingDirection = DIR_EAST; + objectEvent->facingDirectionLocked = TRUE; + StartSlowRunningAnim(objectEvent, sprite, DIR_NORTHEAST); + return MovementAction_RunStairDiagonal_Step1(objectEvent, sprite); +} + +bool8 MovementAction_RunStairDiagonalDownLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) +{ + objectEvent->facingDirection = DIR_WEST; + objectEvent->facingDirectionLocked = TRUE; + StartSlowRunningAnim(objectEvent, sprite, DIR_SOUTHWEST); + return MovementAction_RunStairDiagonal_Step1(objectEvent, sprite); +} + +bool8 MovementAction_RunStairDiagonalDownRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) +{ + objectEvent->facingDirection = DIR_EAST; + objectEvent->facingDirectionLocked = TRUE; + StartSlowRunningAnim(objectEvent, sprite, DIR_SOUTHEAST); + return MovementAction_RunStairDiagonal_Step1(objectEvent, sprite); +} + +bool8 MovementAction_RunStairDiagonal_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) +{ + if (npc_obj_ministep_stop_on_arrival(objectEvent, sprite)) + { + sprite->data[2] = 2; + return TRUE; + } + return FALSE; +} + +bool8 MovementAction_AcroBikeDiagonalUpLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) +{ + objectEvent->facingDirection = DIR_WEST; + objectEvent->facingDirectionLocked = TRUE; + #if SLOW_MOVEMENT_ON_STAIRS + do_go_anim(objectEvent, sprite, DIR_NORTHWEST, 0); + #else + do_go_anim(objectEvent, sprite, DIR_NORTHWEST, 2); + #endif + return MovementAction_RideWaterCurrentLeft_Step1(objectEvent, sprite); +} + +bool8 MovementAction_AcroBikeDiagonalDownLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) +{ + objectEvent->facingDirection = DIR_WEST; + objectEvent->facingDirectionLocked = TRUE; + #if SLOW_MOVEMENT_ON_STAIRS + do_go_anim(objectEvent, sprite, DIR_SOUTHWEST, 0); + #else + do_go_anim(objectEvent, sprite, DIR_SOUTHWEST, 2); + #endif + return MovementAction_RideWaterCurrentLeft_Step1(objectEvent, sprite); +} + +bool8 MovementAction_AcroBikeDiagonalUpRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) +{ + objectEvent->facingDirection = DIR_EAST; + objectEvent->facingDirectionLocked = TRUE; + #if SLOW_MOVEMENT_ON_STAIRS + do_go_anim(objectEvent, sprite, DIR_NORTHEAST, 0); + #else + do_go_anim(objectEvent, sprite, DIR_NORTHEAST, 2); + #endif + return MovementAction_RideWaterCurrentRight_Step1(objectEvent, sprite); +} + +bool8 MovementAction_AcroBikeDiagonalDownRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) +{ + objectEvent->facingDirection = DIR_EAST; + objectEvent->facingDirectionLocked = TRUE; + #if SLOW_MOVEMENT_ON_STAIRS + do_go_anim(objectEvent, sprite, DIR_SOUTHEAST, 0); + #else + do_go_anim(objectEvent, sprite, DIR_SOUTHEAST, 2); + #endif + return MovementAction_RideWaterCurrentRight_Step1(objectEvent, sprite); +} + diff --git a/src/field_player_avatar.c b/src/field_player_avatar.c index 4f85ad628b60..0a98f3dc7c19 100644 --- a/src/field_player_avatar.c +++ b/src/field_player_avatar.c @@ -44,6 +44,8 @@ static void MovePlayerAvatarUsingKeypadInput(u8, u16, u16); static void PlayerAllowForcedMovementIfMovingSameDirection(); static bool8 TryDoMetatileBehaviorForcedMovement(); static u8 GetForcedMovementByMetatileBehavior(); +static bool8 IsSidewaysStairToRight(s16, s16, u8); +static bool8 IsSidewaysStairToLeft(s16, s16, u8); static bool8 ForcedMovement_None(void); static bool8 ForcedMovement_Slip(void); @@ -90,6 +92,8 @@ static bool8 sub_808B618(void); static bool8 PlayerIsAnimActive(void); static bool8 PlayerCheckIfAnimFinishedOrInactive(void); +static void PlayerGoSlow(u8 direction); +static void PlayerRunSlow(u8 direction); static void PlayerRun(u8); static void PlayerNotOnBikeCollide(u8); static void PlayerNotOnBikeCollideWithFarawayIslandMew(u8); @@ -407,7 +411,7 @@ static u8 GetForcedMovementByMetatileBehavior(void) { u8 metatileBehavior = gObjectEvents[gPlayerAvatar.objectEventId].currentMetatileBehavior; - for (i = 0; i < 18; i++) + for (i = 0; i < NELEMS(sForcedMovementTestFuncs); i++) { if (sForcedMovementTestFuncs[i](metatileBehavior)) return i + 1; @@ -607,7 +611,7 @@ static void PlayerNotOnBikeTurningInPlace(u8 direction, u16 heldKeys) static void PlayerNotOnBikeMoving(u8 direction, u16 heldKeys) { u8 collision = CheckForPlayerAvatarCollision(direction); - + if (collision) { if (collision == COLLISION_LEDGE_JUMP) @@ -620,6 +624,26 @@ static void PlayerNotOnBikeMoving(u8 direction, u16 heldKeys) PlayerNotOnBikeCollideWithFarawayIslandMew(direction); return; } + else if (collision == COLLISION_SIDEWAYS_STAIRS_TO_RIGHT_WALKING) + { + PlayerSidewaysStairsToRight(direction); + return; + } + else if (collision == COLLISION_SIDEWAYS_STAIRS_TO_LEFT_WALKING) + { + PlayerSidewaysStairsToLeft(direction); + return; + } + else if (collision == COLLISION_SIDEWAYS_STAIRS_TO_RIGHT_RUNNING) + { + PlayerSidewaysStairsToRightRunning(direction); + return; + } + else if (collision == COLLISION_SIDEWAYS_STAIRS_TO_LEFT_RUNNING) + { + PlayerSidewaysStairsToLeftRunning(direction); + return; + } else { u8 adjustedCollision = collision - COLLISION_STOP_SURFING; @@ -628,10 +652,10 @@ static void PlayerNotOnBikeMoving(u8 direction, u16 heldKeys) return; } } - + if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_SURFING) { - // speed 2 is fast, same speed as running + // speed 2 is fast, same speed as running PlayerGoSpeed2(direction); return; } @@ -639,16 +663,65 @@ static void PlayerNotOnBikeMoving(u8 direction, u16 heldKeys) if (!(gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_UNDERWATER) && (heldKeys & B_BUTTON) && FlagGet(FLAG_SYS_B_DASH) && IsRunningDisallowed(gObjectEvents[gPlayerAvatar.objectEventId].currentMetatileBehavior) == 0) { - PlayerRun(direction); + if (PlayerIsMovingOnRockStairs(direction)) + PlayerRunSlow(direction); + else + PlayerRun(direction); + gPlayerAvatar.flags |= PLAYER_AVATAR_FLAG_DASH; return; } else { - PlayerGoSpeed1(direction); + if (PlayerIsMovingOnRockStairs(direction)) + PlayerGoSlow(direction); + else + PlayerGoSpeed1(direction); } } +bool32 PlayerIsMovingOnRockStairs(u8 direction) +{ + #if SLOW_MOVEMENT_ON_STAIRS + struct ObjectEvent *objectEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; + s16 x = objectEvent->currentCoords.x; + s16 y = objectEvent->currentCoords.y; + + switch (direction) + { + case DIR_NORTH: + return MetatileBehavior_IsRockStairs(MapGridGetMetatileBehaviorAt(x, y)); + case DIR_SOUTH: + MoveCoords(DIR_SOUTH, &x, &y); + return MetatileBehavior_IsRockStairs(MapGridGetMetatileBehaviorAt(x, y)); + /* + case DIR_WEST: + MoveCoords(DIR_WEST, &x, &y); + return MetatileBehavior_IsRockStairs(MapGridGetMetatileBehaviorAt(x, y)); + case DIR_EAST: + MoveCoords(DIR_EAST, &x, &y); + return MetatileBehavior_IsRockStairs(MapGridGetMetatileBehaviorAt(x, y)); + case DIR_SOUTHWEST: + MoveCoords(DIR_SOUTHWEST, &x, &y); + return MetatileBehavior_IsRockStairs(MapGridGetMetatileBehaviorAt(x, y)); + case DIR_SOUTHEAST: + MoveCoords(DIR_SOUTHEAST, &x, &y); + return MetatileBehavior_IsRockStairs(MapGridGetMetatileBehaviorAt(x, y)); + case DIR_NORTHWEST: + MoveCoords(DIR_NORTHWEST, &x, &y); + return MetatileBehavior_IsRockStairs(MapGridGetMetatileBehaviorAt(x, y)); + case DIR_NORTHEAST: + MoveCoords(DIR_NORTHEAST, &x, &y); + return MetatileBehavior_IsRockStairs(MapGridGetMetatileBehaviorAt(x, y)); + */ + default: + return FALSE; + } + #else + return FALSE + #endif +} + static u8 CheckForPlayerAvatarCollision(u8 direction) { s16 x, y; @@ -656,6 +729,7 @@ static u8 CheckForPlayerAvatarCollision(u8 direction) x = playerObjEvent->currentCoords.x; y = playerObjEvent->currentCoords.y; + MoveCoords(direction, &x, &y); return CheckForObjectEventCollision(playerObjEvent, x, y, direction, MapGridGetMetatileBehaviorAt(x, y)); } @@ -691,7 +765,26 @@ u8 CheckForObjectEventCollision(struct ObjectEvent *objectEvent, s16 x, s16 y, u return COLLISION_ROTATING_GATE; CheckAcroBikeCollision(x, y, metatileBehavior, &collision); } - return collision; + + if (collision != COLLISION_IMPASSABLE) + { + if (IsSidewaysStairToRight(x, y, direction)) + { + if (gMain.heldKeys & B_BUTTON) + return COLLISION_SIDEWAYS_STAIRS_TO_RIGHT_RUNNING; + else + return COLLISION_SIDEWAYS_STAIRS_TO_RIGHT_WALKING; + } + else if (IsSidewaysStairToLeft(x, y, direction)) + { + if (gMain.heldKeys & B_BUTTON) + return COLLISION_SIDEWAYS_STAIRS_TO_LEFT_RUNNING; + else + return COLLISION_SIDEWAYS_STAIRS_TO_LEFT_WALKING; + } + } + + return collision; } static u8 sub_808B164(struct ObjectEvent *objectEvent, s16 x, s16 y, u8 direction, u8 metatileBehavior) @@ -953,6 +1046,16 @@ void PlayerSetAnimId(u8 movementActionId, u8 copyableMovement) } } +// slow +static void PlayerGoSlow(u8 direction) +{ + PlayerSetAnimId(GetWalkSlowMovementAction(direction), 2); +} +static void PlayerRunSlow(u8 direction) +{ + PlayerSetAnimId(GetPlayerRunSlowMovementAction(direction), 2); +} + // normal speed (1 speed) void PlayerGoSpeed1(u8 a) { @@ -965,6 +1068,7 @@ void PlayerGoSpeed2(u8 a) PlayerSetAnimId(GetWalkFastMovementAction(a), 2); } +// acro bike speed void PlayerRideWaterCurrent(u8 a) { PlayerSetAnimId(GetRideWaterCurrentMovementAction(a), 2); @@ -2215,3 +2319,83 @@ static u8 TrySpinPlayerForWarp(struct ObjectEvent *object, s16 *delayTimer) *delayTimer = 0; return sSpinDirections[object->facingDirection]; } + +//sideways stairs +static bool8 IsSidewaysStairToRight(s16 x, s16 y, u8 z) +{ + if (GetSidewaysStairsToRightDirection(x, y, z) != 0) + return TRUE; + else + return FALSE; +} + +static bool8 IsSidewaysStairToLeft(s16 x, s16 y, u8 z) +{ + if (GetSidewaysStairsToLeftDirection(x, y, z) != 0) + return TRUE; + else + return FALSE; +} + +u8 GetRightStairsDirection(u8 direction) +{ + switch (direction) + { + case DIR_WEST: + return DIR_SOUTHWEST; + case DIR_EAST: + return DIR_NORTHEAST; + default: + if (direction > DIR_EAST) + direction -= DIR_EAST; + + return direction; + } +} + +u8 GetLeftStairsDirection(u8 direction) +{ + switch (direction) + { + case DIR_WEST: + return DIR_NORTHWEST; + case DIR_EAST: + return DIR_SOUTHEAST; + default: + if (direction > DIR_EAST) + direction -= DIR_EAST; + + return direction; + } +} + +void PlayerSidewaysStairsToRight(u8 direction) +{ + PlayerSetAnimId(GetDiagonalRightStairsMovement(direction), 8); +} + +void PlayerSidewaysStairsToLeft(u8 direction) +{ + PlayerSetAnimId(GetDiagonalLeftStairsMovement(direction), 8); +} + +void PlayerSidewaysStairsToRightRunning(u8 direction) +{ + PlayerSetAnimId(GetDiagonalRightStairsRunningMovement(direction), 8); +} + +void PlayerSidewaysStairsToLeftRunning(u8 direction) +{ + PlayerSetAnimId(GetDiagonalLeftStairsRunningMovement(direction), 8); +} + +void PlayerSidewaysStairsToAcroBikeLeft(u8 direction) +{ + PlayerSetAnimId(GetDiagonalLeftAcroBikeMovement(direction), 8); +} + +void PlayerSidewaysStairsToAcroBikeRight(u8 direction) +{ + PlayerSetAnimId(GetDiagonalRightAcroBikeMovement(direction), 8); +} + diff --git a/src/metatile_behavior.c b/src/metatile_behavior.c index 2a9304a4d8e5..fa773a3b7e80 100644 --- a/src/metatile_behavior.c +++ b/src/metatile_behavior.c @@ -83,9 +83,9 @@ static const u8 sTileBitAttributes[] = [MB_SLIDE_NORTH] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE), [MB_SLIDE_SOUTH] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE), [MB_TRICK_HOUSE_PUZZLE_8_FLOOR] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE), - [MB_UNUSED_49] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE), - [MB_UNUSED_4A] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE), - [MB_UNUSED_4B] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + [MB_SIDEWAYS_STAIRS_RIGHT] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + [MB_SIDEWAYS_STAIRS_LEFT] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + [MB_ROCK_STAIRS] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE), [MB_UNUSED_4C] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE), [MB_UNUSED_4D] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE), [MB_UNUSED_4E] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE), @@ -1495,3 +1495,27 @@ bool8 MetatileBehavior_IsTrainerHillTimer(u8 metatileBehavior) else return FALSE; } + +bool8 MetatileBehavior_IsSidewaysStairsRight(u8 metatileBehavior) +{ + if (metatileBehavior == MB_SIDEWAYS_STAIRS_RIGHT) + return TRUE; + else + return FALSE; +} + +bool8 MetatileBehavior_IsSidewaysStairsLeft(u8 metatileBehavior) +{ + if (metatileBehavior == MB_SIDEWAYS_STAIRS_LEFT) + return TRUE; + else + return FALSE; +} + +bool8 MetatileBehavior_IsRockStairs(u8 metatileBehavior) +{ + if (metatileBehavior == MB_ROCK_STAIRS) // || metatileBehavior == MB_SIDEWAYS_STAIRS_LEFT || metatileBehavior == MB_SIDEWAYS_STAIRS_RIGHT) + return TRUE; + else + return FALSE; +} From e4674ccd03d351e70571ec805729e5b8639ec31c Mon Sep 17 00:00:00 2001 From: Evan Date: Thu, 4 Jun 2020 20:30:27 -0600 Subject: [PATCH 03/27] fully working walk/run/mach bike/acro bike regular movement --- include/constants/event_object_movement.h | 3 - include/constants/global.h | 2 + include/constants/metatile_behaviors.h | 14 +-- include/field_player_avatar.h | 12 +-- include/global.fieldmap.h | 6 +- include/metatile_behavior.h | 10 ++- src/bike.c | 51 ++++++----- src/event_object_movement.c | 86 +++++++++--------- src/field_player_avatar.c | 105 +++++++++++++--------- src/metatile_behavior.c | 72 ++++++++++++--- 10 files changed, 223 insertions(+), 138 deletions(-) diff --git a/include/constants/event_object_movement.h b/include/constants/event_object_movement.h index 9bd3e87c6c93..5172e12d514e 100755 --- a/include/constants/event_object_movement.h +++ b/include/constants/event_object_movement.h @@ -1,8 +1,6 @@ #ifndef GUARD_CONSTANTS_EVENT_OBJECT_MOVEMENT_H #define GUARD_CONSTANTS_EVENT_OBJECT_MOVEMENT_H -#define SLOW_MOVEMENT_ON_STAIRS TRUE // change to false to keep emerald's normal movement speed on outdoor stairs - #define MOVEMENT_TYPE_NONE 0x0 #define MOVEMENT_TYPE_LOOK_AROUND 0x1 #define MOVEMENT_TYPE_WANDER_AROUND 0x2 @@ -265,7 +263,6 @@ #define MOVEMENT_ACTION_RIDE_WATER_CURRENT_DOWN_RIGHT 0xAD //sideways stairs - mach bike - #define MOVEMENT_ACTION_STEP_END 0xFE #endif // GUARD_CONSTANTS_EVENT_OBJECT_MOVEMENT_H diff --git a/include/constants/global.h b/include/constants/global.h index 213ccca5b54e..4a3f0618a8f0 100644 --- a/include/constants/global.h +++ b/include/constants/global.h @@ -118,4 +118,6 @@ #define DIR_NORTHWEST 7 #define DIR_NORTHEAST 8 +#define SLOW_MOVEMENT_ON_STAIRS TRUE // change to false to keep emerald's normal movement speed on outdoor stairs + #endif // GUARD_CONSTANTS_GLOBAL_H diff --git a/include/constants/metatile_behaviors.h b/include/constants/metatile_behaviors.h index ef79f0b6d3ae..07e055380092 100755 --- a/include/constants/metatile_behaviors.h +++ b/include/constants/metatile_behaviors.h @@ -74,13 +74,13 @@ #define MB_SLIDE_NORTH 0x46 #define MB_SLIDE_SOUTH 0x47 #define MB_TRICK_HOUSE_PUZZLE_8_FLOOR 0x48 -#define MB_SIDEWAYS_STAIRS_RIGHT 0x49 -#define MB_SIDEWAYS_STAIRS_LEFT 0x4A -#define MB_ROCK_STAIRS 0x4B -#define MB_UNUSED_4C 0x4C -#define MB_UNUSED_4D 0x4D -#define MB_UNUSED_4E 0x4E -#define MB_UNUSED_4F 0x4F +#define MB_SIDEWAYS_STAIRS_RIGHT_SIDE 0x49 +#define MB_SIDEWAYS_STAIRS_LEFT_SIDE 0x4A +#define MB_SIDEWAYS_STAIRS_RIGHT_SIDE_TOP 0x4B +#define MB_SIDEWAYS_STAIRS_LEFT_SIDE_TOP 0x4C +#define MB_SIDEWAYS_STAIRS_RIGHT_SIDE_BOTTOM 0x4D +#define MB_SIDEWAYS_STAIRS_LEFT_SIDE_BOTTOM 0x4E +#define MB_ROCK_STAIRS 0x4F #define MB_EASTWARD_CURRENT 0x50 #define MB_WESTWARD_CURRENT 0x51 #define MB_NORTHWARD_CURRENT 0x52 diff --git a/include/field_player_avatar.h b/include/field_player_avatar.h index 3177a887ce75..d7b04d40ff8f 100644 --- a/include/field_player_avatar.h +++ b/include/field_player_avatar.h @@ -66,12 +66,12 @@ u8 player_get_pos_including_state_based_drift(s16 *x, s16 *y); void StartFishing(u8 rod); bool32 PlayerIsMovingOnRockStairs(u8 direction); //sideways stairs -u8 GetRightStairsDirection(u8 direction); -u8 GetLeftStairsDirection(u8 direction); -void PlayerSidewaysStairsToRight(u8 direction); -void PlayerSidewaysStairsToLeft(u8 direction); -void PlayerSidewaysStairsToRightRunning(u8 direction); -void PlayerSidewaysStairsToLeftRunning(u8 direction); +u8 GetRightSideStairsDirection(u8 direction); +u8 GetLeftSideStairsDirection(u8 direction); +void PlayerSidewaysStairsRightSide(u8 direction); +void PlayerSidewaysStairsLeftSide(u8 direction); +void PlayerSidewaysStairsRightSideRunning(u8 direction); +void PlayerSidewaysStairsLeftSideRunning(u8 direction); void PlayerSidewaysStairsToAcroBikeLeft(u8 direction); void PlayerSidewaysStairsToAcroBikeRight(u8 direction); diff --git a/include/global.fieldmap.h b/include/global.fieldmap.h index baedb9bf3750..a4c486c960cc 100644 --- a/include/global.fieldmap.h +++ b/include/global.fieldmap.h @@ -279,10 +279,8 @@ enum COLLISION_VERTICAL_RAIL, COLLISION_HORIZONTAL_RAIL, //sideways_stairs - COLLISION_SIDEWAYS_STAIRS_TO_RIGHT_WALKING, - COLLISION_SIDEWAYS_STAIRS_TO_LEFT_WALKING, - COLLISION_SIDEWAYS_STAIRS_TO_RIGHT_RUNNING, - COLLISION_SIDEWAYS_STAIRS_TO_LEFT_RUNNING, + COLLISION_SIDEWAYS_STAIRS_TO_RIGHT, + COLLISION_SIDEWAYS_STAIRS_TO_LEFT }; // player running states diff --git a/include/metatile_behavior.h b/include/metatile_behavior.h index f5781a337110..715f9ef12779 100644 --- a/include/metatile_behavior.h +++ b/include/metatile_behavior.h @@ -147,7 +147,13 @@ bool8 MetatileBehavior_IsLongGrassSouthEdge(u8); bool8 MetatileBehavior_IsTrainerHillTimer(u8); bool8 MetatileBehavior_IsRockStairs(u8 metatileBehavior); //sideways stairs -bool8 MetatileBehavior_IsSidewaysStairsRight(u8); -bool8 MetatileBehavior_IsSidewaysStairsLeft(u8); +bool8 MetatileBehavior_IsSidewaysStairsRightSide(u8); +bool8 MetatileBehavior_IsSidewaysStairsLeftSide(u8); +bool8 MetatileBehavior_IsSidewaysStairsRightSideTop(u8 metatileBehavior); +bool8 MetatileBehavior_IsSidewaysStairsLeftSideTop(u8 metatileBehavior); +bool8 MetatileBehavior_IsSidewaysStairsRightSideBottom(u8 metatileBehavior); +bool8 MetatileBehavior_IsSidewaysStairsLeftSideBottom(u8 metatileBehavior); +bool8 MetatileBehavior_IsSidewaysStairsRightSideAny(u8 metatileBehavior); +bool8 MetatileBehavior_IsSidewaysStairsLeftSideAny(u8 metatileBehavior); #endif // GUARD_METATILE_BEHAVIOR diff --git a/src/bike.c b/src/bike.c index 18dbda6ba3db..a26451778e67 100644 --- a/src/bike.c +++ b/src/bike.c @@ -240,25 +240,24 @@ static void MachBikeTransition_TrySpeedUp(u8 direction) PlayerOnBikeCollide(direction); } } - else if (collision == COLLISION_SIDEWAYS_STAIRS_TO_LEFT_WALKING) + else if (collision == COLLISION_SIDEWAYS_STAIRS_TO_LEFT) { gPlayerAvatar.bikeFrameCounter = 0; gPlayerAvatar.bikeSpeed = SPEED_STANDING; - PlayerGoSpeed2(GetLeftStairsDirection(direction)); + PlayerGoSpeed2(GetLeftSideStairsDirection(direction)); //PlayerSidewaysStairsToAcroBikeLeft(direction); return; } - else if (collision == COLLISION_SIDEWAYS_STAIRS_TO_RIGHT_WALKING) + else if (collision == COLLISION_SIDEWAYS_STAIRS_TO_RIGHT) { gPlayerAvatar.bikeFrameCounter = 0; gPlayerAvatar.bikeSpeed = SPEED_STANDING; //PlayerSidewaysStairsToAcroBikeRight(direction); - PlayerGoSpeed2(GetRightStairsDirection(direction)); + PlayerGoSpeed2(GetRightSideStairsDirection(direction)); return; } else { - // to do: this sometimes crashes based on the metatile behaviours (eg. holding up while traveling down sideways stairs to sw) if (PlayerIsMovingOnRockStairs(direction)) gPlayerAvatar.bikeFrameCounter--; @@ -296,15 +295,14 @@ static void MachBikeTransition_TrySlowDown(u8 direction) } else { - /* - if (collision == COLLISION_SIDEWAYS_STAIRS_TO_LEFT_WALKING) + /*if (collision == COLLISION_SIDEWAYS_STAIRS_TO_LEFT) { - return PlayerGoSpeed2(GetLeftStairsDirection(direction)); + return PlayerGoSpeed2(GetLeftSideStairsDirection(direction)); //return PlayerSidewaysStairsToLeftMachBike(direction); } - else if (collision == COLLISION_SIDEWAYS_STAIRS_TO_RIGHT_WALKING) + else if (collision == COLLISION_SIDEWAYS_STAIRS_TO_RIGHT) { - return PlayerGoSpeed2(GetRightStairsDirection(direction)); + return PlayerGoSpeed2(GetRightSideStairsDirection(direction)); //return PlayerSidewaysStairsToRightMachBike(direction); }*/ @@ -315,6 +313,7 @@ static void MachBikeTransition_TrySlowDown(u8 direction) // the acro bike requires the input handler to be executed before the transition can. static void MovePlayerOnAcroBike(u8 newDirection, u16 newKeys, u16 heldKeys) { + sAcroBikeTransitions[CheckMovementInputAcroBike(&newDirection, newKeys, heldKeys)](newDirection); } @@ -603,10 +602,10 @@ static void AcroBikeTransition_Moving(u8 direction) } else { - if (collision == COLLISION_SIDEWAYS_STAIRS_TO_RIGHT_WALKING) - return PlayerGoSpeed2(GetRightStairsDirection(direction)); - else if (collision == COLLISION_SIDEWAYS_STAIRS_TO_LEFT_WALKING) - return PlayerGoSpeed2(GetLeftStairsDirection(direction)); + if (collision == COLLISION_SIDEWAYS_STAIRS_TO_RIGHT) + return PlayerGoSpeed2(GetRightSideStairsDirection(direction)); + else if (collision == COLLISION_SIDEWAYS_STAIRS_TO_LEFT) + return PlayerGoSpeed2(GetLeftSideStairsDirection(direction)); if (PlayerIsMovingOnRockStairs(direction)) PlayerGoSpeed2(direction); @@ -614,10 +613,10 @@ static void AcroBikeTransition_Moving(u8 direction) PlayerRideWaterCurrent(direction); /* works, but might be better to keep rock stairs to up/down for mach bike - if (collision == COLLISION_SIDEWAYS_STAIRS_TO_RIGHT_WALKING) - direction = GetRightStairsDirection(direction); - else if (collision == COLLISION_SIDEWAYS_STAIRS_TO_LEFT_WALKING) - direction = GetLeftStairsDirection(direction); + if (collision == COLLISION_SIDEWAYS_STAIRS_TO_RIGHT) + direction = GetRightSideStairsDirection(direction); + else if (collision == COLLISION_SIDEWAYS_STAIRS_TO_LEFT) + direction = GetLeftSideStairsDirection(direction); if (PlayerIsMovingOnRockStairs(direction)) PlayerGoSpeed2(direction); @@ -692,10 +691,10 @@ static void AcroBikeTransition_WheelieHoppingMoving(u8 direction) else { derp: - /*if (collision == COLLISION_SIDEWAYS_STAIRS_TO_LEFT_WALKING) - direction = GetLeftStairsDirection(direction); - else if (collision == COLLISION_SIDEWAYS_STAIRS_TO_RIGHT_WALKING) - direction = GetRightStairsDirection(direction); + /*if (collision == COLLISION_SIDEWAYS_STAIRS_TO_LEFT) + direction = GetLeftSideStairsDirection(direction); + else if (collision == COLLISION_SIDEWAYS_STAIRS_TO_RIGHT) + direction = GetRightSideStairsDirection(direction); */ PlayerMovingHoppingWheelie(direction); } @@ -765,10 +764,10 @@ static void AcroBikeTransition_WheelieMoving(u8 direction) return; } - /*if (collision == COLLISION_SIDEWAYS_STAIRS_TO_LEFT_WALKING) - direction = GetLeftStairsDirection(direction); - else if (collision == COLLISION_SIDEWAYS_STAIRS_TO_RIGHT_WALKING) - direction = GetRightStairsDirection(direction);*/ + /*if (collision == COLLISION_SIDEWAYS_STAIRS_TO_LEFT) + direction = GetLeftSideStairsDirection(direction); + else if (collision == COLLISION_SIDEWAYS_STAIRS_TO_RIGHT) + direction = GetRightSideStairsDirection(direction);*/ PlayerWheelieMove(direction); gPlayerAvatar.runningState = MOVING; diff --git a/src/event_object_movement.c b/src/event_object_movement.c index edbc20acb9d5..f6bc55f3982f 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -1122,34 +1122,34 @@ const u8 gRunSlowMovementActions[] = { }; // sideways stairs -const u8 gDiagonalStairRightMovementActions[] = { - [DIR_NONE] = MOVEMENT_ACTION_JUMP_2_RIGHT, - [DIR_SOUTH] = MOVEMENT_ACTION_JUMP_2_DOWN, - [DIR_NORTH] = MOVEMENT_ACTION_JUMP_2_UP, +const u8 gDiagonalStairLeftSideMovementActions[] = { //movement actions for stairs on left side of a wall (southwest and northeast) + [DIR_NONE] = MOVEMENT_ACTION_WALK_SLOW_DOWN, + [DIR_SOUTH] = MOVEMENT_ACTION_WALK_SLOW_DOWN, + [DIR_NORTH] = MOVEMENT_ACTION_RUN_UP_SLOW, [DIR_WEST] = MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_DOWN_LEFT, [DIR_EAST] = MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_UP_RIGHT, }; -const u8 gDiagonalStairLeftMovementActions[] = { - [DIR_NONE] = MOVEMENT_ACTION_JUMP_2_LEFT, - [DIR_SOUTH] = MOVEMENT_ACTION_JUMP_2_DOWN, - [DIR_NORTH] = MOVEMENT_ACTION_JUMP_2_UP, +const u8 gDiagonalStairRightSideMovementActions[] = { //movement actions for stairs on right side of a wall (southeast and northwest) + [DIR_NONE] = MOVEMENT_ACTION_WALK_SLOW_DOWN, + [DIR_SOUTH] = MOVEMENT_ACTION_WALK_SLOW_DOWN, + [DIR_NORTH] = MOVEMENT_ACTION_RUN_UP_SLOW, [DIR_WEST] = MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_UP_LEFT, [DIR_EAST] = MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_DOWN_RIGHT, }; -const u8 gDiagonalStairRightRunningMovementActions[] = { - [DIR_NONE] = MOVEMENT_ACTION_JUMP_2_RIGHT, - [DIR_SOUTH] = MOVEMENT_ACTION_JUMP_2_DOWN, - [DIR_NORTH] = MOVEMENT_ACTION_JUMP_2_UP, - [DIR_WEST] = MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_DOWN_LEFT_RUNNING, - [DIR_EAST] = MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_UP_RIGHT_RUNNING, -}; -const u8 gDiagonalStairLeftRunningMovementActions[] = { - [DIR_NONE] = MOVEMENT_ACTION_JUMP_2_LEFT, - [DIR_SOUTH] = MOVEMENT_ACTION_JUMP_2_DOWN, - [DIR_NORTH] = MOVEMENT_ACTION_JUMP_2_UP, +const u8 gDiagonalStairRightSideRunningMovementActions[] = { + [DIR_NONE] = MOVEMENT_ACTION_RUN_DOWN_SLOW, + [DIR_SOUTH] = MOVEMENT_ACTION_RUN_DOWN_SLOW, + [DIR_NORTH] = MOVEMENT_ACTION_RUN_UP_SLOW, [DIR_WEST] = MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_UP_LEFT_RUNNING, [DIR_EAST] = MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_DOWN_RIGHT_RUNNING, }; +const u8 gDiagonalStairLeftSideRunningMovementActions[] = { + [DIR_NONE] = MOVEMENT_ACTION_RUN_DOWN_SLOW, + [DIR_SOUTH] = MOVEMENT_ACTION_RUN_DOWN_SLOW, + [DIR_NORTH] = MOVEMENT_ACTION_RUN_UP_SLOW, + [DIR_WEST] = MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_DOWN_LEFT_RUNNING, + [DIR_EAST] = MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_UP_RIGHT_RUNNING, +}; const u8 gDiagonalStairLeftAcroBikeMovementActions[] = { [DIR_NONE] = MOVEMENT_ACTION_RIDE_WATER_CURRENT_LEFT, [DIR_SOUTH] = MOVEMENT_ACTION_RIDE_WATER_CURRENT_LEFT, @@ -5160,10 +5160,10 @@ u8 name(u32 idx)\ } //sideways stairs -dirn_to_anim(GetDiagonalRightStairsMovement, gDiagonalStairRightMovementActions); -dirn_to_anim(GetDiagonalLeftStairsMovement, gDiagonalStairLeftMovementActions); -dirn_to_anim(GetDiagonalRightStairsRunningMovement, gDiagonalStairRightRunningMovementActions); -dirn_to_anim(GetDiagonalLeftStairsRunningMovement, gDiagonalStairLeftRunningMovementActions); +dirn_to_anim(GetDiagonalRightStairsMovement, gDiagonalStairRightSideMovementActions); +dirn_to_anim(GetDiagonalLeftStairsMovement, gDiagonalStairLeftSideMovementActions); +dirn_to_anim(GetDiagonalRightStairsRunningMovement, gDiagonalStairRightSideRunningMovementActions); +dirn_to_anim(GetDiagonalLeftStairsRunningMovement, gDiagonalStairLeftSideRunningMovementActions); dirn_to_anim(GetDiagonalLeftAcroBikeMovement, gDiagonalStairLeftAcroBikeMovementActions); dirn_to_anim(GetDiagonalRightAcroBikeMovement, gDiagonalStairRightAcroBikeMovementActions); @@ -9227,57 +9227,63 @@ bool8 MovementActionFunc_RunSlow_Step1(struct ObjectEvent *objectEvent, struct S } //sideways stairs +/* u8 GetSidewaysStairsToRightDirection(s16 x, s16 y, u8 z) { - static bool8 (*const direction[])(u8) = { + static bool8 (*const sRightStairsBehaviors[])(u8) = { MetatileBehavior_IsWalkSouth, MetatileBehavior_IsWalkNorth, MetatileBehavior_IsSidewaysStairsRight, MetatileBehavior_IsSidewaysStairsRight, }; - u8 b; + u8 metatileBehavior; u8 index = z; - if (index == 0) - return 0; - else if (index > 4) - index -= 4; + if (index == DIR_NONE) + return DIR_NONE; + else if (index > DIR_EAST) + index -= DIR_EAST; index--; - b = MapGridGetMetatileBehaviorAt(x, y); - - if (direction[index](b) == 1) + metatileBehavior = MapGridGetMetatileBehaviorAt(x, y); + if (MetatileBehavior_IsEastBlocked(metatileBehavior)) + return DIR_NONE; + + if (sRightStairsBehaviors[index](metatileBehavior)) return index + 1; - return 0; + return DIR_NONE; } u8 GetSidewaysStairsToLeftDirection(s16 x, s16 y, u8 z) { - static bool8 (*const direction[])(u8) = { + static bool8 (*const sLeftStairsBehaviors[])(u8) = { MetatileBehavior_IsWalkSouth, MetatileBehavior_IsWalkNorth, MetatileBehavior_IsSidewaysStairsLeft, MetatileBehavior_IsSidewaysStairsLeft, }; - u8 b; + u8 metatileBehavior; u8 index = z; - if (index == 0) - return 0; + if (index == DIR_NONE) + return DIR_NONE; else if (index > 4) index -= 4; index--; - b = MapGridGetMetatileBehaviorAt(x, y); + metatileBehavior = MapGridGetMetatileBehaviorAt(x, y); + if (MetatileBehavior_IsWestBlocked(metatileBehavior)) + return DIR_NONE; - if (direction[index](b) == 1) + if (sLeftStairsBehaviors[index](metatileBehavior) == 1) return index + 1; - return 0; + return DIR_NONE; } +*/ bool8 MovementAction_WalkStairDiagonalUpLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { diff --git a/src/field_player_avatar.c b/src/field_player_avatar.c index 0a98f3dc7c19..cec876555cb3 100644 --- a/src/field_player_avatar.c +++ b/src/field_player_avatar.c @@ -624,24 +624,20 @@ static void PlayerNotOnBikeMoving(u8 direction, u16 heldKeys) PlayerNotOnBikeCollideWithFarawayIslandMew(direction); return; } - else if (collision == COLLISION_SIDEWAYS_STAIRS_TO_RIGHT_WALKING) + else if (collision == COLLISION_SIDEWAYS_STAIRS_TO_RIGHT) { - PlayerSidewaysStairsToRight(direction); - return; - } - else if (collision == COLLISION_SIDEWAYS_STAIRS_TO_LEFT_WALKING) - { - PlayerSidewaysStairsToLeft(direction); - return; - } - else if (collision == COLLISION_SIDEWAYS_STAIRS_TO_RIGHT_RUNNING) - { - PlayerSidewaysStairsToRightRunning(direction); + if (heldKeys & B_BUTTON && FlagGet(FLAG_SYS_B_DASH)) + PlayerSidewaysStairsRightSideRunning(direction); + else + PlayerSidewaysStairsRightSide(direction); return; } - else if (collision == COLLISION_SIDEWAYS_STAIRS_TO_LEFT_RUNNING) + else if (collision == COLLISION_SIDEWAYS_STAIRS_TO_LEFT) { - PlayerSidewaysStairsToLeftRunning(direction); + if (heldKeys & B_BUTTON && FlagGet(FLAG_SYS_B_DASH)) + return PlayerSidewaysStairsLeftSideRunning(direction); + else + return PlayerSidewaysStairsLeftSide(direction); return; } else @@ -748,6 +744,8 @@ static u8 sub_808B028(u8 direction) u8 CheckForObjectEventCollision(struct ObjectEvent *objectEvent, s16 x, s16 y, u8 direction, u8 metatileBehavior) { u8 collision = GetCollisionAtCoords(objectEvent, x, y, direction); + u8 currentBehavior = MapGridGetMetatileBehaviorAt(objectEvent->currentCoords.x, objectEvent->currentCoords.y); + if (collision == COLLISION_ELEVATION_MISMATCH && CanStopSurfing(x, y, direction)) return COLLISION_STOP_SURFING; @@ -766,25 +764,50 @@ u8 CheckForObjectEventCollision(struct ObjectEvent *objectEvent, s16 x, s16 y, u CheckAcroBikeCollision(x, y, metatileBehavior, &collision); } - if (collision != COLLISION_IMPASSABLE) + //sideways stairs logic + if (MetatileBehavior_IsSidewaysStairsLeftSideTop(metatileBehavior) && direction == DIR_EAST) + return COLLISION_IMPASSABLE; //moving onto left-side top edge east from ground -> cannot move + else if (MetatileBehavior_IsSidewaysStairsRightSideTop(metatileBehavior) && direction == DIR_WEST) + return COLLISION_IMPASSABLE; //moving onto left-side top edge east from ground -> cannot move + else if (MetatileBehavior_IsSidewaysStairsRightSideBottom(metatileBehavior) && (direction == DIR_EAST || direction == DIR_SOUTH)) + return COLLISION_IMPASSABLE; + else if (MetatileBehavior_IsSidewaysStairsLeftSideBottom(metatileBehavior) && (direction == DIR_WEST || direction == DIR_SOUTH)) + return COLLISION_IMPASSABLE; + + if (MetatileBehavior_IsSidewaysStairsLeftSide(metatileBehavior)) { - if (IsSidewaysStairToRight(x, y, direction)) - { - if (gMain.heldKeys & B_BUTTON) - return COLLISION_SIDEWAYS_STAIRS_TO_RIGHT_RUNNING; - else - return COLLISION_SIDEWAYS_STAIRS_TO_RIGHT_WALKING; - } - else if (IsSidewaysStairToLeft(x, y, direction)) - { - if (gMain.heldKeys & B_BUTTON) - return COLLISION_SIDEWAYS_STAIRS_TO_LEFT_RUNNING; - else - return COLLISION_SIDEWAYS_STAIRS_TO_LEFT_WALKING; - } + //moving ONTO left side stair + if (direction == DIR_WEST && currentBehavior != metatileBehavior) + return collision; //moving onto top part of left-stair going left, so no diagonal + else + return COLLISION_SIDEWAYS_STAIRS_TO_LEFT; // move diagonally + } + else if (MetatileBehavior_IsSidewaysStairsRightSide(metatileBehavior)) + { + //moving ONTO right side stair + if (direction == DIR_EAST && currentBehavior != metatileBehavior) + return collision; //moving onto top part of right-stair going right, so no diagonal + else + return COLLISION_SIDEWAYS_STAIRS_TO_RIGHT; + } + else if (MetatileBehavior_IsSidewaysStairsLeftSideAny(currentBehavior)) + { + //moving OFF of any left side stair + if (direction == DIR_WEST && metatileBehavior != currentBehavior) + return COLLISION_SIDEWAYS_STAIRS_TO_LEFT; //moving off of left stairs onto non-stair -> move diagonal + else + return collision; //moving off of left side stair to east -> move east + } + else if (MetatileBehavior_IsSidewaysStairsRightSideAny(currentBehavior)) + { + //moving OFF of any right side stair + if (direction == DIR_EAST && metatileBehavior != currentBehavior) + return COLLISION_SIDEWAYS_STAIRS_TO_RIGHT; //moving off right stair onto non-stair -> move diagonal + else + return collision; } - return collision; + return collision; } static u8 sub_808B164(struct ObjectEvent *objectEvent, s16 x, s16 y, u8 direction, u8 metatileBehavior) @@ -2321,6 +2344,7 @@ static u8 TrySpinPlayerForWarp(struct ObjectEvent *object, s16 *delayTimer) } //sideways stairs +/* static bool8 IsSidewaysStairToRight(s16 x, s16 y, u8 z) { if (GetSidewaysStairsToRightDirection(x, y, z) != 0) @@ -2336,15 +2360,16 @@ static bool8 IsSidewaysStairToLeft(s16 x, s16 y, u8 z) else return FALSE; } +*/ -u8 GetRightStairsDirection(u8 direction) +u8 GetRightSideStairsDirection(u8 direction) { switch (direction) { case DIR_WEST: - return DIR_SOUTHWEST; + return DIR_NORTHWEST; case DIR_EAST: - return DIR_NORTHEAST; + return DIR_SOUTHEAST; default: if (direction > DIR_EAST) direction -= DIR_EAST; @@ -2353,14 +2378,14 @@ u8 GetRightStairsDirection(u8 direction) } } -u8 GetLeftStairsDirection(u8 direction) +u8 GetLeftSideStairsDirection(u8 direction) { switch (direction) { case DIR_WEST: - return DIR_NORTHWEST; + return DIR_SOUTHWEST; case DIR_EAST: - return DIR_SOUTHEAST; + return DIR_NORTHEAST; default: if (direction > DIR_EAST) direction -= DIR_EAST; @@ -2369,22 +2394,22 @@ u8 GetLeftStairsDirection(u8 direction) } } -void PlayerSidewaysStairsToRight(u8 direction) +void PlayerSidewaysStairsRightSide(u8 direction) { PlayerSetAnimId(GetDiagonalRightStairsMovement(direction), 8); } -void PlayerSidewaysStairsToLeft(u8 direction) +void PlayerSidewaysStairsLeftSide(u8 direction) { PlayerSetAnimId(GetDiagonalLeftStairsMovement(direction), 8); } -void PlayerSidewaysStairsToRightRunning(u8 direction) +void PlayerSidewaysStairsRightSideRunning(u8 direction) { PlayerSetAnimId(GetDiagonalRightStairsRunningMovement(direction), 8); } -void PlayerSidewaysStairsToLeftRunning(u8 direction) +void PlayerSidewaysStairsLeftSideRunning(u8 direction) { PlayerSetAnimId(GetDiagonalLeftStairsRunningMovement(direction), 8); } diff --git a/src/metatile_behavior.c b/src/metatile_behavior.c index fa773a3b7e80..f490d25931e5 100644 --- a/src/metatile_behavior.c +++ b/src/metatile_behavior.c @@ -83,13 +83,13 @@ static const u8 sTileBitAttributes[] = [MB_SLIDE_NORTH] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE), [MB_SLIDE_SOUTH] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE), [MB_TRICK_HOUSE_PUZZLE_8_FLOOR] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE), - [MB_SIDEWAYS_STAIRS_RIGHT] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE), - [MB_SIDEWAYS_STAIRS_LEFT] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + [MB_SIDEWAYS_STAIRS_RIGHT_SIDE] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + [MB_SIDEWAYS_STAIRS_LEFT_SIDE] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + [MB_SIDEWAYS_STAIRS_RIGHT_SIDE_TOP] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + [MB_SIDEWAYS_STAIRS_LEFT_SIDE_TOP] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + [MB_SIDEWAYS_STAIRS_RIGHT_SIDE_BOTTOM] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + [MB_SIDEWAYS_STAIRS_LEFT_SIDE_BOTTOM] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE), [MB_ROCK_STAIRS] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE), - [MB_UNUSED_4C] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE), - [MB_UNUSED_4D] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE), - [MB_UNUSED_4E] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE), - [MB_UNUSED_4F] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE), [MB_EASTWARD_CURRENT] = TILE_ATTRIBUTES(TRUE, TRUE, FALSE), [MB_WESTWARD_CURRENT] = TILE_ATTRIBUTES(TRUE, TRUE, FALSE), [MB_NORTHWARD_CURRENT] = TILE_ATTRIBUTES(TRUE, TRUE, FALSE), @@ -1496,17 +1496,69 @@ bool8 MetatileBehavior_IsTrainerHillTimer(u8 metatileBehavior) return FALSE; } -bool8 MetatileBehavior_IsSidewaysStairsRight(u8 metatileBehavior) +bool8 MetatileBehavior_IsSidewaysStairsRightSide(u8 metatileBehavior) { - if (metatileBehavior == MB_SIDEWAYS_STAIRS_RIGHT) + if (metatileBehavior == MB_SIDEWAYS_STAIRS_RIGHT_SIDE || metatileBehavior == MB_SIDEWAYS_STAIRS_RIGHT_SIDE_BOTTOM) return TRUE; else return FALSE; } -bool8 MetatileBehavior_IsSidewaysStairsLeft(u8 metatileBehavior) +bool8 MetatileBehavior_IsSidewaysStairsLeftSide(u8 metatileBehavior) { - if (metatileBehavior == MB_SIDEWAYS_STAIRS_LEFT) + if (metatileBehavior == MB_SIDEWAYS_STAIRS_LEFT_SIDE || metatileBehavior == MB_SIDEWAYS_STAIRS_LEFT_SIDE_BOTTOM) + return TRUE; + else + return FALSE; +} + +bool8 MetatileBehavior_IsSidewaysStairsRightSideTop(u8 metatileBehavior) +{ + if (metatileBehavior == MB_SIDEWAYS_STAIRS_RIGHT_SIDE_TOP) + return TRUE; + else + return FALSE; +} + +bool8 MetatileBehavior_IsSidewaysStairsLeftSideTop(u8 metatileBehavior) +{ + if (metatileBehavior == MB_SIDEWAYS_STAIRS_LEFT_SIDE_TOP) + return TRUE; + else + return FALSE; +} + +bool8 MetatileBehavior_IsSidewaysStairsRightSideBottom(u8 metatileBehavior) +{ + if (metatileBehavior == MB_SIDEWAYS_STAIRS_RIGHT_SIDE_BOTTOM) + return TRUE; + else + return FALSE; +} + +bool8 MetatileBehavior_IsSidewaysStairsLeftSideBottom(u8 metatileBehavior) +{ + if (metatileBehavior == MB_SIDEWAYS_STAIRS_LEFT_SIDE_BOTTOM) + return TRUE; + else + return FALSE; +} + +bool8 MetatileBehavior_IsSidewaysStairsRightSideAny(u8 metatileBehavior) +{ + if (metatileBehavior == MB_SIDEWAYS_STAIRS_RIGHT_SIDE + || metatileBehavior == MB_SIDEWAYS_STAIRS_RIGHT_SIDE_BOTTOM + || metatileBehavior == MB_SIDEWAYS_STAIRS_RIGHT_SIDE_TOP) + return TRUE; + else + return FALSE; +} + +bool8 MetatileBehavior_IsSidewaysStairsLeftSideAny(u8 metatileBehavior) +{ + if (metatileBehavior == MB_SIDEWAYS_STAIRS_LEFT_SIDE + || metatileBehavior == MB_SIDEWAYS_STAIRS_LEFT_SIDE_BOTTOM + || metatileBehavior == MB_SIDEWAYS_STAIRS_LEFT_SIDE_TOP) return TRUE; else return FALSE; From 228b76e136e162655bc27f0713cb9968599093f4 Mon Sep 17 00:00:00 2001 From: Evan Date: Thu, 4 Jun 2020 22:56:25 -0600 Subject: [PATCH 04/27] finish conditional slow stairs movement, clean up code a bit --- include/event_object_movement.h | 3 +- include/field_player_avatar.h | 2 - src/bike.c | 107 +++--- .../movement_action_func_tables.h | 24 +- src/event_object_movement.c | 346 +++++++++--------- src/field_player_avatar.c | 51 +-- src/metatile_behavior.c | 2 +- 7 files changed, 251 insertions(+), 284 deletions(-) diff --git a/include/event_object_movement.h b/include/event_object_movement.h index e8f8df1a4b91..84c89a85d3a6 100644 --- a/include/event_object_movement.h +++ b/include/event_object_movement.h @@ -437,7 +437,6 @@ u8 GetDiagonalRightStairsMovement(u32); u8 GetDiagonalLeftStairsMovement(u32); u8 GetDiagonalRightStairsRunningMovement(u32); u8 GetDiagonalLeftStairsRunningMovement(u32); -u8 GetDiagonalLeftAcroBikeMovement(u32); -u8 GetDiagonalRightAcroBikeMovement(u32); +extern u8 gSidewaysStairsDirection; #endif //GUARD_EVENT_OBJECT_MOVEMENT_H diff --git a/include/field_player_avatar.h b/include/field_player_avatar.h index d7b04d40ff8f..f9cdfa838d83 100644 --- a/include/field_player_avatar.h +++ b/include/field_player_avatar.h @@ -72,7 +72,5 @@ void PlayerSidewaysStairsRightSide(u8 direction); void PlayerSidewaysStairsLeftSide(u8 direction); void PlayerSidewaysStairsRightSideRunning(u8 direction); void PlayerSidewaysStairsLeftSideRunning(u8 direction); -void PlayerSidewaysStairsToAcroBikeLeft(u8 direction); -void PlayerSidewaysStairsToAcroBikeRight(u8 direction); #endif // GUARD_FIELD_PLAYER_AVATAR_H diff --git a/src/bike.c b/src/bike.c index a26451778e67..a21dcb33e128 100644 --- a/src/bike.c +++ b/src/bike.c @@ -178,10 +178,7 @@ static u8 GetMachBikeTransition(u8 *dirTraveling) // the difference between face direction and turn direction is that one changes direction while the other does the animation of turning as well as changing direction. static void MachBikeTransition_FaceDirection(u8 direction) -{ - //if (direction > DIR_EAST) - // direction -= DIR_EAST; - +{ PlayerFaceDirection(direction); Bike_SetBikeStill(); } @@ -190,19 +187,13 @@ static void MachBikeTransition_TurnDirection(u8 direction) { struct ObjectEvent *playerObjEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; - //if (direction > DIR_EAST) - // direction -= DIR_EAST; - if (CanBikeFaceDirOnMetatile(direction, playerObjEvent->currentMetatileBehavior)) { PlayerTurnInPlace(direction); Bike_SetBikeStill(); } else - { - //if (playerObjEvent->facingDirection > DIR_EAST) - // playerObjEvent->facingDirection -= DIR_EAST; - + { MachBikeTransition_FaceDirection(playerObjEvent->facingDirection); } } @@ -242,19 +233,33 @@ static void MachBikeTransition_TrySpeedUp(u8 direction) } else if (collision == COLLISION_SIDEWAYS_STAIRS_TO_LEFT) { - gPlayerAvatar.bikeFrameCounter = 0; - gPlayerAvatar.bikeSpeed = SPEED_STANDING; - PlayerGoSpeed2(GetLeftSideStairsDirection(direction)); - //PlayerSidewaysStairsToAcroBikeLeft(direction); - return; + #if SLOW_MOVEMENT_ON_STAIRS == TRUE + gPlayerAvatar.bikeFrameCounter = 0; + gPlayerAvatar.bikeSpeed = SPEED_STANDING; + PlayerGoSpeed2(GetLeftSideStairsDirection(direction)); + return; + #else + gPlayerAvatar.bikeFrameCounter = 2; + gPlayerAvatar.bikeSpeed = SPEED_STANDING; + PlayerGoSpeed2(GetLeftSideStairsDirection(direction)); + return; + #endif + } else if (collision == COLLISION_SIDEWAYS_STAIRS_TO_RIGHT) { - gPlayerAvatar.bikeFrameCounter = 0; - gPlayerAvatar.bikeSpeed = SPEED_STANDING; - //PlayerSidewaysStairsToAcroBikeRight(direction); - PlayerGoSpeed2(GetRightSideStairsDirection(direction)); - return; + #if SLOW_MOVEMENT_ON_STAIRS == TRUE + gPlayerAvatar.bikeFrameCounter = 0; + gPlayerAvatar.bikeSpeed = SPEED_STANDING; + PlayerGoSpeed2(GetRightSideStairsDirection(direction)); + return; + #else + gPlayerAvatar.bikeFrameCounter = 2; + gPlayerAvatar.bikeSpeed = SPEED_STANDING; + PlayerGoSpeed2(GetRightSideStairsDirection(direction)); + return; + #endif + } else { @@ -295,16 +300,12 @@ static void MachBikeTransition_TrySlowDown(u8 direction) } else { - /*if (collision == COLLISION_SIDEWAYS_STAIRS_TO_LEFT) - { - return PlayerGoSpeed2(GetLeftSideStairsDirection(direction)); - //return PlayerSidewaysStairsToLeftMachBike(direction); - } - else if (collision == COLLISION_SIDEWAYS_STAIRS_TO_RIGHT) - { - return PlayerGoSpeed2(GetRightSideStairsDirection(direction)); - //return PlayerSidewaysStairsToRightMachBike(direction); - }*/ + #if SLOW_MOVEMENT_ON_STAIRS == TRUE + if (collision == COLLISION_SIDEWAYS_STAIRS_TO_LEFT) + return PlayerGoSpeed2(GetLeftSideStairsDirection(direction)); + else if (collision == COLLISION_SIDEWAYS_STAIRS_TO_RIGHT) + return PlayerGoSpeed2(GetRightSideStairsDirection(direction)); + #endif sMachBikeSpeedCallbacks[gPlayerAvatar.bikeFrameCounter](direction); } @@ -313,12 +314,13 @@ static void MachBikeTransition_TrySlowDown(u8 direction) // the acro bike requires the input handler to be executed before the transition can. static void MovePlayerOnAcroBike(u8 newDirection, u16 newKeys, u16 heldKeys) { - + gSidewaysStairsDirection = newDirection; sAcroBikeTransitions[CheckMovementInputAcroBike(&newDirection, newKeys, heldKeys)](newDirection); } static u8 CheckMovementInputAcroBike(u8 *newDirection, u16 newKeys, u16 heldKeys) { + gSidewaysStairsDirection = *newDirection; return sAcroBikeInputHandlers[gPlayerAvatar.acroBikeState](newDirection, newKeys, heldKeys); } @@ -407,6 +409,8 @@ static u8 AcroBikeHandleInputWheelieStanding(u8 *newDirection, u16 newKeys, u16 struct ObjectEvent *playerObjEvent; direction = GetPlayerMovementDirection(); + gSidewaysStairsDirection = direction; + playerObjEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; gPlayerAvatar.runningState = NOT_MOVING; @@ -611,18 +615,6 @@ static void AcroBikeTransition_Moving(u8 direction) PlayerGoSpeed2(direction); else PlayerRideWaterCurrent(direction); - - /* works, but might be better to keep rock stairs to up/down for mach bike - if (collision == COLLISION_SIDEWAYS_STAIRS_TO_RIGHT) - direction = GetRightSideStairsDirection(direction); - else if (collision == COLLISION_SIDEWAYS_STAIRS_TO_LEFT) - direction = GetLeftSideStairsDirection(direction); - - if (PlayerIsMovingOnRockStairs(direction)) - PlayerGoSpeed2(direction); - else - PlayerRideWaterCurrent(direction); - */ } } @@ -691,11 +683,11 @@ static void AcroBikeTransition_WheelieHoppingMoving(u8 direction) else { derp: - /*if (collision == COLLISION_SIDEWAYS_STAIRS_TO_LEFT) - direction = GetLeftSideStairsDirection(direction); + if (collision == COLLISION_SIDEWAYS_STAIRS_TO_LEFT) + gSidewaysStairsDirection = GetLeftSideStairsDirection(direction); else if (collision == COLLISION_SIDEWAYS_STAIRS_TO_RIGHT) - direction = GetRightSideStairsDirection(direction); - */ + gSidewaysStairsDirection = GetRightSideStairsDirection(direction); + PlayerMovingHoppingWheelie(direction); } } @@ -764,10 +756,10 @@ static void AcroBikeTransition_WheelieMoving(u8 direction) return; } - /*if (collision == COLLISION_SIDEWAYS_STAIRS_TO_LEFT) - direction = GetLeftSideStairsDirection(direction); + if (collision == COLLISION_SIDEWAYS_STAIRS_TO_LEFT) + gSidewaysStairsDirection = GetLeftSideStairsDirection(direction); else if (collision == COLLISION_SIDEWAYS_STAIRS_TO_RIGHT) - direction = GetRightSideStairsDirection(direction);*/ + gSidewaysStairsDirection = GetRightSideStairsDirection(direction); PlayerWheelieMove(direction); gPlayerAvatar.runningState = MOVING; @@ -803,6 +795,12 @@ static void AcroBikeTransition_WheelieRisingMoving(u8 direction) } return; } + + if (collision == COLLISION_SIDEWAYS_STAIRS_TO_LEFT) + gSidewaysStairsDirection = GetLeftSideStairsDirection(direction); + else if (collision == COLLISION_SIDEWAYS_STAIRS_TO_RIGHT) + gSidewaysStairsDirection = GetRightSideStairsDirection(direction); + PlayerPopWheelieWhileMoving(direction); gPlayerAvatar.runningState = MOVING; } @@ -826,6 +824,12 @@ static void AcroBikeTransition_WheelieLoweringMoving(u8 direction) PlayerEndWheelie(direction); return; } + + if (collision == COLLISION_SIDEWAYS_STAIRS_TO_LEFT) + gSidewaysStairsDirection = GetLeftSideStairsDirection(direction); + else if (collision == COLLISION_SIDEWAYS_STAIRS_TO_RIGHT) + gSidewaysStairsDirection = GetRightSideStairsDirection(direction); + PlayerEndWheelieWhileMoving(direction); } @@ -1086,6 +1090,7 @@ void Bike_UpdateBikeCounterSpeed(u8 counter) static void Bike_SetBikeStill(void) { + gSidewaysStairsDirection = gObjectEvents[gPlayerAvatar.objectEventId].facingDirection; gPlayerAvatar.bikeFrameCounter = 0; gPlayerAvatar.bikeSpeed = SPEED_STANDING; } diff --git a/src/data/object_events/movement_action_func_tables.h b/src/data/object_events/movement_action_func_tables.h index cc1b522159aa..30c1fac2aacb 100755 --- a/src/data/object_events/movement_action_func_tables.h +++ b/src/data/object_events/movement_action_func_tables.h @@ -1596,25 +1596,41 @@ u8 (*const gMovementActionFuncs_RunRightSlow[])(struct ObjectEvent *, struct Spr //sideways stairs u8 (*const gMovementActionFuncs_WalkStairDiagonalUpLeft[])(struct ObjectEvent *, struct Sprite *) = { MovementAction_WalkStairDiagonalUpLeft_Step0, - MovementAction_WalkSlowDiagonalUpLeft_Step1, + #if SLOW_MOVEMENT_ON_STAIRS == TRUE + MovementAction_WalkSlowDiagonalUpLeft_Step1, + #else + MovementAction_WalkNormalDiagonalUpLeft_Step1, + #endif MovementAction_PauseSpriteAnim, }; u8 (*const gMovementActionFuncs_WalkStairDiagonalUpRight[])(struct ObjectEvent *, struct Sprite *) = { MovementAction_WalkStairDiagonalUpRight_Step0, - MovementAction_WalkSlowDiagonalUpRight_Step1, + #if SLOW_MOVEMENT_ON_STAIRS == TRUE + MovementAction_WalkSlowDiagonalUpRight_Step1, + #else + MovementAction_WalkNormalDiagonalUpRight_Step1, + #endif MovementAction_PauseSpriteAnim, }; u8 (*const gMovementActionFuncs_WalkStairDiagonalDownLeft[])(struct ObjectEvent *, struct Sprite *) = { MovementAction_WalkStairDiagonalDownLeft_Step0, - MovementAction_WalkSlowDiagonalDownLeft_Step1, + #if SLOW_MOVEMENT_ON_STAIRS == TRUE + MovementAction_WalkSlowDiagonalDownLeft_Step1, + #else + MovementAction_WalkNormalDiagonalDownLeft_Step1, + #endif MovementAction_PauseSpriteAnim, }; u8 (*const gMovementActionFuncs_WalkStairDiagonalDownRight[])(struct ObjectEvent *, struct Sprite *) = { MovementAction_WalkStairDiagonalDownRight_Step0, - MovementAction_WalkSlowDiagonalDownRight_Step1, + #if SLOW_MOVEMENT_ON_STAIRS == TRUE + MovementAction_WalkSlowDiagonalDownRight_Step1, + #else + MovementAction_WalkNormalDiagonalDownRight_Step1, + #endif MovementAction_PauseSpriteAnim, }; diff --git a/src/event_object_movement.c b/src/event_object_movement.c index f6bc55f3982f..70970c80bc1a 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -57,6 +57,7 @@ static u8 setup##_callback(struct ObjectEvent *objectEvent, struct Sprite *sprit EWRAM_DATA u8 sCurrentReflectionType = 0; EWRAM_DATA u16 sCurrentSpecialObjectPaletteTag = 0; EWRAM_DATA struct LockedAnimObjectEvents *gLockedAnimObjectEvents = {0}; +EWRAM_DATA u8 gSidewaysStairsDirection = 0; static void MoveCoordsInDirection(u32, s16 *, s16 *, s16, s16); static bool8 ObjectEventExecSingleMovementAction(struct ObjectEvent *, struct Sprite *); @@ -681,10 +682,10 @@ const u8 gFaceDirectionAnimNums[] = { [DIR_NORTH] = 1, [DIR_WEST] = 2, [DIR_EAST] = 3, - [DIR_SOUTHWEST] = 0, - [DIR_SOUTHEAST] = 0, - [DIR_NORTHWEST] = 1, - [DIR_NORTHEAST] = 1, + [DIR_SOUTHWEST] = 2, //0, + [DIR_SOUTHEAST] = 3, //0, + [DIR_NORTHWEST] = 2, //1, + [DIR_NORTHEAST] = 3, //1, }; const u8 gMoveDirectionAnimNums[] = { [DIR_NONE] = 4, @@ -747,10 +748,10 @@ const u8 gAcroWheelieDirectionAnimNums[] = { [DIR_NORTH] = 21, [DIR_WEST] = 22, [DIR_EAST] = 23, - [DIR_SOUTHWEST] = 20, - [DIR_SOUTHEAST] = 20, - [DIR_NORTHWEST] = 21, - [DIR_NORTHEAST] = 21, + [DIR_SOUTHWEST] = 22, //20, + [DIR_SOUTHEAST] = 23, //20, + [DIR_NORTHWEST] = 22, //21, + [DIR_NORTHEAST] = 23, //21, }; const u8 gUnrefAnimNums_08375633[] = { [DIR_NONE] = 24, @@ -769,10 +770,10 @@ const u8 gAcroEndWheelieDirectionAnimNums[] = { [DIR_NORTH] = 29, [DIR_WEST] = 30, [DIR_EAST] = 31, - [DIR_SOUTHWEST] = 28, - [DIR_SOUTHEAST] = 28, - [DIR_NORTHWEST] = 29, - [DIR_NORTHEAST] = 29, + [DIR_SOUTHWEST] = 30, //28, + [DIR_SOUTHEAST] = 31, //28, + [DIR_NORTHWEST] = 30, //29, + [DIR_NORTHEAST] = 31, //29, }; const u8 gAcroUnusedActionDirectionAnimNums[] = { [DIR_NONE] = 32, @@ -791,10 +792,10 @@ const u8 gAcroWheeliePedalDirectionAnimNums[] = { [DIR_NORTH] = 37, [DIR_WEST] = 38, [DIR_EAST] = 39, - [DIR_SOUTHWEST] = 36, - [DIR_SOUTHEAST] = 36, - [DIR_NORTHWEST] = 37, - [DIR_NORTHEAST] = 37, + [DIR_SOUTHWEST] = 38, //36, + [DIR_SOUTHEAST] = 39, //36, + [DIR_NORTHWEST] = 38, //37, + [DIR_NORTHEAST] = 39, //37, }; const u8 gFishingDirectionAnimNums[] = { [DIR_NONE] = 0, @@ -1044,27 +1045,43 @@ const u8 gAcroWheelieFaceDirectionMovementActions[] = { [DIR_NORTH] = MOVEMENT_ACTION_ACRO_WHEELIE_FACE_UP, [DIR_WEST] = MOVEMENT_ACTION_ACRO_WHEELIE_FACE_LEFT, [DIR_EAST] = MOVEMENT_ACTION_ACRO_WHEELIE_FACE_RIGHT, + [DIR_SOUTHWEST] = MOVEMENT_ACTION_ACRO_WHEELIE_FACE_LEFT, + [DIR_NORTHWEST] = MOVEMENT_ACTION_ACRO_WHEELIE_FACE_LEFT, + [DIR_NORTHEAST] = MOVEMENT_ACTION_ACRO_WHEELIE_FACE_RIGHT, + [DIR_SOUTHEAST] = MOVEMENT_ACTION_ACRO_WHEELIE_FACE_RIGHT }; const u8 gAcroPopWheelieFaceDirectionMovementActions[] = { - MOVEMENT_ACTION_ACRO_POP_WHEELIE_DOWN, - MOVEMENT_ACTION_ACRO_POP_WHEELIE_DOWN, - MOVEMENT_ACTION_ACRO_POP_WHEELIE_UP, - MOVEMENT_ACTION_ACRO_POP_WHEELIE_LEFT, - MOVEMENT_ACTION_ACRO_POP_WHEELIE_RIGHT, + [DIR_NONE] = MOVEMENT_ACTION_ACRO_POP_WHEELIE_DOWN, + [DIR_SOUTH] = MOVEMENT_ACTION_ACRO_POP_WHEELIE_DOWN, + [DIR_NORTH] = MOVEMENT_ACTION_ACRO_POP_WHEELIE_UP, + [DIR_WEST] = MOVEMENT_ACTION_ACRO_POP_WHEELIE_LEFT, + [DIR_EAST] = MOVEMENT_ACTION_ACRO_POP_WHEELIE_RIGHT, + [DIR_SOUTHWEST] = MOVEMENT_ACTION_ACRO_POP_WHEELIE_LEFT, + [DIR_NORTHWEST] = MOVEMENT_ACTION_ACRO_POP_WHEELIE_LEFT, + [DIR_SOUTHEAST] = MOVEMENT_ACTION_ACRO_POP_WHEELIE_RIGHT, + [DIR_NORTHEAST] = MOVEMENT_ACTION_ACRO_POP_WHEELIE_RIGHT, }; const u8 gAcroEndWheelieFaceDirectionMovementActions[] = { - MOVEMENT_ACTION_ACRO_END_WHEELIE_FACE_DOWN, - MOVEMENT_ACTION_ACRO_END_WHEELIE_FACE_DOWN, - MOVEMENT_ACTION_ACRO_END_WHEELIE_FACE_UP, - MOVEMENT_ACTION_ACRO_END_WHEELIE_FACE_LEFT, - MOVEMENT_ACTION_ACRO_END_WHEELIE_FACE_RIGHT, + [DIR_NONE] = MOVEMENT_ACTION_ACRO_END_WHEELIE_FACE_DOWN, + [DIR_SOUTH] = MOVEMENT_ACTION_ACRO_END_WHEELIE_FACE_DOWN, + [DIR_NORTH] = MOVEMENT_ACTION_ACRO_END_WHEELIE_FACE_UP, + [DIR_WEST] = MOVEMENT_ACTION_ACRO_END_WHEELIE_FACE_LEFT, + [DIR_EAST] = MOVEMENT_ACTION_ACRO_END_WHEELIE_FACE_RIGHT, + [DIR_SOUTHWEST] = MOVEMENT_ACTION_ACRO_END_WHEELIE_FACE_LEFT, + [DIR_NORTHWEST] = MOVEMENT_ACTION_ACRO_END_WHEELIE_FACE_LEFT, + [DIR_SOUTHEAST] = MOVEMENT_ACTION_ACRO_END_WHEELIE_FACE_RIGHT, + [DIR_NORTHEAST] = MOVEMENT_ACTION_ACRO_END_WHEELIE_FACE_RIGHT, }; const u8 gAcroWheelieHopFaceDirectionMovementActions[] = { - MOVEMENT_ACTION_ACRO_WHEELIE_HOP_FACE_DOWN, - MOVEMENT_ACTION_ACRO_WHEELIE_HOP_FACE_DOWN, - MOVEMENT_ACTION_ACRO_WHEELIE_HOP_FACE_UP, - MOVEMENT_ACTION_ACRO_WHEELIE_HOP_FACE_LEFT, - MOVEMENT_ACTION_ACRO_WHEELIE_HOP_FACE_RIGHT, + [DIR_NONE] = MOVEMENT_ACTION_ACRO_WHEELIE_HOP_FACE_DOWN, + [DIR_SOUTH] = MOVEMENT_ACTION_ACRO_WHEELIE_HOP_FACE_DOWN, + [DIR_NORTH] = MOVEMENT_ACTION_ACRO_WHEELIE_HOP_FACE_UP, + [DIR_WEST] = MOVEMENT_ACTION_ACRO_WHEELIE_HOP_FACE_LEFT, + [DIR_EAST] = MOVEMENT_ACTION_ACRO_WHEELIE_HOP_FACE_RIGHT, + [DIR_SOUTHWEST] = MOVEMENT_ACTION_ACRO_WHEELIE_HOP_FACE_LEFT, + [DIR_NORTHWEST] = MOVEMENT_ACTION_ACRO_WHEELIE_HOP_FACE_LEFT, + [DIR_SOUTHEAST] = MOVEMENT_ACTION_ACRO_WHEELIE_HOP_FACE_RIGHT, + [DIR_NORTHEAST] = MOVEMENT_ACTION_ACRO_WHEELIE_HOP_FACE_RIGHT, }; const u8 gAcroWheelieHopDirectionMovementActions[] = { [DIR_NONE] = MOVEMENT_ACTION_ACRO_WHEELIE_HOP_DOWN, @@ -1072,45 +1089,65 @@ const u8 gAcroWheelieHopDirectionMovementActions[] = { [DIR_NORTH] = MOVEMENT_ACTION_ACRO_WHEELIE_HOP_UP, [DIR_WEST] = MOVEMENT_ACTION_ACRO_WHEELIE_HOP_LEFT, [DIR_EAST] = MOVEMENT_ACTION_ACRO_WHEELIE_HOP_RIGHT, - /*[DIR_SOUTHWEST] = MOVEMENT_ACTION_ACRO_WHEELIE_HOP_LEFT, - [DIR_SOUTHEAST] = MOVEMENT_ACTION_ACRO_WHEELIE_HOP_RIGHT, + [DIR_SOUTHWEST] = MOVEMENT_ACTION_ACRO_WHEELIE_HOP_LEFT, [DIR_NORTHWEST] = MOVEMENT_ACTION_ACRO_WHEELIE_HOP_LEFT, - [DIR_NORTHEAST] = MOVEMENT_ACTION_ACRO_WHEELIE_HOP_RIGHT*/ + [DIR_SOUTHEAST] = MOVEMENT_ACTION_ACRO_WHEELIE_HOP_RIGHT, + [DIR_NORTHEAST] = MOVEMENT_ACTION_ACRO_WHEELIE_HOP_RIGHT, }; const u8 gAcroWheelieJumpDirectionMovementActions[] = { - MOVEMENT_ACTION_ACRO_WHEELIE_JUMP_DOWN, - MOVEMENT_ACTION_ACRO_WHEELIE_JUMP_DOWN, - MOVEMENT_ACTION_ACRO_WHEELIE_JUMP_UP, - MOVEMENT_ACTION_ACRO_WHEELIE_JUMP_LEFT, - MOVEMENT_ACTION_ACRO_WHEELIE_JUMP_RIGHT, + [DIR_NONE] = MOVEMENT_ACTION_ACRO_WHEELIE_JUMP_DOWN, + [DIR_SOUTH] = MOVEMENT_ACTION_ACRO_WHEELIE_JUMP_DOWN, + [DIR_NORTH] = MOVEMENT_ACTION_ACRO_WHEELIE_JUMP_UP, + [DIR_WEST] = MOVEMENT_ACTION_ACRO_WHEELIE_JUMP_LEFT, + [DIR_EAST] = MOVEMENT_ACTION_ACRO_WHEELIE_JUMP_RIGHT, + [DIR_SOUTHWEST] = MOVEMENT_ACTION_ACRO_WHEELIE_JUMP_LEFT, + [DIR_NORTHWEST] = MOVEMENT_ACTION_ACRO_WHEELIE_JUMP_LEFT, + [DIR_SOUTHEAST] = MOVEMENT_ACTION_ACRO_WHEELIE_JUMP_RIGHT, + [DIR_NORTHEAST] = MOVEMENT_ACTION_ACRO_WHEELIE_JUMP_RIGHT, }; const u8 gAcroWheelieInPlaceDirectionMovementActions[] = { - MOVEMENT_ACTION_ACRO_WHEELIE_IN_PLACE_DOWN, - MOVEMENT_ACTION_ACRO_WHEELIE_IN_PLACE_DOWN, - MOVEMENT_ACTION_ACRO_WHEELIE_IN_PLACE_UP, - MOVEMENT_ACTION_ACRO_WHEELIE_IN_PLACE_LEFT, - MOVEMENT_ACTION_ACRO_WHEELIE_IN_PLACE_RIGHT, + [DIR_NONE] = MOVEMENT_ACTION_ACRO_WHEELIE_IN_PLACE_DOWN, + [DIR_SOUTH] = MOVEMENT_ACTION_ACRO_WHEELIE_IN_PLACE_DOWN, + [DIR_NORTH] = MOVEMENT_ACTION_ACRO_WHEELIE_IN_PLACE_UP, + [DIR_WEST] = MOVEMENT_ACTION_ACRO_WHEELIE_IN_PLACE_LEFT, + [DIR_EAST] = MOVEMENT_ACTION_ACRO_WHEELIE_IN_PLACE_RIGHT, + [DIR_SOUTHWEST] = MOVEMENT_ACTION_ACRO_WHEELIE_IN_PLACE_LEFT, + [DIR_NORTHWEST] = MOVEMENT_ACTION_ACRO_WHEELIE_IN_PLACE_LEFT, + [DIR_SOUTHEAST] = MOVEMENT_ACTION_ACRO_WHEELIE_IN_PLACE_RIGHT, + [DIR_NORTHEAST] = MOVEMENT_ACTION_ACRO_WHEELIE_IN_PLACE_RIGHT, }; const u8 gAcroPopWheelieMoveDirectionMovementActions[] = { - MOVEMENT_ACTION_ACRO_POP_WHEELIE_MOVE_DOWN, - MOVEMENT_ACTION_ACRO_POP_WHEELIE_MOVE_DOWN, - MOVEMENT_ACTION_ACRO_POP_WHEELIE_MOVE_UP, - MOVEMENT_ACTION_ACRO_POP_WHEELIE_MOVE_LEFT, - MOVEMENT_ACTION_ACRO_POP_WHEELIE_MOVE_RIGHT, + [DIR_NONE] = MOVEMENT_ACTION_ACRO_POP_WHEELIE_MOVE_DOWN, + [DIR_SOUTH] = MOVEMENT_ACTION_ACRO_POP_WHEELIE_MOVE_DOWN, + [DIR_NORTH] = MOVEMENT_ACTION_ACRO_POP_WHEELIE_MOVE_UP, + [DIR_WEST] = MOVEMENT_ACTION_ACRO_POP_WHEELIE_MOVE_LEFT, + [DIR_EAST] = MOVEMENT_ACTION_ACRO_POP_WHEELIE_MOVE_RIGHT, + [DIR_SOUTHWEST] = MOVEMENT_ACTION_ACRO_POP_WHEELIE_MOVE_LEFT, + [DIR_NORTHWEST] = MOVEMENT_ACTION_ACRO_POP_WHEELIE_MOVE_LEFT, + [DIR_SOUTHEAST] = MOVEMENT_ACTION_ACRO_POP_WHEELIE_MOVE_RIGHT, + [DIR_NORTHEAST] = MOVEMENT_ACTION_ACRO_POP_WHEELIE_MOVE_RIGHT, }; const u8 gAcroWheelieMoveDirectionMovementActions[] = { - MOVEMENT_ACTION_ACRO_WHEELIE_MOVE_DOWN, - MOVEMENT_ACTION_ACRO_WHEELIE_MOVE_DOWN, - MOVEMENT_ACTION_ACRO_WHEELIE_MOVE_UP, - MOVEMENT_ACTION_ACRO_WHEELIE_MOVE_LEFT, - MOVEMENT_ACTION_ACRO_WHEELIE_MOVE_RIGHT, + [DIR_NONE] = MOVEMENT_ACTION_ACRO_WHEELIE_MOVE_DOWN, + [DIR_SOUTH] = MOVEMENT_ACTION_ACRO_WHEELIE_MOVE_DOWN, + [DIR_NORTH] = MOVEMENT_ACTION_ACRO_WHEELIE_MOVE_UP, + [DIR_WEST] = MOVEMENT_ACTION_ACRO_WHEELIE_MOVE_LEFT, + [DIR_EAST] = MOVEMENT_ACTION_ACRO_WHEELIE_MOVE_RIGHT, + [DIR_SOUTHWEST] = MOVEMENT_ACTION_ACRO_WHEELIE_MOVE_LEFT, + [DIR_NORTHWEST] = MOVEMENT_ACTION_ACRO_WHEELIE_MOVE_LEFT, + [DIR_SOUTHEAST] = MOVEMENT_ACTION_ACRO_WHEELIE_MOVE_RIGHT, + [DIR_NORTHEAST] = MOVEMENT_ACTION_ACRO_WHEELIE_MOVE_RIGHT, }; const u8 gAcroEndWheelieMoveDirectionMovementActions[] = { - MOVEMENT_ACTION_ACRO_END_WHEELIE_MOVE_DOWN, - MOVEMENT_ACTION_ACRO_END_WHEELIE_MOVE_DOWN, - MOVEMENT_ACTION_ACRO_END_WHEELIE_MOVE_UP, - MOVEMENT_ACTION_ACRO_END_WHEELIE_MOVE_LEFT, - MOVEMENT_ACTION_ACRO_END_WHEELIE_MOVE_RIGHT, + [DIR_NONE] = MOVEMENT_ACTION_ACRO_END_WHEELIE_MOVE_DOWN, + [DIR_SOUTH] = MOVEMENT_ACTION_ACRO_END_WHEELIE_MOVE_DOWN, + [DIR_NORTH] = MOVEMENT_ACTION_ACRO_END_WHEELIE_MOVE_UP, + [DIR_WEST] = MOVEMENT_ACTION_ACRO_END_WHEELIE_MOVE_LEFT, + [DIR_EAST] = MOVEMENT_ACTION_ACRO_END_WHEELIE_MOVE_RIGHT, + [DIR_SOUTHWEST] = MOVEMENT_ACTION_ACRO_END_WHEELIE_MOVE_LEFT, + [DIR_NORTHWEST] = MOVEMENT_ACTION_ACRO_END_WHEELIE_MOVE_LEFT, + [DIR_SOUTHEAST] = MOVEMENT_ACTION_ACRO_END_WHEELIE_MOVE_RIGHT, + [DIR_NORTHEAST] = MOVEMENT_ACTION_ACRO_END_WHEELIE_MOVE_RIGHT, }; // run slow const u8 gRunSlowMovementActions[] = { @@ -1150,21 +1187,6 @@ const u8 gDiagonalStairLeftSideRunningMovementActions[] = { [DIR_WEST] = MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_DOWN_LEFT_RUNNING, [DIR_EAST] = MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_UP_RIGHT_RUNNING, }; -const u8 gDiagonalStairLeftAcroBikeMovementActions[] = { - [DIR_NONE] = MOVEMENT_ACTION_RIDE_WATER_CURRENT_LEFT, - [DIR_SOUTH] = MOVEMENT_ACTION_RIDE_WATER_CURRENT_LEFT, - [DIR_NORTH] = MOVEMENT_ACTION_RIDE_WATER_CURRENT_LEFT, - [DIR_WEST] = MOVEMENT_ACTION_RIDE_WATER_CURRENT_UP_LEFT, - [DIR_EAST] = MOVEMENT_ACTION_RIDE_WATER_CURRENT_DOWN_RIGHT, - -}; -const u8 gDiagonalStairRightAcroBikeMovementActions[] = { - [DIR_NONE] = MOVEMENT_ACTION_RIDE_WATER_CURRENT_RIGHT, - [DIR_SOUTH] = MOVEMENT_ACTION_RIDE_WATER_CURRENT_RIGHT, - [DIR_NORTH] = MOVEMENT_ACTION_RIDE_WATER_CURRENT_RIGHT, - [DIR_WEST] = MOVEMENT_ACTION_RIDE_WATER_CURRENT_DOWN_LEFT, - [DIR_EAST] = MOVEMENT_ACTION_RIDE_WATER_CURRENT_UP_RIGHT, -}; const u8 gOppositeDirections[] = { DIR_NORTH, @@ -5164,8 +5186,6 @@ dirn_to_anim(GetDiagonalRightStairsMovement, gDiagonalStairRightSideMovementActi dirn_to_anim(GetDiagonalLeftStairsMovement, gDiagonalStairLeftSideMovementActions); dirn_to_anim(GetDiagonalRightStairsRunningMovement, gDiagonalStairRightSideRunningMovementActions); dirn_to_anim(GetDiagonalLeftStairsRunningMovement, gDiagonalStairLeftSideRunningMovementActions); -dirn_to_anim(GetDiagonalLeftAcroBikeMovement, gDiagonalStairLeftAcroBikeMovementActions); -dirn_to_anim(GetDiagonalRightAcroBikeMovement, gDiagonalStairRightAcroBikeMovementActions); dirn_to_anim(GetFaceDirectionMovementAction, gFaceDirectionMovementActions); dirn_to_anim(GetWalkSlowMovementAction, gWalkSlowMovementActions); @@ -7123,7 +7143,7 @@ bool8 MovementAction_AcroWheelieHopFaceRight_Step1(struct ObjectEvent *objectEve bool8 MovementAction_AcroWheelieHopDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8095B84(objectEvent, sprite, DIR_SOUTH, 1, 1); + sub_8095B84(objectEvent, sprite, gSidewaysStairsDirection, 1, 1); return MovementAction_AcroWheelieHopDown_Step1(objectEvent, sprite); } @@ -7140,7 +7160,7 @@ bool8 MovementAction_AcroWheelieHopDown_Step1(struct ObjectEvent *objectEvent, s bool8 MovementAction_AcroWheelieHopUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8095B84(objectEvent, sprite, DIR_NORTH, 1, 1); + sub_8095B84(objectEvent, sprite, gSidewaysStairsDirection, 1, 1); return MovementAction_AcroWheelieHopUp_Step1(objectEvent, sprite); } @@ -7157,7 +7177,7 @@ bool8 MovementAction_AcroWheelieHopUp_Step1(struct ObjectEvent *objectEvent, str bool8 MovementAction_AcroWheelieHopLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8095B84(objectEvent, sprite, DIR_WEST, 1, 1); + sub_8095B84(objectEvent, sprite, gSidewaysStairsDirection, 1, 1); return MovementAction_AcroWheelieHopLeft_Step1(objectEvent, sprite); } @@ -7174,7 +7194,7 @@ bool8 MovementAction_AcroWheelieHopLeft_Step1(struct ObjectEvent *objectEvent, s bool8 MovementAction_AcroWheelieHopRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8095B84(objectEvent, sprite, DIR_EAST, 1, 1); + sub_8095B84(objectEvent, sprite, gSidewaysStairsDirection, 1, 1); return MovementAction_AcroWheelieHopRight_Step1(objectEvent, sprite); } @@ -7191,7 +7211,7 @@ bool8 MovementAction_AcroWheelieHopRight_Step1(struct ObjectEvent *objectEvent, bool8 MovementAction_AcroWheelieJumpDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8095B84(objectEvent, sprite, DIR_SOUTH, 2, 0); + sub_8095B84(objectEvent, sprite, gSidewaysStairsDirection, 2, 0); return MovementAction_AcroWheelieJumpDown_Step1(objectEvent, sprite); } @@ -7208,7 +7228,7 @@ bool8 MovementAction_AcroWheelieJumpDown_Step1(struct ObjectEvent *objectEvent, bool8 MovementAction_AcroWheelieJumpUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8095B84(objectEvent, sprite, DIR_NORTH, 2, 0); + sub_8095B84(objectEvent, sprite, gSidewaysStairsDirection, 2, 0); return MovementAction_AcroWheelieJumpUp_Step1(objectEvent, sprite); } @@ -7225,7 +7245,7 @@ bool8 MovementAction_AcroWheelieJumpUp_Step1(struct ObjectEvent *objectEvent, st bool8 MovementAction_AcroWheelieJumpLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8095B84(objectEvent, sprite, DIR_WEST, 2, 0); + sub_8095B84(objectEvent, sprite, gSidewaysStairsDirection, 2, 0); return MovementAction_AcroWheelieJumpLeft_Step1(objectEvent, sprite); } @@ -7242,7 +7262,7 @@ bool8 MovementAction_AcroWheelieJumpLeft_Step1(struct ObjectEvent *objectEvent, bool8 MovementAction_AcroWheelieJumpRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8095B84(objectEvent, sprite, DIR_EAST, 2, 0); + sub_8095B84(objectEvent, sprite, gSidewaysStairsDirection, 2, 0); return MovementAction_AcroWheelieJumpRight_Step1(objectEvent, sprite); } @@ -7259,25 +7279,25 @@ bool8 MovementAction_AcroWheelieJumpRight_Step1(struct ObjectEvent *objectEvent, bool8 MovementAction_AcroWheelieInPlaceDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8094554(objectEvent, sprite, DIR_SOUTH, GetAcroWheeliePedalDirectionAnimNum(DIR_SOUTH), 8); + sub_8094554(objectEvent, sprite, gSidewaysStairsDirection, GetAcroWheeliePedalDirectionAnimNum(gSidewaysStairsDirection), 8); return MovementAction_WalkInPlace_Step1(objectEvent, sprite); } bool8 MovementAction_AcroWheelieInPlaceUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8094554(objectEvent, sprite, DIR_NORTH, GetAcroWheeliePedalDirectionAnimNum(DIR_NORTH), 8); + sub_8094554(objectEvent, sprite, gSidewaysStairsDirection, GetAcroWheeliePedalDirectionAnimNum(gSidewaysStairsDirection), 8); return MovementAction_WalkInPlace_Step1(objectEvent, sprite); } bool8 MovementAction_AcroWheelieInPlaceLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8094554(objectEvent, sprite, DIR_WEST, GetAcroWheeliePedalDirectionAnimNum(DIR_WEST), 8); + sub_8094554(objectEvent, sprite, gSidewaysStairsDirection, GetAcroWheeliePedalDirectionAnimNum(gSidewaysStairsDirection), 8); return MovementAction_WalkInPlace_Step1(objectEvent, sprite); } bool8 MovementAction_AcroWheelieInPlaceRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8094554(objectEvent, sprite, DIR_EAST, GetAcroWheeliePedalDirectionAnimNum(DIR_EAST), 8); + sub_8094554(objectEvent, sprite, gSidewaysStairsDirection, GetAcroWheeliePedalDirectionAnimNum(gSidewaysStairsDirection), 8); return MovementAction_WalkInPlace_Step1(objectEvent, sprite); } @@ -7290,7 +7310,7 @@ void sub_80960C8(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 dire bool8 MovementAction_AcroPopWheelieMoveDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_80960C8(objectEvent, sprite, DIR_SOUTH, 1); + sub_80960C8(objectEvent, sprite, gSidewaysStairsDirection, 1); return MovementAction_AcroPopWheelieMoveDown_Step1(objectEvent, sprite); } @@ -7306,7 +7326,7 @@ bool8 MovementAction_AcroPopWheelieMoveDown_Step1(struct ObjectEvent *objectEven bool8 MovementAction_AcroPopWheelieMoveUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_80960C8(objectEvent, sprite, DIR_NORTH, 1); + sub_80960C8(objectEvent, sprite, gSidewaysStairsDirection, 1); return MovementAction_AcroPopWheelieMoveUp_Step1(objectEvent, sprite); } @@ -7322,7 +7342,7 @@ bool8 MovementAction_AcroPopWheelieMoveUp_Step1(struct ObjectEvent *objectEvent, bool8 MovementAction_AcroPopWheelieMoveLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_80960C8(objectEvent, sprite, DIR_WEST, 1); + sub_80960C8(objectEvent, sprite, gSidewaysStairsDirection, 1); return MovementAction_AcroPopWheelieMoveLeft_Step1(objectEvent, sprite); } @@ -7338,7 +7358,7 @@ bool8 MovementAction_AcroPopWheelieMoveLeft_Step1(struct ObjectEvent *objectEven bool8 MovementAction_AcroPopWheelieMoveRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_80960C8(objectEvent, sprite, DIR_EAST, 1); + sub_80960C8(objectEvent, sprite, gSidewaysStairsDirection, 1); return MovementAction_AcroPopWheelieMoveRight_Step1(objectEvent, sprite); } @@ -7360,7 +7380,7 @@ void sub_8096200(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 dire bool8 MovementAction_AcroWheelieMoveDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8096200(objectEvent, sprite, DIR_SOUTH, 1); + sub_8096200(objectEvent, sprite, gSidewaysStairsDirection, 1); return MovementAction_AcroWheelieMoveDown_Step1(objectEvent, sprite); } @@ -7376,7 +7396,7 @@ bool8 MovementAction_AcroWheelieMoveDown_Step1(struct ObjectEvent *objectEvent, bool8 MovementAction_AcroWheelieMoveUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8096200(objectEvent, sprite, DIR_NORTH, 1); + sub_8096200(objectEvent, sprite, gSidewaysStairsDirection, 1); return MovementAction_AcroWheelieMoveUp_Step1(objectEvent, sprite); } @@ -7392,7 +7412,7 @@ bool8 MovementAction_AcroWheelieMoveUp_Step1(struct ObjectEvent *objectEvent, st bool8 MovementAction_AcroWheelieMoveLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8096200(objectEvent, sprite, DIR_WEST, 1); + sub_8096200(objectEvent, sprite, gSidewaysStairsDirection, 1); return MovementAction_AcroWheelieMoveLeft_Step1(objectEvent, sprite); } @@ -7408,7 +7428,7 @@ bool8 MovementAction_AcroWheelieMoveLeft_Step1(struct ObjectEvent *objectEvent, bool8 MovementAction_AcroWheelieMoveRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8096200(objectEvent, sprite, DIR_EAST, 1); + sub_8096200(objectEvent, sprite, gSidewaysStairsDirection, 1); return MovementAction_AcroWheelieMoveRight_Step1(objectEvent, sprite); } @@ -7431,7 +7451,7 @@ void sub_8096330(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 dire bool8 MovementAction_AcroEndWheelieMoveDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8096330(objectEvent, sprite, DIR_SOUTH, 1); + sub_8096330(objectEvent, sprite, gSidewaysStairsDirection, 1); return MovementAction_AcroEndWheelieMoveDown_Step1(objectEvent, sprite); } @@ -7447,7 +7467,7 @@ bool8 MovementAction_AcroEndWheelieMoveDown_Step1(struct ObjectEvent *objectEven bool8 MovementAction_AcroEndWheelieMoveUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8096330(objectEvent, sprite, DIR_NORTH, 1); + sub_8096330(objectEvent, sprite, gSidewaysStairsDirection, 1); return MovementAction_AcroEndWheelieMoveUp_Step1(objectEvent, sprite); } @@ -7463,7 +7483,7 @@ bool8 MovementAction_AcroEndWheelieMoveUp_Step1(struct ObjectEvent *objectEvent, bool8 MovementAction_AcroEndWheelieMoveLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8096330(objectEvent, sprite, DIR_WEST, 1); + sub_8096330(objectEvent, sprite, gSidewaysStairsDirection, 1); return MovementAction_AcroEndWheelieMoveLeft_Step1(objectEvent, sprite); } @@ -7479,7 +7499,7 @@ bool8 MovementAction_AcroEndWheelieMoveLeft_Step1(struct ObjectEvent *objectEven bool8 MovementAction_AcroEndWheelieMoveRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8096330(objectEvent, sprite, DIR_EAST, 1); + sub_8096330(objectEvent, sprite, gSidewaysStairsDirection, 1); return MovementAction_AcroEndWheelieMoveRight_Step1(objectEvent, sprite); } @@ -9227,101 +9247,67 @@ bool8 MovementActionFunc_RunSlow_Step1(struct ObjectEvent *objectEvent, struct S } //sideways stairs -/* -u8 GetSidewaysStairsToRightDirection(s16 x, s16 y, u8 z) -{ - static bool8 (*const sRightStairsBehaviors[])(u8) = { - MetatileBehavior_IsWalkSouth, - MetatileBehavior_IsWalkNorth, - MetatileBehavior_IsSidewaysStairsRight, - MetatileBehavior_IsSidewaysStairsRight, - }; - - u8 metatileBehavior; - u8 index = z; - - if (index == DIR_NONE) - return DIR_NONE; - else if (index > DIR_EAST) - index -= DIR_EAST; - - index--; - metatileBehavior = MapGridGetMetatileBehaviorAt(x, y); - if (MetatileBehavior_IsEastBlocked(metatileBehavior)) - return DIR_NONE; - - if (sRightStairsBehaviors[index](metatileBehavior)) - return index + 1; - - return DIR_NONE; -} - -u8 GetSidewaysStairsToLeftDirection(s16 x, s16 y, u8 z) -{ - static bool8 (*const sLeftStairsBehaviors[])(u8) = { - MetatileBehavior_IsWalkSouth, - MetatileBehavior_IsWalkNorth, - MetatileBehavior_IsSidewaysStairsLeft, - MetatileBehavior_IsSidewaysStairsLeft, - }; - - u8 metatileBehavior; - u8 index = z; - - if (index == DIR_NONE) - return DIR_NONE; - else if (index > 4) - index -= 4; - - index--; - metatileBehavior = MapGridGetMetatileBehaviorAt(x, y); - if (MetatileBehavior_IsWestBlocked(metatileBehavior)) - return DIR_NONE; - - if (sLeftStairsBehaviors[index](metatileBehavior) == 1) - return index + 1; - - return DIR_NONE; -} -*/ - bool8 MovementAction_WalkStairDiagonalUpLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { objectEvent->facingDirection = DIR_WEST; objectEvent->facingDirectionLocked = TRUE; - sub_8093B60(objectEvent, sprite, DIR_NORTHWEST); - return MovementAction_WalkSlowDiagonalUpLeft_Step1(objectEvent, sprite); + #if SLOW_MOVEMENT_ON_STAIRS == TRUE + sub_8093B60(objectEvent, sprite, DIR_NORTHWEST); + return MovementAction_WalkSlowDiagonalUpLeft_Step1(objectEvent, sprite); + #else + do_go_anim(objectEvent, sprite, DIR_NORTHWEST, 0); + return MovementAction_WalkNormalDiagonalUpLeft_Step1(objectEvent, sprite); + #endif } bool8 MovementAction_WalkStairDiagonalUpRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { objectEvent->facingDirection = DIR_EAST; objectEvent->facingDirectionLocked = TRUE; - sub_8093B60(objectEvent, sprite, DIR_NORTHEAST); - return MovementAction_WalkSlowDiagonalUpRight_Step1(objectEvent, sprite); + #if SLOW_MOVEMENT_ON_STAIRS == TRUE + sub_8093B60(objectEvent, sprite, DIR_NORTHEAST); + return MovementAction_WalkSlowDiagonalUpRight_Step1(objectEvent, sprite); + #else + do_go_anim(objectEvent, sprite, DIR_NORTHEAST, 0); + return MovementAction_WalkNormalDiagonalUpLeft_Step1(objectEvent, sprite); + #endif } bool8 MovementAction_WalkStairDiagonalDownLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { objectEvent->facingDirection = DIR_WEST; objectEvent->facingDirectionLocked = TRUE; - sub_8093B60(objectEvent, sprite, DIR_SOUTHWEST); - return MovementAction_WalkSlowDiagonalDownLeft_Step1(objectEvent, sprite); + #if SLOW_MOVEMENT_ON_STAIRS == TRUE + sub_8093B60(objectEvent, sprite, DIR_SOUTHWEST); + return MovementAction_WalkSlowDiagonalDownLeft_Step1(objectEvent, sprite); + #else + do_go_anim(objectEvent, sprite, DIR_SOUTHWEST, 0); + return MovementAction_WalkNormalDiagonalUpLeft_Step1(objectEvent, sprite); + #endif } bool8 MovementAction_WalkStairDiagonalDownRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { objectEvent->facingDirection = DIR_EAST; objectEvent->facingDirectionLocked = TRUE; - sub_8093B60(objectEvent, sprite, DIR_SOUTHEAST); - return MovementAction_WalkSlowDiagonalDownRight_Step1(objectEvent, sprite); + #if SLOW_MOVEMENT_ON_STAIRS == TRUE + sub_8093B60(objectEvent, sprite, DIR_SOUTHEAST); + return MovementAction_WalkSlowDiagonalDownRight_Step1(objectEvent, sprite); + #else + do_go_anim(objectEvent, sprite, DIR_SOUTHEAST, 0); + return MovementAction_WalkNormalDiagonalUpLeft_Step1(objectEvent, sprite); + #endif } bool8 MovementAction_RunStairDiagonalUpLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { objectEvent->facingDirection = DIR_WEST; objectEvent->facingDirectionLocked = TRUE; - StartSlowRunningAnim(objectEvent, sprite, DIR_NORTHWEST); + #if SLOW_MOVEMENT_ON_STAIRS == TRUE + StartSlowRunningAnim(objectEvent, sprite, DIR_NORTHWEST); + #else + StartRunningAnim(objectEvent, sprite, DIR_NORTHWEST); + #endif return MovementAction_RunStairDiagonal_Step1(objectEvent, sprite); } @@ -9329,7 +9315,11 @@ bool8 MovementAction_RunStairDiagonalUpRight_Step0(struct ObjectEvent *objectEve { objectEvent->facingDirection = DIR_EAST; objectEvent->facingDirectionLocked = TRUE; - StartSlowRunningAnim(objectEvent, sprite, DIR_NORTHEAST); + #if SLOW_MOVEMENT_ON_STAIRS == TRUE + StartSlowRunningAnim(objectEvent, sprite, DIR_NORTHEAST); + #else + StartRunningAnim(objectEvent, sprite, DIR_NORTHEAST); + #endif return MovementAction_RunStairDiagonal_Step1(objectEvent, sprite); } @@ -9337,7 +9327,11 @@ bool8 MovementAction_RunStairDiagonalDownLeft_Step0(struct ObjectEvent *objectEv { objectEvent->facingDirection = DIR_WEST; objectEvent->facingDirectionLocked = TRUE; - StartSlowRunningAnim(objectEvent, sprite, DIR_SOUTHWEST); + #if SLOW_MOVEMENT_ON_STAIRS == TRUE + StartSlowRunningAnim(objectEvent, sprite, DIR_SOUTHWEST); + #else + StartRunningAnim(objectEvent, sprite, DIR_SOUTHWEST); + #endif return MovementAction_RunStairDiagonal_Step1(objectEvent, sprite); } @@ -9345,7 +9339,11 @@ bool8 MovementAction_RunStairDiagonalDownRight_Step0(struct ObjectEvent *objectE { objectEvent->facingDirection = DIR_EAST; objectEvent->facingDirectionLocked = TRUE; - StartSlowRunningAnim(objectEvent, sprite, DIR_SOUTHEAST); + #if SLOW_MOVEMENT_ON_STAIRS == TRUE + StartSlowRunningAnim(objectEvent, sprite, DIR_SOUTHEAST); + #else + StartRunningAnim(objectEvent, sprite, DIR_SOUTHEAST); + #endif return MovementAction_RunStairDiagonal_Step1(objectEvent, sprite); } @@ -9363,7 +9361,7 @@ bool8 MovementAction_AcroBikeDiagonalUpLeft_Step0(struct ObjectEvent *objectEven { objectEvent->facingDirection = DIR_WEST; objectEvent->facingDirectionLocked = TRUE; - #if SLOW_MOVEMENT_ON_STAIRS + #if SLOW_MOVEMENT_ON_STAIRS == TRUE do_go_anim(objectEvent, sprite, DIR_NORTHWEST, 0); #else do_go_anim(objectEvent, sprite, DIR_NORTHWEST, 2); @@ -9375,7 +9373,7 @@ bool8 MovementAction_AcroBikeDiagonalDownLeft_Step0(struct ObjectEvent *objectEv { objectEvent->facingDirection = DIR_WEST; objectEvent->facingDirectionLocked = TRUE; - #if SLOW_MOVEMENT_ON_STAIRS + #if SLOW_MOVEMENT_ON_STAIRS == TRUE do_go_anim(objectEvent, sprite, DIR_SOUTHWEST, 0); #else do_go_anim(objectEvent, sprite, DIR_SOUTHWEST, 2); @@ -9387,7 +9385,7 @@ bool8 MovementAction_AcroBikeDiagonalUpRight_Step0(struct ObjectEvent *objectEve { objectEvent->facingDirection = DIR_EAST; objectEvent->facingDirectionLocked = TRUE; - #if SLOW_MOVEMENT_ON_STAIRS + #if SLOW_MOVEMENT_ON_STAIRS == TRUE do_go_anim(objectEvent, sprite, DIR_NORTHEAST, 0); #else do_go_anim(objectEvent, sprite, DIR_NORTHEAST, 2); @@ -9399,7 +9397,7 @@ bool8 MovementAction_AcroBikeDiagonalDownRight_Step0(struct ObjectEvent *objectE { objectEvent->facingDirection = DIR_EAST; objectEvent->facingDirectionLocked = TRUE; - #if SLOW_MOVEMENT_ON_STAIRS + #if SLOW_MOVEMENT_ON_STAIRS == TRUE do_go_anim(objectEvent, sprite, DIR_SOUTHEAST, 0); #else do_go_anim(objectEvent, sprite, DIR_SOUTHEAST, 2); diff --git a/src/field_player_avatar.c b/src/field_player_avatar.c index cec876555cb3..b130021912f9 100644 --- a/src/field_player_avatar.c +++ b/src/field_player_avatar.c @@ -690,31 +690,11 @@ bool32 PlayerIsMovingOnRockStairs(u8 direction) case DIR_SOUTH: MoveCoords(DIR_SOUTH, &x, &y); return MetatileBehavior_IsRockStairs(MapGridGetMetatileBehaviorAt(x, y)); - /* - case DIR_WEST: - MoveCoords(DIR_WEST, &x, &y); - return MetatileBehavior_IsRockStairs(MapGridGetMetatileBehaviorAt(x, y)); - case DIR_EAST: - MoveCoords(DIR_EAST, &x, &y); - return MetatileBehavior_IsRockStairs(MapGridGetMetatileBehaviorAt(x, y)); - case DIR_SOUTHWEST: - MoveCoords(DIR_SOUTHWEST, &x, &y); - return MetatileBehavior_IsRockStairs(MapGridGetMetatileBehaviorAt(x, y)); - case DIR_SOUTHEAST: - MoveCoords(DIR_SOUTHEAST, &x, &y); - return MetatileBehavior_IsRockStairs(MapGridGetMetatileBehaviorAt(x, y)); - case DIR_NORTHWEST: - MoveCoords(DIR_NORTHWEST, &x, &y); - return MetatileBehavior_IsRockStairs(MapGridGetMetatileBehaviorAt(x, y)); - case DIR_NORTHEAST: - MoveCoords(DIR_NORTHEAST, &x, &y); - return MetatileBehavior_IsRockStairs(MapGridGetMetatileBehaviorAt(x, y)); - */ default: return FALSE; } #else - return FALSE + return FALSE; #endif } @@ -2344,24 +2324,6 @@ static u8 TrySpinPlayerForWarp(struct ObjectEvent *object, s16 *delayTimer) } //sideways stairs -/* -static bool8 IsSidewaysStairToRight(s16 x, s16 y, u8 z) -{ - if (GetSidewaysStairsToRightDirection(x, y, z) != 0) - return TRUE; - else - return FALSE; -} - -static bool8 IsSidewaysStairToLeft(s16 x, s16 y, u8 z) -{ - if (GetSidewaysStairsToLeftDirection(x, y, z) != 0) - return TRUE; - else - return FALSE; -} -*/ - u8 GetRightSideStairsDirection(u8 direction) { switch (direction) @@ -2413,14 +2375,3 @@ void PlayerSidewaysStairsLeftSideRunning(u8 direction) { PlayerSetAnimId(GetDiagonalLeftStairsRunningMovement(direction), 8); } - -void PlayerSidewaysStairsToAcroBikeLeft(u8 direction) -{ - PlayerSetAnimId(GetDiagonalLeftAcroBikeMovement(direction), 8); -} - -void PlayerSidewaysStairsToAcroBikeRight(u8 direction) -{ - PlayerSetAnimId(GetDiagonalRightAcroBikeMovement(direction), 8); -} - diff --git a/src/metatile_behavior.c b/src/metatile_behavior.c index f490d25931e5..86e4ec98b3d6 100644 --- a/src/metatile_behavior.c +++ b/src/metatile_behavior.c @@ -1566,7 +1566,7 @@ bool8 MetatileBehavior_IsSidewaysStairsLeftSideAny(u8 metatileBehavior) bool8 MetatileBehavior_IsRockStairs(u8 metatileBehavior) { - if (metatileBehavior == MB_ROCK_STAIRS) // || metatileBehavior == MB_SIDEWAYS_STAIRS_LEFT || metatileBehavior == MB_SIDEWAYS_STAIRS_RIGHT) + if (metatileBehavior == MB_ROCK_STAIRS) return TRUE; else return FALSE; From 492683eeb6367d86bc84d2040828cbd0de065dd1 Mon Sep 17 00:00:00 2001 From: Evan Date: Sat, 6 Jun 2020 13:19:17 -0600 Subject: [PATCH 05/27] fix stairs north dir bug --- src/field_player_avatar.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/field_player_avatar.c b/src/field_player_avatar.c index b130021912f9..e156774d428f 100644 --- a/src/field_player_avatar.c +++ b/src/field_player_avatar.c @@ -753,6 +753,9 @@ u8 CheckForObjectEventCollision(struct ObjectEvent *objectEvent, s16 x, s16 y, u return COLLISION_IMPASSABLE; else if (MetatileBehavior_IsSidewaysStairsLeftSideBottom(metatileBehavior) && (direction == DIR_WEST || direction == DIR_SOUTH)) return COLLISION_IMPASSABLE; + else if ((MetatileBehavior_IsSidewaysStairsLeftSideTop(currentBehavior) || MetatileBehavior_IsSidewaysStairsRightSideTop(currentBehavior)) + && direction == DIR_NORTH && collision == COLLISION_NONE) + return COLLISION_IMPASSABLE; //trying to move north off of top-most tile onto same level doesn't work if (MetatileBehavior_IsSidewaysStairsLeftSide(metatileBehavior)) { From 7d4545c088e9d181c763dc23a2d9223f0a0d160e Mon Sep 17 00:00:00 2001 From: Evan Date: Sun, 7 Jun 2020 07:13:47 -0600 Subject: [PATCH 06/27] fix same-level movement on stairs --- src/event_object_movement.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/event_object_movement.c b/src/event_object_movement.c index 70970c80bc1a..5ce8a8e98600 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -1160,30 +1160,30 @@ const u8 gRunSlowMovementActions[] = { // sideways stairs const u8 gDiagonalStairLeftSideMovementActions[] = { //movement actions for stairs on left side of a wall (southwest and northeast) - [DIR_NONE] = MOVEMENT_ACTION_WALK_SLOW_DOWN, - [DIR_SOUTH] = MOVEMENT_ACTION_WALK_SLOW_DOWN, - [DIR_NORTH] = MOVEMENT_ACTION_RUN_UP_SLOW, + [DIR_NONE] = MOVEMENT_ACTION_WALK_NORMAL_DOWN, + [DIR_SOUTH] = MOVEMENT_ACTION_WALK_NORMAL_DOWN, + [DIR_NORTH] = MOVEMENT_ACTION_WALK_NORMAL_UP, [DIR_WEST] = MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_DOWN_LEFT, [DIR_EAST] = MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_UP_RIGHT, }; const u8 gDiagonalStairRightSideMovementActions[] = { //movement actions for stairs on right side of a wall (southeast and northwest) - [DIR_NONE] = MOVEMENT_ACTION_WALK_SLOW_DOWN, - [DIR_SOUTH] = MOVEMENT_ACTION_WALK_SLOW_DOWN, - [DIR_NORTH] = MOVEMENT_ACTION_RUN_UP_SLOW, + [DIR_NONE] = MOVEMENT_ACTION_WALK_NORMAL_DOWN, + [DIR_SOUTH] = MOVEMENT_ACTION_WALK_NORMAL_DOWN, + [DIR_NORTH] = MOVEMENT_ACTION_WALK_NORMAL_UP, [DIR_WEST] = MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_UP_LEFT, [DIR_EAST] = MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_DOWN_RIGHT, }; const u8 gDiagonalStairRightSideRunningMovementActions[] = { - [DIR_NONE] = MOVEMENT_ACTION_RUN_DOWN_SLOW, - [DIR_SOUTH] = MOVEMENT_ACTION_RUN_DOWN_SLOW, - [DIR_NORTH] = MOVEMENT_ACTION_RUN_UP_SLOW, + [DIR_NONE] = MOVEMENT_ACTION_PLAYER_RUN_DOWN, + [DIR_SOUTH] = MOVEMENT_ACTION_PLAYER_RUN_DOWN, + [DIR_NORTH] = MOVEMENT_ACTION_PLAYER_RUN_UP, [DIR_WEST] = MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_UP_LEFT_RUNNING, [DIR_EAST] = MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_DOWN_RIGHT_RUNNING, }; const u8 gDiagonalStairLeftSideRunningMovementActions[] = { - [DIR_NONE] = MOVEMENT_ACTION_RUN_DOWN_SLOW, - [DIR_SOUTH] = MOVEMENT_ACTION_RUN_DOWN_SLOW, - [DIR_NORTH] = MOVEMENT_ACTION_RUN_UP_SLOW, + [DIR_NONE] = MOVEMENT_ACTION_PLAYER_RUN_DOWN, + [DIR_SOUTH] = MOVEMENT_ACTION_PLAYER_RUN_DOWN, + [DIR_NORTH] = MOVEMENT_ACTION_PLAYER_RUN_UP, [DIR_WEST] = MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_DOWN_LEFT_RUNNING, [DIR_EAST] = MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_UP_RIGHT_RUNNING, }; From 3f94abf03d7b63bcd4a8332a7833759f8c72fe35 Mon Sep 17 00:00:00 2001 From: Evan Date: Sun, 7 Jun 2020 07:37:39 -0600 Subject: [PATCH 07/27] fix collision freezing --- src/event_object_movement.c | 22 +++++++++++ src/field_player_avatar.c | 75 ++++++++++++++++--------------------- 2 files changed, 55 insertions(+), 42 deletions(-) diff --git a/src/event_object_movement.c b/src/event_object_movement.c index 5ce8a8e98600..9e02edfef498 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -4873,6 +4873,28 @@ static u8 GetCollisionInDirection(struct ObjectEvent *objectEvent, u8 direction) u8 GetCollisionAtCoords(struct ObjectEvent *objectEvent, s16 x, s16 y, u32 dir) { u8 direction = dir; + u8 currentBehavior = MapGridGetMetatileBehaviorAt(objectEvent->currentCoords.x, objectEvent->currentCoords.y); + u8 nextBehavior = MapGridGetMetatileBehaviorAt(x, y); + + //sideways stairs checks + if (MetatileBehavior_IsSidewaysStairsLeftSideTop(nextBehavior) && dir == DIR_EAST) + return COLLISION_IMPASSABLE; //moving onto left-side top edge east from regular ground -> nope + else if (MetatileBehavior_IsSidewaysStairsRightSideTop(nextBehavior) && dir == DIR_WEST) + return COLLISION_IMPASSABLE; //moving onto left-side top edge east from regular ground -> nope + else if (MetatileBehavior_IsSidewaysStairsRightSideBottom(nextBehavior) && (dir == DIR_EAST || dir == DIR_SOUTH)) + return COLLISION_IMPASSABLE; //moving into right-side bottom edge from regular ground -> nah + else if (MetatileBehavior_IsSidewaysStairsLeftSideBottom(nextBehavior) && (dir == DIR_WEST || dir == DIR_SOUTH)) + return COLLISION_IMPASSABLE; //moving onto left-side bottom edge from regular ground -> nah + else if ((MetatileBehavior_IsSidewaysStairsLeftSideTop(currentBehavior) || MetatileBehavior_IsSidewaysStairsRightSideTop(currentBehavior)) + && dir == DIR_NORTH) + return COLLISION_IMPASSABLE; //trying to move north off of top-most tile onto same level doesn't work + else if (!(MetatileBehavior_IsSidewaysStairsLeftSideTop(currentBehavior) || MetatileBehavior_IsSidewaysStairsRightSideTop(currentBehavior)) + && dir == DIR_SOUTH && (MetatileBehavior_IsSidewaysStairsLeftSideTop(nextBehavior) || MetatileBehavior_IsSidewaysStairsRightSideTop(nextBehavior))) + return COLLISION_IMPASSABLE; //trying to move south onto top stair tile at same level from non-stair -> no + else if (!(MetatileBehavior_IsSidewaysStairsLeftSideBottom(currentBehavior) || MetatileBehavior_IsSidewaysStairsRightSideBottom(currentBehavior)) + && dir == DIR_NORTH && (MetatileBehavior_IsSidewaysStairsLeftSideBottom(nextBehavior) || MetatileBehavior_IsSidewaysStairsRightSideBottom(nextBehavior))) + return COLLISION_IMPASSABLE; //trying to move north onto top stair tile at same level from non-stair -> no + if (IsCoordOutsideObjectEventMovementRange(objectEvent, x, y)) return COLLISION_OUTSIDE_RANGE; else if (MapGridIsImpassableAt(x, y) || GetMapBorderIdAt(x, y) == -1 || IsMetatileDirectionallyImpassable(objectEvent, x, y, direction)) diff --git a/src/field_player_avatar.c b/src/field_player_avatar.c index e156774d428f..dd52e3a61244 100644 --- a/src/field_player_avatar.c +++ b/src/field_player_avatar.c @@ -745,49 +745,40 @@ u8 CheckForObjectEventCollision(struct ObjectEvent *objectEvent, s16 x, s16 y, u } //sideways stairs logic - if (MetatileBehavior_IsSidewaysStairsLeftSideTop(metatileBehavior) && direction == DIR_EAST) - return COLLISION_IMPASSABLE; //moving onto left-side top edge east from ground -> cannot move - else if (MetatileBehavior_IsSidewaysStairsRightSideTop(metatileBehavior) && direction == DIR_WEST) - return COLLISION_IMPASSABLE; //moving onto left-side top edge east from ground -> cannot move - else if (MetatileBehavior_IsSidewaysStairsRightSideBottom(metatileBehavior) && (direction == DIR_EAST || direction == DIR_SOUTH)) - return COLLISION_IMPASSABLE; - else if (MetatileBehavior_IsSidewaysStairsLeftSideBottom(metatileBehavior) && (direction == DIR_WEST || direction == DIR_SOUTH)) - return COLLISION_IMPASSABLE; - else if ((MetatileBehavior_IsSidewaysStairsLeftSideTop(currentBehavior) || MetatileBehavior_IsSidewaysStairsRightSideTop(currentBehavior)) - && direction == DIR_NORTH && collision == COLLISION_NONE) - return COLLISION_IMPASSABLE; //trying to move north off of top-most tile onto same level doesn't work - - if (MetatileBehavior_IsSidewaysStairsLeftSide(metatileBehavior)) - { - //moving ONTO left side stair - if (direction == DIR_WEST && currentBehavior != metatileBehavior) - return collision; //moving onto top part of left-stair going left, so no diagonal - else - return COLLISION_SIDEWAYS_STAIRS_TO_LEFT; // move diagonally - } - else if (MetatileBehavior_IsSidewaysStairsRightSide(metatileBehavior)) - { - //moving ONTO right side stair - if (direction == DIR_EAST && currentBehavior != metatileBehavior) - return collision; //moving onto top part of right-stair going right, so no diagonal - else - return COLLISION_SIDEWAYS_STAIRS_TO_RIGHT; - } - else if (MetatileBehavior_IsSidewaysStairsLeftSideAny(currentBehavior)) - { - //moving OFF of any left side stair - if (direction == DIR_WEST && metatileBehavior != currentBehavior) - return COLLISION_SIDEWAYS_STAIRS_TO_LEFT; //moving off of left stairs onto non-stair -> move diagonal - else - return collision; //moving off of left side stair to east -> move east - } - else if (MetatileBehavior_IsSidewaysStairsRightSideAny(currentBehavior)) + if (direction == DIR_WEST || direction == DIR_EAST) { - //moving OFF of any right side stair - if (direction == DIR_EAST && metatileBehavior != currentBehavior) - return COLLISION_SIDEWAYS_STAIRS_TO_RIGHT; //moving off right stair onto non-stair -> move diagonal - else - return collision; + if (MetatileBehavior_IsSidewaysStairsLeftSide(metatileBehavior)) + { + //moving ONTO left side stair + if (direction == DIR_WEST && currentBehavior != metatileBehavior) + return collision; //moving onto top part of left-stair going left, so no diagonal + else + return COLLISION_SIDEWAYS_STAIRS_TO_LEFT; // move diagonally + } + else if (MetatileBehavior_IsSidewaysStairsRightSide(metatileBehavior)) + { + //moving ONTO right side stair + if (direction == DIR_EAST && currentBehavior != metatileBehavior) + return collision; //moving onto top part of right-stair going right, so no diagonal + else + return COLLISION_SIDEWAYS_STAIRS_TO_RIGHT; + } + else if (MetatileBehavior_IsSidewaysStairsLeftSideAny(currentBehavior)) + { + //moving OFF of any left side stair + if (direction == DIR_WEST && metatileBehavior != currentBehavior) + return COLLISION_SIDEWAYS_STAIRS_TO_LEFT; //moving off of left stairs onto non-stair -> move diagonal + else + return collision; //moving off of left side stair to east -> move east + } + else if (MetatileBehavior_IsSidewaysStairsRightSideAny(currentBehavior)) + { + //moving OFF of any right side stair + if (direction == DIR_EAST && metatileBehavior != currentBehavior) + return COLLISION_SIDEWAYS_STAIRS_TO_RIGHT; //moving off right stair onto non-stair -> move diagonal + else + return collision; + } } return collision; From d3d29d7cb565aeb39952c4b4c0945cabb4d304c9 Mon Sep 17 00:00:00 2001 From: Evan Date: Fri, 19 Jun 2020 23:40:12 -0600 Subject: [PATCH 08/27] cherry pick 0cccbfd0ba608287d5f2b642ea613d9674cd919d --- include/constants/event_object_movement.h | 18 +- include/constants/global.h | 2 - include/event_object_movement.h | 16 +- include/field_player_avatar.h | 4 - include/global.fieldmap.h | 3 +- include/metatile_behavior.h | 1 - src/bike.c | 95 +-- .../movement_action_func_tables.h | 130 ---- src/event_object_movement.c | 693 +++++++++--------- src/field_control_avatar.c | 46 +- src/field_player_avatar.c | 127 +--- src/metatile_behavior.c | 7 - 12 files changed, 451 insertions(+), 691 deletions(-) diff --git a/include/constants/event_object_movement.h b/include/constants/event_object_movement.h index 5172e12d514e..7a02b2b976f9 100755 --- a/include/constants/event_object_movement.h +++ b/include/constants/event_object_movement.h @@ -241,27 +241,11 @@ #define MOVEMENT_ACTION_FIGURE_8 0x9B #define MOVEMENT_ACTION_FLY_UP 0x9C #define MOVEMENT_ACTION_FLY_DOWN 0x9D -// slow running (for stairs) +// slow running #define MOVEMENT_ACTION_RUN_DOWN_SLOW 0x9E #define MOVEMENT_ACTION_RUN_UP_SLOW 0x9F #define MOVEMENT_ACTION_RUN_LEFT_SLOW 0xA0 #define MOVEMENT_ACTION_RUN_RIGHT_SLOW 0xA1 -// sideways stairs - walking -#define MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_UP_LEFT 0xA2 -#define MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_UP_RIGHT 0xA3 -#define MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_DOWN_LEFT 0xA4 -#define MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_DOWN_RIGHT 0xA5 -// sideways stairs - running -#define MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_UP_LEFT_RUNNING 0xA6 -#define MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_UP_RIGHT_RUNNING 0xA7 -#define MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_DOWN_LEFT_RUNNING 0xA8 -#define MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_DOWN_RIGHT_RUNNING 0xA9 -// sideways stairs - acro bike -#define MOVEMENT_ACTION_RIDE_WATER_CURRENT_UP_LEFT 0xAA -#define MOVEMENT_ACTION_RIDE_WATER_CURRENT_UP_RIGHT 0xAB -#define MOVEMENT_ACTION_RIDE_WATER_CURRENT_DOWN_LEFT 0xAC -#define MOVEMENT_ACTION_RIDE_WATER_CURRENT_DOWN_RIGHT 0xAD -//sideways stairs - mach bike #define MOVEMENT_ACTION_STEP_END 0xFE diff --git a/include/constants/global.h b/include/constants/global.h index 4a3f0618a8f0..213ccca5b54e 100644 --- a/include/constants/global.h +++ b/include/constants/global.h @@ -118,6 +118,4 @@ #define DIR_NORTHWEST 7 #define DIR_NORTHEAST 8 -#define SLOW_MOVEMENT_ON_STAIRS TRUE // change to false to keep emerald's normal movement speed on outdoor stairs - #endif // GUARD_CONSTANTS_GLOBAL_H diff --git a/include/event_object_movement.h b/include/event_object_movement.h index 84c89a85d3a6..61e7c5d6c2a0 100644 --- a/include/event_object_movement.h +++ b/include/event_object_movement.h @@ -82,6 +82,7 @@ bool8 TryGetObjectEventIdByLocalIdAndMap(u8, u8, u8, u8 *); u8 GetObjectEventIdByXY(s16, s16); void SetObjectEventDirection(struct ObjectEvent *, u8); u8 GetFirstInactiveObjectEventId(void); +void RemoveObjectEvent(struct ObjectEvent *objectEvent); void RemoveObjectEventByLocalIdAndMap(u8, u8, u8); void LoadPlayerObjectReflectionPalette(u16, u8); void LoadSpecialObjectReflectionPalette(u16, u8); @@ -125,6 +126,7 @@ u8 GetWalkInPlaceFastMovementAction(u32); u8 GetWalkInPlaceNormalMovementAction(u32); u8 GetWalkInPlaceSlowMovementAction(u32); u8 GetCollisionAtCoords(struct ObjectEvent *, s16, s16, u32); +u8 GetCollisionInDirection(struct ObjectEvent *objectEvent, u8 direction); void MoveCoords(u8, s16 *, s16 *); bool8 ObjectEventIsHeldMovementActive(struct ObjectEvent *); u8 ObjectEventClearHeldMovementIfFinished(struct ObjectEvent *); @@ -205,6 +207,8 @@ void CameraObjectReset2(void); u8 GetObjectEventBerryTreeId(u8 objectEventId); void SetBerryTreeJustPicked(u8 mapId, u8 mapNumber, u8 mapGroup); bool8 IsBerryTreeSparkling(u8, u8, u8); +struct ObjectEventTemplate *GetObjectEventTemplateByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup); +u8 TrySpawnObjectEventTemplate(struct ObjectEventTemplate *objectEventTemplate, u8 mapNum, u8 mapGroup, s16 cameraX, s16 cameraY); void MovementType_None(struct Sprite *); void MovementType_LookAround(struct Sprite *); @@ -422,21 +426,23 @@ u8 MovementType_RunInPlace_Step0(struct ObjectEvent *, struct Sprite *); u8 MovementType_Invisible_Step0(struct ObjectEvent *, struct Sprite *); u8 MovementType_Invisible_Step1(struct ObjectEvent *, struct Sprite *); u8 MovementType_Invisible_Step2(struct ObjectEvent *, struct Sprite *); + void SetObjectEventSpriteInvisibility(u8 objectEventId, bool32 invisible); bool32 IsObjectEventSpriteInvisible(u8 objectEventId); void SetObjectEventSpriteGraphics(u8 objectEventId, u8 graphicsId); void SetObjectEventSpriteAnim(u8 objectEventId, u8 animNum); bool32 IsObjectEventSpriteAnimating(u8 objectEventId); +// NEW +u16 GetMiniStepCount(u8 speed); +void RunMiniStep(struct Sprite *sprite, u8 speed, u8 currentFrame); +bool8 PlayerIsUnderWaterfall(struct ObjectEvent *objectEvent); + // run slow u8 GetPlayerRunSlowMovementAction(u32); //sideways stairs u8 GetSidewaysStairsToRightDirection(s16, s16, u8); u8 GetSidewaysStairsToLeftDirection(s16, s16, u8); -u8 GetDiagonalRightStairsMovement(u32); -u8 GetDiagonalLeftStairsMovement(u32); -u8 GetDiagonalRightStairsRunningMovement(u32); -u8 GetDiagonalLeftStairsRunningMovement(u32); -extern u8 gSidewaysStairsDirection; +u8 GetSidewaysStairsCollision(struct ObjectEvent *objectEvent, u8 dir, u8 currentBehavior, u8 nextBehavior, u8 collision); #endif //GUARD_EVENT_OBJECT_MOVEMENT_H diff --git a/include/field_player_avatar.h b/include/field_player_avatar.h index f9cdfa838d83..0f53e0b28d62 100644 --- a/include/field_player_avatar.h +++ b/include/field_player_avatar.h @@ -68,9 +68,5 @@ bool32 PlayerIsMovingOnRockStairs(u8 direction); //sideways stairs u8 GetRightSideStairsDirection(u8 direction); u8 GetLeftSideStairsDirection(u8 direction); -void PlayerSidewaysStairsRightSide(u8 direction); -void PlayerSidewaysStairsLeftSide(u8 direction); -void PlayerSidewaysStairsRightSideRunning(u8 direction); -void PlayerSidewaysStairsLeftSideRunning(u8 direction); #endif // GUARD_FIELD_PLAYER_AVATAR_H diff --git a/include/global.fieldmap.h b/include/global.fieldmap.h index a4c486c960cc..234bf9f91439 100644 --- a/include/global.fieldmap.h +++ b/include/global.fieldmap.h @@ -205,7 +205,8 @@ struct ObjectEvent /*0x1D*/ u8 trainerRange_berryTreeId; /*0x1E*/ u8 currentMetatileBehavior; /*0x1F*/ u8 previousMetatileBehavior; - /*0x20*/ u8 previousMovementDirection; + /*0x20*/ u8 previousMovementDirection:4; + u8 directionOverwrite:4; /*0x21*/ u8 directionSequenceIndex; /*0x22*/ u8 playerCopyableMovement; /*size = 0x24*/ diff --git a/include/metatile_behavior.h b/include/metatile_behavior.h index 715f9ef12779..128978cae6ae 100644 --- a/include/metatile_behavior.h +++ b/include/metatile_behavior.h @@ -145,7 +145,6 @@ bool8 MetatileBehavior_IsQuestionnaire(u8); bool8 MetatileBehavior_IsLongGrass_Duplicate(u8); bool8 MetatileBehavior_IsLongGrassSouthEdge(u8); bool8 MetatileBehavior_IsTrainerHillTimer(u8); -bool8 MetatileBehavior_IsRockStairs(u8 metatileBehavior); //sideways stairs bool8 MetatileBehavior_IsSidewaysStairsRightSide(u8); bool8 MetatileBehavior_IsSidewaysStairsLeftSide(u8); diff --git a/src/bike.c b/src/bike.c index a21dcb33e128..1fe5b58b43a3 100644 --- a/src/bike.c +++ b/src/bike.c @@ -142,6 +142,19 @@ static u8 GetMachBikeTransition(u8 *dirTraveling) { // if the dir updated before this function, get the relevent new direction to check later. u8 direction = GetPlayerMovementDirection(); + + // fix direction when moving on sideways stairs + switch (direction) + { + case DIR_SOUTHWEST: + case DIR_NORTHWEST: + direction = DIR_WEST; + break; + case DIR_SOUTHEAST: + case DIR_NORTHEAST: + direction = DIR_EAST; + break; + } // is the player standing still? if (*dirTraveling == 0) @@ -178,7 +191,7 @@ static u8 GetMachBikeTransition(u8 *dirTraveling) // the difference between face direction and turn direction is that one changes direction while the other does the animation of turning as well as changing direction. static void MachBikeTransition_FaceDirection(u8 direction) -{ +{ PlayerFaceDirection(direction); Bike_SetBikeStill(); } @@ -231,41 +244,8 @@ static void MachBikeTransition_TrySpeedUp(u8 direction) PlayerOnBikeCollide(direction); } } - else if (collision == COLLISION_SIDEWAYS_STAIRS_TO_LEFT) - { - #if SLOW_MOVEMENT_ON_STAIRS == TRUE - gPlayerAvatar.bikeFrameCounter = 0; - gPlayerAvatar.bikeSpeed = SPEED_STANDING; - PlayerGoSpeed2(GetLeftSideStairsDirection(direction)); - return; - #else - gPlayerAvatar.bikeFrameCounter = 2; - gPlayerAvatar.bikeSpeed = SPEED_STANDING; - PlayerGoSpeed2(GetLeftSideStairsDirection(direction)); - return; - #endif - - } - else if (collision == COLLISION_SIDEWAYS_STAIRS_TO_RIGHT) - { - #if SLOW_MOVEMENT_ON_STAIRS == TRUE - gPlayerAvatar.bikeFrameCounter = 0; - gPlayerAvatar.bikeSpeed = SPEED_STANDING; - PlayerGoSpeed2(GetRightSideStairsDirection(direction)); - return; - #else - gPlayerAvatar.bikeFrameCounter = 2; - gPlayerAvatar.bikeSpeed = SPEED_STANDING; - PlayerGoSpeed2(GetRightSideStairsDirection(direction)); - return; - #endif - - } else { - if (PlayerIsMovingOnRockStairs(direction)) - gPlayerAvatar.bikeFrameCounter--; - sMachBikeSpeedCallbacks[gPlayerAvatar.bikeFrameCounter](direction); gPlayerAvatar.bikeSpeed = gPlayerAvatar.bikeFrameCounter + (gPlayerAvatar.bikeFrameCounter >> 1); // same as dividing by 2, but compiler is insistent on >> 1 if (gPlayerAvatar.bikeFrameCounter < 2) // do not go faster than the last element in the mach bike array @@ -300,13 +280,6 @@ static void MachBikeTransition_TrySlowDown(u8 direction) } else { - #if SLOW_MOVEMENT_ON_STAIRS == TRUE - if (collision == COLLISION_SIDEWAYS_STAIRS_TO_LEFT) - return PlayerGoSpeed2(GetLeftSideStairsDirection(direction)); - else if (collision == COLLISION_SIDEWAYS_STAIRS_TO_RIGHT) - return PlayerGoSpeed2(GetRightSideStairsDirection(direction)); - #endif - sMachBikeSpeedCallbacks[gPlayerAvatar.bikeFrameCounter](direction); } } @@ -314,13 +287,11 @@ static void MachBikeTransition_TrySlowDown(u8 direction) // the acro bike requires the input handler to be executed before the transition can. static void MovePlayerOnAcroBike(u8 newDirection, u16 newKeys, u16 heldKeys) { - gSidewaysStairsDirection = newDirection; sAcroBikeTransitions[CheckMovementInputAcroBike(&newDirection, newKeys, heldKeys)](newDirection); } static u8 CheckMovementInputAcroBike(u8 *newDirection, u16 newKeys, u16 heldKeys) { - gSidewaysStairsDirection = *newDirection; return sAcroBikeInputHandlers[gPlayerAvatar.acroBikeState](newDirection, newKeys, heldKeys); } @@ -409,7 +380,7 @@ static u8 AcroBikeHandleInputWheelieStanding(u8 *newDirection, u16 newKeys, u16 struct ObjectEvent *playerObjEvent; direction = GetPlayerMovementDirection(); - gSidewaysStairsDirection = direction; + //gSidewaysStairsDirection = direction; playerObjEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; gPlayerAvatar.runningState = NOT_MOVING; @@ -606,15 +577,7 @@ static void AcroBikeTransition_Moving(u8 direction) } else { - if (collision == COLLISION_SIDEWAYS_STAIRS_TO_RIGHT) - return PlayerGoSpeed2(GetRightSideStairsDirection(direction)); - else if (collision == COLLISION_SIDEWAYS_STAIRS_TO_LEFT) - return PlayerGoSpeed2(GetLeftSideStairsDirection(direction)); - - if (PlayerIsMovingOnRockStairs(direction)) - PlayerGoSpeed2(direction); - else - PlayerRideWaterCurrent(direction); + PlayerRideWaterCurrent(direction); } } @@ -683,11 +646,6 @@ static void AcroBikeTransition_WheelieHoppingMoving(u8 direction) else { derp: - if (collision == COLLISION_SIDEWAYS_STAIRS_TO_LEFT) - gSidewaysStairsDirection = GetLeftSideStairsDirection(direction); - else if (collision == COLLISION_SIDEWAYS_STAIRS_TO_RIGHT) - gSidewaysStairsDirection = GetRightSideStairsDirection(direction); - PlayerMovingHoppingWheelie(direction); } } @@ -756,11 +714,6 @@ static void AcroBikeTransition_WheelieMoving(u8 direction) return; } - if (collision == COLLISION_SIDEWAYS_STAIRS_TO_LEFT) - gSidewaysStairsDirection = GetLeftSideStairsDirection(direction); - else if (collision == COLLISION_SIDEWAYS_STAIRS_TO_RIGHT) - gSidewaysStairsDirection = GetRightSideStairsDirection(direction); - PlayerWheelieMove(direction); gPlayerAvatar.runningState = MOVING; } @@ -795,12 +748,7 @@ static void AcroBikeTransition_WheelieRisingMoving(u8 direction) } return; } - - if (collision == COLLISION_SIDEWAYS_STAIRS_TO_LEFT) - gSidewaysStairsDirection = GetLeftSideStairsDirection(direction); - else if (collision == COLLISION_SIDEWAYS_STAIRS_TO_RIGHT) - gSidewaysStairsDirection = GetRightSideStairsDirection(direction); - + PlayerPopWheelieWhileMoving(direction); gPlayerAvatar.runningState = MOVING; } @@ -824,12 +772,7 @@ static void AcroBikeTransition_WheelieLoweringMoving(u8 direction) PlayerEndWheelie(direction); return; } - - if (collision == COLLISION_SIDEWAYS_STAIRS_TO_LEFT) - gSidewaysStairsDirection = GetLeftSideStairsDirection(direction); - else if (collision == COLLISION_SIDEWAYS_STAIRS_TO_RIGHT) - gSidewaysStairsDirection = GetRightSideStairsDirection(direction); - + PlayerEndWheelieWhileMoving(direction); } @@ -1090,7 +1033,7 @@ void Bike_UpdateBikeCounterSpeed(u8 counter) static void Bike_SetBikeStill(void) { - gSidewaysStairsDirection = gObjectEvents[gPlayerAvatar.objectEventId].facingDirection; + //gSidewaysStairsDirection = gObjectEvents[gPlayerAvatar.objectEventId].facingDirection; gPlayerAvatar.bikeFrameCounter = 0; gPlayerAvatar.bikeSpeed = SPEED_STANDING; } diff --git a/src/data/object_events/movement_action_func_tables.h b/src/data/object_events/movement_action_func_tables.h index 30c1fac2aacb..ffc0611a1d1a 100755 --- a/src/data/object_events/movement_action_func_tables.h +++ b/src/data/object_events/movement_action_func_tables.h @@ -267,20 +267,6 @@ u8 MovementActionFunc_RunSlowUp_Step0(struct ObjectEvent *objectEvent, struct Sp u8 MovementActionFunc_RunSlowLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite); u8 MovementActionFunc_RunSlowRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite); u8 MovementActionFunc_RunSlow_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite); -//sideways stairs -u8 MovementAction_WalkStairDiagonalUpLeft_Step0(struct ObjectEvent *, struct Sprite *); -u8 MovementAction_WalkStairDiagonalUpRight_Step0(struct ObjectEvent *, struct Sprite *); -u8 MovementAction_WalkStairDiagonalDownLeft_Step0(struct ObjectEvent *, struct Sprite *); -u8 MovementAction_WalkStairDiagonalDownRight_Step0(struct ObjectEvent *, struct Sprite *); -u8 MovementAction_RunStairDiagonalUpLeft_Step0(struct ObjectEvent *, struct Sprite *); -u8 MovementAction_RunStairDiagonalUpRight_Step0(struct ObjectEvent *, struct Sprite *); -u8 MovementAction_RunStairDiagonalDownLeft_Step0(struct ObjectEvent *, struct Sprite *); -u8 MovementAction_RunStairDiagonalDownRight_Step0(struct ObjectEvent *, struct Sprite *); -u8 MovementAction_RunStairDiagonal_Step1(struct ObjectEvent *, struct Sprite *); -u8 MovementAction_AcroBikeDiagonalUpLeft_Step0(struct ObjectEvent *, struct Sprite *); -u8 MovementAction_AcroBikeDiagonalDownLeft_Step0(struct ObjectEvent *, struct Sprite *); -u8 MovementAction_AcroBikeDiagonalUpRight_Step0(struct ObjectEvent *, struct Sprite *); -u8 MovementAction_AcroBikeDiagonalDownRight_Step0(struct ObjectEvent *, struct Sprite *); u8 (*const gMovementActionFuncs_FaceDown[])(struct ObjectEvent *, struct Sprite *); u8 (*const gMovementActionFuncs_FaceUp[])(struct ObjectEvent *, struct Sprite *); @@ -445,19 +431,6 @@ u8 (*const gMovementActionFuncs_RunDownSlow[])(struct ObjectEvent *, struct Spri u8 (*const gMovementActionFuncs_RunUpSlow[])(struct ObjectEvent *, struct Sprite *); u8 (*const gMovementActionFuncs_RunLeftSlow[])(struct ObjectEvent *, struct Sprite *); u8 (*const gMovementActionFuncs_RunRightSlow[])(struct ObjectEvent *, struct Sprite *); -//sideways stairs -u8 (*const gMovementActionFuncs_WalkStairDiagonalUpLeft[])(struct ObjectEvent *, struct Sprite *); -u8 (*const gMovementActionFuncs_WalkStairDiagonalUpRight[])(struct ObjectEvent *, struct Sprite *); -u8 (*const gMovementActionFuncs_WalkStairDiagonalDownLeft[])(struct ObjectEvent *, struct Sprite *); -u8 (*const gMovementActionFuncs_WalkStairDiagonalDownRight[])(struct ObjectEvent *, struct Sprite *); -u8 (*const gMovementActionFuncs_RunStairDiagonalUpLeft[])(struct ObjectEvent *, struct Sprite *); -u8 (*const gMovementActionFuncs_RunStairDiagonalUpRight[])(struct ObjectEvent *, struct Sprite *); -u8 (*const gMovementActionFuncs_RunStairDiagonalDownLeft[])(struct ObjectEvent *, struct Sprite *); -u8 (*const gMovementActionFuncs_RunStairDiagonalDownRight[])(struct ObjectEvent *, struct Sprite *); -u8 (*const gMovementActionFuncs_AcroBikeDiagonalUpLeft[])(struct ObjectEvent *, struct Sprite *); -u8 (*const gMovementActionFuncs_AcroBikeDiagonalDownLeft[])(struct ObjectEvent *, struct Sprite *); -u8 (*const gMovementActionFuncs_AcroBikeDiagonalUpRight[])(struct ObjectEvent *, struct Sprite *); -u8 (*const gMovementActionFuncs_AcroBikeDiagonalDownRight[])(struct ObjectEvent *, struct Sprite *); u8 (*const *const gMovementActionFuncs[])(struct ObjectEvent *, struct Sprite *) = { [MOVEMENT_ACTION_FACE_DOWN] = gMovementActionFuncs_FaceDown, @@ -623,19 +596,6 @@ u8 (*const *const gMovementActionFuncs[])(struct ObjectEvent *, struct Sprite *) [MOVEMENT_ACTION_RUN_UP_SLOW] = gMovementActionFuncs_RunUpSlow, [MOVEMENT_ACTION_RUN_LEFT_SLOW] = gMovementActionFuncs_RunLeftSlow, [MOVEMENT_ACTION_RUN_RIGHT_SLOW] = gMovementActionFuncs_RunRightSlow, - //sideways stairs - [MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_UP_LEFT] = gMovementActionFuncs_WalkStairDiagonalUpLeft, - [MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_UP_RIGHT] = gMovementActionFuncs_WalkStairDiagonalUpRight, - [MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_DOWN_LEFT] = gMovementActionFuncs_WalkStairDiagonalDownLeft, - [MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_DOWN_RIGHT] = gMovementActionFuncs_WalkStairDiagonalDownRight, - [MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_UP_LEFT_RUNNING] = gMovementActionFuncs_RunStairDiagonalUpLeft, - [MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_UP_RIGHT_RUNNING] = gMovementActionFuncs_RunStairDiagonalUpRight, - [MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_DOWN_LEFT_RUNNING] = gMovementActionFuncs_RunStairDiagonalDownLeft, - [MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_DOWN_RIGHT_RUNNING] = gMovementActionFuncs_RunStairDiagonalDownRight, - [MOVEMENT_ACTION_RIDE_WATER_CURRENT_UP_LEFT] = gMovementActionFuncs_AcroBikeDiagonalUpLeft, - [MOVEMENT_ACTION_RIDE_WATER_CURRENT_UP_RIGHT] = gMovementActionFuncs_AcroBikeDiagonalUpRight, - [MOVEMENT_ACTION_RIDE_WATER_CURRENT_DOWN_LEFT] = gMovementActionFuncs_AcroBikeDiagonalDownLeft, - [MOVEMENT_ACTION_RIDE_WATER_CURRENT_DOWN_RIGHT] = gMovementActionFuncs_AcroBikeDiagonalDownRight, }; u8 (*const gMovementActionFuncs_FaceDown[])(struct ObjectEvent *, struct Sprite *) = { @@ -1593,93 +1553,3 @@ u8 (*const gMovementActionFuncs_RunRightSlow[])(struct ObjectEvent *, struct Spr MovementAction_PauseSpriteAnim, }; -//sideways stairs -u8 (*const gMovementActionFuncs_WalkStairDiagonalUpLeft[])(struct ObjectEvent *, struct Sprite *) = { - MovementAction_WalkStairDiagonalUpLeft_Step0, - #if SLOW_MOVEMENT_ON_STAIRS == TRUE - MovementAction_WalkSlowDiagonalUpLeft_Step1, - #else - MovementAction_WalkNormalDiagonalUpLeft_Step1, - #endif - MovementAction_PauseSpriteAnim, -}; - -u8 (*const gMovementActionFuncs_WalkStairDiagonalUpRight[])(struct ObjectEvent *, struct Sprite *) = { - MovementAction_WalkStairDiagonalUpRight_Step0, - #if SLOW_MOVEMENT_ON_STAIRS == TRUE - MovementAction_WalkSlowDiagonalUpRight_Step1, - #else - MovementAction_WalkNormalDiagonalUpRight_Step1, - #endif - MovementAction_PauseSpriteAnim, -}; - -u8 (*const gMovementActionFuncs_WalkStairDiagonalDownLeft[])(struct ObjectEvent *, struct Sprite *) = { - MovementAction_WalkStairDiagonalDownLeft_Step0, - #if SLOW_MOVEMENT_ON_STAIRS == TRUE - MovementAction_WalkSlowDiagonalDownLeft_Step1, - #else - MovementAction_WalkNormalDiagonalDownLeft_Step1, - #endif - MovementAction_PauseSpriteAnim, -}; - -u8 (*const gMovementActionFuncs_WalkStairDiagonalDownRight[])(struct ObjectEvent *, struct Sprite *) = { - MovementAction_WalkStairDiagonalDownRight_Step0, - #if SLOW_MOVEMENT_ON_STAIRS == TRUE - MovementAction_WalkSlowDiagonalDownRight_Step1, - #else - MovementAction_WalkNormalDiagonalDownRight_Step1, - #endif - MovementAction_PauseSpriteAnim, -}; - -u8 (*const gMovementActionFuncs_RunStairDiagonalUpLeft[])(struct ObjectEvent *, struct Sprite *) = { - MovementAction_RunStairDiagonalUpLeft_Step0, - MovementAction_RunStairDiagonal_Step1, - MovementAction_PauseSpriteAnim, -}; - -u8 (*const gMovementActionFuncs_RunStairDiagonalUpRight[])(struct ObjectEvent *, struct Sprite *) = { - MovementAction_RunStairDiagonalUpRight_Step0, - MovementAction_RunStairDiagonal_Step1, - MovementAction_PauseSpriteAnim, -}; - -u8 (*const gMovementActionFuncs_RunStairDiagonalDownLeft[])(struct ObjectEvent *, struct Sprite *) = { - MovementAction_RunStairDiagonalDownLeft_Step0, - MovementAction_RunStairDiagonal_Step1, - MovementAction_PauseSpriteAnim, -}; - -u8 (*const gMovementActionFuncs_RunStairDiagonalDownRight[])(struct ObjectEvent *, struct Sprite *) = { - MovementAction_RunStairDiagonalDownRight_Step0, - MovementAction_RunStairDiagonal_Step1, - MovementAction_PauseSpriteAnim, -}; - -u8 (*const gMovementActionFuncs_AcroBikeDiagonalUpLeft[])(struct ObjectEvent *, struct Sprite *) = { - MovementAction_AcroBikeDiagonalUpLeft_Step0, - MovementAction_RideWaterCurrentLeft_Step1, - MovementAction_PauseSpriteAnim, -}; - -u8 (*const gMovementActionFuncs_AcroBikeDiagonalDownLeft[])(struct ObjectEvent *, struct Sprite *) = { - MovementAction_AcroBikeDiagonalDownLeft_Step0, - MovementAction_RideWaterCurrentLeft_Step1, - MovementAction_PauseSpriteAnim, -}; - -u8 (*const gMovementActionFuncs_AcroBikeDiagonalUpRight[])(struct ObjectEvent *, struct Sprite *) = { - MovementAction_AcroBikeDiagonalUpRight_Step0, - MovementAction_RideWaterCurrentRight_Step1, - MovementAction_PauseSpriteAnim, -}; - -u8 (*const gMovementActionFuncs_AcroBikeDiagonalDownRight[])(struct ObjectEvent *, struct Sprite *) = { - MovementAction_AcroBikeDiagonalDownRight_Step0, - MovementAction_RideWaterCurrentRight_Step1, - MovementAction_PauseSpriteAnim, -}; - - diff --git a/src/event_object_movement.c b/src/event_object_movement.c index 9e02edfef498..ebfc902ca31a 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -22,11 +22,13 @@ #include "trainer_see.h" #include "trainer_hill.h" #include "util.h" +#include "follow_me.h" #include "constants/event_object_movement.h" #include "constants/event_objects.h" #include "constants/field_effects.h" #include "constants/items.h" #include "constants/mauville_old_man.h" +#include "constants/metatile_behaviors.h" #include "constants/trainer_types.h" #include "constants/union_room.h" @@ -57,13 +59,11 @@ static u8 setup##_callback(struct ObjectEvent *objectEvent, struct Sprite *sprit EWRAM_DATA u8 sCurrentReflectionType = 0; EWRAM_DATA u16 sCurrentSpecialObjectPaletteTag = 0; EWRAM_DATA struct LockedAnimObjectEvents *gLockedAnimObjectEvents = {0}; -EWRAM_DATA u8 gSidewaysStairsDirection = 0; static void MoveCoordsInDirection(u32, s16 *, s16 *, s16, s16); static bool8 ObjectEventExecSingleMovementAction(struct ObjectEvent *, struct Sprite *); static void SetMovementDelay(struct Sprite *, s16); static bool8 WaitForMovementDelay(struct Sprite *); -static u8 GetCollisionInDirection(struct ObjectEvent *, u8); static u32 state_to_direction(u8, u32, u32); static void TryEnableObjectEventAnim(struct ObjectEvent *, struct Sprite *); static void ObjectEventExecHeldMovementAction(struct ObjectEvent *, struct Sprite *); @@ -113,7 +113,7 @@ static u16 GetObjectEventFlagIdByObjectEventId(u8); static void UpdateObjectEventVisibility(struct ObjectEvent *, struct Sprite *); static void MakeObjectTemplateFromObjectEventTemplate(struct ObjectEventTemplate *, struct SpriteTemplate *, const struct SubspriteTable **); static void GetObjectEventMovingCameraOffset(s16 *, s16 *); -static struct ObjectEventTemplate *GetObjectEventTemplateByLocalIdAndMap(u8, u8, u8); +//static struct ObjectEventTemplate *GetObjectEventTemplateByLocalIdAndMap(u8, u8, u8); static void LoadObjectEventPalette(u16); static void RemoveObjectEventIfOutsideView(struct ObjectEvent *); static void sub_808E1B8(u8, s16, s16); @@ -135,6 +135,9 @@ static void InitSpriteForFigure8Anim(struct Sprite *sprite); static bool8 AnimateSpriteInFigure8(struct Sprite *sprite); static void UpdateObjectEventSprite(struct Sprite *); +static void StartSlowRunningAnim(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 direction); +static bool8 npc_obj_ministep_stop_on_arrival_slow(struct ObjectEvent *objectEvent, struct Sprite *sprite); + const u8 gReflectionEffectPaletteMap[] = {1, 1, 6, 7, 8, 9, 6, 7, 8, 9, 11, 11, 0, 0, 0, 0}; const struct SpriteTemplate gCameraSpriteTemplate = {0, 0xFFFF, &gDummyOamData, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, ObjectCB_CameraObject}; @@ -693,10 +696,10 @@ const u8 gMoveDirectionAnimNums[] = { [DIR_NORTH] = 5, [DIR_WEST] = 6, [DIR_EAST] = 7, - [DIR_SOUTHWEST] = 4, - [DIR_SOUTHEAST] = 4, - [DIR_NORTHWEST] = 5, - [DIR_NORTHEAST] = 5, + [DIR_SOUTHWEST] = 6, + [DIR_SOUTHEAST] = 7, + [DIR_NORTHWEST] = 6, + [DIR_NORTHEAST] = 7, }; const u8 gMoveDirectionFastAnimNums[] = { [DIR_NONE] = 8, @@ -704,10 +707,10 @@ const u8 gMoveDirectionFastAnimNums[] = { [DIR_NORTH] = 9, [DIR_WEST] = 10, [DIR_EAST] = 11, - [DIR_SOUTHWEST] = 8, - [DIR_SOUTHEAST] = 8, - [DIR_NORTHWEST] = 9, - [DIR_NORTHEAST] = 9, + [DIR_SOUTHWEST] = 10, + [DIR_SOUTHEAST] = 11, + [DIR_NORTHWEST] = 10, + [DIR_NORTHEAST] = 11, }; const u8 gMoveDirectionFasterAnimNums[] = { [DIR_NONE] = 12, @@ -715,10 +718,10 @@ const u8 gMoveDirectionFasterAnimNums[] = { [DIR_NORTH] = 13, [DIR_WEST] = 14, [DIR_EAST] = 15, - [DIR_SOUTHWEST] = 12, - [DIR_SOUTHEAST] = 12, - [DIR_NORTHWEST] = 13, - [DIR_NORTHEAST] = 13, + [DIR_SOUTHWEST] = 14, + [DIR_SOUTHEAST] = 15, + [DIR_NORTHWEST] = 14, + [DIR_NORTHEAST] = 15, }; const u8 gMoveDirectionFastestAnimNums[] = { [DIR_NONE] = 16, @@ -726,10 +729,10 @@ const u8 gMoveDirectionFastestAnimNums[] = { [DIR_NORTH] = 17, [DIR_WEST] = 18, [DIR_EAST] = 19, - [DIR_SOUTHWEST] = 16, - [DIR_SOUTHEAST] = 16, - [DIR_NORTHWEST] = 17, - [DIR_NORTHEAST] = 17, + [DIR_SOUTHWEST] = 18, + [DIR_SOUTHEAST] = 19, + [DIR_NORTHWEST] = 18, + [DIR_NORTHEAST] = 19, }; const u8 gJumpSpecialDirectionAnimNums[] = { // used for jumping onto surf mon [DIR_NONE] = 20, @@ -831,18 +834,6 @@ const u8 gFishingBiteDirectionAnimNums[] = { [DIR_NORTHEAST] = 9, }; const u8 gRunningDirectionAnimNums[] = { - [DIR_NONE] = 20, - [DIR_SOUTH] = 20, - [DIR_NORTH] = 21, - [DIR_WEST] = 22, - [DIR_EAST] = 23, - [DIR_SOUTHWEST] = 20, - [DIR_SOUTHEAST] = 20, - [DIR_NORTHWEST] = 21, - [DIR_NORTHEAST] = 21, -}; - -const u8 gStairsRunningDirectionAnimNums[] = { [DIR_NONE] = 20, [DIR_SOUTH] = 20, [DIR_NORTH] = 21, @@ -913,10 +904,6 @@ const u8 gWalkSlowMovementActions[] = { [DIR_NORTH] = MOVEMENT_ACTION_WALK_SLOW_UP, [DIR_WEST] = MOVEMENT_ACTION_WALK_SLOW_LEFT, [DIR_EAST] = MOVEMENT_ACTION_WALK_SLOW_RIGHT, - [DIR_SOUTHWEST] = MOVEMENT_ACTION_WALK_SLOW_DIAGONAL_DOWN_LEFT, - [DIR_SOUTHEAST] = MOVEMENT_ACTION_WALK_SLOW_DIAGONAL_DOWN_RIGHT, - [DIR_NORTHWEST] = MOVEMENT_ACTION_WALK_SLOW_DIAGONAL_UP_LEFT, - [DIR_NORTHEAST] = MOVEMENT_ACTION_WALK_SLOW_DIAGONAL_UP_RIGHT }; const u8 gWalkNormalMovementActions[] = { [DIR_NONE] = MOVEMENT_ACTION_WALK_NORMAL_DOWN, @@ -924,10 +911,6 @@ const u8 gWalkNormalMovementActions[] = { [DIR_NORTH] = MOVEMENT_ACTION_WALK_NORMAL_UP, [DIR_WEST] = MOVEMENT_ACTION_WALK_NORMAL_LEFT, [DIR_EAST] = MOVEMENT_ACTION_WALK_NORMAL_RIGHT, - [DIR_SOUTHWEST] = MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_DOWN_LEFT, - [DIR_SOUTHEAST] = MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_DOWN_RIGHT, - [DIR_NORTHWEST] = MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_UP_LEFT, - [DIR_NORTHEAST] = MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_UP_RIGHT }; const u8 gWalkFastMovementActions[] = { [DIR_NONE] = MOVEMENT_ACTION_WALK_FAST_DOWN, @@ -935,10 +918,6 @@ const u8 gWalkFastMovementActions[] = { [DIR_NORTH] = MOVEMENT_ACTION_WALK_FAST_UP, [DIR_WEST] = MOVEMENT_ACTION_WALK_FAST_LEFT, [DIR_EAST] = MOVEMENT_ACTION_WALK_FAST_RIGHT, - [DIR_SOUTHWEST] = MOVEMENT_ACTION_RIDE_WATER_CURRENT_DOWN_LEFT, - [DIR_SOUTHEAST] = MOVEMENT_ACTION_RIDE_WATER_CURRENT_DOWN_RIGHT, - [DIR_NORTHWEST] = MOVEMENT_ACTION_RIDE_WATER_CURRENT_UP_LEFT, - [DIR_NORTHEAST] = MOVEMENT_ACTION_RIDE_WATER_CURRENT_UP_RIGHT, }; const u8 gRideWaterCurrentMovementActions[] = { [DIR_NONE] = MOVEMENT_ACTION_RIDE_WATER_CURRENT_DOWN, @@ -946,10 +925,6 @@ const u8 gRideWaterCurrentMovementActions[] = { [DIR_NORTH] = MOVEMENT_ACTION_RIDE_WATER_CURRENT_UP, [DIR_WEST] = MOVEMENT_ACTION_RIDE_WATER_CURRENT_LEFT, [DIR_EAST] = MOVEMENT_ACTION_RIDE_WATER_CURRENT_RIGHT, - [DIR_SOUTHWEST] = MOVEMENT_ACTION_RIDE_WATER_CURRENT_DOWN_LEFT, - [DIR_SOUTHEAST] = MOVEMENT_ACTION_RIDE_WATER_CURRENT_DOWN_RIGHT, - [DIR_NORTHWEST] = MOVEMENT_ACTION_RIDE_WATER_CURRENT_UP_LEFT, - [DIR_NORTHEAST] = MOVEMENT_ACTION_RIDE_WATER_CURRENT_UP_RIGHT }; const u8 gWalkFastestMovementActions[] = { [DIR_NONE] = MOVEMENT_ACTION_WALK_FASTEST_DOWN, @@ -957,24 +932,20 @@ const u8 gWalkFastestMovementActions[] = { [DIR_NORTH] = MOVEMENT_ACTION_WALK_FASTEST_UP, [DIR_WEST] = MOVEMENT_ACTION_WALK_FASTEST_LEFT, [DIR_EAST] = MOVEMENT_ACTION_WALK_FASTEST_RIGHT, - [DIR_SOUTHWEST] = MOVEMENT_ACTION_RIDE_WATER_CURRENT_DOWN_LEFT, - [DIR_SOUTHEAST] = MOVEMENT_ACTION_RIDE_WATER_CURRENT_DOWN_RIGHT, - [DIR_NORTHWEST] = MOVEMENT_ACTION_RIDE_WATER_CURRENT_UP_LEFT, - [DIR_NORTHEAST] = MOVEMENT_ACTION_RIDE_WATER_CURRENT_UP_RIGHT }; const u8 gSlideMovementActions[] = { - MOVEMENT_ACTION_SLIDE_DOWN, - MOVEMENT_ACTION_SLIDE_DOWN, - MOVEMENT_ACTION_SLIDE_UP, - MOVEMENT_ACTION_SLIDE_LEFT, - MOVEMENT_ACTION_SLIDE_RIGHT, + [DIR_NONE] = MOVEMENT_ACTION_SLIDE_DOWN, + [DIR_SOUTH] = MOVEMENT_ACTION_SLIDE_DOWN, + [DIR_NORTH] = MOVEMENT_ACTION_SLIDE_UP, + [DIR_WEST] = MOVEMENT_ACTION_SLIDE_LEFT, + [DIR_EAST] = MOVEMENT_ACTION_SLIDE_RIGHT, }; const u8 gPlayerRunMovementActions[] = { - MOVEMENT_ACTION_PLAYER_RUN_DOWN, - MOVEMENT_ACTION_PLAYER_RUN_DOWN, - MOVEMENT_ACTION_PLAYER_RUN_UP, - MOVEMENT_ACTION_PLAYER_RUN_LEFT, - MOVEMENT_ACTION_PLAYER_RUN_RIGHT, + [DIR_NONE] = MOVEMENT_ACTION_PLAYER_RUN_DOWN, + [DIR_SOUTH] = MOVEMENT_ACTION_PLAYER_RUN_DOWN, + [DIR_NORTH] = MOVEMENT_ACTION_PLAYER_RUN_UP, + [DIR_WEST] = MOVEMENT_ACTION_PLAYER_RUN_LEFT, + [DIR_EAST] = MOVEMENT_ACTION_PLAYER_RUN_RIGHT, }; const u8 gJump2MovementActions[] = { MOVEMENT_ACTION_JUMP_2_DOWN, @@ -1012,32 +983,48 @@ const u8 gJumpSpecialMovementActions[] = { MOVEMENT_ACTION_JUMP_SPECIAL_RIGHT, }; const u8 gWalkInPlaceSlowMovementActions[] = { - MOVEMENT_ACTION_WALK_IN_PLACE_SLOW_DOWN, - MOVEMENT_ACTION_WALK_IN_PLACE_SLOW_DOWN, - MOVEMENT_ACTION_WALK_IN_PLACE_SLOW_UP, - MOVEMENT_ACTION_WALK_IN_PLACE_SLOW_LEFT, - MOVEMENT_ACTION_WALK_IN_PLACE_SLOW_RIGHT, + [DIR_NONE] = MOVEMENT_ACTION_WALK_IN_PLACE_SLOW_DOWN, + [DIR_SOUTH] = MOVEMENT_ACTION_WALK_IN_PLACE_SLOW_DOWN, + [DIR_NORTH] = MOVEMENT_ACTION_WALK_IN_PLACE_SLOW_UP, + [DIR_WEST] = MOVEMENT_ACTION_WALK_IN_PLACE_SLOW_LEFT, + [DIR_EAST] = MOVEMENT_ACTION_WALK_IN_PLACE_SLOW_RIGHT, + [DIR_SOUTHWEST] = MOVEMENT_ACTION_WALK_IN_PLACE_SLOW_LEFT, + [DIR_NORTHWEST] = MOVEMENT_ACTION_WALK_IN_PLACE_SLOW_LEFT, + [DIR_NORTHEAST] = MOVEMENT_ACTION_WALK_IN_PLACE_SLOW_RIGHT, + [DIR_SOUTHEAST] = MOVEMENT_ACTION_WALK_IN_PLACE_SLOW_RIGHT }; const u8 gWalkInPlaceNormalMovementActions[] = { - MOVEMENT_ACTION_WALK_IN_PLACE_NORMAL_DOWN, - MOVEMENT_ACTION_WALK_IN_PLACE_NORMAL_DOWN, - MOVEMENT_ACTION_WALK_IN_PLACE_NORMAL_UP, - MOVEMENT_ACTION_WALK_IN_PLACE_NORMAL_LEFT, - MOVEMENT_ACTION_WALK_IN_PLACE_NORMAL_RIGHT, + [DIR_NONE] = MOVEMENT_ACTION_WALK_IN_PLACE_NORMAL_DOWN, + [DIR_SOUTH] = MOVEMENT_ACTION_WALK_IN_PLACE_NORMAL_DOWN, + [DIR_NORTH] = MOVEMENT_ACTION_WALK_IN_PLACE_NORMAL_UP, + [DIR_WEST] = MOVEMENT_ACTION_WALK_IN_PLACE_NORMAL_LEFT, + [DIR_EAST] = MOVEMENT_ACTION_WALK_IN_PLACE_NORMAL_RIGHT, + [DIR_SOUTHWEST] = MOVEMENT_ACTION_WALK_IN_PLACE_NORMAL_LEFT, + [DIR_NORTHWEST] = MOVEMENT_ACTION_WALK_IN_PLACE_NORMAL_LEFT, + [DIR_NORTHEAST] = MOVEMENT_ACTION_WALK_IN_PLACE_NORMAL_RIGHT, + [DIR_SOUTHEAST] = MOVEMENT_ACTION_WALK_IN_PLACE_NORMAL_RIGHT }; const u8 gWalkInPlaceFastMovementActions[] = { - MOVEMENT_ACTION_WALK_IN_PLACE_FAST_DOWN, - MOVEMENT_ACTION_WALK_IN_PLACE_FAST_DOWN, - MOVEMENT_ACTION_WALK_IN_PLACE_FAST_UP, - MOVEMENT_ACTION_WALK_IN_PLACE_FAST_LEFT, - MOVEMENT_ACTION_WALK_IN_PLACE_FAST_RIGHT, + [DIR_NONE] = MOVEMENT_ACTION_WALK_IN_PLACE_FAST_DOWN, + [DIR_SOUTH] = MOVEMENT_ACTION_WALK_IN_PLACE_FAST_DOWN, + [DIR_NORTH] = MOVEMENT_ACTION_WALK_IN_PLACE_FAST_UP, + [DIR_WEST] = MOVEMENT_ACTION_WALK_IN_PLACE_FAST_LEFT, + [DIR_EAST] = MOVEMENT_ACTION_WALK_IN_PLACE_FAST_RIGHT, + [DIR_SOUTHWEST] = MOVEMENT_ACTION_WALK_IN_PLACE_FAST_LEFT, + [DIR_NORTHWEST] = MOVEMENT_ACTION_WALK_IN_PLACE_FAST_LEFT, + [DIR_NORTHEAST] = MOVEMENT_ACTION_WALK_IN_PLACE_FAST_RIGHT, + [DIR_SOUTHEAST] = MOVEMENT_ACTION_WALK_IN_PLACE_FAST_RIGHT }; const u8 gWalkInPlaceFastestMovementActions[] = { - MOVEMENT_ACTION_WALK_IN_PLACE_FASTEST_DOWN, - MOVEMENT_ACTION_WALK_IN_PLACE_FASTEST_DOWN, - MOVEMENT_ACTION_WALK_IN_PLACE_FASTEST_UP, - MOVEMENT_ACTION_WALK_IN_PLACE_FASTEST_LEFT, - MOVEMENT_ACTION_WALK_IN_PLACE_FASTEST_RIGHT, + [DIR_NONE] = MOVEMENT_ACTION_WALK_IN_PLACE_FASTEST_DOWN, + [DIR_SOUTH] = MOVEMENT_ACTION_WALK_IN_PLACE_FASTEST_DOWN, + [DIR_NORTH] = MOVEMENT_ACTION_WALK_IN_PLACE_FASTEST_UP, + [DIR_WEST] = MOVEMENT_ACTION_WALK_IN_PLACE_FASTEST_LEFT, + [DIR_EAST] = MOVEMENT_ACTION_WALK_IN_PLACE_FASTEST_RIGHT, + [DIR_SOUTHWEST] = MOVEMENT_ACTION_WALK_IN_PLACE_FASTEST_LEFT, + [DIR_NORTHWEST] = MOVEMENT_ACTION_WALK_IN_PLACE_FASTEST_LEFT, + [DIR_NORTHEAST] = MOVEMENT_ACTION_WALK_IN_PLACE_FASTEST_RIGHT, + [DIR_SOUTHEAST] = MOVEMENT_ACTION_WALK_IN_PLACE_FASTEST_RIGHT }; const u8 gAcroWheelieFaceDirectionMovementActions[] = { [DIR_NONE] = MOVEMENT_ACTION_ACRO_WHEELIE_FACE_DOWN, @@ -1158,36 +1145,6 @@ const u8 gRunSlowMovementActions[] = { [DIR_EAST] = MOVEMENT_ACTION_RUN_RIGHT_SLOW, }; -// sideways stairs -const u8 gDiagonalStairLeftSideMovementActions[] = { //movement actions for stairs on left side of a wall (southwest and northeast) - [DIR_NONE] = MOVEMENT_ACTION_WALK_NORMAL_DOWN, - [DIR_SOUTH] = MOVEMENT_ACTION_WALK_NORMAL_DOWN, - [DIR_NORTH] = MOVEMENT_ACTION_WALK_NORMAL_UP, - [DIR_WEST] = MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_DOWN_LEFT, - [DIR_EAST] = MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_UP_RIGHT, -}; -const u8 gDiagonalStairRightSideMovementActions[] = { //movement actions for stairs on right side of a wall (southeast and northwest) - [DIR_NONE] = MOVEMENT_ACTION_WALK_NORMAL_DOWN, - [DIR_SOUTH] = MOVEMENT_ACTION_WALK_NORMAL_DOWN, - [DIR_NORTH] = MOVEMENT_ACTION_WALK_NORMAL_UP, - [DIR_WEST] = MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_UP_LEFT, - [DIR_EAST] = MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_DOWN_RIGHT, -}; -const u8 gDiagonalStairRightSideRunningMovementActions[] = { - [DIR_NONE] = MOVEMENT_ACTION_PLAYER_RUN_DOWN, - [DIR_SOUTH] = MOVEMENT_ACTION_PLAYER_RUN_DOWN, - [DIR_NORTH] = MOVEMENT_ACTION_PLAYER_RUN_UP, - [DIR_WEST] = MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_UP_LEFT_RUNNING, - [DIR_EAST] = MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_DOWN_RIGHT_RUNNING, -}; -const u8 gDiagonalStairLeftSideRunningMovementActions[] = { - [DIR_NONE] = MOVEMENT_ACTION_PLAYER_RUN_DOWN, - [DIR_SOUTH] = MOVEMENT_ACTION_PLAYER_RUN_DOWN, - [DIR_NORTH] = MOVEMENT_ACTION_PLAYER_RUN_UP, - [DIR_WEST] = MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_DOWN_LEFT_RUNNING, - [DIR_EAST] = MOVEMENT_ACTION_WALK_STAIRS_DIAGONAL_UP_RIGHT_RUNNING, -}; - const u8 gOppositeDirections[] = { DIR_NORTH, DIR_SOUTH, @@ -1271,10 +1228,11 @@ u8 GetFirstInactiveObjectEventId(void) u8 GetObjectEventIdByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroupId) { - if (localId < OBJ_EVENT_ID_PLAYER) - { + if (localId == 0xFE) + return GetFollowerObjectId(); + else if (localId < OBJ_EVENT_ID_PLAYER) return GetObjectEventIdByLocalIdAndMapInternal(localId, mapNum, mapGroupId); - } + return GetObjectEventIdByLocalId(localId); } @@ -1430,7 +1388,7 @@ static bool8 GetAvailableObjectEventId(u16 localId, u8 mapNum, u8 mapGroup, u8 * return FALSE; } -static void RemoveObjectEvent(struct ObjectEvent *objectEvent) +void RemoveObjectEvent(struct ObjectEvent *objectEvent) { objectEvent->active = FALSE; RemoveObjectEventInternal(objectEvent); @@ -1525,7 +1483,7 @@ static u8 TrySetupObjectEventSprite(struct ObjectEventTemplate *objectEventTempl return objectEventId; } -static u8 TrySpawnObjectEventTemplate(struct ObjectEventTemplate *objectEventTemplate, u8 mapNum, u8 mapGroup, s16 cameraX, s16 cameraY) +u8 TrySpawnObjectEventTemplate(struct ObjectEventTemplate *objectEventTemplate, u8 mapNum, u8 mapGroup, s16 cameraX, s16 cameraY) { u8 objectEventId; struct SpriteTemplate spriteTemplate; @@ -2457,7 +2415,10 @@ void SetObjectEventDirection(struct ObjectEvent *objectEvent, u8 direction) static const u8 *GetObjectEventScriptPointerByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup) { - return GetObjectEventTemplateByLocalIdAndMap(localId, mapNum, mapGroup)->script; + if (GetFollowerLocalId() == 0 || GetFollowerLocalId() != localId) + return GetObjectEventTemplateByLocalIdAndMap(localId, mapNum, mapGroup)->script; + else + return GetFollowerScriptPointer(); } const u8 *GetObjectEventScriptPointerByObjectEventId(u8 objectEventId) @@ -2516,7 +2477,7 @@ u8 GetObjectEventBerryTreeId(u8 objectEventId) return gObjectEvents[objectEventId].trainerRange_berryTreeId; } -static struct ObjectEventTemplate *GetObjectEventTemplateByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup) +struct ObjectEventTemplate *GetObjectEventTemplateByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup) { struct ObjectEventTemplate *templates; const struct MapHeader *mapHeader; @@ -4860,7 +4821,7 @@ u8 GetTrainerFacingDirectionMovementType(u8 direction) return gTrainerFacingDirectionMovementTypes[direction]; } -static u8 GetCollisionInDirection(struct ObjectEvent *objectEvent, u8 direction) +u8 GetCollisionInDirection(struct ObjectEvent *objectEvent, u8 direction) { s16 x; s16 y; @@ -4870,11 +4831,101 @@ static u8 GetCollisionInDirection(struct ObjectEvent *objectEvent, u8 direction) return GetCollisionAtCoords(objectEvent, x, y, direction); } +u8 GetSidewaysStairsCollision(struct ObjectEvent *objectEvent, u8 dir, u8 currentBehavior, u8 nextBehavior, u8 collision) +{ + if ((dir == DIR_SOUTH || dir == DIR_NORTH) && collision != COLLISION_NONE) + return collision; + + if (MetatileBehavior_IsSidewaysStairsLeftSide(nextBehavior)) + { + //moving ONTO left side stair + if (dir == DIR_WEST && currentBehavior != nextBehavior) + return collision; //moving onto top part of left-stair going left, so no diagonal + else + return COLLISION_SIDEWAYS_STAIRS_TO_LEFT; // move diagonally + } + else if (MetatileBehavior_IsSidewaysStairsRightSide(nextBehavior)) + { + //moving ONTO right side stair + if (dir == DIR_EAST && currentBehavior != nextBehavior) + return collision; //moving onto top part of right-stair going right, so no diagonal + else + return COLLISION_SIDEWAYS_STAIRS_TO_RIGHT; + } + else if (MetatileBehavior_IsSidewaysStairsLeftSideAny(currentBehavior)) + { + //moving OFF of any left side stair + if (dir == DIR_WEST && nextBehavior != currentBehavior) + return COLLISION_SIDEWAYS_STAIRS_TO_LEFT; //moving off of left stairs onto non-stair -> move diagonal + else + return collision; //moving off of left side stair to east -> move east + } + else if (MetatileBehavior_IsSidewaysStairsRightSideAny(currentBehavior)) + { + //moving OFF of any right side stair + if (dir == DIR_EAST && nextBehavior != currentBehavior) + return COLLISION_SIDEWAYS_STAIRS_TO_RIGHT; //moving off right stair onto non-stair -> move diagonal + else + return collision; + } + + return collision; +} + +static u8 GetVanillaCollision(struct ObjectEvent *objectEvent, s16 x, s16 y, u8 direction) +{ + if (IsCoordOutsideObjectEventMovementRange(objectEvent, x, y)) + return COLLISION_OUTSIDE_RANGE; + else if (MapGridIsImpassableAt(x, y) || GetMapBorderIdAt(x, y) == -1 || IsMetatileDirectionallyImpassable(objectEvent, x, y, direction)) + return COLLISION_IMPASSABLE; + else if (objectEvent->trackedByCamera && !CanCameraMoveInDirection(direction)) + return COLLISION_IMPASSABLE; + else if (IsZCoordMismatchAt(objectEvent->currentElevation, x, y)) + return COLLISION_ELEVATION_MISMATCH; + else if (DoesObjectCollideWithObjectAt(objectEvent, x, y)) + return COLLISION_OBJECT_EVENT; + + return COLLISION_NONE; +} + +static bool8 ObjectEventOnLeftSideStair(struct ObjectEvent *objectEvent, s16 x, s16 y, u8 direction) +{ + switch (direction) + { + case DIR_EAST: + MoveCoords(DIR_NORTH, &x, &y); + return DoesObjectCollideWithObjectAt(objectEvent, x, y); + case DIR_WEST: + MoveCoords(DIR_SOUTH, &x, &y); + return DoesObjectCollideWithObjectAt(objectEvent, x, y); + default: + return FALSE; //north/south taken care of in GetVanillaCollision + } +} + +static bool8 ObjectEventOnRightSideStair(struct ObjectEvent *objectEvent, s16 x, s16 y, u8 direction) +{ + switch (direction) + { + case DIR_EAST: + MoveCoords(DIR_SOUTH, &x, &y); + return DoesObjectCollideWithObjectAt(objectEvent, x, y); + case DIR_WEST: + MoveCoords(DIR_NORTH, &x, &y); + return DoesObjectCollideWithObjectAt(objectEvent, x, y); + default: + return FALSE; //north/south taken care of in GetVanillaCollision + } +} + u8 GetCollisionAtCoords(struct ObjectEvent *objectEvent, s16 x, s16 y, u32 dir) { u8 direction = dir; u8 currentBehavior = MapGridGetMetatileBehaviorAt(objectEvent->currentCoords.x, objectEvent->currentCoords.y); u8 nextBehavior = MapGridGetMetatileBehaviorAt(x, y); + u8 collision; + + objectEvent->directionOverwrite = DIR_NONE; //sideways stairs checks if (MetatileBehavior_IsSidewaysStairsLeftSideTop(nextBehavior) && dir == DIR_EAST) @@ -4895,17 +4946,26 @@ u8 GetCollisionAtCoords(struct ObjectEvent *objectEvent, s16 x, s16 y, u32 dir) && dir == DIR_NORTH && (MetatileBehavior_IsSidewaysStairsLeftSideBottom(nextBehavior) || MetatileBehavior_IsSidewaysStairsRightSideBottom(nextBehavior))) return COLLISION_IMPASSABLE; //trying to move north onto top stair tile at same level from non-stair -> no - if (IsCoordOutsideObjectEventMovementRange(objectEvent, x, y)) - return COLLISION_OUTSIDE_RANGE; - else if (MapGridIsImpassableAt(x, y) || GetMapBorderIdAt(x, y) == -1 || IsMetatileDirectionallyImpassable(objectEvent, x, y, direction)) - return COLLISION_IMPASSABLE; - else if (objectEvent->trackedByCamera && !CanCameraMoveInDirection(direction)) - return COLLISION_IMPASSABLE; - else if (IsZCoordMismatchAt(objectEvent->currentElevation, x, y)) - return COLLISION_ELEVATION_MISMATCH; - else if (DoesObjectCollideWithObjectAt(objectEvent, x, y)) - return COLLISION_OBJECT_EVENT; - return COLLISION_NONE; + // regular checks + collision = GetVanillaCollision(objectEvent, x, y, dir); + + //sideways stairs checks + collision = GetSidewaysStairsCollision(objectEvent, dir, currentBehavior, nextBehavior, collision); + switch (collision) + { + case COLLISION_SIDEWAYS_STAIRS_TO_LEFT: + if (ObjectEventOnLeftSideStair(objectEvent, x, y, dir)) + return COLLISION_OBJECT_EVENT; + objectEvent->directionOverwrite = GetLeftSideStairsDirection(dir); + return COLLISION_NONE; + case COLLISION_SIDEWAYS_STAIRS_TO_RIGHT: + if (ObjectEventOnRightSideStair(objectEvent, x, y, dir)) + return COLLISION_OBJECT_EVENT; + objectEvent->directionOverwrite = GetRightSideStairsDirection(dir); + return COLLISION_NONE; + } + + return collision; } u8 GetCollisionFlagsAtCoords(struct ObjectEvent *objectEvent, s16 x, s16 y, u8 direction) @@ -4969,8 +5029,9 @@ static bool8 DoesObjectCollideWithObjectAt(struct ObjectEvent *objectEvent, s16 for (i = 0; i < OBJECT_EVENTS_COUNT; i++) { curObject = &gObjectEvents[i]; - if (curObject->active && curObject != objectEvent) - { + if (curObject->active && curObject != objectEvent && !FollowMe_IsCollisionExempt(curObject, objectEvent)) + { + // check for collision if curObject is active, not the object in question, and not exempt from collisions if ((curObject->currentCoords.x == x && curObject->currentCoords.y == y) || (curObject->previousCoords.x == x && curObject->previousCoords.y == y)) { if (AreZCoordsCompatible(objectEvent->currentElevation, curObject->currentElevation)) @@ -5124,6 +5185,9 @@ bool8 ObjectEventSetHeldMovement(struct ObjectEvent *objectEvent, u8 movementAct objectEvent->heldMovementActive = TRUE; objectEvent->heldMovementFinished = FALSE; gSprites[objectEvent->spriteId].data[2] = 0; + + FollowMe(objectEvent, movementActionId, FALSE); + return FALSE; } @@ -5203,12 +5267,6 @@ u8 name(u32 idx)\ return animIds[direction];\ } -//sideways stairs -dirn_to_anim(GetDiagonalRightStairsMovement, gDiagonalStairRightSideMovementActions); -dirn_to_anim(GetDiagonalLeftStairsMovement, gDiagonalStairLeftSideMovementActions); -dirn_to_anim(GetDiagonalRightStairsRunningMovement, gDiagonalStairRightSideRunningMovementActions); -dirn_to_anim(GetDiagonalLeftStairsRunningMovement, gDiagonalStairLeftSideRunningMovementActions); - dirn_to_anim(GetFaceDirectionMovementAction, gFaceDirectionMovementActions); dirn_to_anim(GetWalkSlowMovementAction, gWalkSlowMovementActions); dirn_to_anim(GetPlayerRunSlowMovementAction, gRunSlowMovementActions); @@ -5514,7 +5572,10 @@ bool8 MovementAction_WalkSlowUp_Step1(struct ObjectEvent *objectEvent, struct Sp bool8 MovementAction_WalkSlowLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8093B60(objectEvent, sprite, DIR_WEST); + if (objectEvent->directionOverwrite) + sub_8093B60(objectEvent, sprite, objectEvent->directionOverwrite); + else + sub_8093B60(objectEvent, sprite, DIR_WEST); return MovementAction_WalkSlowLeft_Step1(objectEvent, sprite); } @@ -5530,7 +5591,10 @@ bool8 MovementAction_WalkSlowLeft_Step1(struct ObjectEvent *objectEvent, struct bool8 MovementAction_WalkSlowRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8093B60(objectEvent, sprite, DIR_EAST); + if (objectEvent->directionOverwrite) + sub_8093B60(objectEvent, sprite, objectEvent->directionOverwrite); + else + sub_8093B60(objectEvent, sprite, DIR_EAST); return MovementAction_WalkSlowRight_Step1(objectEvent, sprite); } @@ -5642,7 +5706,10 @@ bool8 MovementAction_WalkNormalUp_Step1(struct ObjectEvent *objectEvent, struct bool8 MovementAction_WalkNormalLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - do_go_anim(objectEvent, sprite, DIR_WEST, 0); + if (objectEvent->directionOverwrite) + do_go_anim(objectEvent, sprite, objectEvent->directionOverwrite, 0); + else + do_go_anim(objectEvent, sprite, DIR_WEST, 0); return MovementAction_WalkNormalLeft_Step1(objectEvent, sprite); } @@ -5658,7 +5725,10 @@ bool8 MovementAction_WalkNormalLeft_Step1(struct ObjectEvent *objectEvent, struc bool8 MovementAction_WalkNormalRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - do_go_anim(objectEvent, sprite, DIR_EAST, 0); + if (objectEvent->directionOverwrite) + do_go_anim(objectEvent, sprite, objectEvent->directionOverwrite, 0); + else + do_go_anim(objectEvent, sprite, DIR_EAST, 0); return MovementAction_WalkNormalRight_Step1(objectEvent, sprite); } @@ -5917,7 +5987,10 @@ bool8 MovementAction_WalkFastUp_Step1(struct ObjectEvent *objectEvent, struct Sp bool8 MovementAction_WalkFastLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - do_go_anim(objectEvent, sprite, DIR_WEST, 1); + if (objectEvent->directionOverwrite) + do_go_anim(objectEvent, sprite, objectEvent->directionOverwrite, 1); + else + do_go_anim(objectEvent, sprite, DIR_WEST, 1); return MovementAction_WalkFastLeft_Step1(objectEvent, sprite); } @@ -5933,7 +6006,10 @@ bool8 MovementAction_WalkFastLeft_Step1(struct ObjectEvent *objectEvent, struct bool8 MovementAction_WalkFastRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - do_go_anim(objectEvent, sprite, DIR_EAST, 1); + if (objectEvent->directionOverwrite) + do_go_anim(objectEvent, sprite, objectEvent->directionOverwrite, 1); + else + do_go_anim(objectEvent, sprite, DIR_EAST, 1); return MovementAction_WalkFastRight_Step1(objectEvent, sprite); } @@ -6063,13 +6139,19 @@ bool8 MovementAction_WalkInPlaceFastestUp_Step0(struct ObjectEvent *objectEvent, bool8 MovementAction_WalkInPlaceFastestLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8094554(objectEvent, sprite, DIR_WEST, GetMoveDirectionFasterAnimNum(DIR_WEST), 4); + if (objectEvent->directionOverwrite) + sub_8094554(objectEvent, sprite, objectEvent->directionOverwrite, GetMoveDirectionFasterAnimNum(DIR_WEST), 4); + else + sub_8094554(objectEvent, sprite, DIR_WEST, GetMoveDirectionFasterAnimNum(DIR_WEST), 4); return MovementAction_WalkInPlace_Step1(objectEvent, sprite); } bool8 MovementAction_WalkInPlaceFastestRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8094554(objectEvent, sprite, DIR_EAST, GetMoveDirectionFasterAnimNum(DIR_EAST), 4); + if (objectEvent->directionOverwrite) + sub_8094554(objectEvent, sprite, objectEvent->directionOverwrite, GetMoveDirectionFasterAnimNum(DIR_WEST), 4); + else + sub_8094554(objectEvent, sprite, DIR_EAST, GetMoveDirectionFasterAnimNum(DIR_EAST), 4); return MovementAction_WalkInPlace_Step1(objectEvent, sprite); } @@ -6107,7 +6189,10 @@ bool8 MovementAction_RideWaterCurrentUp_Step1(struct ObjectEvent *objectEvent, s bool8 MovementAction_RideWaterCurrentLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - do_go_anim(objectEvent, sprite, DIR_WEST, 2); + if (objectEvent->directionOverwrite) + do_go_anim(objectEvent, sprite, objectEvent->directionOverwrite, 2); + else + do_go_anim(objectEvent, sprite, DIR_WEST, 2); return MovementAction_RideWaterCurrentLeft_Step1(objectEvent, sprite); } @@ -6123,7 +6208,10 @@ bool8 MovementAction_RideWaterCurrentLeft_Step1(struct ObjectEvent *objectEvent, bool8 MovementAction_RideWaterCurrentRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - do_go_anim(objectEvent, sprite, DIR_EAST, 2); + if (objectEvent->directionOverwrite) + do_go_anim(objectEvent, sprite, objectEvent->directionOverwrite, 2); + else + do_go_anim(objectEvent, sprite, DIR_EAST, 2); return MovementAction_RideWaterCurrentRight_Step1(objectEvent, sprite); } @@ -6171,7 +6259,10 @@ bool8 MovementAction_WalkFastestUp_Step1(struct ObjectEvent *objectEvent, struct bool8 MovementAction_WalkFastestLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - do_go_anim(objectEvent, sprite, DIR_WEST, 3); + if (objectEvent->directionOverwrite) + do_go_anim(objectEvent, sprite, objectEvent->directionOverwrite, 3); + else + do_go_anim(objectEvent, sprite, DIR_WEST, 3); return MovementAction_WalkFastestLeft_Step1(objectEvent, sprite); } @@ -6187,7 +6278,10 @@ bool8 MovementAction_WalkFastestLeft_Step1(struct ObjectEvent *objectEvent, stru bool8 MovementAction_WalkFastestRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - do_go_anim(objectEvent, sprite, DIR_EAST, 3); + if (objectEvent->directionOverwrite) + do_go_anim(objectEvent, sprite, objectEvent->directionOverwrite, 3); + else + do_go_anim(objectEvent, sprite, DIR_EAST, 3); return MovementAction_WalkFastestRight_Step1(objectEvent, sprite); } @@ -6235,7 +6329,10 @@ bool8 MovementAction_SlideUp_Step1(struct ObjectEvent *objectEvent, struct Sprit bool8 MovementAction_SlideLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - do_go_anim(objectEvent, sprite, DIR_WEST, 4); + if (objectEvent->directionOverwrite) + do_go_anim(objectEvent, sprite, objectEvent->directionOverwrite, 4); + else + do_go_anim(objectEvent, sprite, DIR_WEST, 4); return MovementAction_SlideLeft_Step1(objectEvent, sprite); } @@ -6251,7 +6348,10 @@ bool8 MovementAction_SlideLeft_Step1(struct ObjectEvent *objectEvent, struct Spr bool8 MovementAction_SlideRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - do_go_anim(objectEvent, sprite, DIR_EAST, 4); + if (objectEvent->directionOverwrite) + do_go_anim(objectEvent, sprite, objectEvent->directionOverwrite, 4); + else + do_go_anim(objectEvent, sprite, DIR_EAST, 4); return MovementAction_SlideRight_Step1(objectEvent, sprite); } @@ -6299,7 +6399,10 @@ bool8 MovementAction_PlayerRunUp_Step1(struct ObjectEvent *objectEvent, struct S bool8 MovementAction_PlayerRunLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - StartRunningAnim(objectEvent, sprite, DIR_WEST); + if (objectEvent->directionOverwrite) + StartRunningAnim(objectEvent, sprite, objectEvent->directionOverwrite); + else + StartRunningAnim(objectEvent, sprite, DIR_WEST); return MovementAction_PlayerRunLeft_Step1(objectEvent, sprite); } @@ -6315,7 +6418,10 @@ bool8 MovementAction_PlayerRunLeft_Step1(struct ObjectEvent *objectEvent, struct bool8 MovementAction_PlayerRunRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - StartRunningAnim(objectEvent, sprite, DIR_EAST); + if (objectEvent->directionOverwrite) + StartRunningAnim(objectEvent, sprite, objectEvent->directionOverwrite); + else + StartRunningAnim(objectEvent, sprite, DIR_EAST); return MovementAction_PlayerRunRight_Step1(objectEvent, sprite); } @@ -7165,7 +7271,7 @@ bool8 MovementAction_AcroWheelieHopFaceRight_Step1(struct ObjectEvent *objectEve bool8 MovementAction_AcroWheelieHopDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8095B84(objectEvent, sprite, gSidewaysStairsDirection, 1, 1); + sub_8095B84(objectEvent, sprite, DIR_SOUTH, 1, 1); return MovementAction_AcroWheelieHopDown_Step1(objectEvent, sprite); } @@ -7182,7 +7288,7 @@ bool8 MovementAction_AcroWheelieHopDown_Step1(struct ObjectEvent *objectEvent, s bool8 MovementAction_AcroWheelieHopUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8095B84(objectEvent, sprite, gSidewaysStairsDirection, 1, 1); + sub_8095B84(objectEvent, sprite, DIR_NORTH, 1, 1); return MovementAction_AcroWheelieHopUp_Step1(objectEvent, sprite); } @@ -7199,7 +7305,10 @@ bool8 MovementAction_AcroWheelieHopUp_Step1(struct ObjectEvent *objectEvent, str bool8 MovementAction_AcroWheelieHopLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8095B84(objectEvent, sprite, gSidewaysStairsDirection, 1, 1); + if (objectEvent->directionOverwrite) + sub_8095B84(objectEvent, sprite, objectEvent->directionOverwrite, 1, 1); + else + sub_8095B84(objectEvent, sprite, DIR_WEST, 1, 1); return MovementAction_AcroWheelieHopLeft_Step1(objectEvent, sprite); } @@ -7216,7 +7325,10 @@ bool8 MovementAction_AcroWheelieHopLeft_Step1(struct ObjectEvent *objectEvent, s bool8 MovementAction_AcroWheelieHopRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8095B84(objectEvent, sprite, gSidewaysStairsDirection, 1, 1); + if (objectEvent->directionOverwrite) + sub_8095B84(objectEvent, sprite, objectEvent->directionOverwrite, 1, 1); + else + sub_8095B84(objectEvent, sprite, DIR_EAST, 1, 1); return MovementAction_AcroWheelieHopRight_Step1(objectEvent, sprite); } @@ -7233,7 +7345,7 @@ bool8 MovementAction_AcroWheelieHopRight_Step1(struct ObjectEvent *objectEvent, bool8 MovementAction_AcroWheelieJumpDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8095B84(objectEvent, sprite, gSidewaysStairsDirection, 2, 0); + sub_8095B84(objectEvent, sprite, DIR_SOUTH, 2, 0); return MovementAction_AcroWheelieJumpDown_Step1(objectEvent, sprite); } @@ -7250,7 +7362,7 @@ bool8 MovementAction_AcroWheelieJumpDown_Step1(struct ObjectEvent *objectEvent, bool8 MovementAction_AcroWheelieJumpUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8095B84(objectEvent, sprite, gSidewaysStairsDirection, 2, 0); + sub_8095B84(objectEvent, sprite, DIR_NORTH, 2, 0); return MovementAction_AcroWheelieJumpUp_Step1(objectEvent, sprite); } @@ -7267,7 +7379,10 @@ bool8 MovementAction_AcroWheelieJumpUp_Step1(struct ObjectEvent *objectEvent, st bool8 MovementAction_AcroWheelieJumpLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8095B84(objectEvent, sprite, gSidewaysStairsDirection, 2, 0); + if (objectEvent->directionOverwrite) + sub_8095B84(objectEvent, sprite, objectEvent->directionOverwrite, 2, 0); + else + sub_8095B84(objectEvent, sprite, DIR_WEST, 2, 0); return MovementAction_AcroWheelieJumpLeft_Step1(objectEvent, sprite); } @@ -7284,7 +7399,10 @@ bool8 MovementAction_AcroWheelieJumpLeft_Step1(struct ObjectEvent *objectEvent, bool8 MovementAction_AcroWheelieJumpRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8095B84(objectEvent, sprite, gSidewaysStairsDirection, 2, 0); + if (objectEvent->directionOverwrite) + sub_8095B84(objectEvent, sprite, objectEvent->directionOverwrite, 2, 0); + else + sub_8095B84(objectEvent, sprite, DIR_EAST, 2, 0); return MovementAction_AcroWheelieJumpRight_Step1(objectEvent, sprite); } @@ -7301,25 +7419,31 @@ bool8 MovementAction_AcroWheelieJumpRight_Step1(struct ObjectEvent *objectEvent, bool8 MovementAction_AcroWheelieInPlaceDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8094554(objectEvent, sprite, gSidewaysStairsDirection, GetAcroWheeliePedalDirectionAnimNum(gSidewaysStairsDirection), 8); + sub_8094554(objectEvent, sprite, DIR_SOUTH, GetAcroWheeliePedalDirectionAnimNum(DIR_SOUTH), 8); return MovementAction_WalkInPlace_Step1(objectEvent, sprite); } bool8 MovementAction_AcroWheelieInPlaceUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8094554(objectEvent, sprite, gSidewaysStairsDirection, GetAcroWheeliePedalDirectionAnimNum(gSidewaysStairsDirection), 8); + sub_8094554(objectEvent, sprite, DIR_NORTH, GetAcroWheeliePedalDirectionAnimNum(DIR_NORTH), 8); return MovementAction_WalkInPlace_Step1(objectEvent, sprite); } bool8 MovementAction_AcroWheelieInPlaceLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8094554(objectEvent, sprite, gSidewaysStairsDirection, GetAcroWheeliePedalDirectionAnimNum(gSidewaysStairsDirection), 8); + if (objectEvent->directionOverwrite) + sub_8094554(objectEvent, sprite, objectEvent->directionOverwrite, GetAcroWheeliePedalDirectionAnimNum(objectEvent->directionOverwrite), 8); + else + sub_8094554(objectEvent, sprite, DIR_WEST, GetAcroWheeliePedalDirectionAnimNum(DIR_WEST), 8); return MovementAction_WalkInPlace_Step1(objectEvent, sprite); } bool8 MovementAction_AcroWheelieInPlaceRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8094554(objectEvent, sprite, gSidewaysStairsDirection, GetAcroWheeliePedalDirectionAnimNum(gSidewaysStairsDirection), 8); + if (objectEvent->directionOverwrite) + sub_8094554(objectEvent, sprite, objectEvent->directionOverwrite, GetAcroWheeliePedalDirectionAnimNum(objectEvent->directionOverwrite), 8); + else + sub_8094554(objectEvent, sprite, DIR_EAST, GetAcroWheeliePedalDirectionAnimNum(DIR_EAST), 8); return MovementAction_WalkInPlace_Step1(objectEvent, sprite); } @@ -7332,7 +7456,7 @@ void sub_80960C8(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 dire bool8 MovementAction_AcroPopWheelieMoveDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_80960C8(objectEvent, sprite, gSidewaysStairsDirection, 1); + sub_80960C8(objectEvent, sprite, DIR_SOUTH, 1); return MovementAction_AcroPopWheelieMoveDown_Step1(objectEvent, sprite); } @@ -7348,7 +7472,7 @@ bool8 MovementAction_AcroPopWheelieMoveDown_Step1(struct ObjectEvent *objectEven bool8 MovementAction_AcroPopWheelieMoveUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_80960C8(objectEvent, sprite, gSidewaysStairsDirection, 1); + sub_80960C8(objectEvent, sprite, DIR_NORTH, 1); return MovementAction_AcroPopWheelieMoveUp_Step1(objectEvent, sprite); } @@ -7364,7 +7488,10 @@ bool8 MovementAction_AcroPopWheelieMoveUp_Step1(struct ObjectEvent *objectEvent, bool8 MovementAction_AcroPopWheelieMoveLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_80960C8(objectEvent, sprite, gSidewaysStairsDirection, 1); + if (objectEvent->directionOverwrite) + sub_80960C8(objectEvent, sprite, objectEvent->directionOverwrite, 1); + else + sub_80960C8(objectEvent, sprite, DIR_WEST, 1); return MovementAction_AcroPopWheelieMoveLeft_Step1(objectEvent, sprite); } @@ -7380,7 +7507,10 @@ bool8 MovementAction_AcroPopWheelieMoveLeft_Step1(struct ObjectEvent *objectEven bool8 MovementAction_AcroPopWheelieMoveRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_80960C8(objectEvent, sprite, gSidewaysStairsDirection, 1); + if (objectEvent->directionOverwrite) + sub_80960C8(objectEvent, sprite, objectEvent->directionOverwrite, 1); + else + sub_80960C8(objectEvent, sprite, DIR_EAST, 1); return MovementAction_AcroPopWheelieMoveRight_Step1(objectEvent, sprite); } @@ -7402,7 +7532,7 @@ void sub_8096200(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 dire bool8 MovementAction_AcroWheelieMoveDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8096200(objectEvent, sprite, gSidewaysStairsDirection, 1); + sub_8096200(objectEvent, sprite, DIR_SOUTH, 1); return MovementAction_AcroWheelieMoveDown_Step1(objectEvent, sprite); } @@ -7418,7 +7548,7 @@ bool8 MovementAction_AcroWheelieMoveDown_Step1(struct ObjectEvent *objectEvent, bool8 MovementAction_AcroWheelieMoveUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8096200(objectEvent, sprite, gSidewaysStairsDirection, 1); + sub_8096200(objectEvent, sprite, DIR_NORTH, 1); return MovementAction_AcroWheelieMoveUp_Step1(objectEvent, sprite); } @@ -7434,7 +7564,10 @@ bool8 MovementAction_AcroWheelieMoveUp_Step1(struct ObjectEvent *objectEvent, st bool8 MovementAction_AcroWheelieMoveLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8096200(objectEvent, sprite, gSidewaysStairsDirection, 1); + if (objectEvent->directionOverwrite) + sub_8096200(objectEvent, sprite, objectEvent->directionOverwrite, 1); + else + sub_8096200(objectEvent, sprite, DIR_WEST, 1); return MovementAction_AcroWheelieMoveLeft_Step1(objectEvent, sprite); } @@ -7450,7 +7583,10 @@ bool8 MovementAction_AcroWheelieMoveLeft_Step1(struct ObjectEvent *objectEvent, bool8 MovementAction_AcroWheelieMoveRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8096200(objectEvent, sprite, gSidewaysStairsDirection, 1); + if (objectEvent->directionOverwrite) + sub_8096200(objectEvent, sprite, objectEvent->directionOverwrite, 1); + else + sub_8096200(objectEvent, sprite, DIR_EAST, 1); return MovementAction_AcroWheelieMoveRight_Step1(objectEvent, sprite); } @@ -7473,7 +7609,7 @@ void sub_8096330(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 dire bool8 MovementAction_AcroEndWheelieMoveDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8096330(objectEvent, sprite, gSidewaysStairsDirection, 1); + sub_8096330(objectEvent, sprite, DIR_SOUTH, 1); return MovementAction_AcroEndWheelieMoveDown_Step1(objectEvent, sprite); } @@ -7489,7 +7625,7 @@ bool8 MovementAction_AcroEndWheelieMoveDown_Step1(struct ObjectEvent *objectEven bool8 MovementAction_AcroEndWheelieMoveUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8096330(objectEvent, sprite, gSidewaysStairsDirection, 1); + sub_8096330(objectEvent, sprite, DIR_NORTH, 1); return MovementAction_AcroEndWheelieMoveUp_Step1(objectEvent, sprite); } @@ -7505,7 +7641,10 @@ bool8 MovementAction_AcroEndWheelieMoveUp_Step1(struct ObjectEvent *objectEvent, bool8 MovementAction_AcroEndWheelieMoveLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8096330(objectEvent, sprite, gSidewaysStairsDirection, 1); + if (objectEvent->directionOverwrite) + sub_8096330(objectEvent, sprite, objectEvent->directionOverwrite, 1); + else + sub_8096330(objectEvent, sprite, DIR_WEST, 1); return MovementAction_AcroEndWheelieMoveLeft_Step1(objectEvent, sprite); } @@ -7521,7 +7660,10 @@ bool8 MovementAction_AcroEndWheelieMoveLeft_Step1(struct ObjectEvent *objectEven bool8 MovementAction_AcroEndWheelieMoveRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_8096330(objectEvent, sprite, gSidewaysStairsDirection, 1); + if (objectEvent->directionOverwrite) + sub_8096330(objectEvent, sprite, objectEvent->directionOverwrite, 1); + else + sub_8096330(objectEvent, sprite, DIR_EAST, 1); return MovementAction_AcroEndWheelieMoveRight_Step1(objectEvent, sprite); } @@ -9193,6 +9335,31 @@ u8 MovementAction_Fly_Finish(struct ObjectEvent *objectEvent, struct Sprite *spr return TRUE; } +// NEW +u16 GetMiniStepCount(u8 speed) +{ + return (u16)gUnknown_0850E768[speed]; +} + +void RunMiniStep(struct Sprite *sprite, u8 speed, u8 currentFrame) +{ + gUnknown_0850E754[speed][currentFrame](sprite, sprite->data[3]); +} + +bool8 PlayerIsUnderWaterfall(struct ObjectEvent *objectEvent) +{ + s16 x; + s16 y; + + x = objectEvent->currentCoords.x; + y = objectEvent->currentCoords.y; + MoveCoordsInDirection(DIR_NORTH, &x, &y, 0, 1); + if (MetatileBehavior_IsWaterfall(MapGridGetMetatileBehaviorAt(x, y))) + return TRUE; + + return FALSE; +} + // running slow static void StartSlowRunningAnim(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 direction) { @@ -9248,13 +9415,19 @@ bool8 MovementActionFunc_RunSlowUp_Step0(struct ObjectEvent *objectEvent, struct bool8 MovementActionFunc_RunSlowLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - StartSlowRunningAnim(objectEvent, sprite, DIR_WEST); + if (objectEvent->directionOverwrite) + StartSlowRunningAnim(objectEvent, sprite, objectEvent->directionOverwrite); + else + StartSlowRunningAnim(objectEvent, sprite, DIR_WEST); return MovementActionFunc_RunSlow_Step1(objectEvent, sprite); } bool8 MovementActionFunc_RunSlowRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - StartSlowRunningAnim(objectEvent, sprite, DIR_EAST); + if (objectEvent->directionOverwrite) + StartSlowRunningAnim(objectEvent, sprite, objectEvent->directionOverwrite); + else + StartSlowRunningAnim(objectEvent, sprite, DIR_EAST); return MovementActionFunc_RunSlow_Step1(objectEvent, sprite); } @@ -9267,163 +9440,3 @@ bool8 MovementActionFunc_RunSlow_Step1(struct ObjectEvent *objectEvent, struct S } return FALSE; } - -//sideways stairs -bool8 MovementAction_WalkStairDiagonalUpLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) -{ - objectEvent->facingDirection = DIR_WEST; - objectEvent->facingDirectionLocked = TRUE; - #if SLOW_MOVEMENT_ON_STAIRS == TRUE - sub_8093B60(objectEvent, sprite, DIR_NORTHWEST); - return MovementAction_WalkSlowDiagonalUpLeft_Step1(objectEvent, sprite); - #else - do_go_anim(objectEvent, sprite, DIR_NORTHWEST, 0); - return MovementAction_WalkNormalDiagonalUpLeft_Step1(objectEvent, sprite); - #endif -} - -bool8 MovementAction_WalkStairDiagonalUpRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) -{ - objectEvent->facingDirection = DIR_EAST; - objectEvent->facingDirectionLocked = TRUE; - #if SLOW_MOVEMENT_ON_STAIRS == TRUE - sub_8093B60(objectEvent, sprite, DIR_NORTHEAST); - return MovementAction_WalkSlowDiagonalUpRight_Step1(objectEvent, sprite); - #else - do_go_anim(objectEvent, sprite, DIR_NORTHEAST, 0); - return MovementAction_WalkNormalDiagonalUpLeft_Step1(objectEvent, sprite); - #endif -} - -bool8 MovementAction_WalkStairDiagonalDownLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) -{ - objectEvent->facingDirection = DIR_WEST; - objectEvent->facingDirectionLocked = TRUE; - #if SLOW_MOVEMENT_ON_STAIRS == TRUE - sub_8093B60(objectEvent, sprite, DIR_SOUTHWEST); - return MovementAction_WalkSlowDiagonalDownLeft_Step1(objectEvent, sprite); - #else - do_go_anim(objectEvent, sprite, DIR_SOUTHWEST, 0); - return MovementAction_WalkNormalDiagonalUpLeft_Step1(objectEvent, sprite); - #endif -} - -bool8 MovementAction_WalkStairDiagonalDownRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) -{ - objectEvent->facingDirection = DIR_EAST; - objectEvent->facingDirectionLocked = TRUE; - #if SLOW_MOVEMENT_ON_STAIRS == TRUE - sub_8093B60(objectEvent, sprite, DIR_SOUTHEAST); - return MovementAction_WalkSlowDiagonalDownRight_Step1(objectEvent, sprite); - #else - do_go_anim(objectEvent, sprite, DIR_SOUTHEAST, 0); - return MovementAction_WalkNormalDiagonalUpLeft_Step1(objectEvent, sprite); - #endif -} - -bool8 MovementAction_RunStairDiagonalUpLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) -{ - objectEvent->facingDirection = DIR_WEST; - objectEvent->facingDirectionLocked = TRUE; - #if SLOW_MOVEMENT_ON_STAIRS == TRUE - StartSlowRunningAnim(objectEvent, sprite, DIR_NORTHWEST); - #else - StartRunningAnim(objectEvent, sprite, DIR_NORTHWEST); - #endif - return MovementAction_RunStairDiagonal_Step1(objectEvent, sprite); -} - -bool8 MovementAction_RunStairDiagonalUpRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) -{ - objectEvent->facingDirection = DIR_EAST; - objectEvent->facingDirectionLocked = TRUE; - #if SLOW_MOVEMENT_ON_STAIRS == TRUE - StartSlowRunningAnim(objectEvent, sprite, DIR_NORTHEAST); - #else - StartRunningAnim(objectEvent, sprite, DIR_NORTHEAST); - #endif - return MovementAction_RunStairDiagonal_Step1(objectEvent, sprite); -} - -bool8 MovementAction_RunStairDiagonalDownLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) -{ - objectEvent->facingDirection = DIR_WEST; - objectEvent->facingDirectionLocked = TRUE; - #if SLOW_MOVEMENT_ON_STAIRS == TRUE - StartSlowRunningAnim(objectEvent, sprite, DIR_SOUTHWEST); - #else - StartRunningAnim(objectEvent, sprite, DIR_SOUTHWEST); - #endif - return MovementAction_RunStairDiagonal_Step1(objectEvent, sprite); -} - -bool8 MovementAction_RunStairDiagonalDownRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) -{ - objectEvent->facingDirection = DIR_EAST; - objectEvent->facingDirectionLocked = TRUE; - #if SLOW_MOVEMENT_ON_STAIRS == TRUE - StartSlowRunningAnim(objectEvent, sprite, DIR_SOUTHEAST); - #else - StartRunningAnim(objectEvent, sprite, DIR_SOUTHEAST); - #endif - return MovementAction_RunStairDiagonal_Step1(objectEvent, sprite); -} - -bool8 MovementAction_RunStairDiagonal_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) -{ - if (npc_obj_ministep_stop_on_arrival(objectEvent, sprite)) - { - sprite->data[2] = 2; - return TRUE; - } - return FALSE; -} - -bool8 MovementAction_AcroBikeDiagonalUpLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) -{ - objectEvent->facingDirection = DIR_WEST; - objectEvent->facingDirectionLocked = TRUE; - #if SLOW_MOVEMENT_ON_STAIRS == TRUE - do_go_anim(objectEvent, sprite, DIR_NORTHWEST, 0); - #else - do_go_anim(objectEvent, sprite, DIR_NORTHWEST, 2); - #endif - return MovementAction_RideWaterCurrentLeft_Step1(objectEvent, sprite); -} - -bool8 MovementAction_AcroBikeDiagonalDownLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) -{ - objectEvent->facingDirection = DIR_WEST; - objectEvent->facingDirectionLocked = TRUE; - #if SLOW_MOVEMENT_ON_STAIRS == TRUE - do_go_anim(objectEvent, sprite, DIR_SOUTHWEST, 0); - #else - do_go_anim(objectEvent, sprite, DIR_SOUTHWEST, 2); - #endif - return MovementAction_RideWaterCurrentLeft_Step1(objectEvent, sprite); -} - -bool8 MovementAction_AcroBikeDiagonalUpRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) -{ - objectEvent->facingDirection = DIR_EAST; - objectEvent->facingDirectionLocked = TRUE; - #if SLOW_MOVEMENT_ON_STAIRS == TRUE - do_go_anim(objectEvent, sprite, DIR_NORTHEAST, 0); - #else - do_go_anim(objectEvent, sprite, DIR_NORTHEAST, 2); - #endif - return MovementAction_RideWaterCurrentRight_Step1(objectEvent, sprite); -} - -bool8 MovementAction_AcroBikeDiagonalDownRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) -{ - objectEvent->facingDirection = DIR_EAST; - objectEvent->facingDirectionLocked = TRUE; - #if SLOW_MOVEMENT_ON_STAIRS == TRUE - do_go_anim(objectEvent, sprite, DIR_SOUTHEAST, 0); - #else - do_go_anim(objectEvent, sprite, DIR_SOUTHEAST, 2); - #endif - return MovementAction_RideWaterCurrentRight_Step1(objectEvent, sprite); -} - diff --git a/src/field_control_avatar.c b/src/field_control_avatar.c index 6ec280fd0d79..f0a7f708f8b4 100644 --- a/src/field_control_avatar.c +++ b/src/field_control_avatar.c @@ -28,6 +28,7 @@ #include "trainer_see.h" #include "trainer_hill.h" #include "wild_encounter.h" +#include "follow_me.h" #include "constants/event_bg.h" #include "constants/event_objects.h" #include "constants/field_poison.h" @@ -288,8 +289,39 @@ static const u8 *GetInteractedObjectEventScript(struct MapPosition *position, u8 { u8 objectEventId; const u8 *script; - - objectEventId = GetObjectEventIdByXYZ(position->x, position->y, position->height); + s16 currX = gObjectEvents[gPlayerAvatar.objectEventId].currentCoords.x; + s16 currY = gObjectEvents[gPlayerAvatar.objectEventId].currentCoords.y; + u8 currBehavior = MapGridGetMetatileBehaviorAt(currX, currY); + + switch (direction) + { + case DIR_EAST: + if (MetatileBehavior_IsSidewaysStairsLeftSideAny(metatileBehavior)) + // sideways stairs left-side to your right -> check northeast + objectEventId = GetObjectEventIdByXYZ(currX + 1, currY - 1, position->height); + else if (MetatileBehavior_IsSidewaysStairsRightSideAny(currBehavior)) + // on top of right-side stairs -> check southeast + objectEventId = GetObjectEventIdByXYZ(currX + 1, currY + 1, position->height); + else + // check in front of player + objectEventId = GetObjectEventIdByXYZ(position->x, position->y, position->height); + break; + case DIR_WEST: + if (MetatileBehavior_IsSidewaysStairsRightSideAny(metatileBehavior)) + // facing sideways stairs right side -> check northwest + objectEventId = GetObjectEventIdByXYZ(currX - 1, currY - 1, position->height); + else if (MetatileBehavior_IsSidewaysStairsLeftSideAny(currBehavior)) + // on top of left-side stairs -> check southwest + objectEventId = GetObjectEventIdByXYZ(currX - 1, currY + 1, position->height); + else + // check in front of player + objectEventId = GetObjectEventIdByXYZ(position->x, position->y, position->height); + break; + default: + objectEventId = GetObjectEventIdByXYZ(position->x, position->y, position->height); + break; + } + if (objectEventId == OBJECT_EVENTS_COUNT || gObjectEvents[objectEventId].localId == OBJ_EVENT_ID_PLAYER) { if (MetatileBehavior_IsCounter(metatileBehavior) != TRUE) @@ -448,10 +480,10 @@ static const u8 *GetInteractedMetatileScript(struct MapPosition *position, u8 me static const u8 *GetInteractedWaterScript(struct MapPosition *unused1, u8 metatileBehavior, u8 direction) { - if (FlagGet(FLAG_BADGE05_GET) == TRUE && PartyHasMonWithSurf() == TRUE && IsPlayerFacingSurfableFishableWater() == TRUE) + if (FlagGet(FLAG_BADGE05_GET) == TRUE && PartyHasMonWithSurf() == TRUE && IsPlayerFacingSurfableFishableWater() == TRUE && CheckFollowerFlag(FOLLOWER_FLAG_CAN_SURF)) return EventScript_UseSurf; - if (MetatileBehavior_IsWaterfall(metatileBehavior) == TRUE) + if (MetatileBehavior_IsWaterfall(metatileBehavior) == TRUE && CheckFollowerFlag(FOLLOWER_FLAG_CAN_WATERFALL)) { if (FlagGet(FLAG_BADGE08_GET) == TRUE && IsPlayerSurfingNorth() == TRUE) return EventScript_UseWaterfall; @@ -463,6 +495,9 @@ static const u8 *GetInteractedWaterScript(struct MapPosition *unused1, u8 metati static bool32 TrySetupDiveDownScript(void) { + if (!CheckFollowerFlag(FOLLOWER_FLAG_CAN_DIVE)) + return FALSE; + if (FlagGet(FLAG_BADGE07_GET) && TrySetDiveWarp() == 2) { ScriptContext1_SetupScript(EventScript_UseDive); @@ -473,6 +508,9 @@ static bool32 TrySetupDiveDownScript(void) static bool32 TrySetupDiveEmergeScript(void) { + if (!CheckFollowerFlag(FOLLOWER_FLAG_CAN_DIVE)) + return FALSE; + if (FlagGet(FLAG_BADGE07_GET) && gMapHeader.mapType == MAP_TYPE_UNDERWATER && TrySetDiveWarp() == 1) { ScriptContext1_SetupScript(EventScript_UseDiveUnderwater); diff --git a/src/field_player_avatar.c b/src/field_player_avatar.c index dd52e3a61244..f74b4f5a98a1 100644 --- a/src/field_player_avatar.c +++ b/src/field_player_avatar.c @@ -20,6 +20,7 @@ #include "strings.h" #include "task.h" #include "tv.h" +#include "follow_me.h" #include "wild_encounter.h" #include "constants/abilities.h" #include "constants/event_objects.h" @@ -624,22 +625,6 @@ static void PlayerNotOnBikeMoving(u8 direction, u16 heldKeys) PlayerNotOnBikeCollideWithFarawayIslandMew(direction); return; } - else if (collision == COLLISION_SIDEWAYS_STAIRS_TO_RIGHT) - { - if (heldKeys & B_BUTTON && FlagGet(FLAG_SYS_B_DASH)) - PlayerSidewaysStairsRightSideRunning(direction); - else - PlayerSidewaysStairsRightSide(direction); - return; - } - else if (collision == COLLISION_SIDEWAYS_STAIRS_TO_LEFT) - { - if (heldKeys & B_BUTTON && FlagGet(FLAG_SYS_B_DASH)) - return PlayerSidewaysStairsLeftSideRunning(direction); - else - return PlayerSidewaysStairsLeftSide(direction); - return; - } else { u8 adjustedCollision = collision - COLLISION_STOP_SURFING; @@ -659,45 +644,16 @@ static void PlayerNotOnBikeMoving(u8 direction, u16 heldKeys) if (!(gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_UNDERWATER) && (heldKeys & B_BUTTON) && FlagGet(FLAG_SYS_B_DASH) && IsRunningDisallowed(gObjectEvents[gPlayerAvatar.objectEventId].currentMetatileBehavior) == 0) { - if (PlayerIsMovingOnRockStairs(direction)) - PlayerRunSlow(direction); - else - PlayerRun(direction); - + PlayerRun(direction); gPlayerAvatar.flags |= PLAYER_AVATAR_FLAG_DASH; return; } else { - if (PlayerIsMovingOnRockStairs(direction)) - PlayerGoSlow(direction); - else - PlayerGoSpeed1(direction); + PlayerGoSpeed1(direction); } } -bool32 PlayerIsMovingOnRockStairs(u8 direction) -{ - #if SLOW_MOVEMENT_ON_STAIRS - struct ObjectEvent *objectEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; - s16 x = objectEvent->currentCoords.x; - s16 y = objectEvent->currentCoords.y; - - switch (direction) - { - case DIR_NORTH: - return MetatileBehavior_IsRockStairs(MapGridGetMetatileBehaviorAt(x, y)); - case DIR_SOUTH: - MoveCoords(DIR_SOUTH, &x, &y); - return MetatileBehavior_IsRockStairs(MapGridGetMetatileBehaviorAt(x, y)); - default: - return FALSE; - } - #else - return FALSE; - #endif -} - static u8 CheckForPlayerAvatarCollision(u8 direction) { s16 x, y; @@ -745,42 +701,20 @@ u8 CheckForObjectEventCollision(struct ObjectEvent *objectEvent, s16 x, s16 y, u } //sideways stairs logic - if (direction == DIR_WEST || direction == DIR_EAST) - { - if (MetatileBehavior_IsSidewaysStairsLeftSide(metatileBehavior)) - { - //moving ONTO left side stair - if (direction == DIR_WEST && currentBehavior != metatileBehavior) - return collision; //moving onto top part of left-stair going left, so no diagonal - else - return COLLISION_SIDEWAYS_STAIRS_TO_LEFT; // move diagonally - } - else if (MetatileBehavior_IsSidewaysStairsRightSide(metatileBehavior)) - { - //moving ONTO right side stair - if (direction == DIR_EAST && currentBehavior != metatileBehavior) - return collision; //moving onto top part of right-stair going right, so no diagonal - else - return COLLISION_SIDEWAYS_STAIRS_TO_RIGHT; - } - else if (MetatileBehavior_IsSidewaysStairsLeftSideAny(currentBehavior)) - { - //moving OFF of any left side stair - if (direction == DIR_WEST && metatileBehavior != currentBehavior) - return COLLISION_SIDEWAYS_STAIRS_TO_LEFT; //moving off of left stairs onto non-stair -> move diagonal - else - return collision; //moving off of left side stair to east -> move east - } - else if (MetatileBehavior_IsSidewaysStairsRightSideAny(currentBehavior)) - { - //moving OFF of any right side stair - if (direction == DIR_EAST && metatileBehavior != currentBehavior) - return COLLISION_SIDEWAYS_STAIRS_TO_RIGHT; //moving off right stair onto non-stair -> move diagonal - else - return collision; - } - } - + /* + if (MetatileBehavior_IsSidewaysStairsLeftSideTop(metatileBehavior) && direction == DIR_EAST) + return COLLISION_IMPASSABLE; //moving onto left-side top edge east from ground -> cannot move + else if (MetatileBehavior_IsSidewaysStairsRightSideTop(metatileBehavior) && direction == DIR_WEST) + return COLLISION_IMPASSABLE; //moving onto left-side top edge east from ground -> cannot move + else if (MetatileBehavior_IsSidewaysStairsRightSideBottom(metatileBehavior) && (direction == DIR_EAST || direction == DIR_SOUTH)) + return COLLISION_IMPASSABLE; + else if (MetatileBehavior_IsSidewaysStairsLeftSideBottom(metatileBehavior) && (direction == DIR_WEST || direction == DIR_SOUTH)) + return COLLISION_IMPASSABLE; + else if ((MetatileBehavior_IsSidewaysStairsLeftSideTop(currentBehavior) || MetatileBehavior_IsSidewaysStairsRightSideTop(currentBehavior)) + && direction == DIR_NORTH && collision == COLLISION_NONE) + return COLLISION_IMPASSABLE; //trying to move north off of top-most tile onto same level doesn't work + */ + return collision; } @@ -961,7 +895,7 @@ static void PlayerAvatarTransition_Underwater(struct ObjectEvent *objEvent) ObjectEventSetGraphicsId(objEvent, GetPlayerAvatarGraphicsIdByStateId(PLAYER_AVATAR_STATE_UNDERWATER)); ObjectEventTurn(objEvent, objEvent->movementDirection); SetPlayerAvatarStateMask(PLAYER_AVATAR_FLAG_UNDERWATER); - objEvent->fieldEffectSpriteId = sub_8155800(objEvent->spriteId); + objEvent->fieldEffectSpriteId = DoBobbingFieldEffect(objEvent->spriteId); } static void PlayerAvatarTransition_ReturnToField(struct ObjectEvent *objEvent) @@ -1491,6 +1425,8 @@ void InitPlayerAvatar(s16 x, s16 y, u8 direction, u8 gender) gPlayerAvatar.spriteId = objectEvent->spriteId; gPlayerAvatar.gender = gender; SetPlayerAvatarStateMask(PLAYER_AVATAR_FLAG_5 | PLAYER_AVATAR_FLAG_ON_FOOT); + + CreateFollowerAvatar(); } void SetPlayerInvisibility(bool8 invisible) @@ -1730,12 +1666,14 @@ static void CreateStopSurfingTask(u8 direction) ScriptContext2_Enable(); Overworld_ClearSavedMusic(); Overworld_ChangeMusicToDefault(); - gPlayerAvatar.flags &= ~PLAYER_AVATAR_FLAG_SURFING; + gPlayerAvatar.flags ^= PLAYER_AVATAR_FLAG_SURFING; gPlayerAvatar.flags |= PLAYER_AVATAR_FLAG_ON_FOOT; gPlayerAvatar.preventStep = TRUE; taskId = CreateTask(Task_StopSurfingInit, 0xFF); gTasks[taskId].data[0] = direction; Task_StopSurfingInit(taskId); + + PrepareFollowerDismountSurf(); } static void Task_StopSurfingInit(u8 taskId) @@ -2350,22 +2288,3 @@ u8 GetLeftSideStairsDirection(u8 direction) } } -void PlayerSidewaysStairsRightSide(u8 direction) -{ - PlayerSetAnimId(GetDiagonalRightStairsMovement(direction), 8); -} - -void PlayerSidewaysStairsLeftSide(u8 direction) -{ - PlayerSetAnimId(GetDiagonalLeftStairsMovement(direction), 8); -} - -void PlayerSidewaysStairsRightSideRunning(u8 direction) -{ - PlayerSetAnimId(GetDiagonalRightStairsRunningMovement(direction), 8); -} - -void PlayerSidewaysStairsLeftSideRunning(u8 direction) -{ - PlayerSetAnimId(GetDiagonalLeftStairsRunningMovement(direction), 8); -} diff --git a/src/metatile_behavior.c b/src/metatile_behavior.c index 86e4ec98b3d6..ab5d6f288d81 100644 --- a/src/metatile_behavior.c +++ b/src/metatile_behavior.c @@ -1564,10 +1564,3 @@ bool8 MetatileBehavior_IsSidewaysStairsLeftSideAny(u8 metatileBehavior) return FALSE; } -bool8 MetatileBehavior_IsRockStairs(u8 metatileBehavior) -{ - if (metatileBehavior == MB_ROCK_STAIRS) - return TRUE; - else - return FALSE; -} From 598f5dd9140b90c5bd2d61941a2e24f2c6771646 Mon Sep 17 00:00:00 2001 From: Evan Date: Sun, 28 Jun 2020 17:22:59 -0600 Subject: [PATCH 09/27] cherry pick 8960588d0b0b9e31c8971173396f6e631930229b --- data/layouts/PetalburgCity/map.bin | Bin 1800 -> 1800 bytes src/event_object_movement.c | 18 +++++------------- src/field_control_avatar.c | 11 ++--------- src/field_effect_helpers.c | 2 +- src/field_player_avatar.c | 5 ----- 5 files changed, 8 insertions(+), 28 deletions(-) diff --git a/data/layouts/PetalburgCity/map.bin b/data/layouts/PetalburgCity/map.bin index 35f0172ca20a07e800bc248b803e740364a24715..46c808e0556b1a035ea9cc16f5e47fc0a64f20f5 100644 GIT binary patch delta 229 zcmeC+>)_k)fQcuACDQ={vsfliU=f+bEG5WjFoUVk0Rks5F&ZdL)@Ih`V>Flv7oEs7 zIfYpdC^U;Hn!!h%wkB9_T_m^DN$3M>@ZCBSF^k~q(B zo&hW&!2;4=zyh=>p)g?r6Hsjki=Mz-qZv#)Bs^E$W{(k1D*<&N+_&ine4)v!+3G?M%Hjf05ujtS^xk5 delta 232 zcmeC+>)_k)fQeVq5CIh@Z)6gl#4IHkWE5Tc zp%4~5o@b`dO%+%aS%g`XSSBYhiA-L^BF6)^(+Fboscript; - else - return GetFollowerScriptPointer(); + return GetObjectEventTemplateByLocalIdAndMap(localId, mapNum, mapGroup)->script; } const u8 *GetObjectEventScriptPointerByObjectEventId(u8 objectEventId) @@ -5029,7 +5024,7 @@ static bool8 DoesObjectCollideWithObjectAt(struct ObjectEvent *objectEvent, s16 for (i = 0; i < OBJECT_EVENTS_COUNT; i++) { curObject = &gObjectEvents[i]; - if (curObject->active && curObject != objectEvent && !FollowMe_IsCollisionExempt(curObject, objectEvent)) + if (curObject->active && curObject != objectEvent) { // check for collision if curObject is active, not the object in question, and not exempt from collisions if ((curObject->currentCoords.x == x && curObject->currentCoords.y == y) || (curObject->previousCoords.x == x && curObject->previousCoords.y == y)) @@ -5185,9 +5180,6 @@ bool8 ObjectEventSetHeldMovement(struct ObjectEvent *objectEvent, u8 movementAct objectEvent->heldMovementActive = TRUE; objectEvent->heldMovementFinished = FALSE; gSprites[objectEvent->spriteId].data[2] = 0; - - FollowMe(objectEvent, movementActionId, FALSE); - return FALSE; } diff --git a/src/field_control_avatar.c b/src/field_control_avatar.c index f0a7f708f8b4..9c24ee77eabe 100644 --- a/src/field_control_avatar.c +++ b/src/field_control_avatar.c @@ -28,7 +28,6 @@ #include "trainer_see.h" #include "trainer_hill.h" #include "wild_encounter.h" -#include "follow_me.h" #include "constants/event_bg.h" #include "constants/event_objects.h" #include "constants/field_poison.h" @@ -480,10 +479,10 @@ static const u8 *GetInteractedMetatileScript(struct MapPosition *position, u8 me static const u8 *GetInteractedWaterScript(struct MapPosition *unused1, u8 metatileBehavior, u8 direction) { - if (FlagGet(FLAG_BADGE05_GET) == TRUE && PartyHasMonWithSurf() == TRUE && IsPlayerFacingSurfableFishableWater() == TRUE && CheckFollowerFlag(FOLLOWER_FLAG_CAN_SURF)) + if (FlagGet(FLAG_BADGE05_GET) == TRUE && PartyHasMonWithSurf() == TRUE && IsPlayerFacingSurfableFishableWater() == TRUE) return EventScript_UseSurf; - if (MetatileBehavior_IsWaterfall(metatileBehavior) == TRUE && CheckFollowerFlag(FOLLOWER_FLAG_CAN_WATERFALL)) + if (MetatileBehavior_IsWaterfall(metatileBehavior) == TRUE) { if (FlagGet(FLAG_BADGE08_GET) == TRUE && IsPlayerSurfingNorth() == TRUE) return EventScript_UseWaterfall; @@ -495,9 +494,6 @@ static const u8 *GetInteractedWaterScript(struct MapPosition *unused1, u8 metati static bool32 TrySetupDiveDownScript(void) { - if (!CheckFollowerFlag(FOLLOWER_FLAG_CAN_DIVE)) - return FALSE; - if (FlagGet(FLAG_BADGE07_GET) && TrySetDiveWarp() == 2) { ScriptContext1_SetupScript(EventScript_UseDive); @@ -508,9 +504,6 @@ static bool32 TrySetupDiveDownScript(void) static bool32 TrySetupDiveEmergeScript(void) { - if (!CheckFollowerFlag(FOLLOWER_FLAG_CAN_DIVE)) - return FALSE; - if (FlagGet(FLAG_BADGE07_GET) && gMapHeader.mapType == MAP_TYPE_UNDERWATER && TrySetDiveWarp() == 1) { ScriptContext1_SetupScript(EventScript_UseDiveUnderwater); diff --git a/src/field_effect_helpers.c b/src/field_effect_helpers.c index 67102a83b2a6..e8e3dd6fe3e9 100755 --- a/src/field_effect_helpers.c +++ b/src/field_effect_helpers.c @@ -1081,7 +1081,7 @@ static void CreateBobbingEffect(struct ObjectEvent *objectEvent, struct Sprite * } } -u8 sub_8155800(u8 oldSpriteId) +u8 DoBobbingFieldEffect(u8 oldSpriteId) { u8 spriteId; struct Sprite *sprite; diff --git a/src/field_player_avatar.c b/src/field_player_avatar.c index f74b4f5a98a1..2d70fd2b1027 100644 --- a/src/field_player_avatar.c +++ b/src/field_player_avatar.c @@ -20,7 +20,6 @@ #include "strings.h" #include "task.h" #include "tv.h" -#include "follow_me.h" #include "wild_encounter.h" #include "constants/abilities.h" #include "constants/event_objects.h" @@ -1425,8 +1424,6 @@ void InitPlayerAvatar(s16 x, s16 y, u8 direction, u8 gender) gPlayerAvatar.spriteId = objectEvent->spriteId; gPlayerAvatar.gender = gender; SetPlayerAvatarStateMask(PLAYER_AVATAR_FLAG_5 | PLAYER_AVATAR_FLAG_ON_FOOT); - - CreateFollowerAvatar(); } void SetPlayerInvisibility(bool8 invisible) @@ -1672,8 +1669,6 @@ static void CreateStopSurfingTask(u8 direction) taskId = CreateTask(Task_StopSurfingInit, 0xFF); gTasks[taskId].data[0] = direction; Task_StopSurfingInit(taskId); - - PrepareFollowerDismountSurf(); } static void Task_StopSurfingInit(u8 taskId) From a23f716209b7e765030d2f58bb9adc72eeb4d522 Mon Sep 17 00:00:00 2001 From: Evan Date: Tue, 14 Jul 2020 14:28:02 -0600 Subject: [PATCH 10/27] add slow stair movement back --- include/constants/global.h | 2 + include/field_player_avatar.h | 2 +- include/metatile_behavior.h | 1 + src/bike.c | 12 ++++-- src/event_object_movement.c | 73 +++++++++++++++++------------------ src/field_player_avatar.c | 41 +++++++++++++++++++- src/metatile_behavior.c | 9 +++++ 7 files changed, 95 insertions(+), 45 deletions(-) diff --git a/include/constants/global.h b/include/constants/global.h index 213ccca5b54e..acc1f353d521 100644 --- a/include/constants/global.h +++ b/include/constants/global.h @@ -118,4 +118,6 @@ #define DIR_NORTHWEST 7 #define DIR_NORTHEAST 8 +#define SLOW_MOVEMENT_ON_STAIRS TRUE + #endif // GUARD_CONSTANTS_GLOBAL_H diff --git a/include/field_player_avatar.h b/include/field_player_avatar.h index 0f53e0b28d62..658dc09d0a6d 100644 --- a/include/field_player_avatar.h +++ b/include/field_player_avatar.h @@ -64,7 +64,7 @@ bool32 IsPlayerSpinExitActive(void); void SetPlayerInvisibility(bool8 invisible); u8 player_get_pos_including_state_based_drift(s16 *x, s16 *y); void StartFishing(u8 rod); -bool32 PlayerIsMovingOnRockStairs(u8 direction); +bool8 ObjectMovingOnRockStairs(struct ObjectEvent *objectEvent, u8 direction); //sideways stairs u8 GetRightSideStairsDirection(u8 direction); u8 GetLeftSideStairsDirection(u8 direction); diff --git a/include/metatile_behavior.h b/include/metatile_behavior.h index 128978cae6ae..58d6e82d7616 100644 --- a/include/metatile_behavior.h +++ b/include/metatile_behavior.h @@ -145,6 +145,7 @@ bool8 MetatileBehavior_IsQuestionnaire(u8); bool8 MetatileBehavior_IsLongGrass_Duplicate(u8); bool8 MetatileBehavior_IsLongGrassSouthEdge(u8); bool8 MetatileBehavior_IsTrainerHillTimer(u8); +bool8 MetatileBehavior_IsRockStairs(u8); //sideways stairs bool8 MetatileBehavior_IsSidewaysStairsRightSide(u8); bool8 MetatileBehavior_IsSidewaysStairsLeftSide(u8); diff --git a/src/bike.c b/src/bike.c index 1fe5b58b43a3..7c9eb0cf5ce6 100644 --- a/src/bike.c +++ b/src/bike.c @@ -246,6 +246,9 @@ static void MachBikeTransition_TrySpeedUp(u8 direction) } else { + if (ObjectMovingOnRockStairs(playerObjEvent, direction) && gPlayerAvatar.bikeFrameCounter > 1) + gPlayerAvatar.bikeFrameCounter--; + sMachBikeSpeedCallbacks[gPlayerAvatar.bikeFrameCounter](direction); gPlayerAvatar.bikeSpeed = gPlayerAvatar.bikeFrameCounter + (gPlayerAvatar.bikeFrameCounter >> 1); // same as dividing by 2, but compiler is insistent on >> 1 if (gPlayerAvatar.bikeFrameCounter < 2) // do not go faster than the last element in the mach bike array @@ -380,7 +383,6 @@ static u8 AcroBikeHandleInputWheelieStanding(u8 *newDirection, u16 newKeys, u16 struct ObjectEvent *playerObjEvent; direction = GetPlayerMovementDirection(); - //gSidewaysStairsDirection = direction; playerObjEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; gPlayerAvatar.runningState = NOT_MOVING; @@ -577,7 +579,10 @@ static void AcroBikeTransition_Moving(u8 direction) } else { - PlayerRideWaterCurrent(direction); + if (ObjectMovingOnRockStairs(playerObjEvent, direction)) + PlayerGoSpeed2(direction); + else + PlayerRideWaterCurrent(direction); } } @@ -645,7 +650,7 @@ static void AcroBikeTransition_WheelieHoppingMoving(u8 direction) } else { - derp: + derp: PlayerMovingHoppingWheelie(direction); } } @@ -1033,7 +1038,6 @@ void Bike_UpdateBikeCounterSpeed(u8 counter) static void Bike_SetBikeStill(void) { - //gSidewaysStairsDirection = gObjectEvents[gPlayerAvatar.objectEventId].facingDirection; gPlayerAvatar.bikeFrameCounter = 0; gPlayerAvatar.bikeSpeed = SPEED_STANDING; } diff --git a/src/event_object_movement.c b/src/event_object_movement.c index 16953880293a..fc13c966430f 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -135,7 +135,6 @@ static bool8 AnimateSpriteInFigure8(struct Sprite *sprite); static void UpdateObjectEventSprite(struct Sprite *); static void StartSlowRunningAnim(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 direction); -static bool8 npc_obj_ministep_stop_on_arrival_slow(struct ObjectEvent *objectEvent, struct Sprite *sprite); const u8 gReflectionEffectPaletteMap[] = {1, 1, 6, 7, 8, 9, 6, 7, 8, 9, 11, 11, 0, 0, 0, 0}; @@ -1142,6 +1141,10 @@ const u8 gRunSlowMovementActions[] = { [DIR_NORTH] = MOVEMENT_ACTION_RUN_UP_SLOW, [DIR_WEST] = MOVEMENT_ACTION_RUN_LEFT_SLOW, [DIR_EAST] = MOVEMENT_ACTION_RUN_RIGHT_SLOW, + [DIR_SOUTHWEST] = MOVEMENT_ACTION_RUN_LEFT_SLOW, + [DIR_SOUTHEAST] = MOVEMENT_ACTION_RUN_RIGHT_SLOW, + [DIR_NORTHWEST] = MOVEMENT_ACTION_RUN_LEFT_SLOW, + [DIR_NORTHEAST] = MOVEMENT_ACTION_RUN_RIGHT_SLOW, }; const u8 gOppositeDirections[] = { @@ -5170,10 +5173,35 @@ bool8 ObjectEventIsHeldMovementActive(struct ObjectEvent *objectEvent) return FALSE; } +static u8 TryUpdateMovementActionOnStairs(struct ObjectEvent *objectEvent, u8 movementActionId) +{ + if (objectEvent->isPlayer) + return movementActionId; //handled separately + + if (!ObjectMovingOnRockStairs(objectEvent, objectEvent->movementDirection)) + return movementActionId; + + switch (movementActionId) + { + case MOVEMENT_ACTION_WALK_NORMAL_DOWN: + return MOVEMENT_ACTION_WALK_SLOW_DOWN; + case MOVEMENT_ACTION_WALK_NORMAL_UP: + return MOVEMENT_ACTION_WALK_SLOW_UP; + case MOVEMENT_ACTION_WALK_NORMAL_LEFT: + return MOVEMENT_ACTION_WALK_SLOW_LEFT; + case MOVEMENT_ACTION_WALK_NORMAL_RIGHT: + return MOVEMENT_ACTION_WALK_SLOW_RIGHT; + default: + return movementActionId; + } +} + bool8 ObjectEventSetHeldMovement(struct ObjectEvent *objectEvent, u8 movementActionId) { if (ObjectEventIsMovementOverridden(objectEvent)) return TRUE; + + movementActionId = TryUpdateMovementActionOnStairs(objectEvent, movementActionId); UnfreezeObjectEvent(objectEvent); objectEvent->movementActionId = movementActionId; @@ -5185,6 +5213,7 @@ bool8 ObjectEventSetHeldMovement(struct ObjectEvent *objectEvent, u8 movementAct void ObjectEventForceSetHeldMovement(struct ObjectEvent *objectEvent, u8 movementActionId) { + movementActionId = TryUpdateMovementActionOnStairs(objectEvent, movementActionId); ObjectEventClearHeldMovementIfActive(objectEvent); ObjectEventSetHeldMovement(objectEvent, movementActionId); } @@ -5224,7 +5253,7 @@ u8 ObjectEventClearHeldMovementIfFinished(struct ObjectEvent *objectEvent) u8 ObjectEventGetHeldMovementActionId(struct ObjectEvent *objectEvent) { if (objectEvent->heldMovementActive) - return objectEvent->movementActionId; + return TryUpdateMovementActionOnStairs(objectEvent, objectEvent->movementActionId); return 0xFF; } @@ -5329,6 +5358,7 @@ static u32 state_to_direction(u8 a0, u32 a1, u32 a2) static void ObjectEventExecHeldMovementAction(struct ObjectEvent *objectEvent, struct Sprite *sprite) { + objectEvent->movementActionId = TryUpdateMovementActionOnStairs(objectEvent, objectEvent->movementActionId); if (gMovementActionFuncs[objectEvent->movementActionId][sprite->data[2]](objectEvent, sprite)) { objectEvent->heldMovementFinished = TRUE; @@ -5337,6 +5367,7 @@ static void ObjectEventExecHeldMovementAction(struct ObjectEvent *objectEvent, s static bool8 ObjectEventExecSingleMovementAction(struct ObjectEvent *objectEvent, struct Sprite *sprite) { + objectEvent->movementActionId = TryUpdateMovementActionOnStairs(objectEvent, objectEvent->movementActionId); if (gMovementActionFuncs[objectEvent->movementActionId][sprite->data[2]](objectEvent, sprite)) { objectEvent->movementActionId = 0xFF; @@ -5348,7 +5379,7 @@ static bool8 ObjectEventExecSingleMovementAction(struct ObjectEvent *objectEvent static void ObjectEventSetSingleMovement(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 animId) { - objectEvent->movementActionId = animId; + objectEvent->movementActionId = TryUpdateMovementActionOnStairs(objectEvent, animId); sprite->data[2] = 0; } @@ -9359,40 +9390,6 @@ static void StartSlowRunningAnim(struct ObjectEvent *objectEvent, struct Sprite npc_apply_anim_looping(objectEvent, sprite, GetRunningDirectionAnimNum(objectEvent->facingDirection)); } -#define tDirection data[3] -#define tDelay data[4] -#define tStepNo data[5] -static bool8 obj_npc_ministep_slow(struct Sprite *sprite) -{ - if ((++sprite->tDelay) & 1) - { - Step1(sprite, sprite->tDirection); - sprite->tStepNo++; - } - else - { - Step2(sprite, sprite->tDirection); - sprite->tStepNo += 2; - } - - if (sprite->tStepNo > 15) - return TRUE; - else - return FALSE; -} -static bool8 npc_obj_ministep_stop_on_arrival_slow(struct ObjectEvent *objectEvent, struct Sprite *sprite) -{ - if (obj_npc_ministep_slow(sprite)) - { - ShiftStillObjectEventCoords(objectEvent); - objectEvent->triggerGroundEffectsOnStop = TRUE; - sprite->animPaused = TRUE; - return TRUE; - } - return FALSE; -} - - bool8 MovementActionFunc_RunSlowDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { StartSlowRunningAnim(objectEvent, sprite, DIR_SOUTH); @@ -9425,7 +9422,7 @@ bool8 MovementActionFunc_RunSlowRight_Step0(struct ObjectEvent *objectEvent, str bool8 MovementActionFunc_RunSlow_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (npc_obj_ministep_stop_on_arrival_slow(objectEvent, sprite)) + if (npc_obj_ministep_stop_on_arrival(objectEvent, sprite)) { sprite->data[2] = 2; return TRUE; diff --git a/src/field_player_avatar.c b/src/field_player_avatar.c index 2d70fd2b1027..19e3fb486959 100644 --- a/src/field_player_avatar.c +++ b/src/field_player_avatar.c @@ -643,13 +643,20 @@ static void PlayerNotOnBikeMoving(u8 direction, u16 heldKeys) if (!(gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_UNDERWATER) && (heldKeys & B_BUTTON) && FlagGet(FLAG_SYS_B_DASH) && IsRunningDisallowed(gObjectEvents[gPlayerAvatar.objectEventId].currentMetatileBehavior) == 0) { - PlayerRun(direction); + if (ObjectMovingOnRockStairs(&gObjectEvents[gPlayerAvatar.objectEventId], direction)) + PlayerRunSlow(direction); + else + PlayerRun(direction); + gPlayerAvatar.flags |= PLAYER_AVATAR_FLAG_DASH; return; } else { - PlayerGoSpeed1(direction); + if (ObjectMovingOnRockStairs(&gObjectEvents[gPlayerAvatar.objectEventId], direction)) + PlayerGoSlow(direction); + else + PlayerGoSpeed1(direction); } } @@ -2283,3 +2290,33 @@ u8 GetLeftSideStairsDirection(u8 direction) } } +bool8 ObjectMovingOnRockStairs(struct ObjectEvent *objectEvent, u8 direction) +{ + #if SLOW_MOVEMENT_ON_STAIRS + s16 x = objectEvent->currentCoords.x; + s16 y = objectEvent->currentCoords.y; + + switch (direction) + { + case DIR_NORTH: + return MetatileBehavior_IsRockStairs(MapGridGetMetatileBehaviorAt(x,y)); + case DIR_SOUTH: + MoveCoords(DIR_SOUTH, &x, &y); + return MetatileBehavior_IsRockStairs(MapGridGetMetatileBehaviorAt(x,y)); + case DIR_WEST: + case DIR_EAST: + case DIR_NORTHEAST: + case DIR_NORTHWEST: + case DIR_SOUTHWEST: + case DIR_SOUTHEAST: + // directionOverwrite is only used for sideways stairs motion + if (objectEvent->directionOverwrite) + return TRUE; + default: + return FALSE; + } + #else + return FALSE; + #endif +} + diff --git a/src/metatile_behavior.c b/src/metatile_behavior.c index ab5d6f288d81..ea397ab91da1 100644 --- a/src/metatile_behavior.c +++ b/src/metatile_behavior.c @@ -1564,3 +1564,12 @@ bool8 MetatileBehavior_IsSidewaysStairsLeftSideAny(u8 metatileBehavior) return FALSE; } +bool8 MetatileBehavior_IsRockStairs(u8 metatileBehavior) +{ + if (metatileBehavior == MB_ROCK_STAIRS) + return TRUE; + else + return FALSE; +} + + From 397da3736c400a72c64bb9d9b8f495523ad01299 Mon Sep 17 00:00:00 2001 From: Evan Date: Mon, 17 Aug 2020 13:53:36 -0600 Subject: [PATCH 11/27] follower movement and slow stairs --- include/constants/global.h | 1 + src/event_object_movement.c | 9 +++++++-- src/field_player_avatar.c | 5 +++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/include/constants/global.h b/include/constants/global.h index acc1f353d521..64342170959d 100644 --- a/include/constants/global.h +++ b/include/constants/global.h @@ -119,5 +119,6 @@ #define DIR_NORTHEAST 8 #define SLOW_MOVEMENT_ON_STAIRS TRUE +#define FOLLOW_ME_IMPLEMENTED TRUE //for stairs movement. see ObjectMovingOnRockStairs in src/field_player_avatar.c #endif // GUARD_CONSTANTS_GLOBAL_H diff --git a/src/event_object_movement.c b/src/event_object_movement.c index fc13c966430f..54252db1e7c9 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -5175,8 +5175,13 @@ bool8 ObjectEventIsHeldMovementActive(struct ObjectEvent *objectEvent) static u8 TryUpdateMovementActionOnStairs(struct ObjectEvent *objectEvent, u8 movementActionId) { - if (objectEvent->isPlayer) - return movementActionId; //handled separately + #if FOLLOW_ME_IMPLEMENTED + if (objectEvent->isPlayer || objectEvent->localId == GetFollowerLocalId()) + return movementActionId; //handled separately + #else + if (objectEvent->isPlayer) + return movementActionId; //handled separately + #endif if (!ObjectMovingOnRockStairs(objectEvent, objectEvent->movementDirection)) return movementActionId; diff --git a/src/field_player_avatar.c b/src/field_player_avatar.c index 19e3fb486959..5ef8a0ae2cd5 100644 --- a/src/field_player_avatar.c +++ b/src/field_player_avatar.c @@ -2296,6 +2296,11 @@ bool8 ObjectMovingOnRockStairs(struct ObjectEvent *objectEvent, u8 direction) s16 x = objectEvent->currentCoords.x; s16 y = objectEvent->currentCoords.y; + #if FOLLOW_ME_IMPLEMENTED + if (PlayerHasFollower() && (objectEvent->isPlayer || objectEvent->localId == GetFollowerLocalId())) + return FALSE; + #endif + switch (direction) { case DIR_NORTH: From 01d08d3ceeccec0a6d2f8fc848fa0655aec63f38 Mon Sep 17 00:00:00 2001 From: Evan Date: Sat, 22 Aug 2020 15:25:41 -0600 Subject: [PATCH 12/27] fix sand onto sideways stairs bug --- include/constants/global.h | 2 +- src/event_object_movement.c | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/include/constants/global.h b/include/constants/global.h index 64342170959d..d99ff1392b9c 100644 --- a/include/constants/global.h +++ b/include/constants/global.h @@ -119,6 +119,6 @@ #define DIR_NORTHEAST 8 #define SLOW_MOVEMENT_ON_STAIRS TRUE -#define FOLLOW_ME_IMPLEMENTED TRUE //for stairs movement. see ObjectMovingOnRockStairs in src/field_player_avatar.c +#define FOLLOW_ME_IMPLEMENTED FALSE //for stairs movement. see ObjectMovingOnRockStairs in src/field_player_avatar.c #endif // GUARD_CONSTANTS_GLOBAL_H diff --git a/src/event_object_movement.c b/src/event_object_movement.c index 54252db1e7c9..88b269da6e21 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -7900,12 +7900,17 @@ static void GetGroundEffectFlags_LongGrassOnBeginStep(struct ObjectEvent *objEve static void GetGroundEffectFlags_Tracks(struct ObjectEvent *objEvent, u32 *flags) { - if (MetatileBehavior_IsDeepSand(objEvent->previousMetatileBehavior)) + u8 behavior = objEvent->previousMetatileBehavior; + + if (objEvent->directionOverwrite) + return; + + if (MetatileBehavior_IsDeepSand(behavior)) { *flags |= GROUND_EFFECT_FLAG_DEEP_SAND; } - else if (MetatileBehavior_IsSandOrDeepSand(objEvent->previousMetatileBehavior) - || MetatileBehavior_IsFootprints(objEvent->previousMetatileBehavior)) + else if (MetatileBehavior_IsSandOrDeepSand(behavior) + || MetatileBehavior_IsFootprints(behavior)) { *flags |= GROUND_EFFECT_FLAG_SAND; } From 7b9f308547d16ce850cdbc2d26e5bb2bc1035037 Mon Sep 17 00:00:00 2001 From: Evan Date: Tue, 26 Jan 2021 12:26:56 -0700 Subject: [PATCH 13/27] fix trigger tiles at end of sideways stairs (thx spherical ice for bug report) --- src/scrcmd.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/scrcmd.c b/src/scrcmd.c index 7dc02b6a8f0f..b9c2d942a3ce 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -998,6 +998,7 @@ bool8 ScrCmd_applymovement(struct ScriptContext *ctx) u16 localId = VarGet(ScriptReadHalfword(ctx)); const void *movementScript = (const void *)ScriptReadWord(ctx); + gObjectEvents[GetObjectEventIdByLocalId(localId)].directionOverwrite = DIR_NONE ScriptMovement_StartObjectMovementScript(localId, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, movementScript); sMovingNpcId = localId; return FALSE; @@ -1010,6 +1011,7 @@ bool8 ScrCmd_applymovement_at(struct ScriptContext *ctx) u8 mapGroup = ScriptReadByte(ctx); u8 mapNum = ScriptReadByte(ctx); + gObjectEvents[GetObjectEventIdByLocalId(localId)].directionOverwrite = DIR_NONE ScriptMovement_StartObjectMovementScript(localId, mapNum, mapGroup, movementScript); sMovingNpcId = localId; return FALSE; From 13c5f15e56badc35c9272877c1d7706ef88a100c Mon Sep 17 00:00:00 2001 From: Evan Date: Tue, 26 Jan 2021 12:29:08 -0700 Subject: [PATCH 14/27] cherry pick 53731a7fc7579e61d5ee7d32d0e06f1cbe5a085d --- include/event_object_movement.h | 11 ++++++----- src/event_object_movement.c | 3 +-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/event_object_movement.h b/include/event_object_movement.h index 61e7c5d6c2a0..e9b00d1214be 100644 --- a/include/event_object_movement.h +++ b/include/event_object_movement.h @@ -427,11 +427,12 @@ u8 MovementType_Invisible_Step0(struct ObjectEvent *, struct Sprite *); u8 MovementType_Invisible_Step1(struct ObjectEvent *, struct Sprite *); u8 MovementType_Invisible_Step2(struct ObjectEvent *, struct Sprite *); -void SetObjectEventSpriteInvisibility(u8 objectEventId, bool32 invisible); -bool32 IsObjectEventSpriteInvisible(u8 objectEventId); -void SetObjectEventSpriteGraphics(u8 objectEventId, u8 graphicsId); -void SetObjectEventSpriteAnim(u8 objectEventId, u8 animNum); -bool32 IsObjectEventSpriteAnimating(u8 objectEventId); +void SetObjectEventSpriteInvisibility(u8 var, bool32 var2); +bool32 IsObjectEventSpriteInvisible(u8 var); +void SetObjectEventSpriteGraphics(u8 var1, u8 graphicsId); +void SetObjectEventSpriteAnim(u8 var1, u8 var2); +bool32 IsObjectEventSpriteAnimating(u8 var); +u8 GetObjectEventIdByLocalId(u8 localId); // NEW u16 GetMiniStepCount(u8 speed); diff --git a/src/event_object_movement.c b/src/event_object_movement.c index 88b269da6e21..4cc404d35435 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -103,7 +103,6 @@ static void ApplyLevitateMovement(u8); static bool8 MovementType_Disguise_Callback(struct ObjectEvent *, struct Sprite *); static bool8 MovementType_Buried_Callback(struct ObjectEvent *, struct Sprite *); static void CreateReflectionEffectSprites(void); -static u8 GetObjectEventIdByLocalId(u8); static u8 GetObjectEventIdByLocalIdAndMapInternal(u8, u8, u8); static bool8 GetAvailableObjectEventId(u16, u8, u8, u8 *); static void SetObjectEventDynamicGraphicsId(struct ObjectEvent *); @@ -1270,7 +1269,7 @@ static u8 GetObjectEventIdByLocalIdAndMapInternal(u8 localId, u8 mapNum, u8 mapG return OBJECT_EVENTS_COUNT; } -static u8 GetObjectEventIdByLocalId(u8 localId) +u8 GetObjectEventIdByLocalId(u8 localId) { u8 i; for (i = 0; i < OBJECT_EVENTS_COUNT; i++) From 09c5e27a90d4bea780ffd799bd3ed55550f88493 Mon Sep 17 00:00:00 2001 From: Evan Date: Tue, 26 Jan 2021 12:30:02 -0700 Subject: [PATCH 15/27] syntax fix --- src/scrcmd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/scrcmd.c b/src/scrcmd.c index b9c2d942a3ce..2acad7a79581 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -998,7 +998,7 @@ bool8 ScrCmd_applymovement(struct ScriptContext *ctx) u16 localId = VarGet(ScriptReadHalfword(ctx)); const void *movementScript = (const void *)ScriptReadWord(ctx); - gObjectEvents[GetObjectEventIdByLocalId(localId)].directionOverwrite = DIR_NONE + gObjectEvents[GetObjectEventIdByLocalId(localId)].directionOverwrite = DIR_NONE; ScriptMovement_StartObjectMovementScript(localId, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, movementScript); sMovingNpcId = localId; return FALSE; @@ -1011,7 +1011,7 @@ bool8 ScrCmd_applymovement_at(struct ScriptContext *ctx) u8 mapGroup = ScriptReadByte(ctx); u8 mapNum = ScriptReadByte(ctx); - gObjectEvents[GetObjectEventIdByLocalId(localId)].directionOverwrite = DIR_NONE + gObjectEvents[GetObjectEventIdByLocalId(localId)].directionOverwrite = DIR_NONE; ScriptMovement_StartObjectMovementScript(localId, mapNum, mapGroup, movementScript); sMovingNpcId = localId; return FALSE; From 42cc81a0b9b984143aa564b205b4b3ae58ed6753 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Thu, 1 Apr 2021 20:26:21 -0600 Subject: [PATCH 16/27] DoBobbingFieldEffect declaration --- include/field_effect_helpers.h | 2 +- src/field_effect_helpers.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/field_effect_helpers.h b/include/field_effect_helpers.h index 9b7b6ffd5c4d..6ed0df4c3518 100644 --- a/include/field_effect_helpers.h +++ b/include/field_effect_helpers.h @@ -7,7 +7,7 @@ // Exported ROM declarations u8 CreateWarpArrowSprite(void); -u8 sub_8155800(u8 oldSpriteId); +u8 DoBobbingFieldEffect(u8 oldSpriteId); void SetSurfBobState(u8 spriteId, u8 value); void SetSurfBobWhileFlyingOutState(u8 spriteId, u8 value); void SetSurfBobWhileFishingState(u8 spriteId, u8 value, s16 data1); diff --git a/src/field_effect_helpers.c b/src/field_effect_helpers.c index e8e3dd6fe3e9..d2cc1887a325 100755 --- a/src/field_effect_helpers.c +++ b/src/field_effect_helpers.c @@ -29,7 +29,7 @@ static void UpdateAshFieldEffect_Step2(struct Sprite *); static void SynchroniseSurfAnim(struct ObjectEvent *, struct Sprite *); static void sub_81556E8(struct ObjectEvent *, struct Sprite *); static void CreateBobbingEffect(struct ObjectEvent *, struct Sprite *, struct Sprite *); -static void sub_8155850(struct Sprite *); +static void BobbingEffectSpriteCallback(struct Sprite *); static u32 ShowDisguiseFieldEffect(u8, u8, u8); #define sReflectionObjEventId data[0] @@ -1088,14 +1088,14 @@ u8 DoBobbingFieldEffect(u8 oldSpriteId) spriteId = CreateSpriteAtEnd(&gDummySpriteTemplate, 0, 0, -1); sprite = &gSprites[spriteId]; - sprite->callback = sub_8155850; + sprite->callback = BobbingEffectSpriteCallback; sprite->invisible = TRUE; sprite->data[0] = oldSpriteId; sprite->data[1] = 1; return spriteId; } -static void sub_8155850(struct Sprite *sprite) +static void BobbingEffectSpriteCallback(struct Sprite *sprite) { struct Sprite *oldSprite; From e0ee7ce4844198218165afe3cd7102cfd3070f17 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Thu, 20 May 2021 15:45:13 -0600 Subject: [PATCH 17/27] fix bike tire tracks off sideways stairs --- src/event_object_movement.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/event_object_movement.c b/src/event_object_movement.c index f976dfc68e0d..e2205c09f4d6 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -8313,12 +8313,13 @@ static void DoTracksGroundEffect_BikeTireTracks(struct ObjectEvent *objEvent, st if (objEvent->currentCoords.x != objEvent->previousCoords.x || objEvent->currentCoords.y != objEvent->previousCoords.y) { + u8 movementDir = (objEvent->previousMovementDirection > DIR_EAST) ? (objEvent->previousMovementDirection - DIR_EAST) : objEvent->previousMovementDirection; gFieldEffectArguments[0] = objEvent->previousCoords.x; gFieldEffectArguments[1] = objEvent->previousCoords.y; gFieldEffectArguments[2] = 149; gFieldEffectArguments[3] = 2; gFieldEffectArguments[4] = - bikeTireTracks_Transitions[objEvent->previousMovementDirection][objEvent->facingDirection - 5]; + bikeTireTracks_Transitions[movementDir][objEvent->facingDirection - 5]; FieldEffectStart(FLDEFF_BIKE_TIRE_TRACKS); } } From 70026f2558cf7d463da8d6b8eb03590b6350e7d4 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Thu, 7 Apr 2022 12:24:07 -0400 Subject: [PATCH 18/27] fix tile attributes for sideways stairs behaviors --- src/metatile_behavior.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/metatile_behavior.c b/src/metatile_behavior.c index ad674390c80f..339c2ae468b7 100644 --- a/src/metatile_behavior.c +++ b/src/metatile_behavior.c @@ -66,13 +66,13 @@ static const u8 sTileBitAttributes[NUM_METATILE_BEHAVIORS] = [MB_SLIDE_NORTH] = TILE_FLAG_UNUSED, [MB_SLIDE_SOUTH] = TILE_FLAG_UNUSED, [MB_TRICK_HOUSE_PUZZLE_8_FLOOR] = TILE_FLAG_UNUSED, - [MB_SIDEWAYS_STAIRS_RIGHT_SIDE] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE), - [MB_SIDEWAYS_STAIRS_LEFT_SIDE] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE), - [MB_SIDEWAYS_STAIRS_RIGHT_SIDE_TOP] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE), - [MB_SIDEWAYS_STAIRS_LEFT_SIDE_TOP] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE), - [MB_SIDEWAYS_STAIRS_RIGHT_SIDE_BOTTOM] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE), - [MB_SIDEWAYS_STAIRS_LEFT_SIDE_BOTTOM] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE), - [MB_ROCK_STAIRS] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + [MB_SIDEWAYS_STAIRS_RIGHT_SIDE] = TILE_FLAG_UNUSED, + [MB_SIDEWAYS_STAIRS_LEFT_SIDE] = TILE_FLAG_UNUSED, + [MB_SIDEWAYS_STAIRS_RIGHT_SIDE_TOP] = TILE_FLAG_UNUSED, + [MB_SIDEWAYS_STAIRS_LEFT_SIDE_TOP] = TILE_FLAG_UNUSED, + [MB_SIDEWAYS_STAIRS_RIGHT_SIDE_BOTTOM] = TILE_FLAG_UNUSED, + [MB_SIDEWAYS_STAIRS_LEFT_SIDE_BOTTOM] = TILE_FLAG_UNUSED, + [MB_ROCK_STAIRS] = TILE_FLAG_UNUSED, [MB_EASTWARD_CURRENT] = TILE_FLAG_UNUSED | TILE_FLAG_SURFABLE, [MB_WESTWARD_CURRENT] = TILE_FLAG_UNUSED | TILE_FLAG_SURFABLE, [MB_NORTHWARD_CURRENT] = TILE_FLAG_UNUSED | TILE_FLAG_SURFABLE, From e52349b474a58928acba5145e8f596cc13bbc675 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Mon, 22 May 2023 12:28:32 -0400 Subject: [PATCH 19/27] fix missed conflict --- include/event_object_movement.h | 6 ------ src/event_object_movement.c | 5 +++-- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/include/event_object_movement.h b/include/event_object_movement.h index e636fd032d2d..dc3b4852ed14 100644 --- a/include/event_object_movement.h +++ b/include/event_object_movement.h @@ -214,13 +214,7 @@ s16 GetFigure8YOffset(s16 idx); void CameraObjectReset2(void); u8 GetObjectEventBerryTreeId(u8 objectEventId); void SetBerryTreeJustPicked(u8 mapId, u8 mapNumber, u8 mapGroup); -<<<<<<< HEAD -bool8 IsBerryTreeSparkling(u8, u8, u8); -struct ObjectEventTemplate *GetObjectEventTemplateByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup); -u8 TrySpawnObjectEventTemplate(struct ObjectEventTemplate *objectEventTemplate, u8 mapNum, u8 mapGroup, s16 cameraX, s16 cameraY); -======= bool8 IsBerryTreeSparkling(u8 localId, u8 mapNum, u8 mapGroup); ->>>>>>> 73a6a583b3706979e1a15976e30270984f1f0c26 void MovementType_None(struct Sprite *); void MovementType_LookAround(struct Sprite *); diff --git a/src/event_object_movement.c b/src/event_object_movement.c index 084f8760cd54..1bf74a78185f 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -133,6 +133,7 @@ static u16 GetObjectEventFlagIdByObjectEventId(u8); static void UpdateObjectEventVisibility(struct ObjectEvent *, struct Sprite *); static void MakeSpriteTemplateFromObjectEventTemplate(const struct ObjectEventTemplate *, struct SpriteTemplate *, const struct SubspriteTable **); static void GetObjectEventMovingCameraOffset(s16 *, s16 *); +static const struct ObjectEventTemplate *GetObjectEventTemplateByLocalIdAndMap(u8, u8, u8); static void LoadObjectEventPalette(u16); static void RemoveObjectEventIfOutsideView(struct ObjectEvent *); static void SpawnObjectEventOnReturnToField(u8, s16, s16); @@ -1535,7 +1536,7 @@ static u8 TrySetupObjectEventSprite(const struct ObjectEventTemplate *objectEven return objectEventId; } -u8 TrySpawnObjectEventTemplate(const struct ObjectEventTemplate *objectEventTemplate, u8 mapNum, u8 mapGroup, s16 cameraX, s16 cameraY) +static u8 TrySpawnObjectEventTemplate(const struct ObjectEventTemplate *objectEventTemplate, u8 mapNum, u8 mapGroup, s16 cameraX, s16 cameraY) { u8 objectEventId; struct SpriteTemplate spriteTemplate; @@ -2498,7 +2499,7 @@ u8 GetObjectEventBerryTreeId(u8 objectEventId) return gObjectEvents[objectEventId].trainerRange_berryTreeId; } -struct ObjectEventTemplate *GetObjectEventTemplateByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup) +static const struct ObjectEventTemplate *GetObjectEventTemplateByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup) { const struct ObjectEventTemplate *templates; const struct MapHeader *mapHeader; From d80cf0a193711b8d8c902b50f9cd286f4acc7b8a Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Wed, 24 May 2023 20:48:11 -0400 Subject: [PATCH 20/27] fix exiting sideways stairs onto ice. thanks to Agustin --- src/field_player_avatar.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/field_player_avatar.c b/src/field_player_avatar.c index 44fe6e0c6e0e..db793d10c0e0 100644 --- a/src/field_player_avatar.c +++ b/src/field_player_avatar.c @@ -444,7 +444,22 @@ static bool8 ForcedMovement_None(void) static bool8 DoForcedMovement(u8 direction, void (*moveFunc)(u8)) { struct PlayerAvatar *playerAvatar = &gPlayerAvatar; - u8 collision = CheckForPlayerAvatarCollision(direction); + u8 collision; + + // Check for sideways stairs onto ice movement. + switch (direction) + { + case DIR_NORTHWEST: + case DIR_SOUTHWEST: + direction = DIR_WEST; + break; + case DIR_NORTHEAST: + case DIR_SOUTHEAST: + direction = DIR_EAST; + break; + } + + collision = CheckForPlayerAvatarCollision(direction); playerAvatar->flags |= PLAYER_AVATAR_FLAG_FORCED_MOVE; if (collision) From b3f9c8bf7c51f28275e62da7ed413c3354ca9fb8 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Wed, 19 Jun 2024 10:25:44 -0400 Subject: [PATCH 21/27] GetSidewaysStairsCollision cant descend stairs into water --- src/event_object_movement.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/event_object_movement.c b/src/event_object_movement.c index 1bf74a78185f..a9147902c956 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -4732,6 +4732,10 @@ u8 GetSidewaysStairsCollision(struct ObjectEvent *objectEvent, u8 dir, u8 curren if ((dir == DIR_SOUTH || dir == DIR_NORTH) && collision != COLLISION_NONE) return collision; + // cant descend stairs into water + if (MetatileBehavior_IsSurfableFishableWater(nextBehavior)) + return collision; + if (MetatileBehavior_IsSidewaysStairsLeftSide(nextBehavior)) { //moving ONTO left side stair From 8a6407b6bc9301b1d0e2c5fd0b0631ffd65e8ba7 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Wed, 19 Jun 2024 12:30:09 -0400 Subject: [PATCH 22/27] fix warning --- src/event_object_movement.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/event_object_movement.c b/src/event_object_movement.c index df5c4fd14b91..212280d7b888 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -6069,7 +6069,6 @@ static bool8 ObjectEventOnRightSideStair(struct ObjectEvent *objectEvent, s16 x, u8 GetCollisionAtCoords(struct ObjectEvent *objectEvent, s16 x, s16 y, u32 dir) { - u8 direction = dir; u8 currentBehavior = MapGridGetMetatileBehaviorAt(objectEvent->currentCoords.x, objectEvent->currentCoords.y); u8 nextBehavior = MapGridGetMetatileBehaviorAt(x, y); u8 collision; From e864b686c7d3119bf2fcdf81227ee81bb38a92bc Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Wed, 19 Jun 2024 12:45:36 -0400 Subject: [PATCH 23/27] fix another warning --- src/field_player_avatar.c | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/src/field_player_avatar.c b/src/field_player_avatar.c index 42000c5673f2..2819e2784614 100644 --- a/src/field_player_avatar.c +++ b/src/field_player_avatar.c @@ -713,7 +713,6 @@ static u8 CheckForPlayerAvatarStaticCollision(u8 direction) u8 CheckForObjectEventCollision(struct ObjectEvent *objectEvent, s16 x, s16 y, u8 direction, u8 metatileBehavior) { u8 collision = GetCollisionAtCoords(objectEvent, x, y, direction); - u8 currentBehavior = MapGridGetMetatileBehaviorAt(objectEvent->currentCoords.x, objectEvent->currentCoords.y); if (collision == COLLISION_ELEVATION_MISMATCH && CanStopSurfing(x, y, direction)) return COLLISION_STOP_SURFING; @@ -733,21 +732,6 @@ u8 CheckForObjectEventCollision(struct ObjectEvent *objectEvent, s16 x, s16 y, u CheckAcroBikeCollision(x, y, metatileBehavior, &collision); } - //sideways stairs logic - /* - if (MetatileBehavior_IsSidewaysStairsLeftSideTop(metatileBehavior) && direction == DIR_EAST) - return COLLISION_IMPASSABLE; //moving onto left-side top edge east from ground -> cannot move - else if (MetatileBehavior_IsSidewaysStairsRightSideTop(metatileBehavior) && direction == DIR_WEST) - return COLLISION_IMPASSABLE; //moving onto left-side top edge east from ground -> cannot move - else if (MetatileBehavior_IsSidewaysStairsRightSideBottom(metatileBehavior) && (direction == DIR_EAST || direction == DIR_SOUTH)) - return COLLISION_IMPASSABLE; - else if (MetatileBehavior_IsSidewaysStairsLeftSideBottom(metatileBehavior) && (direction == DIR_WEST || direction == DIR_SOUTH)) - return COLLISION_IMPASSABLE; - else if ((MetatileBehavior_IsSidewaysStairsLeftSideTop(currentBehavior) || MetatileBehavior_IsSidewaysStairsRightSideTop(currentBehavior)) - && direction == DIR_NORTH && collision == COLLISION_NONE) - return COLLISION_IMPASSABLE; //trying to move north off of top-most tile onto same level doesn't work - */ - return collision; } From 0cffe4a96aa34e7c3a28a10e2b51c692a7b85e87 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Mon, 8 Jul 2024 14:08:15 -0400 Subject: [PATCH 24/27] syntax fixes, turn slow movement on rock stairs default off, remove petalburg layout change --- data/layouts/PetalburgCity/map.bin | Bin 1800 -> 1800 bytes include/config/overworld.h | 2 +- src/bike.c | 3 +- .../movement_action_func_tables.h | 4 - src/field_player_avatar.c | 6 +- src/metatile_behavior.c | 232 +++++++++--------- 6 files changed, 120 insertions(+), 127 deletions(-) diff --git a/data/layouts/PetalburgCity/map.bin b/data/layouts/PetalburgCity/map.bin index 46c808e0556b1a035ea9cc16f5e47fc0a64f20f5..35f0172ca20a07e800bc248b803e740364a24715 100644 GIT binary patch delta 232 zcmeC+>)_k)fQeVq5CIh@Z)6gl#4IHkWE5Tc zp%4~5o@b`dO%+%aS%g`XSSBYhiA-L^BF6)^(+Fbo)_k)fQcuACDQ={vsfliU=f+bEG5WjFoUVk0Rks5F&ZdL)@Ih`V>Flv7oEs7 zIfYpdC^U;Hn!!h%wkB9_T_m^DN$3M>@ZCBSF^k~q(B zo&hW&!2;4=zyh=>p)g?r6Hsjki=Mz-qZv#)Bs^E$W{(k1D*<&N+_&ine4)v!+3G?M%Hjf05ujtS^xk5 diff --git a/include/config/overworld.h b/include/config/overworld.h index fc6865f53fe0..6fa0ec9c9859 100644 --- a/include/config/overworld.h +++ b/include/config/overworld.h @@ -3,7 +3,7 @@ // Movement config #define OW_RUNNING_INDOORS GEN_LATEST // In Gen4+, players are allowed to run indoors. -#define SLOW_MOVEMENT_ON_STAIRS TRUE // If enabled, the player will move slower up/down stairs like in FR +#define SLOW_MOVEMENT_ON_STAIRS FALSE // If enabled, the player will move slower up/down stairs like in FR // 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. diff --git a/src/bike.c b/src/bike.c index 1cfecfe15239..427dfdfcf246 100644 --- a/src/bike.c +++ b/src/bike.c @@ -206,7 +206,7 @@ static void MachBikeTransition_TurnDirection(u8 direction) Bike_SetBikeStill(); } else - { + { MachBikeTransition_FaceDirection(playerObjEvent->facingDirection); } } @@ -246,6 +246,7 @@ static void MachBikeTransition_TrySpeedUp(u8 direction) } else { + // we did not hit anything that can slow us down, so perform the advancement callback depending on the bikeFrameCounter and try to increase the mach bike's speed. if (ObjectMovingOnRockStairs(playerObjEvent, direction) && gPlayerAvatar.bikeFrameCounter > 1) gPlayerAvatar.bikeFrameCounter--; diff --git a/src/data/object_events/movement_action_func_tables.h b/src/data/object_events/movement_action_func_tables.h index 0ee3e78afc08..dda5ff399171 100755 --- a/src/data/object_events/movement_action_func_tables.h +++ b/src/data/object_events/movement_action_func_tables.h @@ -266,7 +266,6 @@ u8 MovementAction_FlyUp_Step1(struct ObjectEvent *, struct Sprite *); u8 MovementAction_Fly_Finish(struct ObjectEvent *, struct Sprite *); u8 MovementAction_FlyDown_Step0(struct ObjectEvent *, struct Sprite *); u8 MovementAction_FlyDown_Step1(struct ObjectEvent *, struct Sprite *); -//slow running u8 MovementActionFunc_RunSlowDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite); u8 MovementActionFunc_RunSlowUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite); u8 MovementActionFunc_RunSlowLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite); @@ -435,7 +434,6 @@ u8 (*const gMovementActionFuncs_FlyUp[])(struct ObjectEvent *, struct Sprite *); u8 (*const gMovementActionFuncs_FlyDown[])(struct ObjectEvent *, struct Sprite *); u8 (*const gMovementActionFuncs_EmoteX[])(struct ObjectEvent *, struct Sprite *); u8 (*const gMovementActionFuncs_EmoteDoubleExclMark[])(struct ObjectEvent *, struct Sprite *); -//run slow u8 (*const gMovementActionFuncs_RunDownSlow[])(struct ObjectEvent *, struct Sprite *); u8 (*const gMovementActionFuncs_RunUpSlow[])(struct ObjectEvent *, struct Sprite *); u8 (*const gMovementActionFuncs_RunLeftSlow[])(struct ObjectEvent *, struct Sprite *); @@ -604,7 +602,6 @@ u8 (*const *const gMovementActionFuncs[])(struct ObjectEvent *, struct Sprite *) [MOVEMENT_ACTION_EMOTE_DOUBLE_EXCL_MARK] = gMovementActionFuncs_EmoteDoubleExclMark, [MOVEMENT_ACTION_EXIT_POKEBALL] = gMovementActionFuncs_ExitPokeball, [MOVEMENT_ACTION_ENTER_POKEBALL] = gMovementActionFuncs_EnterPokeball, - //run slow [MOVEMENT_ACTION_RUN_DOWN_SLOW] = gMovementActionFuncs_RunDownSlow, [MOVEMENT_ACTION_RUN_UP_SLOW] = gMovementActionFuncs_RunUpSlow, [MOVEMENT_ACTION_RUN_LEFT_SLOW] = gMovementActionFuncs_RunLeftSlow, @@ -1571,7 +1568,6 @@ u8 (*const gMovementActionFuncs_EmoteDoubleExclMark[])(struct ObjectEvent *, str MovementAction_Finish, }; -//slow running u8 (*const gMovementActionFuncs_RunDownSlow[])(struct ObjectEvent *, struct Sprite *) = { MovementActionFunc_RunSlowDown_Step0, MovementActionFunc_RunSlow_Step1, diff --git a/src/field_player_avatar.c b/src/field_player_avatar.c index 2819e2784614..8e7c47b89e31 100644 --- a/src/field_player_avatar.c +++ b/src/field_player_avatar.c @@ -638,7 +638,7 @@ static void PlayerNotOnBikeTurningInPlace(u8 direction, u16 heldKeys) static void PlayerNotOnBikeMoving(u8 direction, u16 heldKeys) { u8 collision = CheckForPlayerAvatarCollision(direction); - + if (collision) { if (collision == COLLISION_LEDGE_JUMP) @@ -659,7 +659,7 @@ static void PlayerNotOnBikeMoving(u8 direction, u16 heldKeys) return; } } - + if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_SURFING) { // same speed as running @@ -2473,7 +2473,6 @@ u8 GetRightSideStairsDirection(u8 direction) default: if (direction > DIR_EAST) direction -= DIR_EAST; - return direction; } } @@ -2489,7 +2488,6 @@ u8 GetLeftSideStairsDirection(u8 direction) default: if (direction > DIR_EAST) direction -= DIR_EAST; - return direction; } } diff --git a/src/metatile_behavior.c b/src/metatile_behavior.c index 6de81c0f05fb..7063afcf5973 100644 --- a/src/metatile_behavior.c +++ b/src/metatile_behavior.c @@ -8,64 +8,64 @@ static const u8 sTileBitAttributes[NUM_METATILE_BEHAVIORS] = { - [MB_NORMAL] = TILE_FLAG_UNUSED, - [MB_TALL_GRASS] = TILE_FLAG_UNUSED | TILE_FLAG_HAS_ENCOUNTERS, - [MB_LONG_GRASS] = TILE_FLAG_UNUSED | TILE_FLAG_HAS_ENCOUNTERS, - [MB_UNUSED_05] = TILE_FLAG_HAS_ENCOUNTERS, - [MB_DEEP_SAND] = TILE_FLAG_UNUSED | TILE_FLAG_HAS_ENCOUNTERS, - [MB_SHORT_GRASS] = TILE_FLAG_UNUSED, - [MB_CAVE] = TILE_FLAG_UNUSED | TILE_FLAG_HAS_ENCOUNTERS, - [MB_LONG_GRASS_SOUTH_EDGE] = TILE_FLAG_UNUSED, - [MB_NO_RUNNING] = TILE_FLAG_UNUSED, - [MB_INDOOR_ENCOUNTER] = TILE_FLAG_UNUSED | TILE_FLAG_HAS_ENCOUNTERS, - [MB_MOUNTAIN_TOP] = TILE_FLAG_UNUSED, - [MB_BATTLE_PYRAMID_WARP] = TILE_FLAG_UNUSED, - [MB_MOSSDEEP_GYM_WARP] = TILE_FLAG_UNUSED, - [MB_MT_PYRE_HOLE] = TILE_FLAG_UNUSED, - [MB_POND_WATER] = TILE_FLAG_UNUSED | TILE_FLAG_SURFABLE | TILE_FLAG_HAS_ENCOUNTERS, - [MB_INTERIOR_DEEP_WATER] = TILE_FLAG_UNUSED | TILE_FLAG_SURFABLE | TILE_FLAG_HAS_ENCOUNTERS, - [MB_DEEP_WATER] = TILE_FLAG_UNUSED | TILE_FLAG_SURFABLE | TILE_FLAG_HAS_ENCOUNTERS, - [MB_WATERFALL] = TILE_FLAG_UNUSED | TILE_FLAG_SURFABLE, - [MB_SOOTOPOLIS_DEEP_WATER] = TILE_FLAG_UNUSED | TILE_FLAG_SURFABLE, - [MB_OCEAN_WATER] = TILE_FLAG_UNUSED | TILE_FLAG_SURFABLE | TILE_FLAG_HAS_ENCOUNTERS, - [MB_PUDDLE] = TILE_FLAG_UNUSED, - [MB_SHALLOW_WATER] = TILE_FLAG_UNUSED, - [MB_NO_SURFACING] = TILE_FLAG_UNUSED | TILE_FLAG_SURFABLE, - [MB_STAIRS_OUTSIDE_ABANDONED_SHIP] = TILE_FLAG_UNUSED, - [MB_SHOAL_CAVE_ENTRANCE] = TILE_FLAG_UNUSED, - [MB_ICE] = TILE_FLAG_UNUSED, - [MB_SAND] = TILE_FLAG_UNUSED, - [MB_SEAWEED] = TILE_FLAG_UNUSED | TILE_FLAG_SURFABLE | TILE_FLAG_HAS_ENCOUNTERS, - [MB_UNUSED_23] = TILE_FLAG_UNUSED, - [MB_ASHGRASS] = TILE_FLAG_UNUSED | TILE_FLAG_HAS_ENCOUNTERS, - [MB_FOOTPRINTS] = TILE_FLAG_UNUSED | TILE_FLAG_HAS_ENCOUNTERS, - [MB_THIN_ICE] = TILE_FLAG_UNUSED, - [MB_CRACKED_ICE] = TILE_FLAG_UNUSED, - [MB_HOT_SPRINGS] = TILE_FLAG_UNUSED, - [MB_LAVARIDGE_GYM_B1F_WARP] = TILE_FLAG_UNUSED, - [MB_SEAWEED_NO_SURFACING] = TILE_FLAG_UNUSED | TILE_FLAG_SURFABLE | TILE_FLAG_HAS_ENCOUNTERS, - [MB_REFLECTION_UNDER_BRIDGE] = TILE_FLAG_UNUSED, - [MB_IMPASSABLE_EAST] = TILE_FLAG_UNUSED, - [MB_IMPASSABLE_WEST] = TILE_FLAG_UNUSED, - [MB_IMPASSABLE_NORTH] = TILE_FLAG_UNUSED, - [MB_IMPASSABLE_SOUTH] = TILE_FLAG_UNUSED, - [MB_IMPASSABLE_NORTHEAST] = TILE_FLAG_UNUSED, - [MB_IMPASSABLE_NORTHWEST] = TILE_FLAG_UNUSED, - [MB_IMPASSABLE_SOUTHEAST] = TILE_FLAG_UNUSED, - [MB_IMPASSABLE_SOUTHWEST] = TILE_FLAG_UNUSED, - [MB_JUMP_NORTHEAST] = TILE_FLAG_UNUSED, - [MB_JUMP_NORTHWEST] = TILE_FLAG_UNUSED, - [MB_JUMP_SOUTHEAST] = TILE_FLAG_UNUSED, - [MB_JUMP_SOUTHWEST] = TILE_FLAG_UNUSED, - [MB_WALK_EAST] = TILE_FLAG_UNUSED, - [MB_WALK_WEST] = TILE_FLAG_UNUSED, - [MB_WALK_NORTH] = TILE_FLAG_UNUSED, - [MB_WALK_SOUTH] = TILE_FLAG_UNUSED, - [MB_SLIDE_EAST] = TILE_FLAG_UNUSED, - [MB_SLIDE_WEST] = TILE_FLAG_UNUSED, - [MB_SLIDE_NORTH] = TILE_FLAG_UNUSED, - [MB_SLIDE_SOUTH] = TILE_FLAG_UNUSED, - [MB_TRICK_HOUSE_PUZZLE_8_FLOOR] = TILE_FLAG_UNUSED, + [MB_NORMAL] = TILE_FLAG_UNUSED, + [MB_TALL_GRASS] = TILE_FLAG_UNUSED | TILE_FLAG_HAS_ENCOUNTERS, + [MB_LONG_GRASS] = TILE_FLAG_UNUSED | TILE_FLAG_HAS_ENCOUNTERS, + [MB_UNUSED_05] = TILE_FLAG_HAS_ENCOUNTERS, + [MB_DEEP_SAND] = TILE_FLAG_UNUSED | TILE_FLAG_HAS_ENCOUNTERS, + [MB_SHORT_GRASS] = TILE_FLAG_UNUSED, + [MB_CAVE] = TILE_FLAG_UNUSED | TILE_FLAG_HAS_ENCOUNTERS, + [MB_LONG_GRASS_SOUTH_EDGE] = TILE_FLAG_UNUSED, + [MB_NO_RUNNING] = TILE_FLAG_UNUSED, + [MB_INDOOR_ENCOUNTER] = TILE_FLAG_UNUSED | TILE_FLAG_HAS_ENCOUNTERS, + [MB_MOUNTAIN_TOP] = TILE_FLAG_UNUSED, + [MB_BATTLE_PYRAMID_WARP] = TILE_FLAG_UNUSED, + [MB_MOSSDEEP_GYM_WARP] = TILE_FLAG_UNUSED, + [MB_MT_PYRE_HOLE] = TILE_FLAG_UNUSED, + [MB_POND_WATER] = TILE_FLAG_UNUSED | TILE_FLAG_SURFABLE | TILE_FLAG_HAS_ENCOUNTERS, + [MB_INTERIOR_DEEP_WATER] = TILE_FLAG_UNUSED | TILE_FLAG_SURFABLE | TILE_FLAG_HAS_ENCOUNTERS, + [MB_DEEP_WATER] = TILE_FLAG_UNUSED | TILE_FLAG_SURFABLE | TILE_FLAG_HAS_ENCOUNTERS, + [MB_WATERFALL] = TILE_FLAG_UNUSED | TILE_FLAG_SURFABLE, + [MB_SOOTOPOLIS_DEEP_WATER] = TILE_FLAG_UNUSED | TILE_FLAG_SURFABLE, + [MB_OCEAN_WATER] = TILE_FLAG_UNUSED | TILE_FLAG_SURFABLE | TILE_FLAG_HAS_ENCOUNTERS, + [MB_PUDDLE] = TILE_FLAG_UNUSED, + [MB_SHALLOW_WATER] = TILE_FLAG_UNUSED, + [MB_NO_SURFACING] = TILE_FLAG_UNUSED | TILE_FLAG_SURFABLE, + [MB_STAIRS_OUTSIDE_ABANDONED_SHIP] = TILE_FLAG_UNUSED, + [MB_SHOAL_CAVE_ENTRANCE] = TILE_FLAG_UNUSED, + [MB_ICE] = TILE_FLAG_UNUSED, + [MB_SAND] = TILE_FLAG_UNUSED, + [MB_SEAWEED] = TILE_FLAG_UNUSED | TILE_FLAG_SURFABLE | TILE_FLAG_HAS_ENCOUNTERS, + [MB_UNUSED_23] = TILE_FLAG_UNUSED, + [MB_ASHGRASS] = TILE_FLAG_UNUSED | TILE_FLAG_HAS_ENCOUNTERS, + [MB_FOOTPRINTS] = TILE_FLAG_UNUSED | TILE_FLAG_HAS_ENCOUNTERS, + [MB_THIN_ICE] = TILE_FLAG_UNUSED, + [MB_CRACKED_ICE] = TILE_FLAG_UNUSED, + [MB_HOT_SPRINGS] = TILE_FLAG_UNUSED, + [MB_LAVARIDGE_GYM_B1F_WARP] = TILE_FLAG_UNUSED, + [MB_SEAWEED_NO_SURFACING] = TILE_FLAG_UNUSED | TILE_FLAG_SURFABLE | TILE_FLAG_HAS_ENCOUNTERS, + [MB_REFLECTION_UNDER_BRIDGE] = TILE_FLAG_UNUSED, + [MB_IMPASSABLE_EAST] = TILE_FLAG_UNUSED, + [MB_IMPASSABLE_WEST] = TILE_FLAG_UNUSED, + [MB_IMPASSABLE_NORTH] = TILE_FLAG_UNUSED, + [MB_IMPASSABLE_SOUTH] = TILE_FLAG_UNUSED, + [MB_IMPASSABLE_NORTHEAST] = TILE_FLAG_UNUSED, + [MB_IMPASSABLE_NORTHWEST] = TILE_FLAG_UNUSED, + [MB_IMPASSABLE_SOUTHEAST] = TILE_FLAG_UNUSED, + [MB_IMPASSABLE_SOUTHWEST] = TILE_FLAG_UNUSED, + [MB_JUMP_NORTHEAST] = TILE_FLAG_UNUSED, + [MB_JUMP_NORTHWEST] = TILE_FLAG_UNUSED, + [MB_JUMP_SOUTHEAST] = TILE_FLAG_UNUSED, + [MB_JUMP_SOUTHWEST] = TILE_FLAG_UNUSED, + [MB_WALK_EAST] = TILE_FLAG_UNUSED, + [MB_WALK_WEST] = TILE_FLAG_UNUSED, + [MB_WALK_NORTH] = TILE_FLAG_UNUSED, + [MB_WALK_SOUTH] = TILE_FLAG_UNUSED, + [MB_SLIDE_EAST] = TILE_FLAG_UNUSED, + [MB_SLIDE_WEST] = TILE_FLAG_UNUSED, + [MB_SLIDE_NORTH] = TILE_FLAG_UNUSED, + [MB_SLIDE_SOUTH] = TILE_FLAG_UNUSED, + [MB_TRICK_HOUSE_PUZZLE_8_FLOOR] = TILE_FLAG_UNUSED, [MB_SIDEWAYS_STAIRS_RIGHT_SIDE] = TILE_FLAG_UNUSED, [MB_SIDEWAYS_STAIRS_LEFT_SIDE] = TILE_FLAG_UNUSED, [MB_SIDEWAYS_STAIRS_RIGHT_SIDE_TOP] = TILE_FLAG_UNUSED, @@ -73,63 +73,63 @@ static const u8 sTileBitAttributes[NUM_METATILE_BEHAVIORS] = [MB_SIDEWAYS_STAIRS_RIGHT_SIDE_BOTTOM] = TILE_FLAG_UNUSED, [MB_SIDEWAYS_STAIRS_LEFT_SIDE_BOTTOM] = TILE_FLAG_UNUSED, [MB_ROCK_STAIRS] = TILE_FLAG_UNUSED, - [MB_EASTWARD_CURRENT] = TILE_FLAG_UNUSED | TILE_FLAG_SURFABLE, - [MB_WESTWARD_CURRENT] = TILE_FLAG_UNUSED | TILE_FLAG_SURFABLE, - [MB_NORTHWARD_CURRENT] = TILE_FLAG_UNUSED | TILE_FLAG_SURFABLE, - [MB_SOUTHWARD_CURRENT] = TILE_FLAG_UNUSED | TILE_FLAG_SURFABLE, - [MB_NON_ANIMATED_DOOR] = TILE_FLAG_UNUSED, - [MB_LADDER] = TILE_FLAG_UNUSED, - [MB_EAST_ARROW_WARP] = TILE_FLAG_UNUSED, - [MB_WEST_ARROW_WARP] = TILE_FLAG_UNUSED, - [MB_NORTH_ARROW_WARP] = TILE_FLAG_UNUSED, - [MB_SOUTH_ARROW_WARP] = TILE_FLAG_UNUSED, - [MB_CRACKED_FLOOR_HOLE] = TILE_FLAG_UNUSED, - [MB_AQUA_HIDEOUT_WARP] = TILE_FLAG_UNUSED, - [MB_LAVARIDGE_GYM_1F_WARP] = TILE_FLAG_UNUSED, - [MB_ANIMATED_DOOR] = TILE_FLAG_UNUSED, - [MB_UP_ESCALATOR] = TILE_FLAG_UNUSED, - [MB_DOWN_ESCALATOR] = TILE_FLAG_UNUSED, - [MB_WATER_DOOR] = TILE_FLAG_UNUSED | TILE_FLAG_SURFABLE, - [MB_WATER_SOUTH_ARROW_WARP] = TILE_FLAG_UNUSED | TILE_FLAG_SURFABLE, - [MB_DEEP_SOUTH_WARP] = TILE_FLAG_UNUSED, - [MB_UNUSED_6F] = TILE_FLAG_UNUSED | TILE_FLAG_SURFABLE, - [MB_BRIDGE_OVER_POND_LOW] = TILE_FLAG_UNUSED, - [MB_BRIDGE_OVER_POND_MED] = TILE_FLAG_UNUSED, - [MB_BRIDGE_OVER_POND_HIGH] = TILE_FLAG_UNUSED, - [MB_PACIFIDLOG_VERTICAL_LOG_TOP] = TILE_FLAG_UNUSED, - [MB_PACIFIDLOG_VERTICAL_LOG_BOTTOM] = TILE_FLAG_UNUSED, - [MB_PACIFIDLOG_HORIZONTAL_LOG_LEFT] = TILE_FLAG_UNUSED, - [MB_PACIFIDLOG_HORIZONTAL_LOG_RIGHT] = TILE_FLAG_UNUSED, - [MB_FORTREE_BRIDGE] = TILE_FLAG_UNUSED, - [MB_BRIDGE_OVER_POND_MED_EDGE_1] = TILE_FLAG_UNUSED, - [MB_BRIDGE_OVER_POND_MED_EDGE_2] = TILE_FLAG_UNUSED, - [MB_BRIDGE_OVER_POND_HIGH_EDGE_1] = TILE_FLAG_UNUSED, - [MB_BRIDGE_OVER_POND_HIGH_EDGE_2] = TILE_FLAG_UNUSED, - [MB_UNUSED_BRIDGE] = TILE_FLAG_UNUSED, - [MB_BIKE_BRIDGE_OVER_BARRIER] = TILE_FLAG_UNUSED, - [MB_SECRET_BASE_SCENERY] = TILE_FLAG_UNUSED, - [MB_SECRET_BASE_TRAINER_SPOT] = TILE_FLAG_UNUSED, - [MB_HOLDS_SMALL_DECORATION] = TILE_FLAG_UNUSED, - [MB_SECRET_BASE_BALLOON] = TILE_FLAG_UNUSED, - [MB_SECRET_BASE_IMPASSABLE] = TILE_FLAG_UNUSED, - [MB_SECRET_BASE_GLITTER_MAT] = TILE_FLAG_UNUSED, - [MB_SECRET_BASE_JUMP_MAT] = TILE_FLAG_UNUSED, - [MB_SECRET_BASE_SPIN_MAT] = TILE_FLAG_UNUSED, - [MB_SECRET_BASE_SOUND_MAT] = TILE_FLAG_UNUSED, - [MB_SECRET_BASE_BREAKABLE_DOOR] = TILE_FLAG_UNUSED, - [MB_IMPASSABLE_SOUTH_AND_NORTH] = TILE_FLAG_UNUSED, - [MB_IMPASSABLE_WEST_AND_EAST] = TILE_FLAG_UNUSED, - [MB_SECRET_BASE_HOLE] = TILE_FLAG_UNUSED, - [MB_HOLDS_LARGE_DECORATION] = TILE_FLAG_UNUSED, - [MB_SECRET_BASE_TV_SHIELD] = TILE_FLAG_UNUSED, - [MB_PLAYER_ROOM_PC_ON] = TILE_FLAG_UNUSED, - [MB_MUDDY_SLOPE] = TILE_FLAG_UNUSED, - [MB_BUMPY_SLOPE] = TILE_FLAG_UNUSED, - [MB_CRACKED_FLOOR] = TILE_FLAG_UNUSED, - [MB_ISOLATED_VERTICAL_RAIL] = TILE_FLAG_UNUSED, - [MB_ISOLATED_HORIZONTAL_RAIL] = TILE_FLAG_UNUSED, - [MB_VERTICAL_RAIL] = TILE_FLAG_UNUSED, - [MB_HORIZONTAL_RAIL] = TILE_FLAG_UNUSED, + [MB_EASTWARD_CURRENT] = TILE_FLAG_UNUSED | TILE_FLAG_SURFABLE, + [MB_WESTWARD_CURRENT] = TILE_FLAG_UNUSED | TILE_FLAG_SURFABLE, + [MB_NORTHWARD_CURRENT] = TILE_FLAG_UNUSED | TILE_FLAG_SURFABLE, + [MB_SOUTHWARD_CURRENT] = TILE_FLAG_UNUSED | TILE_FLAG_SURFABLE, + [MB_NON_ANIMATED_DOOR] = TILE_FLAG_UNUSED, + [MB_LADDER] = TILE_FLAG_UNUSED, + [MB_EAST_ARROW_WARP] = TILE_FLAG_UNUSED, + [MB_WEST_ARROW_WARP] = TILE_FLAG_UNUSED, + [MB_NORTH_ARROW_WARP] = TILE_FLAG_UNUSED, + [MB_SOUTH_ARROW_WARP] = TILE_FLAG_UNUSED, + [MB_CRACKED_FLOOR_HOLE] = TILE_FLAG_UNUSED, + [MB_AQUA_HIDEOUT_WARP] = TILE_FLAG_UNUSED, + [MB_LAVARIDGE_GYM_1F_WARP] = TILE_FLAG_UNUSED, + [MB_ANIMATED_DOOR] = TILE_FLAG_UNUSED, + [MB_UP_ESCALATOR] = TILE_FLAG_UNUSED, + [MB_DOWN_ESCALATOR] = TILE_FLAG_UNUSED, + [MB_WATER_DOOR] = TILE_FLAG_UNUSED | TILE_FLAG_SURFABLE, + [MB_WATER_SOUTH_ARROW_WARP] = TILE_FLAG_UNUSED | TILE_FLAG_SURFABLE, + [MB_DEEP_SOUTH_WARP] = TILE_FLAG_UNUSED, + [MB_UNUSED_6F] = TILE_FLAG_UNUSED | TILE_FLAG_SURFABLE, + [MB_BRIDGE_OVER_POND_LOW] = TILE_FLAG_UNUSED, + [MB_BRIDGE_OVER_POND_MED] = TILE_FLAG_UNUSED, + [MB_BRIDGE_OVER_POND_HIGH] = TILE_FLAG_UNUSED, + [MB_PACIFIDLOG_VERTICAL_LOG_TOP] = TILE_FLAG_UNUSED, + [MB_PACIFIDLOG_VERTICAL_LOG_BOTTOM] = TILE_FLAG_UNUSED, + [MB_PACIFIDLOG_HORIZONTAL_LOG_LEFT] = TILE_FLAG_UNUSED, + [MB_PACIFIDLOG_HORIZONTAL_LOG_RIGHT] = TILE_FLAG_UNUSED, + [MB_FORTREE_BRIDGE] = TILE_FLAG_UNUSED, + [MB_BRIDGE_OVER_POND_MED_EDGE_1] = TILE_FLAG_UNUSED, + [MB_BRIDGE_OVER_POND_MED_EDGE_2] = TILE_FLAG_UNUSED, + [MB_BRIDGE_OVER_POND_HIGH_EDGE_1] = TILE_FLAG_UNUSED, + [MB_BRIDGE_OVER_POND_HIGH_EDGE_2] = TILE_FLAG_UNUSED, + [MB_UNUSED_BRIDGE] = TILE_FLAG_UNUSED, + [MB_BIKE_BRIDGE_OVER_BARRIER] = TILE_FLAG_UNUSED, + [MB_SECRET_BASE_SCENERY] = TILE_FLAG_UNUSED, + [MB_SECRET_BASE_TRAINER_SPOT] = TILE_FLAG_UNUSED, + [MB_HOLDS_SMALL_DECORATION] = TILE_FLAG_UNUSED, + [MB_SECRET_BASE_BALLOON] = TILE_FLAG_UNUSED, + [MB_SECRET_BASE_IMPASSABLE] = TILE_FLAG_UNUSED, + [MB_SECRET_BASE_GLITTER_MAT] = TILE_FLAG_UNUSED, + [MB_SECRET_BASE_JUMP_MAT] = TILE_FLAG_UNUSED, + [MB_SECRET_BASE_SPIN_MAT] = TILE_FLAG_UNUSED, + [MB_SECRET_BASE_SOUND_MAT] = TILE_FLAG_UNUSED, + [MB_SECRET_BASE_BREAKABLE_DOOR] = TILE_FLAG_UNUSED, + [MB_IMPASSABLE_SOUTH_AND_NORTH] = TILE_FLAG_UNUSED, + [MB_IMPASSABLE_WEST_AND_EAST] = TILE_FLAG_UNUSED, + [MB_SECRET_BASE_HOLE] = TILE_FLAG_UNUSED, + [MB_HOLDS_LARGE_DECORATION] = TILE_FLAG_UNUSED, + [MB_SECRET_BASE_TV_SHIELD] = TILE_FLAG_UNUSED, + [MB_PLAYER_ROOM_PC_ON] = TILE_FLAG_UNUSED, + [MB_MUDDY_SLOPE] = TILE_FLAG_UNUSED, + [MB_BUMPY_SLOPE] = TILE_FLAG_UNUSED, + [MB_CRACKED_FLOOR] = TILE_FLAG_UNUSED, + [MB_ISOLATED_VERTICAL_RAIL] = TILE_FLAG_UNUSED, + [MB_ISOLATED_HORIZONTAL_RAIL] = TILE_FLAG_UNUSED, + [MB_VERTICAL_RAIL] = TILE_FLAG_UNUSED, + [MB_HORIZONTAL_RAIL] = TILE_FLAG_UNUSED, }; bool8 MetatileBehavior_IsATile(u8 metatileBehavior) @@ -1481,5 +1481,3 @@ bool8 MetatileBehavior_IsRockStairs(u8 metatileBehavior) else return FALSE; } - - From 54af254b05f5f9a64f749322719e32cdb913d2c8 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Sun, 4 Aug 2024 12:27:41 -0400 Subject: [PATCH 25/27] fix ObjectMovingOnRockStairs with follower with merrps system --- src/field_player_avatar.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/field_player_avatar.c b/src/field_player_avatar.c index 0b9ec8aa24c3..3c2b65a3b2f7 100644 --- a/src/field_player_avatar.c +++ b/src/field_player_avatar.c @@ -2499,7 +2499,7 @@ bool8 ObjectMovingOnRockStairs(struct ObjectEvent *objectEvent, u8 direction) s16 y = objectEvent->currentCoords.y; // TODO followers on sideways stairs - if (IsFollowerVisible() && (objectEvent->isPlayer || objectEvent->localId == OBJ_EVENT_ID_FOLLOWER)) + if (IsFollowerVisible() && GetFollowerObject() != NULL && (objectEvent->isPlayer || objectEvent->localId == OBJ_EVENT_ID_FOLLOWER)) return FALSE; switch (direction) From bfa020da08f5ed30e01bd7492a1b0b2344fe401b Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Sun, 22 Sep 2024 09:19:58 -0400 Subject: [PATCH 26/27] fix tile attributes --- src/metatile_behavior.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/metatile_behavior.c b/src/metatile_behavior.c index 0248c3cfeecd..7a447148e151 100644 --- a/src/metatile_behavior.c +++ b/src/metatile_behavior.c @@ -66,8 +66,6 @@ static const u8 sTileBitAttributes[NUM_METATILE_BEHAVIORS] = [MB_SLIDE_NORTH] = TILE_FLAG_UNUSED, [MB_SLIDE_SOUTH] = TILE_FLAG_UNUSED, [MB_TRICK_HOUSE_PUZZLE_8_FLOOR] = TILE_FLAG_UNUSED, - [MB_UNUSED_49] = TILE_FLAG_UNUSED, - [MB_UNUSED_4A] = TILE_FLAG_UNUSED, [MB_EASTWARD_CURRENT] = TILE_FLAG_UNUSED | TILE_FLAG_SURFABLE, [MB_WESTWARD_CURRENT] = TILE_FLAG_UNUSED | TILE_FLAG_SURFABLE, [MB_NORTHWARD_CURRENT] = TILE_FLAG_UNUSED | TILE_FLAG_SURFABLE, From c8afe9bbde880294095c0a31681b4c24856ee33d Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Sun, 29 Sep 2024 13:34:11 -0400 Subject: [PATCH 27/27] some formatting fixes --- include/config/overworld.h | 2 +- src/event_object_movement.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/config/overworld.h b/include/config/overworld.h index 7439ebc5ad9a..3298a03209a9 100644 --- a/include/config/overworld.h +++ b/include/config/overworld.h @@ -4,7 +4,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, MB_POKEMART_SIGN, or MB_POKEMON_CENTER_SIGN, the player will automatically read the signpost, as seen in FRLG. -#define SLOW_MOVEMENT_ON_STAIRS FALSE // If enabled, the player will move slower up/down stairs like in FR +#define SLOW_MOVEMENT_ON_STAIRS FALSE // If enabled, the player will move slower up/down stairs like in FR // 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. diff --git a/src/event_object_movement.c b/src/event_object_movement.c index 93bd3ba7ea3c..7f913cde2860 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -9812,7 +9812,7 @@ static void DoTracksGroundEffect_BikeTireTracks(struct ObjectEvent *objEvent, st gFieldEffectArguments[2] = 149; gFieldEffectArguments[3] = 2; gFieldEffectArguments[4] = - bikeTireTracks_Transitions[movementDir][objEvent->facingDirection - 5]; + bikeTireTracks_Transitions[movementDir][objEvent->facingDirection - 5]; FieldEffectStart(FLDEFF_BIKE_TIRE_TRACKS); } }