sm64

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

koopa_shell.inc.c (3128B)


      1 // koopa_shell.inc.c
      2 
      3 struct ObjectHitbox sKoopaShellHitbox = {
      4     /* interactType:      */ INTERACT_KOOPA_SHELL,
      5     /* downOffset:        */ 0,
      6     /* damageOrCoinValue: */ 4,
      7     /* health:            */ 1,
      8     /* numLootCoins:      */ 1,
      9     /* radius:            */ 50,
     10     /* height:            */ 50,
     11     /* hurtboxRadius:     */ 50,
     12     /* hurtboxHeight:     */ 50,
     13 };
     14 
     15 void koopa_shell_spawn_water_drop(void) {
     16     UNUSED u8 filler[4];
     17 
     18     spawn_object(o, MODEL_WAVE_TRAIL, bhvObjectWaveTrail);
     19 
     20     if (gMarioStates[0].forwardVel > 10.0f) {
     21         struct Object *drop = spawn_object_with_scale(o, MODEL_WHITE_PARTICLE_SMALL,
     22                                                       bhvWaterDroplet, 1.5f);
     23         drop->oVelY = random_float() * 30.0f;
     24         obj_translate_xz_random(drop, 110.0f);
     25     }
     26 }
     27 
     28 void bhv_koopa_shell_flame_loop(void) {
     29     if (o->oTimer == 0) {
     30         o->oMoveAngleYaw = random_u16();
     31         o->oVelY = random_float() * 30.0f;
     32         o->oGravity = -4.0f;
     33         o->oAnimState = random_float() * 10.0f;
     34         obj_translate_xz_random(o, 110.0f);
     35         o->oKoopaShellFlameScale = 4.0f;
     36     }
     37 
     38     cur_obj_update_floor_height();
     39     cur_obj_move_using_fvel_and_gravity();
     40 
     41     if (o->oFloorHeight > o->oPosY || o->oTimer > 10) {
     42         obj_mark_for_deletion(o);
     43     }
     44 
     45     o->oKoopaShellFlameScale += -0.3;
     46     cur_obj_scale(o->oKoopaShellFlameScale);
     47 }
     48 
     49 void bhv_koopa_shell_flame_spawn(void) {
     50     s32 i;
     51     for (i = 0; i < 2; i++) {
     52         spawn_object(o, MODEL_RED_FLAME, bhvKoopaShellFlame);
     53     }
     54 }
     55 
     56 void koopa_shell_spawn_sparkles(f32 a) {
     57     struct Object *sp1C = spawn_object(o, MODEL_NONE, bhvSparkleSpawn);
     58     sp1C->oPosY += a;
     59 }
     60 
     61 void bhv_koopa_shell_loop(void) {
     62     struct Surface *sp34;
     63 
     64     obj_set_hitbox(o, &sKoopaShellHitbox);
     65     cur_obj_scale(1.0f);
     66 
     67     switch (o->oAction) {
     68         case 0:
     69             cur_obj_update_floor_and_walls();
     70             cur_obj_if_hit_wall_bounce_away();
     71 
     72             if (o->oInteractStatus & INT_STATUS_INTERACTED) {
     73                 o->oAction++;
     74             }
     75 
     76             o->oFaceAngleYaw += 0x1000;
     77             cur_obj_move_standard(-20);
     78             koopa_shell_spawn_sparkles(10.0f);
     79             break;
     80 
     81         case 1:
     82             obj_copy_pos(o, gMarioObject);
     83             sp34 = cur_obj_update_floor_height_and_get_floor();
     84 
     85             if (absf(find_water_level(o->oPosX, o->oPosZ) - o->oPosY) < 10.0f) {
     86                 koopa_shell_spawn_water_drop();
     87             } else if (absf(o->oPosY - o->oFloorHeight) < 5.0f) {
     88                 if (sp34 != NULL && sp34->type == 1) {
     89                     bhv_koopa_shell_flame_spawn();
     90                 } else {
     91                     koopa_shell_spawn_sparkles(10.0f);
     92                 }
     93             } else {
     94                 koopa_shell_spawn_sparkles(10.0f);
     95             }
     96 
     97             o->oFaceAngleYaw = gMarioObject->oMoveAngleYaw;
     98 
     99             if (o->oInteractStatus & INT_STATUS_STOP_RIDING) {
    100                 obj_mark_for_deletion(o);
    101                 spawn_mist_particles();
    102                 o->oAction = 0;
    103             }
    104             break;
    105     }
    106 
    107     o->oInteractStatus = 0;
    108 }