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

139 lines
3.7 KiB
C
Raw Permalink Normal View History

2019-08-25 04:46:40 +00:00
// breakable_box.c.inc
struct ObjectHitbox sBreakableBoxSmallHitbox = {
/* interactType: */ INTERACT_GRABBABLE,
/* downOffset: */ 20,
/* damageOrCoinValue: */ 0,
/* health: */ 1,
/* numLootCoins: */ 0,
/* radius: */ 150,
/* height: */ 250,
/* hurtboxRadius: */ 150,
/* hurtboxHeight: */ 250,
};
void bhv_breakable_box_small_init(void) {
o->oGravity = 2.5f;
o->oFriction = 0.99f;
o->oBuoyancy = 1.4f;
2020-03-02 03:42:52 +00:00
cur_obj_scale(0.4f);
obj_set_hitbox(o, &sBreakableBoxSmallHitbox);
2019-08-25 04:46:40 +00:00
o->oAnimState = 1;
o->activeFlags |= 0x200;
}
2020-03-02 03:42:52 +00:00
void small_breakable_box_spawn_dust(void) {
2019-08-25 04:46:40 +00:00
struct Object *sp24 = spawn_object(o, MODEL_SMOKE, bhvSmoke);
2020-04-03 18:57:26 +00:00
sp24->oPosX += (s32)(random_float() * 80.0f) - 40;
sp24->oPosZ += (s32)(random_float() * 80.0f) - 40;
2019-08-25 04:46:40 +00:00
}
2020-03-02 03:42:52 +00:00
void small_breakable_box_act_move(void) {
2019-12-02 02:52:53 +00:00
s16 sp1E = object_step();
2019-08-25 04:46:40 +00:00
2020-03-02 03:42:52 +00:00
obj_attack_collided_from_other_object(o);
2019-08-25 04:46:40 +00:00
if (sp1E == 1)
2020-03-02 03:42:52 +00:00
cur_obj_play_sound_2(SOUND_GENERAL_BOX_LANDING_2);
2019-08-25 04:46:40 +00:00
if (sp1E & 1) {
if (o->oForwardVel > 20.0f) {
2020-03-02 03:42:52 +00:00
cur_obj_play_sound_2(SOUND_ENV_SLIDING);
small_breakable_box_spawn_dust();
2019-08-25 04:46:40 +00:00
}
}
if (sp1E & 2) {
2020-03-02 03:42:52 +00:00
spawn_mist_particles();
2019-08-25 04:46:40 +00:00
spawn_triangle_break_particles(20, 138, 0.7f, 3);
2019-12-02 02:52:53 +00:00
obj_spawn_yellow_coins(o, 3);
2019-10-05 19:08:05 +00:00
create_sound_spawner(SOUND_GENERAL_BREAK_BOX);
2019-08-25 04:46:40 +00:00
o->activeFlags = 0;
}
2019-12-02 02:52:53 +00:00
obj_check_floor_death(sp1E, sObjFloor);
2019-08-25 04:46:40 +00:00
}
void breakable_box_small_released_loop(void) {
o->oBreakableBoxSmallFramesSinceReleased++;
// Begin flashing
if (o->oBreakableBoxSmallFramesSinceReleased > 810) {
if (o->oBreakableBoxSmallFramesSinceReleased & 1)
2020-04-03 18:57:26 +00:00
o->header.gfx.node.flags |= GRAPH_RENDER_INVISIBLE;
2019-08-25 04:46:40 +00:00
else
2020-04-03 18:57:26 +00:00
o->header.gfx.node.flags &= ~GRAPH_RENDER_INVISIBLE;
2019-08-25 04:46:40 +00:00
}
// Despawn, and create a corkbox respawner
if (o->oBreakableBoxSmallFramesSinceReleased > 900) {
create_respawner(MODEL_BREAKABLE_BOX_SMALL, bhvBreakableBoxSmall, 3000);
o->activeFlags = 0;
}
}
void breakable_box_small_idle_loop(void) {
switch (o->oAction) {
case 0:
2020-03-02 03:42:52 +00:00
small_breakable_box_act_move();
2019-08-25 04:46:40 +00:00
break;
case 100:
2019-12-02 02:52:53 +00:00
obj_lava_death();
2019-08-25 04:46:40 +00:00
break;
case 101:
o->activeFlags = 0;
create_respawner(MODEL_BREAKABLE_BOX_SMALL, bhvBreakableBoxSmall, 3000);
break;
}
if (o->oBreakableBoxSmallReleased == 1)
breakable_box_small_released_loop();
}
void breakable_box_small_get_dropped(void) {
2020-03-02 03:42:52 +00:00
cur_obj_become_tangible();
cur_obj_enable_rendering();
cur_obj_get_dropped();
2020-04-03 18:57:26 +00:00
o->header.gfx.node.flags &= ~GRAPH_RENDER_INVISIBLE;
2019-08-25 04:46:40 +00:00
o->oHeldState = 0;
o->oBreakableBoxSmallReleased = 1;
o->oBreakableBoxSmallFramesSinceReleased = 0;
}
void breakable_box_small_get_thrown(void) {
2020-03-02 03:42:52 +00:00
cur_obj_become_tangible();
cur_obj_enable_rendering_2();
cur_obj_enable_rendering();
2020-04-03 18:57:26 +00:00
o->header.gfx.node.flags &= ~GRAPH_RENDER_INVISIBLE;
2019-08-25 04:46:40 +00:00
o->oHeldState = 0;
o->oFlags &= ~0x08;
o->oForwardVel = 40.0f;
o->oVelY = 20.0f;
o->oBreakableBoxSmallReleased = 1;
o->oBreakableBoxSmallFramesSinceReleased = 0;
o->activeFlags &= ~0x200;
}
void bhv_breakable_box_small_loop(void) {
switch (o->oHeldState) {
case 0:
breakable_box_small_idle_loop();
break;
case 1:
2020-03-02 03:42:52 +00:00
cur_obj_disable_rendering();
cur_obj_become_intangible();
2019-08-25 04:46:40 +00:00
break;
case 2:
breakable_box_small_get_thrown();
break;
case 3:
breakable_box_small_get_dropped();
break;
}
o->oInteractStatus = 0;
}