Add missing array constants in field_player_avatar

This commit is contained in:
GriffinR 2022-01-08 23:53:55 -05:00
parent a837d1fe2c
commit 8f1a760937
2 changed files with 61 additions and 47 deletions

View File

@ -30,6 +30,15 @@
#include "constants/songs.h"
#include "constants/trainer_types.h"
#define NUM_FORCED_MOVEMENTS 18
#define NUM_ACRO_BIKE_COLLISIONS 5
enum {
PLAYER_STILL,
PLAYER_TURNING,
PLAYER_MOVING,
};
static EWRAM_DATA u8 sSpinStartFacingDir = 0;
EWRAM_DATA struct ObjectEvent gObjectEvents[OBJECT_EVENTS_COUNT] = {};
EWRAM_DATA struct PlayerAvatar gPlayerAvatar = {};
@ -139,9 +148,7 @@ static void AlignFishingAnimationFrames(void);
static u8 TrySpinPlayerForWarp(struct ObjectEvent *object, s16 *a1);
// .rodata
static bool8 (*const sForcedMovementTestFuncs[])(u8) =
static bool8 (*const sForcedMovementTestFuncs[NUM_FORCED_MOVEMENTS])(u8) =
{
MetatileBehavior_IsTrickHouseSlipperyFloor,
MetatileBehavior_IsIce_2,
@ -163,7 +170,8 @@ static bool8 (*const sForcedMovementTestFuncs[])(u8) =
MetatileBehavior_IsMuddySlope,
};
static bool8 (*const sForcedMovementFuncs[])(void) =
// + 1 for ForcedMovement_None, which is excluded above
static bool8 (*const sForcedMovementFuncs[NUM_FORCED_MOVEMENTS + 1])(void) =
{
ForcedMovement_None,
ForcedMovement_Slip,
@ -188,12 +196,12 @@ static bool8 (*const sForcedMovementFuncs[])(void) =
static void (*const sPlayerNotOnBikeFuncs[])(u8, u16) =
{
PlayerNotOnBikeNotMoving,
PlayerNotOnBikeTurningInPlace,
PlayerNotOnBikeMoving,
[PLAYER_STILL] = PlayerNotOnBikeNotMoving,
[PLAYER_TURNING] = PlayerNotOnBikeTurningInPlace,
[PLAYER_MOVING] = PlayerNotOnBikeMoving,
};
static bool8 (*const sAcroBikeTrickMetatiles[])(u8) =
static bool8 (*const sAcroBikeTrickMetatiles[NUM_ACRO_BIKE_COLLISIONS])(u8) =
{
MetatileBehavior_IsBumpySlope,
MetatileBehavior_IsIsolatedVerticalRail,
@ -202,7 +210,7 @@ static bool8 (*const sAcroBikeTrickMetatiles[])(u8) =
MetatileBehavior_IsHorizontalRail,
};
static const u8 sAcroBikeTrickCollisionTypes[] = {
static const u8 sAcroBikeTrickCollisionTypes[NUM_ACRO_BIKE_COLLISIONS] = {
COLLISION_WHEELIE_HOP,
COLLISION_ISOLATED_VERTICAL_RAIL,
COLLISION_ISOLATED_HORIZONTAL_RAIL,
@ -232,33 +240,41 @@ static bool8 (*const sArrowWarpMetatileBehaviorChecks[])(u8) =
static const u8 sRivalAvatarGfxIds[][2] =
{
{OBJ_EVENT_GFX_RIVAL_BRENDAN_NORMAL, OBJ_EVENT_GFX_RIVAL_MAY_NORMAL},
{OBJ_EVENT_GFX_RIVAL_BRENDAN_MACH_BIKE, OBJ_EVENT_GFX_RIVAL_MAY_MACH_BIKE},
{OBJ_EVENT_GFX_RIVAL_BRENDAN_ACRO_BIKE, OBJ_EVENT_GFX_RIVAL_MAY_ACRO_BIKE},
{OBJ_EVENT_GFX_RIVAL_BRENDAN_SURFING, OBJ_EVENT_GFX_RIVAL_MAY_SURFING},
{OBJ_EVENT_GFX_BRENDAN_UNDERWATER, OBJ_EVENT_GFX_MAY_UNDERWATER},
{OBJ_EVENT_GFX_RIVAL_BRENDAN_FIELD_MOVE, OBJ_EVENT_GFX_RIVAL_MAY_FIELD_MOVE},
{OBJ_EVENT_GFX_BRENDAN_FISHING, OBJ_EVENT_GFX_MAY_FISHING},
{OBJ_EVENT_GFX_BRENDAN_WATERING, OBJ_EVENT_GFX_MAY_WATERING}
[PLAYER_AVATAR_STATE_NORMAL] = {OBJ_EVENT_GFX_RIVAL_BRENDAN_NORMAL, OBJ_EVENT_GFX_RIVAL_MAY_NORMAL},
[PLAYER_AVATAR_STATE_MACH_BIKE] = {OBJ_EVENT_GFX_RIVAL_BRENDAN_MACH_BIKE, OBJ_EVENT_GFX_RIVAL_MAY_MACH_BIKE},
[PLAYER_AVATAR_STATE_ACRO_BIKE] = {OBJ_EVENT_GFX_RIVAL_BRENDAN_ACRO_BIKE, OBJ_EVENT_GFX_RIVAL_MAY_ACRO_BIKE},
[PLAYER_AVATAR_STATE_SURFING] = {OBJ_EVENT_GFX_RIVAL_BRENDAN_SURFING, OBJ_EVENT_GFX_RIVAL_MAY_SURFING},
[PLAYER_AVATAR_STATE_UNDERWATER] = {OBJ_EVENT_GFX_BRENDAN_UNDERWATER, OBJ_EVENT_GFX_MAY_UNDERWATER},
[PLAYER_AVATAR_STATE_FIELD_MOVE] = {OBJ_EVENT_GFX_RIVAL_BRENDAN_FIELD_MOVE, OBJ_EVENT_GFX_RIVAL_MAY_FIELD_MOVE},
[PLAYER_AVATAR_STATE_FISHING] = {OBJ_EVENT_GFX_BRENDAN_FISHING, OBJ_EVENT_GFX_MAY_FISHING},
[PLAYER_AVATAR_STATE_WATERING] = {OBJ_EVENT_GFX_BRENDAN_WATERING, OBJ_EVENT_GFX_MAY_WATERING}
};
static const u8 sPlayerAvatarGfxIds[][2] =
{
{OBJ_EVENT_GFX_BRENDAN_NORMAL, OBJ_EVENT_GFX_MAY_NORMAL},
{OBJ_EVENT_GFX_BRENDAN_MACH_BIKE, OBJ_EVENT_GFX_MAY_MACH_BIKE},
{OBJ_EVENT_GFX_BRENDAN_ACRO_BIKE, OBJ_EVENT_GFX_MAY_ACRO_BIKE},
{OBJ_EVENT_GFX_BRENDAN_SURFING, OBJ_EVENT_GFX_MAY_SURFING},
{OBJ_EVENT_GFX_BRENDAN_UNDERWATER, OBJ_EVENT_GFX_MAY_UNDERWATER},
{OBJ_EVENT_GFX_BRENDAN_FIELD_MOVE, OBJ_EVENT_GFX_MAY_FIELD_MOVE},
{OBJ_EVENT_GFX_BRENDAN_FISHING, OBJ_EVENT_GFX_MAY_FISHING},
{OBJ_EVENT_GFX_BRENDAN_WATERING, OBJ_EVENT_GFX_MAY_WATERING},
[PLAYER_AVATAR_STATE_NORMAL] = {OBJ_EVENT_GFX_BRENDAN_NORMAL, OBJ_EVENT_GFX_MAY_NORMAL},
[PLAYER_AVATAR_STATE_MACH_BIKE] = {OBJ_EVENT_GFX_BRENDAN_MACH_BIKE, OBJ_EVENT_GFX_MAY_MACH_BIKE},
[PLAYER_AVATAR_STATE_ACRO_BIKE] = {OBJ_EVENT_GFX_BRENDAN_ACRO_BIKE, OBJ_EVENT_GFX_MAY_ACRO_BIKE},
[PLAYER_AVATAR_STATE_SURFING] = {OBJ_EVENT_GFX_BRENDAN_SURFING, OBJ_EVENT_GFX_MAY_SURFING},
[PLAYER_AVATAR_STATE_UNDERWATER] = {OBJ_EVENT_GFX_BRENDAN_UNDERWATER, OBJ_EVENT_GFX_MAY_UNDERWATER},
[PLAYER_AVATAR_STATE_FIELD_MOVE] = {OBJ_EVENT_GFX_BRENDAN_FIELD_MOVE, OBJ_EVENT_GFX_MAY_FIELD_MOVE},
[PLAYER_AVATAR_STATE_FISHING] = {OBJ_EVENT_GFX_BRENDAN_FISHING, OBJ_EVENT_GFX_MAY_FISHING},
[PLAYER_AVATAR_STATE_WATERING] = {OBJ_EVENT_GFX_BRENDAN_WATERING, OBJ_EVENT_GFX_MAY_WATERING},
};
static const u8 sFRLGAvatarGfxIds[] = {OBJ_EVENT_GFX_RED, OBJ_EVENT_GFX_LEAF};
static const u8 sFRLGAvatarGfxIds[GENDER_COUNT] =
{
[MALE] = OBJ_EVENT_GFX_RED,
[FEMALE] = OBJ_EVENT_GFX_LEAF
};
static const u8 sRSAvatarGfxIds[] = {OBJ_EVENT_GFX_LINK_RS_BRENDAN, OBJ_EVENT_GFX_LINK_RS_MAY};
static const u8 sRSAvatarGfxIds[GENDER_COUNT] =
{
[MALE] = OBJ_EVENT_GFX_LINK_RS_BRENDAN,
[FEMALE] = OBJ_EVENT_GFX_LINK_RS_MAY
};
static const u8 sPlayerAvatarGfxToStateFlag[2][5][2] =
static const u8 sPlayerAvatarGfxToStateFlag[GENDER_COUNT][5][2] =
{
[MALE] =
{
@ -306,8 +322,6 @@ static bool8 (*const sPlayerAvatarSecretBaseMatSpin[])(struct Task *, struct Obj
PlayerAvatar_SecretBaseMatSpinStep3,
};
// .text
void MovementType_Player(struct Sprite *sprite)
{
UpdateObjectEventCurrentMovement(&gObjectEvents[sprite->data[0]], sprite, ObjectEventCB2_NoMovement2);
@ -406,7 +420,7 @@ static u8 GetForcedMovementByMetatileBehavior(void)
{
u8 metatileBehavior = gObjectEvents[gPlayerAvatar.objectEventId].currentMetatileBehavior;
for (i = 0; i < 18; i++)
for (i = 0; i < NUM_FORCED_MOVEMENTS; i++)
{
if (sForcedMovementTestFuncs[i](metatileBehavior))
return i + 1;
@ -429,7 +443,7 @@ static bool8 ForcedMovement_None(void)
return FALSE;
}
static u8 DoForcedMovement(u8 direction, void (*b)(u8))
static bool8 DoForcedMovement(u8 direction, void (*moveFunc)(u8))
{
struct PlayerAvatar *playerAvatar = &gPlayerAvatar;
u8 collision = CheckForPlayerAvatarCollision(direction);
@ -440,7 +454,7 @@ static u8 DoForcedMovement(u8 direction, void (*b)(u8))
ForcedMovement_None();
if (collision < COLLISION_STOP_SURFING)
{
return 0;
return FALSE;
}
else
{
@ -448,23 +462,23 @@ static u8 DoForcedMovement(u8 direction, void (*b)(u8))
PlayerJumpLedge(direction);
playerAvatar->flags |= PLAYER_AVATAR_FLAG_FORCED_MOVE;
playerAvatar->runningState = MOVING;
return 1;
return TRUE;
}
}
else
{
playerAvatar->runningState = MOVING;
b(direction);
return 1;
moveFunc(direction);
return TRUE;
}
}
static u8 DoForcedMovementInCurrentDirection(void (*a)(u8))
static bool8 DoForcedMovementInCurrentDirection(void (*moveFunc)(u8))
{
struct ObjectEvent *playerObjEvent = &gObjectEvents[gPlayerAvatar.objectEventId];
playerObjEvent->disableAnim = TRUE;
return DoForcedMovement(playerObjEvent->movementDirection, a);
return DoForcedMovement(playerObjEvent->movementDirection, moveFunc);
}
static bool8 ForcedMovement_Slip(void)
@ -512,13 +526,13 @@ static bool8 ForcedMovement_PushedEastByCurrent(void)
return DoForcedMovement(DIR_EAST, PlayerRideWaterCurrent);
}
static u8 ForcedMovement_Slide(u8 direction, void (*b)(u8))
static bool8 ForcedMovement_Slide(u8 direction, void (*moveFunc)(u8))
{
struct ObjectEvent *playerObjEvent = &gObjectEvents[gPlayerAvatar.objectEventId];
playerObjEvent->disableAnim = TRUE;
playerObjEvent->facingDirectionLocked = TRUE;
return DoForcedMovement(direction, b);
return DoForcedMovement(direction, moveFunc);
}
static bool8 ForcedMovement_SlideSouth(void)
@ -579,17 +593,17 @@ static u8 CheckMovementInputNotOnBike(u8 direction)
if (direction == DIR_NONE)
{
gPlayerAvatar.runningState = NOT_MOVING;
return 0;
return PLAYER_STILL;
}
else if (direction != GetPlayerMovementDirection() && gPlayerAvatar.runningState != MOVING)
{
gPlayerAvatar.runningState = TURN_DIRECTION;
return 1;
return PLAYER_TURNING;
}
else
{
gPlayerAvatar.runningState = MOVING;
return 2;
return PLAYER_MOVING;
}
}
@ -755,7 +769,7 @@ static void CheckAcroBikeCollision(s16 x, s16 y, u8 metatileBehavior, u8 *collis
{
u8 i;
for (i = 0; i < ARRAY_COUNT(sAcroBikeTrickMetatiles); i++)
for (i = 0; i < NUM_ACRO_BIKE_COLLISIONS; i++)
{
if (sAcroBikeTrickMetatiles[i](metatileBehavior))
{

View File

@ -1408,10 +1408,10 @@ static void NamingScreen_CreatePlayerIcon(void)
u8 rivalGfxId;
u8 spriteId;
rivalGfxId = GetRivalAvatarGraphicsIdByStateIdAndGender(0, sNamingScreen->monSpecies);
rivalGfxId = GetRivalAvatarGraphicsIdByStateIdAndGender(PLAYER_AVATAR_STATE_NORMAL, sNamingScreen->monSpecies);
spriteId = CreateObjectGraphicsSprite(rivalGfxId, SpriteCallbackDummy, 56, 37, 0);
gSprites[spriteId].oam.priority = 3;
StartSpriteAnim(&gSprites[spriteId], 4);
StartSpriteAnim(&gSprites[spriteId], ANIM_STD_GO_SOUTH);
}
static void NamingScreen_CreatePCIcon(void)
@ -1438,7 +1438,7 @@ static void NamingScreen_CreateWaldaDadIcon(void)
spriteId = CreateObjectGraphicsSprite(OBJ_EVENT_GFX_MAN_1, SpriteCallbackDummy, 56, 37, 0);
gSprites[spriteId].oam.priority = 3;
StartSpriteAnim(&gSprites[spriteId], 4);
StartSpriteAnim(&gSprites[spriteId], ANIM_STD_GO_SOUTH);
}
//--------------------------------------------------