Twilight Princess
Decompilation of The Legend of Zelda: Twilight Princess
Loading...
Searching...
No Matches
d_a_formation_mng.h
Go to the documentation of this file.
1#ifndef D_A_FORMATION_MNG_H
2#define D_A_FORMATION_MNG_H
3
4#include "d/d_com_inf_game.h"
5#include "d/d_path.h"
7#include "d/d_kankyo.h"
9
11 /* 808365B0 */ bool checkPathEnd(cXyz, f32);
12 /* 8083665C */ bool checkPoint(cXyz, f32);
13
14 bool isPathClose() { return dPath_ChkClose(mPath); }
17
18 void chgDir() {
19 int dir;
20 if (field_0xc > 0) {
21 dir = -1;
22 } else {
23 dir = 1;
24 }
25 field_0xc = dir;
26 }
27
28 void setPath(int param_1, int param_2, cXyz* param_3) {
30 field_0x4 = 0;
31 field_0xc = 1;
32 field_0x8 = param_3->abs(dPath_GetPnt(mPath, field_0x4)->m_position);
33 }
34
46
50
51 int decIndex(int param_1) {
52 param_1--;
53 if (param_1 < 0) {
54 if (isPathClose()) {
55 param_1 = mPath->m_num - 1;
56 } else {
57 param_1 = 0;
58 }
59 }
60 return param_1;
61 }
62
63 int incIndex(int param_1) {
64 param_1++;
65 if (param_1 >= mPath->m_num) {
66 if (isPathClose()) {
67 param_1 = 0;
68 } else {
69 param_1--;
70 }
71 }
72 return param_1;
73 }
74
75 void setNextPoint() {
76 if (field_0xc > 0) {
78 } else {
80 }
81 field_0x8 = 1000000000.0f;
82 }
83
87 }
88
89 /* 0x0 */ dPath* mPath;
90 /* 0x4 */ int field_0x4;
91 /* 0x8 */ f32 field_0x8;
92 /* 0xC */ s8 field_0xc;
93};
94
95struct FmtPos_c : public daFmtMng_Path_c {
96 /* 80836C24 */ ~FmtPos_c() {}
97 /* 80836C60 */ FmtPos_c() {}
98 /* 0x10 */ cXyz field_0x10;
99 /* 0x1C */ s16 field_0x1c;
100 /* 0x1E */ s16 field_0x1e;
101};
102
104 /* 80837458 */ ~FmtMember_c() {}
105 /* 80837798 */ FmtMember_c() {}
106
107 /* 0x00 */ u32 mNpcId;
108 /* 0x04 */ cXyz field_0x04;
109 /* 0x10 */ cXyz field_0x10;
110 /* 0x1C */ s16 field_0x1c;
111 /* 0x1E */ u16 field_0x1e;
112};
113
122
124 /* 0x00 */ int field_0x00;
125 /* 0x04 */ f32 field_0x04;
126 /* 0x08 */ f32 field_0x08;
127 /* 0x0C */ f32 field_0x0c;
128 /* 0x10 */ f32 field_0x10;
129 /* 0x14 */ s16 field_0x14;
130 /* 0x16 */ s16 field_0x16;
131};
132
133struct daFmtMng_c : public fopAc_ac_c {
134 /* 80835558 */ void initWait();
135 /* 80835624 */ void initMemberPos();
136 /* 80835B24 */ void executeWait();
137 /* 80835D28 */ void initWalk();
138 /* 80835DEC */ void executeWalk();
139 /* 8083622C */ void setMovePath(FmtPos_c*, int);
140 /* 80836810 */ void initReverse();
141 /* 808368A4 */ void executeReverse();
142 /* 80836C64 */ void initMotion();
143 /* 80836E20 */ void executeMotion();
144 /* 80836F78 */ void initFight();
145 /* 80837078 */ void executeFight();
146 /* 808374B4 */ int create();
147 /* 8083750C */ void create_init();
148
151 for (int i = 0; i < mFormationLine * mFormationRow; i++, member++) {
152 fopAcM_delete(member->mNpcId);
153 }
154 delete [] mPos;
155 delete [] mMember;
156 }
157
159 if (dKy_darkworld_check()) {
160 return dKy_getDarktime_hour();
161 }
162 return dKy_getdaytime_hour();
163 }
164
166 if (dKy_darkworld_check()) {
167 return dKy_getDarktime_minute();
168 }
169 return dKy_getdaytime_minute();
170 }
171
172 int getTime() {
173 return getTimeHour() * 60 + getTimeMinute();
174 }
175
176 u8 getPathID() { return shape_angle.x; }
177 u8 getFormationLine() { return fopAcM_GetParam(this) & 0xff; }
178 u8 getFormationRow() { return (fopAcM_GetParam(this) >> 8) & 0xff; }
179 int getStartTime() { return (fopAcM_GetParam(this) >> 16) & 0xff; }
180 int getEndTime() { return (fopAcM_GetParam(this) >> 24) & 0xff; }
181
182 void callExecute() {
183 JUT_ASSERT(680, mAction != 0);
184 (this->*(mAction[1]))();
185 }
186
189 return false;
190 }
193 for (int i = 0; i < mFormationRow * mFormationLine; i++, member++) {
195 if (npcFgd != NULL) {
197 f32 dVar10 = iVar6->y;
199 if (this_01->y - dVar10 < 200.0f) {
200 f32 maxDist = pow(500.0, 2.0);
202 return true;
203 }
204 }
205 }
206 }
207 return false;
208 }
209
210 void callInit() {
211 JUT_ASSERT(667, mAction != 0)
212 (this->*(*mAction))();
213 }
214
215 void setAction(int i_action) {
216 JUT_ASSERT(633, i_action < MODE_MAX_e);
220 callInit();
221 }
222
223 int execute() {
224 callExecute();
227 }
228 return 1;
229 }
230
233 bool memberCulling;
235 for (int i = 0; i < mFormationRow * mFormationLine; i++, member++) {
236 memberCulling = false;
237 if (member->mNpcId != -1) {
239 if (npcFgd != NULL) {
241 }
242 if (!memberCulling) {
243 return false;
244 }
245 }
246 }
247 return true;
248 }
249
252 if (speedF > attr().field_0x04) {
254 }
255 }
256
258 if (speedF <= 0.0f) {
259 return;
260 }
262 member->getTargetPoint(&acStack_28);
263 cLib_addCalcAngleS2(&member->field_0x1c,
264 cLib_targetAngleY(&member->field_0x10, &acStack_28),
265 attr().field_0x14, attr().field_0x16);
266 }
267
269 param_1->x += speedF * cM_ssin(*param_2);
270 param_1->z += speedF * cM_scos(*param_2);
271 }
272
274 FmtPos_c* pos = mPos + 1;
275 for (int i = 1; i < mFormationRow; i++, pos++) {
276 if (cLib_distanceAngleS(pos[-1].field_0x1c, pos[0].field_0x1c) <= attr().field_0x00) {
277 pos[0].field_0x10.set(0.0f, 0.0f, -attr().field_0x10);
278 mDoMtx_stack_c::transS(pos[-1].field_0x10);
279 mDoMtx_stack_c::YrotM(pos[-1].field_0x1c);
280 mDoMtx_stack_c::multVec(&pos[0].field_0x10, &pos[0].field_0x10);
281 }
282 }
283 }
284
286 int j;
287 FmtPos_c* pos;
290 int i;
291 pos = mPos;
292 member = mMember;
293 for (i = 0; i < mFormationRow; i++, pos++) {
294 f32 dVar13 = (mFormationLine - 1) * attr().field_0x0c * 0.5f;
295 mDoMtx_stack_c::transS(pos->field_0x10);
296 mDoMtx_stack_c::YrotM(pos->field_0x1c);
297 for (j = 0; j < mFormationLine; j++, member++) {
298 member->field_0x10.set(member->field_0x04);
299 member->field_0x04.set(dVar13, 0.0f, 0.0f);
300 mDoMtx_stack_c::multVec(&member->field_0x04, &member->field_0x04);
302 npcFgd = NULL;
304 if (npcFgd != NULL) {
307 npcPos->x = member->field_0x04.x;
308 npcPos->z = member->field_0x04.z;
310 cLib_targetAngleY(&member->field_0x10, &member->field_0x04),
311 attr().field_0x14, attr().field_0x16);
312 fopAcM_SetSpeedF(npcFgd, member->field_0x10.abs(member->field_0x04));
313 }
314 }
315 }
316 }
317
318 static FmtMngAttributes const& attr() { return M_attr; }
319 static FmtMngAttributes const M_attr;
320
323
324 /* 0x568 */ FmtPos_c* mPos;
325 /* 0x56C */ FmtMember_c* mMember;
326 /* 0x570 */ dPath* mRoomPath;
327 /* 0x574 */ ActionFunc* mAction;
328 /* 0x578 */ int mCurrentAction;
329 /* 0x57C */ int mPrevAction;
330 /* 0x580 */ int field_0x580;
331 /* 0x584 */ int mFormationLine;
332 /* 0x588 */ int mFormationRow;
333 /* 0x58C */ int mStartTime;
334 /* 0x590 */ int mEndTime;
335 /* 0x594 */ int mDayOfWeek;
336 /* 0x598 */ int field_0x598;
337 /* 0x59C */ int field_0x59c;
338 /* 0x5A0 */ int field_0x5a0;
339};
340
341#endif /* D_A_FORMATION_MNG_H */
s32 cLib_distanceAngleS(s16 x, s16 y)
Definition c_lib.cpp:341
s16 cLib_targetAngleY(const Vec *lhs, const Vec *rhs)
Definition c_lib.cpp:314
void cLib_addCalcAngleS2(s16 *pValue, s16 target, s16 scale, s16 maxStep)
Definition c_lib.cpp:192
T cLib_calcTimer(T *value)
Definition c_lib.h:74
f32 cM_ssin(s16 x)
Definition c_math.h:23
f32 cM_scos(s16 x)
Definition c_math.h:19
static void daPy_getPlayerActorClass()
Definition d_a_b_gnd.cpp:2857
FmtMngAction
Definition d_a_formation_mng.h:114
@ MODE_1_e
Definition d_a_formation_mng.h:116
@ MODE_0_e
Definition d_a_formation_mng.h:115
@ MODE_2_e
Definition d_a_formation_mng.h:117
@ MODE_MAX_e
Definition d_a_formation_mng.h:120
@ MODE_3_e
Definition d_a_formation_mng.h:118
@ MODE_4_e
Definition d_a_formation_mng.h:119
static u8 pos[12]
Definition d_a_obj_kago.cpp:839
s32 dKy_getDarktime_minute()
Definition d_kankyo.cpp:1477
s32 dKy_getdaytime_hour()
Definition d_kankyo.cpp:1449
s32 dKy_getdaytime_minute()
Definition d_kankyo.cpp:1454
bool dKy_darkworld_check()
Definition d_kankyo.cpp:4460
s32 dKy_getDarktime_hour()
Definition d_kankyo.cpp:1471
dPath * dPath_GetRoomPath(int path_index, int room_no)
Definition d_path.cpp:19
dStage_dPnt_c * dPath_GetPnt(dPath const *path, int pnt_index)
Definition d_path.cpp:10
BOOL dPath_ChkClose(dPath *i_path)
Definition d_path.h:19
int i
Definition e_pow.c:165
int j
Definition e_pow.c:165
s32 fopAcM_SearchByID(fpc_ProcID i_actorID, fopAc_ac_c **i_outActor)
Definition f_op_actor_mng.cpp:49
void fopAcM_delete(fopAc_ac_c *i_actor)
Definition f_op_actor_mng.cpp:139
cXyz * fopAcM_GetPosition_p(fopAc_ac_c *pActor)
Definition f_op_actor_mng.h:268
u32 fopAcM_GetParam(const void *pActor)
Definition f_op_actor_mng.h:224
void fopAcM_SetSpeedF(fopAc_ac_c *actor, f32 f)
Definition f_op_actor_mng.h:344
csXyz * fopAcM_GetShapeAngle_p(fopAc_ac_c *pActor)
Definition f_op_actor_mng.h:288
u32 fopAcM_CheckCondition(fopAc_ac_c *p_actor, u32 flag)
Definition f_op_actor_mng.h:292
f32 fopAcM_searchPlayerDistanceXZ2(const fopAc_ac_c *actor)
Definition f_op_actor_mng.h:690
double pow(double, double)
Definition w_pow.c:4
Definition d_a_formation_mng.h:103
~FmtMember_c()
Definition d_a_formation_mng.h:104
cXyz field_0x10
Definition d_a_formation_mng.h:109
u16 field_0x1e
Definition d_a_formation_mng.h:111
FmtMember_c()
Definition d_a_formation_mng.h:105
cXyz field_0x04
Definition d_a_formation_mng.h:108
u32 mNpcId
Definition d_a_formation_mng.h:107
s16 field_0x1c
Definition d_a_formation_mng.h:110
Definition d_a_formation_mng.h:123
f32 field_0x10
Definition d_a_formation_mng.h:128
f32 field_0x08
Definition d_a_formation_mng.h:126
s16 field_0x14
Definition d_a_formation_mng.h:129
s16 field_0x16
Definition d_a_formation_mng.h:130
f32 field_0x04
Definition d_a_formation_mng.h:125
int field_0x00
Definition d_a_formation_mng.h:124
f32 field_0x0c
Definition d_a_formation_mng.h:127
Definition d_a_formation_mng.h:95
s16 field_0x1e
Definition d_a_formation_mng.h:100
s16 field_0x1c
Definition d_a_formation_mng.h:99
~FmtPos_c()
Definition d_a_formation_mng.h:96
FmtPos_c()
Definition d_a_formation_mng.h:97
cXyz field_0x10
Definition d_a_formation_mng.h:98
Definition vec.h:18
s16 x
Definition vec.h:19
Definition d_a_hozelda.cpp:18
Definition d_a_hozelda.cpp:20
void set(f32 pX, f32 pY, f32 pZ)
Definition c_xyz.h:82
f32 abs() const
Definition c_xyz.h:142
Definition d_a_ep.cpp:66
Definition d_a_npc_cd2.cpp:35
u16 m_num
Definition d_path.h:11
dStage_dPnt_c * m_points
Definition d_path.h:16
Vec m_position
Definition d_stage.h:299
u8 field_0x0
Definition d_stage.h:295
u8 mArg0
Definition d_stage.h:298
Definition d_a_formation_mng.h:10
bool checkPoint(cXyz, f32)
Definition d_a_formation_mng.cpp:195
s8 getArg0()
Definition d_a_formation_mng.h:15
bool checkPathEnd(cXyz, f32)
Definition d_a_formation_mng.cpp:178
int field_0x4
Definition d_a_formation_mng.h:90
s8 getArg1()
Definition d_a_formation_mng.h:16
void chgDir()
Definition d_a_formation_mng.h:18
void getStartPoint(Vec *param_1, SVec *param_2)
Definition d_a_formation_mng.h:35
s8 field_0xc
Definition d_a_formation_mng.h:92
void setPath(int param_1, int param_2, cXyz *param_3)
Definition d_a_formation_mng.h:28
int incIndex(int param_1)
Definition d_a_formation_mng.h:63
void setNextPoint()
Definition d_a_formation_mng.h:75
dPath * mPath
Definition d_a_formation_mng.h:89
int decIndex(int param_1)
Definition d_a_formation_mng.h:51
void setNextPoint(cXyz *param_1)
Definition d_a_formation_mng.h:84
void getTargetPoint(Vec *param_1)
Definition d_a_formation_mng.h:47
bool isPathClose()
Definition d_a_formation_mng.h:14
f32 field_0x8
Definition d_a_formation_mng.h:91
Definition d_a_formation_mng.h:133
FmtMember_c * mMember
Definition d_a_formation_mng.h:325
int field_0x580
Definition d_a_formation_mng.h:330
int getStartTime()
Definition d_a_formation_mng.h:179
void executeFight()
Definition d_a_formation_mng.cpp:334
void setMovePos(cXyz *param_1, s16 *param_2)
Definition d_a_formation_mng.h:268
void create_init()
Definition d_a_formation_mng.cpp:391
ActionFunc * mAction
Definition d_a_formation_mng.h:327
int mDayOfWeek
Definition d_a_formation_mng.h:335
u8 getFormationLine()
Definition d_a_formation_mng.h:177
void initFight()
Definition d_a_formation_mng.cpp:318
void initReverse()
Definition d_a_formation_mng.cpp:205
int execute()
Definition d_a_formation_mng.h:223
int mFormationLine
Definition d_a_formation_mng.h:331
int field_0x598
Definition d_a_formation_mng.h:336
void initMemberPos()
Definition d_a_formation_mng.cpp:30
void setAction(int i_action)
Definition d_a_formation_mng.h:215
int field_0x59c
Definition d_a_formation_mng.h:337
void setMemberPos()
Definition d_a_formation_mng.h:285
void executeWait()
Definition d_a_formation_mng.cpp:96
u8 getPathID()
Definition d_a_formation_mng.h:176
void setMoveSpeed()
Definition d_a_formation_mng.h:250
void callExecute()
Definition d_a_formation_mng.h:182
bool checkEmergency()
Definition d_a_formation_mng.h:187
int getTimeMinute()
Definition d_a_formation_mng.h:165
int mPrevAction
Definition d_a_formation_mng.h:329
bool isAllMemberCulling()
Definition d_a_formation_mng.h:231
int mFormationRow
Definition d_a_formation_mng.h:332
int create()
Definition d_a_formation_mng.cpp:384
void initWait()
Definition d_a_formation_mng.cpp:17
int mEndTime
Definition d_a_formation_mng.h:334
static FmtMngAttributes const & attr()
Definition d_a_formation_mng.h:318
int getEndTime()
Definition d_a_formation_mng.h:180
int getTimeHour()
Definition d_a_formation_mng.h:158
void executeReverse()
Definition d_a_formation_mng.cpp:218
dPath * mRoomPath
Definition d_a_formation_mng.h:326
void setMoveAngle(FmtPos_c *member)
Definition d_a_formation_mng.h:257
int field_0x5a0
Definition d_a_formation_mng.h:338
void setMovePath(FmtPos_c *, int)
Definition d_a_formation_mng.cpp:152
void correctFormation()
Definition d_a_formation_mng.h:273
int mStartTime
Definition d_a_formation_mng.h:333
FmtPos_c * mPos
Definition d_a_formation_mng.h:324
void executeWalk()
Definition d_a_formation_mng.cpp:138
void initMotion()
Definition d_a_formation_mng.cpp:264
void(daFmtMng_c::* ActionFunc)()
Definition d_a_formation_mng.h:321
u8 getFormationRow()
Definition d_a_formation_mng.h:178
static daFmtMng_c::ActionFunc ActionTable[10]
Definition d_a_formation_mng.h:86
~daFmtMng_c()
Definition d_a_formation_mng.h:149
int mCurrentAction
Definition d_a_formation_mng.h:328
void initWalk()
Definition d_a_formation_mng.cpp:126
void callInit()
Definition d_a_formation_mng.h:210
int getTime()
Definition d_a_formation_mng.h:172
static FmtMngAttributes const M_attr
Definition d_a_formation_mng.h:11
void executeMotion()
Definition d_a_formation_mng.cpp:300
static u32 i_checkNowWolf()
Definition d_a_player.h:969
static f32 getGroundY()
Definition f_op_actor_mng.h:133
void gndCheck(cXyz const *)
Definition f_op_actor_mng.cpp:2124
Definition d_a_ep.cpp:19
csXyz shape_angle
Definition f_op_actor.h:216
f32 speedF
Definition f_op_actor.h:227
void transS(cXyz const &)
Definition m_Do_mtx.cpp:358
static void YrotM(s16 y)
Definition m_Do_mtx.h:294
static void multVec(const Vec *a, Vec *b)
Definition m_Do_mtx.h:249
signed char s8
Definition types.h:4
unsigned long u32
Definition types.h:10
float f32
Definition types.h:22
signed short s16
Definition types.h:5
unsigned short u16
Definition types.h:9
unsigned char u8
Definition types.h:8