jumping_box.inc.c (2138B)
1 // jumping_box.inc.c 2 3 struct ObjectHitbox sJumpingBoxHitbox = { 4 /* interactType: */ INTERACT_GRABBABLE, 5 /* downOffset: */ 20, 6 /* damageOrCoinValue: */ 0, 7 /* health: */ 1, 8 /* numLootCoins: */ 5, 9 /* radius: */ 150, 10 /* height: */ 250, 11 /* hurtboxRadius: */ 150, 12 /* hurtboxHeight: */ 250, 13 }; 14 15 void jumping_box_act_0(void) { 16 if (o->oSubAction == 0) { 17 if (o->oJumpingBoxUnkF8-- < 0) { 18 o->oSubAction++; 19 } 20 21 if (o->oTimer > o->oJumpingBoxUnkF4) { 22 o->oVelY = random_float() * 5.0f + 15.0f; 23 o->oSubAction++; 24 } 25 } else if (o->oMoveFlags & OBJ_MOVE_ON_GROUND) { 26 o->oSubAction = 0; 27 o->oJumpingBoxUnkF8 = random_float() * 60.0f + 30.0f; 28 } 29 } 30 31 void jumping_box_act_1(void) { 32 if (o->oMoveFlags & (OBJ_MOVE_HIT_WALL | OBJ_MOVE_MASK_IN_WATER | OBJ_MOVE_LANDED)) { 33 obj_mark_for_deletion(o); 34 spawn_mist_particles(); 35 } 36 } 37 38 void (*sJumpingBoxActions[])(void) = { 39 jumping_box_act_0, 40 jumping_box_act_1, 41 }; 42 43 void jumping_box_free_update(void) { 44 cur_obj_set_model(MODEL_BREAKABLE_BOX); 45 cur_obj_scale(0.5f); 46 obj_set_hitbox(o, &sJumpingBoxHitbox); 47 cur_obj_update_floor_and_walls(); 48 cur_obj_move_standard(78); 49 cur_obj_call_action_function(sJumpingBoxActions); 50 } 51 52 void bhv_jumping_box_loop(void) { 53 switch (o->oHeldState) { 54 case HELD_FREE: 55 jumping_box_free_update(); 56 break; 57 58 case HELD_HELD: 59 obj_copy_pos(o, gMarioObject); 60 cur_obj_set_model(MODEL_BREAKABLE_BOX_SMALL); 61 cur_obj_unrender_set_action_and_anim(-1, 0); 62 break; 63 64 case HELD_THROWN: 65 cur_obj_get_thrown_or_placed(40.0f, 20.0f, 1); 66 break; 67 68 case HELD_DROPPED: 69 cur_obj_get_dropped(); 70 o->oAction = 1; 71 break; 72 } 73 74 if (o->oInteractStatus & INT_STATUS_STOP_RIDING) { 75 create_sound_spawner(SOUND_GENERAL_BREAK_BOX); 76 obj_explode_and_spawn_coins(46.0f, 1); 77 } 78 79 o->oInteractStatus = 0; 80 }