bowser_falling_platform.inc.c (3659B)
1 // bowser_falling_platform.inc.c 2 3 struct BowserFallingPlatformData { 4 const Collision *collision; 5 s16 posX; 6 s16 posZ; 7 s16 angle; 8 }; 9 10 struct BowserFallingPlatformData sBowserFallingPlatform[] = { 11 { NULL, 0, 0, 0 }, 12 { bowser_3_seg7_collision_07004B94, -800, -1000, -20992 }, 13 { bowser_3_seg7_collision_07004C18, -1158, 390, -18432 }, 14 { bowser_3_seg7_collision_07004C9C, -1158, 390, -7680 }, 15 { bowser_3_seg7_collision_07004D20, 0, 1240, -6144 }, 16 { bowser_3_seg7_collision_07004DA4, 0, 1240, 6144 }, 17 { bowser_3_seg7_collision_07004E28, 1158, 390, 7680 }, 18 { bowser_3_seg7_collision_07004EAC, 1158, 390, 18432 }, 19 { bowser_3_seg7_collision_07004F30, 800, -1000, 20992 }, 20 { bowser_3_seg7_collision_07004FB4, 800, -1000, -31744 }, 21 { bowser_3_seg7_collision_07005038, -800, -1000, 31744 }, 22 }; 23 24 void falling_bowser_plat_act_start(void) { 25 o->oBitSPlatformBowser = cur_obj_nearest_object_with_behavior(bhvBowser); 26 obj_set_collision_data(o, sBowserFallingPlatform[o->oBhvParams2ndByte].collision); 27 if (o->oBitSPlatformBowser != NULL) { 28 o->oAction = BOWSER_BITS_PLAT_ACT_CHECK; 29 } 30 } 31 32 void falling_bowser_plat_act_check(void) { 33 UNUSED u8 filler[4]; 34 struct Object *bowser = o->oBitSPlatformBowser; 35 36 if (bowser->platform == o) { 37 if (bowser->oAction == BOWSER_ACT_BIG_JUMP 38 && bowser->oBowserStatus & BOWSER_STATUS_BIG_JUMP) { 39 o->oAction = BOWSER_BITS_PLAT_ACT_FALL; 40 } 41 } 42 43 if (bowser->oHealth == 1 44 && (bowser->oAction == BOWSER_ACT_DANCE || bowser->oHeldState != HELD_FREE)) { 45 o->oSubAction = 1; 46 } 47 48 if (o->oSubAction == 0) { 49 o->oBitSPlatformTimer = 0; 50 } else { 51 if ((gDebugInfo[DEBUG_PAGE_EFFECTINFO][6] + 20) 52 * (o->oBhvParams2ndByte - 1) < o->oBitSPlatformTimer) { 53 o->oAction = BOWSER_BITS_PLAT_ACT_FALL; 54 } 55 o->oBitSPlatformTimer++; 56 } 57 } 58 59 void falling_bowser_plat_act_fall(void) { 60 Vec3f pos; 61 s16 angle; 62 f32 val; 63 UNUSED struct Object *bowser = o->oBitSPlatformBowser; 64 65 if (o->oTimer == 0 || o->oTimer == 22) { 66 cur_obj_play_sound_2(SOUND_GENERAL_BOWSER_PLATFORM_2); 67 } 68 69 if (o->oTimer < 22) { 70 set_environmental_camera_shake(SHAKE_ENV_FALLING_BITS_PLAT); 71 o->oVelY = 8.0f; 72 o->oGravity = 0.0f; 73 } else { 74 o->oGravity = -4.0f; 75 } 76 77 if (!(o->oTimer & 1) && o->oTimer < 14) { 78 angle = sBowserFallingPlatform[o->oBhvParams2ndByte].angle 79 + (gDebugInfo[DEBUG_PAGE_EFFECTINFO][1] << 8); 80 val = -(o->oTimer / 2) * 290 + 1740; 81 vec3f_copy_2(pos, &o->oPosX); 82 o->oPosX = sBowserFallingPlatform[o->oBhvParams2ndByte].posX + sins(angle + 0x14B0) * val; 83 o->oPosZ = sBowserFallingPlatform[o->oBhvParams2ndByte].posZ + coss(angle + 0x14B0) * val; 84 o->oPosY = 307.0f; 85 spawn_mist_particles_variable(4, 0, 100.0f); 86 o->oPosX = sBowserFallingPlatform[o->oBhvParams2ndByte].posX + sins(angle - 0x14B0) * val; 87 o->oPosZ = sBowserFallingPlatform[o->oBhvParams2ndByte].posZ + coss(angle - 0x14B0) * val; 88 spawn_mist_particles_variable(4, 0, 100.0f); 89 vec3f_copy_2(&o->oPosX, pos); 90 } 91 92 cur_obj_move_using_fvel_and_gravity(); 93 94 if (o->oTimer > 300) { 95 obj_mark_for_deletion(o); 96 } 97 } 98 99 void (*sFallingBowserPlatformActions[])(void) = { 100 falling_bowser_plat_act_start, 101 falling_bowser_plat_act_check, 102 falling_bowser_plat_act_fall, 103 }; 104 105 void bhv_falling_bowser_platform_loop(void) { 106 cur_obj_call_action_function(sFallingBowserPlatformActions); 107 }