summaryrefslogtreecommitdiff
path: root/include/f_op/f_op_actor.h
blob: 0ba53b5fdc88454a6ff71eb83844ac11a6b640e4 (plain)
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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
#ifndef F_OP_ACTOR_H_
#define F_OP_ACTOR_H_

#include "SSystem/SComponent/c_sxyz.h"
#include "SSystem/SComponent/c_xyz.h"
#include "d/d_kankyo.h"
#include "f_pc/f_pc_leaf.h"
#include "global.h"

class J3DModel;

struct actor_method_class {
    /* 0x00 */ leafdraw_method_class base;
    /* 0x14 */ u8 field_0x14[0xC];  // Likely padding
};

// Unclear what this is. Only used by one actor (PLAYER)
struct actor_method_class2 {
    /* 0x00 */ actor_method_class base;
    /* 0x20 */ u32 field_0x20;
};

enum fopAc_Status_e {
    // Note: The lowest 5 bits of the status field (& 0x1F) act as an index controlling the map icon type.
    fopAcStts_SHOWMAP_e     = 0x00000020,
    fopAcStts_UNK40_e       = 0x00000040, // Related to talking to the Killer Bees?
    fopAcStts_NOCULLEXEC_e  = 0x00000080,
    fopAcStts_CULL_e        = 0x00000100,
    fopAcStts_FREEZE_e      = 0x00000400,
    fopAcStts_UNK800_e      = 0x00000800,
    fopAcStts_UNK1000_e     = 0x00001000, // Door related
    fopAcStts_CARRY_e       = 0x00002000,
    fopAcStts_UNK4000_e     = 0x00004000,
    fopAcStts_FORCEMOVE_e   = 0x00008000,
    fopAcStts_UNK10000_e    = 0x00010000,
    fopAcStts_NOPAUSE_e     = 0x00020000,
    fopAcStts_UNK40000_e    = 0x00040000,
    fopAcStts_UNK80000_e    = 0x00080000, // Hookshot related
    fopAcStts_HOOK_CARRY_e  = 0x00100000,
    fopAcStts_UNK200000_e   = 0x00200000, // Hookshot related
    fopAcStts_NODRAW_e      = 0x01000000,
    fopAcStts_UNK2000000_e  = 0x02000000,
    fopAcStts_BOSS_e        = 0x04000000,
    fopAcStts_UNK8000000_e  = 0x08000000,
    fopAcStts_UNK10000000_e = 0x10000000, // Hookshot related
};

enum fopAc_Condition_e {
    fopAcCnd_NOEXEC_e = 0x02,
    fopAcCnd_NODRAW_e = 0x04,
    fopAcCnd_INIT_e   = 0x08,
};

enum fopAc_Group_e {
    fopAc_ACTOR_e  = 0x0,
    fopAc_PLAYER_e = 0x1,
    fopAc_ENEMY_e  = 0x2,
    fopAc_ENV_e    = 0x3,
    fopAc_NPC_e    = 0x4,
};

enum fopAc_AttentionType_e {
    fopAc_Attn_TYPE_MISC_e     = 0x0, // "LOCK"
    fopAc_Attn_TYPE_TALK_e     = 0x1, // "TALK"
    fopAc_Attn_TYPE_BATTLE_e   = 0x2, // "BATL"
    fopAc_Attn_TYPE_SPEAK_e    = 0x3, // "SPEK"
    fopAc_Attn_TYPE_CARRY_e    = 0x4, // "CARY"
    fopAc_Attn_TYPE_DOOR_e     = 0x5, // "DOOR"
    fopAc_Attn_TYPE_TREASURE_e = 0x6, // "JUEL"
    fopAc_Attn_TYPE_SHIP_e     = 0x7,
};

enum fopAc_AttentionFlag_e {
    fopAc_Attn_LOCKON_MISC_e        = 0x00000001, // "LOCK"
    fopAc_Attn_LOCKON_TALK_e        = 0x00000002, // "TALK"
    fopAc_Attn_LOCKON_BATTLE_e      = 0x00000004, // "BATL"
    fopAc_Attn_ACTION_SPEAK_e       = 0x00000008, // "SPEK"
    fopAc_Attn_ACTION_CARRY_e       = 0x00000010, // "CARY"
    fopAc_Attn_ACTION_DOOR_e        = 0x00000020, // "DOOR"
    fopAc_Attn_ACTION_TREASURE_e    = 0x00000040, // "JUEL"
    fopAc_Attn_ACTION_SHIP_e        = 0x00000080,
    fopAc_Attn_UNK1000000_e         = 0x01000000,
    fopAc_Attn_TALKFLAG_NOTALK_e    = 0x02000000,
    fopAc_Attn_ENEMYFLAG_NOLOCKON_e = 0x04000000,
    fopAc_Attn_TALKFLAG_LOOK_e      = 0x08000000,
    fopAc_Attn_UNK10000000_e        = 0x10000000,
    fopAc_Attn_TALKFLAG_CHECK_e     = 0x20000000,
    fopAc_Attn_TALKFLAG_READ_e      = 0x40000000,
};

enum fopAc_Cull_e {
    /* 0x00 */ fopAc_CULLBOX_0_e,
    /* 0x01 */ fopAc_CULLBOX_1_e,
    /* 0x02 */ fopAc_CULLBOX_2_e,
    /* 0x03 */ fopAc_CULLBOX_3_e,
    /* 0x04 */ fopAc_CULLBOX_4_e,
    /* 0x05 */ fopAc_CULLBOX_5_e,
    /* 0x06 */ fopAc_CULLBOX_6_e,
    /* 0x07 */ fopAc_CULLBOX_7_e,
    /* 0x08 */ fopAc_CULLBOX_8_e,
    /* 0x09 */ fopAc_CULLBOX_9_e,
    /* 0x0A */ fopAc_CULLBOX_10_e,
    /* 0x0B */ fopAc_CULLBOX_11_e,
    /* 0x0C */ fopAc_CULLBOX_12_e,
    /* 0x0D */ fopAc_CULLBOX_13_e,
    /* 0x0E */ fopAc_CULLBOX_CUSTOM_e,
    /* 0x0F */ fopAc_CULLSPHERE_0_e,
    /* 0x10 */ fopAc_CULLSPHERE_1_e,
    /* 0x11 */ fopAc_CULLSPHERE_2_e,
    /* 0x12 */ fopAc_CULLSPHERE_3_e,
    /* 0x13 */ fopAc_CULLSPHERE_4_e,
    /* 0x14 */ fopAc_CULLSPHERE_5_e,
    /* 0x15 */ fopAc_CULLSPHERE_6_e,
    /* 0x16 */ fopAc_CULLSPHERE_7_e,
    /* 0x17 */ fopAc_CULLSPHERE_CUSTOM_e,
};

struct actor_process_profile_definition {
    /* 0x00 */ leaf_process_profile_definition base;
    /* 0x24 */ actor_method_class* sub_method;
    /* 0x28 */ u32 status;
    /* 0x2C */ u8 group;
    /* 0x2D */ u8 cullType;
};  // Size: 0x30

// Unclear what this is. Only appears in 2 profiles (PLAYER,BG)
struct actor_process_profile_definition2 {
    /* 0x00 */ actor_process_profile_definition def;
    /* 0x30 */ u32 field_0x30;
};  // Size: 0x34

class JKRSolidHeap;

enum dEvt_Command_e {
    dEvtCmd_NONE_e      = 0x0000,
    dEvtCmd_INTALK_e    = 0x0001,
    dEvtCmd_INDEMO_e    = 0x0002,
    dEvtCmd_INDOOR_e    = 0x0003,
    dEvtCmd_INGETITEM_e = 0x0004,
    dEvtCmd_INCATCH_e   = 0x0006,
};

enum dEvt_Condition_e {
    dEvtCnd_NONE_e        = 0x0000,
    dEvtCnd_CANTALK_e     = 0x0001,
    dEvtCnd_UNK2_e        = 0x0002,
    dEvtCnd_CANDOOR_e     = 0x0004,
    dEvtCnd_CANGETITEM_e  = 0x0008,
    dEvtCnd_UNK10_e       = 0x0010,
    dEvtCnd_CANTALKITEM_e = 0x0020,
    dEvtCnd_CANCATCH_e    = 0x0040,
};

// TODO: move to d_event.h
class dEvt_info_c {
public:
    typedef s16 (*CallbackFunc)(void*, int);

    dEvt_info_c();
    virtual ~dEvt_info_c() {}
    void setEventName(char*);
    char* getEventName();

    void setToolId(u8 id) { mMapToolId = id; }
    s16 getEventId() { return mEventId; }
    void setEventId(s16 id) { mEventId = id; }

    u16 getCondition() { return mCondition; }
    void setCondition(u16 condition) { mCondition = condition; }
    BOOL chkCondition(u16 condition) { return (mCondition & condition) == condition; }
    void onCondition(u16 cond) { mCondition |= cond; }
    void beforeProc() { mCondition = dEvtCnd_NONE_e; }

    BOOL checkCommandTalk() { return mCommand == dEvtCmd_INTALK_e; }
    BOOL checkCommandItem() { return mCommand == dEvtCmd_INGETITEM_e; }
    BOOL checkCommandDoor() { return mCommand == dEvtCmd_INDOOR_e; }
    BOOL checkCommandDemoAccrpt() { return mCommand == dEvtCmd_INDEMO_e; }
    BOOL checkCommandCatch() { return mCommand == dEvtCmd_INCATCH_e; }
    u16 getCommand() { return mCommand; }
    void setCommand(u16 command) { mCommand = command; }

    void setXyEventCB(CallbackFunc cb) { mpEventCB = cb; }
    s16 runXyEventCB(void* i_actor, int i_itemBtn) {
        if (mpEventCB == NULL)
            return -1;
        return mpEventCB(i_actor, i_itemBtn);
    }
    void setXyCheckCB(CallbackFunc cb) { mpCheckCB = cb; }
    s16 runXyCheckCB(void* i_actor, int i_itemBtn) {
        if (mpCheckCB == NULL)
            return true;
        return mpCheckCB(i_actor, i_itemBtn);
    }
    void setPhotoEventCB(CallbackFunc cb) { mpPhotoCB = cb; }
    s16 runPhotoEventCB(void* i_actor, int i_itemBtn) {
        if (mpPhotoCB == NULL)
            return -1;
        return mpPhotoCB(i_actor, i_itemBtn);
    }

public:
    /* 0x04 */ u16 mCommand;
    /* 0x06 */ u16 mCondition;
    /* 0x08 */ s16 mEventId;
    /* 0x0A */ u8 mMapToolId;
    /* 0x0B */ s8 mIndex;
    /* 0x0C */ CallbackFunc mpEventCB;
    /* 0x10 */ CallbackFunc mpCheckCB;
    /* 0x14 */ CallbackFunc mpPhotoCB;
};  // Size = 0x18

struct actor_place {
    /* 0x00 */ cXyz pos;
    /* 0x0C */ csXyz angle;
    /* 0x12 */ s8 roomNo;
    /* 0x13 */ u8 field_0x13;
};

struct actor_attention_types {
    /* 0x00 */ u8 distances[8];
    /* 0x08 */ cXyz position;
    /* 0x14 */ u32 flags;
};  // Size = 0x18

class JntHit_c;

struct fopAc_cullSizeSphere {
public:
#ifdef __MWERKS__
    fopAc_cullSizeSphere() {}
    ~fopAc_cullSizeSphere() {}
#else
    fopAc_cullSizeSphere() = default;
    ~fopAc_cullSizeSphere() = default;
#endif
    fopAc_cullSizeSphere(cXyz p, f32 r) {
        center = p;
        radius = r;
    }

    /* 0x0 */ cXyz center;
    /* 0xC */ f32 radius;
};

struct fopAc_cullSizeBox {
public:
#ifdef __MWERKS__
    fopAc_cullSizeBox() {}
    ~fopAc_cullSizeBox() {}
    fopAc_cullSizeBox(const fopAc_cullSizeBox& box) {
        min = box.min;
        max = box.max;
    }
#else
    fopAc_cullSizeBox() = default;
    ~fopAc_cullSizeBox() = default;
    fopAc_cullSizeBox(const fopAc_cullSizeBox& box) = default;
#endif
    fopAc_cullSizeBox(cXyz min, cXyz max) {
        this->min = min;
        this->max = max;
    }

    /* 0x0 */ cXyz min;
    /* 0xC */ cXyz max;
};

class fopAc_ac_c {
public:
    /* 0x000 */ leafdraw_class base;
    /* 0x0C0 */ int actor_type;
    /* 0x0C4 */ create_tag_class actor_tag;
    /* 0x0D8 */ create_tag_class draw_tag;
    /* 0x0EC */ actor_method_class* sub_method;
    /* 0x0F0 */ JKRSolidHeap* heap;
    /* 0x0F4 */ dEvt_info_c eventInfo;
    /* 0x10C */ dKy_tevstr_c tevStr;
    /* 0x1BC */ u16 setID;
    /* 0x1BE */ u8 group;
    /* 0x1BF */ u8 cullType;
    /* 0x1C0 */ u8 demoActorID;
    /* 0x1C1 */ s8 argument;
    /* 0x1C2 */ u8 gbaName;
    /* 0x1C4 */ u32 actor_status;
    /* 0x1C8 */ u32 actor_condition;
    /* 0x1CC */ fpc_ProcID parentActorID;
    /* 0x1D0 */ actor_place home;
    /* 0x1E4 */ actor_place old;
    /* 0x1F8 */ actor_place current;
    /* 0x20C */ csXyz shape_angle;
    /* 0x214 */ cXyz scale;
    /* 0x220 */ cXyz speed;
    /* 0x22C */ MtxP cullMtx;
    union {
        /* 0x230 */ fopAc_cullSizeBox box;
        /* 0x230 */ fopAc_cullSizeSphere sphere;
    } cull;
    /* 0x248 */ f32 cullSizeFar;
    /* 0x24C */ J3DModel* model;
    /* 0x250 */ JntHit_c* jntHit;
    /* 0x254 */ f32 speedF;
    /* 0x258 */ f32 gravity;
    /* 0x25C */ f32 maxFallSpeed;
    /* 0x260 */ cXyz eyePos;
    /* 0x26C */ actor_attention_types attention_info;
    /* 0x284 */ s8 max_health;
    /* 0x285 */ s8 health;
    /* 0x288 */ int itemTableIdx;
    /* 0x28C */ u8 stealItemBitNo; // For limited items (Blue Chu Jelly), this is the first itemBitNo to set.
    /* 0x28D */ s8 stealItemLeft;

    fopAc_ac_c();
    ~fopAc_ac_c();

    static u32 stopStatus;

    static u32 getStopStatus() { return stopStatus; }
    static void setStopStatus(u32 status) { stopStatus = status; }
};  // Size: 0x290

STATIC_ASSERT(sizeof(fopAc_ac_c) == 0x290);

class fopEn_enemy_c : public fopAc_ac_c {
public:
    enum ParryOpeningType {
        OPENING_NONE = 0,
        OPENING_JUMP_PARRY = 1,
        OPENING_ROLL_PARRY = 2,
        OPENING_VERTICAL_JUMP_PARRY = 3,
        OPENING_GANONDORF_FINISHER_PARRY = 4,
    };
    
    void initBt(f32 height, f32 radius) {
        setBtHeight(height);
        setBtBodyR(radius);
    }
    f32 getBtHeight() const { return mBtHeight; }
    void setBtHeight(f32 height) { mBtHeight = height; }
    f32 getBtBodyR() const { return mBtBodyR; }
    void setBtBodyR(f32 radius) { mBtBodyR = radius; }
    
    void setBtAttackData(f32 startFrame, f32 endFrame, f32 maxDis, u8 attackType) {
        setBtStartFrame(startFrame);
        setBtEndFrame(endFrame);
        setBtMaxDis(maxDis);
        setBtAttackType(attackType);
    }
    f32 getBtStartFrame() const { return mBtStartFrame; }
    void setBtStartFrame(f32 frame) { mBtStartFrame = frame; }
    f32 getBtEndFrame() const { return mBtEndFrame; }
    void setBtEndFrame(f32 frame) { mBtEndFrame = frame; }
    f32 getBtNowFrame() const { return mBtNowFrame; }
    void setBtNowFrame(f32 frame) { mBtNowFrame = frame; }
    u8 getBtAttackType() const { return mBtAttackType; }
    void setBtAttackType(u8 type) { mBtAttackType = type; }
    f32 getBtMaxDis() const { return mBtMaxDis; }
    void setBtMaxDis(f32 dis) { mBtMaxDis = dis; }
    
    /* 0x290 */ f32 mBtHeight;
    /* 0x294 */ f32 mBtBodyR;
    /* 0x298 */ f32 mBtMaxDis;
    /* 0x29C */ f32 mBtStartFrame;
    /* 0x2A0 */ f32 mBtEndFrame;
    /* 0x2A4 */ f32 mBtNowFrame;
    /* 0x2A8 */ u8 mBtAttackType; // Which type of parry opening to give the player
    /* 0x2A9 */ u8 field_2A9[0x2AC - 0x2A9];
};  // Size: 0x2AC

STATIC_ASSERT(sizeof(fopEn_enemy_c) == 0x2AC);

BOOL fopAc_IsActor(void* actor);

extern int g_fopAc_type;
extern actor_method_class g_fopAc_Method;

#endif