sm64

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

shock_wave.inc.c (1630B)


      1 // shock_wave.inc.c
      2 
      3 /**
      4  * Shockwave scale distance hit points
      5  */
      6 f32 sBowserShockwaveHitPoints[] = { 1.9f, 2.4f, 4.0f, 4.8f };
      7 
      8 /**
      9  * Bowser's shockwave attack main loop
     10  */
     11 void bhv_bowser_shock_wave_loop(void) {
     12     f32 distMin1, distMax1, distMin2, distMax2;
     13     s16 fadeFrames = 70;
     14 
     15     // Scale shockwave as the timer goes on
     16     o->oBowserShockWaveScale = o->oTimer * 10;
     17     cur_obj_scale(o->oBowserShockWaveScale);
     18 
     19     // Slightly reduce opacity each 3 frames
     20     if (gGlobalTimer % 3 != 0) {
     21         o->oOpacity--;
     22     }
     23     // Reduce opacity faster after 70 frames have passed
     24     if (o->oTimer > fadeFrames) {
     25         o->oOpacity -= 5;
     26     }
     27     // Delete object when it's fully transparent
     28     if (o->oOpacity <= 0) {
     29         obj_mark_for_deletion(o);
     30     }
     31     // If object times is less than 70 frame and Mario is not in the air...
     32     if (o->oTimer < fadeFrames && !mario_is_in_air_action()) {
     33         // ..define distance values depending of the scale multiplied by hit points
     34         distMin1 = o->oBowserShockWaveScale * sBowserShockwaveHitPoints[0];
     35         distMax1 = o->oBowserShockWaveScale * sBowserShockwaveHitPoints[1];
     36         distMin2 = o->oBowserShockWaveScale * sBowserShockwaveHitPoints[2];
     37         distMax2 = o->oBowserShockWaveScale * sBowserShockwaveHitPoints[3];
     38         // If Mario is in between distMin and distMax values, shock him
     39         if ((distMin1 < o->oDistanceToMario && o->oDistanceToMario < distMax1)
     40             || (distMin2 < o->oDistanceToMario && o->oDistanceToMario < distMax2)) {
     41             gMarioObject->oInteractStatus |= INT_STATUS_MARIO_SHOCKWAVE;
     42         }
     43     }
     44 }