sm64

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

mad_piano.inc.c (2140B)


      1 // mad_piano.inc.c
      2 
      3 static struct ObjectHitbox sMadPianoHitbox = {
      4     /* interactType:      */ INTERACT_MR_BLIZZARD,
      5     /* downOffset:        */ 0,
      6     /* damageOrCoinValue: */ 3,
      7     /* health:            */ 99,
      8     /* numLootCoins:      */ 0,
      9     /* radius:            */ 200,
     10     /* height:            */ 150,
     11     /* hurtboxRadius:     */ 200,
     12     /* hurtboxHeight:     */ 150,
     13 };
     14 
     15 static void mad_piano_act_wait(void) {
     16     cur_obj_init_animation_with_sound(0);
     17 
     18     if (o->oDistanceToMario < 500.0f) {
     19         if (o->oTimer > 20 && gMarioStates[0].forwardVel > 10.0f) {
     20             o->oAction = MAD_PIANO_ACT_ATTACK;
     21             cur_obj_become_tangible();
     22         }
     23     } else {
     24         o->oTimer = 0;
     25     }
     26 
     27     cur_obj_push_mario_away_from_cylinder(280.0f, 150.0f);
     28 }
     29 
     30 static void mad_piano_act_attack(void) {
     31     cur_obj_update_floor_and_walls();
     32     cur_obj_init_animation_with_sound(1);
     33     cur_obj_play_sound_at_anim_range(0, 0, SOUND_OBJ_MAD_PIANO_CHOMPING);
     34 
     35     if (o->oDistanceToMario < 500.0f) {
     36         o->oTimer = 0;
     37     }
     38 
     39     if (o->oTimer > 80 && cur_obj_check_if_near_animation_end()) {
     40         o->oAction = MAD_PIANO_ACT_WAIT;
     41         o->oForwardVel = 0.0f;
     42         cur_obj_become_intangible();
     43     } else {
     44         f32 dx = o->oPosX - o->oHomeX;
     45         f32 dz = o->oPosZ - o->oHomeZ;
     46         f32 distToHome = sqrtf(dx * dx + dz * dz);
     47 
     48         if (distToHome > 400.0f) {
     49             distToHome = 400.0f / distToHome;
     50             o->oPosX = o->oHomeX + dx * distToHome;
     51             o->oPosZ = o->oHomeZ + dz * distToHome;
     52         }
     53 
     54         cur_obj_rotate_yaw_toward(o->oAngleToMario, 400);
     55         o->oForwardVel = 5.0f;
     56     }
     57 
     58     obj_check_attacks(&sMadPianoHitbox, o->oAction);
     59     cur_obj_move_standard(78);
     60 }
     61 
     62 void bhv_mad_piano_update(void) {
     63     if (!(o->activeFlags & ACTIVE_FLAG_IN_DIFFERENT_ROOM)) {
     64         o->oFaceAngleYaw = o->oMoveAngleYaw - 0x4000;
     65 
     66         switch (o->oAction) {
     67             case MAD_PIANO_ACT_WAIT:
     68                 mad_piano_act_wait();
     69                 break;
     70             case MAD_PIANO_ACT_ATTACK:
     71                 mad_piano_act_attack();
     72                 break;
     73         }
     74     }
     75 }