behavior_actions.c (8871B)
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 static s32 sCapSaveFlags[] = { 51 SAVE_FLAG_HAVE_WING_CAP, 52 SAVE_FLAG_HAVE_METAL_CAP, 53 SAVE_FLAG_HAVE_VANISH_CAP, 54 }; 55 56 // Boo Roll 57 static s16 sBooHitRotations[] = { 58 6047, 5664, 5292, 4934, 4587, 4254, 3933, 3624, 3329, 3046, 2775, 59 2517, 2271, 2039, 1818, 1611, 1416, 1233, 1063, 906, 761, 629, 60 509, 402, 308, 226, 157, 100, 56, 25, 4, 0, 61 }; 62 63 #include "behaviors/star_door.inc.c" 64 #include "behaviors/mr_i.inc.c" 65 #include "behaviors/pole.inc.c" 66 #include "behaviors/thi_top.inc.c" 67 #include "behaviors/capswitch.inc.c" 68 #include "behaviors/king_bobomb.inc.c" 69 #include "behaviors/beta_chest.inc.c" 70 #include "behaviors/water_objs.inc.c" 71 #include "behaviors/cannon.inc.c" 72 #include "behaviors/chuckya.inc.c" 73 #include "behaviors/breakable_wall.inc.c" 74 #include "behaviors/kickable_board.inc.c" 75 #include "behaviors/tower_door.inc.c" 76 #include "behaviors/rotating_platform.inc.c" 77 #include "behaviors/koopa_shell_underwater.inc.c" 78 #include "behaviors/warp.inc.c" 79 #include "behaviors/white_puff_explode.inc.c" 80 81 // not in behavior file 82 static struct SpawnParticlesInfo sMistParticles = { 83 /* bhvParam: */ 2, 84 /* count: */ 20, 85 /* model: */ MODEL_MIST, 86 /* offsetY: */ 0, 87 /* forwardVelBase: */ 40, 88 /* forwardVelRange: */ 5, 89 /* velYBase: */ 30, 90 /* velYRange: */ 20, 91 /* gravity: */ 252, 92 /* dragStrength: */ 30, 93 /* sizeBase: */ 330.0f, 94 /* sizeRange: */ 10.0f, 95 }; 96 97 // generate_wind_puffs/dust (something like that) 98 void spawn_mist_particles_variable(s32 count, s32 offsetY, f32 size) { 99 sMistParticles.sizeBase = size; 100 sMistParticles.sizeRange = size / 20.0; 101 sMistParticles.offsetY = offsetY; 102 103 if (count == 0) { 104 sMistParticles.count = 20; 105 } else if (count > 20) { 106 sMistParticles.count = count; 107 } else { 108 sMistParticles.count = 4; 109 } 110 111 cur_obj_spawn_particles(&sMistParticles); 112 } 113 114 #include "behaviors/sparkle_spawn_star.inc.c" 115 #include "behaviors/coin.inc.c" 116 #include "behaviors/collide_particles.inc.c" 117 #include "behaviors/door.inc.c" 118 #include "behaviors/thwomp.inc.c" 119 #include "behaviors/tumbling_bridge.inc.c" 120 #include "behaviors/elevator.inc.c" 121 #include "behaviors/water_mist_particle.inc.c" 122 #include "behaviors/break_particles.inc.c" 123 #include "behaviors/water_mist.inc.c" 124 #include "behaviors/ground_particles.inc.c" 125 #include "behaviors/wind.inc.c" 126 #include "behaviors/unused_particle_spawn.inc.c" 127 #include "behaviors/ukiki_cage.inc.c" 128 #include "behaviors/falling_rising_platform.inc.c" 129 #include "behaviors/fishing_boo.inc.c" 130 #include "behaviors/flamethrower.inc.c" 131 #include "behaviors/bouncing_fireball.inc.c" 132 #include "behaviors/shock_wave.inc.c" 133 #include "behaviors/flame_mario.inc.c" 134 #include "behaviors/beta_fish_splash_spawner.inc.c" 135 #include "behaviors/spindrift.inc.c" 136 #include "behaviors/tower_platform.inc.c" 137 #include "behaviors/tree_particles.inc.c" 138 #include "behaviors/square_platform_cycle.inc.c" 139 #include "behaviors/piranha_bubbles.inc.c" 140 #include "behaviors/purple_switch.inc.c" 141 #include "behaviors/metal_box.inc.c" 142 #include "behaviors/switch_hidden_objects.inc.c" 143 #include "behaviors/breakable_box.inc.c" 144 145 // not sure what this is doing here. not in a behavior file. 146 Gfx *geo_move_mario_part_from_parent(s32 run, UNUSED struct GraphNode *node, Mat4 mtx) { 147 if (run == TRUE) { 148 Mat4 sp20; 149 struct Object *obj = (struct Object *) gCurGraphNodeObject; 150 if (obj == gMarioObject && obj->prevObj != NULL) { 151 create_transformation_from_matrices(sp20, mtx, *gCurGraphNodeCamera->matrixPtr); 152 obj_update_pos_from_parent_transformation(sp20, obj->prevObj); 153 obj_set_gfx_pos_from_pos(obj->prevObj); 154 } 155 } 156 157 return NULL; 158 } 159 160 #include "behaviors/heave_ho.inc.c" 161 #include "behaviors/spawn_star_exit.inc.c" 162 #include "behaviors/unused_poundable_platform.inc.c" 163 #include "behaviors/beta_trampoline.inc.c" 164 #include "behaviors/jumping_box.inc.c" 165 #include "behaviors/boo_cage.inc.c" 166 167 // not in behavior file 168 // n is the number of objects to spawn, r if the rate of change of phase (frequency?) 169 void spawn_sparkle_particles(s32 n, s32 a1, s32 a2, s32 r) { 170 static s16 D_8035FF10; 171 s32 i; 172 s16 separation = 0x10000 / n; // Evenly spread around a circle 173 174 for (i = 0; i < n; i++) { 175 spawn_object_relative(0, sins(D_8035FF10 + i * separation) * a1, (i + 1) * a2, 176 coss(D_8035FF10 + i * separation) * a1, o, MODEL_NONE, bhvSparkleSpawn); 177 } 178 179 D_8035FF10 += r * 0x100; 180 } 181 182 #include "behaviors/beta_boo_key.inc.c" 183 #include "behaviors/grand_star.inc.c" 184 #include "behaviors/bowser_key.inc.c" 185 #include "behaviors/bullet_bill.inc.c" 186 #include "behaviors/bowser.inc.c" 187 #include "behaviors/bowser_falling_platform.inc.c" 188 #include "behaviors/bowser_flame.inc.c" 189 #include "behaviors/blue_fish.inc.c" 190 191 // Not in behavior file, duplicate of vec3f_copy except without bad return. 192 // Used in a few behavior files. 193 void vec3f_copy_2(Vec3f dest, Vec3f src) { 194 dest[0] = src[0]; 195 dest[1] = src[1]; 196 dest[2] = src[2]; 197 } 198 199 #include "behaviors/checkerboard_platform.inc.c" 200 #include "behaviors/ddd_warp.inc.c" 201 #include "behaviors/water_pillar.inc.c" 202 #include "behaviors/moat_drainer.inc.c" 203 #include "behaviors/bowser_key_cutscene.inc.c" 204 #include "behaviors/moat_grill.inc.c" 205 #include "behaviors/clock_arm.inc.c" 206 #include "behaviors/ukiki.inc.c" 207 #include "behaviors/lll_octagonal_rotating_mesh.inc.c" 208 #include "behaviors/lll_sinking_rock_block.inc.c" 209 #include "behaviors/lll_rotating_hex_flame.inc.c" 210 #include "behaviors/lll_floating_wood_piece.inc.c" 211 #include "behaviors/lll_volcano_flames.inc.c" 212 #include "behaviors/lll_hexagonal_ring.inc.c" 213 #include "behaviors/lll_sinking_rectangle.inc.c" 214 #include "behaviors/tilting_inverted_pyramid.inc.c" 215 #include "behaviors/koopa_shell.inc.c" 216 #include "behaviors/tox_box.inc.c" 217 #include "behaviors/piranha_plant.inc.c" 218 #include "behaviors/bowser_puzzle_piece.inc.c" 219 220 s32 set_obj_anim_with_accel_and_sound(s16 a0, s16 a1, s32 a2) { 221 f32 sp1C; 222 223 if ((sp1C = o->header.gfx.animInfo.animAccel / (f32) 0x10000) == 0) { 224 sp1C = 1.0f; 225 } 226 227 if (cur_obj_check_anim_frame_in_range(a0, sp1C) || cur_obj_check_anim_frame_in_range(a1, sp1C)) { 228 cur_obj_play_sound_2(a2); 229 return TRUE; 230 } 231 232 return FALSE; 233 } 234 235 #include "behaviors/tuxie.inc.c" 236 #include "behaviors/fish.inc.c" 237 #include "behaviors/express_elevator.inc.c" 238 #include "behaviors/bub.inc.c" 239 #include "behaviors/exclamation_box.inc.c" 240 #include "behaviors/sound_spawner.inc.c" 241 #include "behaviors/ddd_sub.inc.c" 242 #include "behaviors/sushi.inc.c" 243 #include "behaviors/jrb_ship.inc.c" 244 #include "behaviors/white_puff.inc.c" 245 #include "behaviors/blue_coin.inc.c" 246 #include "behaviors/grill_door.inc.c" 247 #include "behaviors/wdw_water_level.inc.c" 248 #include "behaviors/tweester.inc.c" 249 #include "behaviors/boo.inc.c" 250 #include "behaviors/bbh_tilting_trap.inc.c" 251 #include "behaviors/bbh_haunted_bookshelf.inc.c" 252 #include "behaviors/bbh_merry_go_round.inc.c" 253 #include "behaviors/static_checkered_platform.inc.c" 254 #include "behaviors/beta_bowser_anchor.inc.c" 255 #ifndef VERSION_JP 256 #include "behaviors/music_touch.inc.c" 257 #endif 258 #include "behaviors/castle_floor_trap.inc.c" 259 #include "behaviors/pole_base.inc.c" 260 #include "behaviors/sparkle_spawn.inc.c" 261 #include "behaviors/scuttlebug.inc.c" // :scuttleeyes: 262 #include "behaviors/whomp.inc.c" 263 #include "behaviors/water_splashes_and_waves.inc.c" 264 #include "behaviors/strong_wind_particle.inc.c" 265 #include "behaviors/sl_snowman_wind.inc.c" 266 #include "behaviors/sl_walking_penguin.inc.c"