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
|
Entities_Actions:
CALL =Reset_Entities_Collision_Map
LD HL, $mem_entities_list
CALL =Entity_Action
CALL =Entity_Action
CALL =Entity_Action
CALL =Entity_Action
CALL =Entity_Action
CALL =Entity_Action
CALL =Entity_Action
CALL =Entity_Action
CALL =Entity_Action
CALL =Entity_Action
CALL =Entity_Action
CALL =Entity_Action
CALL =Entity_Action
CALL =Entity_Action
CALL =Entity_Action
CALL =Entity_Action
RET
Entity_Action:
LD A, (HL+)
CP $00
JR Z, =Entity_Action.skip
INC HL
INC HL
INC HL
LD A, (HL+)
LD D, A
LD A, (HL+)
LD E, A
PUSH HL
LD A, L
AND $f8
LD L, A
; This is confusing but this thing is actually CALL DE
LD BC, =Entity_Action.interaction_end
PUSH BC
PUSH DE
RET
Entity_Action.interaction_end:
POP HL
Entity_Action.skip:
LD A, L
AND $f8
ADD $08
LD L, A
RET
Fox_AI:
PUSH HL
INC HL
INC HL
INC HL
LD A, $mem_map_loading_flags
BIT 1, A
JR Z, =Fox_AI.Update_Position.end
LD A, (HL)
BIT 3, A
JR Z, =Fox_AI.Update_Position.end
RES 3, A
DEC A
LD C, A
AND $01
SLA A
AND $02
DEC A
LD B, A
LD A, L
AND $f8
INC A
LD L, A
BIT 1, C
JR NZ, =Fox_AI.vertical_tile_move
Fox_AI.horizontal_tile_move:
LD A, (HL)
ADD B
LD (HL), A
JP =Fox_AI.Update_Position.end
Fox_AI.vertical_tile_move:
INC HL
LD A, (HL)
ADD B
LD (HL), A
Fox_AI.Update_Position.end:
LD A, L
AND $f8
ADD $03
LD L, A
LD A, $mem_moving_animation_step
CP $01
JR NZ, =Fox_AI.end
LD A, $mem_bunny_direction
BIT 3, A
JR Z, =Fox_AI.end
CALL =RNG_Step
AND $08
LD B, A
LD A, $04
CALL =RNG_Bound
INC A
OR $08
LD B, A
PUSH BC
CALL =Get_Position_After_Move
LD A, C
CALL =Is_Collisionable
CALL =Carve_Entity_Collision_Map
POP BC
CP $00
JR Z, =Fox_AI.change_direction
RES 3, B
Fox_AI.change_direction:
LD (HL), B
Fox_AI.end:
POP HL
RET
|