|
@@ -0,0 +1,80 @@
|
|
1
|
+#include <pokeagb/pokeagb.h>
|
|
2
|
+#include <agb_debug.h>
|
|
3
|
+
|
|
4
|
+#define BLOCK_STATE_SIDEWAY_NW 0x80
|
|
5
|
+#define BLOCK_STATE_SIDEWAY_NE 0x81
|
|
6
|
+#define BLOCK_STATE_SIDEWAY_SW 0x82
|
|
7
|
+#define BLOCK_STATE_SIDEWAY_SE 0x83
|
|
8
|
+#define BEHAVIOR_STAIR_WEST 0xE0
|
|
9
|
+#define BEHAVIOR_STAIR_EAST 0xE1
|
|
10
|
+
|
|
11
|
+const u8 diagonal_animations[4] = {170,171,172,173};
|
|
12
|
+
|
|
13
|
+bool npc_sideway_try_walking(u8 block_state)
|
|
14
|
+{
|
|
15
|
+ if(block_state >= BLOCK_STATE_SIDEWAY_NW) {
|
|
16
|
+ npc_player_set_movement_and_x22(diagonal_animations[block_state - BLOCK_STATE_SIDEWAY_NW], 2);
|
|
17
|
+ // Kinda have to do the thing when the player runs (ish)
|
|
18
|
+ return true;
|
|
19
|
+ }
|
|
20
|
+ return false;
|
|
21
|
+}
|
|
22
|
+
|
|
23
|
+u8 npc_get_walkable_status(struct NpcState *npc, u16 x, u16 y, enum Direction direction, u8 roleTo) {
|
|
24
|
+ dprintf("get_walkable: %d, %d, %d, %d\n", x,y, direction, roleTo);
|
|
25
|
+ u8 block = npc_block_way(npc, x,y,direction);
|
|
26
|
+
|
|
27
|
+ //check for diagonal stair stuff here
|
|
28
|
+ struct NpcState dummyNpc;
|
|
29
|
+ memcpy(&dummyNpc, npc, sizeof(struct NpcState));
|
|
30
|
+
|
|
31
|
+ u16 roleFrom = cur_mapdata_block_role_at(npc->from.x, npc->from.y);
|
|
32
|
+ if (direction == WEST) {
|
|
33
|
+ dprintf("WEST with from: %d\n", roleFrom);
|
|
34
|
+ if(roleFrom == BEHAVIOR_STAIR_WEST) {
|
|
35
|
+ //walk up the stair to the west
|
|
36
|
+ dummyNpc.from.y--;
|
|
37
|
+ dummyNpc.to.y--;
|
|
38
|
+ u8 altBlocked = npc_block_way(&dummyNpc, x,y-1, direction);
|
|
39
|
+ dprintf("trying NW: %d\n", altBlocked);
|
|
40
|
+ return (altBlocked == 0) ? BLOCK_STATE_SIDEWAY_NW : altBlocked;
|
|
41
|
+ }
|
|
42
|
+ else if(roleFrom == BEHAVIOR_STAIR_EAST){
|
|
43
|
+ //walk down the stair to the west
|
|
44
|
+ dummyNpc.from.y++;
|
|
45
|
+ dummyNpc.to.y++;
|
|
46
|
+ u8 altBlocked = npc_block_way(&dummyNpc, x,y+1, direction);
|
|
47
|
+ dprintf("trying SE: %d\n", altBlocked);
|
|
48
|
+ return (altBlocked == 0) ? BLOCK_STATE_SIDEWAY_SW : altBlocked;
|
|
49
|
+ }
|
|
50
|
+ } else if(direction == EAST) {
|
|
51
|
+ if(roleFrom == BEHAVIOR_STAIR_EAST) {
|
|
52
|
+ //walk up the stair to the east
|
|
53
|
+ dummyNpc.from.y--;
|
|
54
|
+ dummyNpc.to.y--;
|
|
55
|
+ u8 altBlocked = npc_block_way(&dummyNpc, x,y-1, direction);
|
|
56
|
+ dprintf("trying NE: %d\n", altBlocked);
|
|
57
|
+ return (altBlocked == 0) ? BLOCK_STATE_SIDEWAY_NE : altBlocked;
|
|
58
|
+ } else if (roleFrom == BEHAVIOR_STAIR_WEST) {
|
|
59
|
+ //walk down the stair to the east
|
|
60
|
+ dummyNpc.from.y++;
|
|
61
|
+ dummyNpc.to.y++;
|
|
62
|
+ u8 altBlocked = npc_block_way(&dummyNpc, x,y+1, direction);
|
|
63
|
+ dprintf("trying SW: %d\n", altBlocked);
|
|
64
|
+ return (altBlocked == 0) ? BLOCK_STATE_SIDEWAY_SE : altBlocked;
|
|
65
|
+ }
|
|
66
|
+ }
|
|
67
|
+
|
|
68
|
+ //continue with game code
|
|
69
|
+
|
|
70
|
+ if(block == 3 && npc_is_passable_maybe(x,y,direction))
|
|
71
|
+ return 5;
|
|
72
|
+ if(npc_handle_jump(x,y,direction)) {
|
|
73
|
+ sav1_secure_increment(0x2B);
|
|
74
|
+ return 6;
|
|
75
|
+ }
|
|
76
|
+ else if(block == 4 && npc_handle_strength(x,y,direction)) {
|
|
77
|
+ return 7;
|
|
78
|
+ }
|
|
79
|
+ return block;
|
|
80
|
+}
|