2019-08-25 04:46:40 +00:00
|
|
|
// sparkle_spawn_star.c.inc
|
|
|
|
|
|
|
|
struct ObjectHitbox sSparkleSpawnStarHitbox = {
|
|
|
|
/* interactType: */ INTERACT_STAR_OR_KEY,
|
|
|
|
/* downOffset: */ 0,
|
|
|
|
/* damageOrCoinValue: */ 0,
|
|
|
|
/* health: */ 0,
|
|
|
|
/* numLootCoins: */ 0,
|
|
|
|
/* radius: */ 80,
|
|
|
|
/* height: */ 50,
|
|
|
|
/* hurtboxRadius: */ 0,
|
|
|
|
/* hurtboxHeight: */ 0,
|
|
|
|
};
|
|
|
|
|
2020-01-03 15:38:57 +00:00
|
|
|
void bhv_spawned_star_init(void) {
|
2019-08-25 04:46:40 +00:00
|
|
|
s32 sp24;
|
2019-09-01 19:50:50 +00:00
|
|
|
if (!(o->oInteractionSubtype & INT_SUBTYPE_NO_EXIT))
|
2019-08-25 04:46:40 +00:00
|
|
|
o->oBehParams = o->parentObj->oBehParams;
|
|
|
|
sp24 = (o->oBehParams >> 24) & 0xFF;
|
2020-03-02 03:42:52 +00:00
|
|
|
if (bit_shift_left(sp24) & save_file_get_star_flags(gCurrSaveFileNum - 1, gCurrCourseNum - 1))
|
|
|
|
cur_obj_set_model(MODEL_TRANSPARENT_STAR);
|
|
|
|
cur_obj_play_sound_2(SOUND_GENERAL2_STAR_APPEARS);
|
2019-08-25 04:46:40 +00:00
|
|
|
}
|
|
|
|
|
2020-03-02 03:42:52 +00:00
|
|
|
void set_sparkle_spawn_star_hitbox(void) {
|
|
|
|
obj_set_hitbox(o, &sSparkleSpawnStarHitbox);
|
2019-08-25 04:46:40 +00:00
|
|
|
if (o->oInteractStatus & INT_STATUS_INTERACTED) {
|
|
|
|
mark_obj_for_deletion(o);
|
|
|
|
o->oInteractStatus = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-02 03:42:52 +00:00
|
|
|
void set_home_to_mario(void) {
|
2019-08-25 04:46:40 +00:00
|
|
|
f32 sp1C;
|
|
|
|
f32 sp18;
|
|
|
|
o->oHomeX = gMarioObject->oPosX;
|
|
|
|
o->oHomeZ = gMarioObject->oPosZ;
|
|
|
|
o->oHomeY = gMarioObject->oPosY;
|
|
|
|
o->oHomeY += 250.0f;
|
|
|
|
o->oPosY = o->oHomeY;
|
|
|
|
sp1C = o->oHomeX - o->oPosX;
|
|
|
|
sp18 = o->oHomeZ - o->oPosZ;
|
|
|
|
o->oForwardVel = sqrtf(sp1C * sp1C + sp18 * sp18) / 23.0f;
|
|
|
|
}
|
|
|
|
|
2020-03-02 03:42:52 +00:00
|
|
|
void set_y_home_to_pos(void) {
|
2019-08-25 04:46:40 +00:00
|
|
|
o->oForwardVel = 0;
|
|
|
|
o->oHomeY = o->oPosY;
|
|
|
|
}
|
|
|
|
|
2020-03-02 03:42:52 +00:00
|
|
|
void slow_star_rotation(void) {
|
2019-08-25 04:46:40 +00:00
|
|
|
if (o->oAngleVelYaw > 0x400)
|
|
|
|
o->oAngleVelYaw -= 0x40;
|
|
|
|
}
|
|
|
|
|
2020-01-03 15:38:57 +00:00
|
|
|
void bhv_spawned_star_loop(void) {
|
2019-08-25 04:46:40 +00:00
|
|
|
if (o->oAction == 0) {
|
|
|
|
if (o->oTimer == 0) {
|
2019-10-05 19:08:05 +00:00
|
|
|
cutscene_object(CUTSCENE_STAR_SPAWN, o);
|
2019-08-25 04:46:40 +00:00
|
|
|
set_time_stop_flags(TIME_STOP_ENABLED | TIME_STOP_MARIO_AND_DOORS);
|
|
|
|
o->activeFlags |= 0x20;
|
|
|
|
o->oAngleVelYaw = 0x800;
|
|
|
|
if (o->oBehParams2ndByte == 0)
|
2020-03-02 03:42:52 +00:00
|
|
|
set_home_to_mario();
|
2019-08-25 04:46:40 +00:00
|
|
|
else
|
2020-03-02 03:42:52 +00:00
|
|
|
set_y_home_to_pos();
|
|
|
|
o->oMoveAngleYaw = cur_obj_angle_to_home();
|
2019-08-25 04:46:40 +00:00
|
|
|
o->oVelY = 50.0f;
|
|
|
|
o->oGravity = -4.0f;
|
2020-03-02 03:42:52 +00:00
|
|
|
spawn_mist_particles();
|
2019-08-25 04:46:40 +00:00
|
|
|
}
|
2020-03-02 03:42:52 +00:00
|
|
|
cur_obj_play_sound_1(SOUND_ENV_STAR);
|
2019-08-25 04:46:40 +00:00
|
|
|
spawn_object(o, MODEL_NONE, bhvSparkleSpawn);
|
|
|
|
if (o->oVelY < 0 && o->oPosY < o->oHomeY) {
|
|
|
|
o->oAction++;
|
|
|
|
o->oForwardVel = 0;
|
|
|
|
o->oVelY = 20.0f;
|
|
|
|
o->oGravity = -1.0f;
|
2019-09-01 19:50:50 +00:00
|
|
|
if (o->oInteractionSubtype & INT_SUBTYPE_NO_EXIT)
|
2019-08-25 04:46:40 +00:00
|
|
|
#ifdef VERSION_JP
|
|
|
|
play_power_star_jingle(FALSE);
|
|
|
|
#else
|
|
|
|
play_power_star_jingle(TRUE);
|
|
|
|
#endif
|
|
|
|
else
|
|
|
|
play_power_star_jingle(TRUE);
|
|
|
|
}
|
|
|
|
} else if (o->oAction == 1) {
|
|
|
|
if (o->oVelY < -4.0f)
|
|
|
|
o->oVelY = -4.0f;
|
|
|
|
if (o->oVelY < 0 && o->oPosY < o->oHomeY) {
|
2020-01-03 15:38:57 +00:00
|
|
|
gObjCutsceneDone = TRUE;
|
2019-08-25 04:46:40 +00:00
|
|
|
o->oVelY = 0;
|
|
|
|
o->oGravity = 0;
|
|
|
|
o->oAction++;
|
|
|
|
}
|
|
|
|
spawn_object(o, MODEL_NONE, bhvSparkleSpawn);
|
|
|
|
} else if (o->oAction == 2) {
|
2020-01-03 15:38:57 +00:00
|
|
|
if (gCamera->cutscene == 0 && gRecentCutscene == 0) {
|
2019-08-25 04:46:40 +00:00
|
|
|
clear_time_stop_flags(TIME_STOP_ENABLED | TIME_STOP_MARIO_AND_DOORS);
|
|
|
|
o->activeFlags &= ~0x20;
|
|
|
|
o->oAction++;
|
|
|
|
}
|
|
|
|
} else {
|
2020-03-02 03:42:52 +00:00
|
|
|
set_sparkle_spawn_star_hitbox();
|
|
|
|
slow_star_rotation();
|
2019-08-25 04:46:40 +00:00
|
|
|
}
|
2020-03-02 03:42:52 +00:00
|
|
|
cur_obj_move_using_fvel_and_gravity();
|
2019-08-25 04:46:40 +00:00
|
|
|
o->oFaceAngleYaw += o->oAngleVelYaw;
|
|
|
|
o->oInteractStatus = 0;
|
|
|
|
}
|
|
|
|
|
2020-01-03 15:38:57 +00:00
|
|
|
void bhv_spawn_star_no_level_exit(u32 sp20) {
|
|
|
|
struct Object *sp1C = spawn_object(o, MODEL_STAR, bhvSpawnedStarNoLevelExit);
|
2019-08-25 04:46:40 +00:00
|
|
|
sp1C->oBehParams = sp20 << 24;
|
2019-09-01 19:50:50 +00:00
|
|
|
sp1C->oInteractionSubtype = INT_SUBTYPE_NO_EXIT;
|
2020-03-02 03:42:52 +00:00
|
|
|
obj_set_angle(sp1C, 0, 0, 0);
|
2019-08-25 04:46:40 +00:00
|
|
|
}
|