-
Notifications
You must be signed in to change notification settings - Fork 2
/
fishing.c
270 lines (241 loc) · 7.19 KB
/
fishing.c
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
#include "object.h"
#include "object_anim.h"
#include "overworld_navigation.h"
#include "task.h"
/*
Assumptions:
void *memcpy(void *dst, const void *src, char n)
*/
#define P ((struct fishing_priv*)&t->priv)
struct fishing_priv {
u16 state;
};
void taskFF_fishing(u8 taskid);
extern bool (*fishing_states[0x10])(struct task_t*);
// 0805D2C0
void fishing_start(u8 rod_quality) {
u8 taskid = task_add(&taskFF_fishing, 0xFF);
task[taskid].priv[15] = rod_quality;
taskFF_fishing(taskid);
if (sub_8150474(2) == 1)
sub_8112C9C();
}
// 0805D304
void taskFF_fishing(u8 taskid) {
struct task_t *t = &task[taskid];
while (fishing_states[P->state](t));
}
// 0805D33C
bool fishing0(struct task_t *t) {
script_env_2_enable();
walkrun_state.lock = true;
t->priv[0]++;
return false;
}
// 0805D35C
bool fishing1(struct task_t *t) {
// used to be using memcpy
u16 wait_base[] = {1, 1, 1}; // 1 per rod
u16 wait_variance[] = {1, 3, 6};
struct npc_state *player_npc = &npc_states[walkrun_state.npc_id];
t->priv[12] = 0;
t->priv[13] = wait_base[t->priv[15]] + rand() % wait_variance[t->priv[15]];
t->priv[14] = player_npc->type_id;
npc_unset_movement_behaviour_if_pause_stash_locked(player_npc);
player_npc->bitfield2 |= npc_unpause_pending;
sub_805CC2C(player_npc->direction & 0xF);
t->priv[0]++;
return false;
}
// 0805D3F4
bool fishing2(struct task_t *t) {
sub_805D9C4(objects[walkrun_state.objid]);
if ((++t->priv[1]) >= 60) // wait one second
t->priv[0]++; // go to state 3
return false;
}
// 0805D430
bool fishing3(struct task_t *t) {
box_border_curve_load_tiles_and_pal();
u16 *priv = t->priv;
priv[0]++;
priv[1] = 0;
priv[2] = 0;
priv[3] = (rand() % 10) + 1;
if (priv[12] == 0)
priv[3] += 3;
if (priv[3] > 10)
priv[3] = 10;
return true;
}
// 0805D47C
bool fishing4(struct task_t *t) {
sub_805D9C4(&objects[walkrun_state.objid]);
t->priv[1]++;
if (t->priv[1] < 19) {
t->priv[1] = 0;
if (t->priv[2] < t->priv[3]) {
// textbox related
sub_8002C48(0, 2, (u32 *)0x835B918, t->priv[2] * 12, 1, 0, 0);
} else {
t->priv[0]++;
if (!t->priv[12])
t->priv[0]++;
t->priv[12]++;
}
}
return false;
}
// 0805D508
/* get_fishing_exists_by_map = sub_8082F78 // returns true if fishing exists on map, else false
sub_8063510 seems to be getting an animation number/id from a table depending on player's dir
*/
bool fishing5(struct task_t *t) {
struct obj *player_obj = &objects[walkrun_state.objid];
sub_805D9C4(player_obj); // animation. I think it's the shaking animation before hitting A
t->priv[0]++;
if ((get_wilddata_fishing_by_map() << 0x18) && !(rand() &1)) {
u8 anim_id = sub_8063510(player_get_direction_sp1AA(walkrun_state.objid));
obj_anim_image_start(player_obj, anim_id);
} else {
t->priv[0] = 11;
}
return true;
}
// 0805D574
bool fishing6(struct task_t *t) {
t->priv[0] += 3; // go to state 9
return false;
}
// 0805D580
/*sub_805D9C4 does some animation. Rod shaking maybe.*/
bool fishing7(struct task_t *t) {
// used to be memcpy
u16 rod_something[] = {0x24, 0x21, 0x1E};
sub_805D9C4(&objects[walkrun_state.objid]);
t->priv[1]++;
if (t->priv[1] >= rod_something[t->priv[15]]) {
t->priv[0] = 12;
return false;
}
if (super.buttons_new_remapped & 1) {
t->priv[0]++;
}
return false;
}
// 0805D5EC
/*sub_805D9C4 does some animation. Rod shaking maybe.*/
bool fishing8(struct task_t *t) {
u16 rod_something[] = {0x0, 0x0, 0x28, 0xA, 0x46, 0x1E};
sub_805D9C4(&objects[walkrun_state.objid]);
t->priv[0]++;
if ((t->priv[12] < t->priv[13]) || (t->priv[12] <= 1) &&
(rod_something[2 * t->priv[15] + t->priv[12]]) > rand() % 100)
t->priv[0] = 3;
return false;
}
// 0805D66C
/*sub_805D9C4 does some animation. Rod shaking maybe.*/
bool fishing9(struct task_t *t) {
sub_805D9C4(&objects[walkrun_state.objid]);
rboxid_clear_pixels(0, 0x11);
// box_related_one(unk, font, string, text_speed, unk, text_colour, text_bg_maybe, shadow);*/
box_related_one(0, 2, (char *)0x841D14E, 1, 0, 2, 1, 3);
t->priv[0]++;
t->priv[1] = 0;
return false;
}
// 0805D6C8
/*sub_805D9C4 does some animation. Rod shaking maybe.
sub_8082FB0 = setup_wild_battle_rod; gens a wild pokemon by rod type & does battle preparations */
bool fishingA(struct task_t *t) {
struct obj *player_obj = &objects[walkrun_state.objid];
if (!t->priv[1])
sub_805D9C4(player_obj);
dialogboxes_upload_tilesets(player_obj);
bool a_pressed = dialogid_was_acknowledged(0);
if (a_pressed && !(t->priv[1])) {
return false;
} else if (a_pressed) {
walkrun_state.lock = 0;
script_env_2_disable();
setup_wild_battle_rod(t->priv[15] & 0xFF);
return false;
} else {
struct npc_state *player_npc = &npc_states[walkrun_state.npc_id];
npc_change_type_maybe(player_npc, t->priv[14] & 0xFF);
npc_turn(player_npc, player_npc->direction & 0xF);
if (walkrun_state.bitfield & 8)
sub_80DC4A4(player_npc->objid_surfing, 0, 0);
player_obj->pos_2.x = 0;
player_obj->pos_2.y = 0;
sub_80F6F54(0, 1); // message box update message maybe?
t->priv[1]++;
return false;
}
}
// 0805D7C0
/*sub_805D9C4 does some animation. Rod shaking maybe.
sub_8063500 gets some byte (anim id maybe) from a byte array depending on player facing dir
(char *)0x841D169 - Not even a nibble */
bool fishingB(struct task_t *t) {
struct obj *player_obj = &objects[walkrun_state.objid];
sub_805D9C4(player_obj);
u8 anim_id = sub_8063500(player_get_direction_sp1AA(walkrun_state.objid));
obj_anim_image_start(player_obj, anim_id);
rboxid_clear_pixels(0, 0x11);
// box_related_one(unk, font, string, text_speed, unk, text_colour, text_bg_maybe, shadow);*/
box_related_one(0, 2, (char *)0x841D169, 1, 0, 2, 1, 3);
t->priv[0] = 13;
return true;
}
// 0805D838
/*sub_805D9C4 does some animation. Rod shaking maybe.
sub_8063500 gets some byte (anim id maybe) from a byte array depending on player facing dir
(char *)0x841D17E - it got away */
bool fishingC(struct task_t *t) {
struct obj *player_obj = &objects[walkrun_state.objid];
sub_805D9C4(player_obj);
u8 anim_id = sub_8063500(player_get_direction_sp1AA(walkrun_state.objid));
obj_anim_image_start(player_obj, anim_id);
// box_related_one(unk, font, string, text_speed, unk, text_colour, text_bg_maybe, shadow);*/
box_related_one(0, 2, (char *)0x841D17E, 1, 0, 2, 1, 3);
t->priv[0]++;
return true;
}
// 0805D8AC
/*sub_805D9C4 does some animation. Rod shaking maybe.*/
bool fishingD(struct task_t *t) {
sub_805D9C4(&objects[walkrun_state.objid]);
t->priv[0]++;
return false;
}
// 0805D8D8
/*sub_805D9C4 does some animation. Rod shaking maybe.*/
bool fishingE(struct task_t *t) {
struct obj *player_obj = &objects[walkrun_state.objid];
struct npc_state *player_npc = &npc_states[walkrun_state.npc_id];
sub_805D9C4(player_obj);
if (player_obj->bitfield & 0x10) {
npc_change_type_maybe(player_npc, t->priv[14] & 0xFF);
npc_turn(player_npc, player_npc->direction & 0xF);
if (walkrun_state.bitfield & 8)
sub_80DC4A4(player_npc->objid_surfing, 0, 0);
player_obj->pos_2.x = 0;
player_obj->pos_2.y = 0;
}
}
// 0805D980
bool fishingF(struct task_t *t) {
textbox_something();
if (a_pressed_maybe(0))
return false;
walkrun_state.lock = false;
script_env_2_disable();
sub_8068A5C();
sub_80F6F54(0, 1);
u8 taskid = task_find_by_funcptr(&taskFF_fishing);
task_del(taskid);
return false;
}
#undef P