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

80 lines
1.8 KiB
C
Raw Normal View History

2019-08-25 04:46:40 +00:00
// spindel.c.inc
void bhv_spindel_init(void) {
o->oHomeY = o->oPosY;
2019-10-05 19:08:05 +00:00
o->oSpindelUnkF4 = 0;
o->oSpindelUnkF8 = 0;
2019-08-25 04:46:40 +00:00
}
void bhv_spindel_loop(void) {
f32 sp1C;
s32 sp18;
2019-10-05 19:08:05 +00:00
if (o->oSpindelUnkF4 == -1) {
2019-08-25 04:46:40 +00:00
if (o->oTimer == 32) {
2019-10-05 19:08:05 +00:00
o->oSpindelUnkF4 = 0;
2019-08-25 04:46:40 +00:00
o->oTimer = 0;
} else {
o->oVelZ = 0.0f;
o->oAngleVelPitch = 0;
return;
}
}
2019-10-05 19:08:05 +00:00
sp18 = 10 - o->oSpindelUnkF4;
2019-08-25 04:46:40 +00:00
if (sp18 < 0)
sp18 *= -1;
sp18 -= 6;
if (sp18 < 0)
sp18 = 0;
if (o->oTimer == sp18 + 8) {
o->oTimer = 0;
2019-10-05 19:08:05 +00:00
o->oSpindelUnkF4++;
if (o->oSpindelUnkF4 == 20) {
if (o->oSpindelUnkF8 == 0) {
o->oSpindelUnkF8 = 1;
2019-08-25 04:46:40 +00:00
} else {
2019-10-05 19:08:05 +00:00
o->oSpindelUnkF8 = 0;
2019-08-25 04:46:40 +00:00
}
2019-10-05 19:08:05 +00:00
o->oSpindelUnkF4 = -1;
2019-08-25 04:46:40 +00:00
}
}
if (sp18 == 4 || sp18 == 3)
sp18 = 4;
else if (sp18 == 2 || sp18 == 1)
sp18 = 2;
else if (sp18 == 0)
sp18 = 1;
if (o->oTimer < sp18 * 8) {
2019-10-05 19:08:05 +00:00
if (o->oSpindelUnkF8 == 0) {
2019-08-25 04:46:40 +00:00
o->oVelZ = 20 / sp18;
o->oAngleVelPitch = 1024 / sp18;
} else {
o->oVelZ = -20 / sp18;
o->oAngleVelPitch = -1024 / sp18;
}
o->oPosZ += o->oVelZ;
o->oMoveAnglePitch += o->oAngleVelPitch;
if (absf_2(o->oMoveAnglePitch & 0x1fff) < 800.0f && o->oAngleVelPitch != 0) {
2020-03-02 03:42:52 +00:00
cur_obj_play_sound_2(SOUND_GENERAL2_SPINDEL_ROLL);
2019-08-25 04:46:40 +00:00
}
sp1C = sins(o->oMoveAnglePitch * 4) * 23.0;
if (sp1C < 0.0f)
sp1C *= -1.0f;
o->oPosY = o->oHomeY + sp1C;
if (o->oTimer + 1 == sp18 * 8)
2020-01-03 15:38:57 +00:00
set_camera_shake_from_point(SHAKE_POS_SMALL, o->oPosX, o->oPosY, o->oPosZ);
2019-08-25 04:46:40 +00:00
}
}