Document player avatar fields

This commit is contained in:
PikalaxALT
2020-03-25 20:40:44 -04:00
parent adc7a0b65a
commit 9cb08e3475
6 changed files with 59 additions and 56 deletions
+3 -3
View File
@@ -231,9 +231,9 @@ struct ObjectEventGraphicsInfo
#define PLAYER_AVATAR_FLAG_ACRO_BIKE (1 << 2) #define PLAYER_AVATAR_FLAG_ACRO_BIKE (1 << 2)
#define PLAYER_AVATAR_FLAG_SURFING (1 << 3) #define PLAYER_AVATAR_FLAG_SURFING (1 << 3)
#define PLAYER_AVATAR_FLAG_UNDERWATER (1 << 4) #define PLAYER_AVATAR_FLAG_UNDERWATER (1 << 4)
#define PLAYER_AVATAR_FLAG_FORCED_MVMT_DISABLED (1 << 5) #define PLAYER_AVATAR_FLAG_FIELD_MOVE (1 << 5)
#define PLAYER_AVATAR_FLAG_MVMT_IS_FORCED (1 << 6) #define PLAYER_AVATAR_FLAG_FISHING (1 << 6)
#define PLAYER_AVATAR_FLAG_DASH (1 << 7) #define PLAYER_AVATAR_FLAG_WATERING (1 << 7)
enum enum
{ {
+17 -16
View File
@@ -289,14 +289,14 @@ enum {
PLAYER_AVATAR_STATE_WATERING, PLAYER_AVATAR_STATE_WATERING,
}; };
#define PLAYER_AVATAR_FLAG_ON_FOOT (1 << PLAYER_AVATAR_STATE_NORMAL) #define PLAYER_AVATAR_FLAG_ON_FOOT (1 << PLAYER_AVATAR_STATE_NORMAL)
#define PLAYER_AVATAR_FLAG_MACH_BIKE (1 << PLAYER_AVATAR_STATE_MACH_BIKE) #define PLAYER_AVATAR_FLAG_MACH_BIKE (1 << PLAYER_AVATAR_STATE_MACH_BIKE)
#define PLAYER_AVATAR_FLAG_ACRO_BIKE (1 << PLAYER_AVATAR_STATE_ACRO_BIKE) #define PLAYER_AVATAR_FLAG_ACRO_BIKE (1 << PLAYER_AVATAR_STATE_ACRO_BIKE)
#define PLAYER_AVATAR_FLAG_SURFING (1 << PLAYER_AVATAR_STATE_SURFING) #define PLAYER_AVATAR_FLAG_SURFING (1 << PLAYER_AVATAR_STATE_SURFING)
#define PLAYER_AVATAR_FLAG_4 (1 << PLAYER_AVATAR_STATE_UNDERWATER) #define PLAYER_AVATAR_FLAG_UNDERWATER (1 << PLAYER_AVATAR_STATE_UNDERWATER)
#define PLAYER_AVATAR_FLAG_FORCED_MVMT_DISABLED (1 << PLAYER_AVATAR_STATE_FIELD_MOVE) #define PLAYER_AVATAR_FLAG_FIELD_MOVE (1 << PLAYER_AVATAR_STATE_FIELD_MOVE)
#define PLAYER_AVATAR_FLAG_MVMT_IS_FORCED (1 << PLAYER_AVATAR_STATE_FISHING) #define PLAYER_AVATAR_FLAG_FISHING (1 << PLAYER_AVATAR_STATE_FISHING)
#define PLAYER_AVATAR_FLAG_DASH (1 << PLAYER_AVATAR_STATE_WATERING) #define PLAYER_AVATAR_FLAG_WATERING (1 << PLAYER_AVATAR_STATE_WATERING)
enum enum
{ {
@@ -346,22 +346,23 @@ enum
struct PlayerAvatar /* 0x202E858 */ struct PlayerAvatar /* 0x202E858 */
{ {
/*0x00*/ u8 flags; /*0x00*/ u8 flags;
/*0x01*/ u8 unk1; // used to be bike, but it's not that in Emerald and probably isn't here either. maybe transition flags? /*0x01*/ u8 transitionFlags; // used to be bike, but it's not that in Emerald and probably isn't here either. maybe transition flags?
/*0x02*/ u8 runningState; // this is a static running state. 00 is not moving, 01 is turn direction, 02 is moving. /*0x02*/ u8 runningState; // this is a static running state. 00 is not moving, 01 is turn direction, 02 is moving.
/*0x03*/ u8 tileTransitionState; // this is a transition running state: 00 is not moving, 01 is transition between tiles, 02 means you are on the frame in which you have centered on a tile but are about to keep moving, even if changing directions. 2 is also used for a ledge hop, since you are transitioning. /*0x03*/ u8 tileTransitionState; // this is a transition running state: 00 is not moving, 01 is transition between tiles, 02 means you are on the frame in which you have centered on a tile but are about to keep moving, even if changing directions. 2 is also used for a ledge hop, since you are transitioning.
/*0x04*/ u8 spriteId; /*0x04*/ u8 spriteId;
/*0x05*/ u8 objectEventId; /*0x05*/ u8 objectEventId;
/*0x06*/ bool8 preventStep; /*0x06*/ bool8 preventStep;
/*0x07*/ u8 gender; /*0x07*/ u8 gender;
// These are not used in FRLG
u8 acroBikeState; u8 acroBikeState;
u8 unk9; u8 newDirBackup;
u8 bikeFrameCounter; u8 bikeFrameCounter;
u8 unkB; u8 bikeSpeed;
u32 unkC; u32 directionHistory;
u32 unk10; u32 abStartSelectHistory;
u8 unk14[8]; u8 dirTimerHistory[8];
u16 unk1C; // For the Rocket mazes
// TODO: rest of struct u16 lastSpinTile;
}; };
struct Camera struct Camera
+1 -1
View File
@@ -2207,7 +2207,7 @@ bool8 ObjectEventIsTrainerAndCloseToPlayer(struct ObjectEvent *objectEvent)
s16 minY; s16 minY;
s16 maxY; s16 maxY;
if (!TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_DASH)) if (!TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_WATERING))
{ {
return FALSE; return FALSE;
} }
+4 -4
View File
@@ -105,11 +105,11 @@ void FieldGetPlayerInput(struct FieldInput *input, u16 newKeys, u16 heldKeys)
{ {
if (GetPlayerSpeed() != 4) if (GetPlayerSpeed() != 4)
{ {
if ((newKeys & START_BUTTON) && !(gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_MVMT_IS_FORCED)) if ((newKeys & START_BUTTON) && !(gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_FISHING))
input->pressedStartButton = TRUE; input->pressedStartButton = TRUE;
if (gQuestLogState != QL_STATE_2 && gQuestLogState != QL_STATE_3) if (gQuestLogState != QL_STATE_2 && gQuestLogState != QL_STATE_3)
{ {
if (!(gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_MVMT_IS_FORCED)) if (!(gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_FISHING))
{ {
if (newKeys & SELECT_BUTTON) if (newKeys & SELECT_BUTTON)
input->pressedSelectButton = TRUE; input->pressedSelectButton = TRUE;
@@ -625,7 +625,7 @@ static bool8 TryStartStepBasedScript(struct MapPosition *position, u16 metatileB
return TRUE; return TRUE;
if (TryStartStepCountScript(metatileBehavior) == TRUE) if (TryStartStepCountScript(metatileBehavior) == TRUE)
return TRUE; return TRUE;
if (!(gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_MVMT_IS_FORCED) && !MetatileBehavior_IsForcedMovementTile(metatileBehavior) && UpdateRepelCounter() == TRUE) if (!(gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_FISHING) && !MetatileBehavior_IsForcedMovementTile(metatileBehavior) && UpdateRepelCounter() == TRUE)
return TRUE; return TRUE;
return FALSE; return FALSE;
} }
@@ -655,7 +655,7 @@ static bool8 TryStartStepCountScript(u16 metatileBehavior)
UpdateHappinessStepCounter(); UpdateHappinessStepCounter();
if (!(gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_MVMT_IS_FORCED) && !MetatileBehavior_IsForcedMovementTile(metatileBehavior)) if (!(gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_FISHING) && !MetatileBehavior_IsForcedMovementTile(metatileBehavior))
{ {
if (sub_810C4EC() == TRUE) if (sub_810C4EC() == TRUE)
{ {
+33 -31
View File
@@ -182,7 +182,7 @@ static void npc_clear_strange_bits(struct ObjectEvent *objEvent)
objEvent->inanimate = 0; objEvent->inanimate = 0;
objEvent->disableAnim = 0; objEvent->disableAnim = 0;
objEvent->facingDirectionLocked = 0; objEvent->facingDirectionLocked = 0;
gPlayerAvatar.flags &= ~PLAYER_AVATAR_FLAG_DASH; gPlayerAvatar.flags &= ~PLAYER_AVATAR_FLAG_WATERING;
} }
static void MovePlayerAvatarUsingKeypadInput(u8 direction, u16 newKeys, u16 heldKeys) static void MovePlayerAvatarUsingKeypadInput(u8 direction, u16 newKeys, u16 heldKeys)
@@ -197,12 +197,12 @@ static void MovePlayerAvatarUsingKeypadInput(u8 direction, u16 newKeys, u16 held
static void PlayerAllowForcedMovementIfMovingSameDirection(void) static void PlayerAllowForcedMovementIfMovingSameDirection(void)
{ {
if (gPlayerAvatar.runningState == MOVING) if (gPlayerAvatar.runningState == MOVING)
gPlayerAvatar.flags &= ~PLAYER_AVATAR_FLAG_FORCED_MVMT_DISABLED; gPlayerAvatar.flags &= ~PLAYER_AVATAR_FLAG_FIELD_MOVE;
} }
static bool8 sub_805B528(void) static bool8 sub_805B528(void)
{ {
if ((gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_MVMT_IS_FORCED) && MetatileBehavior_IsSpinTile(gPlayerAvatar.unk1C)) if ((gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_FISHING) && MetatileBehavior_IsSpinTile(gPlayerAvatar.lastSpinTile))
{ {
gUnknown_2036E30 = &gObjectEvents[gPlayerAvatar.objectEventId]; gUnknown_2036E30 = &gObjectEvents[gPlayerAvatar.objectEventId];
if (gUnknown_2036E30->heldMovementFinished) if (gUnknown_2036E30->heldMovementFinished)
@@ -213,10 +213,10 @@ static bool8 sub_805B528(void)
} }
if (MetatileBehavior_IsSpinTile(gUnknown_2036E30->currentMetatileBehavior)) if (MetatileBehavior_IsSpinTile(gUnknown_2036E30->currentMetatileBehavior))
{ {
gPlayerAvatar.unk1C = gUnknown_2036E30->currentMetatileBehavior; gPlayerAvatar.lastSpinTile = gUnknown_2036E30->currentMetatileBehavior;
} }
ObjectEventClearHeldMovement(gUnknown_2036E30); ObjectEventClearHeldMovement(gUnknown_2036E30);
sub_805C2CC(gPlayerAvatar.unk1C); sub_805C2CC(gPlayerAvatar.lastSpinTile);
} }
return TRUE; return TRUE;
} }
@@ -255,14 +255,14 @@ static bool8 TryDoMetatileBehaviorForcedMovement(void)
{ {
int i; int i;
u8 behavior; u8 behavior;
if (!(gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_FORCED_MVMT_DISABLED)) if (!(gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_FIELD_MOVE))
{ {
behavior = gObjectEvents[gPlayerAvatar.objectEventId].currentMetatileBehavior; behavior = gObjectEvents[gPlayerAvatar.objectEventId].currentMetatileBehavior;
for (i = 0; sForcedMovementFuncs[i].unk0 != NULL; i++) for (i = 0; sForcedMovementFuncs[i].unk0 != NULL; i++)
{ {
if (sForcedMovementFuncs[i].unk0(behavior)) if (sForcedMovementFuncs[i].unk0(behavior))
{ {
gPlayerAvatar.unk1C = behavior; gPlayerAvatar.lastSpinTile = behavior;
return sForcedMovementFuncs[i].unk4(); return sForcedMovementFuncs[i].unk4();
} }
} }
@@ -278,14 +278,14 @@ static bool8 TryDoMetatileBehaviorForcedMovement(void)
static bool8 ForcedMovement_None(void) static bool8 ForcedMovement_None(void)
{ {
if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_MVMT_IS_FORCED) if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_FISHING)
{ {
struct ObjectEvent *playerObjEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; struct ObjectEvent *playerObjEvent = &gObjectEvents[gPlayerAvatar.objectEventId];
playerObjEvent->facingDirectionLocked = FALSE; playerObjEvent->facingDirectionLocked = FALSE;
playerObjEvent->enableAnim = TRUE; playerObjEvent->enableAnim = TRUE;
SetObjectEventDirection(playerObjEvent, playerObjEvent->facingDirection); SetObjectEventDirection(playerObjEvent, playerObjEvent->facingDirection);
gPlayerAvatar.flags &= ~PLAYER_AVATAR_FLAG_MVMT_IS_FORCED; gPlayerAvatar.flags &= ~PLAYER_AVATAR_FLAG_FISHING;
} }
return FALSE; return FALSE;
} }
@@ -295,7 +295,7 @@ static u8 DoForcedMovement(u8 direction, MovementAction movementAction)
struct PlayerAvatar *playerAvatar = &gPlayerAvatar; struct PlayerAvatar *playerAvatar = &gPlayerAvatar;
u8 collision = CheckForPlayerAvatarCollision(direction); u8 collision = CheckForPlayerAvatarCollision(direction);
playerAvatar->flags |= PLAYER_AVATAR_FLAG_MVMT_IS_FORCED; playerAvatar->flags |= PLAYER_AVATAR_FLAG_FISHING;
if (collision) if (collision)
{ {
ForcedMovement_None(); ForcedMovement_None();
@@ -307,7 +307,7 @@ static u8 DoForcedMovement(u8 direction, MovementAction movementAction)
{ {
if (collision == COLLISION_LEDGE_JUMP) if (collision == COLLISION_LEDGE_JUMP)
PlayerJumpLedge(direction); PlayerJumpLedge(direction);
playerAvatar->flags |= PLAYER_AVATAR_FLAG_MVMT_IS_FORCED; playerAvatar->flags |= PLAYER_AVATAR_FLAG_FISHING;
playerAvatar->runningState = MOVING; playerAvatar->runningState = MOVING;
return 1; return 1;
} }
@@ -518,7 +518,7 @@ static void PlayerNotOnBikeMoving(u8 direction, u16 heldKeys)
PlayerRunSlow(direction); PlayerRunSlow(direction);
else else
PlayerRun(direction); PlayerRun(direction);
gPlayerAvatar.flags |= PLAYER_AVATAR_FLAG_DASH; gPlayerAvatar.flags |= PLAYER_AVATAR_FLAG_WATERING;
return; return;
} }
else else
@@ -676,25 +676,25 @@ static void CheckAcroBikeCollision(s16 x, s16 y, u8 metatileBehavior, u8 *collis
void SetPlayerAvatarTransitionFlags(bool16 flags) void SetPlayerAvatarTransitionFlags(bool16 flags)
{ {
gPlayerAvatar.unk1 |= flags; gPlayerAvatar.transitionFlags |= flags;
DoPlayerAvatarTransition(); DoPlayerAvatarTransition();
} }
static void (*const gUnknown_835B844[])(struct ObjectEvent *) = { static void (*const gUnknown_835B844[])(struct ObjectEvent *) = {
PlayerAvatarTransition_Normal, [PLAYER_AVATAR_STATE_NORMAL] = PlayerAvatarTransition_Normal,
PlayerAvatarTransition_Bike, [PLAYER_AVATAR_STATE_MACH_BIKE] = PlayerAvatarTransition_Bike,
PlayerAvatarTransition_Bike, [PLAYER_AVATAR_STATE_ACRO_BIKE] = PlayerAvatarTransition_Bike,
PlayerAvatarTransition_Surfing, [PLAYER_AVATAR_STATE_SURFING] = PlayerAvatarTransition_Surfing,
PlayerAvatarTransition_Underwater, [PLAYER_AVATAR_STATE_UNDERWATER] = PlayerAvatarTransition_Underwater,
PlayerAvatarTransition_ReturnToField, [PLAYER_AVATAR_STATE_FIELD_MOVE] = PlayerAvatarTransition_ReturnToField,
PlayerAvatarTransition_Dummy, [PLAYER_AVATAR_STATE_FISHING] = PlayerAvatarTransition_Dummy,
PlayerAvatarTransition_Dummy [PLAYER_AVATAR_STATE_WATERING] = PlayerAvatarTransition_Dummy
}; };
static void DoPlayerAvatarTransition(void) static void DoPlayerAvatarTransition(void)
{ {
u8 i; u8 i;
u8 flags = gPlayerAvatar.unk1; u8 flags = gPlayerAvatar.transitionFlags;
if (flags != 0) if (flags != 0)
{ {
@@ -703,7 +703,7 @@ static void DoPlayerAvatarTransition(void)
if (flags & 1) if (flags & 1)
gUnknown_835B844[i](&gObjectEvents[gPlayerAvatar.objectEventId]); gUnknown_835B844[i](&gObjectEvents[gPlayerAvatar.objectEventId]);
} }
gPlayerAvatar.unk1 = 0; gPlayerAvatar.transitionFlags = 0;
} }
} }
@@ -738,7 +738,7 @@ static void PlayerAvatarTransition_Underwater(struct ObjectEvent * playerObjEven
static void PlayerAvatarTransition_ReturnToField(struct ObjectEvent * playerObjEvent) static void PlayerAvatarTransition_ReturnToField(struct ObjectEvent * playerObjEvent)
{ {
gPlayerAvatar.flags |= PLAYER_AVATAR_FLAG_FORCED_MVMT_DISABLED; gPlayerAvatar.flags |= PLAYER_AVATAR_FLAG_FIELD_MOVE;
} }
void sub_805BEB8(void) void sub_805BEB8(void)
@@ -1229,7 +1229,7 @@ void ClearPlayerAvatarInfo(void)
void SetPlayerAvatarStateMask(u8 flags) void SetPlayerAvatarStateMask(u8 flags)
{ {
gPlayerAvatar.flags &= (PLAYER_AVATAR_FLAG_DASH | PLAYER_AVATAR_FLAG_MVMT_IS_FORCED | PLAYER_AVATAR_FLAG_FORCED_MVMT_DISABLED); gPlayerAvatar.flags &= (PLAYER_AVATAR_FLAG_WATERING | PLAYER_AVATAR_FLAG_FISHING | PLAYER_AVATAR_FLAG_FIELD_MOVE);
gPlayerAvatar.flags |= flags; gPlayerAvatar.flags |= flags;
} }
@@ -1277,7 +1277,7 @@ void SetPlayerAvatarExtraStateTransition(u8 graphicsId, u8 b)
{ {
u8 unk = GetPlayerAvatarStateTransitionByGraphicsId(graphicsId, gPlayerAvatar.gender); u8 unk = GetPlayerAvatarStateTransitionByGraphicsId(graphicsId, gPlayerAvatar.gender);
gPlayerAvatar.unk1 |= unk | b; gPlayerAvatar.transitionFlags |= unk | b;
DoPlayerAvatarTransition(); DoPlayerAvatarTransition();
} }
@@ -1310,7 +1310,7 @@ void InitPlayerAvatar(s16 x, s16 y, u8 direction, u8 gender)
gPlayerAvatar.objectEventId = objectEventId; gPlayerAvatar.objectEventId = objectEventId;
gPlayerAvatar.spriteId = objectEvent->spriteId; gPlayerAvatar.spriteId = objectEvent->spriteId;
gPlayerAvatar.gender = gender; gPlayerAvatar.gender = gender;
SetPlayerAvatarStateMask(PLAYER_AVATAR_FLAG_FORCED_MVMT_DISABLED | PLAYER_AVATAR_FLAG_ON_FOOT); SetPlayerAvatarStateMask(PLAYER_AVATAR_FLAG_FIELD_MOVE | PLAYER_AVATAR_FLAG_ON_FOOT);
} }
void SetPlayerInvisibility(bool8 invisible) void SetPlayerInvisibility(bool8 invisible)
@@ -1482,7 +1482,7 @@ static bool8 PlayerAvatar_DoSecretBaseMatJump(struct Task *task, struct ObjectEv
if (task->data[1] > 1) if (task->data[1] > 1)
{ {
gPlayerAvatar.preventStep = FALSE; gPlayerAvatar.preventStep = FALSE;
gPlayerAvatar.unk1 |= 0x20; gPlayerAvatar.transitionFlags |= PLAYER_AVATAR_FLAG_FIELD_MOVE;
DestroyTask(FindTaskIdByFunc(DoPlayerAvatarSecretBaseMatJump)); DestroyTask(FindTaskIdByFunc(DoPlayerAvatarSecretBaseMatJump));
} }
} }
@@ -1990,6 +1990,7 @@ void AlignFishingAnimationFrames(struct Sprite * playerSprite)
#define tFinalFacingDirection data[5] #define tFinalFacingDirection data[5]
#define tPriority data[6] #define tPriority data[6]
#define tSubpriority data[7] #define tSubpriority data[7]
#define tLandingDelay data[8]
static const u8 sTeleportFacingDirectionSequence[] = { static const u8 sTeleportFacingDirectionSequence[] = {
[DIR_SOUTH] = DIR_WEST, [DIR_SOUTH] = DIR_WEST,
@@ -2111,14 +2112,14 @@ static void Task_TeleportWarpInPlayerAnim(u8 taskId)
if (sprite->pos1.y >= tYpos) if (sprite->pos1.y >= tYpos)
{ {
sprite->pos1.y = tYpos; sprite->pos1.y = tYpos;
data[8] = 0; tLandingDelay = 0;
tState++; tState++;
} }
break; break;
case 2: case 2:
TeleportAnim_RotatePlayer(object, &tRotationTimer); TeleportAnim_RotatePlayer(object, &tRotationTimer);
data[8]++; tLandingDelay++;
if (data[8] > 8) if (tLandingDelay > 8)
{ {
tState++; tState++;
} }
@@ -2153,6 +2154,7 @@ static u8 TeleportAnim_RotatePlayer(struct ObjectEvent *object, s16 *a1)
return sTeleportFacingDirectionSequence[object->facingDirection]; return sTeleportFacingDirectionSequence[object->facingDirection];
} }
#undef tLandingDelay
#undef tSubpriority #undef tSubpriority
#undef tPriority #undef tPriority
#undef tFinalFacingDirection #undef tFinalFacingDirection
+1 -1
View File
@@ -308,7 +308,7 @@ static bool8 ItemUseCheckFunc_Rod(void)
if (MetatileBehavior_IsWaterfall(behavior)) if (MetatileBehavior_IsWaterfall(behavior))
return FALSE; return FALSE;
if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_4)) if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_UNDERWATER))
return FALSE; return FALSE;
if (!TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_SURFING)) if (!TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_SURFING))
{ {