From dbac777d95875b49e98da94551a89616c2addf3c Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 22 Mar 2020 20:17:47 -0400 Subject: through CheckMovementInputNotOnBike --- src/event_object_movement.c | 4 +- src/field_control_avatar.c | 10 +- src/field_player_avatar.c | 405 ++++++++++++++++++++++++++++++++++++++++++++ src/metatile_behavior.c | 8 +- 4 files changed, 416 insertions(+), 11 deletions(-) create mode 100644 src/field_player_avatar.c (limited to 'src') diff --git a/src/event_object_movement.c b/src/event_object_movement.c index a399ddf5e..dbde0cb93 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -4623,8 +4623,8 @@ dirn_to_anim(sub_8063FDC, gUnknown_83A650F); dirn_to_anim(sub_8064008, gUnknown_83A6514); dirn_to_anim(GetWalkFastestMovementAction, gUnknown_83A6519); dirn_to_anim(GetSlideMovementAction, gUnknown_83A651E); -dirn_to_anim(sub_806408C, gUnknown_83A6523); -dirn_to_anim(sub_80640B8, gUnknown_83A6528); +dirn_to_anim(GetPlayerRunMovementAction, gUnknown_83A6523); +dirn_to_anim(GetPlayerRunSlowMovementAction, gUnknown_83A6528); dirn_to_anim(sub_80640E4, gUnknown_83A652D); dirn_to_anim(GetJump2MovementAction, gUnknown_83A6532); dirn_to_anim(GetJumpInPlaceMovementAction, gUnknown_83A6537); diff --git a/src/field_control_avatar.c b/src/field_control_avatar.c index 89b90ca92..da3fb4a03 100644 --- a/src/field_control_avatar.c +++ b/src/field_control_avatar.c @@ -105,11 +105,11 @@ void FieldGetPlayerInput(struct FieldInput *input, u16 newKeys, u16 heldKeys) { if (GetPlayerSpeed() != 4) { - if ((newKeys & START_BUTTON) && !(gPlayerAvatar.flags & 0x40)) + if ((newKeys & START_BUTTON) && !(gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_MVMT_IS_FORCED)) input->pressedStartButton = TRUE; if (gQuestLogState != QL_STATE_2 && gQuestLogState != QL_STATE_3) { - if (!(gPlayerAvatar.flags & 0x40)) + if (!(gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_MVMT_IS_FORCED)) { if (newKeys & SELECT_BUTTON) input->pressedSelectButton = TRUE; @@ -625,7 +625,7 @@ static bool8 TryStartStepBasedScript(struct MapPosition *position, u16 metatileB return TRUE; if (TryStartStepCountScript(metatileBehavior) == TRUE) return TRUE; - if (!(gPlayerAvatar.flags & 0x40) && !MetatileBehavior_IsForcedMovementTile(metatileBehavior) && UpdateRepelCounter() == TRUE) + if (!(gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_MVMT_IS_FORCED) && !MetatileBehavior_IsForcedMovementTile(metatileBehavior) && UpdateRepelCounter() == TRUE) return TRUE; return FALSE; } @@ -655,7 +655,7 @@ static bool8 TryStartStepCountScript(u16 metatileBehavior) UpdateHappinessStepCounter(); - if (!(gPlayerAvatar.flags & 0x40) && !MetatileBehavior_IsForcedMovementTile(metatileBehavior)) + if (!(gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_MVMT_IS_FORCED) && !MetatileBehavior_IsForcedMovementTile(metatileBehavior)) { if (sub_810C4EC() == TRUE) { @@ -839,7 +839,7 @@ static bool8 TryArrowWarp(struct MapPosition *position, u16 metatileBehavior, u8 else if (sub_806DB84(metatileBehavior, direction) == TRUE) { delay = 0; - if (gPlayerAvatar.flags & 6) + if (gPlayerAvatar.flags & (PLAYER_AVATAR_FLAG_MACH_BIKE | PLAYER_AVATAR_FLAG_ACRO_BIKE)) { SetPlayerAvatarTransitionFlags(1); delay = 12; diff --git a/src/field_player_avatar.c b/src/field_player_avatar.c new file mode 100644 index 000000000..33c68a253 --- /dev/null +++ b/src/field_player_avatar.c @@ -0,0 +1,405 @@ +#include "global.h" +#include "gflib.h" +#include "bike.h" +#include "event_object_movement.h" +#include "field_player_avatar.h" +#include "metatile_behavior.h" +#include "constants/event_object_movement.h" +#include "constants/songs.h" + +EWRAM_DATA struct ObjectEvent * gUnknown_2036E30 = NULL; +EWRAM_DATA bool8 gUnknown_2036E34 = FALSE; +EWRAM_DATA struct ObjectEvent gObjectEvents[OBJECT_EVENTS_COUNT] = {}; +EWRAM_DATA struct PlayerAvatar gPlayerAvatar = {}; + +u8 ObjectEventCB2_NoMovement2(struct ObjectEvent * object, struct Sprite * sprite); +bool8 sub_805B528(void); +bool8 TryInterruptObjectEventSpecialAnim(struct ObjectEvent * playerObjEvent, u8 direction); +void npc_clear_strange_bits(struct ObjectEvent * playerObjEvent); +void DoPlayerAvatarTransition(void); +bool8 TryDoMetatileBehaviorForcedMovement(void); +void MovePlayerAvatarUsingKeypadInput(u8 direction, u16 newKeys, u16 heldKeys); +void PlayerAllowForcedMovementIfMovingSameDirection(void); +bool8 ForcedMovement_None(void); +void PlayerJumpLedge(u8 direction); +u8 CheckForPlayerAvatarCollision(u8 direction); +bool8 ForcedMovement_Slip(void); +bool8 ForcedMovement_WalkSouth(void); +bool8 ForcedMovement_WalkNorth(void); +bool8 ForcedMovement_WalkWest(void); +bool8 ForcedMovement_WalkEast(void); +bool8 ForcedMovement_SpinRight(void); +bool8 ForcedMovement_SpinLeft(void); +bool8 ForcedMovement_SpinUp(void); +bool8 ForcedMovement_SpinDown(void); +void PlaySpinSound(void); +bool8 ForcedMovement_PushedSouthByCurrent(void); +bool8 ForcedMovement_PushedNorthByCurrent(void); +bool8 ForcedMovement_PushedWestByCurrent(void); +bool8 ForcedMovement_PushedEastByCurrent(void); +bool8 ForcedMovement_SlideSouth(void); +bool8 ForcedMovement_SlideNorth(void); +bool8 ForcedMovement_SlideWest(void); +bool8 ForcedMovement_SlideEast(void); +bool8 ForcedMovement_0xBB(void); +bool8 ForcedMovement_0xBC(void); +u8 CheckMovementInputNotOnBike(u8 direction); +void PlayerNotOnBikeNotMoving(u8 direction, u16 heldKeys); +void PlayerNotOnBikeTurningInPlace(u8 direction, u16 heldKeys); +void PlayerNotOnBikeMoving(u8 direction, u16 heldKeys); +void PlayerGoSpeed2(u8 direction); +void PlayerGoSpeed1(u8 direction); +void PlayerGoSpin(u8 direction); +void PlayerRideWaterCurrent(u8 direction); +void sub_805C2CC(u8 metatileBehavior); +void sub_805CC40(struct ObjectEvent * playerObjEvent); +void DoPlayerMatJump(void); +void DoPlayerMatSpin(void); + +void MovementType_Player(struct Sprite *sprite) +{ + UpdateObjectEventCurrentMovement(&gObjectEvents[sprite->data[0]], sprite, ObjectEventCB2_NoMovement2); +} + +u8 ObjectEventCB2_NoMovement2(struct ObjectEvent * object, struct Sprite * sprite) +{ + return 0; +} + +void player_step(u8 direction, u16 newKeys, u16 heldKeys) +{ + struct ObjectEvent *playerObjEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; + + sub_805CC40(playerObjEvent); + if (!gPlayerAvatar.preventStep && !sub_805B528()) + { + if (!TryInterruptObjectEventSpecialAnim(playerObjEvent, direction)) + { + npc_clear_strange_bits(playerObjEvent); + DoPlayerAvatarTransition(); + if (!TryDoMetatileBehaviorForcedMovement()) + { + MovePlayerAvatarUsingKeypadInput(direction, newKeys, heldKeys); + PlayerAllowForcedMovementIfMovingSameDirection(); + } + } + } +} + +bool8 TryInterruptObjectEventSpecialAnim(struct ObjectEvent *playerObjEvent, u8 direction) +{ + + if (ObjectEventIsMovementOverridden(playerObjEvent) + && !ObjectEventClearHeldMovementIfFinished(playerObjEvent)) + { + u8 heldMovementActionId = ObjectEventGetHeldMovementActionId(playerObjEvent); + if (heldMovementActionId > MOVEMENT_ACTION_WALK_FAST_RIGHT && heldMovementActionId < MOVEMENT_ACTION_WALK_IN_PLACE_NORMAL_DOWN) + { + if (direction != DIR_NONE && playerObjEvent->movementDirection != direction) + { + ObjectEventClearHeldMovement(playerObjEvent); + return FALSE; + } + } + + return TRUE; + } + + return FALSE; +} + +void npc_clear_strange_bits(struct ObjectEvent *objEvent) +{ + objEvent->inanimate = 0; + objEvent->disableAnim = 0; + objEvent->facingDirectionLocked = 0; + gPlayerAvatar.flags &= ~PLAYER_AVATAR_FLAG_DASH; +} + +void MovePlayerAvatarUsingKeypadInput(u8 direction, u16 newKeys, u16 heldKeys) +{ + if ((gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_MACH_BIKE) + || (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_ACRO_BIKE)) + MovePlayerOnBike(direction, newKeys, heldKeys); + else + MovePlayerNotOnBike(direction, heldKeys); +} + +void PlayerAllowForcedMovementIfMovingSameDirection(void) +{ + if (gPlayerAvatar.runningState == MOVING) + gPlayerAvatar.flags &= ~PLAYER_AVATAR_FLAG_FORCED_MVMT_DISABLED; +} + +bool8 sub_805B528(void) +{ + if ((gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_MVMT_IS_FORCED) && MetatileBehavior_IsSpinTile(gPlayerAvatar.unk1C)) + { + gUnknown_2036E30 = &gObjectEvents[gPlayerAvatar.objectEventId]; + if (gUnknown_2036E30->heldMovementFinished) + { + if (MetatileBehavior_IsStopSpinning(gUnknown_2036E30->currentMetatileBehavior)) + { + return FALSE; + } + if (MetatileBehavior_IsSpinTile(gUnknown_2036E30->currentMetatileBehavior)) + { + gPlayerAvatar.unk1C = gUnknown_2036E30->currentMetatileBehavior; + } + ObjectEventClearHeldMovement(gUnknown_2036E30); + sub_805C2CC(gPlayerAvatar.unk1C); + } + return TRUE; + } + return FALSE; +} + +const struct { + bool8 (*unk0)(u8 metatileBehavior); + bool8 (*unk4)(void); +} sForcedMovementFuncs[] = { + {MetatileBehavior_IsUnknownMovement48, ForcedMovement_Slip}, + {MetatileBehavior_IsIce_2, ForcedMovement_Slip}, + {MetatileBehavior_IsWalkSouth, ForcedMovement_WalkSouth}, + {MetatileBehavior_IsWalkNorth, ForcedMovement_WalkNorth}, + {MetatileBehavior_IsWalkWest, ForcedMovement_WalkWest}, + {MetatileBehavior_IsWalkEast, ForcedMovement_WalkEast}, + {MetatileBehavior_IsSouthwardCurrent, ForcedMovement_PushedSouthByCurrent}, + {MetatileBehavior_IsNorthwardCurrent, ForcedMovement_PushedNorthByCurrent}, + {MetatileBehavior_IsWestwardCurrent, ForcedMovement_PushedWestByCurrent}, + {MetatileBehavior_IsEastwardCurrent, ForcedMovement_PushedEastByCurrent}, + {MetatileBehavior_IsSpinRight, ForcedMovement_SpinRight}, + {MetatileBehavior_IsSpinLeft, ForcedMovement_SpinLeft}, + {MetatileBehavior_IsSpinUp, ForcedMovement_SpinUp}, + {MetatileBehavior_IsSpinDown, ForcedMovement_SpinDown}, + {MetatileBehavior_IsSlideSouth, ForcedMovement_SlideSouth}, + {MetatileBehavior_IsSlideNorth, ForcedMovement_SlideNorth}, + {MetatileBehavior_IsSlideWest, ForcedMovement_SlideWest}, + {MetatileBehavior_IsSlideEast, ForcedMovement_SlideEast}, + {MetatileBehavior_IsWaterfall, ForcedMovement_PushedSouthByCurrent}, + {MetatileBehavior_UnusedReturnFalse_7, ForcedMovement_0xBB}, + {MetatileBehavior_UnusedReturnFalse_8, ForcedMovement_0xBC}, + {NULL, ForcedMovement_None}, +}; + +bool8 TryDoMetatileBehaviorForcedMovement(void) +{ + int i; + u8 behavior; + if (!(gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_FORCED_MVMT_DISABLED)) + { + behavior = gObjectEvents[gPlayerAvatar.objectEventId].currentMetatileBehavior; + for (i = 0; sForcedMovementFuncs[i].unk0 != NULL; i++) + { + if (sForcedMovementFuncs[i].unk0(behavior)) + { + gPlayerAvatar.unk1C = behavior; + return sForcedMovementFuncs[i].unk4(); + } + } + return sForcedMovementFuncs[i].unk4(); + } + else + { + for (i = 0; sForcedMovementFuncs[i].unk0 != NULL; i++) + ; + return sForcedMovementFuncs[i].unk4(); + } +} + +bool8 ForcedMovement_None(void) +{ + if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_MVMT_IS_FORCED) + { + struct ObjectEvent *playerObjEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; + + playerObjEvent->facingDirectionLocked = FALSE; + playerObjEvent->enableAnim = TRUE; + SetObjectEventDirection(playerObjEvent, playerObjEvent->facingDirection); + gPlayerAvatar.flags &= ~PLAYER_AVATAR_FLAG_MVMT_IS_FORCED; + } + return FALSE; +} + +u8 DoForcedMovement(u8 direction, MovementAction movementAction) +{ + struct PlayerAvatar *playerAvatar = &gPlayerAvatar; + u8 collision = CheckForPlayerAvatarCollision(direction); + + playerAvatar->flags |= PLAYER_AVATAR_FLAG_MVMT_IS_FORCED; + if (collision) + { + ForcedMovement_None(); + if (collision < COLLISION_STOP_SURFING) + { + return 0; + } + else + { + if (collision == COLLISION_LEDGE_JUMP) + PlayerJumpLedge(direction); + playerAvatar->flags |= PLAYER_AVATAR_FLAG_MVMT_IS_FORCED; + playerAvatar->runningState = MOVING; + return 1; + } + } + else + { + playerAvatar->runningState = MOVING; + movementAction(direction); + return 1; + } +} + +u8 DoForcedMovementInCurrentDirection(MovementAction movementAction) +{ + struct ObjectEvent *playerObjEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; + + playerObjEvent->disableAnim = TRUE; + return DoForcedMovement(playerObjEvent->movementDirection, movementAction); +} + +bool8 ForcedMovement_Slip(void) +{ + return DoForcedMovementInCurrentDirection(PlayerGoSpeed2); +} + +bool8 ForcedMovement_WalkSouth(void) +{ + return DoForcedMovement(DIR_SOUTH, PlayerGoSpeed1); +} + +bool8 ForcedMovement_WalkNorth(void) +{ + return DoForcedMovement(DIR_NORTH, PlayerGoSpeed1); +} + +bool8 ForcedMovement_WalkWest(void) +{ + return DoForcedMovement(DIR_WEST, PlayerGoSpeed1); +} + +bool8 ForcedMovement_WalkEast(void) +{ + return DoForcedMovement(DIR_EAST, PlayerGoSpeed1); +} + +bool8 ForcedMovement_SpinRight(void) +{ + PlaySpinSound(); + return DoForcedMovement(DIR_EAST, PlayerGoSpin); +} + +bool8 ForcedMovement_SpinLeft(void) +{ + PlaySpinSound(); + return DoForcedMovement(DIR_WEST, PlayerGoSpin); +} + +bool8 ForcedMovement_SpinUp(void) +{ + PlaySpinSound(); + return DoForcedMovement(DIR_NORTH, PlayerGoSpin); +} + +bool8 ForcedMovement_SpinDown(void) +{ + PlaySpinSound(); + return DoForcedMovement(DIR_SOUTH, PlayerGoSpin); +} + +void PlaySpinSound(void) +{ + PlaySE(SE_W013B); +} + +bool8 ForcedMovement_PushedSouthByCurrent(void) +{ + return DoForcedMovement(DIR_SOUTH, PlayerRideWaterCurrent); +} + +bool8 ForcedMovement_PushedNorthByCurrent(void) +{ + return DoForcedMovement(DIR_NORTH, PlayerRideWaterCurrent); +} + +bool8 ForcedMovement_PushedWestByCurrent(void) +{ + return DoForcedMovement(DIR_WEST, PlayerRideWaterCurrent); +} + +bool8 ForcedMovement_PushedEastByCurrent(void) +{ + return DoForcedMovement(DIR_EAST, PlayerRideWaterCurrent); +} + +u8 ForcedMovement_Slide(u8 direction, MovementAction movementAction) +{ + struct ObjectEvent *playerObjEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; + + playerObjEvent->disableAnim = TRUE; + playerObjEvent->facingDirectionLocked = TRUE; + return DoForcedMovement(direction, movementAction); +} + +bool8 ForcedMovement_SlideSouth(void) +{ + return ForcedMovement_Slide(DIR_SOUTH, PlayerGoSpeed2); +} + +bool8 ForcedMovement_SlideNorth(void) +{ + return ForcedMovement_Slide(DIR_NORTH, PlayerGoSpeed2); +} + +bool8 ForcedMovement_SlideWest(void) +{ + return ForcedMovement_Slide(DIR_WEST, PlayerGoSpeed2); +} + +bool8 ForcedMovement_SlideEast(void) +{ + return ForcedMovement_Slide(DIR_EAST, PlayerGoSpeed2); +} + +bool8 ForcedMovement_0xBB(void) +{ + DoPlayerMatJump(); + return TRUE; +} + +bool8 ForcedMovement_0xBC(void) +{ + DoPlayerMatSpin(); + return TRUE; +} + +void (*const gUnknown_835B814[])(u8, u16) = { + PlayerNotOnBikeNotMoving, + PlayerNotOnBikeTurningInPlace, + PlayerNotOnBikeMoving +}; + +void MovePlayerNotOnBike(u8 direction, u16 heldKeys) +{ + gUnknown_835B814[CheckMovementInputNotOnBike(direction)](direction, heldKeys); +} + +u8 CheckMovementInputNotOnBike(u8 direction) +{ + if (direction == DIR_NONE) + { + gPlayerAvatar.runningState = NOT_MOVING; + return 0; + } + else if (direction != GetPlayerMovementDirection() && gPlayerAvatar.runningState != MOVING) + { + gPlayerAvatar.runningState = TURN_DIRECTION; + return 1; + } + else + { + gPlayerAvatar.runningState = MOVING; + return 2; + } +} diff --git a/src/metatile_behavior.c b/src/metatile_behavior.c index d6a983744..988c9fad0 100644 --- a/src/metatile_behavior.c +++ b/src/metatile_behavior.c @@ -750,7 +750,7 @@ bool8 TestMetatileAttributeBit(u8 arg1, u8 arg2) return FALSE; } -bool8 MetatileBehavior_UnusedIsSpinRight(u8 metatileBehavior) +bool8 MetatileBehavior_IsSpinRight(u8 metatileBehavior) { if(metatileBehavior == MB_SPIN_RIGHT) return TRUE; @@ -758,7 +758,7 @@ bool8 MetatileBehavior_UnusedIsSpinRight(u8 metatileBehavior) return FALSE; } -bool8 MetatileBehavior_UnusedIsSpinLeft(u8 metatileBehavior) +bool8 MetatileBehavior_IsSpinLeft(u8 metatileBehavior) { if(metatileBehavior == MB_SPIN_LEFT) return TRUE; @@ -766,7 +766,7 @@ bool8 MetatileBehavior_UnusedIsSpinLeft(u8 metatileBehavior) return FALSE; } -bool8 MetatileBehavior_UnusedIsSpinUp(u8 metatileBehavior) +bool8 MetatileBehavior_IsSpinUp(u8 metatileBehavior) { if(metatileBehavior == MB_SPIN_UP) return TRUE; @@ -774,7 +774,7 @@ bool8 MetatileBehavior_UnusedIsSpinUp(u8 metatileBehavior) return FALSE; } -bool8 MetatileBehavior_UnusedIsSpinDown(u8 metatileBehavior) +bool8 MetatileBehavior_IsSpinDown(u8 metatileBehavior) { if(metatileBehavior == MB_SPIN_DOWN) return TRUE; -- cgit v1.2.3 From f9a3607824d00f17999288e241fc3ad339716279 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 23 Mar 2020 08:54:37 -0400 Subject: through CheckForObjectEventCollision --- src/field_player_avatar.c | 132 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 130 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/field_player_avatar.c b/src/field_player_avatar.c index 33c68a253..5b2820f96 100644 --- a/src/field_player_avatar.c +++ b/src/field_player_avatar.c @@ -1,11 +1,16 @@ #include "global.h" #include "gflib.h" #include "bike.h" +#include "event_data.h" #include "event_object_movement.h" +#include "fieldmap.h" +#include "field_control_avatar.h" #include "field_player_avatar.h" #include "metatile_behavior.h" +#include "overworld.h" #include "constants/event_object_movement.h" #include "constants/songs.h" +#include "constants/flags.h" EWRAM_DATA struct ObjectEvent * gUnknown_2036E30 = NULL; EWRAM_DATA bool8 gUnknown_2036E34 = FALSE; @@ -21,8 +26,6 @@ bool8 TryDoMetatileBehaviorForcedMovement(void); void MovePlayerAvatarUsingKeypadInput(u8 direction, u16 newKeys, u16 heldKeys); void PlayerAllowForcedMovementIfMovingSameDirection(void); bool8 ForcedMovement_None(void); -void PlayerJumpLedge(u8 direction); -u8 CheckForPlayerAvatarCollision(u8 direction); bool8 ForcedMovement_Slip(void); bool8 ForcedMovement_WalkSouth(void); bool8 ForcedMovement_WalkNorth(void); @@ -47,8 +50,22 @@ u8 CheckMovementInputNotOnBike(u8 direction); void PlayerNotOnBikeNotMoving(u8 direction, u16 heldKeys); void PlayerNotOnBikeTurningInPlace(u8 direction, u16 heldKeys); void PlayerNotOnBikeMoving(u8 direction, u16 heldKeys); +bool32 PlayerIsMovingOnRockStairs(u8 direction); +u8 CheckForPlayerAvatarCollision(u8 direction); +u8 CheckForObjectEventCollision(struct ObjectEvent * objectEvent, s16 x, s16 y, u8 direction, u8 metatileBehavior); +bool8 CanStopSurfing(s16 x, s16 y, u8 direction); +bool8 ShouldJumpLedge(s16 x, s16 y, u8 direction); +bool8 TryPushBoulder(s16 x, s16 y, u8 direction); +bool8 CheckAcroBikeCollision(s16 x, s16 y, u8 metatileBehavior, u8 *collision); +void PlayerNotOnBikeCollide(u8 direction); +void PlayerRun(u8 direction); +void PlayerRunSlow(u8 direction); +void PlayerFaceDirection(u8 direction); +void PlayerTurnInPlace(u8 direction); void PlayerGoSpeed2(u8 direction); void PlayerGoSpeed1(u8 direction); +void PlayerJumpLedge(u8 direction); +void PlayerGoSlow(u8 direction); void PlayerGoSpin(u8 direction); void PlayerRideWaterCurrent(u8 direction); void sub_805C2CC(u8 metatileBehavior); @@ -403,3 +420,114 @@ u8 CheckMovementInputNotOnBike(u8 direction) return 2; } } + +void PlayerNotOnBikeNotMoving(u8 direction, u16 heldKeys) +{ + PlayerFaceDirection(GetPlayerFacingDirection()); +} + +void PlayerNotOnBikeTurningInPlace(u8 direction, u16 heldKeys) +{ + PlayerTurnInPlace(direction); +} + +void PlayerNotOnBikeMoving(u8 direction, u16 heldKeys) +{ + u8 collision = CheckForPlayerAvatarCollision(direction); + + if (collision != COLLISION_NONE) + { + if (collision == COLLISION_LEDGE_JUMP) + { + PlayerJumpLedge(direction); + } + else if (collision == COLLISION_UNKNOWN_WARP_6C_6D_6E_6F) + { + PlayerFaceDirection(direction); + } + else if (collision != COLLISION_STOP_SURFING && collision != COLLISION_LEDGE_JUMP && collision != COLLISION_PUSHED_BOULDER && collision != COLLISION_UNKNOWN_WARP_6C_6D_6E_6F) + { + PlayerNotOnBikeCollide(direction); + } + return; + } + + if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_SURFING) + { + // speed 2 is fast, same speed as running + PlayerGoSpeed2(direction); + return; + } + + if ((heldKeys & B_BUTTON) && FlagGet(FLAG_SYS_B_DASH) + && !IsRunningDisallowed(gObjectEvents[gPlayerAvatar.objectEventId].currentMetatileBehavior)) + { + if (PlayerIsMovingOnRockStairs(direction)) + PlayerRunSlow(direction); + else + PlayerRun(direction); + gPlayerAvatar.flags |= PLAYER_AVATAR_FLAG_DASH; + return; + } + else + { + if (PlayerIsMovingOnRockStairs(direction)) + PlayerGoSlow(direction); + else + PlayerGoSpeed1(direction); + } +} + +bool32 PlayerIsMovingOnRockStairs(u8 direction) +{ + struct ObjectEvent * objectEvent; + s16 x, y; + + objectEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; + x = objectEvent->currentCoords.x; + y = objectEvent->currentCoords.y; + switch (direction) + { + case DIR_NORTH: + return MetatileBehavior_IsRockStairs(MapGridGetMetatileBehaviorAt(x, y)); + case DIR_SOUTH: + MoveCoords(DIR_SOUTH, &x, &y); + return MetatileBehavior_IsRockStairs(MapGridGetMetatileBehaviorAt(x, y)); + default: + return FALSE; + } +} + +u8 CheckForPlayerAvatarCollision(u8 direction) +{ + s16 x, y; + struct ObjectEvent *playerObjEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; + + x = playerObjEvent->currentCoords.x; + y = playerObjEvent->currentCoords.y; + if (sub_806DB84(MapGridGetMetatileBehaviorAt(x, y), direction)) + return 8; + MoveCoords(direction, &x, &y); + return CheckForObjectEventCollision(playerObjEvent, x, y, direction, MapGridGetMetatileBehaviorAt(x, y)); +} + +u8 CheckForObjectEventCollision(struct ObjectEvent *objectEvent, s16 x, s16 y, u8 direction, u8 metatileBehavior) +{ + u8 collision = GetCollisionAtCoords(objectEvent, x, y, direction); + if (collision == COLLISION_ELEVATION_MISMATCH && CanStopSurfing(x, y, direction)) + return COLLISION_STOP_SURFING; + + if (ShouldJumpLedge(x, y, direction)) + { + IncrementGameStat(GAME_STAT_JUMPED_DOWN_LEDGES); + return COLLISION_LEDGE_JUMP; + } + if (collision == COLLISION_OBJECT_EVENT && TryPushBoulder(x, y, direction)) + return COLLISION_PUSHED_BOULDER; + + if (collision == COLLISION_NONE) + { + CheckAcroBikeCollision(x, y, metatileBehavior, &collision); + } + return collision; +} -- cgit v1.2.3 From 5b3e9f376b2ed230df1d7e6d23e0239f69d10ba4 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 23 Mar 2020 21:42:35 -0400 Subject: through PlayerGetCopyableMovement --- src/dynamic_placeholder_text_util.c | 2 +- src/event_data.c | 2 +- src/field_control_avatar.c | 2 +- src/field_fadetransition.c | 2 +- src/field_player_avatar.c | 238 +++++++++++++++++++++++++++++++++++- src/fldeff_strength.c | 2 +- src/item_use.c | 8 +- src/metatile_behavior.c | 12 +- 8 files changed, 251 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/dynamic_placeholder_text_util.c b/src/dynamic_placeholder_text_util.c index 921612cfc..955c4866a 100644 --- a/src/dynamic_placeholder_text_util.c +++ b/src/dynamic_placeholder_text_util.c @@ -56,7 +56,7 @@ static const u8 sTextColorTable[] = [OBJ_EVENT_GFX_TEACHY_TV_HOST / 2] = 0x00, // OBJ_EVENT_GFX_GYM_GUY [OBJ_EVENT_GFX_ITEM_BALL / 2] = 0x33, // OBJ_EVENT_GFX_TOWN_MAP [OBJ_EVENT_GFX_POKEDEX / 2] = 0x33, // OBJ_EVENT_GFX_CUT_TREE - [OBJ_EVENT_GFX_ROCK_SMASH_ROCK / 2] = 0x33, // OBJ_EVENT_GFX_STRENGTH_BOULDER + [OBJ_EVENT_GFX_ROCK_SMASH_ROCK / 2] = 0x33, // OBJ_EVENT_GFX_PUSHABLE_BOULDER [OBJ_EVENT_GFX_FOSSIL / 2] = 0x33, // OBJ_EVENT_GFX_RUBY [OBJ_EVENT_GFX_SAPPHIRE / 2] = 0x33, // OBJ_EVENT_GFX_OLD_AMBER [OBJ_EVENT_GFX_GYM_SIGN / 2] = 0x33, // OBJ_EVENT_GFX_SIGN diff --git a/src/event_data.c b/src/event_data.c index a162e8701..f16267c98 100644 --- a/src/event_data.c +++ b/src/event_data.c @@ -44,7 +44,7 @@ void sub_806E110(void) memset(gSaveBlock1Ptr->vars, 0, 16 * 2); FlagClear(FLAG_SYS_WHITE_FLUTE_ACTIVE); FlagClear(FLAG_SYS_BLACK_FLUTE_ACTIVE); - FlagClear(FLAG_SYS_STRENGTH_ACTIVE); + FlagClear(FLAG_SYS_USE_STRENGTH); FlagClear(FLAG_SYS_SPECIAL_WILD_BATTLE); FlagClear(FLAG_SYS_INFORMED_OF_LOCAL_WIRELESS_PLAYER); } diff --git a/src/field_control_avatar.c b/src/field_control_avatar.c index da3fb4a03..891af3e90 100644 --- a/src/field_control_avatar.c +++ b/src/field_control_avatar.c @@ -906,7 +906,7 @@ static bool8 IsWarpMetatileBehavior(u16 metatileBehavior) return TRUE; if (MetatileBehavior_IsEscalator(metatileBehavior) == TRUE) return TRUE; - if (MetatileBehavior_IsCaveDoor(metatileBehavior) == TRUE) + if (MetatileBehavior_IsNonAnimDoor(metatileBehavior) == TRUE) return TRUE; if (MetatileBehavior_IsLavaridgeB1FWarp(metatileBehavior) == TRUE) return TRUE; diff --git a/src/field_fadetransition.c b/src/field_fadetransition.c index 10d6b3d72..c24d153ac 100644 --- a/src/field_fadetransition.c +++ b/src/field_fadetransition.c @@ -260,7 +260,7 @@ static void sub_807DE78(bool8 a0) else { sub_807DF4C(a0); - if (MetatileBehavior_IsCaveDoor(behavior) == TRUE) + if (MetatileBehavior_IsNonAnimDoor(behavior) == TRUE) func = task_map_chg_seq_0807E20C; else if (MetatileBehavior_IsUnknownWarp6C_to_6F(behavior) == TRUE) { diff --git a/src/field_player_avatar.c b/src/field_player_avatar.c index 5b2820f96..c27eb2650 100644 --- a/src/field_player_avatar.c +++ b/src/field_player_avatar.c @@ -8,9 +8,13 @@ #include "field_player_avatar.h" #include "metatile_behavior.h" #include "overworld.h" +#include "quest_log.h" +#include "quest_log_player.h" #include "constants/event_object_movement.h" +#include "constants/event_objects.h" #include "constants/songs.h" #include "constants/flags.h" +#include "constants/metatile_behaviors.h" EWRAM_DATA struct ObjectEvent * gUnknown_2036E30 = NULL; EWRAM_DATA bool8 gUnknown_2036E34 = FALSE; @@ -21,7 +25,6 @@ u8 ObjectEventCB2_NoMovement2(struct ObjectEvent * object, struct Sprite * sprit bool8 sub_805B528(void); bool8 TryInterruptObjectEventSpecialAnim(struct ObjectEvent * playerObjEvent, u8 direction); void npc_clear_strange_bits(struct ObjectEvent * playerObjEvent); -void DoPlayerAvatarTransition(void); bool8 TryDoMetatileBehaviorForcedMovement(void); void MovePlayerAvatarUsingKeypadInput(u8 direction, u16 newKeys, u16 heldKeys); void PlayerAllowForcedMovementIfMovingSameDirection(void); @@ -56,7 +59,20 @@ u8 CheckForObjectEventCollision(struct ObjectEvent * objectEvent, s16 x, s16 y, bool8 CanStopSurfing(s16 x, s16 y, u8 direction); bool8 ShouldJumpLedge(s16 x, s16 y, u8 direction); bool8 TryPushBoulder(s16 x, s16 y, u8 direction); -bool8 CheckAcroBikeCollision(s16 x, s16 y, u8 metatileBehavior, u8 *collision); +void CheckAcroBikeCollision(s16 x, s16 y, u8 metatileBehavior, u8 *collision); +void DoPlayerAvatarTransition(void); +void PlayerAvatarTransition_Dummy(struct ObjectEvent * playerObject); +void PlayerAvatarTransition_Normal(struct ObjectEvent * playerObject); +void PlayerAvatarTransition_Bike(struct ObjectEvent * playerObject); +void PlayerAvatarTransition_Surfing(struct ObjectEvent * playerObject); +void PlayerAvatarTransition_Underwater(struct ObjectEvent * playerObject); +void PlayerAvatarTransition_ReturnToField(struct ObjectEvent * playerObject); +bool8 PlayerIsAnimActive(void); +bool8 PlayerCheckIfAnimFinishedOrInactive(void); +bool8 player_is_anim_in_certain_ranges(void); +bool8 sub_805BF58(void); +void CreateStopSurfingTask(u8 direction); +void StartStrengthAnim(u8 objectEventId, u8 direction); void PlayerNotOnBikeCollide(u8 direction); void PlayerRun(u8 direction); void PlayerRunSlow(u8 direction); @@ -531,3 +547,221 @@ u8 CheckForObjectEventCollision(struct ObjectEvent *objectEvent, s16 x, s16 y, u } return collision; } + +const u8 gUnknown_835B820[] = { + MOVEMENT_ACTION_FACE_DOWN_FAST, + MOVEMENT_ACTION_FACE_DOWN_FAST, + MOVEMENT_ACTION_FACE_UP_FAST, + MOVEMENT_ACTION_FACE_LEFT_FAST, + MOVEMENT_ACTION_FACE_RIGHT_FAST +}; + +bool8 CanStopSurfing(s16 x, s16 y, u8 direction) +{ + if ((gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_SURFING) + && MapGridGetZCoordAt(x, y) == 3 + && GetObjectEventIdByXYZ(x, y, 3) == OBJECT_EVENTS_COUNT) + { + sub_811278C(gUnknown_835B820[direction], 16); + CreateStopSurfingTask(direction); + return TRUE; + } + else + { + return FALSE; + } +} + +bool8 ShouldJumpLedge(s16 x, s16 y, u8 z) +{ + if (GetLedgeJumpDirection(x, y, z) != 0) + return TRUE; + else + return FALSE; +} + +bool8 TryPushBoulder(s16 x, s16 y, u8 direction) +{ + u8 objectEventId; + if (!FlagGet(FLAG_SYS_USE_STRENGTH)) + return FALSE; + + objectEventId = GetObjectEventIdByXY(x, y); + if (objectEventId == OBJECT_EVENTS_COUNT) + return FALSE; + + if (gObjectEvents[objectEventId].graphicsId != OBJ_EVENT_GFX_PUSHABLE_BOULDER) + return FALSE; + + x = gObjectEvents[objectEventId].currentCoords.x; + y = gObjectEvents[objectEventId].currentCoords.y; + MoveCoords(direction, &x, &y); + if (MapGridGetMetatileBehaviorAt(x, y) == MB_FALL_WARP || (GetCollisionAtCoords(&gObjectEvents[objectEventId], x, y, direction) == COLLISION_NONE && !MetatileBehavior_IsNonAnimDoor(MapGridGetMetatileBehaviorAt(x, y)))) + { + StartStrengthAnim(objectEventId, direction); + return TRUE; + } + else + { + direction++; + direction--; + return FALSE; + } +} + +bool8 (*const gUnknown_835B828[])(u8) = { + MetatileBehavior_IsBumpySlope, + MetatileBehavior_IsIsolatedVerticalRail, + MetatileBehavior_IsIsolatedHorizontalRail, + MetatileBehavior_IsVerticalRail, + MetatileBehavior_IsHorizontalRail +}; + +const u8 gUnknown_835B83C[] = { + COLLISION_WHEELIE_HOP, + COLLISION_ISOLATED_VERTICAL_RAIL, + COLLISION_ISOLATED_HORIZONTAL_RAIL, + COLLISION_VERTICAL_RAIL, + COLLISION_HORIZONTAL_RAIL, +}; + +void CheckAcroBikeCollision(s16 x, s16 y, u8 metatileBehavior, u8 *collision) +{ + u8 i; + + for (i = 0; i < NELEMS(gUnknown_835B828); i++) + { + if (gUnknown_835B828[i](metatileBehavior)) + { + *collision = gUnknown_835B83C[i]; + return; + } + } +} + +void SetPlayerAvatarTransitionFlags(bool16 flags) +{ + gPlayerAvatar.unk1 |= flags; + DoPlayerAvatarTransition(); +} + +void (*const gUnknown_835B844[])(struct ObjectEvent *) = { + PlayerAvatarTransition_Normal, + PlayerAvatarTransition_Bike, + PlayerAvatarTransition_Bike, + PlayerAvatarTransition_Surfing, + PlayerAvatarTransition_Underwater, + PlayerAvatarTransition_ReturnToField, + PlayerAvatarTransition_Dummy, + PlayerAvatarTransition_Dummy +}; + +void DoPlayerAvatarTransition(void) +{ + u8 i; + u8 flags = gPlayerAvatar.unk1; + + if (flags != 0) + { + for (i = 0; i < NELEMS(gUnknown_835B844); i++, flags >>= 1) + { + if (flags & 1) + gUnknown_835B844[i](&gObjectEvents[gPlayerAvatar.objectEventId]); + } + gPlayerAvatar.unk1 = 0; + } +} + +void PlayerAvatarTransition_Dummy(struct ObjectEvent * playerObjEvent) +{ + +} + +void PlayerAvatarTransition_Normal(struct ObjectEvent * playerObjEvent) +{ + sub_8150474(0); + sub_8150498(0); +} + +void PlayerAvatarTransition_Bike(struct ObjectEvent * playerObjEvent) +{ + sub_8150474(1); + sub_8150498(1); + sub_80BD620(0, 0); +} + +void PlayerAvatarTransition_Surfing(struct ObjectEvent * playerObjEvent) +{ + sub_8150474(3); + sub_8150498(3); +} + +void PlayerAvatarTransition_Underwater(struct ObjectEvent * playerObjEvent) +{ + +} + +void PlayerAvatarTransition_ReturnToField(struct ObjectEvent * playerObjEvent) +{ + gPlayerAvatar.flags |= PLAYER_AVATAR_FLAG_FORCED_MVMT_DISABLED; +} + +void sub_805BEB8(void) +{ + gPlayerAvatar.tileTransitionState = T_NOT_MOVING; + if (PlayerIsAnimActive()) + { + if (!PlayerCheckIfAnimFinishedOrInactive()) + { + if (!player_is_anim_in_certain_ranges()) + gPlayerAvatar.tileTransitionState = T_TILE_TRANSITION; + } + else + { + if (!sub_805BF58()) + gPlayerAvatar.tileTransitionState = T_TILE_CENTER; + } + } +} + +bool8 player_is_anim_in_certain_ranges(void) +{ + u8 movementActionId = gObjectEvents[gPlayerAvatar.objectEventId].movementActionId; + + if (movementActionId <= MOVEMENT_ACTION_FACE_RIGHT_FAST + || (movementActionId >= MOVEMENT_ACTION_DELAY_1 && movementActionId <= MOVEMENT_ACTION_DELAY_16) + || (movementActionId >= MOVEMENT_ACTION_WALK_IN_PLACE_SLOW_DOWN && movementActionId <= MOVEMENT_ACTION_WALK_IN_PLACE_FASTEST_RIGHT) + || (movementActionId >= MOVEMENT_ACTION_ACRO_WHEELIE_FACE_DOWN && movementActionId <= MOVEMENT_ACTION_ACRO_END_WHEELIE_FACE_RIGHT) + || (movementActionId >= MOVEMENT_ACTION_ACRO_WHEELIE_IN_PLACE_DOWN && movementActionId <= MOVEMENT_ACTION_ACRO_WHEELIE_IN_PLACE_RIGHT)) + return TRUE; + else + return FALSE; +} + +bool8 sub_805BF58(void) +{ + if (player_is_anim_in_certain_ranges() && gPlayerAvatar.runningState != TURN_DIRECTION) + return TRUE; + else + return FALSE; +} + +bool8 PlayerIsAnimActive(void) +{ + return ObjectEventIsMovementOverridden(&gObjectEvents[gPlayerAvatar.objectEventId]); +} + +bool8 PlayerCheckIfAnimFinishedOrInactive(void) +{ + return ObjectEventCheckHeldMovementStatus(&gObjectEvents[gPlayerAvatar.objectEventId]); +} + +void PlayerSetCopyableMovement(u8 a) +{ + gObjectEvents[gPlayerAvatar.objectEventId].playerCopyableMovement = a; +} + +u8 PlayerGetCopyableMovement(void) +{ + return gObjectEvents[gPlayerAvatar.objectEventId].playerCopyableMovement; +} diff --git a/src/fldeff_strength.c b/src/fldeff_strength.c index c6b92b28c..c9a0fd1d5 100644 --- a/src/fldeff_strength.c +++ b/src/fldeff_strength.c @@ -13,7 +13,7 @@ static void ShowMonCB_UseStrength(void); bool8 SetUpFieldMove_Strength(void) { - if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_SURFING) || CheckObjectGraphicsInFrontOfPlayer(OBJ_EVENT_GFX_STRENGTH_BOULDER) != TRUE) + if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_SURFING) || CheckObjectGraphicsInFrontOfPlayer(OBJ_EVENT_GFX_PUSHABLE_BOULDER) != TRUE) { return FALSE; } diff --git a/src/item_use.c b/src/item_use.c index 6f81ee0e3..0b74e0726 100644 --- a/src/item_use.c +++ b/src/item_use.c @@ -263,10 +263,10 @@ void FieldUseFunc_MachBike(u8 taskId) behavior = MapGridGetMetatileBehaviorAt(x, y); if (FlagGet(FLAG_SYS_ON_CYCLING_ROAD) == TRUE - || MetatileBehavior_ReturnFalse_17(behavior) == TRUE - || MetatileBehavior_ReturnFalse_18(behavior) == TRUE - || MetatileBehavior_ReturnFalse_15(behavior) == TRUE - || MetatileBehavior_ReturnFalse_16(behavior) == TRUE) + || MetatileBehavior_IsVerticalRail(behavior) == TRUE + || MetatileBehavior_IsHorizontalRail(behavior) == TRUE + || MetatileBehavior_IsIsolatedVerticalRail(behavior) == TRUE + || MetatileBehavior_IsIsolatedHorizontalRail(behavior) == TRUE) sub_80A10C4(taskId, gTasks[taskId].data[3], 2, gUnknown_8416451); else if (sub_8055C9C() == TRUE && !sub_80BD540()) { diff --git a/src/metatile_behavior.c b/src/metatile_behavior.c index 988c9fad0..c937a3b48 100644 --- a/src/metatile_behavior.c +++ b/src/metatile_behavior.c @@ -191,7 +191,7 @@ bool8 MetatileBehavior_IsLadder(u8 metatileBehavior) return FALSE; } -bool8 MetatileBehavior_IsCaveDoor(u8 metatileBehavior) +bool8 MetatileBehavior_IsNonAnimDoor(u8 metatileBehavior) { if(metatileBehavior == MB_CAVE_DOOR) return TRUE; @@ -677,11 +677,11 @@ bool8 MetatileBehavior_IsCyclingRoadPullDownTileGrass(u8 metatileBehavior) return metatileBehavior == MB_CYCLING_ROAD_PULL_DOWN_GRASS; } -bool8 MetatileBehavior_ReturnFalse_14(u8 metatileBehavior) { return FALSE; } -bool8 MetatileBehavior_ReturnFalse_15(u8 metatileBehavior) { return FALSE; } -bool8 MetatileBehavior_ReturnFalse_16(u8 metatileBehavior) { return FALSE; } -bool8 MetatileBehavior_ReturnFalse_17(u8 metatileBehavior) { return FALSE; } -bool8 MetatileBehavior_ReturnFalse_18(u8 metatileBehavior) { return FALSE; } +bool8 MetatileBehavior_IsBumpySlope(u8 metatileBehavior) { return FALSE; } +bool8 MetatileBehavior_IsIsolatedVerticalRail(u8 metatileBehavior) { return FALSE; } +bool8 MetatileBehavior_IsIsolatedHorizontalRail(u8 metatileBehavior) { return FALSE; } +bool8 MetatileBehavior_IsVerticalRail(u8 metatileBehavior) { return FALSE; } +bool8 MetatileBehavior_IsHorizontalRail(u8 metatileBehavior) { return FALSE; } bool8 MetatileBehavior_IsSeaweed(u8 metatileBehavior) { -- cgit v1.2.3 From 58535acf885934feb524057dcf2b773b070cd258 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 23 Mar 2020 21:46:52 -0400 Subject: better match for TryPushBoulder --- src/field_player_avatar.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/field_player_avatar.c b/src/field_player_avatar.c index c27eb2650..4b805c123 100644 --- a/src/field_player_avatar.c +++ b/src/field_player_avatar.c @@ -583,6 +583,7 @@ bool8 ShouldJumpLedge(s16 x, s16 y, u8 z) bool8 TryPushBoulder(s16 x, s16 y, u8 direction) { u8 objectEventId; + u8 direction_ = direction; if (!FlagGet(FLAG_SYS_USE_STRENGTH)) return FALSE; @@ -595,16 +596,14 @@ bool8 TryPushBoulder(s16 x, s16 y, u8 direction) x = gObjectEvents[objectEventId].currentCoords.x; y = gObjectEvents[objectEventId].currentCoords.y; - MoveCoords(direction, &x, &y); - if (MapGridGetMetatileBehaviorAt(x, y) == MB_FALL_WARP || (GetCollisionAtCoords(&gObjectEvents[objectEventId], x, y, direction) == COLLISION_NONE && !MetatileBehavior_IsNonAnimDoor(MapGridGetMetatileBehaviorAt(x, y)))) + MoveCoords(direction_, &x, &y); + if (MapGridGetMetatileBehaviorAt(x, y) == MB_FALL_WARP || (GetCollisionAtCoords(&gObjectEvents[objectEventId], x, y, direction_) == COLLISION_NONE && !MetatileBehavior_IsNonAnimDoor(MapGridGetMetatileBehaviorAt(x, y)))) { - StartStrengthAnim(objectEventId, direction); + StartStrengthAnim(objectEventId, direction_); return TRUE; } else { - direction++; - direction--; return FALSE; } } -- cgit v1.2.3 From 87b2c7f34b5a734d3af98ea2dc7d9fafecd809a6 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Tue, 24 Mar 2020 08:56:14 -0400 Subject: through PlayerSetAnimId; some quest log doc --- src/field_player_avatar.c | 15 ++ src/new_menu_helpers.c | 2 +- src/quest_log.c | 506 +++++++++++++++++++++++----------------------- src/quest_log_objects.c | 4 +- 4 files changed, 271 insertions(+), 256 deletions(-) (limited to 'src') diff --git a/src/field_player_avatar.c b/src/field_player_avatar.c index 4b805c123..a7525fc41 100644 --- a/src/field_player_avatar.c +++ b/src/field_player_avatar.c @@ -764,3 +764,18 @@ u8 PlayerGetCopyableMovement(void) { return gObjectEvents[gPlayerAvatar.objectEventId].playerCopyableMovement; } + +void PlayerForceSetHeldMovement(u8 a) +{ + ObjectEventForceSetHeldMovement(&gObjectEvents[gPlayerAvatar.objectEventId], a); +} + +void PlayerSetAnimId(u8 movementActionId, u8 copyableMovement) +{ + if (!PlayerIsAnimActive()) + { + PlayerSetCopyableMovement(copyableMovement); + if (!ObjectEventSetHeldMovement(&gObjectEvents[gPlayerAvatar.objectEventId], movementActionId)) + sub_8112628(movementActionId); + } +} diff --git a/src/new_menu_helpers.c b/src/new_menu_helpers.c index 959370398..d184bae05 100644 --- a/src/new_menu_helpers.c +++ b/src/new_menu_helpers.c @@ -496,7 +496,7 @@ void ClearDialogWindowAndFrame(u8 windowId, bool8 copyToVram) if (copyToVram == TRUE) CopyWindowToVram(windowId, 3); if (gQuestLogState == 2) - sub_8111134(); + CommitQuestLogWindow1(); } void ClearStdWindowAndFrame(u8 windowId, bool8 copyToVram) diff --git a/src/quest_log.c b/src/quest_log.c index bc8e67a6b..fb327433a 100644 --- a/src/quest_log.c +++ b/src/quest_log.c @@ -69,7 +69,7 @@ struct UnkStruct_203AE94 u8 unk_3; }; -struct UnkStruct_203AE98 +struct QuestLogEntry { u8 unk_0; u8 unk_1; @@ -94,9 +94,9 @@ struct UnkStruct_203B044 }; u8 gUnknown_3005E88; -u16 sNumQuestLogs; +u16 sNumEventsInLogEntry; struct UnkStruct_3005E90 gUnknown_3005E90; -struct UnkStruct_203AE98 * gUnknown_3005E94; +struct QuestLogEntry * sCurQuestLogEntry; static struct UnkStruct_300201C * sFlagOrVarRecords; static u16 sNumFlagsOrVars; @@ -105,44 +105,44 @@ static EWRAM_DATA u8 sCurrentSceneNum = 0; static EWRAM_DATA u8 sNumScenes = 0; EWRAM_DATA u8 gQuestLogState = 0; static EWRAM_DATA u16 gUnknown_203ADFC = 0; -static EWRAM_DATA u8 gUnknown_203ADFE[3] = {0}; +static EWRAM_DATA u8 sQuestLogHeaderWindowIds[3] = {0}; static EWRAM_DATA u16 *gUnknown_203AE04 = NULL; static EWRAM_DATA u16 *gUnknown_203AE08 = NULL; static EWRAM_DATA u16 *gUnknown_203AE0C[32] = {NULL}; static EWRAM_DATA void (* sQuestLogCB)(void) = NULL; static EWRAM_DATA u16 *gUnknown_203AE90 = NULL; static EWRAM_DATA struct UnkStruct_203AE94 gUnknown_203AE94 = {0}; -static EWRAM_DATA struct UnkStruct_203AE98 gUnknown_203AE98[32] = {0}; -static EWRAM_DATA u16 sQuestLogIdx = 0; +static EWRAM_DATA struct QuestLogEntry sQuestLogSceneRecordBuffer[32] = {0}; +static EWRAM_DATA u16 sQuestLogCursor = 0; static EWRAM_DATA u8 sMovementScripts[64][2] = {{0}}; -static EWRAM_DATA u16 gUnknown_203B01A = 0; +static EWRAM_DATA u16 sNextStepDelay = 0; static EWRAM_DATA u16 gUnknown_203B01C = 0; static EWRAM_DATA u16 sFlagOrVarPlayhead = 0; static EWRAM_DATA u8 sHelpMessageWindowId = 0; static EWRAM_DATA struct UnkStruct_203B024 gUnknown_203B024 = {0}; static EWRAM_DATA struct UnkStruct_203B044 gUnknown_203B044 = {0}; static EWRAM_DATA u8 gUnknown_203B048 = 0; -static EWRAM_DATA u8 gUnknown_203B049 = 0; +static EWRAM_DATA bool8 sNewlyEnteredMap = FALSE; static EWRAM_DATA u8 gUnknown_203B04A = 0; -static EWRAM_DATA bool8 gUnknown_203B04B = 0; +static EWRAM_DATA bool8 gUnknown_203B04B = FALSE; static void sub_8110A00(void); static void sub_8110A3C(void); -static void sub_8110BB0(u8); -static void sub_8110BE8(u8); +static void SetPlayerInitialCoordsAtScene(u8); +static void SetNPCInitialCoordsAtScene(u8); static void sub_8110E3C(void); -static void sub_8110D94(void); -static void sub_8110E20(void); -static void sub_8110D48(u8); -static u8 sub_8110E68(struct UnkStruct_203AE98 *); +static void BackUpTrainerRematchesToVars(void); +static void BackUpMapLayoutToVar(void); +static void SetGameStateAtScene(u8); +static u8 TryRecordQuestLogEntrySequence(struct QuestLogEntry *); static void sub_8110F90(u8); -static void sub_8111150(u8); +static void QuestLogPlaybackSetObjectEventTemplates(u8); static void sub_8111368(void); static void QuestLog_GetSaneMonCounts(void); static u16 QuestLog_GetSanePartyCount(void); static u16 QuestLog_GetSaneBoxCount(void); static void sub_8111688(void); -static void sub_811175C(u8, struct UnkStruct_203AE98 *); +static void sub_811175C(u8, struct QuestLogEntry *); static void sub_81118F4(s8); static void QuestLog_AdvancePlayhead(void); static void QuestLog_StartFinalScene(void); @@ -163,9 +163,9 @@ static void Task_EndQuestLog(u8); static bool8 sub_81121D8(u8); static void sub_811229C(void); static void sub_8112888(u8); -static void sub_8112940(u8, struct UnkStruct_203AE98 *, u16); +static void SetUpQuestLogEntry(u8, struct QuestLogEntry *, u16); static bool8 sub_8112CEC(void); -static bool8 sub_8112D1C(void); +static bool8 RecordHeadAtEndOfEntry(void); static void TryLoseFansFromPlayTimeAfterLinkBattle(struct TrainerFanClub *); static void UpdateTrainerFanClubGameClear(struct TrainerFanClub *); static u8 PlayerGainRandomTrainerFan(struct TrainerFanClub *); @@ -194,13 +194,13 @@ static void sub_8113B88(void); static void sub_8113B94(u16); static void sub_8113BD8(void); static u16 *sub_8113BF4(u16 *); -static u16 *sub_8113C20(u16 *, struct UnkStruct_203AE98 *); +static u16 *sub_8113C20(u16 *, struct QuestLogEntry *); static u16 *sub_8113C5C(u16 *, u16); -static u16 *sub_8113C8C(u16 *, struct UnkStruct_203AE98 *); -static u16 *sub_8113CC8(u16 *, struct UnkStruct_203AE98 *); -static u16 *sub_8113D08(u16 *, struct UnkStruct_203AE98 *); -static u16 *sub_8113D48(u16 *, struct UnkStruct_203AE98 *); -static u16 *sub_8113D94(u16 *, struct UnkStruct_203AE98 *); +static u16 *sub_8113C8C(u16 *, struct QuestLogEntry *); +static u16 *sub_8113CC8(u16 *, struct QuestLogEntry *); +static u16 *sub_8113D08(u16 *, struct QuestLogEntry *); +static u16 *sub_8113D48(u16 *, struct QuestLogEntry *); +static u16 *sub_8113D94(u16 *, struct QuestLogEntry *); static u16 *BufferQuestLogData_SwitchedPartyOrder(u16 *, const u16 *); static u16 *BufferQuestLogData_UsedItem(u16 *, const u16 *); static u16 *BufferQuestLogData_GaveHeldItemFromPartyMenu(u16 *, const u16 *); @@ -282,7 +282,7 @@ static bool8 sub_81153A8(u16, const u16 *); static bool8 sub_81153E4(u16, const u16 *); static void BufferLinkPartnersName(u8 *); -static const struct WindowTemplate gUnknown_845661C[3] = { +static const struct WindowTemplate sQuestLogHeaderWindowTemplates[3] = { { 0, 0, 0, 30, 2, 15, 0x0e9 }, { 0, 0, 18, 30, 2, 15, 0x0ad }, { 0, 0, 14, 30, 6, 15, 0x14c } @@ -303,7 +303,7 @@ void sub_8110840(void * oldPointer) { if (gUnknown_203AE08) gUnknown_203AE08 = (void *)gUnknown_203AE08 + offset; - if (gQuestLogState == 2) + if (gQuestLogState == QL_STATE_2) { int r3; for (r3 = 0; r3 < (int)NELEMS(gUnknown_203AE0C); r3++) @@ -325,7 +325,7 @@ void ResetQuestLog(void) sub_81138F8(); } -void sub_81108F0(u8 a0) +static void DestroySav1QuestLogEntry(u8 a0) { memset(gSaveBlock1Ptr->questLog + a0, 0, sizeof(struct QuestLog)); gUnknown_203AE04 = NULL; @@ -373,7 +373,7 @@ static void SetQuestLogState(u8 state) static void sub_8110A00(void) { - if (sub_8110E68(gUnknown_203AE98) != 1) + if (TryRecordQuestLogEntrySequence(sQuestLogSceneRecordBuffer) != 1) { gUnknown_3005E88 = 0; sub_8110E3C(); @@ -389,7 +389,7 @@ static void sub_8110A3C(void) if (gUnknown_203AE94.unk_0_6 == 0) { - if (gUnknown_3005E88 || gUnknown_203AE94.unk_0_0 == 1 || (gUnknown_203AE94.unk_1 < 32 && gUnknown_203AE0C[gUnknown_203AE94.unk_1])) + if (gUnknown_3005E88 || gUnknown_203AE94.unk_0_0 == 1 || (gUnknown_203AE94.unk_1 < NELEMS(gUnknown_203AE0C) && gUnknown_203AE0C[gUnknown_203AE94.unk_1] != NULL)) sub_8111AD8(); else { @@ -410,12 +410,12 @@ u8 sub_8110AC8(void) return gSaveBlock1Ptr->questLog[sCurrentSceneNum].unk_000; } -void sub_8110AEC(u16 eventId) +static void StartRecordingQuestLogEntry(u16 eventId) { if (sCurrentSceneNum >= QUEST_LOG_SCENE_COUNT) sCurrentSceneNum = 0; - sub_81108F0(sCurrentSceneNum); + DestroySav1QuestLogEntry(sCurrentSceneNum); sub_8113B88(); gUnknown_203AE08 = gSaveBlock1Ptr->questLog[sCurrentSceneNum].unk_568; if (IS_LINK_QL_EVENT(eventId) || eventId == QL_EVENT_DEPARTED) @@ -423,18 +423,18 @@ void sub_8110AEC(u16 eventId) else gSaveBlock1Ptr->questLog[sCurrentSceneNum].unk_000 = 1; QuestLog_GetSaneMonCounts(); - sub_8110BB0(sCurrentSceneNum); - sub_8110BE8(sCurrentSceneNum); - sub_8110D94(); - sub_8110E20(); - sub_8110D48(sCurrentSceneNum); + SetPlayerInitialCoordsAtScene(sCurrentSceneNum); + SetNPCInitialCoordsAtScene(sCurrentSceneNum); + BackUpTrainerRematchesToVars(); + BackUpMapLayoutToVar(); + SetGameStateAtScene(sCurrentSceneNum); gUnknown_203ADFC = 0; - sub_8112940(2, gUnknown_203AE98, 0x100); - sub_8110E68(gUnknown_203AE98); - SetQuestLogState(1); + SetUpQuestLogEntry(2, sQuestLogSceneRecordBuffer, 0x100); + TryRecordQuestLogEntrySequence(sQuestLogSceneRecordBuffer); + SetQuestLogState(QL_STATE_1); } -static void sub_8110BB0(u8 sceneNum) +static void SetPlayerInitialCoordsAtScene(u8 sceneNum) { struct QuestLog * questLog = &gSaveBlock1Ptr->questLog[sceneNum]; questLog->mapGroup = gSaveBlock1Ptr->location.mapGroup; @@ -444,7 +444,7 @@ static void sub_8110BB0(u8 sceneNum) questLog->y = gSaveBlock1Ptr->pos.y; } -static void sub_8110BE8(u8 sceneNum) +static void SetNPCInitialCoordsAtScene(u8 sceneNum) { struct QuestLog * questLog = &gSaveBlock1Ptr->questLog[sceneNum]; u16 i; @@ -478,7 +478,7 @@ static void sub_8110BE8(u8 sceneNum) } } -static void sub_8110D48(u8 sceneNum) +static void SetGameStateAtScene(u8 sceneNum) { struct QuestLog * questLog = &gSaveBlock1Ptr->questLog[sceneNum]; @@ -486,7 +486,7 @@ static void sub_8110D48(u8 sceneNum) CpuCopy16(gSaveBlock1Ptr->vars, questLog->vars, VARS_COUNT * sizeof(u16)); } -static void sub_8110D94(void) +static void BackUpTrainerRematchesToVars(void) { u16 i, j; u16 sp0[4]; @@ -501,13 +501,13 @@ static void sub_8110D94(void) sp0[i] += (1 << j); } } - VarSet(VAR_0x40AA + i, sp0[i]); + VarSet(VAR_QLBAK_TRAINER_REMATCHES + i, sp0[i]); } } -static void sub_8110E20(void) +static void BackUpMapLayoutToVar(void) { - VarSet(VAR_0x40AE, gSaveBlock1Ptr->mapLayoutId); + VarSet(VAR_QLBAK_MAP_LAYOUT, gSaveBlock1Ptr->mapLayoutId); } static void sub_8110E3C(void) @@ -517,22 +517,22 @@ static void sub_8110E3C(void) sCurrentSceneNum = 0; } -static bool8 sub_8110E68(struct UnkStruct_203AE98 * a0) +static bool8 TryRecordQuestLogEntrySequence(struct QuestLogEntry * entry) { u16 i; - for (i = gUnknown_203ADFC; i < sQuestLogIdx; i++) + for (i = gUnknown_203ADFC; i < sQuestLogCursor; i++) { if (gUnknown_203AE08 == NULL) return FALSE; - switch (a0[i].unk_6) + switch (entry[i].unk_6) { case 0: case 1: - gUnknown_203AE08 = sub_8113D48(gUnknown_203AE08, &a0[i]); + gUnknown_203AE08 = sub_8113D48(gUnknown_203AE08, &entry[i]); break; default: - gUnknown_203AE08 = sub_8113CC8(gUnknown_203AE08, &a0[i]); + gUnknown_203AE08 = sub_8113CC8(gUnknown_203AE08, &entry[i]); break; } if (gUnknown_203AE08 == NULL) @@ -547,7 +547,7 @@ static bool8 sub_8110E68(struct UnkStruct_203AE98 * a0) gUnknown_203AE08 = sub_8113BF4(gUnknown_203AE08); return FALSE; } - gUnknown_203ADFC = sQuestLogIdx; + gUnknown_203ADFC = sQuestLogCursor; return TRUE; } @@ -589,16 +589,16 @@ static void sub_8110F90(u8 unused) void sub_8110FCC(void) { - sub_811175C(sCurrentSceneNum, gUnknown_203AE98); + sub_811175C(sCurrentSceneNum, sQuestLogSceneRecordBuffer); sub_8113B88(); - sub_8112940(1, gUnknown_203AE98, 0x100); - sub_8111150(sCurrentSceneNum); + SetUpQuestLogEntry(1, sQuestLogSceneRecordBuffer, 0x100); + QuestLogPlaybackSetObjectEventTemplates(sCurrentSceneNum); } bool8 sub_8111000(void) { LoadPalette(stdpal_get(4), 0xF0, 0x20); - SetQuestLogState(2); + SetQuestLogState(QL_STATE_2); sub_807DF64(); gUnknown_203AE94 = (struct UnkStruct_203AE94){}; gUnknown_203AE94.unk_0_0 = 2; @@ -608,7 +608,7 @@ bool8 sub_8111000(void) bool8 sub_8111038(void) { LoadPalette(stdpal_get(4), 0xF0, 0x20); - SetQuestLogState(2); + SetQuestLogState(QL_STATE_2); sub_807DF7C(); gUnknown_203AE94 = (struct UnkStruct_203AE94){}; gUnknown_203AE94.unk_0_0 = 2; @@ -619,10 +619,10 @@ void DrawPreviouslyOnQuestHeader(u8 sceneNum) { u8 i; - for (i = 0; i < 3; i++) + for (i = 0; i < NELEMS(sQuestLogHeaderWindowTemplates); i++) { - gUnknown_203ADFE[i] = AddWindow(&gUnknown_845661C[i]); - FillWindowPixelRect(gUnknown_203ADFE[i], 15, 0, 0, gUnknown_845661C[i].width * 8, gUnknown_845661C[i].height * 8); + sQuestLogHeaderWindowIds[i] = AddWindow(&sQuestLogHeaderWindowTemplates[i]); + FillWindowPixelRect(sQuestLogHeaderWindowIds[i], 15, 0, 0, sQuestLogHeaderWindowTemplates[i].width * 8, sQuestLogHeaderWindowTemplates[i].height * 8); } StringExpandPlaceholders(gStringVar4, gText_QuestLog_PreviouslyOnYourQuest); @@ -634,21 +634,21 @@ void DrawPreviouslyOnQuestHeader(u8 sceneNum) StringAppend(gStringVar4, gStringVar1); } - AddTextPrinterParameterized4(gUnknown_203ADFE[0], 2, 2, 2, 1, 2, sTextColors, 0, gStringVar4); - PutWindowTilemap(gUnknown_203ADFE[0]); - PutWindowTilemap(gUnknown_203ADFE[1]); - CopyWindowToVram(gUnknown_203ADFE[0], 2); - CopyWindowToVram(gUnknown_203ADFE[2], 2); - CopyWindowToVram(gUnknown_203ADFE[1], 3); + AddTextPrinterParameterized4(sQuestLogHeaderWindowIds[0], 2, 2, 2, 1, 2, sTextColors, 0, gStringVar4); + PutWindowTilemap(sQuestLogHeaderWindowIds[0]); + PutWindowTilemap(sQuestLogHeaderWindowIds[1]); + CopyWindowToVram(sQuestLogHeaderWindowIds[0], 2); + CopyWindowToVram(sQuestLogHeaderWindowIds[2], 2); + CopyWindowToVram(sQuestLogHeaderWindowIds[1], 3); } -void sub_8111134(void) +void CommitQuestLogWindow1(void) { - PutWindowTilemap(gUnknown_203ADFE[1]); - CopyWindowToVram(gUnknown_203ADFE[1], 1); + PutWindowTilemap(sQuestLogHeaderWindowIds[1]); + CopyWindowToVram(sQuestLogHeaderWindowIds[1], 1); } -static void sub_8111150(u8 sceneNum) +static void QuestLogPlaybackSetObjectEventTemplates(u8 sceneNum) { struct QuestLog *questLog = &gSaveBlock1Ptr->questLog[sceneNum]; u16 i; @@ -667,7 +667,7 @@ static void sub_8111150(u8 sceneNum) gSaveBlock1Ptr->objectEventTemplates[i].movementType = questLog->npcData[i].movementType; } - sub_815A1F8(questLog, gSaveBlock1Ptr->objectEventTemplates); + SetSav1ObjectEventsFromQuestLog(questLog, gSaveBlock1Ptr->objectEventTemplates); } void sub_8111274(u8 sceneNum, bool8 a1) @@ -695,7 +695,7 @@ void sub_8111274(u8 sceneNum, bool8 a1) static void sub_8111368(void) { - gQuestLogState = 2; + gQuestLogState = QL_STATE_2; ResetSpecialVars(); ClearBag(); ClearPCItemSlots(); @@ -847,7 +847,7 @@ static void sub_8111688(void) for (i = 0; i < 4; i++) { - sp0[i] = VarGet(VAR_0x40AA + i); + sp0[i] = VarGet(VAR_QLBAK_TRAINER_REMATCHES + i); for (j = 0; j < 16; j++) { @@ -864,7 +864,7 @@ void sub_8111708(void) { struct MapHeader sp0; - gSaveBlock1Ptr->mapLayoutId = VarGet(VAR_0x40AE); + gSaveBlock1Ptr->mapLayoutId = VarGet(VAR_QLBAK_MAP_LAYOUT); if (gSaveBlock1Ptr->mapLayoutId == 0) { sp0 = *Overworld_GetMapHeaderByGroupAndId(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum); @@ -872,14 +872,14 @@ void sub_8111708(void) } } -static void sub_811175C(u8 sceneNum, struct UnkStruct_203AE98 * a1) +static void sub_811175C(u8 sceneNum, struct QuestLogEntry * a1) { u16 i; u16 *r4; u16 r6 = 0; u16 r9 = 0; - memset(a1, 0, 32 * sizeof(struct UnkStruct_203AE98)); + memset(a1, 0, 32 * sizeof(struct QuestLogEntry)); for (i = 0; i < NELEMS(gUnknown_203AE0C); i++) { gUnknown_203AE0C[i] = NULL; @@ -951,7 +951,7 @@ static void QuestLog_StartFinalScene(void) SetMainCallback2(sub_8057430); gFieldCallback2 = sub_8111F60; FreeAllWindowBuffers(); - gQuestLogState = 3; + gQuestLogState = QL_STATE_3; sQuestLogCB = NULL; } @@ -1077,7 +1077,7 @@ static u8 sub_8111BD4(void) bool8 sub_8111C2C(void) { - if (gQuestLogState != 2) + if (gQuestLogState != QL_STATE_2) return FALSE; if (gUnknown_3005E88 == 0 || gUnknown_203AE94.unk_0_0 == 1 || gUnknown_203AE94.unk_0_0 == 2) return TRUE; @@ -1112,7 +1112,7 @@ bool8 sub_8111CD0(void) void sub_8111CF0(void) { - if (gQuestLogState == 2) + if (gQuestLogState == QL_STATE_2) DrawPreviouslyOnQuestHeader(sNumScenes); } @@ -1127,9 +1127,9 @@ static void DrawQuestLogSceneDescription(void) numLines++; } - PutWindowTilemap(gUnknown_203ADFE[2]); - sub_8111D90(gUnknown_203ADFE[2]); - AddTextPrinterParameterized4(gUnknown_203ADFE[2], 2, 2, sQuestLogTextLineYCoords[numLines], 1, 0, sTextColors, 0, gStringVar4); + PutWindowTilemap(sQuestLogHeaderWindowIds[2]); + sub_8111D90(sQuestLogHeaderWindowIds[2]); + AddTextPrinterParameterized4(sQuestLogHeaderWindowIds[2], 2, 2, sQuestLogTextLineYCoords[numLines], 1, 0, sTextColors, 0, gStringVar4); ScheduleBgCopyTilemapToVram(0); } @@ -1172,11 +1172,11 @@ static void sub_8111D90(u8 a0) static void QuestLog_CloseTextWindow(void) { - ClearWindowTilemap(gUnknown_203ADFE[2]); - FillWindowPixelRect(gUnknown_203ADFE[2], 15, 0, 0, 0xf0, 0x30); - CopyWindowToVram(gUnknown_203ADFE[2], 2); - PutWindowTilemap(gUnknown_203ADFE[1]); - CopyWindowToVram(gUnknown_203ADFE[1], 1); + ClearWindowTilemap(sQuestLogHeaderWindowIds[2]); + FillWindowPixelRect(sQuestLogHeaderWindowIds[2], 15, 0, 0, 0xf0, 0x30); + CopyWindowToVram(sQuestLogHeaderWindowIds[2], 2); + PutWindowTilemap(sQuestLogHeaderWindowIds[1]); + CopyWindowToVram(sQuestLogHeaderWindowIds[1], 1); } static void QuestLog_SkipToEndOfPlayback(s8 delay) @@ -1194,7 +1194,7 @@ static void QuestLog_WaitFadeAndCancelPlayback(void) { if (gSaveBlock1Ptr->questLog[sCurrentSceneNum].unk_000 == 0) break; - sub_811175C(sCurrentSceneNum, gUnknown_203AE98); + sub_811175C(sCurrentSceneNum, sQuestLogSceneRecordBuffer); } gUnknown_3005E88 = 0; QuestLog_StartFinalScene(); @@ -1203,7 +1203,7 @@ static void QuestLog_WaitFadeAndCancelPlayback(void) void sub_8111F14(void) { - if (gQuestLogState == 3) + if (gQuestLogState == QL_STATE_3) gUnknown_203AE90 = AllocZeroed(0x200 * sizeof(u16)); } @@ -1288,7 +1288,7 @@ static void Task_EndQuestLog(u8 taskId) gDisableMapMusicChangeOnMapLoad = 0; Overworld_PlaySpecialMapMusic(); sub_811229C(); - FillWindowPixelRect(gUnknown_203ADFE[0], 0xF, 0, 0, gUnknown_845661C[0].width * 8, gUnknown_845661C[0].height * 8); + FillWindowPixelRect(sQuestLogHeaderWindowIds[0], 0xF, 0, 0, sQuestLogHeaderWindowTemplates[0].width * 8, sQuestLogHeaderWindowTemplates[0].height * 8); tState++; break; case 1: @@ -1296,9 +1296,9 @@ static void Task_EndQuestLog(u8 taskId) { for (i = 0; i < 3; i++) { - ClearWindowTilemap(gUnknown_203ADFE[i]); - CopyWindowToVram(gUnknown_203ADFE[i], 1); - RemoveWindow(gUnknown_203ADFE[i]); + ClearWindowTilemap(sQuestLogHeaderWindowIds[i]); + CopyWindowToVram(sQuestLogHeaderWindowIds[i], 1); + RemoveWindow(sQuestLogHeaderWindowIds[i]); } tTimer = 0; tState++; @@ -1339,10 +1339,10 @@ static bool8 sub_81121D8(u8 taskId) sub_80716F8(gPlttBufferUnfaded + 0x01, gPlttBufferFaded + 0x01, 0xDF, 0x0F - data[1]); sub_80716F8(gPlttBufferUnfaded + 0x100, gPlttBufferFaded + 0x100, 0x100, 0x0F - data[1]); - FillWindowPixelRect(gUnknown_203ADFE[0], 0x00, 0, gUnknown_845661C[0].height * 8 - 1 - data[1], gUnknown_845661C[0].width * 8, 1); - FillWindowPixelRect(gUnknown_203ADFE[1], 0x00, 0, data[1], gUnknown_845661C[1].width * 8, 1); - CopyWindowToVram(gUnknown_203ADFE[0], 2); - CopyWindowToVram(gUnknown_203ADFE[1], 2); + FillWindowPixelRect(sQuestLogHeaderWindowIds[0], 0x00, 0, sQuestLogHeaderWindowTemplates[0].height * 8 - 1 - data[1], sQuestLogHeaderWindowTemplates[0].width * 8, 1); + FillWindowPixelRect(sQuestLogHeaderWindowIds[1], 0x00, 0, data[1], sQuestLogHeaderWindowTemplates[1].width * 8, 1); + CopyWindowToVram(sQuestLogHeaderWindowIds[0], 2); + CopyWindowToVram(sQuestLogHeaderWindowIds[1], 2); data[1]++; return FALSE; } @@ -1362,9 +1362,9 @@ static void sub_811229C(void) void sub_811231C(void) { - if (gQuestLogState == 1) + if (gQuestLogState == QL_STATE_1) { - sub_8110E68(gUnknown_203AE98); + TryRecordQuestLogEntrySequence(sQuestLogSceneRecordBuffer); sub_8110E3C(); gQuestLogState = 0; sQuestLogCB = NULL; @@ -1376,9 +1376,9 @@ void sub_811231C(void) void sub_8112364(void) { - if (gUnknown_3005E88 && gQuestLogState == 1) + if (gUnknown_3005E88 && gQuestLogState == QL_STATE_1) { - sub_8110E68(gUnknown_203AE98); + TryRecordQuestLogEntrySequence(sQuestLogSceneRecordBuffer); sub_8113A1C(1); sub_8110E3C(); gUnknown_3005E88 = 0; @@ -1452,29 +1452,29 @@ void sub_81124EC(u8 a0, u8 a1, u8 a2, u8 a3) { if (!sub_8112CEC()) { - gUnknown_3005E94[sQuestLogIdx].unk_4 = gUnknown_203B01A; - gUnknown_3005E94[sQuestLogIdx].unk_6 = 0; - gUnknown_3005E94[sQuestLogIdx].unk_0 = a0; - gUnknown_3005E94[sQuestLogIdx].unk_1 = a1; - gUnknown_3005E94[sQuestLogIdx].unk_2 = a2; - gUnknown_3005E94[sQuestLogIdx].unk_3 = a3; - sQuestLogIdx++; - gUnknown_203B01A = 0; + sCurQuestLogEntry[sQuestLogCursor].unk_4 = sNextStepDelay; + sCurQuestLogEntry[sQuestLogCursor].unk_6 = 0; + sCurQuestLogEntry[sQuestLogCursor].unk_0 = a0; + sCurQuestLogEntry[sQuestLogCursor].unk_1 = a1; + sCurQuestLogEntry[sQuestLogCursor].unk_2 = a2; + sCurQuestLogEntry[sQuestLogCursor].unk_3 = a3; + sQuestLogCursor++; + sNextStepDelay = 0; } } void sub_8112588(u8 a0, u8 a1, u8 a2, u8 a3, u8 a4) { - if (!sub_8112D1C()) + if (!RecordHeadAtEndOfEntry()) { - gUnknown_3005E94[sQuestLogIdx].unk_4 = gUnknown_203B01A; - gUnknown_3005E94[sQuestLogIdx].unk_6 = 0; - gUnknown_3005E94[sQuestLogIdx].unk_0 = a0; - gUnknown_3005E94[sQuestLogIdx].unk_1 = a1; - gUnknown_3005E94[sQuestLogIdx].unk_2 = a2; - gUnknown_3005E94[sQuestLogIdx].unk_3 = a3; - sQuestLogIdx++; - gUnknown_203B01A = a4; + sCurQuestLogEntry[sQuestLogCursor].unk_4 = sNextStepDelay; + sCurQuestLogEntry[sQuestLogCursor].unk_6 = 0; + sCurQuestLogEntry[sQuestLogCursor].unk_0 = a0; + sCurQuestLogEntry[sQuestLogCursor].unk_1 = a1; + sCurQuestLogEntry[sQuestLogCursor].unk_2 = a2; + sCurQuestLogEntry[sQuestLogCursor].unk_3 = a3; + sQuestLogCursor++; + sNextStepDelay = a4; } } @@ -1482,75 +1482,75 @@ void sub_8112628(u8 a0) { if (!sub_8112CEC()) { - if (a0 != gUnknown_3005E94[gUnknown_203B01C].unk_3 || a0 > 3) + if (a0 != sCurQuestLogEntry[gUnknown_203B01C].unk_3 || a0 > 3) { - gUnknown_3005E94[sQuestLogIdx].unk_4 = gUnknown_203B01A; - gUnknown_3005E94[sQuestLogIdx].unk_6 = 0; - gUnknown_3005E94[sQuestLogIdx].unk_0 = 0; - gUnknown_3005E94[sQuestLogIdx].unk_3 = a0; - gUnknown_203B01C = sQuestLogIdx; - sQuestLogIdx++; - gUnknown_203B01A = 0; + sCurQuestLogEntry[sQuestLogCursor].unk_4 = sNextStepDelay; + sCurQuestLogEntry[sQuestLogCursor].unk_6 = 0; + sCurQuestLogEntry[sQuestLogCursor].unk_0 = 0; + sCurQuestLogEntry[sQuestLogCursor].unk_3 = a0; + gUnknown_203B01C = sQuestLogCursor; + sQuestLogCursor++; + sNextStepDelay = 0; } } } void sub_81126AC(u8 a0, u8 a1) { - if (!sub_8112D1C()) + if (!RecordHeadAtEndOfEntry()) { - gUnknown_3005E94[sQuestLogIdx].unk_4 = gUnknown_203B01A; - gUnknown_3005E94[sQuestLogIdx].unk_6 = 0; - gUnknown_3005E94[sQuestLogIdx].unk_0 = 0; - gUnknown_3005E94[sQuestLogIdx].unk_3 = a0; - gUnknown_203B01C = sQuestLogIdx; - sQuestLogIdx++; - gUnknown_203B01A = a1; + sCurQuestLogEntry[sQuestLogCursor].unk_4 = sNextStepDelay; + sCurQuestLogEntry[sQuestLogCursor].unk_6 = 0; + sCurQuestLogEntry[sQuestLogCursor].unk_0 = 0; + sCurQuestLogEntry[sQuestLogCursor].unk_3 = a0; + gUnknown_203B01C = sQuestLogCursor; + sQuestLogCursor++; + sNextStepDelay = a1; } } -void sub_8112720(u8 a0) +void sub_8112720(u8 movementActionId) { - if (!sub_8112D1C()) + if (!RecordHeadAtEndOfEntry()) { - gUnknown_3005E94[sQuestLogIdx].unk_4 = gUnknown_203B01A; - gUnknown_3005E94[sQuestLogIdx].unk_6 = 1; - gUnknown_3005E94[sQuestLogIdx].unk_0 = 0; - gUnknown_3005E94[sQuestLogIdx].unk_3 = a0; - sQuestLogIdx++; - gUnknown_203B01A = 0; + sCurQuestLogEntry[sQuestLogCursor].unk_4 = sNextStepDelay; + sCurQuestLogEntry[sQuestLogCursor].unk_6 = 1; + sCurQuestLogEntry[sQuestLogCursor].unk_0 = 0; + sCurQuestLogEntry[sQuestLogCursor].unk_3 = movementActionId; + sQuestLogCursor++; + sNextStepDelay = 0; } } -void sub_811278C(u8 a0, u8 a1) +void sub_811278C(u8 movementActionId, u8 duration) { - if (!sub_8112D1C()) + if (!RecordHeadAtEndOfEntry()) { - gUnknown_3005E94[sQuestLogIdx].unk_4 = gUnknown_203B01A; - gUnknown_3005E94[sQuestLogIdx].unk_6 = 1; - gUnknown_3005E94[sQuestLogIdx].unk_0 = 0; - gUnknown_3005E94[sQuestLogIdx].unk_3 = a0; - sQuestLogIdx++; - gUnknown_203B01A = a1; + sCurQuestLogEntry[sQuestLogCursor].unk_4 = sNextStepDelay; + sCurQuestLogEntry[sQuestLogCursor].unk_6 = 1; + sCurQuestLogEntry[sQuestLogCursor].unk_0 = 0; + sCurQuestLogEntry[sQuestLogCursor].unk_3 = movementActionId; + sQuestLogCursor++; + sNextStepDelay = duration; } } void sub_81127F8(struct UnkStruct_3005E90 * a0) { - if (sQuestLogIdx < sNumQuestLogs) + if (sQuestLogCursor < sNumEventsInLogEntry) { u32 r2 = *(u32 *)a0 & 0x00FF00F3; - gUnknown_3005E94[sQuestLogIdx].unk_4 = gUnknown_203B01A; - gUnknown_3005E94[sQuestLogIdx].unk_6 = 2; - gUnknown_3005E94[sQuestLogIdx].unk_0 = r2; - gUnknown_3005E94[sQuestLogIdx].unk_1 = r2 >> 8; - gUnknown_3005E94[sQuestLogIdx].unk_2 = r2 >> 16; - gUnknown_3005E94[sQuestLogIdx].unk_3 = r2 >> 24; - sQuestLogIdx++; + sCurQuestLogEntry[sQuestLogCursor].unk_4 = sNextStepDelay; + sCurQuestLogEntry[sQuestLogCursor].unk_6 = 2; + sCurQuestLogEntry[sQuestLogCursor].unk_0 = r2; + sCurQuestLogEntry[sQuestLogCursor].unk_1 = r2 >> 8; + sCurQuestLogEntry[sQuestLogCursor].unk_2 = r2 >> 16; + sCurQuestLogEntry[sQuestLogCursor].unk_3 = r2 >> 24; + sQuestLogCursor++; if (ScriptContext2_IsEnabled()) - gUnknown_203B01A = TRUE; + sNextStepDelay = TRUE; else - gUnknown_203B01A = FALSE; + sNextStepDelay = FALSE; } } @@ -1580,10 +1580,10 @@ void sub_81128BC(u8 a0) gUnknown_3005E88 = 3; else if (r1 == 2) { - gUnknown_3005E94[sQuestLogIdx].unk_4 = gUnknown_203B01A; - gUnknown_3005E94[sQuestLogIdx].unk_6 = 3; - sQuestLogIdx++; - gUnknown_203B01A = 0; + sCurQuestLogEntry[sQuestLogCursor].unk_4 = sNextStepDelay; + sCurQuestLogEntry[sQuestLogCursor].unk_6 = 3; + sQuestLogCursor++; + sNextStepDelay = 0; gUnknown_3005E88 = 4; } break; @@ -1596,68 +1596,68 @@ void sub_81128BC(u8 a0) } } -static void sub_8112940(u8 a0, struct UnkStruct_203AE98 *a1, u16 a2) +static void SetUpQuestLogEntry(u8 kind, struct QuestLogEntry *entry, u16 size) { - s32 i; + int i; - switch (a0) + switch (kind) { default: gUnknown_3005E88 = 0; break; case 1: - gUnknown_3005E94 = a1; - sNumQuestLogs = a2 / 8; - for (i = 0; i < 0x40; i++) + sCurQuestLogEntry = entry; + sNumEventsInLogEntry = size / sizeof(*sCurQuestLogEntry); + for (i = 0; i < (s32)NELEMS(sMovementScripts); i++) { sMovementScripts[i][0] |= 0xFF; sMovementScripts[i][1] |= 0xFF; } - sQuestLogIdx = 0; + sQuestLogCursor = 0; gUnknown_203B01C = 0; gUnknown_3005E90 = (struct UnkStruct_3005E90){}; - gUnknown_203B01A = gUnknown_3005E94[sQuestLogIdx].unk_4; - sMovementScripts[0][0] = gUnknown_3005E94[sQuestLogIdx].unk_3; + sNextStepDelay = sCurQuestLogEntry[sQuestLogCursor].unk_4; + sMovementScripts[0][0] = sCurQuestLogEntry[sQuestLogCursor].unk_3; sMovementScripts[0][1] = 0xFF; gUnknown_3005E88 = 1; break; case 2: - gUnknown_3005E94 = a1; - sNumQuestLogs = a2 / 8; - for (i = 0; i < sNumQuestLogs; i++) + sCurQuestLogEntry = entry; + sNumEventsInLogEntry = size / sizeof(*sCurQuestLogEntry); + for (i = 0; i < sNumEventsInLogEntry; i++) { - gUnknown_3005E94[i] = (struct UnkStruct_203AE98){ 0, 0, 0, 0, 0xFFFF, 0xFF }; + sCurQuestLogEntry[i] = (struct QuestLogEntry){ 0, 0, 0, 0, 0xFFFF, 0xFF }; } - sQuestLogIdx = 0; - gUnknown_203B01A = 0; - gUnknown_3005E94[sQuestLogIdx].unk_4 = 0; - gUnknown_3005E94[sQuestLogIdx].unk_6 = 0; - gUnknown_3005E94[sQuestLogIdx].unk_0 = 0; + sQuestLogCursor = 0; + sNextStepDelay = 0; + sCurQuestLogEntry[sQuestLogCursor].unk_4 = 0; + sCurQuestLogEntry[sQuestLogCursor].unk_6 = 0; + sCurQuestLogEntry[sQuestLogCursor].unk_0 = 0; switch (GetPlayerFacingDirection()) { case DIR_NONE: case DIR_SOUTH: - gUnknown_3005E94[sQuestLogIdx].unk_3 = DIR_SOUTH - 1; + sCurQuestLogEntry[sQuestLogCursor].unk_3 = DIR_SOUTH - 1; break; case DIR_EAST: - gUnknown_3005E94[sQuestLogIdx].unk_3 = DIR_EAST - 1; + sCurQuestLogEntry[sQuestLogCursor].unk_3 = DIR_EAST - 1; break; case DIR_NORTH: - gUnknown_3005E94[sQuestLogIdx].unk_3 = DIR_NORTH - 1; + sCurQuestLogEntry[sQuestLogCursor].unk_3 = DIR_NORTH - 1; break; case DIR_WEST: - gUnknown_3005E94[sQuestLogIdx].unk_3 = DIR_WEST - 1; + sCurQuestLogEntry[sQuestLogCursor].unk_3 = DIR_WEST - 1; break; } gUnknown_203B01C = 0; - sQuestLogIdx++; - gUnknown_3005E94[sQuestLogIdx].unk_4 = 0; - gUnknown_3005E94[sQuestLogIdx].unk_6 = 2; - gUnknown_3005E94[sQuestLogIdx].unk_0 = 0; - gUnknown_3005E94[sQuestLogIdx].unk_1 = 0; - gUnknown_3005E94[sQuestLogIdx].unk_2 = 0; - gUnknown_3005E94[sQuestLogIdx].unk_3 = 0; - sQuestLogIdx++; + sQuestLogCursor++; + sCurQuestLogEntry[sQuestLogCursor].unk_4 = 0; + sCurQuestLogEntry[sQuestLogCursor].unk_6 = 2; + sCurQuestLogEntry[sQuestLogCursor].unk_0 = 0; + sCurQuestLogEntry[sQuestLogCursor].unk_1 = 0; + sCurQuestLogEntry[sQuestLogCursor].unk_2 = 0; + sCurQuestLogEntry[sQuestLogCursor].unk_3 = 0; + sQuestLogCursor++; gUnknown_3005E88 = 2; break; } @@ -1672,22 +1672,22 @@ void sub_8112B3C(void) case 1: if (!sub_8112CEC()) { - if (gUnknown_203B01A != 0) - gUnknown_203B01A--; + if (sNextStepDelay != 0) + sNextStepDelay--; else { do { - switch (gUnknown_3005E94[sQuestLogIdx].unk_6) + switch (sCurQuestLogEntry[sQuestLogCursor].unk_6) { case 0: - sMovementScripts[gUnknown_3005E94[sQuestLogIdx].unk_0][0] = gUnknown_3005E94[sQuestLogIdx].unk_3; + sMovementScripts[sCurQuestLogEntry[sQuestLogCursor].unk_0][0] = sCurQuestLogEntry[sQuestLogCursor].unk_3; break; case 1: - sMovementScripts[gUnknown_3005E94[sQuestLogIdx].unk_0][1] = gUnknown_3005E94[sQuestLogIdx].unk_3; + sMovementScripts[sCurQuestLogEntry[sQuestLogCursor].unk_0][1] = sCurQuestLogEntry[sQuestLogCursor].unk_3; break; case 2: - *(u32 *)&gUnknown_3005E90 = ((gUnknown_3005E94[sQuestLogIdx].unk_3 << 24) | (gUnknown_3005E94[sQuestLogIdx].unk_2 << 16) | (gUnknown_3005E94[sQuestLogIdx].unk_1 << 8) | (gUnknown_3005E94[sQuestLogIdx].unk_0 << 0)); + *(u32 *)&gUnknown_3005E90 = ((sCurQuestLogEntry[sQuestLogCursor].unk_3 << 24) | (sCurQuestLogEntry[sQuestLogCursor].unk_2 << 16) | (sCurQuestLogEntry[sQuestLogCursor].unk_1 << 8) | (sCurQuestLogEntry[sQuestLogCursor].unk_0 << 0)); break; case 3: gUnknown_3005E88 = 3; @@ -1700,17 +1700,17 @@ void sub_8112B3C(void) } if (gUnknown_3005E88 == 0) break; - if (++sQuestLogIdx >= sNumQuestLogs) + if (++sQuestLogCursor >= sNumEventsInLogEntry) { gUnknown_3005E88 = 0; break; } - gUnknown_203B01A = gUnknown_3005E94[sQuestLogIdx].unk_4; + sNextStepDelay = sCurQuestLogEntry[sQuestLogCursor].unk_4; } while (gUnknown_3005E88 != 3 - && (gUnknown_203B01A == 0 || gUnknown_203B01A == 0xFFFF)); + && (sNextStepDelay == 0 || sNextStepDelay == 0xFFFF)); } } - else if (sQuestLogIdx >= sNumQuestLogs) + else if (sQuestLogCursor >= sNumEventsInLogEntry) { gUnknown_3005E88 = 0; } @@ -1718,8 +1718,8 @@ void sub_8112B3C(void) case 2: if (ScriptContext2_IsEnabled() != TRUE) { - gUnknown_203B01A++; - if (sQuestLogIdx >= sNumQuestLogs) + sNextStepDelay++; + if (sQuestLogCursor >= sNumEventsInLogEntry) gUnknown_3005E88 = 0; } break; @@ -1732,7 +1732,7 @@ void sub_8112B3C(void) void sub_8112C9C(void) { - gUnknown_203B01A++; + sNextStepDelay++; } u8 sub_8112CAC(void) @@ -1753,14 +1753,14 @@ u8 sub_8112CAC(void) static bool8 sub_8112CEC(void) { - if (sQuestLogIdx >= sNumQuestLogs || ScriptContext2_IsEnabled() == TRUE) + if (sQuestLogCursor >= sNumEventsInLogEntry || ScriptContext2_IsEnabled() == TRUE) return TRUE; return FALSE; } -static bool8 sub_8112D1C(void) +static bool8 RecordHeadAtEndOfEntry(void) { - if (sQuestLogIdx >= sNumQuestLogs) + if (sQuestLogCursor >= sNumEventsInLogEntry) return TRUE; return FALSE; } @@ -1774,9 +1774,9 @@ static const struct UnkStruct_300201C gUnknown_84566A4 = { void * QuestLogGetFlagOrVarPtr(bool8 isFlag, u16 idx) { void * response; - if (sQuestLogIdx == 0) + if (sQuestLogCursor == 0) return NULL; - if (sQuestLogIdx >= sNumQuestLogs) + if (sQuestLogCursor >= sNumEventsInLogEntry) return NULL; if (sFlagOrVarPlayhead >= sNumFlagsOrVars) return NULL; @@ -1792,9 +1792,9 @@ void * QuestLogGetFlagOrVarPtr(bool8 isFlag, u16 idx) void QuestLogSetFlagOrVar(bool8 isFlag, u16 idx, u16 value) { - if (sQuestLogIdx == 0) + if (sQuestLogCursor == 0) return; - if (sQuestLogIdx >= sNumQuestLogs) + if (sQuestLogCursor >= sNumEventsInLogEntry) return; if (sFlagOrVarPlayhead >= sNumFlagsOrVars) return; @@ -1817,7 +1817,7 @@ void sub_8112E3C(u8 a0, struct UnkStruct_300201C * a1, u16 a2) sFlagOrVarPlayhead = 0; if (a0 == 2) { - for (i = 0; i < sNumQuestLogs; i++) + for (i = 0; i < sNumEventsInLogEntry; i++) { sFlagOrVarRecords[i] = gUnknown_84566A4; } @@ -2395,7 +2395,7 @@ void SetQuestLogEvent(u16 eventId, const u16 *eventData) return; } sub_811381C(); - if (gQuestLogState == 2) + if (gQuestLogState == QL_STATE_2) return; if (!IS_VALID_QL_EVENT(eventId)) @@ -2431,7 +2431,7 @@ void SetQuestLogEvent(u16 eventId, const u16 *eventData) { if (sub_81153A8(eventId, eventData) == FALSE) return; - sub_8110AEC(eventId); + StartRecordingQuestLogEntry(eventId); } } else if (eventId == QL_EVENT_OBTAINED_ITEM) @@ -2513,10 +2513,10 @@ bool8 sub_8113748(void) if (InQuestLogDisabledLocation() != TRUE) return FALSE; - if (gQuestLogState == 2) + if (gQuestLogState == QL_STATE_2) return TRUE; - if (gQuestLogState == 1) + if (gQuestLogState == QL_STATE_1) sub_8112364(); return FALSE; @@ -2579,7 +2579,7 @@ static u16 *sub_8113828(u16 eventId, const u16 *eventData) if (sub_81153A8(eventId, eventData) == FALSE) return NULL; - sub_8110AEC(eventId); + StartRecordingQuestLogEntry(eventId); sub_8113B94(eventId); if (eventId == QL_EVENT_DEFEATED_WILD_MON) @@ -2619,7 +2619,7 @@ void sub_811390C(void) { u16 *resp; gUnknown_203B04A = 0; - sub_8110AEC(gUnknown_203B024.unk_00); + StartRecordingQuestLogEntry(gUnknown_203B024.unk_00); resp = sQuestLogStorageCBs[gUnknown_203B024.unk_00](gUnknown_203AE08, gUnknown_203B024.unk_04); gUnknown_203AE08 = resp; sub_81138F8(); @@ -2651,7 +2651,7 @@ void sub_81139BC(void) if (gUnknown_3005E88 == 0) { gUnknown_203B04A = 0; - sub_8110AEC(gUnknown_203B024.unk_00); + StartRecordingQuestLogEntry(gUnknown_203B024.unk_00); } sub_8113B94(gUnknown_203B024.unk_00); resp = sQuestLogStorageCBs[gUnknown_203B024.unk_00](gUnknown_203AE08, gUnknown_203B024.unk_04); @@ -2665,7 +2665,7 @@ void sub_81139BC(void) static void sub_8113A1C(u16 a0) { gUnknown_203AE08 = sub_8113C5C(gUnknown_203AE08, a0); - sQuestLogIdx++; + sQuestLogCursor++; } static bool8 IsQuestLogEventWithSpecialEncounterSpecies(u16 eventId, const u16 *eventData) @@ -2806,7 +2806,7 @@ static bool8 sub_8113AE8(const u16 *a0) const u16 *r0 = a0; #endif - if (r0 == NULL || r0[1] > sQuestLogIdx) + if (r0 == NULL || r0[1] > sQuestLogCursor) return FALSE; sQuestLogEventTextBufferCBs[a0[0] & 0xFFF](a0); @@ -2836,11 +2836,11 @@ static void sub_8113B88(void) static void sub_8113B94(u16 eventId) { - if (gUnknown_203B044.unk_0 != (u8)eventId || gUnknown_203B044.unk_2 != sQuestLogIdx) + if (gUnknown_203B044.unk_0 != (u8)eventId || gUnknown_203B044.unk_2 != sQuestLogCursor) { gUnknown_203B044.unk_0 = eventId; gUnknown_203B044.unk_1 = 0; - gUnknown_203B044.unk_2 = sQuestLogIdx; + gUnknown_203B044.unk_2 = sQuestLogCursor; } else if (gUnknown_203B044.unk_1 < 5) gUnknown_203B044.unk_1++; @@ -2848,7 +2848,7 @@ static void sub_8113B94(u16 eventId) static void sub_8113BD8(void) { - gUnknown_203B049 = 0; + sNewlyEnteredMap = FALSE; gUnknown_203B04A = 0; gUnknown_203B04B = FALSE; } @@ -2861,7 +2861,7 @@ static u16 *sub_8113BF4(u16 *a0) return a0 + 1; } -static u16 *sub_8113C20(u16 *a0, struct UnkStruct_203AE98 * a1) +static u16 *sub_8113C20(u16 *a0, struct QuestLogEntry * a1) { if (!sub_8110988(a0, sQuestLogEventCmdSizes[QL_EVENT_39])) return NULL; @@ -2883,7 +2883,7 @@ static u16 *sub_8113C5C(u16 *a0, u16 a1) return a0 + 2; } -static u16 *sub_8113C8C(u16 *a0, struct UnkStruct_203AE98 * a1) +static u16 *sub_8113C8C(u16 *a0, struct QuestLogEntry * a1) { if (!sub_8110988(a0, sQuestLogEventCmdSizes[QL_EVENT_41])) return NULL; @@ -2896,7 +2896,7 @@ static u16 *sub_8113C8C(u16 *a0, struct UnkStruct_203AE98 * a1) return a0 + 2; } -static u16 *sub_8113CC8(u16 *a0, struct UnkStruct_203AE98 * a1) +static u16 *sub_8113CC8(u16 *a0, struct QuestLogEntry * a1) { u8 *r6 = (u8 *)a0 + 4; @@ -2911,7 +2911,7 @@ static u16 *sub_8113CC8(u16 *a0, struct UnkStruct_203AE98 * a1) return (u16 *)(r6 + 4); } -static u16 *sub_8113D08(u16 *a0, struct UnkStruct_203AE98 * a1) +static u16 *sub_8113D08(u16 *a0, struct QuestLogEntry * a1) { u8 *r6 = (u8 *)a0 + 4; @@ -2926,7 +2926,7 @@ static u16 *sub_8113D08(u16 *a0, struct UnkStruct_203AE98 * a1) return (u16 *)(r6 + 4); } -static u16 *sub_8113D48(u16 *a0, struct UnkStruct_203AE98 * a1) +static u16 *sub_8113D48(u16 *a0, struct QuestLogEntry * a1) { u16 *r4 = a0; u8 *r6 = (u8 *)a0 + 4; @@ -2945,7 +2945,7 @@ static u16 *sub_8113D48(u16 *a0, struct UnkStruct_203AE98 * a1) return (u16 *)(r6 + 4); } -static u16 *sub_8113D94(u16 *a0, struct UnkStruct_203AE98 * a1) +static u16 *sub_8113D94(u16 *a0, struct QuestLogEntry * a1) { u16 *r5 = a0; u8 *r6 = (u8 *)a0 + 4; @@ -2999,7 +2999,7 @@ u16 *sub_8113DE0(u16 eventId, u16 *a1) r1 = gUnknown_203B044.unk_1; r5[0] = eventId + (r1 << 12); - r5[1] = sQuestLogIdx; + r5[1] = sQuestLogCursor; r5 = (void *)r5 + (r1 * cmdSize + 4); return r5; } @@ -3244,7 +3244,7 @@ static u16 *BufferQuestLogData_UsedPkmnCenter(u16 *a0, const u16 *eventData) return NULL; r4[0] = QL_EVENT_USED_PKMN_CENTER; - r4[1] = sQuestLogIdx; + r4[1] = sQuestLogCursor; return r4 + 2; } @@ -3260,7 +3260,7 @@ static u16 *BufferQuestLogData_LinkTraded(u16 *a0, const u16 *eventData) u16 *r4 = a0 + 4; a0[0] = QL_EVENT_LINK_TRADED; - a0[1] = sQuestLogIdx; + a0[1] = sQuestLogCursor; a0[2] = eventData[0]; a0[3] = eventData[1]; eventData += 2; @@ -3305,7 +3305,7 @@ static const u8 *const sBattleOutcomeTexts[] = { static u16 *BufferQuestLogData_LinkBattledSingle(u16 *a0, const u16 *eventData) { a0[0] = QL_EVENT_LINK_BATTLED_SINGLE; - a0[1] = sQuestLogIdx; + a0[1] = sQuestLogCursor; *((u8 *)a0 + 4) = *((const u8 *)eventData + 0); memcpy((u8 *)a0 + 5, (const u8 *)eventData + 1, PLAYER_NAME_LENGTH); a0 += 6; @@ -3329,7 +3329,7 @@ static const u16 *BufferQuestLogText_LinkBattledSingle(const u16 *a0) static u16 *BufferQuestLogData_LinkBattledDouble(u16 *a0, const u16 *eventData) { a0[0] = QL_EVENT_LINK_BATTLED_DOUBLE; - a0[1] = sQuestLogIdx; + a0[1] = sQuestLogCursor; *((u8 *)a0 + 4) = *((const u8 *)eventData + 0); memcpy((u8 *)a0 + 5, (const u8 *)eventData + 1, PLAYER_NAME_LENGTH); a0 += 6; @@ -3353,7 +3353,7 @@ static const u16 *BufferQuestLogText_LinkBattledDouble(const u16 *a0) static u16 *BufferQuestLogData_LinkBattledMulti(u16 *a0, const u16 *eventData) { a0[0] = QL_EVENT_LINK_BATTLED_MULTI; - a0[1] = sQuestLogIdx; + a0[1] = sQuestLogCursor; *((u8 *)a0 + 4) = *((const u8 *)eventData + 0); memcpy((u8 *)a0 + 5, (const u8 *)eventData + 1, PLAYER_NAME_LENGTH); memcpy((u8 *)a0 + 12, (const u8 *)eventData + 8, PLAYER_NAME_LENGTH); @@ -3388,7 +3388,7 @@ static const u16 *BufferQuestLogText_LinkBattledMulti(const u16 *a0) static u16 *BufferQuestLogData_UsedUnionRoom(u16 *a0, const u16 *eventData) { a0[0] = QL_EVENT_USED_UNION_ROOM; - a0[1] = sQuestLogIdx; + a0[1] = sQuestLogCursor; return a0 + 2; } @@ -3402,7 +3402,7 @@ static const u16 *BufferQuestLogText_UsedUnionRoom(const u16 *a0) static u16 *BufferQuestLogData_UsedUnionRoomChat(u16 *a0, const u16 *eventData) { a0[0] = QL_EVENT_USED_UNION_ROOM_CHAT; - a0[1] = sQuestLogIdx; + a0[1] = sQuestLogCursor; return a0 + 2; } @@ -3417,7 +3417,7 @@ static u16 *BufferQuestLogData_LinkTradedUnionRoom(u16 *a0, const u16 *eventData { u8 *r4 = (u8 *)(a0 + 4); a0[0] = QL_EVENT_LINK_TRADED_UNION; - a0[1] = sQuestLogIdx; + a0[1] = sQuestLogCursor; a0[2] = eventData[0]; a0[3] = eventData[1]; memcpy(r4, eventData + 2, PLAYER_NAME_LENGTH); @@ -3441,7 +3441,7 @@ static const u16 *BufferQuestLogText_LinkTradedUnionRoom(const u16 *a0) static u16 *BufferQuestLogData_LinkBattledUnionRoom(u16 *a0, const u16 *eventData) { a0[0] = QL_EVENT_LINK_BATTLED_UNION; - a0[1] = sQuestLogIdx; + a0[1] = sQuestLogCursor; *(u8 *)&a0[2] = *(const u8 *)&eventData[0]; memcpy((u8 *)a0 + 5, (const u8 *)eventData + 1, PLAYER_NAME_LENGTH); a0 += 6; @@ -3743,7 +3743,7 @@ static u16 *BufferQuestLogData_DefeatedWildMon(u16 *a0, const u16 *eventData) if (r5[0] == 0 && r5[1] == 0) { r4[0] = QL_EVENT_DEFEATED_WILD_MON; - r4[1] = sQuestLogIdx; + r4[1] = sQuestLogCursor; } if (eventData[0]) r4[2] = eventData[0]; @@ -3847,7 +3847,7 @@ static u16 *BufferQuestLogData_DefeatedChampion(u16 *a0, const u16 *eventData) if (!sub_8110944(a0, sQuestLogEventCmdSizes[QL_EVENT_DEFEATED_CHAMPION])) return NULL; a0[0] = 0x2021; - a0[1] = sQuestLogIdx; + a0[1] = sQuestLogCursor; a0[2] = eventData[1]; a0[3] = eventData[2]; *((u8 *)a0 + 8) = *((const u8 *)eventData + 6); @@ -4299,7 +4299,7 @@ void QuestLog_RecordEnteredMap(u16 worldMapFlag) { s32 i; - if (gQuestLogState == 2 || gQuestLogState == 3) + if (gQuestLogState == QL_STATE_2 || gQuestLogState == QL_STATE_3) return; for (i = 0; i < (int)NELEMS(sQuestLogWorldMapFlags); i++) @@ -4308,13 +4308,13 @@ void QuestLog_RecordEnteredMap(u16 worldMapFlag) { if (!FlagGet(worldMapFlag)) { - gUnknown_203B049 = TRUE; + sNewlyEnteredMap = TRUE; break; } else { - gUnknown_203B049 += 0; - gUnknown_203B049 = FALSE; + sNewlyEnteredMap += 0; + sNewlyEnteredMap = FALSE; break; } } @@ -4324,13 +4324,13 @@ void QuestLog_RecordEnteredMap(u16 worldMapFlag) void sub_8115798(void) { u16 sp0; - if (gQuestLogState != 2 && gQuestLogState != 3) + if (gQuestLogState != QL_STATE_2 && gQuestLogState != QL_STATE_3) { - if (gUnknown_203B049) + if (sNewlyEnteredMap) { sp0 = gMapHeader.regionMapSectionId; SetQuestLogEvent(QL_EVENT_ARRIVED, &sp0); - gUnknown_203B049 = FALSE; + sNewlyEnteredMap = FALSE; } } } diff --git a/src/quest_log_objects.c b/src/quest_log_objects.c index 2c17987e8..64b4b7fe5 100644 --- a/src/quest_log_objects.c +++ b/src/quest_log_objects.c @@ -45,7 +45,7 @@ void SetQuestLogObjectEventsData(struct QuestLog * questLog) } } -void sub_815A1F8(const struct QuestLog * questLog, const struct ObjectEventTemplate * templates) +void SetSav1ObjectEventsFromQuestLog(const struct QuestLog * questLog, const struct ObjectEventTemplate * templates) { u32 i, j; const struct QuestLogObjectEvent * questLogObjectEvents = questLog->unk_008; @@ -131,7 +131,7 @@ void sub_815A1F8(const struct QuestLog * questLog, const struct ObjectEventTempl void sub_815A540(void) { - if (gQuestLogState == 2) + if (gQuestLogState == QL_STATE_2) { s16 x, y; -- cgit v1.2.3 From 8a85485cc25b9ac67c9b60697efd56c88d7b1d5f Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Tue, 24 Mar 2020 18:17:18 -0400 Subject: through PlayerTurnInPlace --- src/field_player_avatar.c | 97 ++++++++++++++++++++++++++++++++++++++++++++--- src/quest_log.c | 37 +++++++++--------- 2 files changed, 110 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/field_player_avatar.c b/src/field_player_avatar.c index a7525fc41..61d6f930f 100644 --- a/src/field_player_avatar.c +++ b/src/field_player_avatar.c @@ -71,19 +71,20 @@ bool8 PlayerIsAnimActive(void); bool8 PlayerCheckIfAnimFinishedOrInactive(void); bool8 player_is_anim_in_certain_ranges(void); bool8 sub_805BF58(void); +void PlayerRun(u8 direction); +void PlayerRunSlow(u8 direction); +void PlayerGoSpeed2(u8 direction); +void PlayerGoSpeed1(u8 direction); +void PlayerGoSlow(u8 direction); +void PlayerRideWaterCurrent(u8 direction); +void sub_805C438(u8 direction); void CreateStopSurfingTask(u8 direction); void StartStrengthAnim(u8 objectEventId, u8 direction); void PlayerNotOnBikeCollide(u8 direction); -void PlayerRun(u8 direction); -void PlayerRunSlow(u8 direction); void PlayerFaceDirection(u8 direction); void PlayerTurnInPlace(u8 direction); -void PlayerGoSpeed2(u8 direction); -void PlayerGoSpeed1(u8 direction); void PlayerJumpLedge(u8 direction); -void PlayerGoSlow(u8 direction); void PlayerGoSpin(u8 direction); -void PlayerRideWaterCurrent(u8 direction); void sub_805C2CC(u8 metatileBehavior); void sub_805CC40(struct ObjectEvent * playerObjEvent); void DoPlayerMatJump(void); @@ -779,3 +780,87 @@ void PlayerSetAnimId(u8 movementActionId, u8 copyableMovement) sub_8112628(movementActionId); } } + +void sub_805C06C(struct ObjectEvent * objectEvent, u8 movementAction) +{ + if (!ObjectEventSetHeldMovement(&gObjectEvents[gPlayerAvatar.objectEventId], movementAction)) + sub_81126AC(movementAction, 0); +} + +void sub_805C0A4(struct ObjectEvent * objectEvent, u8 movementAction) +{ + if (!ObjectEventSetHeldMovement(objectEvent, movementAction)) + sub_8112588(objectEvent->localId, objectEvent->mapNum, objectEvent->mapGroup, movementAction, 32); +} + +void sub_805C0D4(u8 direction) +{ + PlayerSetAnimId(sub_8063F2C(direction), 2); +} + +void PlayerGoSlow(u8 direction) +{ + PlayerSetAnimId(sub_8063F58(direction), 2); +} + +void PlayerGoSpeed1(u8 direction) +{ + PlayerSetAnimId(GetWalkNormalMovementAction(direction), 2); +} + +void PlayerGoSpeed2(u8 direction) +{ + PlayerSetAnimId(GetWalkFastMovementAction(direction), 2); +} + +void sub_805C134(u8 direction) +{ + PlayerSetAnimId(sub_8063FDC(direction), 2); +} + +void PlayerRideWaterCurrent(u8 direction) +{ + PlayerSetAnimId(sub_8064008(direction), 2); +} + +void sub_805C164(u8 direction) +{ + PlayerSetAnimId(GetWalkFastestMovementAction(direction), 2); +} + +void PlayerRun(u8 direction) +{ + PlayerSetAnimId(GetPlayerRunMovementAction(direction), 2); +} + +void PlayerRunSlow(u8 direction) +{ + PlayerSetAnimId(GetPlayerRunSlowMovementAction(direction), 2); +} + +void PlayerOnBikeCollide(u8 direction) +{ + sub_805C438(direction); + PlayerSetAnimId(GetWalkInPlaceNormalMovementAction(direction), 2); +} + +void PlayerNotOnBikeCollide(u8 direction) +{ + sub_805C438(direction); + PlayerSetAnimId(GetStepInPlaceDelay32AnimId(direction), 2); +} + +void PlayerFaceDirection(u8 direction) +{ + PlayerSetAnimId(GetFaceDirectionMovementAction(direction), 1); +} + +void sub_805C20C(u8 direction) +{ + PlayerSetAnimId(GetWalkSlowMovementAction(direction), 1); +} + +void PlayerTurnInPlace(u8 direction) +{ + PlayerSetAnimId(GetWalkInPlaceSlowMovementAction(direction), 1); +} diff --git a/src/quest_log.c b/src/quest_log.c index fb327433a..b2dbb5721 100644 --- a/src/quest_log.c +++ b/src/quest_log.c @@ -43,6 +43,7 @@ #include "constants/species.h" #include "constants/items.h" #include "constants/field_weather.h" +#include "constants/event_object_movement.h" u8 gUnknown_3005E88; @@ -1448,7 +1449,7 @@ void sub_811246C(struct Sprite *sprite) } } -void sub_81124EC(u8 a0, u8 a1, u8 a2, u8 a3) +void sub_81124EC(u8 a0, u8 a1, u8 a2, u8 movementActionId) { if (!sub_8112CEC()) { @@ -1457,37 +1458,37 @@ void sub_81124EC(u8 a0, u8 a1, u8 a2, u8 a3) sCurQuestLogEntry[sQuestLogCursor].unk_0 = a0; sCurQuestLogEntry[sQuestLogCursor].unk_1 = a1; sCurQuestLogEntry[sQuestLogCursor].unk_2 = a2; - sCurQuestLogEntry[sQuestLogCursor].unk_3 = a3; + sCurQuestLogEntry[sQuestLogCursor].unk_3 = movementActionId; sQuestLogCursor++; sNextStepDelay = 0; } } -void sub_8112588(u8 a0, u8 a1, u8 a2, u8 a3, u8 a4) +void sub_8112588(u8 localId, u8 mapNum, u8 mapGroup, u8 movementActionId, u8 duration) { if (!RecordHeadAtEndOfEntry()) { sCurQuestLogEntry[sQuestLogCursor].unk_4 = sNextStepDelay; sCurQuestLogEntry[sQuestLogCursor].unk_6 = 0; - sCurQuestLogEntry[sQuestLogCursor].unk_0 = a0; - sCurQuestLogEntry[sQuestLogCursor].unk_1 = a1; - sCurQuestLogEntry[sQuestLogCursor].unk_2 = a2; - sCurQuestLogEntry[sQuestLogCursor].unk_3 = a3; + sCurQuestLogEntry[sQuestLogCursor].unk_0 = localId; + sCurQuestLogEntry[sQuestLogCursor].unk_1 = mapNum; + sCurQuestLogEntry[sQuestLogCursor].unk_2 = mapGroup; + sCurQuestLogEntry[sQuestLogCursor].unk_3 = movementActionId; sQuestLogCursor++; - sNextStepDelay = a4; + sNextStepDelay = duration; } } -void sub_8112628(u8 a0) +void sub_8112628(u8 movementActionId) { if (!sub_8112CEC()) { - if (a0 != sCurQuestLogEntry[gUnknown_203B01C].unk_3 || a0 > 3) + if (movementActionId != sCurQuestLogEntry[gUnknown_203B01C].unk_3 || movementActionId > MOVEMENT_ACTION_FACE_RIGHT) { sCurQuestLogEntry[sQuestLogCursor].unk_4 = sNextStepDelay; sCurQuestLogEntry[sQuestLogCursor].unk_6 = 0; sCurQuestLogEntry[sQuestLogCursor].unk_0 = 0; - sCurQuestLogEntry[sQuestLogCursor].unk_3 = a0; + sCurQuestLogEntry[sQuestLogCursor].unk_3 = movementActionId; gUnknown_203B01C = sQuestLogCursor; sQuestLogCursor++; sNextStepDelay = 0; @@ -1495,17 +1496,17 @@ void sub_8112628(u8 a0) } } -void sub_81126AC(u8 a0, u8 a1) +void sub_81126AC(u8 movementActionId, u8 duration) { if (!RecordHeadAtEndOfEntry()) { sCurQuestLogEntry[sQuestLogCursor].unk_4 = sNextStepDelay; sCurQuestLogEntry[sQuestLogCursor].unk_6 = 0; sCurQuestLogEntry[sQuestLogCursor].unk_0 = 0; - sCurQuestLogEntry[sQuestLogCursor].unk_3 = a0; + sCurQuestLogEntry[sQuestLogCursor].unk_3 = movementActionId; gUnknown_203B01C = sQuestLogCursor; sQuestLogCursor++; - sNextStepDelay = a1; + sNextStepDelay = duration; } } @@ -1637,16 +1638,16 @@ static void SetUpQuestLogEntry(u8 kind, struct QuestLogEntry *entry, u16 size) { case DIR_NONE: case DIR_SOUTH: - sCurQuestLogEntry[sQuestLogCursor].unk_3 = DIR_SOUTH - 1; + sCurQuestLogEntry[sQuestLogCursor].unk_3 = MOVEMENT_ACTION_FACE_DOWN; break; case DIR_EAST: - sCurQuestLogEntry[sQuestLogCursor].unk_3 = DIR_EAST - 1; + sCurQuestLogEntry[sQuestLogCursor].unk_3 = MOVEMENT_ACTION_FACE_RIGHT; break; case DIR_NORTH: - sCurQuestLogEntry[sQuestLogCursor].unk_3 = DIR_NORTH - 1; + sCurQuestLogEntry[sQuestLogCursor].unk_3 = MOVEMENT_ACTION_FACE_UP; break; case DIR_WEST: - sCurQuestLogEntry[sQuestLogCursor].unk_3 = DIR_WEST - 1; + sCurQuestLogEntry[sQuestLogCursor].unk_3 = MOVEMENT_ACTION_FACE_LEFT; break; } gUnknown_203B01C = 0; -- cgit v1.2.3 From 6c964a63505f6dc7527661400f6aae145c4cdf4b Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Tue, 24 Mar 2020 20:59:37 -0400 Subject: through InitPlayerAvatar --- src/event_object_movement.c | 20 +- src/field_player_avatar.c | 434 +++++++++++++++++++++++++++++++++++++++++++- src/naming_screen.c | 2 +- 3 files changed, 440 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/event_object_movement.c b/src/event_object_movement.c index dbde0cb93..7fde3ff21 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -4628,7 +4628,7 @@ dirn_to_anim(GetPlayerRunSlowMovementAction, gUnknown_83A6528); dirn_to_anim(sub_80640E4, gUnknown_83A652D); dirn_to_anim(GetJump2MovementAction, gUnknown_83A6532); dirn_to_anim(GetJumpInPlaceMovementAction, gUnknown_83A6537); -dirn_to_anim(sub_8064168, gUnknown_83A653C); +dirn_to_anim(GetJumpInPlaceTurnAroundMovementAction, gUnknown_83A653C); dirn_to_anim(GetJumpMovementAction, gUnknown_83A6541); dirn_to_anim(sub_80641C0, gUnknown_83A6546); dirn_to_anim(sub_80641EC, gUnknown_83A654B); @@ -4642,15 +4642,15 @@ bool8 ObjectEventFaceOppositeDirection(struct ObjectEvent *objectEvent, u8 direc return ObjectEventSetHeldMovement(objectEvent, GetFaceDirectionMovementAction(GetOppositeDirection(direction))); } -dirn_to_anim(sub_80642F4, gUnknown_83A6564); -dirn_to_anim(sub_8064320, gUnknown_83A6569); -dirn_to_anim(sub_806434C, gUnknown_83A656E); -dirn_to_anim(sub_8064378, gUnknown_83A6573); -dirn_to_anim(sub_80643A4, gUnknown_83A6578); -dirn_to_anim(sub_80643D0, gUnknown_83A657D); -dirn_to_anim(sub_80643FC, gUnknown_83A6582); -dirn_to_anim(sub_8064428, gUnknown_83A6587); -dirn_to_anim(sub_8064454, gUnknown_83A658C); +dirn_to_anim(GetAcroWheelieFaceDirectionMovementAction, gUnknown_83A6564); +dirn_to_anim(GetAcroPopWheelieFaceDirectionMovementAction, gUnknown_83A6569); +dirn_to_anim(GetAcroEndWheelieFaceDirectionMovementAction, gUnknown_83A656E); +dirn_to_anim(GetAcroWheelieHopFaceDirectionMovementAction, gUnknown_83A6573); +dirn_to_anim(GetAcroWheelieHopDirectionMovementAction, gUnknown_83A6578); +dirn_to_anim(GetAcroWheelieJumpDirectionMovementAction, gUnknown_83A657D); +dirn_to_anim(GetAcroWheelieInPlaceDirectionMovementAction, gUnknown_83A6582); +dirn_to_anim(GetAcroPopWheelieMoveDirectionMovementAction, gUnknown_83A6587); +dirn_to_anim(GetAcroWheelieMoveDirectionMovementAction, gUnknown_83A658C); u8 GetOppositeDirection(u8 direction) { diff --git a/src/field_player_avatar.c b/src/field_player_avatar.c index 61d6f930f..ae0ee6942 100644 --- a/src/field_player_avatar.c +++ b/src/field_player_avatar.c @@ -5,9 +5,11 @@ #include "event_object_movement.h" #include "fieldmap.h" #include "field_control_avatar.h" +#include "field_effect_helpers.h" #include "field_player_avatar.h" #include "metatile_behavior.h" #include "overworld.h" +#include "party_menu.h" #include "quest_log.h" #include "quest_log_player.h" #include "constants/event_object_movement.h" @@ -15,6 +17,8 @@ #include "constants/songs.h" #include "constants/flags.h" #include "constants/metatile_behaviors.h" +#include "constants/species.h" +#include "constants/moves.h" EWRAM_DATA struct ObjectEvent * gUnknown_2036E30 = NULL; EWRAM_DATA bool8 gUnknown_2036E34 = FALSE; @@ -77,15 +81,17 @@ void PlayerGoSpeed2(u8 direction); void PlayerGoSpeed1(u8 direction); void PlayerGoSlow(u8 direction); void PlayerRideWaterCurrent(u8 direction); -void sub_805C438(u8 direction); -void CreateStopSurfingTask(u8 direction); -void StartStrengthAnim(u8 objectEventId, u8 direction); void PlayerNotOnBikeCollide(u8 direction); void PlayerFaceDirection(u8 direction); void PlayerTurnInPlace(u8 direction); void PlayerJumpLedge(u8 direction); +void PlayCollisionSoundIfNotFacingWarp(u8 direction); void PlayerGoSpin(u8 direction); void sub_805C2CC(u8 metatileBehavior); +bool8 MetatileAtCoordsIsWaterTile(s16 x, s16 y); +bool8 player_should_look_direction_be_enforced_upon_movement(void); +void CreateStopSurfingTask(u8 direction); +void StartStrengthAnim(u8 objectEventId, u8 direction); void sub_805CC40(struct ObjectEvent * playerObjEvent); void DoPlayerMatJump(void); void DoPlayerMatSpin(void); @@ -840,13 +846,13 @@ void PlayerRunSlow(u8 direction) void PlayerOnBikeCollide(u8 direction) { - sub_805C438(direction); + PlayCollisionSoundIfNotFacingWarp(direction); PlayerSetAnimId(GetWalkInPlaceNormalMovementAction(direction), 2); } void PlayerNotOnBikeCollide(u8 direction) { - sub_805C438(direction); + PlayCollisionSoundIfNotFacingWarp(direction); PlayerSetAnimId(GetStepInPlaceDelay32AnimId(direction), 2); } @@ -864,3 +870,421 @@ void PlayerTurnInPlace(u8 direction) { PlayerSetAnimId(GetWalkInPlaceSlowMovementAction(direction), 1); } + +void PlayerJumpLedge(u8 direction) +{ + PlaySE(SE_DANSA); + PlayerSetAnimId(GetJump2MovementAction(direction), 8); +} + +void sub_805C260(void) +{ + PlayerSetAnimId(MOVEMENT_ACTION_0x9F, 0); +} + +void sub_805C270(void) +{ + if (gPlayerAvatar.tileTransitionState == T_TILE_CENTER || gPlayerAvatar.tileTransitionState == T_NOT_MOVING) + { + if (player_should_look_direction_be_enforced_upon_movement()) + PlayerForceSetHeldMovement(GetFaceDirectionMovementAction(gObjectEvents[gPlayerAvatar.objectEventId].facingDirection)); + } +} + +void PlayerGoSpin(u8 direction) +{ + PlayerSetAnimId(sub_80640E4(direction), 3); +} + +void sub_805C2CC(u8 metatileBehavior) +{ + int i; + + for (i = 0; sForcedMovementFuncs[i].unk0 != NULL; i++) + { + if (sForcedMovementFuncs[i].unk0(metatileBehavior)) + sForcedMovementFuncs[i].unk4(); + } +} + +void PlayerIdleWheelie(u8 direction) +{ + PlayerSetAnimId(GetAcroWheelieFaceDirectionMovementAction(direction), 1); +} + +void PlayerStartWheelie(u8 direction) +{ + PlayerSetAnimId(GetAcroPopWheelieFaceDirectionMovementAction(direction), 1); +} + +void PlayerEndWheelie(u8 direction) +{ + PlayerSetAnimId(GetAcroEndWheelieFaceDirectionMovementAction(direction), 1); +} + +void PlayerStandingHoppingWheelie(u8 direction) +{ + PlaySE(SE_JITE_PYOKO); + PlayerSetAnimId(GetAcroWheelieHopFaceDirectionMovementAction(direction), 1); +} + +void PlayerMovingHoppingWheelie(u8 direction) +{ + PlaySE(SE_JITE_PYOKO); + PlayerSetAnimId(GetAcroWheelieHopDirectionMovementAction(direction), 2); +} + +void PlayerLedgeHoppingWheelie(u8 direction) +{ + PlaySE(SE_JITE_PYOKO); + PlayerSetAnimId(GetAcroWheelieJumpDirectionMovementAction(direction), 8); +} + +void PlayerAcroTurnJump(u8 direction) +{ + PlaySE(SE_JITE_PYOKO); + PlayerSetAnimId(GetJumpInPlaceTurnAroundMovementAction(direction), 1); +} + +void PlayerAcroWheelieCollide(u8 direction) +{ + PlaySE(SE_WALL_HIT); + PlayerSetAnimId(GetAcroWheelieInPlaceDirectionMovementAction(direction), 2); +} + +void sub_805C408(u8 direction) +{ + PlayerSetAnimId(GetAcroPopWheelieMoveDirectionMovementAction(direction), 2); +} + +void sub_805C420(u8 direction) +{ + PlayerSetAnimId(GetAcroWheelieMoveDirectionMovementAction(direction), 2); +} + +bool8 (*const sArrowWarpMetatileBehaviorChecks[])(u8) = { + MetatileBehavior_IsSouthArrowWarp, + MetatileBehavior_IsNorthArrowWarp, + MetatileBehavior_IsWestArrowWarp, + MetatileBehavior_IsEastArrowWarp +}; + +void PlayCollisionSoundIfNotFacingWarp(u8 direction) +{ + s16 x, y; + u8 metatileBehavior = gObjectEvents[gPlayerAvatar.objectEventId].currentMetatileBehavior; + + if (!sArrowWarpMetatileBehaviorChecks[direction - 1](metatileBehavior)) + { + if (direction == DIR_WEST) + { + if (MetatileBehavior_IsUnknownWarp6D(metatileBehavior) || MetatileBehavior_IsUnknownWarp6F(metatileBehavior)) + return; + } + if (direction == DIR_EAST) + { + if (MetatileBehavior_IsUnknownWarp6C(metatileBehavior) || MetatileBehavior_IsUnknownWarp6E(metatileBehavior)) + return; + } + if (direction == DIR_NORTH) + { + PlayerGetDestCoords(&x, &y); + MoveCoords(DIR_NORTH, &x, &y); + metatileBehavior = MapGridGetMetatileBehaviorAt(x, y); + if (MetatileBehavior_IsWarpDoor(metatileBehavior)) + return; + } + PlaySE(SE_WALL_HIT); + } +} + +void GetXYCoordsOneStepInFrontOfPlayer(s16 *x, s16 *y) +{ + *x = gObjectEvents[gPlayerAvatar.objectEventId].currentCoords.x; + *y = gObjectEvents[gPlayerAvatar.objectEventId].currentCoords.y; + MoveCoords(GetPlayerFacingDirection(), x, y); +} + +void PlayerGetDestCoords(s16 *x, s16 *y) +{ + *x = gObjectEvents[gPlayerAvatar.objectEventId].currentCoords.x; + *y = gObjectEvents[gPlayerAvatar.objectEventId].currentCoords.y; +} + +u8 player_get_pos_including_state_based_drift(s16 *x, s16 *y) +{ + struct ObjectEvent *object = &gObjectEvents[gPlayerAvatar.objectEventId]; + + if (object->heldMovementActive && !object->heldMovementFinished && !gSprites[object->spriteId].data[2]) + { + *x = object->currentCoords.x; + *y = object->currentCoords.y; + + switch (object->movementActionId) + { + case MOVEMENT_ACTION_WALK_NORMAL_DOWN: + case MOVEMENT_ACTION_PLAYER_RUN_DOWN: + (*y)++; + return TRUE; + case MOVEMENT_ACTION_WALK_NORMAL_UP: + case MOVEMENT_ACTION_PLAYER_RUN_UP: + (*y)--; + return TRUE; + case MOVEMENT_ACTION_WALK_NORMAL_LEFT: + case MOVEMENT_ACTION_PLAYER_RUN_LEFT: + (*x)--; + return TRUE; + case MOVEMENT_ACTION_WALK_NORMAL_RIGHT: + case MOVEMENT_ACTION_PLAYER_RUN_RIGHT: + (*x)++; + return TRUE; + } + } + + *x = -1; + *y = -1; + return FALSE; +} + +u8 GetPlayerFacingDirection(void) +{ + return gObjectEvents[gPlayerAvatar.objectEventId].facingDirection; +} + +u8 GetPlayerMovementDirection(void) +{ + return gObjectEvents[gPlayerAvatar.objectEventId].movementDirection; +} + +u8 PlayerGetZCoord(void) +{ + return gObjectEvents[gPlayerAvatar.objectEventId].previousElevation; +} + +void MovePlayerToMapCoords(s16 x, s16 y) +{ + MoveObjectEventToMapCoords(&gObjectEvents[gPlayerAvatar.objectEventId], x, y); +} + +u8 TestPlayerAvatarFlags(u8 bm) +{ + return gPlayerAvatar.flags & bm; +} + +u8 GetPlayerAvatarFlags(void) +{ + return gPlayerAvatar.flags; +} + +u8 GetPlayerAvatarObjectId(void) +{ + return gPlayerAvatar.spriteId; +} + +void sub_805C774(void) +{ + ForcedMovement_None(); +} + +void sub_805C780(void) +{ + struct ObjectEvent *playerObjEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; + + npc_clear_strange_bits(playerObjEvent); + SetObjectEventDirection(playerObjEvent, playerObjEvent->facingDirection); + if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_MACH_BIKE | PLAYER_AVATAR_FLAG_ACRO_BIKE)) + { + Bike_HandleBumpySlopeJump(); + Bike_UpdateBikeCounterSpeed(0); + } +} + +const u8 sPlayerAvatarGfxIds[][2] = { + {OBJ_EVENT_GFX_RED_NORMAL, OBJ_EVENT_GFX_GREEN_NORMAL}, + {OBJ_EVENT_GFX_RED_BIKE, OBJ_EVENT_GFX_GREEN_BIKE}, + {OBJ_EVENT_GFX_RED_SURF, OBJ_EVENT_GFX_GREEN_SURF}, + {OBJ_EVENT_GFX_RED_ITEM, OBJ_EVENT_GFX_GREEN_ITEM}, + {OBJ_EVENT_GFX_RED_FISH, OBJ_EVENT_GFX_GREEN_FISH}, + {OBJ_EVENT_GFX_RED_ITEM_COPY, OBJ_EVENT_GFX_GREEN_ITEM_COPY}, +}; + +const u8 sHoennLinkPartnerGfxIds[] = { + OBJ_EVENT_GFX_RS_BRENDAN, + OBJ_EVENT_GFX_RS_MAY +}; + +u8 GetRivalAvatarGraphicsIdByStateIdAndGender(u8 state, u8 gender) +{ + return GetPlayerAvatarGraphicsIdByStateIdAndGender(state, gender); +} + +u8 GetPlayerAvatarGraphicsIdByStateIdAndGender(u8 state, u8 gender) +{ + return sPlayerAvatarGfxIds[state][gender]; +} + +u8 GetHoennLinkPartnerGraphicsIdByGender(u8 gender) +{ + return sHoennLinkPartnerGfxIds[gender]; +} + +u8 GetPlayerAvatarGraphicsIdByStateId(u8 state) +{ + return GetPlayerAvatarGraphicsIdByStateIdAndGender(state, gPlayerAvatar.gender); +} + +u8 GetPlayerAvatarGenderByGraphicsId(u8 gfxId) +{ + switch (gfxId) + { + case OBJ_EVENT_GFX_GREEN_NORMAL: + case OBJ_EVENT_GFX_GREEN_BIKE: + case OBJ_EVENT_GFX_GREEN_SURF: + case OBJ_EVENT_GFX_GREEN_ITEM: + case OBJ_EVENT_GFX_GREEN_FISH: + return FEMALE; + default: + return MALE; + } +} + +bool8 PartyHasMonWithSurf(void) +{ + u8 i; + + if (!TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_SURFING)) + { + for (i = 0; i < PARTY_SIZE; i++) + { + if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) == SPECIES_NONE) + break; + if (MonKnowsMove(&gPlayerParty[i], MOVE_SURF)) + return TRUE; + } + } + return FALSE; +} + +bool8 IsPlayerSurfingNorth(void) +{ + if (GetPlayerMovementDirection() == DIR_NORTH && TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_SURFING)) + return TRUE; + else + return FALSE; +} + +bool8 IsPlayerFacingSurfableFishableWater(void) +{ + struct ObjectEvent *playerObjEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; + s16 x = playerObjEvent->currentCoords.x; + s16 y = playerObjEvent->currentCoords.y; + + MoveCoords(playerObjEvent->facingDirection, &x, &y); + if (GetCollisionAtCoords(playerObjEvent, x, y, playerObjEvent->facingDirection) == COLLISION_ELEVATION_MISMATCH + && PlayerGetZCoord() == 3 + && MetatileAtCoordsIsWaterTile(x, y) == TRUE) + return TRUE; + else + return FALSE; +} + +bool8 MetatileAtCoordsIsWaterTile(s16 x, s16 y) +{ + return TestMetatileAttributeBit(MapGridGetMetatileAttributeAt(x, y, METATILE_ATTRIBUTE_TERRAIN), TILE_TERRAIN_WATER); +} + +void ClearPlayerAvatarInfo(void) +{ + gPlayerAvatar = (struct PlayerAvatar){}; +} + +void SetPlayerAvatarStateMask(u8 flags) +{ + gPlayerAvatar.flags &= (PLAYER_AVATAR_FLAG_DASH | PLAYER_AVATAR_FLAG_MVMT_IS_FORCED | PLAYER_AVATAR_FLAG_FORCED_MVMT_DISABLED); + gPlayerAvatar.flags |= flags; +} + +const u8 gUnknown_835B882[][3][2] = { + // Male + { + {OBJ_EVENT_GFX_RED_NORMAL, PLAYER_AVATAR_FLAG_ON_FOOT}, + {OBJ_EVENT_GFX_RED_BIKE, PLAYER_AVATAR_FLAG_MACH_BIKE}, + {OBJ_EVENT_GFX_RED_SURF, PLAYER_AVATAR_FLAG_SURFING}, + }, + // Female + { + {OBJ_EVENT_GFX_GREEN_NORMAL, PLAYER_AVATAR_FLAG_ON_FOOT}, + {OBJ_EVENT_GFX_GREEN_BIKE, PLAYER_AVATAR_FLAG_MACH_BIKE}, + {OBJ_EVENT_GFX_GREEN_SURF, PLAYER_AVATAR_FLAG_SURFING}, + } +}; + +u8 GetPlayerAvatarStateTransitionByGraphicsId(u8 graphicsId, u8 gender) +{ + u8 i; + + for (i = 0; i < NELEMS(*gUnknown_835B882); i++) + { + if (gUnknown_835B882[gender][i][0] == graphicsId) + return gUnknown_835B882[gender][i][1]; + } + return 1; +} + +u8 GetPlayerAvatarGraphicsIdByCurrentState(void) +{ + u8 i; + u8 r5 = gPlayerAvatar.flags; + + for (i = 0; i < NELEMS(*gUnknown_835B882); i++) + { + if (gUnknown_835B882[gPlayerAvatar.gender][i][1] & r5) + return gUnknown_835B882[gPlayerAvatar.gender][i][0]; + } + return 0; +} + +const u8 gUnknown_835B88E[] = { + OBJ_EVENT_GFX_RED_VS_SEEKER, + OBJ_EVENT_GFX_GREEN_VS_SEEKER +}; + +void SetPlayerAvatarExtraStateTransition(u8 graphicsId, u8 b) +{ + u8 unk = GetPlayerAvatarStateTransitionByGraphicsId(graphicsId, gPlayerAvatar.gender); + + gPlayerAvatar.unk1 |= unk | b; + DoPlayerAvatarTransition(); +} + +void InitPlayerAvatar(s16 x, s16 y, u8 direction, u8 gender) +{ + struct ObjectEventTemplate playerObjEventTemplate; + u8 objectEventId; + struct ObjectEvent *objectEvent; + + playerObjEventTemplate.localId = OBJ_EVENT_ID_PLAYER; + playerObjEventTemplate.graphicsId = GetPlayerAvatarGraphicsIdByStateIdAndGender(PLAYER_AVATAR_STATE_NORMAL, gender); + playerObjEventTemplate.x = x - 7; + playerObjEventTemplate.y = y - 7; + playerObjEventTemplate.elevation = 0; + playerObjEventTemplate.movementType = MOVEMENT_TYPE_PLAYER; + playerObjEventTemplate.movementRangeX = 0; + playerObjEventTemplate.movementRangeY = 0; + playerObjEventTemplate.trainerType = 0; + playerObjEventTemplate.trainerRange_berryTreeId = 0; + playerObjEventTemplate.script = NULL; + playerObjEventTemplate.flagId = 0; + objectEventId = SpawnSpecialObjectEvent(&playerObjEventTemplate); + objectEvent = &gObjectEvents[objectEventId]; + objectEvent->isPlayer = 1; + objectEvent->warpArrowSpriteId = CreateWarpArrowSprite(); + ObjectEventTurn(objectEvent, direction); + ClearPlayerAvatarInfo(); + gPlayerAvatar.runningState = NOT_MOVING; + gPlayerAvatar.tileTransitionState = T_NOT_MOVING; + gPlayerAvatar.objectEventId = objectEventId; + gPlayerAvatar.spriteId = objectEvent->spriteId; + gPlayerAvatar.gender = gender; + SetPlayerAvatarStateMask(PLAYER_AVATAR_FLAG_FORCED_MVMT_DISABLED | PLAYER_AVATAR_FLAG_ON_FOOT); +} diff --git a/src/naming_screen.c b/src/naming_screen.c index b8b121535..1a41c8c0b 100644 --- a/src/naming_screen.c +++ b/src/naming_screen.c @@ -1300,7 +1300,7 @@ static void NamingScreen_CreatePlayerIcon(void) u8 rivalGfxId; u8 spriteId; - rivalGfxId = sub_805C7C8(0, sNamingScreenData->monSpecies); + rivalGfxId = GetRivalAvatarGraphicsIdByStateIdAndGender(0, sNamingScreenData->monSpecies); spriteId = AddPseudoObjectEvent(rivalGfxId, SpriteCallbackDummy, 0x38, 0x25, 0); gSprites[spriteId].oam.priority = 3; StartSpriteAnim(&gSprites[spriteId], 4); -- cgit v1.2.3 From f1841ef24d63aa2425d4316b9f49408d90c29bdb Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 25 Mar 2020 08:57:52 -0400 Subject: through sub_805D1A8 --- src/dynamic_placeholder_text_util.c | 4 +- src/field_effect.c | 2 +- src/field_fadetransition.c | 2 +- src/field_player_avatar.c | 318 +++++++++++++++++++++++++++++++++++- src/quest_log_player.c | 8 +- 5 files changed, 318 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/dynamic_placeholder_text_util.c b/src/dynamic_placeholder_text_util.c index 955c4866a..b0e689501 100644 --- a/src/dynamic_placeholder_text_util.c +++ b/src/dynamic_placeholder_text_util.c @@ -11,10 +11,10 @@ static const u8 sTextColorTable[] = [OBJ_EVENT_GFX_RED_NORMAL / 2] = 0x00, // OBJ_EVENT_GFX_RED_BIKE [OBJ_EVENT_GFX_RED_SURF / 2] = 0x00, // OBJ_EVENT_GFX_RED_ITEM [OBJ_EVENT_GFX_RED_FISH / 2] = 0x00, // OBJ_EVENT_GFX_RED_ITEM_COPY - [OBJ_EVENT_GFX_RED_VS_SEEKER / 2] = 0x10, // OBJ_EVENT_GFX_GREEN_NORMAL + [OBJ_EVENT_GFX_RED_FIELD_MOVE_BIKE / 2] = 0x10, // OBJ_EVENT_GFX_GREEN_NORMAL [OBJ_EVENT_GFX_GREEN_BIKE / 2] = 0x11, // OBJ_EVENT_GFX_GREEN_SURF [OBJ_EVENT_GFX_GREEN_ITEM / 2] = 0x11, // OBJ_EVENT_GFX_GREEN_FISH - [OBJ_EVENT_GFX_GREEN_ITEM_COPY / 2] = 0x11, // OBJ_EVENT_GFX_GREEN_VS_SEEKER + [OBJ_EVENT_GFX_GREEN_ITEM_COPY / 2] = 0x11, // OBJ_EVENT_GFX_GREEN_FIELD_MOVE_BIKE [OBJ_EVENT_GFX_RS_BRENDAN / 2] = 0x10, // OBJ_EVENT_GFX_RS_MAY [OBJ_EVENT_GFX_LITTLE_BOY / 2] = 0x10, // OBJ_EVENT_GFX_LITTLE_GIRL [OBJ_EVENT_GFX_YOUNGSTER / 2] = 0x00, // OBJ_EVENT_GFX_BOY diff --git a/src/field_effect.c b/src/field_effect.c index 082aee32d..b59ce5a6b 100644 --- a/src/field_effect.c +++ b/src/field_effect.c @@ -2888,7 +2888,7 @@ u8 FldEff_UseSurf(void) { u8 taskId = CreateTask(Task_FldEffUseSurf, 0xff); gTasks[taskId].data[15] = gFieldEffectArguments[0]; - sav1_reset_battle_music_maybe(); + Overworld_ClearSavedMusic(); if (sub_8056124(MUS_NAMINORI)) Overworld_ChangeMusicTo(MUS_NAMINORI); return FALSE; diff --git a/src/field_fadetransition.c b/src/field_fadetransition.c index c24d153ac..cde5f0e84 100644 --- a/src/field_fadetransition.c +++ b/src/field_fadetransition.c @@ -126,7 +126,7 @@ static void sub_807DC70(void) static void sub_807DCB0(bool8 arg) { - sub_805CB04(!arg); + SetPlayerInvisibility(!arg); } static void task0A_nop_for_a_while(u8 taskId) diff --git a/src/field_player_avatar.c b/src/field_player_avatar.c index ae0ee6942..e3035351b 100644 --- a/src/field_player_avatar.c +++ b/src/field_player_avatar.c @@ -5,6 +5,7 @@ #include "event_object_movement.h" #include "fieldmap.h" #include "field_control_avatar.h" +#include "field_effect.h" #include "field_effect_helpers.h" #include "field_player_avatar.h" #include "metatile_behavior.h" @@ -12,6 +13,7 @@ #include "party_menu.h" #include "quest_log.h" #include "quest_log_player.h" +#include "script.h" #include "constants/event_object_movement.h" #include "constants/event_objects.h" #include "constants/songs.h" @@ -89,12 +91,24 @@ void PlayCollisionSoundIfNotFacingWarp(u8 direction); void PlayerGoSpin(u8 direction); void sub_805C2CC(u8 metatileBehavior); bool8 MetatileAtCoordsIsWaterTile(s16 x, s16 y); -bool8 player_should_look_direction_be_enforced_upon_movement(void); -void CreateStopSurfingTask(u8 direction); -void StartStrengthAnim(u8 objectEventId, u8 direction); void sub_805CC40(struct ObjectEvent * playerObjEvent); +void StartStrengthAnim(u8 objectEventId, u8 direction); +void Task_BumpBoulder(u8 taskId); +bool8 sub_805CD64(struct Task * task, struct ObjectEvent * playerObj, struct ObjectEvent * boulderObj); +bool8 do_boulder_dust(struct Task * task, struct ObjectEvent * playerObj, struct ObjectEvent * boulderObj); +bool8 sub_805CE20(struct Task * task, struct ObjectEvent * playerObj, struct ObjectEvent * boulderObj); void DoPlayerMatJump(void); +void DoPlayerAvatarSecretBaseMatJump(u8 taskId); +bool8 PlayerAvatar_DoSecretBaseMatJump(struct Task * task, struct ObjectEvent * playerObj); void DoPlayerMatSpin(void); +void PlayerAvatar_DoSecretBaseMatSpin(u8 taskId); +bool8 PlayerAvatar_SecretBaseMatSpinStep0(struct Task * task, struct ObjectEvent * playerObj); +bool8 PlayerAvatar_SecretBaseMatSpinStep1(struct Task * task, struct ObjectEvent * playerObj); +bool8 PlayerAvatar_SecretBaseMatSpinStep2(struct Task * task, struct ObjectEvent * playerObj); +bool8 PlayerAvatar_SecretBaseMatSpinStep3(struct Task * task, struct ObjectEvent * playerObj); +void CreateStopSurfingTask(u8 direction); +void Task_StopSurfingInit(u8 taskId); +bool8 player_should_look_direction_be_enforced_upon_movement(void); void MovementType_Player(struct Sprite *sprite) { @@ -1244,11 +1258,6 @@ u8 GetPlayerAvatarGraphicsIdByCurrentState(void) return 0; } -const u8 gUnknown_835B88E[] = { - OBJ_EVENT_GFX_RED_VS_SEEKER, - OBJ_EVENT_GFX_GREEN_VS_SEEKER -}; - void SetPlayerAvatarExtraStateTransition(u8 graphicsId, u8 b) { u8 unk = GetPlayerAvatarStateTransitionByGraphicsId(graphicsId, gPlayerAvatar.gender); @@ -1288,3 +1297,296 @@ void InitPlayerAvatar(s16 x, s16 y, u8 direction, u8 gender) gPlayerAvatar.gender = gender; SetPlayerAvatarStateMask(PLAYER_AVATAR_FLAG_FORCED_MVMT_DISABLED | PLAYER_AVATAR_FLAG_ON_FOOT); } + +void SetPlayerInvisibility(bool8 invisible) +{ + gObjectEvents[gPlayerAvatar.objectEventId].invisible = invisible; + if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_SURFING)) + gSprites[gObjectEvents[gPlayerAvatar.objectEventId].fieldEffectSpriteId].invisible = invisible; +} + +void sub_805CB70(void) +{ + ObjectEventSetGraphicsId(&gObjectEvents[gPlayerAvatar.objectEventId], GetPlayerAvatarGraphicsIdByStateId(PLAYER_AVATAR_STATE_SURFING)); + StartSpriteAnim(&gSprites[gPlayerAvatar.spriteId], 0); +} + +const u8 gUnknown_835B88E[] = { + OBJ_EVENT_GFX_RED_FIELD_MOVE_BIKE, + OBJ_EVENT_GFX_GREEN_FIELD_MOVE_BIKE +}; + +u8 sub_805CBB8(void) +{ + if (gPlayerAvatar.flags & (PLAYER_AVATAR_FLAG_MACH_BIKE | PLAYER_AVATAR_FLAG_ACRO_BIKE)) + return gUnknown_835B88E[gPlayerAvatar.gender]; + else + return GetPlayerAvatarGraphicsIdByStateId(PLAYER_AVATAR_STATE_FIELD_MOVE); +} + +void sub_805CBE8(void) +{ + ObjectEventSetGraphicsId(&gObjectEvents[gPlayerAvatar.objectEventId], sub_805CBB8()); + StartSpriteAnim(&gSprites[gPlayerAvatar.spriteId], 0); +} + +void sub_805CC2C(void) +{ + sub_8150498(2); +} + +void nullsub_24(void) +{ + +} + +void nullsub_25(void) +{ + +} + +bool8 (*const sArrowWarpMetatileBehaviorChecks2[])(u8) = { + MetatileBehavior_IsSouthArrowWarp, + MetatileBehavior_IsNorthArrowWarp, + MetatileBehavior_IsWestArrowWarp, + MetatileBehavior_IsEastArrowWarp +}; + +void sub_805CC40(struct ObjectEvent *objectEvent) +{ + s16 x; + s16 y; + u8 direction; + u8 metatileBehavior = objectEvent->currentMetatileBehavior; + + for (x = 0, direction = DIR_SOUTH; x < 4; x++, direction++) + { + if (sArrowWarpMetatileBehaviorChecks2[x](metatileBehavior) && direction == objectEvent->movementDirection) + { + x = objectEvent->currentCoords.x; + y = objectEvent->currentCoords.y; + MoveCoords(direction, &x, &y); + ShowWarpArrowSprite(objectEvent->warpArrowSpriteId, direction, x, y); + return; + } + } + SetSpriteInvisible(objectEvent->warpArrowSpriteId); +} + +bool8 (*const gUnknown_835B8A0[])(struct Task * task, struct ObjectEvent * playerObj, struct ObjectEvent * boulderObj) = { + sub_805CD64, + do_boulder_dust, + sub_805CE20 +}; + +void StartStrengthAnim(u8 a, u8 b) +{ + u8 taskId = CreateTask(Task_BumpBoulder, 0xFF); + + gTasks[taskId].data[1] = a; + gTasks[taskId].data[2] = b; + Task_BumpBoulder(taskId); +} + +void Task_BumpBoulder(u8 taskId) +{ + while (gUnknown_835B8A0[gTasks[taskId].data[0]](&gTasks[taskId], + &gObjectEvents[gPlayerAvatar.objectEventId], + &gObjectEvents[gTasks[taskId].data[1]])) + ; +} + +bool8 sub_805CD64(struct Task *task, struct ObjectEvent *playerObject, struct ObjectEvent *strengthObject) +{ + ScriptContext2_Enable(); + gPlayerAvatar.preventStep = TRUE; + task->data[0]++; + return FALSE; +} + +bool8 do_boulder_dust(struct Task *task, struct ObjectEvent *playerObject, struct ObjectEvent *strengthObject) +{ + if (!ObjectEventIsMovementOverridden(playerObject) + && !ObjectEventIsMovementOverridden(strengthObject)) + { + ObjectEventClearHeldMovementIfFinished(playerObject); + ObjectEventClearHeldMovementIfFinished(strengthObject); + sub_805C06C(playerObject, GetWalkInPlaceNormalMovementAction((u8)task->data[2])); + sub_805C0A4(strengthObject, sub_8063F2C((u8)task->data[2])); + gFieldEffectArguments[0] = strengthObject->currentCoords.x; + gFieldEffectArguments[1] = strengthObject->currentCoords.y; + gFieldEffectArguments[2] = strengthObject->previousElevation; + gFieldEffectArguments[3] = gSprites[strengthObject->spriteId].oam.priority; + FieldEffectStart(FLDEFF_DUST); + PlaySE(SE_W070); + task->data[0]++; + } + return FALSE; +} + +bool8 sub_805CE20(struct Task *task, struct ObjectEvent *playerObject, struct ObjectEvent *strengthObject) +{ + if (ObjectEventCheckHeldMovementStatus(playerObject) + && ObjectEventCheckHeldMovementStatus(strengthObject)) + { + ObjectEventClearHeldMovementIfFinished(playerObject); + ObjectEventClearHeldMovementIfFinished(strengthObject); + sub_806DE28(strengthObject); + sub_806DE70(strengthObject->currentCoords.x, strengthObject->currentCoords.y); + gPlayerAvatar.preventStep = FALSE; + ScriptContext2_Disable(); + DestroyTask(FindTaskIdByFunc(Task_BumpBoulder)); + } + return FALSE; +} + +bool8 (*const sPlayerAvatarSecretBaseMatJump[])(struct Task *, struct ObjectEvent *) = { + PlayerAvatar_DoSecretBaseMatJump +}; + +void DoPlayerMatJump(void) +{ + DoPlayerAvatarSecretBaseMatJump(CreateTask(DoPlayerAvatarSecretBaseMatJump, 0xFF)); +} + +void DoPlayerAvatarSecretBaseMatJump(u8 taskId) +{ + while (sPlayerAvatarSecretBaseMatJump[gTasks[taskId].data[0]](&gTasks[taskId], &gObjectEvents[gPlayerAvatar.objectEventId])) + ; +} + +// because data[0] is used to call this, it can be inferred that there may have been multiple mat jump functions at one point, so the name for these groups of functions is appropriate in assuming the sole use of mat jump. +bool8 PlayerAvatar_DoSecretBaseMatJump(struct Task *task, struct ObjectEvent *objectEvent) +{ + gPlayerAvatar.preventStep = TRUE; + if (ObjectEventClearHeldMovementIfFinished(objectEvent)) + { + PlaySE(SE_DANSA); + sub_805C06C(objectEvent, GetJumpInPlaceMovementAction(objectEvent->facingDirection)); + task->data[1]++; + if (task->data[1] > 1) + { + gPlayerAvatar.preventStep = FALSE; + gPlayerAvatar.unk1 |= 0x20; + DestroyTask(FindTaskIdByFunc(DoPlayerAvatarSecretBaseMatJump)); + } + } + return FALSE; +} + +bool8 (*const sPlayerAvatarSecretBaseMatSpin[])(struct Task * task, struct ObjectEvent * playerObj) = { + PlayerAvatar_SecretBaseMatSpinStep0, + PlayerAvatar_SecretBaseMatSpinStep1, + PlayerAvatar_SecretBaseMatSpinStep2, + PlayerAvatar_SecretBaseMatSpinStep3, +}; + +void DoPlayerMatSpin(void) +{ + u8 taskId = CreateTask(PlayerAvatar_DoSecretBaseMatSpin, 0xFF); + + PlayerAvatar_DoSecretBaseMatSpin(taskId); +} + +void PlayerAvatar_DoSecretBaseMatSpin(u8 taskId) +{ + while (sPlayerAvatarSecretBaseMatSpin[gTasks[taskId].data[0]](&gTasks[taskId], &gObjectEvents[gPlayerAvatar.objectEventId])) + ; +} + +bool8 PlayerAvatar_SecretBaseMatSpinStep0(struct Task *task, struct ObjectEvent *objectEvent) +{ + task->data[0]++; + task->data[1] = objectEvent->movementDirection; + gPlayerAvatar.preventStep = TRUE; + ScriptContext2_Enable(); + PlaySE(SE_TK_WARPIN); + return TRUE; +} + +bool8 PlayerAvatar_SecretBaseMatSpinStep1(struct Task *task, struct ObjectEvent *objectEvent) +{ + u8 directions[] = {DIR_WEST, DIR_EAST, DIR_NORTH, DIR_SOUTH}; + + if (ObjectEventClearHeldMovementIfFinished(objectEvent)) + { + u8 direction; + + sub_805C06C(objectEvent, GetFaceDirectionMovementAction(direction = directions[objectEvent->movementDirection - 1])); + if (direction == (u8)task->data[1]) + task->data[2]++; + task->data[0]++; + if (task->data[2] > 3 && direction == GetOppositeDirection(task->data[1])) + task->data[0]++; + } + return FALSE; +} + +bool8 PlayerAvatar_SecretBaseMatSpinStep2(struct Task *task, struct ObjectEvent *objectEvent) +{ + const u8 actions[] = { + MOVEMENT_ACTION_DELAY_1, + MOVEMENT_ACTION_DELAY_1, + MOVEMENT_ACTION_DELAY_2, + MOVEMENT_ACTION_DELAY_4, + MOVEMENT_ACTION_DELAY_8, + }; + + if (ObjectEventClearHeldMovementIfFinished(objectEvent)) + { + sub_805C06C(objectEvent, actions[task->data[2]]); + task->data[0] = 1; + } + return FALSE; +} + +bool8 PlayerAvatar_SecretBaseMatSpinStep3(struct Task *task, struct ObjectEvent *objectEvent) +{ + if (ObjectEventClearHeldMovementIfFinished(objectEvent)) + { + sub_805C06C(objectEvent, sub_8063F2C(GetOppositeDirection(task->data[1]))); + ScriptContext2_Disable(); + gPlayerAvatar.preventStep = FALSE; + DestroyTask(FindTaskIdByFunc(PlayerAvatar_DoSecretBaseMatSpin)); + } + return FALSE; +} + +void CreateStopSurfingTask(u8 direction) +{ + u8 taskId; + + ScriptContext2_Enable(); + FreezeObjectEvents(); + Overworld_ClearSavedMusic(); + Overworld_ChangeMusicToDefault(); + gPlayerAvatar.flags &= ~PLAYER_AVATAR_FLAG_SURFING; + gPlayerAvatar.flags |= PLAYER_AVATAR_FLAG_ON_FOOT; + gPlayerAvatar.preventStep = TRUE; + taskId = CreateTask(Task_StopSurfingInit, 0xFF); + gTasks[taskId].data[0] = direction; + Task_StopSurfingInit(taskId); +} + +void CreateStopSurfingTask_NoMusicChange(u8 direction) +{ + u8 taskId; + + ScriptContext2_Enable(); + FreezeObjectEvents(); + gPlayerAvatar.flags &= ~PLAYER_AVATAR_FLAG_SURFING; + gPlayerAvatar.flags |= PLAYER_AVATAR_FLAG_ON_FOOT; + gPlayerAvatar.preventStep = TRUE; + taskId = CreateTask(Task_StopSurfingInit, 0xFF); + gTasks[taskId].data[0] = direction; + Task_StopSurfingInit(taskId); +} + +void sub_805D1A8(void) +{ + if (gUnknown_3005E88 != 1 && gUnknown_3005E88 != 3) + { + sub_811278C(gUnknown_835B820[DIR_NORTH], 16); + CreateStopSurfingTask(DIR_NORTH); + } +} diff --git a/src/quest_log_player.c b/src/quest_log_player.c index be40042b3..0819e8fc5 100644 --- a/src/quest_log_player.c +++ b/src/quest_log_player.c @@ -177,20 +177,20 @@ static void sub_81507BC(struct ObjectEvent * a0, u8 a1) static void sub_81507CC(void) { - sub_805D154(1); + CreateStopSurfingTask_NoMusicChange(1); } static void sub_81507D8(void) { - sub_805D154(2); + CreateStopSurfingTask_NoMusicChange(2); } static void sub_81507E4(void) { - sub_805D154(3); + CreateStopSurfingTask_NoMusicChange(3); } static void sub_81507F0(void) { - sub_805D154(4); + CreateStopSurfingTask_NoMusicChange(4); } -- cgit v1.2.3 From c032dc02319139771d8fed40c14297ee81b18b34 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 25 Mar 2020 17:37:07 -0400 Subject: through AlignFishingAnimationFrames --- src/event_object_movement.c | 2 + src/field_player_avatar.c | 401 +++++++++++++++++++++++++++++++++++++++++++- src/item_use.c | 2 +- src/quest_log_player.c | 6 +- src/strings.c | 6 +- 5 files changed, 409 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/event_object_movement.c b/src/event_object_movement.c index 7fde3ff21..c326b2d01 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -4084,6 +4084,8 @@ static void ClearObjectEventMovement(struct ObjectEvent *objectEvent, struct Spr sprite->data[1] = 0; } +// Off by one error + u8 GetFaceDirectionAnimNum(u8 direction) { return gFaceDirectionAnimNums[direction]; diff --git a/src/field_player_avatar.c b/src/field_player_avatar.c index e3035351b..0ee1f2fea 100644 --- a/src/field_player_avatar.c +++ b/src/field_player_avatar.c @@ -8,12 +8,17 @@ #include "field_effect.h" #include "field_effect_helpers.h" #include "field_player_avatar.h" +#include "help_system.h" #include "metatile_behavior.h" +#include "new_menu_helpers.h" #include "overworld.h" #include "party_menu.h" #include "quest_log.h" #include "quest_log_player.h" +#include "random.h" #include "script.h" +#include "strings.h" +#include "wild_encounter.h" #include "constants/event_object_movement.h" #include "constants/event_objects.h" #include "constants/songs.h" @@ -108,6 +113,24 @@ bool8 PlayerAvatar_SecretBaseMatSpinStep2(struct Task * task, struct ObjectEvent bool8 PlayerAvatar_SecretBaseMatSpinStep3(struct Task * task, struct ObjectEvent * playerObj); void CreateStopSurfingTask(u8 direction); void Task_StopSurfingInit(u8 taskId); +void Task_WaitStopSurfing(u8 taskId); +void Task_Fishing(u8 taskId); +bool8 Fishing1(struct Task * task); +bool8 Fishing2(struct Task * task); +bool8 Fishing3(struct Task * task); +bool8 Fishing4(struct Task * task); +bool8 Fishing5(struct Task * task); +bool8 Fishing6(struct Task * task); +bool8 Fishing7(struct Task * task); +bool8 Fishing8(struct Task * task); +bool8 Fishing9(struct Task * task); +bool8 Fishing10(struct Task * task); +bool8 Fishing11(struct Task * task); +bool8 Fishing12(struct Task * task); +bool8 Fishing13(struct Task * task); +bool8 Fishing14(struct Task * task); +bool8 Fishing15(struct Task * task); +bool8 Fishing16(struct Task * task); bool8 player_should_look_direction_be_enforced_upon_movement(void); void MovementType_Player(struct Sprite *sprite) @@ -1330,7 +1353,7 @@ void sub_805CBE8(void) StartSpriteAnim(&gSprites[gPlayerAvatar.spriteId], 0); } -void sub_805CC2C(void) +void sub_805CC2C(u8 direction) { sub_8150498(2); } @@ -1590,3 +1613,379 @@ void sub_805D1A8(void) CreateStopSurfingTask(DIR_NORTH); } } + +void Task_StopSurfingInit(u8 taskId) +{ + struct ObjectEvent *playerObjEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; + + if (ObjectEventIsMovementOverridden(playerObjEvent)) + { + if (!ObjectEventClearHeldMovementIfFinished(playerObjEvent)) + return; + } + sub_80DC44C(playerObjEvent->fieldEffectSpriteId, 2); + sub_805C06C(playerObjEvent, sub_80641EC((u8)gTasks[taskId].data[0])); + gTasks[taskId].func = Task_WaitStopSurfing; +} + +void Task_WaitStopSurfing(u8 taskId) +{ + struct ObjectEvent *playerObjEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; + + if (ObjectEventClearHeldMovementIfFinished(playerObjEvent)) + { + ObjectEventSetGraphicsId(playerObjEvent, GetPlayerAvatarGraphicsIdByStateId(PLAYER_AVATAR_STATE_NORMAL)); + sub_805C06C(playerObjEvent, GetFaceDirectionMovementAction(playerObjEvent->facingDirection)); + gPlayerAvatar.preventStep = FALSE; + ScriptContext2_Disable(); + UnfreezeObjectEvents(); + DestroySprite(&gSprites[playerObjEvent->fieldEffectSpriteId]); + DestroyTask(taskId); + SetHelpContextForMap(); + } +} + +bool8 (*const sFishingStateFuncs[])(struct Task *) = +{ + Fishing1, + Fishing2, + Fishing3, + Fishing4, + Fishing5, + Fishing6, + Fishing7, + Fishing8, + Fishing9, + Fishing10, + Fishing11, + Fishing12, + Fishing13, + Fishing14, + Fishing15, + Fishing16, +}; + +#define tStep data[0] +#define tFrameCounter data[1] +#define tNumDots data[2] +#define tDotsRequired data[3] +#define tRoundsPlayed data[12] +#define tMinRoundsRequired data[13] +#define tPlayerGfxId data[14] +#define tFishingRod data[15] + +#define FISHING_START_ROUND 3 +#define FISHING_GOT_BITE 6 +#define FISHING_ON_HOOK 9 +#define FISHING_NO_BITE 11 +#define FISHING_GOT_AWAY 12 +#define FISHING_SHOW_RESULT 13 + +void StartFishing(u8 rod) +{ + u8 taskId = CreateTask(Task_Fishing, 0xFF); + + gTasks[taskId].tFishingRod = rod; + Task_Fishing(taskId); + if (sub_8150474(2) == TRUE) + sub_8112C9C(); +} + + +void Task_Fishing(u8 taskId) +{ + while (sFishingStateFuncs[gTasks[taskId].tStep](&gTasks[taskId])) + ; +} + +bool8 Fishing1(struct Task *task) +{ + ScriptContext2_Enable(); + gPlayerAvatar.preventStep = TRUE; + task->tStep++; + return FALSE; +} + +bool8 Fishing2(struct Task *task) +{ + struct ObjectEvent *playerObjEvent; + const s16 arr1[] = {1, 1, 1}; + const s16 arr2[] = {1, 3, 6}; + + task->tRoundsPlayed = 0; + task->tMinRoundsRequired = arr1[task->tFishingRod] + (Random() % arr2[task->tFishingRod]); + task->tPlayerGfxId = gObjectEvents[gPlayerAvatar.objectEventId].graphicsId; + playerObjEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; + ObjectEventClearHeldMovementIfActive(playerObjEvent); + playerObjEvent->enableAnim = 1; + sub_805CC2C(playerObjEvent->facingDirection); + task->tStep++; + return FALSE; +} + +bool8 Fishing3(struct Task *task) +{ + AlignFishingAnimationFrames(&gSprites[gPlayerAvatar.spriteId]); + + // Wait one second + task->tFrameCounter++; + if (task->tFrameCounter >= 60) + task->tStep++; + return FALSE; +} + +bool8 Fishing4(struct Task *task) +{ + u32 randVal; + + sub_80F7768(0, TRUE); + task->tStep++; + task->tFrameCounter = 0; + task->tNumDots = 0; + randVal = Random(); + randVal %= 10; + task->tDotsRequired = randVal + 1; + if (task->tRoundsPlayed == 0) + task->tDotsRequired = randVal + 4; + if (task->tDotsRequired >= 10) + task->tDotsRequired = 10; + return TRUE; +} + +// Play a round of the dot game +bool8 Fishing5(struct Task *task) +{ + static const u8 dot[] = _("ยท"); + + AlignFishingAnimationFrames(&gSprites[gPlayerAvatar.spriteId]); + task->tFrameCounter++; + if (task->tFrameCounter >= 20) + { + task->tFrameCounter = 0; + if (task->tNumDots >= task->tDotsRequired) + { + task->tStep++; + if (task->tRoundsPlayed != 0) + task->tStep++; + task->tRoundsPlayed++; + } + else + { + AddTextPrinterParameterized(0, 2, dot, task->tNumDots * 12, 1, 0, NULL); + task->tNumDots++; + } + } + return FALSE; +} + +// Determine if fish bites +bool8 Fishing6(struct Task *task) +{ + bool8 bite; + + AlignFishingAnimationFrames(&gSprites[gPlayerAvatar.spriteId]); + task->tStep++; + bite = FALSE; + + if (!DoesCurrentMapHaveFishingMons() || Random() & 1) + { + task->tStep = FISHING_NO_BITE; + } + else + { + StartSpriteAnim(&gSprites[gPlayerAvatar.spriteId], sub_8063510(GetPlayerFacingDirection())); + } + return TRUE; +} + +// Oh! A Bite! +bool8 Fishing7(struct Task *task) +{ + task->tStep += 3; + return FALSE; +} + +// We have a bite. Now, wait for the player to press A, or the timer to expire. +bool8 Fishing8(struct Task *task) +{ + const s16 reelTimeouts[3] = {36, 33, 30}; + + AlignFishingAnimationFrames(&gSprites[gPlayerAvatar.spriteId]); + task->tFrameCounter++; + if (task->tFrameCounter >= reelTimeouts[task->tFishingRod]) + task->tStep = FISHING_GOT_AWAY; + else if (gMain.newKeys & A_BUTTON) + task->tStep++; + return FALSE; +} + +// Determine if we're going to play the dot game again +bool8 Fishing9(struct Task *task) +{ + const s16 arr[][2] = + { + {0, 0}, + {40, 10}, + {70, 30} + }; + + AlignFishingAnimationFrames(&gSprites[gPlayerAvatar.spriteId]); + task->tStep++; + if (task->tRoundsPlayed < task->tMinRoundsRequired) + { + task->tStep = FISHING_START_ROUND; + } + else if (task->tRoundsPlayed < 2) + { + // probability of having to play another round + s16 probability = Random() % 100; + + if (arr[task->tFishingRod][task->tRoundsPlayed] > probability) + task->tStep = FISHING_START_ROUND; + } + return FALSE; +} + +bool8 Fishing10(struct Task *task) +{ + AlignFishingAnimationFrames(&gSprites[gPlayerAvatar.spriteId]); + FillWindowPixelBuffer(0, PIXEL_FILL(1)); + AddTextPrinterParameterized2(0, 2, gText_PokemonOnHook, 1, 0, TEXT_COLOR_DARK_GREY, TEXT_COLOR_WHITE, TEXT_COLOR_LIGHT_GREY); + task->tStep++; + task->tFrameCounter = 0; + return FALSE; +} + +bool8 Fishing11(struct Task *task) +{ + if (task->tFrameCounter == 0) + AlignFishingAnimationFrames(&gSprites[gPlayerAvatar.spriteId]); + + RunTextPrinters(); + + if (task->tFrameCounter == 0) + { + if (!IsTextPrinterActive(0)) + { + struct ObjectEvent *playerObjEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; + + ObjectEventSetGraphicsId(playerObjEvent, task->tPlayerGfxId); + ObjectEventTurn(playerObjEvent, playerObjEvent->movementDirection); + if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_SURFING) + sub_80DC4A4(gObjectEvents[gPlayerAvatar.objectEventId].fieldEffectSpriteId, 0, 0); + gSprites[gPlayerAvatar.spriteId].pos2.x = 0; + gSprites[gPlayerAvatar.spriteId].pos2.y = 0; + ClearDialogWindowAndFrame(0, TRUE); + task->tFrameCounter++; + return FALSE; + } + } + + if (task->tFrameCounter != 0) + { + gPlayerAvatar.preventStep = FALSE; + ScriptContext2_Disable(); + FishingWildEncounter(task->tFishingRod); + DestroyTask(FindTaskIdByFunc(Task_Fishing)); + } + return FALSE; +} + +// Not even a nibble +bool8 Fishing12(struct Task *task) +{ + AlignFishingAnimationFrames(&gSprites[gPlayerAvatar.spriteId]); + StartSpriteAnim(&gSprites[gPlayerAvatar.spriteId], GetFishingBiteDirectionAnimNum(GetPlayerFacingDirection())); + FillWindowPixelBuffer(0, PIXEL_FILL(1)); + AddTextPrinterParameterized2(0, 2, gText_NotEvenANibble, 1, NULL, TEXT_COLOR_DARK_GREY, TEXT_COLOR_WHITE, TEXT_COLOR_LIGHT_GREY); + task->tStep = FISHING_SHOW_RESULT; + return TRUE; +} + +// It got away +bool8 Fishing13(struct Task *task) +{ + AlignFishingAnimationFrames(&gSprites[gPlayerAvatar.spriteId]); + StartSpriteAnim(&gSprites[gPlayerAvatar.spriteId], GetFishingBiteDirectionAnimNum(GetPlayerFacingDirection())); + AddTextPrinterParameterized2(0, 2, gText_ItGotAway, 1, NULL, TEXT_COLOR_DARK_GREY, TEXT_COLOR_WHITE, TEXT_COLOR_LIGHT_GREY); + task->tStep++; + return TRUE; +} + +// Wait one second +bool8 Fishing14(struct Task *task) +{ + AlignFishingAnimationFrames(&gSprites[gPlayerAvatar.spriteId]); + task->tStep++; + return FALSE; +} + +bool8 Fishing15(struct Task *task) +{ + AlignFishingAnimationFrames(&gSprites[gPlayerAvatar.spriteId]); + if (gSprites[gPlayerAvatar.spriteId].animEnded) + { + struct ObjectEvent *playerObjEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; + + ObjectEventSetGraphicsId(playerObjEvent, task->tPlayerGfxId); + ObjectEventTurn(playerObjEvent, playerObjEvent->movementDirection); + if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_SURFING) + sub_80DC4A4(gObjectEvents[gPlayerAvatar.objectEventId].fieldEffectSpriteId, 0, 0); + gSprites[gPlayerAvatar.spriteId].pos2.x = 0; + gSprites[gPlayerAvatar.spriteId].pos2.y = 0; + task->tStep++; + } + return FALSE; +} + +bool8 Fishing16(struct Task *task) +{ + RunTextPrinters(); + if (!IsTextPrinterActive(0)) + { + gPlayerAvatar.preventStep = FALSE; + ScriptContext2_Disable(); + UnfreezeObjectEvents(); + ClearDialogWindowAndFrame(0, TRUE); + DestroyTask(FindTaskIdByFunc(Task_Fishing)); + } + return FALSE; +} + +#undef tStep +#undef tFrameCounter +#undef tFishingRod + +void AlignFishingAnimationFrames(struct Sprite * playerSprite) +{ + u8 animCmdIndex; + u8 animType; + + AnimateSprite(playerSprite); + playerSprite->pos2.x = 0; + playerSprite->pos2.y = 0; + animCmdIndex = playerSprite->animCmdIndex; + if (playerSprite->anims[playerSprite->animNum][animCmdIndex].type == -1) + { + animCmdIndex--; + } + else + { + playerSprite->animDelayCounter++; + if (playerSprite->anims[playerSprite->animNum][animCmdIndex].type == -1) + animCmdIndex--; + } + animType = playerSprite->anims[playerSprite->animNum][animCmdIndex].type; + if (animType == 1 || animType == 2 || animType == 3) + { + playerSprite->pos2.x = 8; + if (GetPlayerFacingDirection() == 3) + playerSprite->pos2.x = -8; + } + if (animType == 5) + playerSprite->pos2.y = -8; + if (animType == 10 || animType == 11) + playerSprite->pos2.y = 8; + if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_SURFING) + sub_80DC4A4(gObjectEvents[gPlayerAvatar.objectEventId].fieldEffectSpriteId, 1, playerSprite->pos2.y); +} diff --git a/src/item_use.c b/src/item_use.c index 0b74e0726..ea7005f4e 100644 --- a/src/item_use.c +++ b/src/item_use.c @@ -327,7 +327,7 @@ static bool8 ItemUseCheckFunc_Rod(void) static void ItemUseOnFieldCB_Rod(u8 taskId) { - sub_805D2C0(ItemId_GetSecondaryId(gSpecialVar_ItemId)); + StartFishing(ItemId_GetSecondaryId(gSpecialVar_ItemId)); DestroyTask(taskId); } diff --git a/src/quest_log_player.c b/src/quest_log_player.c index 0819e8fc5..9eb0fbeb8 100644 --- a/src/quest_log_player.c +++ b/src/quest_log_player.c @@ -39,7 +39,7 @@ void sub_8150454(u8 a0) gUnknown_8471EDC[a0](); } -bool8 sub_8150474(u8 a0) +bool32 sub_8150474(u8 a0) { if (gUnknown_3005E88 == 2) { @@ -107,7 +107,7 @@ static void sub_81505C4(u8 taskId) gTasks[taskId].data[1] = 0; break; case 1: - sub_805D9C4(sprite); + AlignFishingAnimationFrames(sprite); if (gTasks[taskId].data[1] < 60) gTasks[taskId].data[1]++; else @@ -118,7 +118,7 @@ static void sub_81505C4(u8 taskId) gTasks[taskId].data[0]++; break; case 3: - sub_805D9C4(sprite); + AlignFishingAnimationFrames(sprite); if (sprite->animEnded) { if (!(gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_SURFING)) diff --git a/src/strings.c b/src/strings.c index faf42c86a..547a36138 100644 --- a/src/strings.c +++ b/src/strings.c @@ -1056,9 +1056,9 @@ const u8 gText_BerryCrush2[] = _("BERRY CRUSH"); const u8 gText_PressingSpeedRankings[] = _("Pressing-Speed Rankings"); const u8 gText_Var1Players[] = _("{STR_VAR_1} PLAYERS"); ALIGNED(4) const u8 gText_Ghost[] = _("GHOST"); -const u8 gUnknown_841D14E[] = _("A POKรฉMON's on the hook!{PAUSE_UNTIL_PRESS}"); -const u8 gUnknown_841D169[] = _("Not even a nibbleโ€ฅ{PAUSE_UNTIL_PRESS}"); -const u8 gUnknown_841D17E[] = _("It got awayโ€ฅ{PAUSE_UNTIL_PRESS}"); +const u8 gText_PokemonOnHook[] = _("A POKรฉMON's on the hook!{PAUSE_UNTIL_PRESS}"); +const u8 gText_NotEvenANibble[] = _("Not even a nibbleโ€ฅ{PAUSE_UNTIL_PRESS}"); +const u8 gText_ItGotAway[] = _("It got awayโ€ฅ{PAUSE_UNTIL_PRESS}"); const u8 gUnknown_841D18D[] = _("ROOFTOP"); ALIGNED(4) const u8 gString_PokemonFireRed_Staff[] = _("Pokรฉmon FireRed Version\nStaff"); ALIGNED(4) const u8 gString_PokemonLeafGreen_Staff[] = _("Pokรฉmon LeafGreen Version\nStaff"); -- cgit v1.2.3 From 302c6bfe6b13a329cb2aa36913b07b86abcc3694 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 25 Mar 2020 18:00:26 -0400 Subject: finish field_player_avatar --- src/field_player_avatar.c | 163 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 161 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/field_player_avatar.c b/src/field_player_avatar.c index 0ee1f2fea..375123577 100644 --- a/src/field_player_avatar.c +++ b/src/field_player_avatar.c @@ -4,6 +4,7 @@ #include "event_data.h" #include "event_object_movement.h" #include "fieldmap.h" +#include "field_camera.h" #include "field_control_avatar.h" #include "field_effect.h" #include "field_effect_helpers.h" @@ -28,7 +29,7 @@ #include "constants/moves.h" EWRAM_DATA struct ObjectEvent * gUnknown_2036E30 = NULL; -EWRAM_DATA bool8 gUnknown_2036E34 = FALSE; +EWRAM_DATA u8 gUnknown_2036E34 = DIR_NONE; EWRAM_DATA struct ObjectEvent gObjectEvents[OBJECT_EVENTS_COUNT] = {}; EWRAM_DATA struct PlayerAvatar gPlayerAvatar = {}; @@ -131,7 +132,9 @@ bool8 Fishing13(struct Task * task); bool8 Fishing14(struct Task * task); bool8 Fishing15(struct Task * task); bool8 Fishing16(struct Task * task); -bool8 player_should_look_direction_be_enforced_upon_movement(void); +void sub_805DB04(u8 taskId); +void sub_805DC38(u8 taskId); +u8 sub_805DDC8(struct ObjectEvent * object, s16 *timer); void MovementType_Player(struct Sprite *sprite) { @@ -1989,3 +1992,159 @@ void AlignFishingAnimationFrames(struct Sprite * playerSprite) if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_SURFING) sub_80DC4A4(gObjectEvents[gPlayerAvatar.objectEventId].fieldEffectSpriteId, 1, playerSprite->pos2.y); } + +void sub_805DAB0(void) +{ + u8 taskId = CreateTask(sub_805DB04, 0); + sub_805DB04(taskId); +} + +bool32 sub_805DAD0(void) +{ + return FuncIsActiveTask(sub_805DB04); +} + +void sub_805DAE4(u8 direction) +{ + gUnknown_2036E34 = direction; +} + +u8 sub_805DAF0(void) +{ + if (gUnknown_2036E34 == DIR_NONE) + return DIR_SOUTH; + else + return gUnknown_2036E34; +} + +void sub_805DB04(u8 taskId) +{ + struct ObjectEvent *object = &gObjectEvents[gPlayerAvatar.objectEventId]; + struct Sprite *sprite = &gSprites[object->spriteId]; + s16 *data = gTasks[taskId].data; + + switch (data[0]) + { + case 0: + if (!ObjectEventClearHeldMovementIfFinished(object)) + { + return; + } + + sub_805DAE4(object->facingDirection); + data[1] = 0; + data[2] = 1; + data[3] = (u16)(sprite->pos1.y + sprite->pos2.y) * 16; + sprite->pos2.y = 0; + CameraObjectReset2(); + object->fixedPriority = TRUE; + sprite->oam.priority = 0; + sprite->subpriority = 0; + sprite->subspriteMode = SUBSPRITES_OFF; + data[0]++; + case 1: + sub_805DDC8(object, &data[1]); + data[3] -= data[2]; + data[2] += 3; + sprite->pos1.y = data[3] >> 4; + if (sprite->pos1.y + (s16)gTotalCameraPixelOffsetY < -32) + { + data[0]++; + } + break; + case 2: + DestroyTask(taskId); + break; + } +} + +void sub_805DC04(void) +{ + u8 taskId = CreateTask(sub_805DC38, 0); + sub_805DC38(taskId); +} + +bool32 sub_805DC24(void) +{ + return FuncIsActiveTask(sub_805DC38); +} + +const u8 gUnknown_835B92C[] = {DIR_SOUTH, DIR_WEST, DIR_EAST, DIR_NORTH, DIR_SOUTH}; + +void sub_805DC38(u8 taskId) +{ + struct ObjectEvent *object = &gObjectEvents[gPlayerAvatar.objectEventId]; + struct Sprite *sprite = &gSprites[object->spriteId]; + s16 *data = gTasks[taskId].data; + + switch (data[0]) + { + case 0: + data[5] = sub_805DAF0(); + ObjectEventForceSetHeldMovement(object, GetFaceDirectionMovementAction(gUnknown_835B92C[data[5]])); + data[1] = 0; + data[2] = 116; + data[4] = sprite->pos1.y; + data[6] = sprite->oam.priority; + data[7] = sprite->subpriority; + data[3] = -((u16)sprite->pos2.y + 32) * 16; + sprite->pos2.y = 0; + CameraObjectReset2(); + object->fixedPriority = TRUE; + sprite->oam.priority = 1; + sprite->subpriority = 0; + sprite->subspriteMode = SUBSPRITES_OFF; + data[0]++; + case 1: + sub_805DDC8(object, &data[1]); + data[3] += data[2]; + data[2] -= 3; + if (data[2] < 4) + { + data[2] = 4; + } + sprite->pos1.y = data[3] >> 4; + if (sprite->pos1.y >= data[4]) + { + sprite->pos1.y = data[4]; + data[8] = 0; + data[0]++; + } + break; + case 2: + sub_805DDC8(object, &data[1]); + data[8]++; + if (data[8] > 8) + { + data[0]++; + } + break; + case 3: + if (data[5] == sub_805DDC8(object, &data[1])) + { + object->fixedPriority = 0; + sprite->oam.priority = data[6]; + sprite->subpriority = data[7]; + CameraObjectReset1(); + DestroyTask(taskId); + } + break; + } +} + +u8 sub_805DDC8(struct ObjectEvent *object, s16 *a1) +{ + if (*a1 < 8 && ++(*a1) < 8) + { + return object->facingDirection; + } + + if (!ObjectEventCheckHeldMovementStatus(object)) + { + return object->facingDirection; + } + + ObjectEventForceSetHeldMovement(object, GetFaceDirectionMovementAction(gUnknown_835B92C[object->facingDirection])); + *a1 = 0; + return gUnknown_835B92C[object->facingDirection]; +} -- cgit v1.2.3 From 3a29f9be954b8846f32865be146aefaf1b9f5fda Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 25 Mar 2020 18:12:07 -0400 Subject: static syms in field_player_avatar --- src/field_player_avatar.c | 447 ++++++++++++++++++++++------------------------ 1 file changed, 218 insertions(+), 229 deletions(-) (limited to 'src') diff --git a/src/field_player_avatar.c b/src/field_player_avatar.c index 375123577..cced50f4b 100644 --- a/src/field_player_avatar.c +++ b/src/field_player_avatar.c @@ -28,120 +28,109 @@ #include "constants/species.h" #include "constants/moves.h" -EWRAM_DATA struct ObjectEvent * gUnknown_2036E30 = NULL; -EWRAM_DATA u8 gUnknown_2036E34 = DIR_NONE; +static EWRAM_DATA struct ObjectEvent * gUnknown_2036E30 = NULL; +static EWRAM_DATA u8 gUnknown_2036E34 = DIR_NONE; EWRAM_DATA struct ObjectEvent gObjectEvents[OBJECT_EVENTS_COUNT] = {}; EWRAM_DATA struct PlayerAvatar gPlayerAvatar = {}; -u8 ObjectEventCB2_NoMovement2(struct ObjectEvent * object, struct Sprite * sprite); -bool8 sub_805B528(void); -bool8 TryInterruptObjectEventSpecialAnim(struct ObjectEvent * playerObjEvent, u8 direction); -void npc_clear_strange_bits(struct ObjectEvent * playerObjEvent); -bool8 TryDoMetatileBehaviorForcedMovement(void); -void MovePlayerAvatarUsingKeypadInput(u8 direction, u16 newKeys, u16 heldKeys); -void PlayerAllowForcedMovementIfMovingSameDirection(void); -bool8 ForcedMovement_None(void); -bool8 ForcedMovement_Slip(void); -bool8 ForcedMovement_WalkSouth(void); -bool8 ForcedMovement_WalkNorth(void); -bool8 ForcedMovement_WalkWest(void); -bool8 ForcedMovement_WalkEast(void); -bool8 ForcedMovement_SpinRight(void); -bool8 ForcedMovement_SpinLeft(void); -bool8 ForcedMovement_SpinUp(void); -bool8 ForcedMovement_SpinDown(void); -void PlaySpinSound(void); -bool8 ForcedMovement_PushedSouthByCurrent(void); -bool8 ForcedMovement_PushedNorthByCurrent(void); -bool8 ForcedMovement_PushedWestByCurrent(void); -bool8 ForcedMovement_PushedEastByCurrent(void); -bool8 ForcedMovement_SlideSouth(void); -bool8 ForcedMovement_SlideNorth(void); -bool8 ForcedMovement_SlideWest(void); -bool8 ForcedMovement_SlideEast(void); -bool8 ForcedMovement_0xBB(void); -bool8 ForcedMovement_0xBC(void); -u8 CheckMovementInputNotOnBike(u8 direction); -void PlayerNotOnBikeNotMoving(u8 direction, u16 heldKeys); -void PlayerNotOnBikeTurningInPlace(u8 direction, u16 heldKeys); -void PlayerNotOnBikeMoving(u8 direction, u16 heldKeys); -bool32 PlayerIsMovingOnRockStairs(u8 direction); -u8 CheckForPlayerAvatarCollision(u8 direction); +static u8 ObjectEventCB2_NoMovement2(struct ObjectEvent * object, struct Sprite * sprite); +static bool8 sub_805B528(void); +static bool8 TryInterruptObjectEventSpecialAnim(struct ObjectEvent * playerObjEvent, u8 direction); +static void npc_clear_strange_bits(struct ObjectEvent * playerObjEvent); +static bool8 TryDoMetatileBehaviorForcedMovement(void); +static void MovePlayerAvatarUsingKeypadInput(u8 direction, u16 newKeys, u16 heldKeys); +static void PlayerAllowForcedMovementIfMovingSameDirection(void); +static bool8 ForcedMovement_None(void); +static bool8 ForcedMovement_Slip(void); +static bool8 ForcedMovement_WalkSouth(void); +static bool8 ForcedMovement_WalkNorth(void); +static bool8 ForcedMovement_WalkWest(void); +static bool8 ForcedMovement_WalkEast(void); +static bool8 ForcedMovement_SpinRight(void); +static bool8 ForcedMovement_SpinLeft(void); +static bool8 ForcedMovement_SpinUp(void); +static bool8 ForcedMovement_SpinDown(void); +static void PlaySpinSound(void); +static bool8 ForcedMovement_PushedSouthByCurrent(void); +static bool8 ForcedMovement_PushedNorthByCurrent(void); +static bool8 ForcedMovement_PushedWestByCurrent(void); +static bool8 ForcedMovement_PushedEastByCurrent(void); +static bool8 ForcedMovement_SlideSouth(void); +static bool8 ForcedMovement_SlideNorth(void); +static bool8 ForcedMovement_SlideWest(void); +static bool8 ForcedMovement_SlideEast(void); +static bool8 ForcedMovement_0xBB(void); +static bool8 ForcedMovement_0xBC(void); +static u8 CheckMovementInputNotOnBike(u8 direction); +static void PlayerNotOnBikeNotMoving(u8 direction, u16 heldKeys); +static void PlayerNotOnBikeTurningInPlace(u8 direction, u16 heldKeys); +static void PlayerNotOnBikeMoving(u8 direction, u16 heldKeys); +static u8 CheckForPlayerAvatarCollision(u8 direction); u8 CheckForObjectEventCollision(struct ObjectEvent * objectEvent, s16 x, s16 y, u8 direction, u8 metatileBehavior); -bool8 CanStopSurfing(s16 x, s16 y, u8 direction); -bool8 ShouldJumpLedge(s16 x, s16 y, u8 direction); -bool8 TryPushBoulder(s16 x, s16 y, u8 direction); -void CheckAcroBikeCollision(s16 x, s16 y, u8 metatileBehavior, u8 *collision); -void DoPlayerAvatarTransition(void); -void PlayerAvatarTransition_Dummy(struct ObjectEvent * playerObject); -void PlayerAvatarTransition_Normal(struct ObjectEvent * playerObject); -void PlayerAvatarTransition_Bike(struct ObjectEvent * playerObject); -void PlayerAvatarTransition_Surfing(struct ObjectEvent * playerObject); -void PlayerAvatarTransition_Underwater(struct ObjectEvent * playerObject); -void PlayerAvatarTransition_ReturnToField(struct ObjectEvent * playerObject); -bool8 PlayerIsAnimActive(void); -bool8 PlayerCheckIfAnimFinishedOrInactive(void); -bool8 player_is_anim_in_certain_ranges(void); -bool8 sub_805BF58(void); -void PlayerRun(u8 direction); -void PlayerRunSlow(u8 direction); -void PlayerGoSpeed2(u8 direction); -void PlayerGoSpeed1(u8 direction); -void PlayerGoSlow(u8 direction); -void PlayerRideWaterCurrent(u8 direction); -void PlayerNotOnBikeCollide(u8 direction); -void PlayerFaceDirection(u8 direction); -void PlayerTurnInPlace(u8 direction); -void PlayerJumpLedge(u8 direction); -void PlayCollisionSoundIfNotFacingWarp(u8 direction); -void PlayerGoSpin(u8 direction); -void sub_805C2CC(u8 metatileBehavior); -bool8 MetatileAtCoordsIsWaterTile(s16 x, s16 y); -void sub_805CC40(struct ObjectEvent * playerObjEvent); -void StartStrengthAnim(u8 objectEventId, u8 direction); -void Task_BumpBoulder(u8 taskId); -bool8 sub_805CD64(struct Task * task, struct ObjectEvent * playerObj, struct ObjectEvent * boulderObj); -bool8 do_boulder_dust(struct Task * task, struct ObjectEvent * playerObj, struct ObjectEvent * boulderObj); -bool8 sub_805CE20(struct Task * task, struct ObjectEvent * playerObj, struct ObjectEvent * boulderObj); -void DoPlayerMatJump(void); -void DoPlayerAvatarSecretBaseMatJump(u8 taskId); -bool8 PlayerAvatar_DoSecretBaseMatJump(struct Task * task, struct ObjectEvent * playerObj); -void DoPlayerMatSpin(void); -void PlayerAvatar_DoSecretBaseMatSpin(u8 taskId); -bool8 PlayerAvatar_SecretBaseMatSpinStep0(struct Task * task, struct ObjectEvent * playerObj); -bool8 PlayerAvatar_SecretBaseMatSpinStep1(struct Task * task, struct ObjectEvent * playerObj); -bool8 PlayerAvatar_SecretBaseMatSpinStep2(struct Task * task, struct ObjectEvent * playerObj); -bool8 PlayerAvatar_SecretBaseMatSpinStep3(struct Task * task, struct ObjectEvent * playerObj); -void CreateStopSurfingTask(u8 direction); -void Task_StopSurfingInit(u8 taskId); -void Task_WaitStopSurfing(u8 taskId); -void Task_Fishing(u8 taskId); -bool8 Fishing1(struct Task * task); -bool8 Fishing2(struct Task * task); -bool8 Fishing3(struct Task * task); -bool8 Fishing4(struct Task * task); -bool8 Fishing5(struct Task * task); -bool8 Fishing6(struct Task * task); -bool8 Fishing7(struct Task * task); -bool8 Fishing8(struct Task * task); -bool8 Fishing9(struct Task * task); -bool8 Fishing10(struct Task * task); -bool8 Fishing11(struct Task * task); -bool8 Fishing12(struct Task * task); -bool8 Fishing13(struct Task * task); -bool8 Fishing14(struct Task * task); -bool8 Fishing15(struct Task * task); -bool8 Fishing16(struct Task * task); -void sub_805DB04(u8 taskId); -void sub_805DC38(u8 taskId); -u8 sub_805DDC8(struct ObjectEvent * object, s16 *timer); +static bool8 CanStopSurfing(s16 x, s16 y, u8 direction); +static bool8 ShouldJumpLedge(s16 x, s16 y, u8 direction); +static bool8 TryPushBoulder(s16 x, s16 y, u8 direction); +static void CheckAcroBikeCollision(s16 x, s16 y, u8 metatileBehavior, u8 *collision); +static void DoPlayerAvatarTransition(void); +static void PlayerAvatarTransition_Dummy(struct ObjectEvent * playerObject); +static void PlayerAvatarTransition_Normal(struct ObjectEvent * playerObject); +static void PlayerAvatarTransition_Bike(struct ObjectEvent * playerObject); +static void PlayerAvatarTransition_Surfing(struct ObjectEvent * playerObject); +static void PlayerAvatarTransition_Underwater(struct ObjectEvent * playerObject); +static void PlayerAvatarTransition_ReturnToField(struct ObjectEvent * playerObject); +static bool8 PlayerIsAnimActive(void); +static bool8 PlayerCheckIfAnimFinishedOrInactive(void); +static bool8 player_is_anim_in_certain_ranges(void); +static bool8 sub_805BF58(void); +static void PlayCollisionSoundIfNotFacingWarp(u8 direction); +static void PlayerGoSpin(u8 direction); +static void sub_805C2CC(u8 metatileBehavior); +static bool8 MetatileAtCoordsIsWaterTile(s16 x, s16 y); +static void sub_805CC40(struct ObjectEvent * playerObjEvent); +static void StartStrengthAnim(u8 objectEventId, u8 direction); +static void Task_BumpBoulder(u8 taskId); +static bool8 sub_805CD64(struct Task * task, struct ObjectEvent * playerObj, struct ObjectEvent * boulderObj); +static bool8 do_boulder_dust(struct Task * task, struct ObjectEvent * playerObj, struct ObjectEvent * boulderObj); +static bool8 sub_805CE20(struct Task * task, struct ObjectEvent * playerObj, struct ObjectEvent * boulderObj); +static void DoPlayerMatJump(void); +static void DoPlayerAvatarSecretBaseMatJump(u8 taskId); +static bool8 PlayerAvatar_DoSecretBaseMatJump(struct Task * task, struct ObjectEvent * playerObj); +static void DoPlayerMatSpin(void); +static void PlayerAvatar_DoSecretBaseMatSpin(u8 taskId); +static bool8 PlayerAvatar_SecretBaseMatSpinStep0(struct Task * task, struct ObjectEvent * playerObj); +static bool8 PlayerAvatar_SecretBaseMatSpinStep1(struct Task * task, struct ObjectEvent * playerObj); +static bool8 PlayerAvatar_SecretBaseMatSpinStep2(struct Task * task, struct ObjectEvent * playerObj); +static bool8 PlayerAvatar_SecretBaseMatSpinStep3(struct Task * task, struct ObjectEvent * playerObj); +static void CreateStopSurfingTask(u8 direction); +static void Task_StopSurfingInit(u8 taskId); +static void Task_WaitStopSurfing(u8 taskId); +static void Task_Fishing(u8 taskId); +static bool8 Fishing1(struct Task * task); +static bool8 Fishing2(struct Task * task); +static bool8 Fishing3(struct Task * task); +static bool8 Fishing4(struct Task * task); +static bool8 Fishing5(struct Task * task); +static bool8 Fishing6(struct Task * task); +static bool8 Fishing7(struct Task * task); +static bool8 Fishing8(struct Task * task); +static bool8 Fishing9(struct Task * task); +static bool8 Fishing10(struct Task * task); +static bool8 Fishing11(struct Task * task); +static bool8 Fishing12(struct Task * task); +static bool8 Fishing13(struct Task * task); +static bool8 Fishing14(struct Task * task); +static bool8 Fishing15(struct Task * task); +static bool8 Fishing16(struct Task * task); +static void sub_805DB04(u8 taskId); +static void sub_805DC38(u8 taskId); +static u8 sub_805DDC8(struct ObjectEvent * object, s16 *timer); void MovementType_Player(struct Sprite *sprite) { UpdateObjectEventCurrentMovement(&gObjectEvents[sprite->data[0]], sprite, ObjectEventCB2_NoMovement2); } -u8 ObjectEventCB2_NoMovement2(struct ObjectEvent * object, struct Sprite * sprite) +static u8 ObjectEventCB2_NoMovement2(struct ObjectEvent * object, struct Sprite * sprite) { return 0; } @@ -166,7 +155,7 @@ void player_step(u8 direction, u16 newKeys, u16 heldKeys) } } -bool8 TryInterruptObjectEventSpecialAnim(struct ObjectEvent *playerObjEvent, u8 direction) +static bool8 TryInterruptObjectEventSpecialAnim(struct ObjectEvent *playerObjEvent, u8 direction) { if (ObjectEventIsMovementOverridden(playerObjEvent) @@ -188,7 +177,7 @@ bool8 TryInterruptObjectEventSpecialAnim(struct ObjectEvent *playerObjEvent, u8 return FALSE; } -void npc_clear_strange_bits(struct ObjectEvent *objEvent) +static void npc_clear_strange_bits(struct ObjectEvent *objEvent) { objEvent->inanimate = 0; objEvent->disableAnim = 0; @@ -196,7 +185,7 @@ void npc_clear_strange_bits(struct ObjectEvent *objEvent) gPlayerAvatar.flags &= ~PLAYER_AVATAR_FLAG_DASH; } -void MovePlayerAvatarUsingKeypadInput(u8 direction, u16 newKeys, u16 heldKeys) +static void MovePlayerAvatarUsingKeypadInput(u8 direction, u16 newKeys, u16 heldKeys) { if ((gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_MACH_BIKE) || (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_ACRO_BIKE)) @@ -205,13 +194,13 @@ void MovePlayerAvatarUsingKeypadInput(u8 direction, u16 newKeys, u16 heldKeys) MovePlayerNotOnBike(direction, heldKeys); } -void PlayerAllowForcedMovementIfMovingSameDirection(void) +static void PlayerAllowForcedMovementIfMovingSameDirection(void) { if (gPlayerAvatar.runningState == MOVING) gPlayerAvatar.flags &= ~PLAYER_AVATAR_FLAG_FORCED_MVMT_DISABLED; } -bool8 sub_805B528(void) +static bool8 sub_805B528(void) { if ((gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_MVMT_IS_FORCED) && MetatileBehavior_IsSpinTile(gPlayerAvatar.unk1C)) { @@ -234,7 +223,7 @@ bool8 sub_805B528(void) return FALSE; } -const struct { +static const struct { bool8 (*unk0)(u8 metatileBehavior); bool8 (*unk4)(void); } sForcedMovementFuncs[] = { @@ -262,7 +251,7 @@ const struct { {NULL, ForcedMovement_None}, }; -bool8 TryDoMetatileBehaviorForcedMovement(void) +static bool8 TryDoMetatileBehaviorForcedMovement(void) { int i; u8 behavior; @@ -287,7 +276,7 @@ bool8 TryDoMetatileBehaviorForcedMovement(void) } } -bool8 ForcedMovement_None(void) +static bool8 ForcedMovement_None(void) { if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_MVMT_IS_FORCED) { @@ -301,7 +290,7 @@ bool8 ForcedMovement_None(void) return FALSE; } -u8 DoForcedMovement(u8 direction, MovementAction movementAction) +static u8 DoForcedMovement(u8 direction, MovementAction movementAction) { struct PlayerAvatar *playerAvatar = &gPlayerAvatar; u8 collision = CheckForPlayerAvatarCollision(direction); @@ -331,7 +320,7 @@ u8 DoForcedMovement(u8 direction, MovementAction movementAction) } } -u8 DoForcedMovementInCurrentDirection(MovementAction movementAction) +static u8 DoForcedMovementInCurrentDirection(MovementAction movementAction) { struct ObjectEvent *playerObjEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; @@ -339,81 +328,81 @@ u8 DoForcedMovementInCurrentDirection(MovementAction movementAction) return DoForcedMovement(playerObjEvent->movementDirection, movementAction); } -bool8 ForcedMovement_Slip(void) +static bool8 ForcedMovement_Slip(void) { return DoForcedMovementInCurrentDirection(PlayerGoSpeed2); } -bool8 ForcedMovement_WalkSouth(void) +static bool8 ForcedMovement_WalkSouth(void) { return DoForcedMovement(DIR_SOUTH, PlayerGoSpeed1); } -bool8 ForcedMovement_WalkNorth(void) +static bool8 ForcedMovement_WalkNorth(void) { return DoForcedMovement(DIR_NORTH, PlayerGoSpeed1); } -bool8 ForcedMovement_WalkWest(void) +static bool8 ForcedMovement_WalkWest(void) { return DoForcedMovement(DIR_WEST, PlayerGoSpeed1); } -bool8 ForcedMovement_WalkEast(void) +static bool8 ForcedMovement_WalkEast(void) { return DoForcedMovement(DIR_EAST, PlayerGoSpeed1); } -bool8 ForcedMovement_SpinRight(void) +static bool8 ForcedMovement_SpinRight(void) { PlaySpinSound(); return DoForcedMovement(DIR_EAST, PlayerGoSpin); } -bool8 ForcedMovement_SpinLeft(void) +static bool8 ForcedMovement_SpinLeft(void) { PlaySpinSound(); return DoForcedMovement(DIR_WEST, PlayerGoSpin); } -bool8 ForcedMovement_SpinUp(void) +static bool8 ForcedMovement_SpinUp(void) { PlaySpinSound(); return DoForcedMovement(DIR_NORTH, PlayerGoSpin); } -bool8 ForcedMovement_SpinDown(void) +static bool8 ForcedMovement_SpinDown(void) { PlaySpinSound(); return DoForcedMovement(DIR_SOUTH, PlayerGoSpin); } -void PlaySpinSound(void) +static void PlaySpinSound(void) { PlaySE(SE_W013B); } -bool8 ForcedMovement_PushedSouthByCurrent(void) +static bool8 ForcedMovement_PushedSouthByCurrent(void) { return DoForcedMovement(DIR_SOUTH, PlayerRideWaterCurrent); } -bool8 ForcedMovement_PushedNorthByCurrent(void) +static bool8 ForcedMovement_PushedNorthByCurrent(void) { return DoForcedMovement(DIR_NORTH, PlayerRideWaterCurrent); } -bool8 ForcedMovement_PushedWestByCurrent(void) +static bool8 ForcedMovement_PushedWestByCurrent(void) { return DoForcedMovement(DIR_WEST, PlayerRideWaterCurrent); } -bool8 ForcedMovement_PushedEastByCurrent(void) +static bool8 ForcedMovement_PushedEastByCurrent(void) { return DoForcedMovement(DIR_EAST, PlayerRideWaterCurrent); } -u8 ForcedMovement_Slide(u8 direction, MovementAction movementAction) +static u8 ForcedMovement_Slide(u8 direction, MovementAction movementAction) { struct ObjectEvent *playerObjEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; @@ -422,39 +411,39 @@ u8 ForcedMovement_Slide(u8 direction, MovementAction movementAction) return DoForcedMovement(direction, movementAction); } -bool8 ForcedMovement_SlideSouth(void) +static bool8 ForcedMovement_SlideSouth(void) { return ForcedMovement_Slide(DIR_SOUTH, PlayerGoSpeed2); } -bool8 ForcedMovement_SlideNorth(void) +static bool8 ForcedMovement_SlideNorth(void) { return ForcedMovement_Slide(DIR_NORTH, PlayerGoSpeed2); } -bool8 ForcedMovement_SlideWest(void) +static bool8 ForcedMovement_SlideWest(void) { return ForcedMovement_Slide(DIR_WEST, PlayerGoSpeed2); } -bool8 ForcedMovement_SlideEast(void) +static bool8 ForcedMovement_SlideEast(void) { return ForcedMovement_Slide(DIR_EAST, PlayerGoSpeed2); } -bool8 ForcedMovement_0xBB(void) +static bool8 ForcedMovement_0xBB(void) { DoPlayerMatJump(); return TRUE; } -bool8 ForcedMovement_0xBC(void) +static bool8 ForcedMovement_0xBC(void) { DoPlayerMatSpin(); return TRUE; } -void (*const gUnknown_835B814[])(u8, u16) = { +static void (*const gUnknown_835B814[])(u8, u16) = { PlayerNotOnBikeNotMoving, PlayerNotOnBikeTurningInPlace, PlayerNotOnBikeMoving @@ -465,7 +454,7 @@ void MovePlayerNotOnBike(u8 direction, u16 heldKeys) gUnknown_835B814[CheckMovementInputNotOnBike(direction)](direction, heldKeys); } -u8 CheckMovementInputNotOnBike(u8 direction) +static u8 CheckMovementInputNotOnBike(u8 direction) { if (direction == DIR_NONE) { @@ -484,17 +473,17 @@ u8 CheckMovementInputNotOnBike(u8 direction) } } -void PlayerNotOnBikeNotMoving(u8 direction, u16 heldKeys) +static void PlayerNotOnBikeNotMoving(u8 direction, u16 heldKeys) { PlayerFaceDirection(GetPlayerFacingDirection()); } -void PlayerNotOnBikeTurningInPlace(u8 direction, u16 heldKeys) +static void PlayerNotOnBikeTurningInPlace(u8 direction, u16 heldKeys) { PlayerTurnInPlace(direction); } -void PlayerNotOnBikeMoving(u8 direction, u16 heldKeys) +static void PlayerNotOnBikeMoving(u8 direction, u16 heldKeys) { u8 collision = CheckForPlayerAvatarCollision(direction); @@ -561,7 +550,7 @@ bool32 PlayerIsMovingOnRockStairs(u8 direction) } } -u8 CheckForPlayerAvatarCollision(u8 direction) +static u8 CheckForPlayerAvatarCollision(u8 direction) { s16 x, y; struct ObjectEvent *playerObjEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; @@ -595,7 +584,7 @@ u8 CheckForObjectEventCollision(struct ObjectEvent *objectEvent, s16 x, s16 y, u return collision; } -const u8 gUnknown_835B820[] = { +static const u8 gUnknown_835B820[] = { MOVEMENT_ACTION_FACE_DOWN_FAST, MOVEMENT_ACTION_FACE_DOWN_FAST, MOVEMENT_ACTION_FACE_UP_FAST, @@ -603,7 +592,7 @@ const u8 gUnknown_835B820[] = { MOVEMENT_ACTION_FACE_RIGHT_FAST }; -bool8 CanStopSurfing(s16 x, s16 y, u8 direction) +static bool8 CanStopSurfing(s16 x, s16 y, u8 direction) { if ((gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_SURFING) && MapGridGetZCoordAt(x, y) == 3 @@ -619,7 +608,7 @@ bool8 CanStopSurfing(s16 x, s16 y, u8 direction) } } -bool8 ShouldJumpLedge(s16 x, s16 y, u8 z) +static bool8 ShouldJumpLedge(s16 x, s16 y, u8 z) { if (GetLedgeJumpDirection(x, y, z) != 0) return TRUE; @@ -627,7 +616,7 @@ bool8 ShouldJumpLedge(s16 x, s16 y, u8 z) return FALSE; } -bool8 TryPushBoulder(s16 x, s16 y, u8 direction) +static bool8 TryPushBoulder(s16 x, s16 y, u8 direction) { u8 objectEventId; u8 direction_ = direction; @@ -655,7 +644,7 @@ bool8 TryPushBoulder(s16 x, s16 y, u8 direction) } } -bool8 (*const gUnknown_835B828[])(u8) = { +static bool8 (*const gUnknown_835B828[])(u8) = { MetatileBehavior_IsBumpySlope, MetatileBehavior_IsIsolatedVerticalRail, MetatileBehavior_IsIsolatedHorizontalRail, @@ -663,7 +652,7 @@ bool8 (*const gUnknown_835B828[])(u8) = { MetatileBehavior_IsHorizontalRail }; -const u8 gUnknown_835B83C[] = { +static const u8 gUnknown_835B83C[] = { COLLISION_WHEELIE_HOP, COLLISION_ISOLATED_VERTICAL_RAIL, COLLISION_ISOLATED_HORIZONTAL_RAIL, @@ -671,7 +660,7 @@ const u8 gUnknown_835B83C[] = { COLLISION_HORIZONTAL_RAIL, }; -void CheckAcroBikeCollision(s16 x, s16 y, u8 metatileBehavior, u8 *collision) +static void CheckAcroBikeCollision(s16 x, s16 y, u8 metatileBehavior, u8 *collision) { u8 i; @@ -691,7 +680,7 @@ void SetPlayerAvatarTransitionFlags(bool16 flags) DoPlayerAvatarTransition(); } -void (*const gUnknown_835B844[])(struct ObjectEvent *) = { +static void (*const gUnknown_835B844[])(struct ObjectEvent *) = { PlayerAvatarTransition_Normal, PlayerAvatarTransition_Bike, PlayerAvatarTransition_Bike, @@ -702,7 +691,7 @@ void (*const gUnknown_835B844[])(struct ObjectEvent *) = { PlayerAvatarTransition_Dummy }; -void DoPlayerAvatarTransition(void) +static void DoPlayerAvatarTransition(void) { u8 i; u8 flags = gPlayerAvatar.unk1; @@ -718,36 +707,36 @@ void DoPlayerAvatarTransition(void) } } -void PlayerAvatarTransition_Dummy(struct ObjectEvent * playerObjEvent) +static void PlayerAvatarTransition_Dummy(struct ObjectEvent * playerObjEvent) { } -void PlayerAvatarTransition_Normal(struct ObjectEvent * playerObjEvent) +static void PlayerAvatarTransition_Normal(struct ObjectEvent * playerObjEvent) { sub_8150474(0); sub_8150498(0); } -void PlayerAvatarTransition_Bike(struct ObjectEvent * playerObjEvent) +static void PlayerAvatarTransition_Bike(struct ObjectEvent * playerObjEvent) { sub_8150474(1); sub_8150498(1); sub_80BD620(0, 0); } -void PlayerAvatarTransition_Surfing(struct ObjectEvent * playerObjEvent) +static void PlayerAvatarTransition_Surfing(struct ObjectEvent * playerObjEvent) { sub_8150474(3); sub_8150498(3); } -void PlayerAvatarTransition_Underwater(struct ObjectEvent * playerObjEvent) +static void PlayerAvatarTransition_Underwater(struct ObjectEvent * playerObjEvent) { } -void PlayerAvatarTransition_ReturnToField(struct ObjectEvent * playerObjEvent) +static void PlayerAvatarTransition_ReturnToField(struct ObjectEvent * playerObjEvent) { gPlayerAvatar.flags |= PLAYER_AVATAR_FLAG_FORCED_MVMT_DISABLED; } @@ -770,7 +759,7 @@ void sub_805BEB8(void) } } -bool8 player_is_anim_in_certain_ranges(void) +static bool8 player_is_anim_in_certain_ranges(void) { u8 movementActionId = gObjectEvents[gPlayerAvatar.objectEventId].movementActionId; @@ -784,7 +773,7 @@ bool8 player_is_anim_in_certain_ranges(void) return FALSE; } -bool8 sub_805BF58(void) +static bool8 sub_805BF58(void) { if (player_is_anim_in_certain_ranges() && gPlayerAvatar.runningState != TURN_DIRECTION) return TRUE; @@ -792,17 +781,17 @@ bool8 sub_805BF58(void) return FALSE; } -bool8 PlayerIsAnimActive(void) +static bool8 PlayerIsAnimActive(void) { return ObjectEventIsMovementOverridden(&gObjectEvents[gPlayerAvatar.objectEventId]); } -bool8 PlayerCheckIfAnimFinishedOrInactive(void) +static bool8 PlayerCheckIfAnimFinishedOrInactive(void) { return ObjectEventCheckHeldMovementStatus(&gObjectEvents[gPlayerAvatar.objectEventId]); } -void PlayerSetCopyableMovement(u8 a) +static void PlayerSetCopyableMovement(u8 a) { gObjectEvents[gPlayerAvatar.objectEventId].playerCopyableMovement = a; } @@ -812,12 +801,12 @@ u8 PlayerGetCopyableMovement(void) return gObjectEvents[gPlayerAvatar.objectEventId].playerCopyableMovement; } -void PlayerForceSetHeldMovement(u8 a) +static void PlayerForceSetHeldMovement(u8 a) { ObjectEventForceSetHeldMovement(&gObjectEvents[gPlayerAvatar.objectEventId], a); } -void PlayerSetAnimId(u8 movementActionId, u8 copyableMovement) +static void PlayerSetAnimId(u8 movementActionId, u8 copyableMovement) { if (!PlayerIsAnimActive()) { @@ -827,13 +816,13 @@ void PlayerSetAnimId(u8 movementActionId, u8 copyableMovement) } } -void sub_805C06C(struct ObjectEvent * objectEvent, u8 movementAction) +static void sub_805C06C(struct ObjectEvent * objectEvent, u8 movementAction) { if (!ObjectEventSetHeldMovement(&gObjectEvents[gPlayerAvatar.objectEventId], movementAction)) sub_81126AC(movementAction, 0); } -void sub_805C0A4(struct ObjectEvent * objectEvent, u8 movementAction) +static void sub_805C0A4(struct ObjectEvent * objectEvent, u8 movementAction) { if (!ObjectEventSetHeldMovement(objectEvent, movementAction)) sub_8112588(objectEvent->localId, objectEvent->mapNum, objectEvent->mapGroup, movementAction, 32); @@ -931,12 +920,12 @@ void sub_805C270(void) } } -void PlayerGoSpin(u8 direction) +static void PlayerGoSpin(u8 direction) { PlayerSetAnimId(sub_80640E4(direction), 3); } -void sub_805C2CC(u8 metatileBehavior) +static void sub_805C2CC(u8 metatileBehavior) { int i; @@ -947,69 +936,69 @@ void sub_805C2CC(u8 metatileBehavior) } } -void PlayerIdleWheelie(u8 direction) +static void PlayerIdleWheelie(u8 direction) { PlayerSetAnimId(GetAcroWheelieFaceDirectionMovementAction(direction), 1); } -void PlayerStartWheelie(u8 direction) +static void PlayerStartWheelie(u8 direction) { PlayerSetAnimId(GetAcroPopWheelieFaceDirectionMovementAction(direction), 1); } -void PlayerEndWheelie(u8 direction) +static void PlayerEndWheelie(u8 direction) { PlayerSetAnimId(GetAcroEndWheelieFaceDirectionMovementAction(direction), 1); } -void PlayerStandingHoppingWheelie(u8 direction) +static void PlayerStandingHoppingWheelie(u8 direction) { PlaySE(SE_JITE_PYOKO); PlayerSetAnimId(GetAcroWheelieHopFaceDirectionMovementAction(direction), 1); } -void PlayerMovingHoppingWheelie(u8 direction) +static void PlayerMovingHoppingWheelie(u8 direction) { PlaySE(SE_JITE_PYOKO); PlayerSetAnimId(GetAcroWheelieHopDirectionMovementAction(direction), 2); } -void PlayerLedgeHoppingWheelie(u8 direction) +static void PlayerLedgeHoppingWheelie(u8 direction) { PlaySE(SE_JITE_PYOKO); PlayerSetAnimId(GetAcroWheelieJumpDirectionMovementAction(direction), 8); } -void PlayerAcroTurnJump(u8 direction) +static void PlayerAcroTurnJump(u8 direction) { PlaySE(SE_JITE_PYOKO); PlayerSetAnimId(GetJumpInPlaceTurnAroundMovementAction(direction), 1); } -void PlayerAcroWheelieCollide(u8 direction) +static void PlayerAcroWheelieCollide(u8 direction) { PlaySE(SE_WALL_HIT); PlayerSetAnimId(GetAcroWheelieInPlaceDirectionMovementAction(direction), 2); } -void sub_805C408(u8 direction) +static void sub_805C408(u8 direction) { PlayerSetAnimId(GetAcroPopWheelieMoveDirectionMovementAction(direction), 2); } -void sub_805C420(u8 direction) +static void sub_805C420(u8 direction) { PlayerSetAnimId(GetAcroWheelieMoveDirectionMovementAction(direction), 2); } -bool8 (*const sArrowWarpMetatileBehaviorChecks[])(u8) = { +static bool8 (*const sArrowWarpMetatileBehaviorChecks[])(u8) = { MetatileBehavior_IsSouthArrowWarp, MetatileBehavior_IsNorthArrowWarp, MetatileBehavior_IsWestArrowWarp, MetatileBehavior_IsEastArrowWarp }; -void PlayCollisionSoundIfNotFacingWarp(u8 direction) +static void PlayCollisionSoundIfNotFacingWarp(u8 direction) { s16 x, y; u8 metatileBehavior = gObjectEvents[gPlayerAvatar.objectEventId].currentMetatileBehavior; @@ -1139,7 +1128,7 @@ void sub_805C780(void) } } -const u8 sPlayerAvatarGfxIds[][2] = { +static const u8 sPlayerAvatarGfxIds[][2] = { {OBJ_EVENT_GFX_RED_NORMAL, OBJ_EVENT_GFX_GREEN_NORMAL}, {OBJ_EVENT_GFX_RED_BIKE, OBJ_EVENT_GFX_GREEN_BIKE}, {OBJ_EVENT_GFX_RED_SURF, OBJ_EVENT_GFX_GREEN_SURF}, @@ -1148,7 +1137,7 @@ const u8 sPlayerAvatarGfxIds[][2] = { {OBJ_EVENT_GFX_RED_ITEM_COPY, OBJ_EVENT_GFX_GREEN_ITEM_COPY}, }; -const u8 sHoennLinkPartnerGfxIds[] = { +static const u8 sHoennLinkPartnerGfxIds[] = { OBJ_EVENT_GFX_RS_BRENDAN, OBJ_EVENT_GFX_RS_MAY }; @@ -1244,7 +1233,7 @@ void SetPlayerAvatarStateMask(u8 flags) gPlayerAvatar.flags |= flags; } -const u8 gUnknown_835B882[][3][2] = { +static const u8 gUnknown_835B882[][3][2] = { // Male { {OBJ_EVENT_GFX_RED_NORMAL, PLAYER_AVATAR_FLAG_ON_FOOT}, @@ -1337,7 +1326,7 @@ void sub_805CB70(void) StartSpriteAnim(&gSprites[gPlayerAvatar.spriteId], 0); } -const u8 gUnknown_835B88E[] = { +static const u8 gUnknown_835B88E[] = { OBJ_EVENT_GFX_RED_FIELD_MOVE_BIKE, OBJ_EVENT_GFX_GREEN_FIELD_MOVE_BIKE }; @@ -1366,19 +1355,19 @@ void nullsub_24(void) } -void nullsub_25(void) +static void nullsub_25(void) { } -bool8 (*const sArrowWarpMetatileBehaviorChecks2[])(u8) = { +static bool8 (*const sArrowWarpMetatileBehaviorChecks2[])(u8) = { MetatileBehavior_IsSouthArrowWarp, MetatileBehavior_IsNorthArrowWarp, MetatileBehavior_IsWestArrowWarp, MetatileBehavior_IsEastArrowWarp }; -void sub_805CC40(struct ObjectEvent *objectEvent) +static void sub_805CC40(struct ObjectEvent *objectEvent) { s16 x; s16 y; @@ -1399,13 +1388,13 @@ void sub_805CC40(struct ObjectEvent *objectEvent) SetSpriteInvisible(objectEvent->warpArrowSpriteId); } -bool8 (*const gUnknown_835B8A0[])(struct Task * task, struct ObjectEvent * playerObj, struct ObjectEvent * boulderObj) = { +static bool8 (*const gUnknown_835B8A0[])(struct Task * task, struct ObjectEvent * playerObj, struct ObjectEvent * boulderObj) = { sub_805CD64, do_boulder_dust, sub_805CE20 }; -void StartStrengthAnim(u8 a, u8 b) +static void StartStrengthAnim(u8 a, u8 b) { u8 taskId = CreateTask(Task_BumpBoulder, 0xFF); @@ -1414,7 +1403,7 @@ void StartStrengthAnim(u8 a, u8 b) Task_BumpBoulder(taskId); } -void Task_BumpBoulder(u8 taskId) +static void Task_BumpBoulder(u8 taskId) { while (gUnknown_835B8A0[gTasks[taskId].data[0]](&gTasks[taskId], &gObjectEvents[gPlayerAvatar.objectEventId], @@ -1422,7 +1411,7 @@ void Task_BumpBoulder(u8 taskId) ; } -bool8 sub_805CD64(struct Task *task, struct ObjectEvent *playerObject, struct ObjectEvent *strengthObject) +static bool8 sub_805CD64(struct Task *task, struct ObjectEvent *playerObject, struct ObjectEvent *strengthObject) { ScriptContext2_Enable(); gPlayerAvatar.preventStep = TRUE; @@ -1430,7 +1419,7 @@ bool8 sub_805CD64(struct Task *task, struct ObjectEvent *playerObject, struct Ob return FALSE; } -bool8 do_boulder_dust(struct Task *task, struct ObjectEvent *playerObject, struct ObjectEvent *strengthObject) +static bool8 do_boulder_dust(struct Task *task, struct ObjectEvent *playerObject, struct ObjectEvent *strengthObject) { if (!ObjectEventIsMovementOverridden(playerObject) && !ObjectEventIsMovementOverridden(strengthObject)) @@ -1450,7 +1439,7 @@ bool8 do_boulder_dust(struct Task *task, struct ObjectEvent *playerObject, struc return FALSE; } -bool8 sub_805CE20(struct Task *task, struct ObjectEvent *playerObject, struct ObjectEvent *strengthObject) +static bool8 sub_805CE20(struct Task *task, struct ObjectEvent *playerObject, struct ObjectEvent *strengthObject) { if (ObjectEventCheckHeldMovementStatus(playerObject) && ObjectEventCheckHeldMovementStatus(strengthObject)) @@ -1466,23 +1455,23 @@ bool8 sub_805CE20(struct Task *task, struct ObjectEvent *playerObject, struct Ob return FALSE; } -bool8 (*const sPlayerAvatarSecretBaseMatJump[])(struct Task *, struct ObjectEvent *) = { +static bool8 (*const sPlayerAvatarSecretBaseMatJump[])(struct Task *, struct ObjectEvent *) = { PlayerAvatar_DoSecretBaseMatJump }; -void DoPlayerMatJump(void) +static void DoPlayerMatJump(void) { DoPlayerAvatarSecretBaseMatJump(CreateTask(DoPlayerAvatarSecretBaseMatJump, 0xFF)); } -void DoPlayerAvatarSecretBaseMatJump(u8 taskId) +static void DoPlayerAvatarSecretBaseMatJump(u8 taskId) { while (sPlayerAvatarSecretBaseMatJump[gTasks[taskId].data[0]](&gTasks[taskId], &gObjectEvents[gPlayerAvatar.objectEventId])) ; } // because data[0] is used to call this, it can be inferred that there may have been multiple mat jump functions at one point, so the name for these groups of functions is appropriate in assuming the sole use of mat jump. -bool8 PlayerAvatar_DoSecretBaseMatJump(struct Task *task, struct ObjectEvent *objectEvent) +static bool8 PlayerAvatar_DoSecretBaseMatJump(struct Task *task, struct ObjectEvent *objectEvent) { gPlayerAvatar.preventStep = TRUE; if (ObjectEventClearHeldMovementIfFinished(objectEvent)) @@ -1500,27 +1489,27 @@ bool8 PlayerAvatar_DoSecretBaseMatJump(struct Task *task, struct ObjectEvent *ob return FALSE; } -bool8 (*const sPlayerAvatarSecretBaseMatSpin[])(struct Task * task, struct ObjectEvent * playerObj) = { +static bool8 (*const sPlayerAvatarSecretBaseMatSpin[])(struct Task * task, struct ObjectEvent * playerObj) = { PlayerAvatar_SecretBaseMatSpinStep0, PlayerAvatar_SecretBaseMatSpinStep1, PlayerAvatar_SecretBaseMatSpinStep2, PlayerAvatar_SecretBaseMatSpinStep3, }; -void DoPlayerMatSpin(void) +static void DoPlayerMatSpin(void) { u8 taskId = CreateTask(PlayerAvatar_DoSecretBaseMatSpin, 0xFF); PlayerAvatar_DoSecretBaseMatSpin(taskId); } -void PlayerAvatar_DoSecretBaseMatSpin(u8 taskId) +static void PlayerAvatar_DoSecretBaseMatSpin(u8 taskId) { while (sPlayerAvatarSecretBaseMatSpin[gTasks[taskId].data[0]](&gTasks[taskId], &gObjectEvents[gPlayerAvatar.objectEventId])) ; } -bool8 PlayerAvatar_SecretBaseMatSpinStep0(struct Task *task, struct ObjectEvent *objectEvent) +static bool8 PlayerAvatar_SecretBaseMatSpinStep0(struct Task *task, struct ObjectEvent *objectEvent) { task->data[0]++; task->data[1] = objectEvent->movementDirection; @@ -1530,7 +1519,7 @@ bool8 PlayerAvatar_SecretBaseMatSpinStep0(struct Task *task, struct ObjectEvent return TRUE; } -bool8 PlayerAvatar_SecretBaseMatSpinStep1(struct Task *task, struct ObjectEvent *objectEvent) +static bool8 PlayerAvatar_SecretBaseMatSpinStep1(struct Task *task, struct ObjectEvent *objectEvent) { u8 directions[] = {DIR_WEST, DIR_EAST, DIR_NORTH, DIR_SOUTH}; @@ -1548,7 +1537,7 @@ bool8 PlayerAvatar_SecretBaseMatSpinStep1(struct Task *task, struct ObjectEvent return FALSE; } -bool8 PlayerAvatar_SecretBaseMatSpinStep2(struct Task *task, struct ObjectEvent *objectEvent) +static bool8 PlayerAvatar_SecretBaseMatSpinStep2(struct Task *task, struct ObjectEvent *objectEvent) { const u8 actions[] = { MOVEMENT_ACTION_DELAY_1, @@ -1566,7 +1555,7 @@ bool8 PlayerAvatar_SecretBaseMatSpinStep2(struct Task *task, struct ObjectEvent return FALSE; } -bool8 PlayerAvatar_SecretBaseMatSpinStep3(struct Task *task, struct ObjectEvent *objectEvent) +static bool8 PlayerAvatar_SecretBaseMatSpinStep3(struct Task *task, struct ObjectEvent *objectEvent) { if (ObjectEventClearHeldMovementIfFinished(objectEvent)) { @@ -1578,7 +1567,7 @@ bool8 PlayerAvatar_SecretBaseMatSpinStep3(struct Task *task, struct ObjectEvent return FALSE; } -void CreateStopSurfingTask(u8 direction) +static void CreateStopSurfingTask(u8 direction) { u8 taskId; @@ -1617,7 +1606,7 @@ void sub_805D1A8(void) } } -void Task_StopSurfingInit(u8 taskId) +static void Task_StopSurfingInit(u8 taskId) { struct ObjectEvent *playerObjEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; @@ -1631,7 +1620,7 @@ void Task_StopSurfingInit(u8 taskId) gTasks[taskId].func = Task_WaitStopSurfing; } -void Task_WaitStopSurfing(u8 taskId) +static void Task_WaitStopSurfing(u8 taskId) { struct ObjectEvent *playerObjEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; @@ -1648,7 +1637,7 @@ void Task_WaitStopSurfing(u8 taskId) } } -bool8 (*const sFishingStateFuncs[])(struct Task *) = +static bool8 (*const sFishingStateFuncs[])(struct Task *) = { Fishing1, Fishing2, @@ -1695,13 +1684,13 @@ void StartFishing(u8 rod) } -void Task_Fishing(u8 taskId) +static void Task_Fishing(u8 taskId) { while (sFishingStateFuncs[gTasks[taskId].tStep](&gTasks[taskId])) ; } -bool8 Fishing1(struct Task *task) +static bool8 Fishing1(struct Task *task) { ScriptContext2_Enable(); gPlayerAvatar.preventStep = TRUE; @@ -1709,7 +1698,7 @@ bool8 Fishing1(struct Task *task) return FALSE; } -bool8 Fishing2(struct Task *task) +static bool8 Fishing2(struct Task *task) { struct ObjectEvent *playerObjEvent; const s16 arr1[] = {1, 1, 1}; @@ -1726,7 +1715,7 @@ bool8 Fishing2(struct Task *task) return FALSE; } -bool8 Fishing3(struct Task *task) +static bool8 Fishing3(struct Task *task) { AlignFishingAnimationFrames(&gSprites[gPlayerAvatar.spriteId]); @@ -1737,7 +1726,7 @@ bool8 Fishing3(struct Task *task) return FALSE; } -bool8 Fishing4(struct Task *task) +static bool8 Fishing4(struct Task *task) { u32 randVal; @@ -1756,7 +1745,7 @@ bool8 Fishing4(struct Task *task) } // Play a round of the dot game -bool8 Fishing5(struct Task *task) +static bool8 Fishing5(struct Task *task) { static const u8 dot[] = _("ยท"); @@ -1782,7 +1771,7 @@ bool8 Fishing5(struct Task *task) } // Determine if fish bites -bool8 Fishing6(struct Task *task) +static bool8 Fishing6(struct Task *task) { bool8 bite; @@ -1802,14 +1791,14 @@ bool8 Fishing6(struct Task *task) } // Oh! A Bite! -bool8 Fishing7(struct Task *task) +static bool8 Fishing7(struct Task *task) { task->tStep += 3; return FALSE; } // We have a bite. Now, wait for the player to press A, or the timer to expire. -bool8 Fishing8(struct Task *task) +static bool8 Fishing8(struct Task *task) { const s16 reelTimeouts[3] = {36, 33, 30}; @@ -1823,7 +1812,7 @@ bool8 Fishing8(struct Task *task) } // Determine if we're going to play the dot game again -bool8 Fishing9(struct Task *task) +static bool8 Fishing9(struct Task *task) { const s16 arr[][2] = { @@ -1849,7 +1838,7 @@ bool8 Fishing9(struct Task *task) return FALSE; } -bool8 Fishing10(struct Task *task) +static bool8 Fishing10(struct Task *task) { AlignFishingAnimationFrames(&gSprites[gPlayerAvatar.spriteId]); FillWindowPixelBuffer(0, PIXEL_FILL(1)); @@ -1859,7 +1848,7 @@ bool8 Fishing10(struct Task *task) return FALSE; } -bool8 Fishing11(struct Task *task) +static bool8 Fishing11(struct Task *task) { if (task->tFrameCounter == 0) AlignFishingAnimationFrames(&gSprites[gPlayerAvatar.spriteId]); @@ -1895,7 +1884,7 @@ bool8 Fishing11(struct Task *task) } // Not even a nibble -bool8 Fishing12(struct Task *task) +static bool8 Fishing12(struct Task *task) { AlignFishingAnimationFrames(&gSprites[gPlayerAvatar.spriteId]); StartSpriteAnim(&gSprites[gPlayerAvatar.spriteId], GetFishingBiteDirectionAnimNum(GetPlayerFacingDirection())); @@ -1906,7 +1895,7 @@ bool8 Fishing12(struct Task *task) } // It got away -bool8 Fishing13(struct Task *task) +static bool8 Fishing13(struct Task *task) { AlignFishingAnimationFrames(&gSprites[gPlayerAvatar.spriteId]); StartSpriteAnim(&gSprites[gPlayerAvatar.spriteId], GetFishingBiteDirectionAnimNum(GetPlayerFacingDirection())); @@ -1916,14 +1905,14 @@ bool8 Fishing13(struct Task *task) } // Wait one second -bool8 Fishing14(struct Task *task) +static bool8 Fishing14(struct Task *task) { AlignFishingAnimationFrames(&gSprites[gPlayerAvatar.spriteId]); task->tStep++; return FALSE; } -bool8 Fishing15(struct Task *task) +static bool8 Fishing15(struct Task *task) { AlignFishingAnimationFrames(&gSprites[gPlayerAvatar.spriteId]); if (gSprites[gPlayerAvatar.spriteId].animEnded) @@ -1941,7 +1930,7 @@ bool8 Fishing15(struct Task *task) return FALSE; } -bool8 Fishing16(struct Task *task) +static bool8 Fishing16(struct Task *task) { RunTextPrinters(); if (!IsTextPrinterActive(0)) @@ -2009,7 +1998,7 @@ void sub_805DAE4(u8 direction) gUnknown_2036E34 = direction; } -u8 sub_805DAF0(void) +static u8 sub_805DAF0(void) { if (gUnknown_2036E34 == DIR_NONE) return DIR_SOUTH; @@ -2017,7 +2006,7 @@ u8 sub_805DAF0(void) return gUnknown_2036E34; } -void sub_805DB04(u8 taskId) +static void sub_805DB04(u8 taskId) { struct ObjectEvent *object = &gObjectEvents[gPlayerAvatar.objectEventId]; struct Sprite *sprite = &gSprites[object->spriteId]; @@ -2069,9 +2058,9 @@ bool32 sub_805DC24(void) return FuncIsActiveTask(sub_805DC38); } -const u8 gUnknown_835B92C[] = {DIR_SOUTH, DIR_WEST, DIR_EAST, DIR_NORTH, DIR_SOUTH}; +static const u8 gUnknown_835B92C[] = {DIR_SOUTH, DIR_WEST, DIR_EAST, DIR_NORTH, DIR_SOUTH}; -void sub_805DC38(u8 taskId) +static void sub_805DC38(u8 taskId) { struct ObjectEvent *object = &gObjectEvents[gPlayerAvatar.objectEventId]; struct Sprite *sprite = &gSprites[object->spriteId]; @@ -2132,7 +2121,7 @@ void sub_805DC38(u8 taskId) } } -u8 sub_805DDC8(struct ObjectEvent *object, s16 *a1) +static u8 sub_805DDC8(struct ObjectEvent *object, s16 *a1) { if (*a1 < 8 && ++(*a1) < 8) { -- cgit v1.2.3 From adc7a0b65a16f8fcbbadd527980950dec351b9cd Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 25 Mar 2020 19:40:34 -0400 Subject: Document field teleport anim --- src/field_fadetransition.c | 76 +++++++++++------------ src/field_player_avatar.c | 146 ++++++++++++++++++++++++++------------------- src/field_screen_effect.c | 4 +- src/option_menu.c | 2 +- src/quest_log.c | 2 +- src/scrcmd.c | 2 +- src/seagallop.c | 2 +- 7 files changed, 129 insertions(+), 105 deletions(-) (limited to 'src') diff --git a/src/field_fadetransition.c b/src/field_fadetransition.c index cde5f0e84..03190c095 100644 --- a/src/field_fadetransition.c +++ b/src/field_fadetransition.c @@ -29,9 +29,9 @@ static void sub_807DF4C(u8 a0); static void sub_807DFBC(u8 taskId); static void task_map_chg_seq_0807E20C(u8 taskId); static void task_map_chg_seq_0807E2CC(u8 taskId); -static void sub_807E31C(u8 taskId); +static void Task_TeleportWarpIn(u8 taskId); static void sub_807E718(u8 taskId); -static void sub_807E784(u8 taskId); +static void Task_TeleportWarp(u8 taskId); static void sub_807E80C(u8 taskId); static void sub_807E980(u8 taskId); static void sub_807EB64(u16, s16*, s16*); @@ -131,7 +131,7 @@ static void sub_807DCB0(bool8 arg) static void task0A_nop_for_a_while(u8 taskId) { - if (sub_807E418() == TRUE) + if (FieldFadeTransitionBackgroundEffectIsFinished() == TRUE) DestroyTask(taskId); } @@ -145,7 +145,7 @@ void sub_807DCE4(void) static void task0A_asap_script_env_2_enable_and_set_ctx_running(u8 taskId) { - if (sub_807E418() == TRUE) + if (FieldFadeTransitionBackgroundEffectIsFinished() == TRUE) { DestroyTask(taskId); EnableBothScriptContexts(); @@ -184,7 +184,7 @@ static void task_mpl_807DD60(u8 taskId) } break; case 2: - if (sub_807E418() == TRUE) + if (FieldFadeTransitionBackgroundEffectIsFinished() == TRUE) { ScriptContext2_Disable(); DestroyTask(taskId); @@ -218,7 +218,7 @@ static void sub_807DDF0(u8 taskId) } break; case 2: - if (sub_807E418() == TRUE) + if (FieldFadeTransitionBackgroundEffectIsFinished() == TRUE) { sub_8009FE8(); ScriptContext2_Disable(); @@ -284,7 +284,7 @@ static void sub_807DF4C(bool8 a0) FadeInFromBlack(); } -void sub_807DF64(void) +void FieldCB_UnionRoomWarp(void) { Overworld_PlaySpecialMapMusic(); sub_8111CF0(); @@ -300,13 +300,13 @@ void sub_807DF7C(void) ScriptContext2_Enable(); } -static void sub_807DF94(void) +static void FieldCB_TeleportWarpIn(void) { Overworld_PlaySpecialMapMusic(); WarpFadeInScreen(); sub_8111CF0(); PlaySE(SE_TK_WARPOUT); - CreateTask(sub_807E31C, 10); + CreateTask(Task_TeleportWarpIn, 10); ScriptContext2_Enable(); } @@ -363,7 +363,7 @@ static void sub_807DFBC(u8 taskId) } break; case 9: - if (sub_807E418() && walkrun_is_standing_still() && !FieldIsDoorAnimationRunning() && !FuncIsActiveTask(Task_BarnDoorWipe)) + if (FieldFadeTransitionBackgroundEffectIsFinished() && walkrun_is_standing_still() && !FieldIsDoorAnimationRunning() && !FuncIsActiveTask(Task_BarnDoorWipe)) { ObjectEventClearHeldMovementIfFinished(&gObjectEvents[GetObjectEventIdByLocalIdAndMap(0xFF, 0, 0)]); task->data[0] = 4; @@ -371,7 +371,7 @@ static void sub_807DFBC(u8 taskId) break; // Legacy RS case 1: - if (sub_807E418()) + if (FieldFadeTransitionBackgroundEffectIsFinished()) { sub_807DCB0(TRUE); ObjectEventSetHeldMovement(&gObjectEvents[GetObjectEventIdByLocalIdAndMap(0xFF, 0, 0)], MOVEMENT_ACTION_WALK_NORMAL_DOWN); @@ -413,7 +413,7 @@ static void task_map_chg_seq_0807E20C(u8 taskId) task->data[0] = 1; break; case 1: - if (sub_807E418()) + if (FieldFadeTransitionBackgroundEffectIsFinished()) { sub_807DCB0(TRUE); ObjectEventSetHeldMovement(&gObjectEvents[GetObjectEventIdByLocalIdAndMap(0xFF, 0, 0)], GetWalkNormalMovementAction(GetPlayerFacingDirection())); @@ -444,7 +444,7 @@ static void task_map_chg_seq_0807E2CC(u8 taskId) gTasks[taskId].data[0]++; break; case 1: - if (sub_807E418()) + if (FieldFadeTransitionBackgroundEffectIsFinished()) { UnfreezeObjectEvents(); ScriptContext2_Disable(); @@ -454,18 +454,18 @@ static void task_map_chg_seq_0807E2CC(u8 taskId) } } -static void sub_807E31C(u8 taskId) +static void Task_TeleportWarpIn(u8 taskId) { switch (gTasks[taskId].data[0]) { case 0: FreezeObjectEvents(); ScriptContext2_Enable(); - sub_805DC04(); + StartTeleportInPlayerAnim(); gTasks[taskId].data[0]++; break; case 1: - if (sub_807E418() && sub_805DC24() != TRUE) + if (FieldFadeTransitionBackgroundEffectIsFinished() && WaitTeleportInPlayerAnim() != TRUE) { UnfreezeObjectEvents(); ScriptContext2_Disable(); @@ -477,7 +477,7 @@ static void sub_807E31C(u8 taskId) static void Task_WaitFadeAndCreateStartMenuTask(u8 taskId) { - if (sub_807E418() == TRUE) + if (FieldFadeTransitionBackgroundEffectIsFinished() == TRUE) { DestroyTask(taskId); CreateTask(Task_StartMenuHandleInput, 80); @@ -499,7 +499,7 @@ bool8 FieldCB2_ReturnToStartMenuInit(void) static void task_mpl_807E3C8(u8 taskId) { - if (sub_807E418() == TRUE) + if (FieldFadeTransitionBackgroundEffectIsFinished() == TRUE) { ScriptContext2_Disable(); DestroyTask(taskId); @@ -515,12 +515,12 @@ void sub_807E3EC(void) CreateTask(task_mpl_807E3C8, 10); } -static bool32 sub_807E40C(void) +static bool32 WaitWarpFadeOutScreen(void) { return gPaletteFade.active; } -bool32 sub_807E418(void) +bool32 FieldFadeTransitionBackgroundEffectIsFinished(void) { if (IsWeatherNotFadingIn() == TRUE && ForestMapPreviewScreenIsRunning()) return TRUE; @@ -535,7 +535,7 @@ void DoWarp(void) WarpFadeOutScreen(); PlayRainStoppingSoundEffect(); PlaySE(SE_KAIDAN); - gFieldCallback = sub_807DF64; + gFieldCallback = FieldCB_UnionRoomWarp; CreateTask(sub_807E718, 10); } @@ -545,7 +545,7 @@ void DoDiveWarp(void) TryFadeOutOldMapMusic(); WarpFadeOutScreen(); PlayRainStoppingSoundEffect(); - gFieldCallback = sub_807DF64; + gFieldCallback = FieldCB_UnionRoomWarp; CreateTask(sub_807E718, 10); } @@ -560,7 +560,7 @@ void sub_807E4A0(u16 metatileBehavior, u16 delay) void DoDoorWarp(void) { ScriptContext2_Enable(); - gFieldCallback = sub_807DF64; + gFieldCallback = FieldCB_UnionRoomWarp; CreateTask(sub_807E80C, 10); } @@ -568,14 +568,14 @@ void sub_807E500(void) { ScriptContext2_Enable(); CreateTask(sub_807E718, 10); - gFieldCallback = sub_807DF94; + gFieldCallback = FieldCB_TeleportWarpIn; } void DoUnionRoomWarp(void) { ScriptContext2_Enable(); - gFieldCallback = sub_807DF64; - CreateTask(sub_807E784, 10); + gFieldCallback = FieldCB_UnionRoomWarp; + CreateTask(Task_TeleportWarp, 10); } void DoFallWarp(void) @@ -606,8 +606,8 @@ void DoTeleportWarp(void) { ScriptContext2_Enable(); TryFadeOutOldMapMusic(); - CreateTask(sub_807E784, 10); - gFieldCallback = sub_807DF94; + CreateTask(Task_TeleportWarp, 10); + gFieldCallback = FieldCB_TeleportWarpIn; } void sub_807E5C4(void) @@ -628,7 +628,7 @@ static void sub_807E5EC(u8 taskId) task->data[0]++; break; case 1: - if (!sub_807E40C() && BGMusicStopped()) + if (!WaitWarpFadeOutScreen() && BGMusicStopped()) task->data[0]++; break; case 2: @@ -661,7 +661,7 @@ static void sub_807E678(u8 taskId) data[0]++; break; case 1: - if (!sub_807E40C() && BGMusicStopped()) + if (!WaitWarpFadeOutScreen() && BGMusicStopped()) { Link_TryStartSend5FFF(); data[0]++; @@ -694,7 +694,7 @@ static void sub_807E718(u8 taskId) task->data[0]++; break; case 1: - if (!sub_807E40C() && BGMusicStopped()) + if (!WaitWarpFadeOutScreen() && BGMusicStopped()) task->data[0]++; break; case 2: @@ -705,7 +705,7 @@ static void sub_807E718(u8 taskId) } } -static void sub_807E784(u8 taskId) +static void Task_TeleportWarp(u8 taskId) { struct Task *task = &gTasks[taskId]; switch (task->data[0]) @@ -714,18 +714,18 @@ static void sub_807E784(u8 taskId) FreezeObjectEvents(); ScriptContext2_Enable(); PlaySE(SE_TK_WARPIN); - sub_805DAB0(); + StartTeleportWarpOutPlayerAnim(); task->data[0]++; break; case 1: - if (!sub_805DAD0()) + if (!WaitTeleportWarpOutPlayerAnim()) { WarpFadeOutScreen(); task->data[0]++; } break; case 2: - if (!sub_807E40C() && BGMusicStopped()) + if (!WaitWarpFadeOutScreen() && BGMusicStopped()) task->data[0]++; break; case 3: @@ -829,11 +829,11 @@ static void sub_807E980(u8 taskId) break; case 3: sub_807EAC4(data[2], data[3], &data[4], &data[5], &data[6]); - if (!sub_807E40C() && BGMusicStopped()) + if (!WaitWarpFadeOutScreen() && BGMusicStopped()) data[0]++; break; default: - gFieldCallback = sub_807DF64; + gFieldCallback = FieldCB_UnionRoomWarp; WarpIntoMap(); SetMainCallback2(CB2_LoadMap); DestroyTask(taskId); @@ -898,7 +898,7 @@ static void sub_807EC34(u8 taskId) switch (data[0]) { default: - if (sub_807E418() == TRUE) + if (FieldFadeTransitionBackgroundEffectIsFinished() == TRUE) { CameraObjectReset1(); ScriptContext2_Disable(); diff --git a/src/field_player_avatar.c b/src/field_player_avatar.c index cced50f4b..4d474db2f 100644 --- a/src/field_player_avatar.c +++ b/src/field_player_avatar.c @@ -29,7 +29,7 @@ #include "constants/moves.h" static EWRAM_DATA struct ObjectEvent * gUnknown_2036E30 = NULL; -static EWRAM_DATA u8 gUnknown_2036E34 = DIR_NONE; +static EWRAM_DATA u8 sTeleportSavedFacingDirection = DIR_NONE; EWRAM_DATA struct ObjectEvent gObjectEvents[OBJECT_EVENTS_COUNT] = {}; EWRAM_DATA struct PlayerAvatar gPlayerAvatar = {}; @@ -121,9 +121,9 @@ static bool8 Fishing13(struct Task * task); static bool8 Fishing14(struct Task * task); static bool8 Fishing15(struct Task * task); static bool8 Fishing16(struct Task * task); -static void sub_805DB04(u8 taskId); -static void sub_805DC38(u8 taskId); -static u8 sub_805DDC8(struct ObjectEvent * object, s16 *timer); +static void Task_TeleportWarpOutPlayerAnim(u8 taskId); +static void Task_TeleportWarpInPlayerAnim(u8 taskId); +static u8 TeleportAnim_RotatePlayer(struct ObjectEvent * object, s16 *timer); void MovementType_Player(struct Sprite *sprite) { @@ -1982,37 +1982,54 @@ void AlignFishingAnimationFrames(struct Sprite * playerSprite) sub_80DC4A4(gObjectEvents[gPlayerAvatar.objectEventId].fieldEffectSpriteId, 1, playerSprite->pos2.y); } -void sub_805DAB0(void) +#define tState data[0] +#define tRotationTimer data[1] +#define tDeltaY data[2] +#define tYdeflection data[3] +#define tYpos data[4] +#define tFinalFacingDirection data[5] +#define tPriority data[6] +#define tSubpriority data[7] + +static const u8 sTeleportFacingDirectionSequence[] = { + [DIR_SOUTH] = DIR_WEST, + [DIR_WEST] = DIR_NORTH, + [DIR_NORTH] = DIR_EAST, + [DIR_EAST] = DIR_SOUTH, + [DIR_NONE] = DIR_SOUTH, +}; + +void StartTeleportWarpOutPlayerAnim(void) { - u8 taskId = CreateTask(sub_805DB04, 0); - sub_805DB04(taskId); + u8 taskId = CreateTask(Task_TeleportWarpOutPlayerAnim, 0); + Task_TeleportWarpOutPlayerAnim(taskId); } -bool32 sub_805DAD0(void) +bool32 WaitTeleportWarpOutPlayerAnim(void) { - return FuncIsActiveTask(sub_805DB04); + return FuncIsActiveTask(Task_TeleportWarpOutPlayerAnim); } -void sub_805DAE4(u8 direction) +void SavePlayerFacingDirectionForTeleport(u8 direction) { - gUnknown_2036E34 = direction; + sTeleportSavedFacingDirection = direction; } -static u8 sub_805DAF0(void) +static u8 GetTeleportSavedFacingDirection(void) { - if (gUnknown_2036E34 == DIR_NONE) + if (sTeleportSavedFacingDirection == DIR_NONE) return DIR_SOUTH; else - return gUnknown_2036E34; + return sTeleportSavedFacingDirection; } -static void sub_805DB04(u8 taskId) +static void Task_TeleportWarpOutPlayerAnim(u8 taskId) { struct ObjectEvent *object = &gObjectEvents[gPlayerAvatar.objectEventId]; struct Sprite *sprite = &gSprites[object->spriteId]; s16 *data = gTasks[taskId].data; - switch (data[0]) + switch (tState) { case 0: if (!ObjectEventClearHeldMovementIfFinished(object)) @@ -2020,25 +2037,25 @@ static void sub_805DB04(u8 taskId) return; } - sub_805DAE4(object->facingDirection); - data[1] = 0; - data[2] = 1; - data[3] = (u16)(sprite->pos1.y + sprite->pos2.y) * 16; + SavePlayerFacingDirectionForTeleport(object->facingDirection); + tRotationTimer = 0; + tDeltaY = 1; + tYdeflection = (u16)(sprite->pos1.y + sprite->pos2.y) * 16; sprite->pos2.y = 0; CameraObjectReset2(); object->fixedPriority = TRUE; sprite->oam.priority = 0; sprite->subpriority = 0; sprite->subspriteMode = SUBSPRITES_OFF; - data[0]++; + tState++; case 1: - sub_805DDC8(object, &data[1]); - data[3] -= data[2]; - data[2] += 3; - sprite->pos1.y = data[3] >> 4; + TeleportAnim_RotatePlayer(object, &tRotationTimer); + tYdeflection -= tDeltaY; + tDeltaY += 3; + sprite->pos1.y = tYdeflection >> 4; if (sprite->pos1.y + (s16)gTotalCameraPixelOffsetY < -32) { - data[0]++; + tState++; } break; case 2: @@ -2047,73 +2064,71 @@ static void sub_805DB04(u8 taskId) } } -void sub_805DC04(void) +void StartTeleportInPlayerAnim(void) { - u8 taskId = CreateTask(sub_805DC38, 0); - sub_805DC38(taskId); + u8 taskId = CreateTask(Task_TeleportWarpInPlayerAnim, 0); + Task_TeleportWarpInPlayerAnim(taskId); } -bool32 sub_805DC24(void) +bool32 WaitTeleportInPlayerAnim(void) { - return FuncIsActiveTask(sub_805DC38); + return FuncIsActiveTask(Task_TeleportWarpInPlayerAnim); } -static const u8 gUnknown_835B92C[] = {DIR_SOUTH, DIR_WEST, DIR_EAST, DIR_NORTH, DIR_SOUTH}; - -static void sub_805DC38(u8 taskId) +static void Task_TeleportWarpInPlayerAnim(u8 taskId) { struct ObjectEvent *object = &gObjectEvents[gPlayerAvatar.objectEventId]; struct Sprite *sprite = &gSprites[object->spriteId]; s16 *data = gTasks[taskId].data; - switch (data[0]) + switch (tState) { case 0: - data[5] = sub_805DAF0(); - ObjectEventForceSetHeldMovement(object, GetFaceDirectionMovementAction(gUnknown_835B92C[data[5]])); - data[1] = 0; - data[2] = 116; - data[4] = sprite->pos1.y; - data[6] = sprite->oam.priority; - data[7] = sprite->subpriority; - data[3] = -((u16)sprite->pos2.y + 32) * 16; + tFinalFacingDirection = GetTeleportSavedFacingDirection(); + ObjectEventForceSetHeldMovement(object, GetFaceDirectionMovementAction(sTeleportFacingDirectionSequence[tFinalFacingDirection])); + tRotationTimer = 0; + tDeltaY = 116; + tYpos = sprite->pos1.y; + tPriority = sprite->oam.priority; + tSubpriority = sprite->subpriority; + tYdeflection = -((u16)sprite->pos2.y + 32) * 16; sprite->pos2.y = 0; CameraObjectReset2(); object->fixedPriority = TRUE; sprite->oam.priority = 1; sprite->subpriority = 0; sprite->subspriteMode = SUBSPRITES_OFF; - data[0]++; + tState++; case 1: - sub_805DDC8(object, &data[1]); - data[3] += data[2]; - data[2] -= 3; - if (data[2] < 4) + TeleportAnim_RotatePlayer(object, &tRotationTimer); + tYdeflection += tDeltaY; + tDeltaY -= 3; + if (tDeltaY < 4) { - data[2] = 4; + tDeltaY = 4; } - sprite->pos1.y = data[3] >> 4; - if (sprite->pos1.y >= data[4]) + sprite->pos1.y = tYdeflection >> 4; + if (sprite->pos1.y >= tYpos) { - sprite->pos1.y = data[4]; + sprite->pos1.y = tYpos; data[8] = 0; - data[0]++; + tState++; } break; case 2: - sub_805DDC8(object, &data[1]); + TeleportAnim_RotatePlayer(object, &tRotationTimer); data[8]++; if (data[8] > 8) { - data[0]++; + tState++; } break; case 3: - if (data[5] == sub_805DDC8(object, &data[1])) + if (tFinalFacingDirection == TeleportAnim_RotatePlayer(object, &tRotationTimer)) { object->fixedPriority = 0; - sprite->oam.priority = data[6]; - sprite->subpriority = data[7]; + sprite->oam.priority = tPriority; + sprite->subpriority = tSubpriority; CameraObjectReset1(); DestroyTask(taskId); } @@ -2121,7 +2136,7 @@ static void sub_805DC38(u8 taskId) } } -static u8 sub_805DDC8(struct ObjectEvent *object, s16 *a1) +static u8 TeleportAnim_RotatePlayer(struct ObjectEvent *object, s16 *a1) { if (*a1 < 8 && ++(*a1) < 8) { @@ -2133,7 +2148,16 @@ static u8 sub_805DDC8(struct ObjectEvent *object, s16 *a1) return object->facingDirection; } - ObjectEventForceSetHeldMovement(object, GetFaceDirectionMovementAction(gUnknown_835B92C[object->facingDirection])); + ObjectEventForceSetHeldMovement(object, GetFaceDirectionMovementAction(sTeleportFacingDirectionSequence[object->facingDirection])); *a1 = 0; - return gUnknown_835B92C[object->facingDirection]; + return sTeleportFacingDirectionSequence[object->facingDirection]; } + +#undef tSubpriority +#undef tPriority +#undef tFinalFacingDirection +#undef tYpos +#undef tYdeflection +#undef tDeltaY +#undef tRotationTimer +#undef tState diff --git a/src/field_screen_effect.c b/src/field_screen_effect.c index 85739ad24..a12b57b24 100644 --- a/src/field_screen_effect.c +++ b/src/field_screen_effect.c @@ -434,14 +434,14 @@ static void sub_807F45C(u8 taskId) ++gTasks[taskId].data[0]; break; case 3: - if (sub_807E418() == TRUE) + if (FieldFadeTransitionBackgroundEffectIsFinished() == TRUE) { DestroyTask(taskId); ScriptContext1_SetupScript(EventScript_AfterWhiteOutHeal); } break; case 6: - if (sub_807E418() == TRUE) + if (FieldFadeTransitionBackgroundEffectIsFinished() == TRUE) { DestroyTask(taskId); ScriptContext1_SetupScript(EventScript_AfterWhiteOutMomHeal); diff --git a/src/option_menu.c b/src/option_menu.c index 56a4ec877..62e90c33b 100644 --- a/src/option_menu.c +++ b/src/option_menu.c @@ -509,7 +509,7 @@ static void BufferOptionMenuString(u8 selection) static void CloseAndSaveOptionMenu(u8 taskId) { - gFieldCallback = sub_807DF64; + gFieldCallback = FieldCB_UnionRoomWarp; SetMainCallback2(gMain.savedCallback); FreeAllWindowBuffers(); gSaveBlock2Ptr->optionsTextSpeed = sOptionMenuPtr->option[MENUITEM_TEXTSPEED]; diff --git a/src/quest_log.c b/src/quest_log.c index b2dbb5721..21a05f407 100644 --- a/src/quest_log.c +++ b/src/quest_log.c @@ -600,7 +600,7 @@ bool8 sub_8111000(void) { LoadPalette(stdpal_get(4), 0xF0, 0x20); SetQuestLogState(QL_STATE_2); - sub_807DF64(); + FieldCB_UnionRoomWarp(); gUnknown_203AE94 = (struct UnkStruct_203AE94){}; gUnknown_203AE94.unk_0_0 = 2; return 1; diff --git a/src/scrcmd.c b/src/scrcmd.c index 2b5137f9a..af977fbc7 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -802,7 +802,7 @@ bool8 ScrCmd_warpteleport2(struct ScriptContext * ctx) u16 y = VarGet(ScriptReadHalfword(ctx)); SetWarpDestination(mapGroup, mapNum, warpId, x, y); - sub_805DAE4(GetPlayerFacingDirection()); + SavePlayerFacingDirectionForTeleport(GetPlayerFacingDirection()); sub_807E500(); ResetInitialPlayerAvatarState(); return TRUE; diff --git a/src/seagallop.c b/src/seagallop.c index 1e2234b9c..fb55e6bd2 100644 --- a/src/seagallop.c +++ b/src/seagallop.c @@ -322,7 +322,7 @@ static void Task_Seagallop_3(void) SetWarpDestination(warpInfo[0], warpInfo[1], -1, warpInfo[2], warpInfo[3]); PlayRainStoppingSoundEffect(); PlaySE(SE_KAIDAN); - gFieldCallback = sub_807DF64; + gFieldCallback = FieldCB_UnionRoomWarp; WarpIntoMap(); SetMainCallback2(CB2_LoadMap); ResetInitialPlayerAvatarState(); -- cgit v1.2.3 From 9cb08e34750ad591daf69900d9f857cb8a4ddfbe Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 25 Mar 2020 20:40:44 -0400 Subject: Document player avatar fields --- src/event_object_movement.c | 2 +- src/field_control_avatar.c | 8 +++--- src/field_player_avatar.c | 64 +++++++++++++++++++++++---------------------- src/item_use.c | 2 +- 4 files changed, 39 insertions(+), 37 deletions(-) (limited to 'src') diff --git a/src/event_object_movement.c b/src/event_object_movement.c index c326b2d01..11d15ea98 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -2207,7 +2207,7 @@ bool8 ObjectEventIsTrainerAndCloseToPlayer(struct ObjectEvent *objectEvent) s16 minY; s16 maxY; - if (!TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_DASH)) + if (!TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_WATERING)) { return FALSE; } diff --git a/src/field_control_avatar.c b/src/field_control_avatar.c index 891af3e90..ee413df2d 100644 --- a/src/field_control_avatar.c +++ b/src/field_control_avatar.c @@ -105,11 +105,11 @@ void FieldGetPlayerInput(struct FieldInput *input, u16 newKeys, u16 heldKeys) { 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; 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) input->pressedSelectButton = TRUE; @@ -625,7 +625,7 @@ static bool8 TryStartStepBasedScript(struct MapPosition *position, u16 metatileB return TRUE; if (TryStartStepCountScript(metatileBehavior) == 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 FALSE; } @@ -655,7 +655,7 @@ static bool8 TryStartStepCountScript(u16 metatileBehavior) 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) { diff --git a/src/field_player_avatar.c b/src/field_player_avatar.c index 4d474db2f..d308dcaba 100644 --- a/src/field_player_avatar.c +++ b/src/field_player_avatar.c @@ -182,7 +182,7 @@ static void npc_clear_strange_bits(struct ObjectEvent *objEvent) objEvent->inanimate = 0; objEvent->disableAnim = 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) @@ -197,12 +197,12 @@ static void MovePlayerAvatarUsingKeypadInput(u8 direction, u16 newKeys, u16 held static void PlayerAllowForcedMovementIfMovingSameDirection(void) { if (gPlayerAvatar.runningState == MOVING) - gPlayerAvatar.flags &= ~PLAYER_AVATAR_FLAG_FORCED_MVMT_DISABLED; + gPlayerAvatar.flags &= ~PLAYER_AVATAR_FLAG_FIELD_MOVE; } 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]; if (gUnknown_2036E30->heldMovementFinished) @@ -213,10 +213,10 @@ static bool8 sub_805B528(void) } if (MetatileBehavior_IsSpinTile(gUnknown_2036E30->currentMetatileBehavior)) { - gPlayerAvatar.unk1C = gUnknown_2036E30->currentMetatileBehavior; + gPlayerAvatar.lastSpinTile = gUnknown_2036E30->currentMetatileBehavior; } ObjectEventClearHeldMovement(gUnknown_2036E30); - sub_805C2CC(gPlayerAvatar.unk1C); + sub_805C2CC(gPlayerAvatar.lastSpinTile); } return TRUE; } @@ -255,14 +255,14 @@ static bool8 TryDoMetatileBehaviorForcedMovement(void) { int i; u8 behavior; - if (!(gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_FORCED_MVMT_DISABLED)) + if (!(gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_FIELD_MOVE)) { behavior = gObjectEvents[gPlayerAvatar.objectEventId].currentMetatileBehavior; for (i = 0; sForcedMovementFuncs[i].unk0 != NULL; i++) { if (sForcedMovementFuncs[i].unk0(behavior)) { - gPlayerAvatar.unk1C = behavior; + gPlayerAvatar.lastSpinTile = behavior; return sForcedMovementFuncs[i].unk4(); } } @@ -278,14 +278,14 @@ static bool8 TryDoMetatileBehaviorForcedMovement(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]; playerObjEvent->facingDirectionLocked = FALSE; playerObjEvent->enableAnim = TRUE; SetObjectEventDirection(playerObjEvent, playerObjEvent->facingDirection); - gPlayerAvatar.flags &= ~PLAYER_AVATAR_FLAG_MVMT_IS_FORCED; + gPlayerAvatar.flags &= ~PLAYER_AVATAR_FLAG_FISHING; } return FALSE; } @@ -295,7 +295,7 @@ static u8 DoForcedMovement(u8 direction, MovementAction movementAction) struct PlayerAvatar *playerAvatar = &gPlayerAvatar; u8 collision = CheckForPlayerAvatarCollision(direction); - playerAvatar->flags |= PLAYER_AVATAR_FLAG_MVMT_IS_FORCED; + playerAvatar->flags |= PLAYER_AVATAR_FLAG_FISHING; if (collision) { ForcedMovement_None(); @@ -307,7 +307,7 @@ static u8 DoForcedMovement(u8 direction, MovementAction movementAction) { if (collision == COLLISION_LEDGE_JUMP) PlayerJumpLedge(direction); - playerAvatar->flags |= PLAYER_AVATAR_FLAG_MVMT_IS_FORCED; + playerAvatar->flags |= PLAYER_AVATAR_FLAG_FISHING; playerAvatar->runningState = MOVING; return 1; } @@ -518,7 +518,7 @@ static void PlayerNotOnBikeMoving(u8 direction, u16 heldKeys) PlayerRunSlow(direction); else PlayerRun(direction); - gPlayerAvatar.flags |= PLAYER_AVATAR_FLAG_DASH; + gPlayerAvatar.flags |= PLAYER_AVATAR_FLAG_WATERING; return; } else @@ -676,25 +676,25 @@ static void CheckAcroBikeCollision(s16 x, s16 y, u8 metatileBehavior, u8 *collis void SetPlayerAvatarTransitionFlags(bool16 flags) { - gPlayerAvatar.unk1 |= flags; + gPlayerAvatar.transitionFlags |= flags; DoPlayerAvatarTransition(); } static void (*const gUnknown_835B844[])(struct ObjectEvent *) = { - PlayerAvatarTransition_Normal, - PlayerAvatarTransition_Bike, - PlayerAvatarTransition_Bike, - PlayerAvatarTransition_Surfing, - PlayerAvatarTransition_Underwater, - PlayerAvatarTransition_ReturnToField, - PlayerAvatarTransition_Dummy, - PlayerAvatarTransition_Dummy + [PLAYER_AVATAR_STATE_NORMAL] = PlayerAvatarTransition_Normal, + [PLAYER_AVATAR_STATE_MACH_BIKE] = PlayerAvatarTransition_Bike, + [PLAYER_AVATAR_STATE_ACRO_BIKE] = PlayerAvatarTransition_Bike, + [PLAYER_AVATAR_STATE_SURFING] = PlayerAvatarTransition_Surfing, + [PLAYER_AVATAR_STATE_UNDERWATER] = PlayerAvatarTransition_Underwater, + [PLAYER_AVATAR_STATE_FIELD_MOVE] = PlayerAvatarTransition_ReturnToField, + [PLAYER_AVATAR_STATE_FISHING] = PlayerAvatarTransition_Dummy, + [PLAYER_AVATAR_STATE_WATERING] = PlayerAvatarTransition_Dummy }; static void DoPlayerAvatarTransition(void) { u8 i; - u8 flags = gPlayerAvatar.unk1; + u8 flags = gPlayerAvatar.transitionFlags; if (flags != 0) { @@ -703,7 +703,7 @@ static void DoPlayerAvatarTransition(void) if (flags & 1) 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) { - gPlayerAvatar.flags |= PLAYER_AVATAR_FLAG_FORCED_MVMT_DISABLED; + gPlayerAvatar.flags |= PLAYER_AVATAR_FLAG_FIELD_MOVE; } void sub_805BEB8(void) @@ -1229,7 +1229,7 @@ void ClearPlayerAvatarInfo(void) 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; } @@ -1277,7 +1277,7 @@ void SetPlayerAvatarExtraStateTransition(u8 graphicsId, u8 b) { u8 unk = GetPlayerAvatarStateTransitionByGraphicsId(graphicsId, gPlayerAvatar.gender); - gPlayerAvatar.unk1 |= unk | b; + gPlayerAvatar.transitionFlags |= unk | b; DoPlayerAvatarTransition(); } @@ -1310,7 +1310,7 @@ void InitPlayerAvatar(s16 x, s16 y, u8 direction, u8 gender) gPlayerAvatar.objectEventId = objectEventId; gPlayerAvatar.spriteId = objectEvent->spriteId; 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) @@ -1482,7 +1482,7 @@ static bool8 PlayerAvatar_DoSecretBaseMatJump(struct Task *task, struct ObjectEv if (task->data[1] > 1) { gPlayerAvatar.preventStep = FALSE; - gPlayerAvatar.unk1 |= 0x20; + gPlayerAvatar.transitionFlags |= PLAYER_AVATAR_FLAG_FIELD_MOVE; DestroyTask(FindTaskIdByFunc(DoPlayerAvatarSecretBaseMatJump)); } } @@ -1990,6 +1990,7 @@ void AlignFishingAnimationFrames(struct Sprite * playerSprite) #define tFinalFacingDirection data[5] #define tPriority data[6] #define tSubpriority data[7] +#define tLandingDelay data[8] static const u8 sTeleportFacingDirectionSequence[] = { [DIR_SOUTH] = DIR_WEST, @@ -2111,14 +2112,14 @@ static void Task_TeleportWarpInPlayerAnim(u8 taskId) if (sprite->pos1.y >= tYpos) { sprite->pos1.y = tYpos; - data[8] = 0; + tLandingDelay = 0; tState++; } break; case 2: TeleportAnim_RotatePlayer(object, &tRotationTimer); - data[8]++; - if (data[8] > 8) + tLandingDelay++; + if (tLandingDelay > 8) { tState++; } @@ -2153,6 +2154,7 @@ static u8 TeleportAnim_RotatePlayer(struct ObjectEvent *object, s16 *a1) return sTeleportFacingDirectionSequence[object->facingDirection]; } +#undef tLandingDelay #undef tSubpriority #undef tPriority #undef tFinalFacingDirection diff --git a/src/item_use.c b/src/item_use.c index ea7005f4e..df3dbaceb 100644 --- a/src/item_use.c +++ b/src/item_use.c @@ -308,7 +308,7 @@ static bool8 ItemUseCheckFunc_Rod(void) if (MetatileBehavior_IsWaterfall(behavior)) return FALSE; - if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_4)) + if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_UNDERWATER)) return FALSE; if (!TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_SURFING)) { -- cgit v1.2.3 From b0878acc98761b6ce488289906cd44b334134f95 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Thu, 26 Mar 2020 17:17:11 -0400 Subject: Address review comments --- src/field_player_avatar.c | 6 +++--- src/new_menu_helpers.c | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/field_player_avatar.c b/src/field_player_avatar.c index b301f4e22..efa7546e0 100644 --- a/src/field_player_avatar.c +++ b/src/field_player_avatar.c @@ -179,9 +179,9 @@ static bool8 TryInterruptObjectEventSpecialAnim(struct ObjectEvent *playerObjEve static void npc_clear_strange_bits(struct ObjectEvent *objEvent) { - objEvent->inanimate = 0; - objEvent->disableAnim = 0; - objEvent->facingDirectionLocked = 0; + objEvent->inanimate = FALSE; + objEvent->disableAnim = FALSE; + objEvent->facingDirectionLocked = FALSE; gPlayerAvatar.flags &= ~PLAYER_AVATAR_FLAG_WATERING; } diff --git a/src/new_menu_helpers.c b/src/new_menu_helpers.c index d184bae05..78bc6b7a4 100644 --- a/src/new_menu_helpers.c +++ b/src/new_menu_helpers.c @@ -457,7 +457,7 @@ void AddTextPrinterWithCustomSpeedForMessage(bool8 allowSkippingDelayWithButtonP void LoadStdWindowFrameGfx(void) { - if (gQuestLogState == 2) + if (gQuestLogState == QL_STATE_2) { gTextFlags.autoScroll = 1; TextWindow_LoadTilesStdFrame1(0, DLG_WINDOW_BASE_TILE_NUM); @@ -495,7 +495,7 @@ void ClearDialogWindowAndFrame(u8 windowId, bool8 copyToVram) ClearWindowTilemap(windowId); if (copyToVram == TRUE) CopyWindowToVram(windowId, 3); - if (gQuestLogState == 2) + if (gQuestLogState == QL_STATE_2) CommitQuestLogWindow1(); } @@ -527,7 +527,7 @@ static void WindowFunc_DrawStandardFrame(u8 bg, u8 tilemapLeft, u8 tilemapTop, u static void WindowFunc_DrawDialogueFrame(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum) { - if (!IsMsgSignPost() || gQuestLogState == 2) + if (!IsMsgSignPost() || gQuestLogState == QL_STATE_2) { FillBgTilemapBufferRect(bg, DLG_WINDOW_BASE_TILE_NUM + 0, tilemapLeft - 2, tilemapTop - 1, 1, 1, DLG_WINDOW_PALETTE_NUM); FillBgTilemapBufferRect(bg, DLG_WINDOW_BASE_TILE_NUM + 1, tilemapLeft - 1, tilemapTop - 1, 1, 1, DLG_WINDOW_PALETTE_NUM); @@ -611,7 +611,7 @@ void SetStdWindowBorderStyle(u8 windowId, bool8 copyToVram) void sub_80F7768(u8 windowId, bool8 copyToVram) { - if (gQuestLogState == 2) + if (gQuestLogState == QL_STATE_2) { gTextFlags.autoScroll = 1; TextWindow_LoadTilesStdFrame1(0, DLG_WINDOW_BASE_TILE_NUM); -- cgit v1.2.3 From 9130579f1454c869e74ea8c953c0c778a4760396 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Thu, 26 Mar 2020 17:37:14 -0400 Subject: Resolve off-by-one error in evobjmv.c --- src/event_object_movement.c | 48 +++++++++++++++++++++------------------------ src/field_player_avatar.c | 6 +++--- src/quest_log_player.c | 6 +++--- 3 files changed, 28 insertions(+), 32 deletions(-) (limited to 'src') diff --git a/src/event_object_movement.c b/src/event_object_movement.c index 8c029822f..5361d05dc 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -153,8 +153,6 @@ static void sub_80632BC(struct Sprite *); static void sub_80632E0(struct Sprite *); static void MovementType_WanderAroundDuplicate(struct Sprite *); -extern void MovementType_Player(struct Sprite *); - #define movement_type_def(setup, table) \ static u8 setup##_callback(struct ObjectEvent *, struct Sprite *); \ void setup(struct Sprite *sprite) \ @@ -806,7 +804,7 @@ const u8 gAcroEndWheelieDirectionAnimNums[] = { [DIR_NORTHEAST] = 0x1D, }; -const u8 gAcroUnusedActionDirectionAnimNums[] = { +const u8 gUnknown_83A6465[] = { [DIR_NONE] = 0x18, [DIR_SOUTH] = 0x18, [DIR_NORTH] = 0x19, @@ -818,7 +816,7 @@ const u8 gAcroUnusedActionDirectionAnimNums[] = { [DIR_NORTHEAST] = 0x1B, }; -const u8 gAcroWheeliePedalDirectionAnimNums[] = { +const u8 gAcroUnusedActionDirectionAnimNums[] = { [DIR_NONE] = 0x20, [DIR_SOUTH] = 0x20, [DIR_NORTH] = 0x21, @@ -830,7 +828,7 @@ const u8 gAcroWheeliePedalDirectionAnimNums[] = { [DIR_NORTHEAST] = 0x21, }; -const u8 gFishingDirectionAnimNums[] = { +const u8 gAcroWheeliePedalDirectionAnimNums[] = { [DIR_NONE] = 0x24, [DIR_SOUTH] = 0x24, [DIR_NORTH] = 0x25, @@ -842,7 +840,7 @@ const u8 gFishingDirectionAnimNums[] = { [DIR_NORTHEAST] = 0x25, }; -const u8 gFishingNoCatchDirectionAnimNums[] = { +const u8 gFishingDirectionAnimNums[] = { [DIR_NONE] = 0x0, [DIR_SOUTH] = 0x0, [DIR_NORTH] = 0x1, @@ -854,7 +852,7 @@ const u8 gFishingNoCatchDirectionAnimNums[] = { [DIR_NORTHEAST] = 0x1, }; -const u8 gFishingBiteDirectionAnimNums[] = { +const u8 gFishingNoCatchDirectionAnimNums[] = { [DIR_NONE] = 0x4, [DIR_SOUTH] = 0x4, [DIR_NORTH] = 0x5, @@ -866,7 +864,7 @@ const u8 gFishingBiteDirectionAnimNums[] = { [DIR_NORTHEAST] = 0x5, }; -const u8 gUnknown_83A648A[] = { +const u8 gFishingBiteDirectionAnimNums[] = { [DIR_NONE] = 0x8, [DIR_SOUTH] = 0x8, [DIR_NORTH] = 0x9, @@ -4917,8 +4915,6 @@ static void ClearObjectEventMovement(struct ObjectEvent *objectEvent, struct Spr sprite->data[1] = 0; } -// Off by one error - u8 GetFaceDirectionAnimNum(u8 direction) { return gFaceDirectionAnimNums[direction]; @@ -4964,6 +4960,11 @@ u8 GetAcroEndWheelieDirectionAnimNum(u8 direction) return gAcroEndWheelieDirectionAnimNums[direction]; } +u8 sub_80634C0(u8 direction) +{ + return gUnknown_83A6465[direction]; +} + u8 GetAcroUnusedActionDirectionAnimNum(u8 direction) { return gAcroUnusedActionDirectionAnimNums[direction]; @@ -4989,11 +4990,6 @@ u8 GetFishingBiteDirectionAnimNum(u8 direction) return gFishingBiteDirectionAnimNums[direction]; } -u8 sub_8063510(u8 direction) -{ - return gUnknown_83A648A[direction]; -} - u8 GetRunningDirectionAnimNum(u8 direction) { return gRunningDirectionAnimNums[direction]; @@ -7539,7 +7535,7 @@ void sub_8066C70(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 dire { SetObjectEventDirection(objectEvent, direction); ShiftStillObjectEventCoords(objectEvent); - obj_npc_animation_step(objectEvent, sprite, GetFishingDirectionAnimNum(direction)); + obj_npc_animation_step(objectEvent, sprite, GetAcroWheeliePedalDirectionAnimNum(direction)); sprite->animPaused = TRUE; sprite->data[2] = 1; } @@ -7618,25 +7614,25 @@ static bool8 MovementAction_AcroEndWheelieFaceRight_Step0(struct ObjectEvent *ob static bool8 MovementAction_UnusedAcroActionDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - StartSpriteAnimInDirection(objectEvent, sprite, DIR_SOUTH, GetAcroWheeliePedalDirectionAnimNum(DIR_SOUTH)); + StartSpriteAnimInDirection(objectEvent, sprite, DIR_SOUTH, GetAcroUnusedActionDirectionAnimNum(DIR_SOUTH)); return FALSE; } static bool8 MovementAction_UnusedAcroActionUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - StartSpriteAnimInDirection(objectEvent, sprite, DIR_NORTH, GetAcroWheeliePedalDirectionAnimNum(DIR_NORTH)); + StartSpriteAnimInDirection(objectEvent, sprite, DIR_NORTH, GetAcroUnusedActionDirectionAnimNum(DIR_NORTH)); return FALSE; } static bool8 MovementAction_UnusedAcroActionLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - StartSpriteAnimInDirection(objectEvent, sprite, DIR_WEST, GetAcroWheeliePedalDirectionAnimNum(DIR_WEST)); + StartSpriteAnimInDirection(objectEvent, sprite, DIR_WEST, GetAcroUnusedActionDirectionAnimNum(DIR_WEST)); return FALSE; } static bool8 MovementAction_UnusedAcroActionRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - StartSpriteAnimInDirection(objectEvent, sprite, DIR_EAST, GetAcroWheeliePedalDirectionAnimNum(DIR_EAST)); + StartSpriteAnimInDirection(objectEvent, sprite, DIR_EAST, GetAcroUnusedActionDirectionAnimNum(DIR_EAST)); return FALSE; } @@ -7853,25 +7849,25 @@ static bool8 MovementAction_AcroWheelieJumpRight_Step1(struct ObjectEvent *objec static bool8 MovementActionFunc_x88_0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_80656C4(objectEvent, sprite, DIR_SOUTH, GetFishingDirectionAnimNum(DIR_SOUTH), 8); + sub_80656C4(objectEvent, sprite, DIR_SOUTH, GetAcroWheeliePedalDirectionAnimNum(DIR_SOUTH), 8); return MovementAction_WalkInPlace_Step1(objectEvent, sprite); } static bool8 MovementActionFunc_x89_0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_80656C4(objectEvent, sprite, DIR_NORTH, GetFishingDirectionAnimNum(DIR_NORTH), 8); + sub_80656C4(objectEvent, sprite, DIR_NORTH, GetAcroWheeliePedalDirectionAnimNum(DIR_NORTH), 8); return MovementAction_WalkInPlace_Step1(objectEvent, sprite); } static bool8 MovementActionFunc_x8A_0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_80656C4(objectEvent, sprite, DIR_WEST, GetFishingDirectionAnimNum(DIR_WEST), 8); + sub_80656C4(objectEvent, sprite, DIR_WEST, GetAcroWheeliePedalDirectionAnimNum(DIR_WEST), 8); return MovementAction_WalkInPlace_Step1(objectEvent, sprite); } static bool8 MovementActionFunc_x8B_0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - sub_80656C4(objectEvent, sprite, DIR_EAST, GetFishingDirectionAnimNum(DIR_EAST), 8); + sub_80656C4(objectEvent, sprite, DIR_EAST, GetAcroWheeliePedalDirectionAnimNum(DIR_EAST), 8); return MovementAction_WalkInPlace_Step1(objectEvent, sprite); } @@ -7949,7 +7945,7 @@ static bool8 MovementAction_AcroPopWheelieMoveRight_Step1(struct ObjectEvent *ob void sub_806751C(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 direction, u8 speed) { npc_apply_direction(objectEvent, sprite, direction, speed); - npc_apply_anim_looping(objectEvent, sprite, GetFishingDirectionAnimNum(objectEvent->facingDirection)); + npc_apply_anim_looping(objectEvent, sprite, GetAcroWheeliePedalDirectionAnimNum(objectEvent->facingDirection)); } static bool8 MovementAction_AcroWheelieMoveDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) @@ -8019,7 +8015,7 @@ static bool8 MovementAction_AcroWheelieMoveRight_Step1(struct ObjectEvent *objec void sub_806764C(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 direction, u8 speed) { npc_apply_direction(objectEvent, sprite, direction, speed); - npc_apply_anim_looping(objectEvent, sprite, GetAcroUnusedActionDirectionAnimNum(objectEvent->facingDirection)); + npc_apply_anim_looping(objectEvent, sprite, sub_80634C0(objectEvent->facingDirection)); SeekSpriteAnim(sprite, 0); } diff --git a/src/field_player_avatar.c b/src/field_player_avatar.c index efa7546e0..481e55578 100644 --- a/src/field_player_avatar.c +++ b/src/field_player_avatar.c @@ -1785,7 +1785,7 @@ static bool8 Fishing6(struct Task *task) } else { - StartSpriteAnim(&gSprites[gPlayerAvatar.spriteId], sub_8063510(GetPlayerFacingDirection())); + StartSpriteAnim(&gSprites[gPlayerAvatar.spriteId], GetFishingBiteDirectionAnimNum(GetPlayerFacingDirection())); } return TRUE; } @@ -1887,7 +1887,7 @@ static bool8 Fishing11(struct Task *task) static bool8 Fishing12(struct Task *task) { AlignFishingAnimationFrames(&gSprites[gPlayerAvatar.spriteId]); - StartSpriteAnim(&gSprites[gPlayerAvatar.spriteId], GetFishingBiteDirectionAnimNum(GetPlayerFacingDirection())); + StartSpriteAnim(&gSprites[gPlayerAvatar.spriteId], GetFishingNoCatchDirectionAnimNum(GetPlayerFacingDirection())); FillWindowPixelBuffer(0, PIXEL_FILL(1)); AddTextPrinterParameterized2(0, 2, gText_NotEvenANibble, 1, NULL, TEXT_COLOR_DARK_GREY, TEXT_COLOR_WHITE, TEXT_COLOR_LIGHT_GREY); task->tStep = FISHING_SHOW_RESULT; @@ -1898,7 +1898,7 @@ static bool8 Fishing12(struct Task *task) static bool8 Fishing13(struct Task *task) { AlignFishingAnimationFrames(&gSprites[gPlayerAvatar.spriteId]); - StartSpriteAnim(&gSprites[gPlayerAvatar.spriteId], GetFishingBiteDirectionAnimNum(GetPlayerFacingDirection())); + StartSpriteAnim(&gSprites[gPlayerAvatar.spriteId], GetFishingNoCatchDirectionAnimNum(GetPlayerFacingDirection())); AddTextPrinterParameterized2(0, 2, gText_ItGotAway, 1, NULL, TEXT_COLOR_DARK_GREY, TEXT_COLOR_WHITE, TEXT_COLOR_LIGHT_GREY); task->tStep++; return TRUE; diff --git a/src/quest_log_player.c b/src/quest_log_player.c index 9eb0fbeb8..42233999e 100644 --- a/src/quest_log_player.c +++ b/src/quest_log_player.c @@ -87,7 +87,7 @@ static void sub_8150530(void) else { sub_81507BC(objectEvent, GetPlayerAvatarGraphicsIdByStateId(4)); - StartSpriteAnim(sprite, GetFishingNoCatchDirectionAnimNum(objectEvent->facingDirection)); + StartSpriteAnim(sprite, GetFishingDirectionAnimNum(objectEvent->facingDirection)); } } @@ -102,7 +102,7 @@ static void sub_81505C4(u8 taskId) ObjectEventClearHeldMovementIfActive(objectEvent); objectEvent->enableAnim = TRUE; sub_81507BC(objectEvent, GetPlayerAvatarGraphicsIdByStateId(4)); - StartSpriteAnim(sprite, GetFishingNoCatchDirectionAnimNum(objectEvent->facingDirection)); + StartSpriteAnim(sprite, GetFishingDirectionAnimNum(objectEvent->facingDirection)); gTasks[taskId].data[0]++; gTasks[taskId].data[1] = 0; break; @@ -114,7 +114,7 @@ static void sub_81505C4(u8 taskId) gTasks[taskId].data[0]++; break; case 2: - StartSpriteAnim(sprite, GetFishingBiteDirectionAnimNum(GetPlayerFacingDirection())); + StartSpriteAnim(sprite, GetFishingNoCatchDirectionAnimNum(GetPlayerFacingDirection())); gTasks[taskId].data[0]++; break; case 3: -- cgit v1.2.3