mirror of
https://github.com/pret/pokeemerald.git
synced 2026-09-30 22:07:24 -05:00
Fix all fakematches in event object movement (#2263)
Some checks failed
CI / build (push) Has been cancelled
Some checks failed
CI / build (push) Has been cancelled
* Fix all fakematches in event object movement Min changes needed. This also required adjusting faraway_mew's return type. * Address feedback --------- Co-authored-by: Mike-Goutokuji <83477269+mike-goutokuji@users.noreply.github.com>
This commit is contained in:
@@ -148,11 +148,11 @@ void InitObjectEventPalettes(u8 reflectionType);
|
||||
void UpdateObjectEventCurrentMovement(struct ObjectEvent *objectEvent, struct Sprite *sprite, bool8 (*callback)(struct ObjectEvent *, struct Sprite *));
|
||||
bool8 ObjectEventFaceOppositeDirection(struct ObjectEvent *objectEvent, u8 direction);
|
||||
u8 GetOppositeDirection(u8 direction);
|
||||
u8 GetWalkInPlaceFasterMovementAction(u32);
|
||||
u8 GetWalkInPlaceFastMovementAction(u32);
|
||||
u8 GetWalkInPlaceNormalMovementAction(u32);
|
||||
u8 GetWalkInPlaceSlowMovementAction(u32);
|
||||
u8 GetCollisionAtCoords(struct ObjectEvent *objectEvent, s16 x, s16 y, u32 dir);
|
||||
u8 GetWalkInPlaceFasterMovementAction(u8);
|
||||
u8 GetWalkInPlaceFastMovementAction(u8);
|
||||
u8 GetWalkInPlaceNormalMovementAction(u8);
|
||||
u8 GetWalkInPlaceSlowMovementAction(u8);
|
||||
u8 GetCollisionAtCoords(struct ObjectEvent *objectEvent, s16 x, s16 y, u8 direction);
|
||||
void MoveCoords(u8 direction, s16 *x, s16 *y);
|
||||
bool8 ObjectEventIsHeldMovementActive(struct ObjectEvent *objectEvent);
|
||||
u8 ObjectEventClearHeldMovementIfFinished(struct ObjectEvent *objectEvent);
|
||||
@@ -161,24 +161,24 @@ void SetTrainerMovementType(struct ObjectEvent *objectEvent, u8 movementType);
|
||||
u8 GetTrainerFacingDirectionMovementType(u8 direction);
|
||||
const u8 *GetObjectEventScriptPointerByObjectEventId(u8 objectEventId);
|
||||
u8 GetCollisionFlagsAtCoords(struct ObjectEvent *objectEvent, s16 x, s16 y, u8 direction);
|
||||
u8 GetFaceDirectionMovementAction(u32);
|
||||
u8 GetWalkNormalMovementAction(u32);
|
||||
u8 GetWalkFastMovementAction(u32);
|
||||
u8 GetRideWaterCurrentMovementAction(u32);
|
||||
u8 GetWalkFasterMovementAction(u32);
|
||||
u8 GetPlayerRunMovementAction(u32);
|
||||
u8 GetJumpInPlaceMovementAction(u32);
|
||||
u8 GetAcroWheelieFaceDirectionMovementAction(u32);
|
||||
u8 GetAcroPopWheelieFaceDirectionMovementAction(u32);
|
||||
u8 GetAcroEndWheelieFaceDirectionMovementAction(u32);
|
||||
u8 GetAcroWheelieHopFaceDirectionMovementAction(u32);
|
||||
u8 GetAcroWheelieHopDirectionMovementAction(u32);
|
||||
u8 GetAcroWheelieJumpDirectionMovementAction(u32);
|
||||
u8 GetJumpInPlaceTurnAroundMovementAction(u32);
|
||||
u8 GetAcroWheelieInPlaceDirectionMovementAction(u32);
|
||||
u8 GetAcroPopWheelieMoveDirectionMovementAction(u32);
|
||||
u8 GetAcroWheelieMoveDirectionMovementAction(u32);
|
||||
u8 GetAcroEndWheelieMoveDirectionMovementAction(u32);
|
||||
u8 GetFaceDirectionMovementAction(u8);
|
||||
u8 GetWalkNormalMovementAction(u8);
|
||||
u8 GetWalkFastMovementAction(u8);
|
||||
u8 GetRideWaterCurrentMovementAction(u8);
|
||||
u8 GetWalkFasterMovementAction(u8);
|
||||
u8 GetPlayerRunMovementAction(u8);
|
||||
u8 GetJumpInPlaceMovementAction(u8);
|
||||
u8 GetAcroWheelieFaceDirectionMovementAction(u8);
|
||||
u8 GetAcroPopWheelieFaceDirectionMovementAction(u8);
|
||||
u8 GetAcroEndWheelieFaceDirectionMovementAction(u8);
|
||||
u8 GetAcroWheelieHopFaceDirectionMovementAction(u8);
|
||||
u8 GetAcroWheelieHopDirectionMovementAction(u8);
|
||||
u8 GetAcroWheelieJumpDirectionMovementAction(u8);
|
||||
u8 GetJumpInPlaceTurnAroundMovementAction(u8);
|
||||
u8 GetAcroWheelieInPlaceDirectionMovementAction(u8);
|
||||
u8 GetAcroPopWheelieMoveDirectionMovementAction(u8);
|
||||
u8 GetAcroWheelieMoveDirectionMovementAction(u8);
|
||||
u8 GetAcroEndWheelieMoveDirectionMovementAction(u8);
|
||||
u8 GetFishingDirectionAnimNum(u8 direction);
|
||||
u8 GetAcroWheelieDirectionAnimNum(u8 direction);
|
||||
u8 GetFishingBiteDirectionAnimNum(u8 direction);
|
||||
@@ -191,11 +191,11 @@ u8 ObjectEventGetHeldMovementActionId(struct ObjectEvent *objectEvent);
|
||||
void TryOverrideTemplateCoordsForObjectEvent(const struct ObjectEvent *objectEvent, u8 movementType);
|
||||
void OverrideTemplateCoordsForObjectEvent(const struct ObjectEvent *objectEvent);
|
||||
void ShiftStillObjectEventCoords(struct ObjectEvent *objEvent);
|
||||
void ObjectEventMoveDestCoords(struct ObjectEvent *objEvent, u32 direction, s16 *x, s16 *y);
|
||||
void ObjectEventMoveDestCoords(struct ObjectEvent *objEvent, u8 direction, s16 *x, s16 *y);
|
||||
u8 AddCameraObject(u8 linkedSpriteId);
|
||||
void UpdateObjectEventsForCameraUpdate(s16 x, s16 y);
|
||||
u8 GetWalkSlowMovementAction(u32);
|
||||
u8 GetJumpMovementAction(u32);
|
||||
u8 GetWalkSlowMovementAction(u8);
|
||||
u8 GetJumpMovementAction(u8);
|
||||
u8 ElevationToPriority(u8 elevation);
|
||||
void ObjectEventUpdateElevation(struct ObjectEvent *objEvent);
|
||||
void SetObjectSubpriorityByElevation(u8 elevation, struct Sprite *sprite, u8 subpriority);
|
||||
@@ -277,9 +277,9 @@ void MovementType_JogInPlace(struct Sprite *sprite);
|
||||
void MovementType_RunInPlace(struct Sprite *sprite);
|
||||
void MovementType_Invisible(struct Sprite *sprite);
|
||||
void MovementType_WalkSlowlyInPlace(struct Sprite *sprite);
|
||||
u8 GetSlideMovementAction(u32);
|
||||
u8 GetJumpMovementAction(u32);
|
||||
u8 GetJump2MovementAction(u32);
|
||||
u8 GetSlideMovementAction(u8);
|
||||
u8 GetJumpMovementAction(u8);
|
||||
u8 GetJump2MovementAction(u8);
|
||||
u8 CreateCopySpriteAt(struct Sprite *sprite, s16 x, s16 y, u8 subpriority);
|
||||
|
||||
bool8 MovementType_WanderAround_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef GUARD_FARAWAY_ISLAND_H
|
||||
#define GUARD_FARAWAY_ISLAND_H
|
||||
|
||||
u32 GetMewMoveDirection(void);
|
||||
u8 GetMewMoveDirection(void);
|
||||
bool8 ShouldMewShakeGrass(struct ObjectEvent *objectEvent);
|
||||
void UpdateFarawayIslandStepCounter(void);
|
||||
bool8 ObjectEventIsFarawayIslandMew(struct ObjectEvent *objectEvent);
|
||||
|
||||
@@ -43,7 +43,7 @@ void SetPlayerAvatarFieldMove(void);
|
||||
u8 GetPlayerAvatarGraphicsIdByCurrentState(void);
|
||||
void SetPlayerAvatarStateMask(u8 flags);
|
||||
u8 GetPlayerAvatarGraphicsIdByStateId(u8 state);
|
||||
u8 GetJumpSpecialMovementAction(u32);
|
||||
u8 GetJumpSpecialMovementAction(u8);
|
||||
bool8 PartyHasMonWithSurf(void);
|
||||
bool8 IsPlayerFacingSurfableFishableWater(void);
|
||||
bool8 IsPlayerSurfingNorth(void);
|
||||
|
||||
@@ -90,12 +90,12 @@ static EWRAM_DATA u8 sCurrentReflectionType = 0;
|
||||
static EWRAM_DATA u16 sCurrentSpecialObjectPaletteTag = 0;
|
||||
static EWRAM_DATA struct LockedAnimObjectEvents *sLockedAnimObjectEvents = {0};
|
||||
|
||||
static void MoveCoordsInDirection(u32, s16 *, s16 *, s16, s16);
|
||||
static void MoveCoordsInDirection(u8, 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 GetCopyDirection(u8, u32, u32);
|
||||
static u8 GetCopyDirection(u8, u8, u8);
|
||||
static void TryEnableObjectEventAnim(struct ObjectEvent *, struct Sprite *);
|
||||
static void ObjectEventExecHeldMovementAction(struct ObjectEvent *, struct Sprite *);
|
||||
static void UpdateObjectEventSpriteAnimPause(struct ObjectEvent *, struct Sprite *);
|
||||
@@ -2360,13 +2360,9 @@ u8 CreateCopySpriteAt(struct Sprite *sprite, s16 x, s16 y, u8 subpriority)
|
||||
|
||||
void SetObjectEventDirection(struct ObjectEvent *objectEvent, u8 direction)
|
||||
{
|
||||
s8 d2;
|
||||
objectEvent->previousMovementDirection = objectEvent->facingDirection;
|
||||
if (!objectEvent->facingDirectionLocked)
|
||||
{
|
||||
d2 = direction;
|
||||
objectEvent->facingDirection = d2;
|
||||
}
|
||||
objectEvent->facingDirection = direction;
|
||||
objectEvent->movementDirection = direction;
|
||||
}
|
||||
|
||||
@@ -4190,7 +4186,8 @@ bool8 CopyablePlayerMovement_None(struct ObjectEvent *objectEvent, struct Sprite
|
||||
|
||||
bool8 CopyablePlayerMovement_FaceDirection(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 playerDirection, bool8 tileCallback(u8))
|
||||
{
|
||||
ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(GetCopyDirection(gInitialMovementTypeFacingDirections[objectEvent->movementType], objectEvent->directionSequenceIndex, playerDirection)));
|
||||
playerDirection = GetCopyDirection(gInitialMovementTypeFacingDirections[objectEvent->movementType], objectEvent->directionSequenceIndex, playerDirection);
|
||||
ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(playerDirection));
|
||||
objectEvent->singleMovementActive = TRUE;
|
||||
sprite->sTypeFuncId = 2;
|
||||
return TRUE;
|
||||
@@ -4198,34 +4195,33 @@ bool8 CopyablePlayerMovement_FaceDirection(struct ObjectEvent *objectEvent, stru
|
||||
|
||||
bool8 CopyablePlayerMovement_WalkNormal(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 playerDirection, bool8 tileCallback(u8))
|
||||
{
|
||||
u32 direction;
|
||||
s16 x;
|
||||
s16 y;
|
||||
s16 x, y;
|
||||
u8 direction;
|
||||
|
||||
direction = playerDirection;
|
||||
if (ObjectEventIsFarawayIslandMew(objectEvent))
|
||||
if (!ObjectEventIsFarawayIslandMew(objectEvent)) {
|
||||
playerDirection = GetCopyDirection(gInitialMovementTypeFacingDirections[objectEvent->movementType], objectEvent->directionSequenceIndex, playerDirection);
|
||||
}
|
||||
else
|
||||
{
|
||||
direction = GetMewMoveDirection();
|
||||
if (direction == DIR_NONE)
|
||||
direction = playerDirection;
|
||||
playerDirection = GetMewMoveDirection();
|
||||
if (playerDirection == DIR_NONE)
|
||||
{
|
||||
direction = playerDirection;
|
||||
direction = GetCopyDirection(gInitialMovementTypeFacingDirections[objectEvent->movementType], objectEvent->directionSequenceIndex, direction);
|
||||
ObjectEventMoveDestCoords(objectEvent, direction, &x, &y);
|
||||
ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(direction));
|
||||
playerDirection = direction;
|
||||
playerDirection = GetCopyDirection(gInitialMovementTypeFacingDirections[objectEvent->movementType], objectEvent->directionSequenceIndex, playerDirection);
|
||||
ObjectEventMoveDestCoords(objectEvent, playerDirection, &x, &y);
|
||||
ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(playerDirection));
|
||||
objectEvent->singleMovementActive = TRUE;
|
||||
sprite->sTypeFuncId = 2;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
direction = GetCopyDirection(gInitialMovementTypeFacingDirections[objectEvent->movementType], objectEvent->directionSequenceIndex, direction);
|
||||
}
|
||||
ObjectEventMoveDestCoords(objectEvent, direction, &x, &y);
|
||||
ObjectEventSetSingleMovement(objectEvent, sprite, GetWalkNormalMovementAction(direction));
|
||||
|
||||
if (GetCollisionAtCoords(objectEvent, x, y, direction) || (tileCallback != NULL && !tileCallback(MapGridGetMetatileBehaviorAt(x, y))))
|
||||
ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(direction));
|
||||
ObjectEventMoveDestCoords(objectEvent, playerDirection, &x, &y);
|
||||
ObjectEventSetSingleMovement(objectEvent, sprite, GetWalkNormalMovementAction(playerDirection));
|
||||
|
||||
if (GetCollisionAtCoords(objectEvent, x, y, playerDirection) || (tileCallback != NULL && !tileCallback(MapGridGetMetatileBehaviorAt(x, y))))
|
||||
ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(playerDirection));
|
||||
|
||||
objectEvent->singleMovementActive = TRUE;
|
||||
sprite->sTypeFuncId = 2;
|
||||
@@ -4234,17 +4230,15 @@ bool8 CopyablePlayerMovement_WalkNormal(struct ObjectEvent *objectEvent, struct
|
||||
|
||||
bool8 CopyablePlayerMovement_WalkFast(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 playerDirection, bool8 tileCallback(u8))
|
||||
{
|
||||
u32 direction;
|
||||
s16 x;
|
||||
s16 y;
|
||||
|
||||
direction = playerDirection;
|
||||
direction = GetCopyDirection(gInitialMovementTypeFacingDirections[objectEvent->movementType], objectEvent->directionSequenceIndex, direction);
|
||||
ObjectEventMoveDestCoords(objectEvent, direction, &x, &y);
|
||||
ObjectEventSetSingleMovement(objectEvent, sprite, GetWalkFastMovementAction(direction));
|
||||
playerDirection = GetCopyDirection(gInitialMovementTypeFacingDirections[objectEvent->movementType], objectEvent->directionSequenceIndex, playerDirection);
|
||||
ObjectEventMoveDestCoords(objectEvent, playerDirection, &x, &y);
|
||||
ObjectEventSetSingleMovement(objectEvent, sprite, GetWalkFastMovementAction(playerDirection));
|
||||
|
||||
if (GetCollisionAtCoords(objectEvent, x, y, direction) || (tileCallback != NULL && !tileCallback(MapGridGetMetatileBehaviorAt(x, y))))
|
||||
ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(direction));
|
||||
if (GetCollisionAtCoords(objectEvent, x, y, playerDirection) || (tileCallback != NULL && !tileCallback(MapGridGetMetatileBehaviorAt(x, y))))
|
||||
ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(playerDirection));
|
||||
|
||||
objectEvent->singleMovementActive = TRUE;
|
||||
sprite->sTypeFuncId = 2;
|
||||
@@ -4253,17 +4247,15 @@ bool8 CopyablePlayerMovement_WalkFast(struct ObjectEvent *objectEvent, struct Sp
|
||||
|
||||
bool8 CopyablePlayerMovement_WalkFaster(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 playerDirection, bool8 tileCallback(u8))
|
||||
{
|
||||
u32 direction;
|
||||
s16 x;
|
||||
s16 y;
|
||||
|
||||
direction = playerDirection;
|
||||
direction = GetCopyDirection(gInitialMovementTypeFacingDirections[objectEvent->movementType], objectEvent->directionSequenceIndex, direction);
|
||||
ObjectEventMoveDestCoords(objectEvent, direction, &x, &y);
|
||||
ObjectEventSetSingleMovement(objectEvent, sprite, GetWalkFasterMovementAction(direction));
|
||||
playerDirection = GetCopyDirection(gInitialMovementTypeFacingDirections[objectEvent->movementType], objectEvent->directionSequenceIndex, playerDirection);
|
||||
ObjectEventMoveDestCoords(objectEvent, playerDirection, &x, &y);
|
||||
ObjectEventSetSingleMovement(objectEvent, sprite, GetWalkFasterMovementAction(playerDirection));
|
||||
|
||||
if (GetCollisionAtCoords(objectEvent, x, y, direction) || (tileCallback != NULL && !tileCallback(MapGridGetMetatileBehaviorAt(x, y))))
|
||||
ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(direction));
|
||||
if (GetCollisionAtCoords(objectEvent, x, y, playerDirection) || (tileCallback != NULL && !tileCallback(MapGridGetMetatileBehaviorAt(x, y))))
|
||||
ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(playerDirection));
|
||||
|
||||
objectEvent->singleMovementActive = TRUE;
|
||||
sprite->sTypeFuncId = 2;
|
||||
@@ -4272,17 +4264,15 @@ bool8 CopyablePlayerMovement_WalkFaster(struct ObjectEvent *objectEvent, struct
|
||||
|
||||
bool8 CopyablePlayerMovement_Slide(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 playerDirection, bool8 tileCallback(u8))
|
||||
{
|
||||
u32 direction;
|
||||
s16 x;
|
||||
s16 y;
|
||||
|
||||
direction = playerDirection;
|
||||
direction = GetCopyDirection(gInitialMovementTypeFacingDirections[objectEvent->movementType], objectEvent->directionSequenceIndex, direction);
|
||||
ObjectEventMoveDestCoords(objectEvent, direction, &x, &y);
|
||||
ObjectEventSetSingleMovement(objectEvent, sprite, GetSlideMovementAction(direction));
|
||||
playerDirection = GetCopyDirection(gInitialMovementTypeFacingDirections[objectEvent->movementType], objectEvent->directionSequenceIndex, playerDirection);
|
||||
ObjectEventMoveDestCoords(objectEvent, playerDirection, &x, &y);
|
||||
ObjectEventSetSingleMovement(objectEvent, sprite, GetSlideMovementAction(playerDirection));
|
||||
|
||||
if (GetCollisionAtCoords(objectEvent, x, y, direction) || (tileCallback != NULL && !tileCallback(MapGridGetMetatileBehaviorAt(x, y))))
|
||||
ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(direction));
|
||||
if (GetCollisionAtCoords(objectEvent, x, y, playerDirection) || (tileCallback != NULL && !tileCallback(MapGridGetMetatileBehaviorAt(x, y))))
|
||||
ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(playerDirection));
|
||||
|
||||
objectEvent->singleMovementActive = TRUE;
|
||||
sprite->sTypeFuncId = 2;
|
||||
@@ -4291,11 +4281,8 @@ bool8 CopyablePlayerMovement_Slide(struct ObjectEvent *objectEvent, struct Sprit
|
||||
|
||||
bool8 CopyablePlayerMovement_JumpInPlace(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 playerDirection, bool8 tileCallback(u8))
|
||||
{
|
||||
u32 direction;
|
||||
|
||||
direction = playerDirection;
|
||||
direction = GetCopyDirection(gInitialMovementTypeFacingDirections[objectEvent->movementType], objectEvent->directionSequenceIndex, direction);
|
||||
ObjectEventSetSingleMovement(objectEvent, sprite, GetJumpInPlaceMovementAction(direction));
|
||||
playerDirection = GetCopyDirection(gInitialMovementTypeFacingDirections[objectEvent->movementType], objectEvent->directionSequenceIndex, playerDirection);
|
||||
ObjectEventSetSingleMovement(objectEvent, sprite, GetJumpInPlaceMovementAction(playerDirection));
|
||||
objectEvent->singleMovementActive = TRUE;
|
||||
sprite->sTypeFuncId = 2;
|
||||
return TRUE;
|
||||
@@ -4303,17 +4290,15 @@ bool8 CopyablePlayerMovement_JumpInPlace(struct ObjectEvent *objectEvent, struct
|
||||
|
||||
bool8 CopyablePlayerMovement_Jump(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 playerDirection, bool8 tileCallback(u8))
|
||||
{
|
||||
u32 direction;
|
||||
s16 x;
|
||||
s16 y;
|
||||
|
||||
direction = playerDirection;
|
||||
direction = GetCopyDirection(gInitialMovementTypeFacingDirections[objectEvent->movementType], objectEvent->directionSequenceIndex, direction);
|
||||
ObjectEventMoveDestCoords(objectEvent, direction, &x, &y);
|
||||
ObjectEventSetSingleMovement(objectEvent, sprite, GetJumpMovementAction(direction));
|
||||
playerDirection = GetCopyDirection(gInitialMovementTypeFacingDirections[objectEvent->movementType], objectEvent->directionSequenceIndex, playerDirection);
|
||||
ObjectEventMoveDestCoords(objectEvent, playerDirection, &x, &y);
|
||||
ObjectEventSetSingleMovement(objectEvent, sprite, GetJumpMovementAction(playerDirection));
|
||||
|
||||
if (GetCollisionAtCoords(objectEvent, x, y, direction) || (tileCallback != NULL && !tileCallback(MapGridGetMetatileBehaviorAt(x, y))))
|
||||
ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(direction));
|
||||
if (GetCollisionAtCoords(objectEvent, x, y, playerDirection) || (tileCallback != NULL && !tileCallback(MapGridGetMetatileBehaviorAt(x, y))))
|
||||
ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(playerDirection));
|
||||
|
||||
objectEvent->singleMovementActive = TRUE;
|
||||
sprite->sTypeFuncId = 2;
|
||||
@@ -4322,19 +4307,17 @@ bool8 CopyablePlayerMovement_Jump(struct ObjectEvent *objectEvent, struct Sprite
|
||||
|
||||
bool8 CopyablePlayerMovement_Jump2(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 playerDirection, bool8 tileCallback(u8))
|
||||
{
|
||||
u32 direction;
|
||||
s16 x;
|
||||
s16 y;
|
||||
|
||||
direction = playerDirection;
|
||||
direction = GetCopyDirection(gInitialMovementTypeFacingDirections[objectEvent->movementType], objectEvent->directionSequenceIndex, direction);
|
||||
playerDirection = GetCopyDirection(gInitialMovementTypeFacingDirections[objectEvent->movementType], objectEvent->directionSequenceIndex, playerDirection);
|
||||
x = objectEvent->currentCoords.x;
|
||||
y = objectEvent->currentCoords.y;
|
||||
MoveCoordsInDirection(direction, &x, &y, 2, 2);
|
||||
ObjectEventSetSingleMovement(objectEvent, sprite, GetJump2MovementAction(direction));
|
||||
MoveCoordsInDirection(playerDirection, &x, &y, 2, 2);
|
||||
ObjectEventSetSingleMovement(objectEvent, sprite, GetJump2MovementAction(playerDirection));
|
||||
|
||||
if (GetCollisionAtCoords(objectEvent, x, y, direction) || (tileCallback != NULL && !tileCallback(MapGridGetMetatileBehaviorAt(x, y))))
|
||||
ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(direction));
|
||||
if (GetCollisionAtCoords(objectEvent, x, y, playerDirection) || (tileCallback != NULL && !tileCallback(MapGridGetMetatileBehaviorAt(x, y))))
|
||||
ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(playerDirection));
|
||||
|
||||
objectEvent->singleMovementActive = TRUE;
|
||||
sprite->sTypeFuncId = 2;
|
||||
@@ -4655,9 +4638,8 @@ static u8 GetCollisionInDirection(struct ObjectEvent *objectEvent, u8 direction)
|
||||
return GetCollisionAtCoords(objectEvent, x, y, direction);
|
||||
}
|
||||
|
||||
u8 GetCollisionAtCoords(struct ObjectEvent *objectEvent, s16 x, s16 y, u32 dir)
|
||||
u8 GetCollisionAtCoords(struct ObjectEvent *objectEvent, s16 x, s16 y, u8 direction)
|
||||
{
|
||||
u8 direction = dir;
|
||||
if (IsCoordOutsideObjectEventMovementRange(objectEvent, x, y))
|
||||
return COLLISION_OUTSIDE_RANGE;
|
||||
else if (MapGridGetCollisionAt(x, y) || GetMapBorderIdAt(x, y) == CONNECTION_INVALID || IsMetatileDirectionallyImpassable(objectEvent, x, y, direction))
|
||||
@@ -4775,19 +4757,16 @@ static void UNUSED MoveCoordsInMapCoordIncrement(u8 direction, s16 *x, s16 *y)
|
||||
*y += sDirectionToVectors[direction].y << 4;
|
||||
}
|
||||
|
||||
static void MoveCoordsInDirection(u32 dir, s16 *x, s16 *y, s16 deltaX, s16 deltaY)
|
||||
static void MoveCoordsInDirection(u8 direction, s16 *x, s16 *y, s16 deltaX, s16 deltaY)
|
||||
{
|
||||
u8 direction = dir;
|
||||
s16 dx2 = (u16)deltaX;
|
||||
s16 dy2 = (u16)deltaY;
|
||||
if (sDirectionToVectors[direction].x > 0)
|
||||
*x += dx2;
|
||||
*x += deltaX;
|
||||
if (sDirectionToVectors[direction].x < 0)
|
||||
*x -= dx2;
|
||||
*x -= deltaX;
|
||||
if (sDirectionToVectors[direction].y > 0)
|
||||
*y += dy2;
|
||||
*y += deltaY;
|
||||
if (sDirectionToVectors[direction].y < 0)
|
||||
*y -= dy2;
|
||||
*y -= deltaY;
|
||||
}
|
||||
|
||||
void GetMapCoordsFromSpritePos(s16 x, s16 y, s16 *destX, s16 *destY)
|
||||
@@ -4843,12 +4822,11 @@ static void GetObjectEventMovingCameraOffset(s16 *x, s16 *y)
|
||||
(*y)--;
|
||||
}
|
||||
|
||||
void ObjectEventMoveDestCoords(struct ObjectEvent *objectEvent, u32 direction, s16 *x, s16 *y)
|
||||
void ObjectEventMoveDestCoords(struct ObjectEvent *objectEvent, u8 direction, s16 *x, s16 *y)
|
||||
{
|
||||
u8 newDirn = direction;
|
||||
*x = objectEvent->currentCoords.x;
|
||||
*y = objectEvent->currentCoords.y;
|
||||
MoveCoords(newDirn, x, y);
|
||||
MoveCoords(direction, x, y);
|
||||
}
|
||||
|
||||
bool8 ObjectEventIsMovementOverridden(struct ObjectEvent *objectEvent)
|
||||
@@ -4944,11 +4922,9 @@ void UpdateObjectEventCurrentMovement(struct ObjectEvent *objectEvent, struct Sp
|
||||
}
|
||||
|
||||
#define dirn_to_anim(name, table)\
|
||||
u8 name(u32 idx)\
|
||||
u8 name(u8 direction)\
|
||||
{\
|
||||
u8 direction;\
|
||||
u8 animIds[sizeof(table)];\
|
||||
direction = idx;\
|
||||
memcpy(animIds, (table), sizeof(table));\
|
||||
if (direction > DIR_EAST) direction = 0;\
|
||||
return animIds[direction];\
|
||||
@@ -4993,7 +4969,7 @@ u8 GetOppositeDirection(u8 direction)
|
||||
u8 directions[sizeof sOppositeDirections];
|
||||
|
||||
memcpy(directions, sOppositeDirections, sizeof sOppositeDirections);
|
||||
if (direction <= DIR_NONE || direction > (sizeof sOppositeDirections))
|
||||
if (direction == DIR_NONE || direction > (sizeof sOppositeDirections))
|
||||
return direction;
|
||||
|
||||
return directions[direction - 1];
|
||||
@@ -5001,7 +4977,7 @@ u8 GetOppositeDirection(u8 direction)
|
||||
|
||||
// Takes the player's original and current direction and gives a direction the copy NPC should consider as the player's direction.
|
||||
// See comments at the table's definition.
|
||||
static u32 GetPlayerDirectionForCopy(u8 initDir, u8 moveDir)
|
||||
static u8 GetPlayerDirectionForCopy(u8 initDir, u8 moveDir)
|
||||
{
|
||||
return sPlayerDirectionsForCopy[initDir - 1][moveDir - 1];
|
||||
}
|
||||
@@ -5009,17 +4985,14 @@ static u32 GetPlayerDirectionForCopy(u8 initDir, u8 moveDir)
|
||||
// copyInitDir is the initial facing direction of the copying NPC.
|
||||
// playerInitDir is the direction the player was facing when the copying NPC was spawned, as set by MovementType_CopyPlayer_Step0.
|
||||
// playerMoveDir is the direction the player is currently moving.
|
||||
static u32 GetCopyDirection(u8 copyInitDir, u32 playerInitDir, u32 playerMoveDir)
|
||||
static u8 GetCopyDirection(u8 copyInitDir, u8 playerInitDir, u8 playerMoveDir)
|
||||
{
|
||||
u32 dir;
|
||||
u8 _playerInitDir = playerInitDir;
|
||||
u8 _playerMoveDir = playerMoveDir;
|
||||
if (_playerInitDir == DIR_NONE || _playerMoveDir == DIR_NONE
|
||||
|| _playerInitDir > DIR_EAST || _playerMoveDir > DIR_EAST)
|
||||
if (playerInitDir == DIR_NONE || playerMoveDir == DIR_NONE
|
||||
|| playerInitDir > DIR_EAST || playerMoveDir > DIR_EAST)
|
||||
return DIR_NONE;
|
||||
|
||||
dir = GetPlayerDirectionForCopy(_playerInitDir, playerMoveDir);
|
||||
return sPlayerDirectionToCopyDirection[copyInitDir - 1][dir - 1];
|
||||
playerMoveDir = GetPlayerDirectionForCopy(playerInitDir, playerMoveDir);
|
||||
return sPlayerDirectionToCopyDirection[copyInitDir - 1][playerMoveDir - 1];
|
||||
}
|
||||
|
||||
static void ObjectEventExecHeldMovementAction(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
||||
@@ -7350,8 +7323,8 @@ static void UpdateObjectEventVisibility(struct ObjectEvent *objectEvent, struct
|
||||
|
||||
static void UpdateObjectEventOffscreen(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
||||
{
|
||||
u16 x, y;
|
||||
u16 x2, y2;
|
||||
s16 x, y;
|
||||
s16 x2, y2;
|
||||
const struct ObjectEventGraphicsInfo *graphicsInfo;
|
||||
|
||||
objectEvent->offScreen = FALSE;
|
||||
@@ -7367,15 +7340,13 @@ static void UpdateObjectEventOffscreen(struct ObjectEvent *objectEvent, struct S
|
||||
x = sprite->x + sprite->x2 + sprite->centerToCornerVecX;
|
||||
y = sprite->y + sprite->y2 + sprite->centerToCornerVecY;
|
||||
}
|
||||
x2 = graphicsInfo->width;
|
||||
x2 += x;
|
||||
y2 = y;
|
||||
y2 += graphicsInfo->height;
|
||||
x2 = (u16)x + (u16)graphicsInfo->width;
|
||||
y2 = (u16)y + (u16)graphicsInfo->height;
|
||||
|
||||
if ((s16)x >= DISPLAY_WIDTH + 16 || (s16)x2 < -16)
|
||||
if (x >= DISPLAY_WIDTH + 16 || x2 < -16)
|
||||
objectEvent->offScreen = TRUE;
|
||||
|
||||
if ((s16)y >= DISPLAY_HEIGHT + 16 || (s16)y2 < -16)
|
||||
if (y >= DISPLAY_HEIGHT + 16 || y2 < -16)
|
||||
objectEvent->offScreen = TRUE;
|
||||
}
|
||||
|
||||
@@ -7493,8 +7464,7 @@ static void GetGroundEffectFlags_SandHeap(struct ObjectEvent *objEvent, u32 *fla
|
||||
{
|
||||
if (!objEvent->inSandPile)
|
||||
{
|
||||
objEvent->inSandPile = FALSE;
|
||||
objEvent->inSandPile = TRUE;
|
||||
objEvent->inSandPile++;
|
||||
*flags |= GROUND_EFFECT_FLAG_SAND_PILE;
|
||||
}
|
||||
}
|
||||
@@ -7513,8 +7483,7 @@ static void GetGroundEffectFlags_ShallowFlowingWater(struct ObjectEvent *objEven
|
||||
{
|
||||
if (!objEvent->inShallowFlowingWater)
|
||||
{
|
||||
objEvent->inShallowFlowingWater = FALSE;
|
||||
objEvent->inShallowFlowingWater = TRUE;
|
||||
objEvent->inShallowFlowingWater++;
|
||||
*flags |= GROUND_EFFECT_FLAG_SHALLOW_FLOWING_WATER;
|
||||
}
|
||||
}
|
||||
@@ -7544,8 +7513,7 @@ static void GetGroundEffectFlags_ShortGrass(struct ObjectEvent *objEvent, u32 *f
|
||||
{
|
||||
if (!objEvent->inShortGrass)
|
||||
{
|
||||
objEvent->inShortGrass = FALSE;
|
||||
objEvent->inShortGrass = TRUE;
|
||||
objEvent->inShortGrass++;
|
||||
*flags |= GROUND_EFFECT_FLAG_SHORT_GRASS;
|
||||
}
|
||||
}
|
||||
@@ -7562,8 +7530,7 @@ static void GetGroundEffectFlags_HotSprings(struct ObjectEvent *objEvent, u32 *f
|
||||
{
|
||||
if (!objEvent->inHotSprings)
|
||||
{
|
||||
objEvent->inHotSprings = FALSE;
|
||||
objEvent->inHotSprings = TRUE;
|
||||
objEvent->inHotSprings++;
|
||||
*flags |= GROUND_EFFECT_FLAG_HOT_SPRINGS;
|
||||
}
|
||||
}
|
||||
@@ -7626,12 +7593,12 @@ static u8 ObjectEventGetNearbyReflectionType(struct ObjectEvent *objEvent)
|
||||
{
|
||||
const struct ObjectEventGraphicsInfo *info = GetObjectEventGraphicsInfo(objEvent->graphicsId);
|
||||
|
||||
// ceil div by tile width?
|
||||
// Ceil div by tile width. Size / 16 + 1;
|
||||
s16 width = (info->width + 8) >> 4;
|
||||
s16 height = (info->height + 8) >> 4;
|
||||
s16 i, j;
|
||||
u8 result, b; // used by RETURN_REFLECTION_TYPE_AT
|
||||
s16 one = 1;
|
||||
s16 one = 1; // + 1
|
||||
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
@@ -7671,18 +7638,17 @@ u8 GetLedgeJumpDirection(s16 x, s16 y, u8 direction)
|
||||
};
|
||||
|
||||
u8 behavior;
|
||||
u8 index = direction;
|
||||
|
||||
if (index == DIR_NONE)
|
||||
if (direction == DIR_NONE)
|
||||
return DIR_NONE;
|
||||
else if (index > DIR_EAST)
|
||||
index -= DIR_EAST;
|
||||
else if (direction > DIR_EAST)
|
||||
direction -= DIR_EAST;
|
||||
|
||||
index--;
|
||||
direction--;
|
||||
behavior = MapGridGetMetatileBehaviorAt(x, y);
|
||||
|
||||
if (ledgeBehaviorFuncs[index](behavior) == TRUE)
|
||||
return index + 1;
|
||||
if (ledgeBehaviorFuncs[direction](behavior) == TRUE)
|
||||
return direction + 1;
|
||||
|
||||
return DIR_NONE;
|
||||
}
|
||||
@@ -8188,34 +8154,37 @@ void UnfreezeObjectEvents(void)
|
||||
UnfreezeObjectEvent(&gObjectEvents[i]);
|
||||
}
|
||||
|
||||
static void Step1(struct Sprite *sprite, u8 dir)
|
||||
// Each step function moves the sprite along its direction vector by N pixels per frame.
|
||||
// Over the course of the step animation, these sum to 16 pixels (one full metatile).
|
||||
// The left-shifts represent pixel displacements per frame (e.g. << 3 moves 8 pixels, or one 8x8 tile):
|
||||
static void Step1(struct Sprite *sprite, u8 direction)
|
||||
{
|
||||
sprite->x += sDirectionToVectors[dir].x;
|
||||
sprite->y += sDirectionToVectors[dir].y;
|
||||
sprite->x += sDirectionToVectors[direction].x;
|
||||
sprite->y += sDirectionToVectors[direction].y;
|
||||
}
|
||||
|
||||
static void Step2(struct Sprite *sprite, u8 dir)
|
||||
static void Step2(struct Sprite *sprite, u8 direction)
|
||||
{
|
||||
sprite->x += 2 * (u16) sDirectionToVectors[dir].x;
|
||||
sprite->y += 2 * (u16) sDirectionToVectors[dir].y;
|
||||
sprite->x += sDirectionToVectors[direction].x << 1;
|
||||
sprite->y += sDirectionToVectors[direction].y << 1;
|
||||
}
|
||||
|
||||
static void Step3(struct Sprite *sprite, u8 dir)
|
||||
static void Step3(struct Sprite *sprite, u8 direction)
|
||||
{
|
||||
sprite->x += 2 * (u16) sDirectionToVectors[dir].x + (u16) sDirectionToVectors[dir].x;
|
||||
sprite->y += 2 * (u16) sDirectionToVectors[dir].y + (u16) sDirectionToVectors[dir].y;
|
||||
sprite->x += (sDirectionToVectors[direction].x << 1) + sDirectionToVectors[direction].x;
|
||||
sprite->y += (sDirectionToVectors[direction].y << 1) + sDirectionToVectors[direction].y;
|
||||
}
|
||||
|
||||
static void Step4(struct Sprite *sprite, u8 dir)
|
||||
static void Step4(struct Sprite *sprite, u8 direction)
|
||||
{
|
||||
sprite->x += 4 * (u16) sDirectionToVectors[dir].x;
|
||||
sprite->y += 4 * (u16) sDirectionToVectors[dir].y;
|
||||
sprite->x += sDirectionToVectors[direction].x << 2;
|
||||
sprite->y += sDirectionToVectors[direction].y << 2;
|
||||
}
|
||||
|
||||
static void Step8(struct Sprite *sprite, u8 dir)
|
||||
static void Step8(struct Sprite *sprite, u8 direction)
|
||||
{
|
||||
sprite->x += 8 * (u16) sDirectionToVectors[dir].x;
|
||||
sprite->y += 8 * (u16) sDirectionToVectors[dir].y;
|
||||
sprite->x += sDirectionToVectors[direction].x << 3;
|
||||
sprite->y += sDirectionToVectors[direction].y << 3;
|
||||
}
|
||||
|
||||
#define sSpeed data[4]
|
||||
@@ -8559,7 +8528,7 @@ bool8 SpriteAnimEnded(struct Sprite *sprite)
|
||||
|
||||
void UpdateObjectEventSpriteInvisibility(struct Sprite *sprite, bool8 invisible)
|
||||
{
|
||||
u16 x, y;
|
||||
s16 x, y;
|
||||
s16 x2, y2;
|
||||
|
||||
sprite->invisible = invisible;
|
||||
@@ -8575,12 +8544,12 @@ void UpdateObjectEventSpriteInvisibility(struct Sprite *sprite, bool8 invisible)
|
||||
y = sprite->y + sprite->y2 + sprite->centerToCornerVecY;
|
||||
}
|
||||
|
||||
x2 = x - (sprite->centerToCornerVecX >> 1);
|
||||
y2 = y - (sprite->centerToCornerVecY >> 1);
|
||||
x2 = (u16)x - (u16)(sprite->centerToCornerVecX >> 1);
|
||||
y2 = (u16)y - (u16)(sprite->centerToCornerVecY >> 1);
|
||||
|
||||
if ((s16)x >= DISPLAY_WIDTH + 16 || x2 < -16)
|
||||
if (x >= DISPLAY_WIDTH + 16 || x2 < -16)
|
||||
sprite->invisible = TRUE;
|
||||
if ((s16)y >= DISPLAY_HEIGHT + 16 || y2 < -16)
|
||||
if (y >= DISPLAY_HEIGHT + 16 || y2 < -16)
|
||||
sprite->invisible = TRUE;
|
||||
}
|
||||
|
||||
@@ -8732,14 +8701,14 @@ static void VirtualObject_UpdateAnim(struct Sprite *sprite)
|
||||
{
|
||||
switch(sprite->sAnimNum)
|
||||
{
|
||||
case UNION_ROOM_SPAWN_NONE:
|
||||
break;
|
||||
case UNION_ROOM_SPAWN_IN:
|
||||
MoveUnionRoomObjectDown(sprite);
|
||||
break;
|
||||
case UNION_ROOM_SPAWN_OUT:
|
||||
MoveUnionRoomObjectUp(sprite);
|
||||
break;
|
||||
case 0:
|
||||
break;
|
||||
default:
|
||||
sprite->sAnimNum = 0;
|
||||
break;
|
||||
|
||||
@@ -43,10 +43,10 @@ static u8 GetMewObjectEventId(void)
|
||||
|
||||
// When the player enters Faraway Island interior it begins a "hide and seek" minigame where Mew disappears into the grass
|
||||
// This function returns the direction Mew will take a step, and is run every time the player takes a step
|
||||
u32 GetMewMoveDirection(void)
|
||||
u8 GetMewMoveDirection(void)
|
||||
{
|
||||
u8 i;
|
||||
int mewSafeFromTrap;
|
||||
bool32 mewSafeFromTrap;
|
||||
struct ObjectEvent *mew = &gObjectEvents[GetMewObjectEventId()];
|
||||
|
||||
sPlayerToMewDeltaX = gObjectEvents[gPlayerAvatar.objectEventId].previousCoords.x - mew->currentCoords.x;
|
||||
|
||||
Reference in New Issue
Block a user