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 bool checkPathEnd(cXyz, f32);
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) {
29 mPath = dPath_GetRoomPath(param_1, param_2);
30 field_0x4 = 0;
31 field_0xc = 1;
32 field_0x8 = param_3->abs(dPath_GetPnt(mPath, field_0x4)->m_position);
33 }
34
35 void getStartPoint(Vec* param_1, SVec* param_2) {
36 *param_1 = dPath_GetPnt(mPath, 0)->m_position;
37 Vec local_2c = dPath_GetPnt(mPath, 1)->m_position;
38 cXyz cStack_38(param_1->x, param_1->y + 200.0f, param_1->z);
39 if (fopAcM_gc_c::gndCheck(&cStack_38)) {
40 param_1->y = fopAcM_gc_c::getGroundY();
41 }
42 param_2->x = 0;
43 param_2->y = cLib_targetAngleY(param_1, &local_2c);
44 param_2->z = 0;
45 }
46
47 void getTargetPoint(Vec* param_1) {
49 }
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 = G_CM3D_F_INF;
82 }
83
84 void setNextPoint(cXyz *param_1) {
86 field_0x8 = param_1->abs(dPath_GetPnt(mPath, field_0x4)->m_position);
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 /* 0x10 */ cXyz field_0x10;
97 /* 0x1C */ s16 field_0x1c;
98 /* 0x1E */ s16 field_0x1e;
99};
100
102 /* 0x00 */ u32 mNpcId;
103 /* 0x04 */ cXyz field_0x04;
104 /* 0x10 */ cXyz field_0x10;
105 /* 0x1C */ s16 field_0x1c;
106 /* 0x1E */ u16 field_0x1e;
107};
108
117
119 /* 0x00 */ int field_0x00;
120 /* 0x04 */ f32 field_0x04;
121 /* 0x08 */ f32 field_0x08;
122 /* 0x0C */ f32 field_0x0c;
123 /* 0x10 */ f32 field_0x10;
124 /* 0x14 */ s16 field_0x14;
125 /* 0x16 */ s16 field_0x16;
126};
127
128struct daFmtMng_c : public fopAc_ac_c {
129 void initWait();
130 void initMemberPos();
131 void executeWait();
132 void initWalk();
133 void executeWalk();
134 void setMovePath(FmtPos_c*, int);
135 void initReverse();
136 void executeReverse();
137 void initMotion();
138 void executeMotion();
139 void initFight();
140 void executeFight();
141 int create();
142 void create_init();
143
145 FmtMember_c* member = mMember;
146 for (int i = 0; i < mFormationLine * mFormationRow; i++, member++) {
147 fopAcM_delete(member->mNpcId);
148 }
149 delete [] mPos;
150 delete [] mMember;
151 }
152
154 if (dKy_darkworld_check()) {
155 return dKy_getDarktime_hour();
156 }
157 return dKy_getdaytime_hour();
158 }
159
161 if (dKy_darkworld_check()) {
162 return dKy_getDarktime_minute();
163 }
164 return dKy_getdaytime_minute();
165 }
166
167 int getTime() {
168 return getTimeHour() * 60 + getTimeMinute();
169 }
170
171 u8 getPathID() { return shape_angle.x; }
172 u8 getFormationLine() { return fopAcM_GetParam(this) & 0xff; }
173 u8 getFormationRow() { return (fopAcM_GetParam(this) >> 8) & 0xff; }
174 int getStartTime() { return (fopAcM_GetParam(this) >> 16) & 0xff; }
175 int getEndTime() { return (fopAcM_GetParam(this) >> 24) & 0xff; }
176
177 void callExecute() {
178 JUT_ASSERT(680, mAction != NULL);
179 (this->*(mAction[1]))();
180 }
181
184 return false;
185 }
186 FmtMember_c* member = mMember;
187 fopAc_ac_c* npcFgd = NULL;
188 for (int i = 0; i < mFormationRow * mFormationLine; i++, member++) {
189 fopAcM_SearchByID(member->mNpcId, &npcFgd);
190 if (npcFgd != NULL) {
192 f32 dVar10 = iVar6->y;
193 cXyz* this_01 = fopAcM_GetPosition_p(npcFgd);
194 if (this_01->y - dVar10 < 200.0f) {
195 f32 maxDist = pow(500.0, 2.0);
196 if (fopAcM_searchPlayerDistanceXZ2(npcFgd) < maxDist) {
197 return true;
198 }
199 }
200 }
201 }
202 return false;
203 }
204
205 void callInit() {
206 JUT_ASSERT(667, mAction != NULL)
207 (this->*(*mAction))();
208 }
209
210 void setAction(int i_action) {
211 JUT_ASSERT(633, i_action < MODE_MAX_e);
213 mCurrentAction = i_action;
215 callInit();
216 }
217
218 int execute() {
219 callExecute();
222 }
223 return 1;
224 }
225
227 FmtMember_c* member = mMember;
228 bool memberCulling;
229 fopAc_ac_c* npcFgd = NULL;
230 for (int i = 0; i < mFormationRow * mFormationLine; i++, member++) {
231 memberCulling = false;
232 if (member->mNpcId != -1) {
233 fopAcM_SearchByID(member->mNpcId, &npcFgd);
234 if (npcFgd != NULL) {
235 memberCulling = fopAcM_CheckCondition(npcFgd, 4);
236 }
237 if (!memberCulling) {
238 return false;
239 }
240 }
241 }
242 return true;
243 }
244
247 if (speedF > attr().field_0x04) {
249 }
250 }
251
252 void setMoveAngle(FmtPos_c* member) {
253 if (speedF <= 0.0f) {
254 return;
255 }
256 cXyz acStack_28;
257 member->getTargetPoint(&acStack_28);
259 cLib_targetAngleY(&member->field_0x10, &acStack_28),
260 attr().field_0x14, attr().field_0x16);
261 }
262
263 void setMovePos(cXyz* param_1, s16* param_2) {
264 param_1->x += speedF * cM_ssin(*param_2);
265 param_1->z += speedF * cM_scos(*param_2);
266 }
267
269 FmtPos_c* pos = mPos + 1;
270 for (int i = 1; i < mFormationRow; i++, pos++) {
271 if (cLib_distanceAngleS(pos[-1].field_0x1c, pos[0].field_0x1c) <= attr().field_0x00) {
272 pos[0].field_0x10.set(0.0f, 0.0f, -attr().field_0x10);
274 mDoMtx_stack_c::YrotM(pos[-1].field_0x1c);
276 }
277 }
278 }
279
281 int j;
282 FmtPos_c* pos;
283 fopAc_ac_c* npcFgd;
284 FmtMember_c* member;
285 int i;
286 pos = mPos;
287 member = mMember;
288 for (i = 0; i < mFormationRow; i++, pos++) {
289 f32 dVar13 = (mFormationLine - 1) * attr().field_0x0c * 0.5f;
292 for (j = 0; j < mFormationLine; j++, member++) {
293 member->field_0x10.set(member->field_0x04);
294 member->field_0x04.set(dVar13, 0.0f, 0.0f);
296 dVar13 -= attr().field_0x0c;
297 npcFgd = NULL;
298 fopAcM_SearchByID(member->mNpcId, &npcFgd);
299 if (npcFgd != NULL) {
300 cXyz* npcPos = fopAcM_GetPosition_p(npcFgd);
301 csXyz* npcAngle = fopAcM_GetShapeAngle_p(npcFgd);
302 npcPos->x = member->field_0x04.x;
303 npcPos->z = member->field_0x04.z;
304 cLib_addCalcAngleS2(&npcAngle->y,
305 cLib_targetAngleY(&member->field_0x10, &member->field_0x04),
306 attr().field_0x14, attr().field_0x16);
307 fopAcM_SetSpeedF(npcFgd, member->field_0x10.abs(member->field_0x04));
308 }
309 }
310 }
311 }
312
313 static FmtMngAttributes const& attr() { return M_attr; }
314 static FmtMngAttributes const M_attr;
315
316 typedef void (daFmtMng_c::*ActionFunc)();
318
319 /* 0x568 */ FmtPos_c* mPos;
320 /* 0x56C */ FmtMember_c* mMember;
321 /* 0x570 */ dPath* mRoomPath;
322 /* 0x574 */ ActionFunc* mAction;
323 /* 0x578 */ int mCurrentAction;
324 /* 0x57C */ int mPrevAction;
325 /* 0x580 */ int field_0x580;
326 /* 0x584 */ int mFormationLine;
327 /* 0x588 */ int mFormationRow;
328 /* 0x58C */ int mStartTime;
329 /* 0x590 */ int mEndTime;
330 /* 0x594 */ int mDayOfWeek;
331 /* 0x598 */ int field_0x598;
332 /* 0x59C */ int field_0x59c;
333 /* 0x5A0 */ int field_0x5a0;
334};
335
336#endif /* D_A_FORMATION_MNG_H */
s32 cLib_distanceAngleS(s16 x, s16 y)
Definition c_lib.cpp:482
void cLib_addCalcAngleS2(s16 *pvalue, s16 target, s16 scale, s16 maxStep)
Definition c_lib.cpp:273
s16 cLib_targetAngleY(const Vec *lhs, const Vec *rhs)
Definition c_lib.cpp:435
f32 cM_ssin(s16 x)
Definition c_math.h:23
f32 cM_scos(s16 x)
Definition c_math.h:19
Definition c_sxyz.h:10
static u32 checkNowWolf()
Definition d_a_player.h:1156
static f32 getGroundY()
Definition f_op_actor_mng.h:905
static bool gndCheck(const cXyz *)
Definition f_op_actor_mng.cpp:1994
Definition f_op_actor.h:230
csXyz shape_angle
Definition f_op_actor.h:252
f32 speedF
Definition f_op_actor.h:263
static void YrotM(s16 y)
Definition m_Do_mtx.h:298
static void multVec(const Vec *a, Vec *b)
Definition m_Do_mtx.h:253
static void transS(cXyz const &xyz)
Definition m_Do_mtx.cpp:360
FmtMngAction
Definition d_a_formation_mng.h:109
@ MODE_1_e
Definition d_a_formation_mng.h:111
@ MODE_0_e
Definition d_a_formation_mng.h:110
@ MODE_2_e
Definition d_a_formation_mng.h:112
@ MODE_MAX_e
Definition d_a_formation_mng.h:115
@ MODE_3_e
Definition d_a_formation_mng.h:113
@ MODE_4_e
Definition d_a_formation_mng.h:114
f32 field_0x10
Definition d_a_npc_coach.cpp:579
f32 field_0x14
Definition d_a_npc_coach.cpp:580
daPy_py_c * daPy_getPlayerActorClass()
Definition d_a_player.h:1260
int dKy_getdaytime_hour()
Definition d_kankyo.cpp:1711
int dKy_getDarktime_hour()
Definition d_kankyo.cpp:1731
u8 dKy_darkworld_check()
Definition d_kankyo.cpp:11379
int dKy_getdaytime_minute()
Definition d_kankyo.cpp:1716
int dKy_getDarktime_minute()
Definition d_kankyo.cpp:1736
dPath * dPath_GetRoomPath(int path_index, int room_no)
Definition d_path.cpp:19
dPnt * dPath_GetPnt(dPath const *path, int pnt_index)
Definition d_path.cpp:11
BOOL dPath_ChkClose(const dPath *i_path)
Definition d_path.h:28
signed char s8
Definition types.h:7
unsigned long u32
Definition types.h:12
signed short int s16
Definition types.h:9
float f32
Definition types.h:25
unsigned short int u16
Definition types.h:10
unsigned char u8
Definition types.h:8
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:123
s32 fopAcM_delete(fopAc_ac_c *i_actor)
Definition f_op_actor_mng.cpp:205
u32 fopAcM_CheckCondition(fopAc_ac_c *i_actor, u32 flag)
Definition f_op_actor_mng.h:264
void fopAcM_SetSpeedF(fopAc_ac_c *actor, f32 f)
Definition f_op_actor_mng.h:324
u32 fopAcM_GetParam(const void *i_actor)
Definition f_op_actor_mng.h:192
cXyz * fopAcM_GetPosition_p(fopAc_ac_c *i_actor)
Definition f_op_actor_mng.h:236
f32 fopAcM_searchPlayerDistanceXZ2(const fopAc_ac_c *actor)
Definition f_op_actor_mng.h:739
csXyz * fopAcM_GetShapeAngle_p(fopAc_ac_c *i_actor)
Definition f_op_actor_mng.h:260
double pow(double, double)
Definition w_pow.c:3
Definition d_a_formation_mng.h:101
cXyz field_0x10
Definition d_a_formation_mng.h:104
u16 field_0x1e
Definition d_a_formation_mng.h:106
cXyz field_0x04
Definition d_a_formation_mng.h:103
u32 mNpcId
Definition d_a_formation_mng.h:102
s16 field_0x1c
Definition d_a_formation_mng.h:105
Definition d_a_formation_mng.h:118
f32 field_0x10
Definition d_a_formation_mng.h:123
f32 field_0x08
Definition d_a_formation_mng.h:121
s16 field_0x14
Definition d_a_formation_mng.h:124
s16 field_0x16
Definition d_a_formation_mng.h:125
f32 field_0x04
Definition d_a_formation_mng.h:120
int field_0x00
Definition d_a_formation_mng.h:119
f32 field_0x0c
Definition d_a_formation_mng.h:122
Definition d_a_formation_mng.h:95
s16 field_0x1e
Definition d_a_formation_mng.h:98
s16 field_0x1c
Definition d_a_formation_mng.h:97
cXyz field_0x10
Definition d_a_formation_mng.h:96
Definition c_sxyz.h:6
s16 x
Definition c_sxyz.h:7
s16 z
Definition c_sxyz.h:7
s16 y
Definition c_sxyz.h:7
Definition mtx.h:13
f32 z
Definition mtx.h:14
f32 x
Definition mtx.h:14
f32 y
Definition mtx.h:14
Definition c_xyz.h:7
void set(f32 pX, f32 pY, f32 pZ)
Definition c_xyz.h:97
f32 abs() const
Definition c_xyz.h:137
Definition d_path.h:18
u16 m_num
Definition d_path.h:19
dPnt * m_points
Definition d_path.h:25
Vec m_position
Definition d_path.h:15
u8 mArg0
Definition d_path.h:14
u8 mArg1
Definition d_path.h:11
Definition d_a_formation_mng.h:10
bool checkPoint(cXyz, f32)
Definition d_a_formation_mng.cpp:168
s8 getArg0()
Definition d_a_formation_mng.h:15
bool checkPathEnd(cXyz, f32)
Definition d_a_formation_mng.cpp:152
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:128
FmtMember_c * mMember
Definition d_a_formation_mng.h:320
int field_0x580
Definition d_a_formation_mng.h:325
int getStartTime()
Definition d_a_formation_mng.h:174
void executeFight()
Definition d_a_formation_mng.cpp:301
void setMovePos(cXyz *param_1, s16 *param_2)
Definition d_a_formation_mng.h:263
void create_init()
Definition d_a_formation_mng.cpp:350
ActionFunc * mAction
Definition d_a_formation_mng.h:322
int mDayOfWeek
Definition d_a_formation_mng.h:330
u8 getFormationLine()
Definition d_a_formation_mng.h:172
void initFight()
Definition d_a_formation_mng.cpp:286
void initReverse()
Definition d_a_formation_mng.cpp:177
int execute()
Definition d_a_formation_mng.h:218
int mFormationLine
Definition d_a_formation_mng.h:326
int field_0x598
Definition d_a_formation_mng.h:331
void initMemberPos()
Definition d_a_formation_mng.cpp:29
void setAction(int i_action)
Definition d_a_formation_mng.h:210
int field_0x59c
Definition d_a_formation_mng.h:332
void setMemberPos()
Definition d_a_formation_mng.h:280
void executeWait()
Definition d_a_formation_mng.cpp:74
u8 getPathID()
Definition d_a_formation_mng.h:171
void setMoveSpeed()
Definition d_a_formation_mng.h:245
void callExecute()
Definition d_a_formation_mng.h:177
bool checkEmergency()
Definition d_a_formation_mng.h:182
int getTimeMinute()
Definition d_a_formation_mng.h:160
int mPrevAction
Definition d_a_formation_mng.h:324
bool isAllMemberCulling()
Definition d_a_formation_mng.h:226
int mFormationRow
Definition d_a_formation_mng.h:327
int create()
Definition d_a_formation_mng.cpp:344
void initWait()
Definition d_a_formation_mng.cpp:17
int mEndTime
Definition d_a_formation_mng.h:329
static FmtMngAttributes const & attr()
Definition d_a_formation_mng.h:313
int getEndTime()
Definition d_a_formation_mng.h:175
int getTimeHour()
Definition d_a_formation_mng.h:153
void executeReverse()
Definition d_a_formation_mng.cpp:189
dPath * mRoomPath
Definition d_a_formation_mng.h:321
void setMoveAngle(FmtPos_c *member)
Definition d_a_formation_mng.h:252
int field_0x5a0
Definition d_a_formation_mng.h:333
void setMovePath(FmtPos_c *, int)
Definition d_a_formation_mng.cpp:127
void correctFormation()
Definition d_a_formation_mng.h:268
int mStartTime
Definition d_a_formation_mng.h:328
FmtPos_c * mPos
Definition d_a_formation_mng.h:319
void executeWalk()
Definition d_a_formation_mng.cpp:114
void initMotion()
Definition d_a_formation_mng.cpp:234
void(daFmtMng_c::*) ActionFunc()
Definition d_a_formation_mng.h:316
u8 getFormationRow()
Definition d_a_formation_mng.h:173
static daFmtMng_c::ActionFunc ActionTable[10]
Definition d_a_formation_mng.h:65
~daFmtMng_c()
Definition d_a_formation_mng.h:144
int mCurrentAction
Definition d_a_formation_mng.h:323
void initWalk()
Definition d_a_formation_mng.cpp:103
void callInit()
Definition d_a_formation_mng.h:205
int getTime()
Definition d_a_formation_mng.h:167
static FmtMngAttributes const M_attr
Definition d_a_formation_mng.h:12
void executeMotion()
Definition d_a_formation_mng.cpp:269