summaryrefslogtreecommitdiff
path: root/include/actor_types.h
blob: 9c41a2e0dd042e9ed679f08730f3473617d37e79 (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
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
#ifndef ACTOR_TYPES_H
#define ACTOR_TYPES_H

#include <libultraship.h>
#include <macros.h>
#include <common_structs.h>

// #pragma GCC diagnostic push
// #pragma GCC diagnostic ignored "-Wmicrosoft-extension"
// #pragma GCC diagnostic ignored "-Wmissing-member-name-in-structure-/-union"

/**
 * gActorList should be understood to be populated by generic Actor structs.
 * However, for human readability, many functions interacting with actor list elements expect one of the many
 * specialized types found in this file.
 *
 * Note that specialized types must be the same size as a plain Actor. Don't be mislead into thinking that
 * because its a separate type that it can modified separately from plain Actor. If you modify/add an actor type
 * and its size is different from plain Actor's, you WILL run into buggy (potentially crash inducing) behaviour.
 *
 * Specialized structs are customizable so long as the following member specifications are met:
 *
 * In general:
 *     0x00 -> s16 type
 *     0x02 -> s16 flags
 *     0x30 -> Collision unk30
 *
 * If player can collide with the actor:
 *     0x0C -> f32 boundingBoxSize
 *
 * If the actor makes sound (necessary for doppler/volume stuff):
 *     0x18 -> Vec3f pos
 *     0x24 -> Vec3f velocity
 *
 * Other members are more flexible, and even the non-general specifications can be ignored IF AND ONLY IF you know
 * exactly what you're doing.
 */
enum ActorType {
    ACTOR_UNKNOWN_0x01 = 0x01,
    ACTOR_TREE_MARIO_RACEWAY,
    ACTOR_TREE_YOSHI_VALLEY,
    ACTOR_TREE_ROYAL_RACEWAY,
    ACTOR_FALLING_ROCK,
    ACTOR_BANANA,
    ACTOR_GREEN_SHELL,
    ACTOR_RED_SHELL,
    ACTOR_YOSHI_EGG,
    ACTOR_PIRANHA_PLANT,
    ACTOR_UNKNOWN_0x0B,
    ACTOR_ITEM_BOX,
    ACTOR_FAKE_ITEM_BOX,
    ACTOR_BANANA_BUNCH,
    ACTOR_TRAIN_ENGINE,
    ACTOR_TRAIN_TENDER,
    ACTOR_TRAIN_PASSENGER_CAR,
    ACTOR_COW,
    ACTOR_TREE_MOO_MOO_FARM,
    ACTOR_UNKNOWN_0x14,
    ACTOR_TRIPLE_GREEN_SHELL,
    ACTOR_TRIPLE_RED_SHELL,
    ACTOR_MARIO_SIGN,
    ACTOR_UNKNOWN_0x18,
    ACTOR_PALM_TREE,
    ACTOR_UNKNOWN_0x1A,
    ACTOR_UNKNOWN_0x1B,
    ACTOR_TREE_BOWSERS_CASTLE,
    ACTOR_TREE_FRAPPE_SNOWLAND,
    ACTOR_CACTUS1_KALAMARI_DESERT,
    ACTOR_CACTUS2_KALAMARI_DESERT,
    ACTOR_CACTUS3_KALAMARI_DESERT,
    ACTOR_BUSH_BOWSERS_CASTLE,
    ACTOR_UNKNOWN_0x21,
    ACTOR_WARIO_SIGN,
    ACTOR_UNKNOWN_0x23,
    ACTOR_BOX_TRUCK,
    ACTOR_PADDLE_BOAT,
    ACTOR_RAILROAD_CROSSING,
    ACTOR_SCHOOL_BUS,
    ACTOR_TANKER_TRUCK,
    ACTOR_BLUE_SPINY_SHELL,
    ACTOR_HOT_AIR_BALLOON_ITEM_BOX,
    ACTOR_CAR,
    ACTOR_KIWANO_FRUIT
};

#define ACTOR_LIST_SIZE 100

// Actor flags
#define ACTOR_IS_NOT_EXPIRED 0xF // The actor possesses some kind of collision and can be removed

// Actor shell->state (green, red and blue)
enum ShellState {
    HELD_SHELL,                  // Single shell that has not been dropped. (probably holding Z).
    RELEASED_SHELL,              // This is the short window where single shells aren't being held or launched.
    MOVING_SHELL,                // Moving towards its target after being shot.
    RED_SHELL_LOCK_ON,           // Red shell is targeting.
    TRIPLE_GREEN_SHELL,          // Loses triple shell state when shot.
    GREEN_SHELL_HIT_A_RACER,     // A racer has been hit by a green shell.
    TRIPLE_RED_SHELL,            // Loses triple shell state when shot.
    DESTROYED_SHELL,             // Collision with the shell.
    BLUE_SHELL_LOCK_ON,          // A blue shell has found a target and is hastily approaching it.
    BLUE_SHELL_TARGET_ELIMINATED // Mission completed, well done boss.
};

// Actor banana->state
enum BananaState {
    HELD_BANANA,               // Single banana that has not been dropped.
    DROPPED_BANANA,            // A banana in the state of being dropped on the ground (it only last for a few frames).
    FIRST_BANANA_BUNCH_BANANA, // The first banana of the banana bunch
    BANANA_BUNCH_BANANA,       // Every banana of the banana bunch except the first one.
    BANANA_ON_GROUND,          // A banana sitting on the ground.
    DESTROYED_BANANA           // Collision with the banana.
};

// Actor fakeItemBox->state
#define HELD_FAKE_ITEM_BOX 0      // Item box is being held be Z.
#define FAKE_ITEM_BOX_ON_GROUND 1 // Item box is on the ground.
#define DESTROYED_FAKE_ITEM_BOX 2 // Collision with fake item box.

struct Actor {
    /* 0x00 */ s16 type;
    /* 0x02 */ s16 flags;
    /* 0x04 */ s16 unk_04;
    /* 0x06 */ s16 state;
    /* 0x08 */ f32 unk_08;
    /* 0x0C */ f32 boundingBoxSize;
    /* 0x10 */ Vec3s rot;
    /* 0x16 */ s16 unk_16;
    /* 0x18 */ Vec3f pos;
    /* 0x24 */ Vec3f velocity;
    /* 0x30 */ Collision unk30;
}; // size = 0x70

// Duplicate declare for simplicity when externing actors & packed files.
extern struct Actor gActorList[ACTOR_LIST_SIZE]; // D_8015F9B8

/*
Specialized actor types
*/

/*
Used by the locomotive, tender, and passenger car
*/
struct TrainCar {
    /* 0x00 */ s16 type;
    /* 0x02 */ s16 flags;
    /* 0x04 */ s16 unk_04;
    /* 0x06 */ s16 wheelRot;
    /* 0x08 */ f32 unk_08;
    /* 0x0C */ f32 unk_0C;
    /* 0x10 */ Vec3s rot;
    /* 0x10 */ s16 unk_16;
    /* 0x18 */ Vec3f pos;
    /* 0x24 */ Vec3f velocity;
    /* 0x30 */ Collision unk30;
}; // size = 0x70

struct RailroadCrossing {
    /* 0x00 */ s16 type;
    /* 0x02 */ s16 flags;
    /* 0x04 */ s16 someTimer;
    /* 0x06 */ s16 crossingId;
    /* 0x08 */ f32 unk_08;
    /* 0x0C */ f32 unk_0C;
    /* 0x10 */ Vec3s rot;
    /* 0x16 */ s16 unk_16;
    /* 0x18 */ Vec3f pos;
    /* 0x24 */ Vec3f velocity;
    /* 0x30 */ Collision unk30;
}; // size = 0x70

struct FallingRock {
    /* 0x00 */ s16 type;
    /* 0x02 */ s16 flags;
    /* 0x04 */ s16 respawnTimer;
    /* 0x06 */ s16 unk_06;
    /* 0x08 */ f32 unk_08;
    /* 0x0C */ f32 boundingBoxSize;
    /* 0x10 */ Vec3s rot;
    /* 0x16 */ s16 unk_16;
    /* 0x18 */ Vec3f pos;
    /* 0x24 */ Vec3f velocity;
    /* 0x30 */ Collision unk30;
}; // size = 0x70

struct ActorSpawnData {
    /* 0x00 */ Vec3s pos;
    union {
        /* 0x06 */ u16 someId; // Usually populated, but not necessarily used by all actors types
        /* 0x06 */ s16 signedSomeId;
    };
};

// Required for evaluate_collision_player_palm_trees due to diff size.
// members unverified. data located at d_course_dks_jungle_parkway_tree_spawn
/**
 * There are nearly 100 trees in DK Jungle Parkway. If they were put into the actor list proper
 * they would fill it up, leaving no space for stuff like item boxes, shells, bananas, kiwano fruits,
 * etc.
 * So, this struct type acts as both spawn data AND a stripped down Actor for those trees.
 * Give the tree a position, a byte for flags stuffed into an s16 used to indicate tree sub-type,
 * and an s16 containing as the tree's original Y position.
 **/
struct UnkActorSpawnData {
    /* 0x00 */ Vec3s pos;
    // Techinically only the bottom byte of someId is the "id". The top byte is used for flags.
    /* 0x06 */ s16 someId;
    // Stores the tree's original Y position.
    /* 0x08 */ s16 unk8;
};

struct YoshiValleyEgg {
    /* 0x00 */ s16 type;
    /* 0x02 */ s16 flags;
    /* 0x04 */ s16 unk_04;
    /* 0x06 */ s16 unk_06;
    /* 0x08 */ f32 pathRadius;
    /* 0x0C */ f32 boundingBoxSize;
    /* 0x10 */ s16 pathRot;
    /* 0x12 */ s16 eggRot;
    /* 0x14 */ s16 unk_14;
    /* 0x16 */ s16 unk_16;
    /* 0x18 */ Vec3f pos;
    // Note, pathCenter[1] should be understood to be the Y velocity of the egg
    // pathCenter[0] and pathCenter[2] are the X,Z coordinates of the center of the path
    /* 0x24 */ Vec3f pathCenter;
    /* 0x30 */ Collision unk30;
}; // size = 0x70

struct KiwanoFruit {
    /* 0x00 */ s16 type;
    /* 0x02 */ s16 flags;
    /* 0x04 */ s16
        targetPlayer; // Id of the player this actor tracks. Each player has their own kiwano actor just for them
    /* 0x06 */ s16 state;
    /* 0x08 */ f32 bonkTimer; // bonkState? Not sure what this is tracking, but its some form of count down that starts
                              // after the fruit hits you
    /* 0x0C */ f32 boundingBoxSize;
    /* 0x10 */ s16 animState;
    /* 0x12 */ s16 animTimer;
    /* 0x14 */ s16 unk_14;
    /* 0x16 */ s16 unk_16;
    /* 0x18 */ Vec3f pos;
    /* 0x24 */ Vec3f velocity;
    /* 0x30 */ Collision unk30;
}; // size = 0x70

struct PaddleWheelBoat {
    /* 0x00 */ s16 type;
    /* 0x02 */ s16 flags;
    /* 0x04 */ s16 unk_04;
    /* 0x06 */ s16 wheelRot;
    /* 0x08 */ f32 unk_08;
    /* 0x0C */ f32 unk_0C;
    /* 0x10 */ Vec3s boatRot;
    /* 0x16 */ s16 unk_16;
    /* 0x18 */ Vec3f pos;
    /* 0x24 */ Vec3f velocity;
    /* 0x30 */ Collision unk30;
}; // size = 0x70

struct PiranhaPlant {
    /* 0x00 */ s16 type;
    /* 0x02 */ s16 flags;
    /* 0x04 */ Vec4s visibilityStates; // A per-camera visibilty state tracker
    /* 0x0C */ f32 boundingBoxSize;
    /* 0x10 */ Vec4s unk10;
    /* 0x18 */ Vec3f pos;
    /* 0x24 */ Vec4s timers; // A per-camera timer. Might be more appropriate to call this state
    /* 0x2C */ f32 unk_02C;
    /* 0x30 */ Collision unk30;
}; // size = 0x70

struct PalmTree {
    /* 0x00 */ s16 type;
    /* 0x02 */ s16 flags;
    /* 0x04 */ s16 variant; // four different types of palm trees
    /* 0x06 */ s16 state;
    /* 0x08 */ f32 unk_08;
    /* 0x0C */ f32 boundingBoxSize;
    /* 0x10 */ Vec3s rot;
    /* 0x16 */ s16 unk_16;
    /* 0x18 */ Vec3f pos;
    /* 0x24 */ Vec3f velocity;
    /* 0x30 */ Collision unk30;
}; // size = 0x70

typedef struct {
    /* 0x00 */ s16 type;
    /* 0x02 */ s16 flags;
    /* 0x04 */ s16 shellsAvailable;
    /* 0x06 */ s16 state;
    /* 0x08 */ f32 unk_08;
    /* 0x0C */ f32 unk_0C;
    /* 0x10 */ s16 rotVelocity;
    /* 0x12 */ s16 rotAngle;
    /* 0x14 */ s16 playerId; // Id of the player that "owns" the shells
    /* 0x16 */ s16 unk_16;
    /* 0x18 */ Vec3f unk_18;
    /* 0x24 */ Vec3f shellIndices; // Indices in gActorList for the shells "owned" by this parent
    /* 0x30 */ Collision unk30;
} TripleShellParent; // size = 0x70

struct ShellActor {
    /* 0x00 */ s16 type;
    /* 0x02 */ s16 flags;
    // Index in gActorList for the parent actor of this shell
    // Seems to pull double duty as a timer
    union {
        /* 0x04 */ s16 parentIndex;
        /* 0x04 */ s16 someTimer;
        // Red Shells only (maybe blue shells?)
        /* 0x04 */ s16 targetPlayer; // Player the shell is after
    };
    /* 0x06 */ s16 state;
    /* 0x08 */ f32 shellId; // 0, 1, or 2. Indicates which shell in the triplet this one is
    /* 0x0C */ f32 boundingBoxSize;
    /* 0x10 */ s16 rotVelocity; // Change in rotAngle on a per-update basis
    union {
        /* 0x12 */ s16 rotAngle;  // Angle of rotation around player (or parent?), not the rotation of the shell itself
        /* 0x12 */ u16 pathIndex; // Index in the set of points that make up the "path" the red/blue shell follows (may
                                  // be GP mode exclusive)
    };
    /* 0x14 */ s16 playerId; // Id of the player that "owns" the shell
    /* 0x16 */ s16 unk_16;
    /* 0x18 */ Vec3f pos;
    /* 0x24 */ Vec3f velocity; // All 0 until the shell is fired
    /* 0x30 */ Collision unk30;
}; // size = 0x70

struct ItemBox {
    /* 0x00 */ s16 type;
    /* 0x02 */ s16 flags;
    /* 0x04 */ s16 someTimer;
    /* 0x06 */ s16 state;
    /* 0x08 */ f32 resetDistance; // Value added to the Y position when box is touched. Expected to be negative
                                  // Distance at which a player can activate the item box
                                  // Named "bounding box" to match the name used for the "size" of a kart
    /* 0x0C */ f32 boundingBoxSize;
    /* 0x10 */ Vec3s rot;
    /* 0x16 */ s16 unk_16;
    /* 0x18 */ Vec3f pos;
    /* 0x24 */ f32 origY; // Original Y position. Basically the Y position the box will reset to after being touched
    /* 0x28 */ f32 unk_028;
    /* 0x2C */ f32 unk_02C;
    /* 0x30 */ Collision unk30;
}; // size = 0x70

struct FakeItemBox {
    /* 0x00 */ s16 type;
    /* 0x02 */ s16 flags;
    /* 0x04 */ s16 someTimer;
    /* 0x06 */ s16 state;
    /* 0x08 */ f32 sizeScaling; // Controls the size of the box
    /* 0x0C */ f32 boundingBoxSize;
    /* 0x10 */ Vec3s rot;
    /* 0x16 */ s16 unk_16;
    /* 0x18 */ Vec3f pos;
    /* 0x24 */ f32 playerId;
    /* 0x28 */ f32 targetY;
    /* 0x2C */ f32 unk_02C;
    /* 0x30 */ Collision unk30;
}; // size = 0x70

struct BananaBunchParent {
    /* 0x00 */ s16 type;
    /* 0x02 */ s16 flags;
    /* 0x04 */ s16 unk_04;
    /* 0x06 */ s16 state;
    /* 0x08 */ f32 unk_08;
    /* 0x0C */ f32 unk_0C;
    /* 0x10 */ s16 playerId;         // Player that own the bananas
    /* 0x12 */ s16 bananaIndices[5]; // Indices in gActorList for the bananas owned by this parent
    /* 0x1C */ s16 bananasAvailable;
    /* 0x1E */ s16 unk_1E;
    /* 0x20 */ f32 unk_20[4];
    /* 0x30 */ Collision unk30;
}; // size = 0x70

struct BananaActor {
    /* 0x00 */ s16 type;
    /* 0x02 */ s16 flags;
    /* 0x04 */ s16 unk_04;
    /* 0x06 */ s16 state;
    /* 0x08 */ s16 parentIndex;
    /* 0x0A */ s16 bananaId; // ? Appears to indiciate which banana of the bunch this one is
    /* 0x0C */ f32 boundingBoxSize;
    union {
        /* 0x10 */ Vec3s rot;
        struct {
            /* 0x10 */ s16 playerId;     // Id of the player that owns this banana
            /* 0x12 */ s16 elderIndex;   // Index in gActorList of the next-oldest banana in the bunch
            /* 0x14 */ s16 youngerIndex; // Index in gActorList of the next-youngest banana in the bunch
        };
    };
    /* 0x16 */ s16 unk_16;
    /* 0x18 */ Vec3f pos;
    /* 0x24 */ Vec3f velocity;
    /* 0x30 */ Collision unk30;
}; // size = 0x70

// #pragma GCC diagnostic pop

#endif // ACTOR_TYPES_H