Added support for Ghoulslash's sideways stairs with followers.
This commit is contained in:
parent
cf673fda9f
commit
a4e1c8419a
@ -4729,8 +4729,14 @@ bool8 MovementType_FollowPlayer_Active(struct ObjectEvent *objectEvent, struct S
|
||||
|
||||
bool8 MovementType_FollowPlayer_Moving(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
||||
{
|
||||
if (ObjectEventExecSingleMovementAction(objectEvent, sprite))
|
||||
{
|
||||
#ifdef MB_SIDEWAYS_STAIRS_RIGHT_SIDE
|
||||
// Copied from ObjectEventExecSingleMovementAction
|
||||
if (gMovementActionFuncs[objectEvent->movementActionId][sprite->sActionFuncId](objectEvent, sprite)) {
|
||||
objectEvent->movementActionId = MOVEMENT_ACTION_NONE;
|
||||
sprite->sActionFuncId = 0;
|
||||
#else
|
||||
if (ObjectEventExecSingleMovementAction(objectEvent, sprite)) {
|
||||
#endif
|
||||
objectEvent->singleMovementActive = 0;
|
||||
if (sprite->data[1]) { // restore nonzero state
|
||||
sprite->data[1] = 1;
|
||||
@ -4760,6 +4766,9 @@ bool8 FollowablePlayerMovement_Step(struct ObjectEvent *objectEvent, struct Spri
|
||||
s16 y;
|
||||
s16 targetX;
|
||||
s16 targetY;
|
||||
#ifdef MB_SIDEWAYS_STAIRS_RIGHT_SIDE
|
||||
u8 playerAction = gObjectEvents[gPlayerAvatar.objectEventId].movementActionId;
|
||||
#endif
|
||||
|
||||
targetX = gObjectEvents[gPlayerAvatar.objectEventId].previousCoords.x;
|
||||
targetY = gObjectEvents[gPlayerAvatar.objectEventId].previousCoords.y;
|
||||
@ -4786,12 +4795,27 @@ bool8 FollowablePlayerMovement_Step(struct ObjectEvent *objectEvent, struct Spri
|
||||
|
||||
// Follow player
|
||||
direction = GetDirectionToFace(x, y, targetX, targetY);
|
||||
ObjectEventMoveDestCoords(objectEvent, direction, &x, &y);
|
||||
if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_DASH)) { // Set follow speed accordingly
|
||||
ObjectEventSetSingleMovement(objectEvent, sprite, GetWalkFastMovementAction(direction));
|
||||
#ifdef MB_SIDEWAYS_STAIRS_RIGHT_SIDE // https://github.com/ghoulslash/pokeemerald/tree/sideways_stairs
|
||||
MoveCoords(direction, &x, &y);
|
||||
GetCollisionAtCoords(objectEvent, x, y, direction); // Sets directionOverwrite for stairs
|
||||
if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_DASH)) { // Set follow speed according to player's speed
|
||||
if (playerAction >= MOVEMENT_ACTION_RUN_DOWN_SLOW && playerAction <= MOVEMENT_ACTION_RUN_RIGHT_SLOW)
|
||||
objectEvent->movementActionId = GetWalkNormalMovementAction(direction);
|
||||
else
|
||||
objectEvent->movementActionId = GetWalkFastMovementAction(direction);
|
||||
} else {
|
||||
ObjectEventSetSingleMovement(objectEvent, sprite, GetWalkNormalMovementAction(direction));
|
||||
if (playerAction >= MOVEMENT_ACTION_WALK_SLOW_DOWN && playerAction <= MOVEMENT_ACTION_WALK_SLOW_RIGHT)
|
||||
ObjectEventSetSingleMovement(objectEvent, sprite, GetWalkSlowMovementAction(direction));
|
||||
else
|
||||
objectEvent->movementActionId = GetWalkNormalMovementAction(direction);
|
||||
}
|
||||
sprite->sActionFuncId = 0;
|
||||
#else
|
||||
if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_DASH)) // Set follow speed according to player's speed
|
||||
ObjectEventSetSingleMovement(objectEvent, sprite, GetWalkFastMovementAction(direction));
|
||||
else
|
||||
ObjectEventSetSingleMovement(objectEvent, sprite, GetWalkNormalMovementAction(direction));
|
||||
#endif
|
||||
objectEvent->singleMovementActive = 1;
|
||||
sprite->data[1] = 2;
|
||||
return TRUE;
|
||||
@ -5286,6 +5310,9 @@ static bool8 DoesObjectCollideWithObjectAt(struct ObjectEvent *objectEvent, s16
|
||||
u8 i;
|
||||
struct ObjectEvent *curObject;
|
||||
|
||||
if (objectEvent->localId == OBJ_EVENT_ID_FOLLOWER)
|
||||
return FALSE; // follower cannot collide with other objects, but they can collide with it
|
||||
|
||||
for (i = 0; i < OBJECT_EVENTS_COUNT; i++)
|
||||
{
|
||||
curObject = &gObjectEvents[i];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user