boo_cage.inc.c (3782B)
1 2 /** 3 * Behavior for bhvBooCage. 4 * This is the cage inside the big boo in the castle courtyard 5 * that lets Mario enter BBH. It has its own special interaction type, 6 * INTERACT_BBH_ENTRANCE. 7 */ 8 9 /** 10 * Boo cage hitbox. It's not tangible; this is the hitbox 11 * Mario has to enter to enter BBH. 12 */ 13 static struct ObjectHitbox sBooCageHitbox = { 14 /* interactType: */ INTERACT_BBH_ENTRANCE, 15 /* downOffset: */ 0, 16 /* damageOrCoinValue: */ 0, 17 /* health: */ 0, 18 /* numLootCoins: */ 0, 19 /* radius: */ 120, 20 /* height: */ 300, 21 /* hurtboxRadius: */ 0, 22 /* hurtboxHeight: */ 0, 23 }; 24 25 /** 26 * Update function for bhvBooCage. 27 */ 28 void bhv_boo_cage_loop(void) { 29 UNUSED u8 filler[4]; 30 31 obj_set_hitbox(o, &sBooCageHitbox); 32 33 switch (o->oAction) { 34 case BOO_CAGE_ACT_IN_BOO: 35 // Don't let Mario enter BBH until the boo is killed 36 cur_obj_become_intangible(); 37 38 // Useless scale. This is also found in the code for BOO_CAGE_ACT_ON_GROUND. 39 // Was the boo cage originally meant to have been shrunk and grow while falling? 40 cur_obj_scale(1.0f); 41 42 // If the cage's parent boo is killed, set the action to BOO_CAGE_ACT_FALLING, 43 // give the cage an initial Y velocity of 60 units/frame, and play the puzzle jingle. 44 // Otherwise, stay inside the boo. 45 if (o->parentObj->oBooDeathStatus != BOO_DEATH_STATUS_ALIVE) { 46 o->oAction++; 47 o->oVelY = 60.0f; 48 play_puzzle_jingle(); 49 } else { 50 obj_copy_pos_and_angle(o, o->parentObj); 51 } 52 53 break; 54 55 case BOO_CAGE_ACT_FALLING: 56 // Reset pitch and roll. This is useless, since the cage never rotates. 57 // Was it meant to rotate inside the boo, like the beta boo key? 58 o->oFaceAnglePitch = 0; 59 o->oFaceAngleRoll = 0; 60 61 // Apply standard physics to the cage. 62 cur_obj_update_floor_and_walls(); 63 cur_obj_move_standard(-78); 64 65 // Spawn sparkles while the cage falls. 66 spawn_object(o, MODEL_NONE, bhvSparkleSpawn); 67 68 // When the cage lands/bounces, play a landing/bouncing sound. 69 if (o->oMoveFlags & OBJ_MOVE_LANDED) { 70 cur_obj_play_sound_2(SOUND_GENERAL_SOFT_LANDING); 71 } 72 73 // Once the cage stops bouncing and settles on the ground, 74 // set the action to BOO_CAGE_ACT_ON_GROUND. 75 // This is the only use of the OBJ_MOVE_AT_WATER_SURFACE flag in the game. 76 // It seems to serve no purpose here. 77 if (o->oMoveFlags 78 & (OBJ_MOVE_UNDERWATER_ON_GROUND | OBJ_MOVE_AT_WATER_SURFACE | OBJ_MOVE_ON_GROUND)) { 79 o->oAction++; 80 } 81 82 break; 83 84 case BOO_CAGE_ACT_ON_GROUND: 85 // Allow Mario to enter the cage once it's still on the ground. 86 cur_obj_become_tangible(); 87 88 // The other useless scale 89 cur_obj_scale(1.0f); 90 91 // Set the action to BOO_CAGE_ACT_MARIO_JUMPING_IN when Mario jumps in. 92 if (obj_check_if_collided_with_object(o, gMarioObject)) { 93 o->oAction++; 94 } 95 96 break; 97 98 case BOO_CAGE_ACT_MARIO_JUMPING_IN: 99 // All this action does is wait 100 frames after Mario starts 100 // jumping into the cage to set the action to BOO_CAGE_ACT_USELESS, 101 // which does nothing. By extension, this action is also useless. 102 103 if (o->oTimer > 100) { 104 o->oAction++; 105 } 106 107 break; 108 109 case BOO_CAGE_ACT_USELESS: 110 break; 111 } 112 }