sm64coopdx/src/game/behaviors/thwomp.inc.c

68 lines
1.9 KiB
C
Raw Normal View History

2019-08-25 04:46:40 +00:00
// thwomp.c.inc
2020-03-02 03:42:52 +00:00
void grindel_thwomp_act_4(void) {
2020-08-12 06:03:30 +00:00
if (o->oTimer == 0) {
2020-06-02 16:44:34 +00:00
o->oThwompRandomTimer = random_float() * 10.0f + 20.0f;
2020-08-12 06:03:30 +00:00
}
if (o->oTimer > o->oThwompRandomTimer) {
2019-08-25 04:46:40 +00:00
o->oAction = 0;
2020-08-12 06:03:30 +00:00
}
2019-08-25 04:46:40 +00:00
}
2020-03-02 03:42:52 +00:00
void grindel_thwomp_act_2(void) {
2019-08-25 04:46:40 +00:00
o->oVelY += -4.0f;
o->oPosY += o->oVelY;
if (o->oPosY < o->oHomeY) {
o->oPosY = o->oHomeY;
o->oVelY = 0;
o->oAction = 3;
}
}
2020-03-02 03:42:52 +00:00
void grindel_thwomp_act_3(void) {
2020-08-12 06:03:30 +00:00
if (o->oTimer == 0) {
int distanceToPlayer = dist_between_objects(o, gMarioStates[0].marioObj);
if (distanceToPlayer < 1500.0f) {
2020-03-02 03:42:52 +00:00
cur_obj_shake_screen(SHAKE_POS_SMALL);
cur_obj_play_sound_2(SOUND_OBJ_THWOMP);
2019-08-25 04:46:40 +00:00
}
2020-08-12 06:03:30 +00:00
}
if (o->oTimer > 9) {
2019-08-25 04:46:40 +00:00
o->oAction = 4;
2020-08-12 06:03:30 +00:00
}
2019-08-25 04:46:40 +00:00
}
2020-03-02 03:42:52 +00:00
void grindel_thwomp_act_1(void) {
2020-08-12 06:03:30 +00:00
if (o->oTimer == 0) {
2020-06-02 16:44:34 +00:00
o->oThwompRandomTimer = random_float() * 30.0f + 10.0f;
2020-08-12 06:03:30 +00:00
}
if (network_owns_object(o) && o->oTimer > o->oThwompRandomTimer) {
2019-08-25 04:46:40 +00:00
o->oAction = 2;
2020-08-12 06:03:30 +00:00
network_send_object(o);
}
2019-08-25 04:46:40 +00:00
}
2020-03-02 03:42:52 +00:00
void grindel_thwomp_act_0(void) {
2019-08-25 04:46:40 +00:00
if (o->oBehParams2ndByte + 40 < o->oTimer) {
o->oAction = 1;
o->oPosY += 5.0f;
} else
o->oPosY += 10.0f;
}
2020-03-02 03:42:52 +00:00
void (*sGrindelThwompActions[])(void) = { grindel_thwomp_act_0, grindel_thwomp_act_1,
grindel_thwomp_act_2, grindel_thwomp_act_3,
grindel_thwomp_act_4 };
2019-08-25 04:46:40 +00:00
void bhv_grindel_thwomp_loop(void) {
if (!network_sync_object_initialized(o)) {
2020-08-12 06:03:30 +00:00
network_init_object(o, SYNC_DISTANCE_ONLY_EVENTS);
network_init_object_field(o, &o->oAction);
network_init_object_field(o, &o->oPosY);
network_init_object_field(o, &o->oThwompRandomTimer);
network_init_object_field(o, &o->oTimer);
network_init_object_field(o, &o->oVelY);
}
2020-03-02 03:42:52 +00:00
cur_obj_call_action_function(sGrindelThwompActions);
2019-08-25 04:46:40 +00:00
}