Path: blob/master/src/game/behaviors/beta_chest.inc.c
7861 views
/**1* Behavior for bhvBetaChestBottom and bhvBetaChestLid.2* These are apparently the beta versions of chests.3* They do not spawn stars or appear in groups; they only4* open and spawn an air bubble. In other words, they're5* practically the same as underwater chests in-game, except6* without any star-giving or puzzle functionality.7*/89/**10* Init function for bhvBetaChestBottom.11*/12void bhv_beta_chest_bottom_init(void) {13// Set the object's model14cur_obj_set_model(MODEL_TREASURE_CHEST_BASE);1516// ??? Pointless code?17// Maybe chests were originally intended to have random yaws.18// Shoshinkai 1995 footage shows chests in DDD scattered around19// a point with different yaws. Maybe this feature was lazily20// cancelled by setting the yaw to 0, right before this beta21// object was discarded?22o->oMoveAngleYaw = random_u16();23o->oMoveAngleYaw = 0;2425// Spawn the chest lid 97 units in the +Y direction and 77 units in the -Z direction.26spawn_object_relative(0, 0, 97, -77, o, MODEL_TREASURE_CHEST_LID, bhvBetaChestLid);27}2829/**30* Update function for bhvBetaChestBottom.31* This gives the chest a "virtual hitbox" that pushes Mario away32* with radius 200 units and height 200 units.33*/34void bhv_beta_chest_bottom_loop(void) {35cur_obj_push_mario_away_from_cylinder(200.0f, 200.0f);36}3738/**39* Update function for bhvBetaChestLid.40* The chest lid handles all the logic of the chest,41* namely opening the chest and spawning an air bubble.42*/43void bhv_beta_chest_lid_loop(void) {44switch (o->oAction) {45case BETA_CHEST_ACT_IDLE_CLOSED:46if (dist_between_objects(o->parentObj, gMarioObject) < 300.0f) {47o->oAction++; // Set to BETA_CHEST_ACT_OPENING48}4950break;51case BETA_CHEST_ACT_OPENING:52if (o->oTimer == 0) {53// Spawn the bubble 80 units in the -Y direction and 120 units in the +Z direction.54spawn_object_relative(0, 0, -80, 120, o, MODEL_BUBBLE, bhvWaterAirBubble);55play_sound(SOUND_GENERAL_CLAM_SHELL1, o->header.gfx.cameraToObject);56}5758// Rotate the lid 0x400 (1024) angle units per frame backwards.59// When the lid becomes vertical, stop rotating.60o->oFaceAnglePitch -= 0x400;61if (o->oFaceAnglePitch < -0x4000) {62o->oAction++; // Set to BETA_CHEST_ACT_IDLE_OPEN63}6465// Fall-through66case BETA_CHEST_ACT_IDLE_OPEN:67break;68}69}707172