1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
|
#include "global.h"
#include "bike.h"
#include "script.h"
#include "task.h"
#include "field_player_avatar.h"
#include "event_object_movement.h"
#include "field_effect.h"
#include "field_effect_helpers.h"
#include "quest_log.h"
#include "quest_log_player.h"
static void QL_GfxTransition_Normal(void);
static void QL_GfxTransition_Bike(void);
static void QL_GfxTransition_Fish(void);
static void Task_QLFishMovement(u8 taskId);
static void QL_GfxTransition_StartSurf(void);
static void QL_GfxTransition_VSSeeker(void);
static void Task_QLVSSeekerMovement(u8 taskId);
static void QL_GfxTransition_StopSurfSouth(void);
static void QL_GfxTransition_StopSurfNorth(void);
static void QL_GfxTransition_StopSurfWest(void);
static void QL_GfxTransition_StopSurfEast(void);
static void QL_SetObjectGraphicsId(struct ObjectEvent *object, u8 graphicsId);
static void (*const sQLGfxTransitions[])(void) = {
[QL_PLAYER_GFX_NORMAL] = QL_GfxTransition_Normal,
[QL_PLAYER_GFX_BIKE] = QL_GfxTransition_Bike,
[QL_PLAYER_GFX_FISH] = QL_GfxTransition_Fish,
[QL_PLAYER_GFX_SURF] = QL_GfxTransition_StartSurf,
[QL_PLAYER_GFX_STOP_SURF_S] = QL_GfxTransition_StopSurfSouth,
[QL_PLAYER_GFX_STOP_SURF_N] = QL_GfxTransition_StopSurfNorth,
[QL_PLAYER_GFX_STOP_SURF_W] = QL_GfxTransition_StopSurfWest,
[QL_PLAYER_GFX_STOP_SURF_E] = QL_GfxTransition_StopSurfEast,
[QL_PLAYER_GFX_VSSEEKER] = QL_GfxTransition_VSSeeker
};
void QuestLogUpdatePlayerSprite(u8 state)
{
if (state < NELEMS(sQLGfxTransitions))
sQLGfxTransitions[state]();
}
bool32 QuestLogTryRecordPlayerAvatarGfxTransition(u8 state)
{
if (gQuestLogPlaybackState == 2)
{
QuestLogRecordPlayerAvatarGfxTransition(state);
return TRUE;
}
return FALSE;
}
void QuestLogCallUpdatePlayerSprite(u8 state)
{
return QuestLogUpdatePlayerSprite(state);
}
static void QL_GfxTransition_Normal(void)
{
struct ObjectEvent *objectEvent = &gObjectEvents[gPlayerAvatar.objectEventId];
QL_SetObjectGraphicsId(objectEvent, GetPlayerAvatarGraphicsIdByStateId(PLAYER_AVATAR_GFX_NORMAL));
ObjectEventTurn(objectEvent, objectEvent->movementDirection);
SetPlayerAvatarStateMask(PLAYER_AVATAR_FLAG_ON_FOOT);
}
static void QL_GfxTransition_Bike(void)
{
struct ObjectEvent *objectEvent = &gObjectEvents[gPlayerAvatar.objectEventId];
QL_SetObjectGraphicsId(objectEvent, GetPlayerAvatarGraphicsIdByStateId(PLAYER_AVATAR_GFX_BIKE));
ObjectEventTurn(objectEvent, objectEvent->movementDirection);
SetPlayerAvatarStateMask(PLAYER_AVATAR_FLAG_MACH_BIKE);
BikeClearState(0, 0);
}
static void QL_GfxTransition_Fish(void)
{
struct ObjectEvent *objectEvent = &gObjectEvents[gPlayerAvatar.objectEventId];
struct Sprite *sprite = &gSprites[objectEvent->spriteId];
if (gQuestLogPlaybackState == 1 || gQuestLogPlaybackState == 3)
{
u8 taskId;
ScriptContext2_Enable();
gPlayerAvatar.preventStep = TRUE;
taskId = CreateTask(Task_QLFishMovement, 0xFF);
gTasks[taskId].data[0] = 0;
}
else
{
QL_SetObjectGraphicsId(objectEvent, GetPlayerAvatarGraphicsIdByStateId(PLAYER_AVATAR_GFX_FISH));
StartSpriteAnim(sprite, GetFishingDirectionAnimNum(objectEvent->facingDirection));
}
}
static void Task_QLFishMovement(u8 taskId)
{
struct ObjectEvent *objectEvent = &gObjectEvents[gPlayerAvatar.objectEventId];
struct Sprite *sprite = &gSprites[objectEvent->spriteId];
switch (gTasks[taskId].data[0])
{
case 0:
ObjectEventClearHeldMovementIfActive(objectEvent);
objectEvent->enableAnim = TRUE;
QL_SetObjectGraphicsId(objectEvent, GetPlayerAvatarGraphicsIdByStateId(PLAYER_AVATAR_GFX_FISH));
StartSpriteAnim(sprite, GetFishingDirectionAnimNum(objectEvent->facingDirection));
gTasks[taskId].data[0]++;
gTasks[taskId].data[1] = 0;
break;
case 1:
AlignFishingAnimationFrames(sprite);
if (gTasks[taskId].data[1] < 60)
gTasks[taskId].data[1]++;
else
gTasks[taskId].data[0]++;
break;
case 2:
StartSpriteAnim(sprite, GetFishingNoCatchDirectionAnimNum(GetPlayerFacingDirection()));
gTasks[taskId].data[0]++;
break;
case 3:
AlignFishingAnimationFrames(sprite);
if (sprite->animEnded)
{
if (!(gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_SURFING))
QL_SetObjectGraphicsId(objectEvent, GetPlayerAvatarGraphicsIdByStateId(PLAYER_AVATAR_GFX_NORMAL));
else
QL_SetObjectGraphicsId(objectEvent, GetPlayerAvatarGraphicsIdByStateId(PLAYER_AVATAR_GFX_RIDE));
ObjectEventTurn(objectEvent, objectEvent->movementDirection);
sprite->x2 = 0;
sprite->y2 = 0;
ScriptContext2_Disable();
DestroyTask(taskId);
}
break;
}
}
static void QL_GfxTransition_StartSurf(void)
{
struct ObjectEvent *objectEvent = &gObjectEvents[gPlayerAvatar.objectEventId];
u8 fieldEffectId;
if (!(gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_SURFING))
{
QL_SetObjectGraphicsId(objectEvent, GetPlayerAvatarGraphicsIdByStateId(PLAYER_AVATAR_GFX_RIDE));
ObjectEventTurn(objectEvent, objectEvent->movementDirection);
SetPlayerAvatarStateMask(PLAYER_AVATAR_FLAG_SURFING);
gFieldEffectArguments[0] = objectEvent->currentCoords.x;
gFieldEffectArguments[1] = objectEvent->currentCoords.y;
gFieldEffectArguments[2] = gPlayerAvatar.objectEventId;
fieldEffectId = FieldEffectStart(FLDEFF_SURF_BLOB);
objectEvent->fieldEffectSpriteId = fieldEffectId;
SetSurfBlob_BobState(fieldEffectId, 1);
}
}
static void QL_GfxTransition_VSSeeker(void)
{
FieldEffectStart(FLDEFF_USE_VS_SEEKER);
CreateTask(Task_QLVSSeekerMovement, 0x00);
}
static void Task_QLVSSeekerMovement(u8 taskId)
{
if (!FieldEffectActiveListContains(FLDEFF_USE_VS_SEEKER))
{
UnfreezeObjectEvents();
ScriptContext2_Disable();
DestroyTask(taskId);
}
}
static void QL_SetObjectGraphicsId(struct ObjectEvent * object, u8 graphicsId)
{
ObjectEventSetGraphicsId(object, graphicsId);
}
static void QL_GfxTransition_StopSurfSouth(void)
{
CreateStopSurfingTask_NoMusicChange(DIR_SOUTH);
}
static void QL_GfxTransition_StopSurfNorth(void)
{
CreateStopSurfingTask_NoMusicChange(DIR_NORTH);
}
static void QL_GfxTransition_StopSurfWest(void)
{
CreateStopSurfingTask_NoMusicChange(DIR_WEST);
}
static void QL_GfxTransition_StopSurfEast(void)
{
CreateStopSurfingTask_NoMusicChange(DIR_EAST);
}
|