sm64

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

wind.inc.c (1377B)


      1 // wind.inc.c
      2 
      3 void spawn_wind_particles(s16 pitch, s16 yaw) {
      4     s32 i;
      5     for (i = 0; i < 3; i++) {
      6         struct Object *wind = spawn_object(o, MODEL_MIST, bhvWind);
      7         wind->oMoveAngleYaw = yaw;
      8         wind->oMoveAnglePitch = pitch;
      9     }
     10 }
     11 
     12 void bhv_wind_loop(void) {
     13     s16 sp2E = 500;
     14     f32 scale = 1.0f;
     15 
     16     if (o->oTimer == 0) {
     17         o->oOpacity = 100;
     18         if (o->oMoveAnglePitch == 0) {
     19             obj_translate_xz_random(o, 900.0f);
     20             o->oPosX += sins(o->oMoveAngleYaw + 0x8000) * sp2E; // NOP as Pitch is 0
     21             o->oPosY += 80.0f + random_f32_around_zero(200.0f);
     22             o->oPosZ += coss(o->oMoveAngleYaw + 0x8000) * sp2E; // -coss(a) * sp2E
     23             o->oMoveAngleYaw += random_f32_around_zero(4000.0f);
     24             o->oForwardVel = random_float() * 70.0f + 50.0f;
     25         } else {
     26             obj_translate_xz_random(o, 600.0f);
     27             o->oPosY -= sp2E - 200; // 300
     28             o->oVelY = random_float() * 30.0f + 50.0f;
     29             o->oMoveAngleYaw = random_u16();
     30             o->oForwardVel = 10.0f;
     31         }
     32         obj_set_billboard(o);
     33         cur_obj_scale(scale);
     34     }
     35 
     36     if (o->oTimer > 8) {
     37         obj_mark_for_deletion(o);
     38     }
     39 
     40     o->oFaceAnglePitch += 4000.0f + 2000.0f * random_float();
     41     o->oFaceAngleYaw += 4000.0f + 2000.0f * random_float();
     42     cur_obj_move_using_fvel_and_gravity();
     43 }