cherry pick 0cccbfd0ba608287d5f2b642ea613d9674cd919d

This commit is contained in:
Evan 2020-06-19 23:40:12 -06:00 committed by ghoulslash
parent 3f94abf03d
commit d3d29d7cb5
12 changed files with 451 additions and 691 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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*/

View File

@ -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);

View File

@ -143,6 +143,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)
{
@ -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;
}
@ -796,11 +749,6 @@ 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;
}
@ -825,11 +773,6 @@ static void AcroBikeTransition_WheelieLoweringMoving(u8 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;
}

View File

@ -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,
};

File diff suppressed because it is too large Load Diff

View File

@ -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;
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;
}
objectEventId = GetObjectEventIdByXYZ(position->x, position->y, position->height);
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);

View File

@ -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,41 +701,19 @@ 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);
}

View File

@ -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;
}