Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
MorsGames
GitHub Repository: MorsGames/sm64plus
Path: blob/master/src/game/behavior_actions.c
7858 views
1
#include <PR/ultratypes.h>
2
3
#include "types.h"
4
#include "actors/common1.h"
5
#include "actors/group12.h"
6
#include "actors/group13.h"
7
#include "area.h"
8
#include "audio/external.h"
9
#include "behavior_actions.h"
10
#include "behavior_data.h"
11
#include "camera.h"
12
#include "debug.h"
13
#include "dialog_ids.h"
14
#include "engine/behavior_script.h"
15
#include "engine/graph_node.h"
16
#include "engine/math_util.h"
17
#include "engine/surface_collision.h"
18
#include "engine/surface_load.h"
19
#include "game_init.h"
20
#include "ingame_menu.h"
21
#include "interaction.h"
22
#include "level_misc_macros.h"
23
#include "level_table.h"
24
#include "level_update.h"
25
#include "levels/bob/header.h"
26
#include "levels/bowser_3/header.h"
27
#include "levels/castle_inside/header.h"
28
#include "levels/hmc/header.h"
29
#include "main.h"
30
#include "mario.h"
31
#include "mario_actions_cutscene.h"
32
#include "mario_step.h"
33
#include "obj_behaviors.h"
34
#include "obj_behaviors_2.h"
35
#include "object_constants.h"
36
#include "object_helpers.h"
37
#include "object_list_processor.h"
38
#include "paintings.h"
39
#include "platform_displacement.h"
40
#include "rendering_graph_node.h"
41
#include "save_file.h"
42
#include "seq_ids.h"
43
#include "sm64.h"
44
#include "spawn_object.h"
45
#include "spawn_sound.h"
46
#include "rumble_init.h"
47
48
#define o gCurrentObject
49
50
struct WFRotatingPlatformData {
51
s16 pad;
52
s16 scale;
53
const Collision *collisionData;
54
s16 collisionDistance;
55
};
56
57
struct Struct8032F34C {
58
s16 numBridgeSections;
59
s16 bridgeRelativeStartingXorZ;
60
s16 platformWidth;
61
s16 model;
62
const void *segAddr;
63
};
64
65
struct Struct802C0DF0 {
66
u8 unk0;
67
u8 unk1;
68
u8 unk2;
69
u8 model;
70
const BehaviorScript *behavior;
71
};
72
73
struct Struct8032F754 {
74
s32 unk0;
75
Vec3f unk1;
76
f32 unk2;
77
};
78
79
struct OpenableGrill {
80
s16 halfWidth;
81
s16 modelID;
82
const Collision *collision;
83
};
84
85
static s32 sCapSaveFlags[] = { SAVE_FLAG_HAVE_WING_CAP, SAVE_FLAG_HAVE_METAL_CAP, SAVE_FLAG_HAVE_VANISH_CAP };
86
87
// Boo Roll
88
static s16 sBooHitRotations[] = { 6047, 5664, 5292, 4934, 4587, 4254, 3933, 3624, 3329, 3046, 2775,
89
2517, 2271, 2039, 1818, 1611, 1416, 1233, 1063, 906, 761, 629,
90
509, 402, 308, 226, 157, 100, 56, 25, 4, 0 };
91
92
#include "behaviors/star_door.inc.c"
93
#include "behaviors/mr_i.inc.c"
94
#include "behaviors/pole.inc.c"
95
#include "behaviors/thi_top.inc.c"
96
#include "behaviors/capswitch.inc.c"
97
#include "behaviors/king_bobomb.inc.c"
98
#include "behaviors/beta_chest.inc.c"
99
#include "behaviors/water_objs.inc.c"
100
#include "behaviors/cannon.inc.c"
101
#include "behaviors/chuckya.inc.c"
102
#include "behaviors/breakable_wall.inc.c"
103
#include "behaviors/kickable_board.inc.c"
104
#include "behaviors/tower_door.inc.c"
105
#include "behaviors/rotating_platform.inc.c"
106
#include "behaviors/koopa_shell_underwater.inc.c"
107
#include "behaviors/warp.inc.c"
108
#include "behaviors/white_puff_explode.inc.c"
109
110
// not in behavior file
111
struct SpawnParticlesInfo sMistParticles = { 2, 20, MODEL_MIST, 0, 40, 5, 30, 20, 252, 30, 330.0f, 10.0f };
112
113
// generate_wind_puffs/dust (something like that)
114
void spawn_mist_particles_variable(s32 count, s32 offsetY, f32 size) {
115
sMistParticles.sizeBase = size;
116
sMistParticles.sizeRange = size / 20.0;
117
sMistParticles.offsetY = offsetY;
118
if (count == 0) {
119
sMistParticles.count = 20;
120
} else if (count > 20) {
121
sMistParticles.count = count;
122
} else {
123
sMistParticles.count = 4;
124
}
125
cur_obj_spawn_particles(&sMistParticles);
126
}
127
128
#include "behaviors/sparkle_spawn_star.inc.c"
129
#include "behaviors/coin.inc.c"
130
#include "behaviors/collide_particles.inc.c"
131
#include "behaviors/door.inc.c"
132
#include "behaviors/thwomp.inc.c"
133
#include "behaviors/tumbling_bridge.inc.c"
134
#include "behaviors/elevator.inc.c"
135
#include "behaviors/water_mist_particle.inc.c"
136
#include "behaviors/break_particles.inc.c"
137
#include "behaviors/water_mist.inc.c"
138
#include "behaviors/ground_particles.inc.c"
139
#include "behaviors/wind.inc.c"
140
#include "behaviors/unused_particle_spawn.inc.c"
141
#include "behaviors/ukiki_cage.inc.c"
142
#include "behaviors/falling_rising_platform.inc.c"
143
#include "behaviors/fishing_boo.inc.c"
144
#include "behaviors/flamethrower.inc.c"
145
#include "behaviors/bouncing_fireball.inc.c"
146
#include "behaviors/shock_wave.inc.c"
147
#include "behaviors/flame_mario.inc.c"
148
#include "behaviors/beta_fish_splash_spawner.inc.c"
149
#include "behaviors/spindrift.inc.c"
150
#include "behaviors/tower_platform.inc.c"
151
#include "behaviors/tree_particles.inc.c"
152
#include "behaviors/square_platform_cycle.inc.c"
153
#include "behaviors/piranha_bubbles.inc.c"
154
#include "behaviors/purple_switch.inc.c"
155
#include "behaviors/metal_box.inc.c"
156
#include "behaviors/switch_hidden_objects.inc.c"
157
#include "behaviors/breakable_box.inc.c"
158
159
// not sure what this is doing here. not in a behavior file.
160
Gfx *geo_move_mario_part_from_parent(s32 run, UNUSED struct GraphNode *node, Mat4 mtx) {
161
Mat4 sp20;
162
struct Object *sp1C;
163
164
if (run == TRUE) {
165
sp1C = (struct Object *) gCurGraphNodeObject;
166
if (sp1C == gMarioObject && sp1C->prevObj != NULL) {
167
create_transformation_from_matrices(sp20, mtx, *gCurGraphNodeCamera->matrixPtr);
168
obj_update_pos_from_parent_transformation(sp20, sp1C->prevObj);
169
obj_set_gfx_pos_from_pos(sp1C->prevObj);
170
}
171
}
172
return NULL;
173
}
174
175
#include "behaviors/heave_ho.inc.c"
176
#include "behaviors/spawn_star_exit.inc.c"
177
#include "behaviors/unused_poundable_platform.inc.c"
178
#include "behaviors/beta_trampoline.inc.c"
179
#include "behaviors/jumping_box.inc.c"
180
#include "behaviors/boo_cage.inc.c"
181
182
// not in behavior file
183
// n is the number of objects to spawn, r if the rate of change of phase (frequency?)
184
void spawn_sparkle_particles(s32 n, s32 a1, s32 a2, s32 r) {
185
static s16 D_8035FF10;
186
s32 i;
187
s16 separation = 0x10000 / n; // Evenly spread around a circle
188
for (i = 0; i < n; i++) {
189
spawn_object_relative(0, sins(D_8035FF10 + i * separation) * a1, (i + 1) * a2,
190
coss(D_8035FF10 + i * separation) * a1, o, MODEL_NONE, bhvSparkleSpawn);
191
}
192
193
D_8035FF10 += r * 0x100;
194
}
195
196
#include "behaviors/beta_boo_key.inc.c"
197
#include "behaviors/grand_star.inc.c"
198
#include "behaviors/bowser_key.inc.c"
199
#include "behaviors/bullet_bill.inc.c"
200
#include "behaviors/bowser.inc.c"
201
#include "behaviors/bowser_falling_platform.inc.c"
202
#include "behaviors/bowser_flame.inc.c"
203
#include "behaviors/blue_fish.inc.c"
204
205
// Not in behavior file, duplicate of vec3f_copy except without bad return.
206
// Used in a few behavior files.
207
void vec3f_copy_2(Vec3f dest, Vec3f src) {
208
dest[0] = src[0];
209
dest[1] = src[1];
210
dest[2] = src[2];
211
}
212
213
#include "behaviors/checkerboard_platform.inc.c"
214
#include "behaviors/ddd_warp.inc.c"
215
#include "behaviors/water_pillar.inc.c"
216
#include "behaviors/moat_drainer.inc.c"
217
#include "behaviors/bowser_key_cutscene.inc.c"
218
#include "behaviors/moat_grill.inc.c"
219
#include "behaviors/clock_arm.inc.c"
220
#include "behaviors/ukiki.inc.c"
221
#include "behaviors/lll_octagonal_rotating_mesh.inc.c"
222
#include "behaviors/lll_sinking_rock_block.inc.c"
223
#include "behaviors/lll_rotating_hex_flame.inc.c"
224
#include "behaviors/lll_floating_wood_piece.inc.c"
225
#include "behaviors/lll_volcano_flames.inc.c"
226
#include "behaviors/lll_hexagonal_ring.inc.c"
227
#include "behaviors/lll_sinking_rectangle.inc.c"
228
#include "behaviors/tilting_inverted_pyramid.inc.c"
229
#include "behaviors/tox_box.inc.c"
230
#include "behaviors/piranha_plant.inc.c"
231
#include "behaviors/bowser_puzzle_piece.inc.c"
232
233
s32 set_obj_anim_with_accel_and_sound(s16 a0, s16 a1, s32 a2) {
234
f32 sp1C;
235
if ((sp1C = o->header.gfx.animInfo.animAccel / (f32) 0x10000) == 0)
236
sp1C = 1.0f;
237
if (cur_obj_check_anim_frame_in_range(a0, sp1C) || cur_obj_check_anim_frame_in_range(a1, sp1C)) {
238
cur_obj_play_sound_2(a2);
239
return 1;
240
}
241
return 0;
242
}
243
244
#include "behaviors/tuxie.inc.c"
245
#include "behaviors/fish.inc.c"
246
#include "behaviors/express_elevator.inc.c"
247
#include "behaviors/bub.inc.c"
248
#include "behaviors/exclamation_box.inc.c"
249
#include "behaviors/sound_spawner.inc.c"
250
#include "behaviors/ddd_sub.inc.c"
251
#include "behaviors/sushi.inc.c"
252
#include "behaviors/jrb_ship.inc.c"
253
#include "behaviors/white_puff.inc.c"
254
#include "behaviors/blue_coin.inc.c"
255
#include "behaviors/grill_door.inc.c"
256
#include "behaviors/wdw_water_level.inc.c"
257
#include "behaviors/tweester.inc.c"
258
#include "behaviors/boo.inc.c"
259
#include "behaviors/bbh_tilting_trap.inc.c"
260
#include "behaviors/bbh_haunted_bookshelf.inc.c"
261
#include "behaviors/bbh_merry_go_round.inc.c"
262
#include "behaviors/static_checkered_platform.inc.c"
263
#include "behaviors/beta_bowser_anchor.inc.c"
264
#ifndef VERSION_JP
265
#include "behaviors/music_touch.inc.c"
266
#endif
267
#include "behaviors/castle_floor_trap.inc.c"
268
#include "behaviors/pole_base.inc.c"
269
#include "behaviors/sparkle_spawn.inc.c"
270
#include "behaviors/scuttlebug.inc.c" // :scuttleeyes:
271
#include "behaviors/whomp.inc.c"
272
#include "behaviors/water_splashes_and_waves.inc.c"
273
#include "behaviors/strong_wind_particle.inc.c"
274
#include "behaviors/sl_snowman_wind.inc.c"
275
#include "behaviors/sl_walking_penguin.inc.c"
276
277