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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
|
/*
* File: z_en_hs.c
* Overlay: ovl_En_Hs
* Description: Carpenter's Son
*/
#include "z_en_hs.h"
#include "gfx.h"
#include "gfx_setupdl.h"
#include "printf.h"
#include "sfx.h"
#include "sys_matrix.h"
#include "terminal.h"
#include "translation.h"
#include "z_lib.h"
#include "play_state.h"
#include "player.h"
#include "save.h"
#include "assets/objects/object_hs/object_hs.h"
#define FLAGS (ACTOR_FLAG_ATTENTION_ENABLED | ACTOR_FLAG_FRIENDLY)
void EnHs_Init(Actor* thisx, PlayState* play);
void EnHs_Destroy(Actor* thisx, PlayState* play);
void EnHs_Update(Actor* thisx, PlayState* play);
void EnHs_Draw(Actor* thisx, PlayState* play);
void func_80A6E9AC(EnHs* this, PlayState* play);
void func_80A6E6B0(EnHs* this, PlayState* play);
ActorProfile En_Hs_Profile = {
/**/ ACTOR_EN_HS,
/**/ ACTORCAT_NPC,
/**/ FLAGS,
/**/ OBJECT_HS,
/**/ sizeof(EnHs),
/**/ EnHs_Init,
/**/ EnHs_Destroy,
/**/ EnHs_Update,
/**/ EnHs_Draw,
};
static ColliderCylinderInit sCylinderInit = {
{
COL_MATERIAL_NONE,
AT_NONE,
AC_ON | AC_TYPE_ENEMY,
OC1_ON | OC1_TYPE_ALL,
OC2_TYPE_1,
COLSHAPE_CYLINDER,
},
{
ELEM_MATERIAL_UNK0,
{ 0x00000000, HIT_SPECIAL_EFFECT_NONE, 0x00 },
{ 0xFFCFFFFF, HIT_BACKLASH_NONE, 0x00 },
ATELEM_NONE,
ACELEM_ON,
OCELEM_ON,
},
{ 40, 40, 0, { 0, 0, 0 } },
};
void func_80A6E3A0(EnHs* this, EnHsActionFunc actionFunc) {
this->actionFunc = actionFunc;
}
void EnHs_Init(Actor* thisx, PlayState* play) {
EnHs* this = (EnHs*)thisx;
s32 pad;
ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f);
SkelAnime_InitFlex(play, &this->skelAnime, &object_hs_Skel_006260, &object_hs_Anim_0005C0, this->jointTable,
this->morphTable, 16);
Animation_PlayLoop(&this->skelAnime, &object_hs_Anim_0005C0);
Collider_InitCylinder(play, &this->collider);
Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit);
this->actor.colChkInfo.mass = MASS_IMMOVABLE;
Actor_SetScale(&this->actor, 0.01f);
if (!LINK_IS_ADULT) {
this->actor.params = 0;
} else {
this->actor.params = 1;
}
if (this->actor.params == 1) {
PRINTF(VT_FGCOL(CYAN) T(" ヒヨコの店(大人の時) \n", " chicken shop (adult era) \n") VT_RST);
func_80A6E3A0(this, func_80A6E9AC);
if (GET_ITEMGETINF(ITEMGETINF_30)) {
PRINTF(VT_FGCOL(CYAN) T(" ヒヨコ屋閉店 \n", " chicken shop closed \n") VT_RST);
Actor_Kill(&this->actor);
}
} else {
PRINTF(VT_FGCOL(CYAN) T(" ヒヨコの店(子人の時) \n", " chicken shop (child era) \n") VT_RST);
func_80A6E3A0(this, func_80A6E9AC);
}
this->unk_2A8 = 0;
this->actor.attentionRangeType = ATTENTION_RANGE_6;
}
void EnHs_Destroy(Actor* thisx, PlayState* play) {
EnHs* this = (EnHs*)thisx;
Collider_DestroyCylinder(play, &this->collider);
}
s32 func_80A6E53C(EnHs* this, PlayState* play, u16 textId, EnHsActionFunc actionFunc) {
s16 yawDiff;
if (Actor_TalkOfferAccepted(&this->actor, play)) {
func_80A6E3A0(this, actionFunc);
return 1;
}
this->actor.textId = textId;
yawDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y;
if ((ABS(yawDiff) <= 0x2150) && (this->actor.xzDistToPlayer < 100.0f)) {
this->unk_2A8 |= 1;
Actor_OfferTalk(&this->actor, play, 100.0f);
}
return 0;
}
void func_80A6E5EC(EnHs* this, PlayState* play) {
if (Actor_TextboxIsClosing(&this->actor, play)) {
func_80A6E3A0(this, func_80A6E6B0);
}
this->unk_2A8 |= 1;
}
void func_80A6E630(EnHs* this, PlayState* play) {
if ((Message_GetState(&play->msgCtx) == TEXT_STATE_DONE) && Message_ShouldAdvance(play)) {
Interface_SetSubTimer(180);
func_80A6E3A0(this, func_80A6E6B0);
CLEAR_EVENTINF(EVENTINF_MARATHON_ACTIVE);
}
this->unk_2A8 |= 1;
}
void func_80A6E6B0(EnHs* this, PlayState* play) {
func_80A6E53C(this, play, 0x10B6, func_80A6E5EC);
}
void func_80A6E6D8(EnHs* this, PlayState* play) {
if (Actor_TextboxIsClosing(&this->actor, play)) {
func_80A6E3A0(this, func_80A6E9AC);
}
}
void func_80A6E70C(EnHs* this, PlayState* play) {
if (Actor_TextboxIsClosing(&this->actor, play)) {
func_80A6E3A0(this, func_80A6E9AC);
}
}
void func_80A6E740(EnHs* this, PlayState* play) {
if (Actor_HasParent(&this->actor, play)) {
this->actor.parent = NULL;
func_80A6E3A0(this, func_80A6E630);
} else {
Actor_OfferGetItem(&this->actor, play, GI_ODD_MUSHROOM, 10000.0f, 50.0f);
}
this->unk_2A8 |= 1;
}
void func_80A6E7BC(EnHs* this, PlayState* play) {
if ((Message_GetState(&play->msgCtx) == TEXT_STATE_CHOICE) && Message_ShouldAdvance(play)) {
switch (play->msgCtx.choiceIndex) {
case 0:
func_80A6E3A0(this, func_80A6E740);
Actor_OfferGetItem(&this->actor, play, GI_ODD_MUSHROOM, 10000.0f, 50.0f);
break;
case 1:
Message_ContinueTextbox(play, 0x10B4);
func_80A6E3A0(this, func_80A6E70C);
break;
}
Animation_Change(&this->skelAnime, &object_hs_Anim_0005C0, 1.0f, 0.0f,
Animation_GetLastFrame(&object_hs_Anim_0005C0), ANIMMODE_LOOP, 8.0f);
}
this->unk_2A8 |= 1;
}
void func_80A6E8CC(EnHs* this, PlayState* play) {
Player* player = GET_PLAYER(play);
if ((Message_GetState(&play->msgCtx) == TEXT_STATE_EVENT) && Message_ShouldAdvance(play)) {
Message_ContinueTextbox(play, 0x10B3);
func_80A6E3A0(this, func_80A6E7BC);
Animation_Change(&this->skelAnime, &object_hs_Anim_000528, 1.0f, 0.0f,
Animation_GetLastFrame(&object_hs_Anim_000528), ANIMMODE_LOOP, 8.0f);
}
if (this->unk_2AA > 0) {
this->unk_2AA--;
if (this->unk_2AA == 0) {
Player_PlaySfx(player, NA_SE_EV_CHICKEN_CRY_M);
}
}
this->unk_2A8 |= 1;
}
void func_80A6E9AC(EnHs* this, PlayState* play) {
Player* player = GET_PLAYER(play);
s16 yawDiff;
if (Actor_TalkOfferAccepted(&this->actor, play)) {
if (Actor_GetPlayerExchangeItemId(play) == EXCH_ITEM_COJIRO) {
player->actor.textId = 0x10B2;
func_80A6E3A0(this, func_80A6E8CC);
Animation_Change(&this->skelAnime, &object_hs_Anim_000304, 1.0f, 0.0f,
Animation_GetLastFrame(&object_hs_Anim_000304), ANIMMODE_LOOP, 8.0f);
this->unk_2AA = 40;
Sfx_PlaySfxCentered(NA_SE_SY_TRE_BOX_APPEAR);
} else {
player->actor.textId = 0x10B1;
func_80A6E3A0(this, func_80A6E6D8);
}
} else {
yawDiff = this->actor.yawTowardsPlayer - this->actor.shape.rot.y;
this->actor.textId = 0x10B1;
if ((ABS(yawDiff) <= 0x2150) && (this->actor.xzDistToPlayer < 100.0f)) {
Actor_OfferTalkExchangeEquiCylinder(&this->actor, play, 100.0f, EXCH_ITEM_COJIRO);
}
}
}
void EnHs_Update(Actor* thisx, PlayState* play) {
EnHs* this = (EnHs*)thisx;
s32 pad;
Collider_UpdateCylinder(thisx, &this->collider);
CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base);
Actor_MoveXZGravity(&this->actor);
Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_2);
if (SkelAnime_Update(&this->skelAnime)) {
this->skelAnime.curFrame = 0.0f;
}
this->actionFunc(this, play);
if (this->unk_2A8 & 1) {
Actor_TrackPlayer(play, &this->actor, &this->unk_29C, &this->unk_2A2, this->actor.focus.pos);
this->unk_2A8 &= ~1;
} else {
Math_SmoothStepToS(&this->unk_29C.x, 12800, 6, 6200, 100);
Math_SmoothStepToS(&this->unk_29C.y, 0, 6, 6200, 100);
Math_SmoothStepToS(&this->unk_2A2.x, 0, 6, 6200, 100);
Math_SmoothStepToS(&this->unk_2A2.y, 0, 6, 6200, 100);
}
}
s32 EnHs_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) {
EnHs* this = (EnHs*)thisx;
switch (limbIndex) {
case 9:
rot->x += this->unk_29C.y;
rot->z += this->unk_29C.x;
break;
case 10:
*dList = NULL;
return false;
case 11:
*dList = NULL;
return false;
case 12:
if (this->actor.params == 1) {
*dList = NULL;
return false;
}
break;
case 13:
if (this->actor.params == 1) {
*dList = NULL;
return false;
}
break;
}
return false;
}
void EnHs_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) {
static Vec3f D_80A6EDFC = { 300.0f, 1000.0f, 0.0f };
EnHs* this = (EnHs*)thisx;
if (limbIndex == 9) {
Matrix_MultVec3f(&D_80A6EDFC, &this->actor.focus.pos);
}
}
void EnHs_Draw(Actor* thisx, PlayState* play) {
EnHs* this = (EnHs*)thisx;
Gfx_SetupDL_37Opa(play->state.gfxCtx);
SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount,
EnHs_OverrideLimbDraw, EnHs_PostLimbDraw, this);
}
|