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

100 lines
3.0 KiB
C
Raw Normal View History

2019-08-25 04:46:40 +00:00
// switch_hidden_objects.c.inc
struct ObjectHitbox sBreakableBoxHitbox = {
/* interactType: */ INTERACT_BREAKABLE,
/* downOffset: */ 20,
/* damageOrCoinValue: */ 0,
/* health: */ 1,
/* numLootCoins: */ 0,
/* radius: */ 150,
/* height: */ 200,
/* hurtboxRadius: */ 150,
/* hurtboxHeight: */ 200,
};
2020-03-02 03:42:52 +00:00
void breakable_box_init(void) {
2019-10-05 19:08:05 +00:00
o->oHiddenObjectUnkF4 = NULL;
2019-08-25 04:46:40 +00:00
o->oAnimState = 1;
switch (o->oBehParams2ndByte) {
case 0:
o->oNumLootCoins = 0;
break;
case 1:
o->oNumLootCoins = 3;
break;
case 2:
o->oNumLootCoins = 5;
break;
case 3:
2020-03-02 03:42:52 +00:00
cur_obj_scale(1.5f);
2019-08-25 04:46:40 +00:00
break;
}
}
2020-03-02 03:42:52 +00:00
void hidden_breakable_box_actions(void) {
2019-08-25 04:46:40 +00:00
struct Object *sp1C;
2020-03-02 03:42:52 +00:00
obj_set_hitbox(o, &sBreakableBoxHitbox);
cur_obj_set_model(MODEL_BREAKABLE_BOX_SMALL);
2019-08-25 04:46:40 +00:00
if (o->oAction == 0) {
2020-03-02 03:42:52 +00:00
cur_obj_disable_rendering();
cur_obj_become_intangible();
2019-08-25 04:46:40 +00:00
if (o->oTimer == 0)
2020-03-02 03:42:52 +00:00
breakable_box_init();
2019-10-05 19:08:05 +00:00
if (o->oHiddenObjectUnkF4 == NULL)
2020-03-02 03:42:52 +00:00
o->oHiddenObjectUnkF4 = cur_obj_nearest_object_with_behavior(bhvFloorSwitchHiddenObjects);
2019-08-25 04:46:40 +00:00
if ((sp1C = o->oHiddenObjectUnkF4) != NULL)
if (sp1C->oAction == 2) {
o->oAction++;
2020-03-02 03:42:52 +00:00
cur_obj_enable_rendering();
cur_obj_unhide();
2019-08-25 04:46:40 +00:00
}
} else if (o->oAction == 1) {
2020-03-02 03:42:52 +00:00
cur_obj_become_tangible();
if (cur_obj_wait_then_blink(360, 20))
2019-08-25 04:46:40 +00:00
o->oAction = 0;
2020-03-02 03:42:52 +00:00
if (cur_obj_was_attacked_or_ground_pounded()) {
spawn_mist_particles();
2019-08-25 04:46:40 +00:00
spawn_triangle_break_particles(30, 138, 3.0f, 4);
o->oAction++;
2020-03-02 03:42:52 +00:00
cur_obj_play_sound_2(SOUND_GENERAL_BREAK_BOX);
2019-08-25 04:46:40 +00:00
}
load_object_collision_model();
} else {
2020-03-02 03:42:52 +00:00
cur_obj_become_intangible();
cur_obj_disable_rendering();
2019-08-25 04:46:40 +00:00
o->oInteractStatus = 0;
if ((sp1C = o->oHiddenObjectUnkF4) != NULL)
if (sp1C->oAction == 0)
o->oAction = 0;
}
}
2020-03-02 03:42:52 +00:00
void hidden_unbreakable_box_actions(void) {
2019-08-25 04:46:40 +00:00
struct Object *sp1C;
2020-03-02 03:42:52 +00:00
obj_set_collision_data(o, wdw_seg7_collision_07018528);
2019-08-25 04:46:40 +00:00
if (o->oAction == 0) {
2020-03-02 03:42:52 +00:00
cur_obj_disable_rendering();
cur_obj_become_intangible();
2019-08-25 04:46:40 +00:00
if (o->oHiddenObjectUnkF4 == NULL)
2020-03-02 03:42:52 +00:00
o->oHiddenObjectUnkF4 = cur_obj_nearest_object_with_behavior(bhvFloorSwitchHiddenObjects);
2019-08-25 04:46:40 +00:00
if ((sp1C = o->oHiddenObjectUnkF4) != NULL)
if (sp1C->oAction == 2) {
o->oAction++;
2020-03-02 03:42:52 +00:00
cur_obj_enable_rendering();
cur_obj_unhide();
2019-08-25 04:46:40 +00:00
}
} else {
2020-03-02 03:42:52 +00:00
cur_obj_become_tangible();
if (cur_obj_wait_then_blink(360, 20))
2019-08-25 04:46:40 +00:00
o->oAction = 0;
load_object_collision_model();
}
}
void bhv_hidden_object_loop(void) {
if (o->oBehParams2ndByte == 0)
2020-03-02 03:42:52 +00:00
hidden_breakable_box_actions(); // Confused, that function has code depending on the action
2019-08-25 04:46:40 +00:00
else
2020-03-02 03:42:52 +00:00
hidden_unbreakable_box_actions();
2019-08-25 04:46:40 +00:00
}