2019-08-25 04:46:40 +00:00
|
|
|
// grand_star.c.inc
|
|
|
|
|
2020-03-02 03:42:52 +00:00
|
|
|
s32 arc_to_goal_pos(Vec3f a0, Vec3f a1, f32 yVel, f32 gravity) {
|
2019-08-25 04:46:40 +00:00
|
|
|
f32 dx = a0[0] - a1[0];
|
|
|
|
f32 dz = a0[2] - a1[2];
|
|
|
|
f32 planarDist = sqrtf(dx * dx + dz * dz);
|
|
|
|
s32 time;
|
|
|
|
o->oMoveAngleYaw = atan2s(dz, dx);
|
|
|
|
o->oVelY = yVel;
|
|
|
|
o->oGravity = gravity;
|
|
|
|
time = -2.0f / o->oGravity * yVel - 1.0f;
|
|
|
|
o->oForwardVel = planarDist / time;
|
|
|
|
return time;
|
|
|
|
}
|
|
|
|
|
2020-03-02 03:42:52 +00:00
|
|
|
void grand_star_zero_velocity(void) {
|
2019-08-25 04:46:40 +00:00
|
|
|
o->oGravity = 0.0f;
|
|
|
|
o->oVelY = 0.0f;
|
|
|
|
o->oForwardVel = 0.0f;
|
|
|
|
}
|
|
|
|
|
|
|
|
void bhv_grand_star_loop(void) {
|
|
|
|
UNUSED s32 unused;
|
|
|
|
Vec3f sp28;
|
|
|
|
sp28[0] = sp28[1] = sp28[2] = 0.0f;
|
|
|
|
if (o->oAction == 0) {
|
|
|
|
if (o->oTimer == 0) {
|
2020-03-02 03:42:52 +00:00
|
|
|
obj_set_angle(o, 0, 0, 0);
|
2019-08-25 04:46:40 +00:00
|
|
|
o->oAngleVelYaw = 0x400;
|
2020-03-02 03:42:52 +00:00
|
|
|
cur_obj_play_sound_2(SOUND_GENERAL2_STAR_APPEARS);
|
2019-08-25 04:46:40 +00:00
|
|
|
}
|
|
|
|
if (o->oTimer > 70)
|
|
|
|
o->oAction++;
|
2020-03-02 03:42:52 +00:00
|
|
|
spawn_sparkle_particles(3, 200, 80, -60);
|
2019-08-25 04:46:40 +00:00
|
|
|
} else if (o->oAction == 1) {
|
|
|
|
if (o->oTimer == 0) {
|
2020-03-02 03:42:52 +00:00
|
|
|
cur_obj_play_sound_2(SOUND_GENERAL_GRAND_STAR);
|
2019-10-05 19:08:05 +00:00
|
|
|
cutscene_object(CUTSCENE_STAR_SPAWN, o);
|
2020-03-02 03:42:52 +00:00
|
|
|
o->oGrandStarUnk108 = arc_to_goal_pos(sp28, &o->oPosX, 80.0f, -2.0f);
|
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
|
|
|
if (o->oSubAction == 0) {
|
|
|
|
if (o->oPosY < o->oHomeY) {
|
|
|
|
o->oPosY = o->oHomeY;
|
|
|
|
o->oVelY = 60.0f;
|
|
|
|
o->oForwardVel = 0.0f;
|
|
|
|
o->oSubAction++;
|
2020-03-02 03:42:52 +00:00
|
|
|
cur_obj_play_sound_2(SOUND_GENERAL_GRAND_STAR_JUMP);
|
2019-08-25 04:46:40 +00:00
|
|
|
}
|
|
|
|
} else if (o->oVelY < 0.0f && o->oPosY < o->oHomeY + 200.0f) {
|
|
|
|
o->oPosY = o->oHomeY + 200.0f;
|
2020-03-02 03:42:52 +00:00
|
|
|
grand_star_zero_velocity();
|
2020-01-03 15:38:57 +00:00
|
|
|
gObjCutsceneDone = 1;
|
2019-08-25 04:46:40 +00:00
|
|
|
set_mario_npc_dialog(0);
|
|
|
|
o->oAction++;
|
|
|
|
o->oInteractStatus = 0;
|
2020-03-02 03:42:52 +00:00
|
|
|
cur_obj_play_sound_2(SOUND_GENERAL_GRAND_STAR_JUMP);
|
2019-08-25 04:46:40 +00:00
|
|
|
}
|
2020-03-02 03:42:52 +00:00
|
|
|
spawn_sparkle_particles(3, 200, 80, -60);
|
2019-08-25 04:46:40 +00:00
|
|
|
} else {
|
2020-03-02 03:42:52 +00:00
|
|
|
cur_obj_become_tangible();
|
2019-08-25 04:46:40 +00:00
|
|
|
if (o->oInteractStatus & INT_STATUS_INTERACTED) {
|
2020-03-02 03:42:52 +00:00
|
|
|
obj_mark_for_deletion(o);
|
2019-08-25 04:46:40 +00:00
|
|
|
o->oInteractStatus = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (o->oAngleVelYaw > 0x400)
|
|
|
|
o->oAngleVelYaw -= 0x100;
|
|
|
|
o->oFaceAngleYaw += o->oAngleVelYaw;
|
2020-03-02 03:42:52 +00:00
|
|
|
cur_obj_scale(2.0f);
|
2019-08-25 04:46:40 +00:00
|
|
|
o->oGraphYOffset = 110.0f;
|
|
|
|
}
|