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
|
/**
* @file gorman.c
* @ingroup NPCs
*
* @brief Gorman NPC
*/
#include "player.h"
#include "npc.h"
#include "asm.h"
#include "message.h"
#include "script.h"
#include "flags.h"
#include "room.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unk_68;
/*0x69*/ s8 unk_69;
} GormanEntity;
void sub_080697A4(Entity* this);
void sub_08069838(GormanEntity* this);
void sub_08069888(Entity* this);
const SpriteLoadData gUnk_08111C3C[] = {
{ 193, 64, 4 },
{ 5313, 64, 4 },
{ 0, 0, 0 },
};
void sub_080697C4(Entity*);
void sub_080697EC(Entity*);
void (*const gUnk_08111C48[])(Entity*) = {
sub_080697C4,
sub_080697EC,
};
const u16 gUnk_08111C50[] = {
TEXT_INDEX(TEXT_GORMAN_ORACLES, 0x1), TEXT_INDEX(TEXT_GORMAN_ORACLES, 0x2), TEXT_INDEX(TEXT_GORMAN_ORACLES, 0xc),
TEXT_INDEX(TEXT_GORMAN_ORACLES, 0xd), TEXT_INDEX(TEXT_GORMAN_ORACLES, 0xe), TEXT_INDEX(TEXT_GORMAN_ORACLES, 0x15),
};
const Coords gUnk_08111C5C[] = {
{ .HALF = { 0x68, 0x1c8 } }, { .HALF = { 0x28, 0x1c8 } }, { .HALF = { 0x68, 0x188 } },
{ .HALF = { 0x68, 0x1c8 } }, { .HALF = { 0x28, 0x188 } }, { .HALF = { 0x68, 0x188 } }
};
const u8 gUnk_08111C74[] = {
0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 0,
};
const Coords gUnk_08111C84[] = {
{ .HALF = { 0x178, 0x108 } },
{ .HALF = { 0x138, 0x108 } },
};
const u8 gUnk_08111C8C[] = {
0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 0,
};
const u8 gUnk_08111C9C[] = {
0, 1, 0, 1, 2, 3, 2, 3, 4, 5, 4, 5,
};
const u8 gUnk_08111CA8[] = {
1, 2, 0, 0, 3, 4, 1, 2, 5, 5, 3, 4,
};
const u8 gUnk_08111CB4[] = {
0,
1,
0,
1,
};
const u8 gUnk_08111CB8[] = {
1,
1,
0,
0,
};
void Gorman(GormanEntity* this) {
if ((super->flags & ENT_SCRIPTED) != 0) {
sub_08069838(this);
} else {
sub_080697A4(super);
}
}
void sub_080697A4(Entity* this) {
gUnk_08111C48[this->action](this);
sub_0806ED78(this);
}
void sub_080697C4(Entity* this) {
if (LoadExtraSpriteData(this, gUnk_08111C3C)) {
this->action = 1;
InitializeAnimation(this, 2);
AddInteractableWhenBigObject(this);
}
}
void sub_080697EC(Entity* this) {
s32 tmp;
tmp = GetAnimationStateInRectRadius(this, 0x20, 0x20);
if (tmp >= 0) {
if (this->subtimer == 0) {
this->subtimer = 16;
if (this->animIndex != tmp) {
InitializeAnimation(this, tmp);
}
} else {
this->subtimer--;
}
}
if (this->interactType != INTERACTION_NONE) {
this->interactType = INTERACTION_NONE;
sub_08069888(this);
}
}
void sub_08069838(GormanEntity* this) {
if (super->action == 0) {
if (!LoadExtraSpriteData(super, gUnk_08111C3C)) {
return;
}
super->action++;
this->unk_68 = 0;
this->unk_69 = 0;
sub_0807DD64(super);
}
ExecuteScriptAndHandleAnimation(super, NULL);
if (super->interactType != INTERACTION_NONE) {
super->interactType = INTERACTION_NONE;
sub_08069888(super);
}
}
void sub_08069888(Entity* this) {
s32 index;
if (CheckGlobalFlag(GOMAN_RENTED_HOUSE) == 0) {
index = 0;
SetGlobalFlag(GOMAN_RENTED_HOUSE);
} else if (((CheckGlobalFlag(RENTED_HOUSE_DIN) == 0) && (CheckGlobalFlag(RENTED_HOUSE_NAYRU) == 0)) &&
(CheckGlobalFlag(RENTED_HOUSE_FARORE) == 0)) {
index = 1;
} else if (CheckGlobalFlag(TATEKAKE_HOUSE) == 0) {
index = 2;
} else if (CheckGlobalFlag(GOMAN_NEW_HOUSE) == 0) {
index = 3;
SetGlobalFlag(GOMAN_NEW_HOUSE);
} else if ((CheckGlobalFlag(NEW_HOUSE_DIN) == 0) && (CheckGlobalFlag(NEW_HOUSE_NAYRU) == 0)) {
index = CheckGlobalFlag(NEW_HOUSE_FARORE) ? 5 : 4;
} else {
index = 5;
}
MessageNoOverlap(gUnk_08111C50[index], this);
}
void sub_0806991C(GormanEntity* this, ScriptExecutionContext* context) {
u32 tmp;
const Coords* ptr;
this->unk_68 = (Random() & 0x1f) + 0x3c;
ptr = &gUnk_08111C5C[this->unk_69];
context->x.HALF.HI = gRoomControls.origin_x + ptr->HALF.x;
context->y.HALF.HI = gRoomControls.origin_y + ptr->HALF.y;
context->unk_19 = 8;
context->postScriptActions |= 2;
context->condition = 0;
tmp = CalculateDirectionFromOffsets(context->x.HALF.HI - super->x.HALF.HI, context->y.HALF.HI - super->y.HALF.HI);
super->direction = tmp;
super->animationState = (super->animationState & 0x80) | gUnk_08111C74[(tmp << 0x18) >> 0x1c];
gActiveScriptInfo.flags |= 1;
}
void sub_080699AC(GormanEntity* this, ScriptExecutionContext* context) {
u32 tmp;
const Coords* ptr;
this->unk_68 = (Random() & 0x1f) + 0x3c;
ptr = &gUnk_08111C84[this->unk_69];
context->x.HALF.HI = gRoomControls.origin_x + ptr->HALF.x;
context->y.HALF.HI = gRoomControls.origin_y + ptr->HALF.y;
context->unk_19 = 8;
context->postScriptActions |= 2;
context->condition = 0;
tmp = CalculateDirectionFromOffsets(context->x.HALF.HI - super->x.HALF.HI, context->y.HALF.HI - super->y.HALF.HI);
super->direction = tmp;
super->animationState = (super->animationState & 0x80) | gUnk_08111C8C[(tmp << 0x18) >> 0x1c];
gActiveScriptInfo.flags |= 1;
}
void sub_08069A3C(GormanEntity* this) {
this->unk_69 = gUnk_08111C9C[(Random() & 1) + this->unk_69 * 2];
}
void sub_08069A60(GormanEntity* this) {
this->unk_69 = gUnk_08111CA8[(Random() & 1) + this->unk_69 * 2];
}
void sub_08069A84(GormanEntity* this) {
this->unk_69 = gUnk_08111CB4[(Random() & 1) + this->unk_69 * 2];
}
void sub_08069AA8(GormanEntity* this) {
this->unk_69 = gUnk_08111CB8[(Random() & 1) + this->unk_69 * 2];
}
void sub_08069ACC(GormanEntity* this, ScriptExecutionContext* context) {
if (--this->unk_68 * 0x1000000 < 1) {
context->condition = 1;
} else {
context->condition = 0;
}
}
void Gorman_Head(Entity* this) {
SetExtraSpriteFrame(this, 0, (this->frame & 7) + 0xf);
SetExtraSpriteFrame(this, 1, this->frameIndex);
SetSpriteSubEntryOffsetData1(this, 1, 0);
sub_0807000C(this);
}
|