|
@@ -2,12 +2,40 @@
|
2
|
2
|
|
3
|
3
|
typedef bool (*MoveCallback)(struct NpcState* npc, struct Object* obj);
|
4
|
4
|
|
|
5
|
+const struct Coords16 tile_movement_dirs[17] = {
|
|
6
|
+ { 0, 0 }, // [0] nothing
|
|
7
|
+
|
|
8
|
+ { 0, 1 }, // [1] down
|
|
9
|
+ { 0, -1 }, // [2] up
|
|
10
|
+ { -1, 0 }, // [3] left
|
|
11
|
+ { 1, 0 }, // [4] right
|
|
12
|
+
|
|
13
|
+ { -1, 1 }, // [5] down left
|
|
14
|
+ { 1, 1 }, // [6] down right
|
|
15
|
+ { -1, -1 }, // [7] up left
|
|
16
|
+ { 1, -1 }, // [8] up right
|
|
17
|
+
|
|
18
|
+ { -1, 0 }, // [9] down left (enter)
|
|
19
|
+ { 1, 0 }, // [10] down right (enter)
|
|
20
|
+ { -1, -1 }, // [11] up left (enter)
|
|
21
|
+ { 1, -1 }, // [12] up right (enter)
|
|
22
|
+
|
|
23
|
+ { -1, 1 }, // [13] down left (leave)
|
|
24
|
+ { 1, 1 }, // [14] down right (leave)
|
|
25
|
+ { -1, 0 }, // [15] up left (leave)
|
|
26
|
+ { 1, 0 }, // [16] up right (leave)
|
|
27
|
+};
|
|
28
|
+
|
5
|
29
|
void npc_walk_modify_diagonal(struct NpcState* npc, struct Object* obj, u8 direction) {
|
6
|
|
- npc->to.x = walking_directions[direction].x + npc->from.x;
|
7
|
|
- npc->to.y = walking_directions[direction].y + npc->from.y;
|
|
30
|
+ npc->to.x = tile_movement_dirs[direction].x + npc->from.x;
|
|
31
|
+ npc->to.y = tile_movement_dirs[direction].y + npc->from.y;
|
|
32
|
+ //dprintf("npc->from.x=%d npc->from.y=%d direction=%d\n", npc->from.x, npc->from.y, direction);
|
|
33
|
+ //dprintf("npc->to.x=%d npc->to.y=%d\n", npc->to.x, npc->to.y);
|
8
|
34
|
obj->priv[3] = direction;
|
9
|
35
|
}
|
10
|
36
|
|
|
37
|
+// stairs to stairs
|
|
38
|
+
|
11
|
39
|
bool npc_walk_mdia_ul(struct NpcState* npc, struct Object* obj) {
|
12
|
40
|
npc_run_any(npc, obj, 3, 0);
|
13
|
41
|
npc_walk_modify_diagonal(npc,obj,7);
|
|
@@ -22,7 +50,7 @@ bool npc_walk_mdia_ur(struct NpcState* npc, struct Object* obj) {
|
22
|
50
|
|
23
|
51
|
bool npc_walk_mdia_dl(struct NpcState* npc, struct Object* obj) {
|
24
|
52
|
npc_run_any(npc, obj, 3, 0);
|
25
|
|
- npc_update_direction(npc, 3);
|
|
53
|
+ //npc_update_direction(npc, 3);
|
26
|
54
|
npc_walk_modify_diagonal(npc,obj,5);
|
27
|
55
|
return npc_run_is_finished(npc,obj);
|
28
|
56
|
}
|
|
@@ -33,13 +61,78 @@ bool npc_walk_mdia_dr(struct NpcState* npc, struct Object* obj) {
|
33
|
61
|
return npc_run_is_finished(npc,obj);
|
34
|
62
|
}
|
35
|
63
|
|
36
|
|
-MoveCallback npc_walk_anim_mdia_ul[3] = {npc_walk_mdia_ul, npc_run_is_finished, npc_move_end};
|
37
|
|
-MoveCallback npc_walk_anim_mdia_ur[3] = {npc_walk_mdia_ur, npc_run_is_finished, npc_move_end};
|
38
|
|
-MoveCallback npc_walk_anim_mdia_dl[3] = {npc_walk_mdia_dl, npc_run_is_finished, npc_move_end};
|
39
|
|
-MoveCallback npc_walk_anim_mdia_dr[3] = {npc_walk_mdia_dr, npc_run_is_finished, npc_move_end};
|
|
64
|
+// enter stairs
|
|
65
|
+
|
|
66
|
+bool npc_walk_mdia_ul_enter(struct NpcState* npc, struct Object* obj) {
|
|
67
|
+ npc_run_any(npc, obj, 3, 0);
|
|
68
|
+ npc_walk_modify_diagonal(npc,obj,7+4);
|
|
69
|
+ return npc_run_is_finished(npc,obj);
|
|
70
|
+}
|
|
71
|
+
|
|
72
|
+bool npc_walk_mdia_ur_enter(struct NpcState* npc, struct Object* obj) {
|
|
73
|
+ npc_run_any(npc, obj, 4, 0);
|
|
74
|
+ npc_walk_modify_diagonal(npc,obj,8+4);
|
|
75
|
+ return npc_run_is_finished(npc,obj);
|
|
76
|
+}
|
|
77
|
+
|
|
78
|
+bool npc_walk_mdia_dl_enter(struct NpcState* npc, struct Object* obj) {
|
|
79
|
+ npc_run_any(npc, obj, 3, 0);
|
|
80
|
+ //npc_update_direction(npc, 3);
|
|
81
|
+ npc_walk_modify_diagonal(npc,obj,5+4);
|
|
82
|
+ return npc_run_is_finished(npc,obj);
|
|
83
|
+}
|
|
84
|
+
|
|
85
|
+bool npc_walk_mdia_dr_enter(struct NpcState* npc, struct Object* obj) {
|
|
86
|
+ npc_run_any(npc, obj, 4, 0);
|
|
87
|
+ npc_walk_modify_diagonal(npc,obj,6+4);
|
|
88
|
+ return npc_run_is_finished(npc,obj);
|
|
89
|
+}
|
|
90
|
+
|
|
91
|
+// leave stairs
|
|
92
|
+
|
|
93
|
+bool npc_walk_mdia_ul_leave(struct NpcState* npc, struct Object* obj) {
|
|
94
|
+ npc_run_any(npc, obj, 3, 0);
|
|
95
|
+ npc_walk_modify_diagonal(npc,obj,7+8);
|
|
96
|
+ return npc_run_is_finished(npc,obj);
|
|
97
|
+}
|
|
98
|
+
|
|
99
|
+bool npc_walk_mdia_ur_leave(struct NpcState* npc, struct Object* obj) {
|
|
100
|
+ npc_run_any(npc, obj, 4, 0);
|
|
101
|
+ npc_walk_modify_diagonal(npc,obj,8+8);
|
|
102
|
+ return npc_run_is_finished(npc,obj);
|
|
103
|
+}
|
|
104
|
+
|
|
105
|
+bool npc_walk_mdia_dl_leave(struct NpcState* npc, struct Object* obj) {
|
|
106
|
+ npc_run_any(npc, obj, 3, 0);
|
|
107
|
+ //npc_update_direction(npc, 3);
|
|
108
|
+ npc_walk_modify_diagonal(npc,obj,5+8);
|
|
109
|
+ return npc_run_is_finished(npc,obj);
|
|
110
|
+}
|
|
111
|
+
|
|
112
|
+bool npc_walk_mdia_dr_leave(struct NpcState* npc, struct Object* obj) {
|
|
113
|
+ npc_run_any(npc, obj, 4, 0);
|
|
114
|
+ npc_walk_modify_diagonal(npc,obj,6+8);
|
|
115
|
+ return npc_run_is_finished(npc,obj);
|
|
116
|
+}
|
|
117
|
+
|
|
118
|
+static const MoveCallback npc_walk_anim_mdia_ul[3] = {npc_walk_mdia_ul, npc_run_is_finished, npc_move_end};
|
|
119
|
+static const MoveCallback npc_walk_anim_mdia_ur[3] = {npc_walk_mdia_ur, npc_run_is_finished, npc_move_end};
|
|
120
|
+static const MoveCallback npc_walk_anim_mdia_dl[3] = {npc_walk_mdia_dl, npc_run_is_finished, npc_move_end};
|
|
121
|
+static const MoveCallback npc_walk_anim_mdia_dr[3] = {npc_walk_mdia_dr, npc_run_is_finished, npc_move_end};
|
|
122
|
+
|
|
123
|
+static const MoveCallback npc_walk_anim_mdia_ul_enter[3] = {npc_walk_mdia_ul_enter, npc_run_is_finished, npc_move_end};
|
|
124
|
+static const MoveCallback npc_walk_anim_mdia_ur_enter[3] = {npc_walk_mdia_ur_enter, npc_run_is_finished, npc_move_end};
|
|
125
|
+static const MoveCallback npc_walk_anim_mdia_dl_enter[3] = {npc_walk_mdia_dl_enter, npc_run_is_finished, npc_move_end};
|
|
126
|
+static const MoveCallback npc_walk_anim_mdia_dr_enter[3] = {npc_walk_mdia_dr_enter, npc_run_is_finished, npc_move_end};
|
|
127
|
+
|
|
128
|
+static const MoveCallback npc_walk_anim_mdia_ul_leave[3] = {npc_walk_mdia_ul_leave, npc_run_is_finished, npc_move_end};
|
|
129
|
+static const MoveCallback npc_walk_anim_mdia_ur_leave[3] = {npc_walk_mdia_ur_leave, npc_run_is_finished, npc_move_end};
|
|
130
|
+static const MoveCallback npc_walk_anim_mdia_dl_leave[3] = {npc_walk_mdia_dl_leave, npc_run_is_finished, npc_move_end};
|
|
131
|
+static const MoveCallback npc_walk_anim_mdia_dr_leave[3] = {npc_walk_mdia_dr_leave, npc_run_is_finished, npc_move_end};
|
|
132
|
+
|
40
|
133
|
|
41
|
134
|
/* first new is 170 */
|
42
|
|
-const MoveCallback* npc_walk_animations[174] =
|
|
135
|
+const MoveCallback* npc_walk_animations[182] =
|
43
|
136
|
{
|
44
|
137
|
(MoveCallback*)0x83a6864u, (MoveCallback*)0x83a686cu, (MoveCallback*)0x83a6874u, (MoveCallback*)0x83a687cu,
|
45
|
138
|
(MoveCallback*)0x83a6a30u, (MoveCallback*)0x83a6a38u, (MoveCallback*)0x83a6a40u, (MoveCallback*)0x83a6a48u,
|
|
@@ -84,5 +177,69 @@ const MoveCallback* npc_walk_animations[174] =
|
84
|
177
|
(MoveCallback*)0x83a6a00u, (MoveCallback*)0x83a6a0cu, (MoveCallback*)0x83a6a18u, (MoveCallback*)0x83a6a24u,
|
85
|
178
|
(MoveCallback*)0x83a700cu, (MoveCallback*)0x83a7018u, (MoveCallback*)0x83a6c3cu, (MoveCallback*)0x83a6c48u,
|
86
|
179
|
(MoveCallback*)0x83a6c54u, (MoveCallback*)0x83A6C60u, npc_walk_anim_mdia_ul, npc_walk_anim_mdia_ur,
|
87
|
|
- npc_walk_anim_mdia_dl, npc_walk_anim_mdia_dr
|
88
|
|
-};
|
|
180
|
+ npc_walk_anim_mdia_dl, npc_walk_anim_mdia_dr, npc_walk_anim_mdia_ul_enter, npc_walk_anim_mdia_ur_enter,
|
|
181
|
+ npc_walk_anim_mdia_dl_enter, npc_walk_anim_mdia_dr_enter, npc_walk_anim_mdia_ul_leave, npc_walk_anim_mdia_ur_leave,
|
|
182
|
+ npc_walk_anim_mdia_dl_leave, npc_walk_anim_mdia_dr_leave,
|
|
183
|
+};
|
|
184
|
+
|
|
185
|
+static const struct Coords16 enter_leave_table[4] = {
|
|
186
|
+ { -1, 0 },
|
|
187
|
+ { 1, 0 },
|
|
188
|
+ { -1, 0 },
|
|
189
|
+ { 1, 0 },
|
|
190
|
+};
|
|
191
|
+
|
|
192
|
+static inline void little_steps_var(struct Object *obj, u16 movement, int mult) {
|
|
193
|
+ if (movement <= 8) {
|
|
194
|
+ // normal
|
|
195
|
+ obj->pos1.x += tile_movement_dirs[movement].x * mult;
|
|
196
|
+ obj->pos1.y += tile_movement_dirs[movement].y * mult;
|
|
197
|
+ } else if (movement <= 12) {
|
|
198
|
+ dprintf("--------------\n");
|
|
199
|
+ dprintf("animation phase: %d\n", obj->priv[5]);
|
|
200
|
+ dprintf("pos2.x=%d pos2.y=%d\n", obj->pos2.x, obj->pos2.y);
|
|
201
|
+ dprintf("OLD: x=%d y=%d\n", obj->pos1.x, obj->pos1.y);
|
|
202
|
+ // enter diagonal
|
|
203
|
+ if (obj->priv[5] < 8) {
|
|
204
|
+ obj->pos1.x += enter_leave_table[movement - 9].x * mult;
|
|
205
|
+ obj->pos1.y += enter_leave_table[movement - 9].y * mult;
|
|
206
|
+ } else {
|
|
207
|
+ obj->pos1.x += tile_movement_dirs[movement - 4].x * mult;
|
|
208
|
+ obj->pos1.y += tile_movement_dirs[movement - 4].y * mult;
|
|
209
|
+ }
|
|
210
|
+ dprintf("NEW: x=%d y=%d\n", obj->pos1.x, obj->pos1.y);
|
|
211
|
+ } else {
|
|
212
|
+ dprintf("--------------\n");
|
|
213
|
+ dprintf("animation phase: %d\n", obj->priv[5]);
|
|
214
|
+ dprintf("pos2.x=%d pos2.y=%d\n", obj->pos2.x, obj->pos2.y);
|
|
215
|
+ dprintf("OLD: x=%d y=%d\n", obj->pos1.x, obj->pos1.y);
|
|
216
|
+ if (obj->priv[5] < 8) {
|
|
217
|
+ obj->pos1.x += tile_movement_dirs[movement - 8].x * mult;
|
|
218
|
+ obj->pos1.y += tile_movement_dirs[movement - 8].y * mult;
|
|
219
|
+ } else {
|
|
220
|
+ obj->pos1.x += enter_leave_table[movement - 13].x * mult;
|
|
221
|
+ obj->pos1.y += enter_leave_table[movement - 13].y * mult;
|
|
222
|
+ }
|
|
223
|
+ dprintf("NEW: x=%d y=%d\n", obj->pos1.x, obj->pos1.y);
|
|
224
|
+ }
|
|
225
|
+}
|
|
226
|
+
|
|
227
|
+void little_steps_single_hook(struct Object *obj, u16 movement) {
|
|
228
|
+ little_steps_var(obj, movement, 1);
|
|
229
|
+}
|
|
230
|
+
|
|
231
|
+void little_steps_double_hook(struct Object *obj, u16 movement) {
|
|
232
|
+ little_steps_var(obj, movement, 2);
|
|
233
|
+}
|
|
234
|
+
|
|
235
|
+void little_steps_triple_hook(struct Object *obj, u16 movement) {
|
|
236
|
+ little_steps_var(obj, movement, 3);
|
|
237
|
+}
|
|
238
|
+
|
|
239
|
+void little_steps_quad_hook(struct Object *obj, u16 movement) {
|
|
240
|
+ little_steps_var(obj, movement, 4);
|
|
241
|
+}
|
|
242
|
+
|
|
243
|
+void little_steps_octa_hook(struct Object *obj, u16 movement) {
|
|
244
|
+ little_steps_var(obj, movement, 8);
|
|
245
|
+}
|