treasure_chest.inc.c (6560B)
1 // treasure_chest.inc.c 2 3 /** 4 * Hitbox for treasure chest bottom. 5 */ 6 static struct ObjectHitbox sTreasureChestBottomHitbox = { 7 /* interactType: */ INTERACT_SHOCK, 8 /* downOffset: */ 0, 9 /* damageOrCoinValue: */ 1, 10 /* health: */ 0, 11 /* numLootCoins: */ 0, 12 /* radius: */ 300, 13 /* height: */ 300, 14 /* hurtboxRadius: */ 310, 15 /* hurtboxHeight: */ 310, 16 }; 17 18 void bhv_treasure_chest_top_loop(void) { 19 struct Object *sp34 = o->parentObj->parentObj; 20 21 switch (o->oAction) { 22 case 0: 23 if (o->parentObj->oAction == 1) { 24 o->oAction = 1; 25 } 26 break; 27 28 case 1: 29 if (o->oTimer == 0) { 30 if (sp34->oTreasureChestUnkFC == 0) { 31 spawn_object_relative(0, 0, -80, 120, o, MODEL_BUBBLE, bhvWaterAirBubble); 32 play_sound(SOUND_GENERAL_CLAM_SHELL1, o->header.gfx.cameraToObject); 33 } else { 34 play_sound(SOUND_GENERAL_OPEN_CHEST, o->header.gfx.cameraToObject); 35 } 36 } 37 38 o->oFaceAnglePitch -= 0x200; 39 if (o->oFaceAnglePitch < -0x4000) { 40 o->oFaceAnglePitch = -0x4000; 41 o->oAction++; 42 if (o->parentObj->oBhvParams2ndByte != 4) { 43 spawn_orange_number(o->parentObj->oBhvParams2ndByte, 0, -40, 0); 44 } 45 } 46 break; 47 48 case 2: 49 if (o->parentObj->oAction == 0) { 50 o->oAction = 3; 51 } 52 break; 53 54 case 3: 55 o->oFaceAnglePitch += 0x800; 56 if (o->oFaceAnglePitch > 0) { 57 o->oFaceAnglePitch = 0; 58 o->oAction = 0; 59 } 60 } 61 } 62 63 void bhv_treasure_chest_bottom_init(void) { 64 spawn_object_relative(0, 0, 102, -77, o, MODEL_TREASURE_CHEST_LID, bhvTreasureChestTop); 65 obj_set_hitbox(o, &sTreasureChestBottomHitbox); 66 } 67 68 void bhv_treasure_chest_bottom_loop(void) { 69 switch (o->oAction) { 70 case 0: 71 if (obj_check_if_facing_toward_angle(o->oMoveAngleYaw, gMarioObject->header.gfx.angle[1] + 0x8000, 0x3000) 72 && is_point_within_radius_of_mario(o->oPosX, o->oPosY, o->oPosZ, 150) 73 && !o->parentObj->oTreasureChestUnkF8) { 74 if (o->parentObj->oTreasureChestUnkF4 == o->oBhvParams2ndByte) { 75 play_sound(SOUND_GENERAL2_RIGHT_ANSWER, gGlobalSoundSource); 76 o->parentObj->oTreasureChestUnkF4++; 77 o->oAction = 1; 78 } else { 79 o->parentObj->oTreasureChestUnkF4 = 1; 80 o->parentObj->oTreasureChestUnkF8 = TRUE; 81 o->oAction = 2; 82 cur_obj_become_tangible(); 83 play_sound(SOUND_MENU_CAMERA_BUZZ, gGlobalSoundSource); 84 } 85 } 86 break; 87 88 case 1: 89 if (o->parentObj->oTreasureChestUnkF8 == TRUE) { 90 o->oAction = 0; 91 } 92 break; 93 94 case 2: 95 cur_obj_become_intangible(); 96 if (!is_point_within_radius_of_mario(o->oPosX, o->oPosY, o->oPosZ, 500)) { 97 o->parentObj->oTreasureChestUnkF8 = FALSE; 98 o->oAction = 0; 99 } 100 } 101 102 cur_obj_push_mario_away_from_cylinder(150.0f, 150.0f); 103 o->oInteractStatus = 0; 104 } 105 106 void spawn_treasure_chest(s8 sp3B, s32 x, s32 y, s32 z, s16 yaw) { 107 struct Object *sp34 = spawn_object_abs_with_rot(o, 0, MODEL_TREASURE_CHEST_BASE, 108 bhvTreasureChestBottom, x, y, z, 0, yaw, 0); 109 sp34->oBhvParams2ndByte = sp3B; 110 } 111 112 void bhv_treasure_chest_ship_init(void) { 113 spawn_treasure_chest(1, 400, -350, -2700, 0); 114 spawn_treasure_chest(2, 650, -350, -940, -0x6001); 115 spawn_treasure_chest(3, -550, -350, -770, 0x5FFF); 116 spawn_treasure_chest(4, 100, -350, -1700, 0); 117 o->oTreasureChestUnkF4 = 1; 118 o->oTreasureChestUnkFC = 0; 119 } 120 121 void bhv_treasure_chest_ship_loop(void) { 122 switch (o->oAction) { 123 case 0: 124 if (o->oTreasureChestUnkF4 == 5) { 125 play_puzzle_jingle(); 126 fade_volume_scale(0, 127, 1000); 127 o->oAction = 1; 128 } 129 break; 130 131 case 1: 132 if (gEnvironmentRegions != NULL) { 133 gEnvironmentRegions[6] -= 5; 134 play_sound(SOUND_ENV_WATER_DRAIN, gGlobalSoundSource); 135 set_environmental_camera_shake(SHAKE_ENV_JRB_SHIP_DRAIN); 136 if (gEnvironmentRegions[6] < -335) { 137 gEnvironmentRegions[6] = -335; 138 o->activeFlags = ACTIVE_FLAG_DEACTIVATED; 139 } 140 #if ENABLE_RUMBLE 141 reset_rumble_timers_2(2); 142 #endif 143 } 144 break; 145 } 146 } 147 148 void bhv_treasure_chest_jrb_init(void) { 149 spawn_treasure_chest(1, -1700, -2812, -1150, 0x7FFF); 150 spawn_treasure_chest(2, -1150, -2812, -1550, 0x7FFF); 151 spawn_treasure_chest(3, -2400, -2812, -1800, 0x7FFF); 152 spawn_treasure_chest(4, -1800, -2812, -2100, 0x7FFF); 153 o->oTreasureChestUnkF4 = 1; 154 o->oTreasureChestUnkFC = 1; 155 } 156 157 void bhv_treasure_chest_jrb_loop(void) { 158 switch (o->oAction) { 159 case 0: 160 if (o->oTreasureChestUnkF4 == 5) { 161 play_puzzle_jingle(); 162 o->oAction = 1; 163 } 164 break; 165 166 case 1: 167 if (o->oTimer == 60) { 168 spawn_mist_particles(); 169 spawn_default_star(-1800.0f, -2500.0f, -1700.0f); 170 o->oAction = 2; 171 } 172 break; 173 174 case 2: 175 break; 176 } 177 } 178 179 void bhv_treasure_chest_ddd_init(void) { 180 spawn_treasure_chest(1, -4500, -5119, 1300, -0x6001); 181 spawn_treasure_chest(2, -1800, -5119, 1050, 0x1FFF); 182 spawn_treasure_chest(3, -4500, -5119, -1100, 9102); 183 spawn_treasure_chest(4, -2400, -4607, 125, 16019); 184 185 o->oTreasureChestUnkF4 = 1; 186 o->oTreasureChestUnkFC = 0; 187 } 188 189 void bhv_treasure_chest_ddd_loop(void) { 190 switch (o->oAction) { 191 case 0: 192 if (o->oTreasureChestUnkF4 == 5) { 193 play_puzzle_jingle(); 194 o->oAction = 1; 195 } 196 break; 197 198 case 1: 199 if (o->oTimer == 60) { 200 spawn_mist_particles(); 201 spawn_default_star(-1900.0f, -4000.0f, -1400.0f); 202 o->oAction = 2; 203 } 204 break; 205 206 case 2: 207 break; 208 } 209 }