From 197d9c93ffe15f1a7d32e9d256310788d50f4895 Mon Sep 17 00:00:00 2001 From: MysterD Date: Mon, 7 Sep 2020 23:10:28 -0700 Subject: [PATCH] Prevent exclamation box from double spawning stars --- include/object_fields.h | 2 +- src/game/behaviors/exclamation_box.inc.c | 29 ++++++++++-------------- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/include/object_fields.h b/include/object_fields.h index 6bcaf6d8..6629ebd1 100644 --- a/include/object_fields.h +++ b/include/object_fields.h @@ -458,7 +458,7 @@ #define /*0x0F4*/ oExclamationBoxUnkF4 OBJECT_FIELD_F32(0x1B) // scale? #define /*0x0F8*/ oExclamationBoxUnkF8 OBJECT_FIELD_F32(0x1C) // scale? #define /*0x0FC*/ oExclamationBoxUnkFC OBJECT_FIELD_S32(0x1D) // angle? -#define /*0x100*/ oExclamationBoxForce OBJECT_FIELD_S32(0x1E) // angle? +#define /*0x100*/ oExclamationBoxForce OBJECT_FIELD_S32(0x49) // angle? /* Eyerok Boss */ #define /*0x0F8*/ oEyerokBossNumHands OBJECT_FIELD_S32(0x1C) diff --git a/src/game/behaviors/exclamation_box.inc.c b/src/game/behaviors/exclamation_box.inc.c index 305d3267..fddf9be2 100644 --- a/src/game/behaviors/exclamation_box.inc.c +++ b/src/game/behaviors/exclamation_box.inc.c @@ -36,6 +36,7 @@ void bhv_rotating_exclamation_box_loop(void) { } void exclamation_box_act_0(void) { + o->oExclamationBoxForce = FALSE; if (o->oBehParams2ndByte < 3) { o->oAnimState = o->oBehParams2ndByte; if ((save_file_get_flags() & D_8032F0C0[o->oBehParams2ndByte]) @@ -71,11 +72,15 @@ void exclamation_box_act_2(void) { o->oPosY = o->oHomeY; o->oGraphYOffset = 0.0f; } - if (nearest_mario_state_to_object(o) == &gMarioStates[0]) { - if (o->oExclamationBoxUnkFC == 0x4000 || cur_obj_was_attacked_or_ground_pounded()) { - o->oExclamationBoxForce = TRUE; - network_send_object(o); - o->oExclamationBoxForce = FALSE; + + u8 isNearest = (nearest_mario_state_to_object(o) == &gMarioStates[0]); + if (o->oExclamationBoxForce || isNearest) { + if (o->oExclamationBoxForce || (isNearest && cur_obj_was_attacked_or_ground_pounded())) { + if (!o->oExclamationBoxForce) { + o->oExclamationBoxForce = TRUE; + network_send_object(o); + o->oExclamationBoxForce = FALSE; + } cur_obj_become_intangible(); o->oExclamationBoxUnkFC = 0x4000; o->oVelY = 30.0f; @@ -110,7 +115,6 @@ void exclamation_box_spawn_contents(struct Struct802C0DF0 *a0, u8 a1) { struct Object *sp1C = NULL; if (o->oExclamationBoxForce) { - o->oExclamationBoxForce = FALSE; return; } @@ -138,7 +142,6 @@ void exclamation_box_act_4(void) { spawn_mist_particles_variable(0, 0, 46.0f); spawn_triangle_break_particles(20, 139, 0.3f, o->oAnimState); create_sound_spawner(SOUND_GENERAL_BREAK_BOX); - o->oExclamationBoxForce = FALSE; if (o->oBehParams2ndByte < 3) { o->oAction = 5; cur_obj_hide(); @@ -157,18 +160,10 @@ void (*sExclamationBoxActions[])(void) = { exclamation_box_act_0, exclamation_bo void bhv_exclamation_box_loop(void) { if (!network_sync_object_initialized(o)) { - network_init_object(o, SYNC_DISTANCE_ONLY_EVENTS); + struct SyncObject* so = network_init_object(o, SYNC_DISTANCE_ONLY_EVENTS); + so->syncDeathEvent = FALSE; network_init_object_field(o, &o->oExclamationBoxForce); } - if (o->oExclamationBoxForce && o->oAction < 3) { - cur_obj_become_intangible(); - o->oExclamationBoxUnkFC = 0x4000; - o->oVelY = 30.0f; - o->oGravity = -8.0f; - o->oFloorHeight = o->oPosY; - o->oAction = 3; - queue_rumble_data_object(o, 5, 80); - } cur_obj_scale(2.0f); cur_obj_call_action_function(sExclamationBoxActions); }