sm64

A Super Mario 64 decompilation
Log | Files | Refs | README | LICENSE

king_bobomb.inc.c (11071B)


      1 // king_bobomb.inc.c
      2 
      3 // Copy of geo_update_projectile_pos_from_parent
      4 Gfx *geo_update_held_mario_pos(s32 run, UNUSED struct GraphNode *node, Mat4 mtx) {
      5     if (run == TRUE) {
      6         Mat4 sp20;
      7         struct Object *obj = (struct Object *) gCurGraphNodeObject;
      8         if (obj->prevObj != NULL) {
      9             create_transformation_from_matrices(sp20, mtx, *gCurGraphNodeCamera->matrixPtr);
     10             obj_update_pos_from_parent_transformation(sp20, obj->prevObj);
     11             obj_set_gfx_pos_from_pos(obj->prevObj);
     12         }
     13     }
     14 
     15     return NULL;
     16 }
     17 
     18 void bhv_bobomb_anchor_mario_loop(void) {
     19     common_anchor_mario_behavior(50.0f, 50.0f, INT_STATUS_MARIO_UNK6);
     20 }
     21 
     22 void king_bobomb_act_0(void) {
     23 #ifndef VERSION_JP
     24     o->oForwardVel = 0.0f;
     25     o->oVelY = 0.0f;
     26 #endif
     27 
     28     if (o->oSubAction == 0) {
     29         cur_obj_become_intangible();
     30         gSecondCameraFocus = o;
     31         cur_obj_init_animation_with_sound(5);
     32         cur_obj_set_pos_to_home();
     33         o->oHealth = 3;
     34 
     35         if (cur_obj_can_mario_activate_textbox_2(500.0f, 100.0f)) {
     36             o->oSubAction++;
     37             seq_player_lower_volume(SEQ_PLAYER_LEVEL, 60, 40);
     38         }
     39     } else if (cur_obj_update_dialog_with_cutscene(MARIO_DIALOG_LOOK_UP,
     40         DIALOG_FLAG_TURN_TO_MARIO, CUTSCENE_DIALOG, DIALOG_017)) {
     41         o->oAction = 2;
     42         o->oFlags |= OBJ_FLAG_HOLDABLE;
     43     }
     44 }
     45 
     46 s32 mario_is_far_below_object(f32 arg0) {
     47     if (arg0 < o->oPosY - gMarioObject->oPosY) {
     48         return TRUE;
     49     } else {
     50         return FALSE;
     51     }
     52 }
     53 
     54 void king_bobomb_act_2(void) {
     55     cur_obj_become_tangible();
     56 
     57     if (o->oPosY - o->oHomeY < -100.0f) { // Thrown off hill
     58         o->oAction = 5;
     59         cur_obj_become_intangible();
     60     }
     61 
     62     if (o->oKingBobombUnk100 == 0) {
     63         if (cur_obj_check_anim_frame(15)) {
     64             cur_obj_shake_screen(SHAKE_POS_SMALL);
     65         }
     66 
     67         if (cur_obj_init_animation_and_check_if_near_end(4)) {
     68             o->oKingBobombUnk100++;
     69         }
     70     } else {
     71         if (o->oKingBobombUnk100 == 1) {
     72             cur_obj_init_animation_and_anim_frame(11, 7);
     73             o->oKingBobombUnk100 = 2;
     74         } else {
     75             cur_obj_init_animation_with_sound(11);
     76         }
     77 
     78         if (o->oKingBobombUnk108 == 0) {
     79             o->oForwardVel = 3.0f;
     80             cur_obj_rotate_yaw_toward(o->oAngleToMario, 0x100);
     81         } else {
     82             o->oForwardVel = 0.0f;
     83             o->oKingBobombUnk108--;
     84         }
     85     }
     86 
     87     if (cur_obj_check_grabbed_mario()) {
     88         o->oAction = 3;
     89     }
     90 
     91     if (mario_is_far_below_object(1200.0f)) {
     92         o->oAction = 0;
     93         stop_background_music(SEQUENCE_ARGS(4, SEQ_EVENT_BOSS));
     94     }
     95 }
     96 
     97 void king_bobomb_act_3(void) {
     98     if (o->oSubAction == 0) {
     99         o->oForwardVel = 0.0f;
    100         o->oKingBobombUnk104 = 0;
    101         o->oKingBobombUnkFC = 0;
    102 
    103         if (o->oTimer == 0) {
    104             cur_obj_play_sound_2(SOUND_OBJ_UNKNOWN3);
    105         }
    106 
    107         if (cur_obj_init_animation_and_check_if_near_end(0)) {
    108             o->oSubAction++;
    109             cur_obj_init_animation_and_anim_frame(1, 0);
    110         }
    111     } else if (o->oSubAction == 1) {
    112         cur_obj_init_animation_with_sound(1);
    113         o->oKingBobombUnkFC += player_performed_grab_escape_action();
    114 
    115         print_debug_bottom_up("%d", o->oKingBobombUnkFC);
    116 
    117         if (o->oKingBobombUnkFC > 10) {
    118             o->oKingBobombUnk88 = 3;
    119             o->oAction = 2;
    120             o->oKingBobombUnk108 = 35;
    121             o->oInteractStatus &= ~INT_STATUS_GRABBED_MARIO;
    122         } else {
    123             o->oForwardVel = 3.0f;
    124 
    125             if (o->oKingBobombUnk104 > 20 && cur_obj_rotate_yaw_toward(0, 0x400)) {
    126                 o->oSubAction++;
    127                 cur_obj_init_animation_and_anim_frame(9, 22);
    128             }
    129         }
    130 
    131         o->oKingBobombUnk104++;
    132     } else {
    133         cur_obj_init_animation_with_sound(9);
    134 
    135         if (cur_obj_check_anim_frame(31)) {
    136             o->oKingBobombUnk88 = 2;
    137             cur_obj_play_sound_2(SOUND_OBJ_UNKNOWN4);
    138         } else if (cur_obj_check_if_near_animation_end()) {
    139             o->oAction = 1;
    140             o->oInteractStatus &= ~INT_STATUS_GRABBED_MARIO;
    141         }
    142     }
    143 }
    144 
    145 void king_bobomb_act_1(void) {
    146     o->oForwardVel = 0.0f;
    147     o->oVelY = 0.0f;
    148 
    149     cur_obj_init_animation_with_sound(11);
    150 
    151     o->oMoveAngleYaw = approach_s16_symmetric(o->oMoveAngleYaw, o->oAngleToMario, 0x200);
    152 
    153     if (o->oDistanceToMario < 2500.0f) {
    154         o->oAction = 2;
    155     }
    156 
    157     if (mario_is_far_below_object(1200.0f)) {
    158         o->oAction = 0;
    159         stop_background_music(SEQUENCE_ARGS(4, SEQ_EVENT_BOSS));
    160     }
    161 }
    162 
    163 void king_bobomb_act_6(void) {
    164     if (o->oSubAction == 0) {
    165         if (o->oTimer == 0) {
    166             o->oKingBobombUnk104 = 0;
    167 
    168             cur_obj_play_sound_2(SOUND_OBJ_KING_BOBOMB);
    169             cur_obj_play_sound_2(SOUND_OBJ2_KING_BOBOMB_DAMAGE);
    170             cur_obj_shake_screen(SHAKE_POS_SMALL);
    171             spawn_mist_particles_variable(0, 0, 100.0f);
    172 
    173             o->oInteractType = INTERACT_DAMAGE;
    174 
    175             cur_obj_become_tangible();
    176         }
    177 
    178         if (cur_obj_init_animation_and_check_if_near_end(2)) {
    179             o->oKingBobombUnk104++;
    180         }
    181 
    182         if (o->oKingBobombUnk104 > 3) {
    183             o->oSubAction++;
    184         }
    185     } else if (o->oSubAction == 1) {
    186         if (cur_obj_init_animation_and_check_if_near_end(10)) {
    187             o->oSubAction++;
    188             o->oInteractType = INTERACT_GRABBABLE;
    189 
    190             cur_obj_become_intangible();
    191         }
    192     } else {
    193         cur_obj_init_animation_with_sound(11);
    194 
    195         if (cur_obj_rotate_yaw_toward(o->oAngleToMario, 0x800) == TRUE) {
    196             o->oAction = 2;
    197         }
    198     }
    199 }
    200 
    201 void king_bobomb_act_7(void) {
    202     cur_obj_init_animation_with_sound(2);
    203     if (cur_obj_update_dialog_with_cutscene(MARIO_DIALOG_LOOK_UP,
    204         DIALOG_FLAG_TEXT_DEFAULT, CUTSCENE_DIALOG, DIALOG_116)) {
    205         create_sound_spawner(SOUND_OBJ_KING_WHOMP_DEATH);
    206 
    207         cur_obj_hide();
    208         cur_obj_become_intangible();
    209 
    210         spawn_mist_particles_variable(0, 0, 200.0f);
    211         spawn_triangle_break_particles(20, MODEL_DIRT_ANIMATION, 3.0f, 4);
    212         cur_obj_shake_screen(SHAKE_POS_SMALL);
    213 
    214 #ifndef VERSION_JP
    215         cur_obj_spawn_star_at_y_offset(2000.0f, 4500.0f, -4500.0f, 200.0f);
    216 #else
    217         o->oPosY += 100.0f;
    218         spawn_default_star(2000.0f, 4500.0f, -4500.0f);
    219 #endif
    220 
    221         o->oAction = 8;
    222     }
    223 }
    224 
    225 void king_bobomb_act_8(void) {
    226     if (o->oTimer == 60) {
    227         stop_background_music(SEQUENCE_ARGS(4, SEQ_EVENT_BOSS));
    228     }
    229 }
    230 
    231 void king_bobomb_act_4(void) { // bobomb been thrown
    232     if (o->oPosY - o->oHomeY > -100.0f) { // not thrown off hill
    233         if (o->oMoveFlags & OBJ_MOVE_LANDED) {
    234             o->oHealth--;
    235 
    236             o->oForwardVel = 0.0f;
    237             o->oVelY = 0.0f;
    238 
    239             cur_obj_play_sound_2(SOUND_OBJ_KING_BOBOMB);
    240 
    241             if (o->oHealth != 0) {
    242                 o->oAction = 6;
    243             } else {
    244                 o->oAction = 7;
    245             }
    246         }
    247     } else if (o->oSubAction == 0) {
    248         if (o->oMoveFlags & OBJ_MOVE_ON_GROUND) {
    249             o->oForwardVel = 0.0f;
    250             o->oVelY = 0.0f;
    251 
    252             o->oSubAction++;
    253         } else if (o->oMoveFlags & OBJ_MOVE_LANDED) {
    254             cur_obj_play_sound_2(SOUND_OBJ_KING_BOBOMB);
    255         }
    256     } else {
    257         if (cur_obj_init_animation_and_check_if_near_end(10)) {
    258             o->oAction = 5; // Go back to top of hill
    259         }
    260 
    261         o->oSubAction++;
    262     }
    263 }
    264 
    265 void king_bobomb_act_5(void) { // bobomb returns home
    266     switch (o->oSubAction) {
    267         case 0:
    268             if (o->oTimer == 0) {
    269                 cur_obj_play_sound_2(SOUND_OBJ_KING_BOBOMB_JUMP);
    270             }
    271 
    272             o->oKingBobombUnkF8 = 1;
    273 
    274             cur_obj_init_animation_and_extend_if_at_end(8);
    275             o->oMoveAngleYaw = cur_obj_angle_to_home();
    276 
    277             if (o->oPosY < o->oHomeY) {
    278                 o->oVelY = 100.0f;
    279             } else {
    280                 arc_to_goal_pos(&o->oHomeX, &o->oPosX, 100.0f, -4.0f);
    281                 o->oSubAction++;
    282             }
    283             break;
    284 
    285         case 1:
    286             cur_obj_init_animation_and_extend_if_at_end(8);
    287 
    288             if (o->oVelY < 0 && o->oPosY < o->oHomeY) {
    289                 o->oPosY = o->oHomeY;
    290                 o->oVelY = 0;
    291                 o->oForwardVel = 0;
    292                 o->oGravity = -4.0f;
    293 
    294                 o->oKingBobombUnkF8 = 0;
    295 
    296                 cur_obj_init_animation_with_sound(7);
    297                 cur_obj_play_sound_2(SOUND_OBJ_KING_BOBOMB);
    298                 cur_obj_shake_screen(SHAKE_POS_SMALL);
    299 
    300                 o->oSubAction++;
    301             }
    302             break;
    303 
    304         case 2:
    305             if (cur_obj_init_animation_and_check_if_near_end(7)) {
    306                 o->oSubAction++;
    307             }
    308             break;
    309 
    310         case 3:
    311             if (mario_is_far_below_object(1200.0f)) {
    312                 o->oAction = 0;
    313                 stop_background_music(SEQUENCE_ARGS(4, SEQ_EVENT_BOSS));
    314             }
    315 
    316             if (cur_obj_can_mario_activate_textbox_2(500.0f, 100.0f)) {
    317                 o->oSubAction++;
    318             }
    319             break;
    320 
    321         case 4:
    322             if (cur_obj_update_dialog_with_cutscene(MARIO_DIALOG_LOOK_UP,
    323                 DIALOG_FLAG_TURN_TO_MARIO, CUTSCENE_DIALOG, DIALOG_128)) {
    324                 o->oAction = 2;
    325             }
    326             break;
    327     }
    328 }
    329 
    330 void (*sKingBobombActions[])(void) = {
    331     king_bobomb_act_0,
    332     king_bobomb_act_1,
    333     king_bobomb_act_2,
    334     king_bobomb_act_3,
    335     king_bobomb_act_4,
    336     king_bobomb_act_5,
    337     king_bobomb_act_6,
    338     king_bobomb_act_7,
    339     king_bobomb_act_8,
    340 };
    341 
    342 struct SoundState sKingBobombSoundStates[] = {
    343     { 0, 0, 0, NO_SOUND },
    344     { 1, 1, 20, SOUND_OBJ_POUNDING1_HIGHPRIO },
    345     { 0, 0, 0, NO_SOUND },
    346     { 0, 0, 0, NO_SOUND },
    347     { 1, 15, -1, SOUND_OBJ_POUNDING1_HIGHPRIO },
    348     { 0, 0, 0, NO_SOUND },
    349     { 0, 0, 0, NO_SOUND },
    350     { 0, 0, 0, NO_SOUND },
    351     { 0, 0, 0, NO_SOUND },
    352     { 1, 33, -1, SOUND_OBJ_POUNDING1_HIGHPRIO },
    353     { 0, 0, 0, NO_SOUND },
    354     { 1, 1, 15, SOUND_OBJ_POUNDING1_HIGHPRIO },
    355 };
    356 
    357 void king_bobomb_move(void) {
    358     cur_obj_update_floor_and_walls();
    359 
    360     if (o->oKingBobombUnkF8 == 0) {
    361         cur_obj_move_standard(-78);
    362     } else {
    363         cur_obj_move_using_fvel_and_gravity();
    364     }
    365 
    366     cur_obj_call_action_function(sKingBobombActions);
    367     exec_anim_sound_state(sKingBobombSoundStates);
    368 
    369     if (o->oDistanceToMario < 5000.0f) {
    370         cur_obj_enable_rendering();
    371     } else {
    372         cur_obj_disable_rendering();
    373     }
    374 }
    375 
    376 void bhv_king_bobomb_loop(void) {
    377     f32 sp34 = 20.0f;
    378     f32 sp30 = 50.0f;
    379     UNUSED u8 filler[8];
    380 
    381     o->oInteractionSubtype |= INT_SUBTYPE_GRABS_MARIO;
    382 
    383     switch (o->oHeldState) {
    384         case HELD_FREE:
    385             king_bobomb_move();
    386             break;
    387         case HELD_HELD:
    388             cur_obj_unrender_set_action_and_anim(6, 1);
    389             break;
    390         case HELD_THROWN:
    391         case HELD_DROPPED:
    392             cur_obj_get_thrown_or_placed(sp34, sp30, 4);
    393             cur_obj_become_intangible();
    394             o->oPosY += 20.0f;
    395             break;
    396     }
    397 
    398     o->oInteractStatus = 0;
    399 }