sm64pc/src/game/behaviors/ukiki_cage.inc.c

107 lines
2.7 KiB
C
Raw Normal View History

2019-08-25 04:46:40 +00:00
// ukiki_cage.c.inc
2019-09-01 19:50:50 +00:00
/**
* @file Contains behavior for the ukiki's cage
* and the star within the cage.
*
* The cage is parent of the cage star and another
* dummy object referenced by ukiki (bhvUkikiCageChild).
*/
/**
* Behavior for the cage star.
* Only really used for initializing then spawning the star.
*
* Not an actual star object until later.
*/
void bhv_ukiki_cage_star_loop(void) {
switch (o->oAction) {
case UKIKI_CAGE_STAR_ACT_IN_CAGE:
// Initialization to see if the star is collected (blue) or not (yellow).
if (o->oTimer == 0) {
2020-03-02 03:42:52 +00:00
if (bit_shift_left(1)
2019-09-01 19:50:50 +00:00
& save_file_get_star_flags(gCurrSaveFileNum - 1, gCurrCourseNum - 1)) {
2020-03-02 03:42:52 +00:00
cur_obj_set_model(MODEL_TRANSPARENT_STAR);
2019-09-01 19:50:50 +00:00
}
}
2019-08-25 04:46:40 +00:00
2020-03-02 03:42:52 +00:00
obj_copy_pos(o, o->parentObj);
obj_copy_behavior_params(o, o->parentObj);
2019-08-25 04:46:40 +00:00
2019-09-01 19:50:50 +00:00
// When they cage hides itself, spawn particles and the star.
if (o->parentObj->oAction == UKIKI_CAGE_ACT_HIDE) {
o->oAction++;
}
2019-08-25 04:46:40 +00:00
break;
2019-09-01 19:50:50 +00:00
case UKIKI_CAGE_STAR_ACT_SPAWN_STAR:
2020-03-02 03:42:52 +00:00
obj_mark_for_deletion(o);
spawn_mist_particles();
2019-09-01 19:50:50 +00:00
spawn_triangle_break_particles(20, 138, 0.7, 3);
2020-03-02 03:42:52 +00:00
spawn_default_star(2500.0f, -1200.0f, 1300.0f);
2019-09-01 19:50:50 +00:00
break;
2019-08-25 04:46:40 +00:00
}
2019-09-01 19:50:50 +00:00
// Spin to look like a star.
o->oFaceAngleYaw += 0x400;
2019-08-25 04:46:40 +00:00
}
2019-09-01 19:50:50 +00:00
/**
* Default state until ukiki reaches the cage.
*/
void ukiki_cage_act_wait_for_ukiki(void) {
if (o->oUkikiCageNextAction != UKIKI_CAGE_ACT_WAIT_FOR_UKIKI) {
o->oAction = UKIKI_CAGE_ACT_SPIN;
2019-08-25 04:46:40 +00:00
}
2019-09-01 19:50:50 +00:00
load_object_collision_model();
2019-08-25 04:46:40 +00:00
}
2019-09-01 19:50:50 +00:00
/**
* Spin once ukiki has landed on the cage.
*/
void ukiki_cage_act_spin(void) {
if (o->oUkikiCageNextAction != UKIKI_CAGE_ACT_SPIN) {
o->oAction = UKIKI_CAGE_ACT_FALL;
2019-08-25 04:46:40 +00:00
}
2019-09-01 19:50:50 +00:00
o->oMoveAngleYaw += 0x800;
load_object_collision_model();
2019-08-25 04:46:40 +00:00
}
2019-09-01 19:50:50 +00:00
/**
* Assist ukiki in his death.
*/
void ukiki_cage_act_fall(void) {
//! (PARTIAL_UPDATE)
2020-03-02 03:42:52 +00:00
cur_obj_update_floor_and_walls();
cur_obj_move_standard(78);
2019-09-01 19:50:50 +00:00
if (o->oMoveFlags & (OBJ_MOVE_LANDED | OBJ_MOVE_ENTERED_WATER)) {
o->oAction = UKIKI_CAGE_ACT_HIDE;
2019-08-25 04:46:40 +00:00
}
}
2019-09-01 19:50:50 +00:00
/**
* Hide once we've exploded.
*
* Perhaps deleting the object would be better than
* hiding the object?
*/
void ukiki_cage_act_hide(void) {
2020-03-02 03:42:52 +00:00
cur_obj_hide();
2019-09-01 19:50:50 +00:00
}
/**
* An array of the cage's actions.
*/
void (*sUkikiCageActions[])(void) = {
ukiki_cage_act_wait_for_ukiki, ukiki_cage_act_spin,
ukiki_cage_act_fall, ukiki_cage_act_hide,
};
/**
* Main behavior loop for the cage. Only calls the relevant action.
*/
void bhv_ukiki_cage_loop(void) {
2020-03-02 03:42:52 +00:00
cur_obj_call_action_function(sUkikiCageActions);
2019-08-25 04:46:40 +00:00
}