through AlignFishingAnimationFrames

This commit is contained in:
PikalaxALT
2020-03-25 17:37:07 -04:00
parent f1841ef24d
commit c032dc0231
13 changed files with 421 additions and 1165 deletions
File diff suppressed because it is too large Load Diff
-34
View File
@@ -4,39 +4,5 @@
.section .rodata
.align 2
.align 2
gUnknown_835B8CC:: @ 835B8CC
.4byte sub_805D33C
.4byte fish1
.4byte fish2
.4byte sub_805D430
.4byte sub_805D47C
.4byte sub_805D508
.4byte sub_805D574
.4byte sub_805D580
.4byte sub_805D5EC
.4byte sub_805D66C
.4byte sub_805D6C8
.4byte sub_805D7C0
.4byte sub_805D838
.4byte sub_805D8AC
.4byte sub_805D8D8
.4byte sub_805D980
gUnknown_835B90C:: @ 835B90C
.2byte 0x0001, 0x0001, 0x0001
gUnknown_835B912:: @ 835B912
.2byte 0x0001, 0x0003, 0x0006
gUnknown_835B918:: @ 835B918
.string "·$"
gUnknown_835B91A:: @ 835B91A
.2byte 0x0024, 0x0021, 0x001e
gUnknown_835B920:: @ 835B920
.2byte 0x0000, 0x0000, 0x0028, 0x000a, 0x0046, 0x001e
gUnknown_835B92C:: @ 835B92C
.byte 0x01, 0x03, 0x04, 0x02, 0x01
+2
View File
@@ -217,5 +217,7 @@ u8 GetJumpInPlaceTurnAroundMovementAction(u32 direction);
u8 GetAcroWheelieInPlaceDirectionMovementAction(u32 direction);
u8 GetAcroPopWheelieMoveDirectionMovementAction(u32 direction);
u8 GetAcroWheelieMoveDirectionMovementAction(u32 direction);
u8 sub_80641EC(u32 direction);
u8 sub_8063510(u8 direction);
#endif // GUARD_EVENT_OBJECT_MOVEMENT_H
+1
View File
@@ -24,5 +24,6 @@ u32 StartFieldEffectForObjectEvent(u8, struct ObjectEvent*);
u8 FindTallGrassFieldEffectSpriteId(u8 localId, u8 mapNum, u8 mapGroup, s16 x, s16 y);
void ShowWarpArrowSprite(u8 spriteId, u8 direction, s16 x, s16 y);
void SetSpriteInvisible(u8 spriteId);
void sub_80DC4A4(u8 spriteId, u8 value, s16 data1);
#endif //GUARD_FIELD_EFFECT_HELPERS_H
+2 -2
View File
@@ -19,12 +19,12 @@ void sub_805C780(void);
void GetXYCoordsOneStepInFrontOfPlayer(s16 *xPtr, s16 *yPtr);
u8 GetPlayerAvatarGraphicsIdByStateId(u8);
void SetPlayerAvatarStateMask(u8 mask);
void sub_805D9C4(struct Sprite *sprite);
void AlignFishingAnimationFrames(struct Sprite *sprite);
void CreateStopSurfingTask_NoMusicChange(u8 direction);
void sub_805DAE4(u8 direction);
void SetPlayerAvatarTransitionFlags(u16 a);
bool8 IsPlayerFacingSurfableFishableWater(void);
void sub_805D2C0(u8 secondaryId);
void StartFishing(u8 secondaryId);
u8 GetPlayerAvatarObjectId(void);
u8 PlayerGetZCoord(void);
u8 GetPlayerAvatarGraphicsIdByCurrentState(void);
+1
View File
@@ -58,5 +58,6 @@ void Special_UpdateTrainerFansAfterLinkBattle(void);
void sub_8112628(u8 movementActionId);
void sub_81126AC(u8 movementActionId, u8 duration);
void sub_8112588(u8 localId, u8 mapNum, u8 mapGroup, u8 movementActionId, u8 duration);
void sub_8112C9C(void);
#endif //GUARD_QUEST_LOG_H
+1 -1
View File
@@ -4,7 +4,7 @@
#include "global.h"
void sub_8150454(void);
bool8 sub_8150474(u8 a0);
bool32 sub_8150474(u8 a0);
void sub_8150498(u8 a0);
#endif //GUARD_QUEST_LOG_PLAYER_H
+5
View File
@@ -1463,4 +1463,9 @@ extern const u8 gUnknown_841B2C6[];
extern const u8 gUnknown_841B2E5[];
extern const u8 gUnknown_841B2DC[];
// field_player_avatar
extern const u8 gText_PokemonOnHook[];
extern const u8 gText_NotEvenANibble[];
extern const u8 gText_ItGotAway[];
#endif //GUARD_STRINGS_H
+2
View File
@@ -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];
+400 -1
View File
@@ -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);
}
+1 -1
View File
@@ -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);
}
+3 -3
View File
@@ -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))
+3 -3
View File
@@ -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");