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
|
/**
* @file goron.c
* @ingroup NPCs
*
* @brief Goron NPC
*/
#include "effects.h"
#include "entity.h"
#include "kinstone.h"
#include "message.h"
#include "script.h"
#include "npc.h"
#include "common.h"
#include "player.h"
#include "physics.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused[24];
/*0x80*/ u16 unk_80;
/*0x82*/ u16 unk_82;
} GoronEntity;
void sub_08069310(Entity*);
void sub_08069328(Entity*);
void sub_08069390(Entity*);
void sub_080693C4(GoronEntity*);
void sub_080693D0(GoronEntity*);
void Goron(GoronEntity* this) {
static void (*const actionFuncs[])(Entity*) = {
sub_08069310,
sub_08069328,
sub_08069390,
};
static void (*const scriptedActionFuncs[])(GoronEntity*) = {
sub_080693C4,
sub_080693D0,
};
if (super->flags & ENT_SCRIPTED) {
scriptedActionFuncs[super->action](this);
} else {
actionFuncs[super->action](super);
sub_0806ED78(super);
}
}
void sub_08069310(Entity* this) {
AddInteractableWhenBigObject(this);
this->action = 1;
InitAnimationForceUpdate(this, 2);
}
void sub_08069328(Entity* this) {
if (++this->subtimer > 16) {
int action;
this->subtimer = 0;
action = GetAnimationStateInRectRadius(this, 40, 40);
if (action >= 0) {
this->animationState = action;
}
}
if (this->animIndex != this->animationState) {
InitAnimationForceUpdate(this, this->animationState);
}
if (this->interactType != INTERACTION_NONE) {
this->action = 2;
RequestPriority(this);
InitAnimationForceUpdate(this, 8);
MessageFromTarget(this->timer + TEXT_INDEX(TEXT_MINISH2, 0x0));
}
}
void sub_08069390(Entity* this) {
UpdateAnimationSingleFrame(this);
if ((gMessage.state & MESSAGE_ACTIVE) == 0) {
this->action = 1;
this->interactType = INTERACTION_NONE;
RevokePriority(this);
InitAnimationForceUpdate(this, this->animationState);
}
}
void sub_080693C4(GoronEntity* this) {
super->action = 1;
InitScriptForNPC(super);
}
void sub_08069428(Entity* this, s32 offsetX, bool32 createFx65);
void sub_080693D0(GoronEntity* this) {
ExecuteScriptAndHandleAnimation(super, NULL);
if (super->animIndex == 8) {
bool32 createFx65 = (this->unk_82 & 0xF) != 0;
if (super->frame == 1) {
super->frame = 0;
sub_08069428(super, Q_16_16(-8.0), createFx65);
}
if (super->frame == 2) {
super->frame = 0;
sub_08069428(super, Q_16_16(8.0), createFx65);
}
}
}
void sub_08069428(Entity* this, s32 offsetX, bool32 createFx65) {
Entity* fx = CreateFx(this, FX_ROCK, 0);
if (fx) {
PositionRelative(this, fx, offsetX, Q_16_16(-16.0));
SortEntityAbove(this, fx);
}
if (createFx65 != 0) {
fx = CreateFx(this, FX_REFLECT4, 0);
if (fx) {
PositionRelative(this, fx, offsetX, Q_16_16(-16.0));
SortEntityAbove(this, fx);
}
}
}
u32 sub_08069480(Entity* this) {
return (u8)GetFusionToOffer(this);
}
void sub_0806948C(Entity* this, ScriptExecutionContext* context) {
context->condition = CheckKinstoneFused((u8)sub_08069480(this));
gActiveScriptInfo.flags |= 1;
}
void Goron_MakeInteractable(Entity* this) {
u32 kinstone = (u8)sub_08069480(this);
if (CheckKinstoneFused(kinstone)) {
AddInteractableWhenBigObject(this);
} else {
AddInteractableWhenBigFuser(this, kinstone);
}
}
void sub_080694D8(Entity* this) {
static const Dialog gUnk_08111A94[] = {
{ 0x2f,
DIALOG_KINSTONE,
DIALOG_CHECK_FLAG,
1,
{ TEXT_INDEX(TEXT_TINGLE, 0x13), TEXT_INDEX(TEXT_TINGLE, 0x0e) } },
{ 0x2f,
DIALOG_KINSTONE,
DIALOG_CHECK_FLAG,
1,
{ TEXT_INDEX(TEXT_TINGLE, 0x14), TEXT_INDEX(TEXT_TINGLE, 0x0f) } },
{ 0x2f,
DIALOG_KINSTONE,
DIALOG_CHECK_FLAG,
1,
{ TEXT_INDEX(TEXT_TINGLE, 0x15), TEXT_INDEX(TEXT_TINGLE, 0x10) } },
{ 0x2f,
DIALOG_KINSTONE,
DIALOG_CHECK_FLAG,
1,
{ TEXT_INDEX(TEXT_TINGLE, 0x16), TEXT_INDEX(TEXT_TINGLE, 0x11) } },
{ 0x2f,
DIALOG_KINSTONE,
DIALOG_CHECK_FLAG,
1,
{ TEXT_INDEX(TEXT_TINGLE, 0x17), TEXT_INDEX(TEXT_TINGLE, 0x12) } },
{ 0, 0, DIALOG_NORMAL, 1, { 0, TEXT_INDEX(TEXT_TINGLE, 0x18) } },
};
ShowNPCDialogue(this, &gUnk_08111A94[this->type]);
}
void sub_080694EC(GoronEntity* this) {
u32 anim;
super->animationState = 4;
anim = 2;
if (!CheckKinstoneFused(KINSTONE_2F))
anim = 8;
InitAnimationForceUpdate(super, anim);
this->unk_80 = anim;
}
void Goron_Fusion(Entity* this) {
if (this->action == 0) {
this->action++;
this->spriteSettings.draw = 1;
InitAnimationForceUpdate(this, 2);
} else {
UpdateAnimationSingleFrame(this);
}
}
|