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