Added support for follower bobbing. See event_objects.h
This commit is contained in:
parent
8b0457197a
commit
712669c822
3 changed files with 43 additions and 20 deletions
Binary file not shown.
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 7.9 KiB |
|
@ -276,6 +276,10 @@
|
||||||
#define OBJ_EVENT_GFX_VAR_E (OBJ_EVENT_GFX_VARS + 0xE)
|
#define OBJ_EVENT_GFX_VAR_E (OBJ_EVENT_GFX_VARS + 0xE)
|
||||||
#define OBJ_EVENT_GFX_VAR_F (OBJ_EVENT_GFX_VARS + 0xF) // 255
|
#define OBJ_EVENT_GFX_VAR_F (OBJ_EVENT_GFX_VARS + 0xF) // 255
|
||||||
|
|
||||||
|
// If true, follower pokemon will bob up and down
|
||||||
|
// during their idle & walking animations
|
||||||
|
#define OW_MON_BOBBING TRUE
|
||||||
|
|
||||||
#define SHADOW_SIZE_S 0
|
#define SHADOW_SIZE_S 0
|
||||||
#define SHADOW_SIZE_M 1
|
#define SHADOW_SIZE_M 1
|
||||||
#define SHADOW_SIZE_L 2
|
#define SHADOW_SIZE_L 2
|
||||||
|
|
|
@ -4973,9 +4973,7 @@ bool8 MovementType_FollowPlayer_Shadow(struct ObjectEvent *objectEvent, struct S
|
||||||
|
|
||||||
bool8 MovementType_FollowPlayer_Active(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
bool8 MovementType_FollowPlayer_Active(struct ObjectEvent *objectEvent, struct Sprite *sprite)
|
||||||
{
|
{
|
||||||
if (gPlayerAvatar.tileTransitionState == T_NOT_MOVING && !gObjectEvents[gPlayerAvatar.objectEventId].heldMovementActive ) { // do nothing if player is stationary
|
if (!IsFollowerVisible()) {
|
||||||
return FALSE;
|
|
||||||
} else if (!IsFollowerVisible()) {
|
|
||||||
if (objectEvent->invisible) { // Return to shadowing state
|
if (objectEvent->invisible) { // Return to shadowing state
|
||||||
sprite->sTypeFuncId = 0;
|
sprite->sTypeFuncId = 0;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -5005,23 +5003,33 @@ bool8 MovementType_FollowPlayer_Moving(struct ObjectEvent *objectEvent, struct S
|
||||||
if (sprite->sTypeFuncId) { // restore nonzero state
|
if (sprite->sTypeFuncId) { // restore nonzero state
|
||||||
sprite->sTypeFuncId = 1;
|
sprite->sTypeFuncId = 1;
|
||||||
}
|
}
|
||||||
} else if (objectEvent->movementActionId != MOVEMENT_ACTION_EXIT_POKEBALL) {
|
} else if (objectEvent->movementActionId < MOVEMENT_ACTION_EXIT_POKEBALL) {
|
||||||
UpdateFollowerTransformEffect(objectEvent, sprite);
|
UpdateFollowerTransformEffect(objectEvent, sprite);
|
||||||
|
#if OW_MON_BOBBING == TRUE
|
||||||
|
if ((sprite->data[5] & 7) == 2)
|
||||||
|
sprite->y2 ^= -1;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool8 FollowablePlayerMovement_Idle(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 playerDirection, bool8 tileCallback(u8))
|
bool8 FollowablePlayerMovement_Idle(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 playerDirection, bool8 tileCallback(u8))
|
||||||
{
|
{
|
||||||
u8 direction;
|
if (!objectEvent->singleMovementActive)
|
||||||
if (!objectEvent->singleMovementActive) { // walk in place
|
{ // walk in place
|
||||||
ObjectEventSetSingleMovement(objectEvent, sprite, GetWalkInPlaceNormalMovementAction(objectEvent->facingDirection));
|
ObjectEventSetSingleMovement(objectEvent, sprite, GetWalkInPlaceNormalMovementAction(objectEvent->facingDirection));
|
||||||
sprite->sTypeFuncId = 1;
|
sprite->sTypeFuncId = 1;
|
||||||
objectEvent->singleMovementActive = 1;
|
objectEvent->singleMovementActive = 1;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else if (ObjectEventExecSingleMovementAction(objectEvent, sprite)) { // finish movement action
|
}
|
||||||
|
else if (ObjectEventExecSingleMovementAction(objectEvent, sprite))
|
||||||
|
{ // finish movement action
|
||||||
objectEvent->singleMovementActive = 0;
|
objectEvent->singleMovementActive = 0;
|
||||||
}
|
}
|
||||||
|
#if OW_MON_BOBBING == TRUE
|
||||||
|
else if ((sprite->data[3] & 7) == 2)
|
||||||
|
sprite->y2 ^= -1;
|
||||||
|
#endif
|
||||||
UpdateFollowerTransformEffect(objectEvent, sprite);
|
UpdateFollowerTransformEffect(objectEvent, sprite);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -5034,7 +5042,7 @@ bool8 FollowablePlayerMovement_Step(struct ObjectEvent *objectEvent, struct Spri
|
||||||
s16 targetX;
|
s16 targetX;
|
||||||
s16 targetY;
|
s16 targetY;
|
||||||
#ifdef MB_SIDEWAYS_STAIRS_RIGHT_SIDE
|
#ifdef MB_SIDEWAYS_STAIRS_RIGHT_SIDE
|
||||||
u8 playerAction = gObjectEvents[gPlayerAvatar.objectEventId].movementActionId;
|
u32 playerAction = gObjectEvents[gPlayerAvatar.objectEventId].movementActionId;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
targetX = gObjectEvents[gPlayerAvatar.objectEventId].previousCoords.x;
|
targetX = gObjectEvents[gPlayerAvatar.objectEventId].previousCoords.x;
|
||||||
|
@ -5059,6 +5067,9 @@ bool8 FollowablePlayerMovement_Step(struct ObjectEvent *objectEvent, struct Spri
|
||||||
ObjectEventSetSingleMovement(objectEvent, sprite, MOVEMENT_ACTION_EXIT_POKEBALL);
|
ObjectEventSetSingleMovement(objectEvent, sprite, MOVEMENT_ACTION_EXIT_POKEBALL);
|
||||||
objectEvent->singleMovementActive = 1;
|
objectEvent->singleMovementActive = 1;
|
||||||
sprite->sTypeFuncId = 2;
|
sprite->sTypeFuncId = 2;
|
||||||
|
#if OW_MON_BOBBING == TRUE
|
||||||
|
sprite->y2 = 0;
|
||||||
|
#endif
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else if (x == targetX && y == targetY) { // don't move if already in the player's last position
|
} else if (x == targetX && y == targetY) { // don't move if already in the player's last position
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -5082,8 +5093,12 @@ bool8 FollowablePlayerMovement_Step(struct ObjectEvent *objectEvent, struct Spri
|
||||||
} else {
|
} else {
|
||||||
if (playerAction >= MOVEMENT_ACTION_WALK_SLOW_DOWN && playerAction <= MOVEMENT_ACTION_WALK_SLOW_RIGHT)
|
if (playerAction >= MOVEMENT_ACTION_WALK_SLOW_DOWN && playerAction <= MOVEMENT_ACTION_WALK_SLOW_RIGHT)
|
||||||
ObjectEventSetSingleMovement(objectEvent, sprite, GetWalkSlowMovementAction(direction));
|
ObjectEventSetSingleMovement(objectEvent, sprite, GetWalkSlowMovementAction(direction));
|
||||||
else
|
else {
|
||||||
objectEvent->movementActionId = GetWalkNormalMovementAction(direction);
|
objectEvent->movementActionId = GetWalkNormalMovementAction(direction);
|
||||||
|
#if OW_MON_BOBBING == TRUE
|
||||||
|
sprite->y2 = -1;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
sprite->sActionFuncId = 0;
|
sprite->sActionFuncId = 0;
|
||||||
#else
|
#else
|
||||||
|
@ -5094,8 +5109,12 @@ bool8 FollowablePlayerMovement_Step(struct ObjectEvent *objectEvent, struct Spri
|
||||||
// If *player* jumps, make step take twice as long
|
// If *player* jumps, make step take twice as long
|
||||||
else if (PlayerGetCopyableMovement() == COPY_MOVE_JUMP2)
|
else if (PlayerGetCopyableMovement() == COPY_MOVE_JUMP2)
|
||||||
ObjectEventSetSingleMovement(objectEvent, sprite, GetWalkSlowMovementAction(direction));
|
ObjectEventSetSingleMovement(objectEvent, sprite, GetWalkSlowMovementAction(direction));
|
||||||
else
|
else {
|
||||||
ObjectEventSetSingleMovement(objectEvent, sprite, GetWalkNormalMovementAction(direction));
|
ObjectEventSetSingleMovement(objectEvent, sprite, GetWalkNormalMovementAction(direction));
|
||||||
|
#if OW_MON_BOBBING == TRUE
|
||||||
|
sprite->y2 = -1;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
objectEvent->singleMovementActive = 1;
|
objectEvent->singleMovementActive = 1;
|
||||||
sprite->sTypeFuncId = 2;
|
sprite->sTypeFuncId = 2;
|
||||||
|
|
Loading…
Reference in a new issue