diff --git a/src/game/behaviors/bowser_bomb.inc.c b/src/game/behaviors/bowser_bomb.inc.c index e1e560ae..97c7b215 100644 --- a/src/game/behaviors/bowser_bomb.inc.c +++ b/src/game/behaviors/bowser_bomb.inc.c @@ -1,18 +1,48 @@ // bowser_bomb.c.inc +static s32 networkBowserBombHit = 0; + +static void bhv_bowser_bomb_hit_player(void) { + if (networkBowserBombHit == 0) { + networkBowserBombHit = o->oSyncID; + network_send_object(o); + } + networkBowserBombHit = 0; + + o->oInteractStatus &= ~INT_STATUS_INTERACTED; + spawn_object(o, MODEL_EXPLOSION, bhvExplosion); + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; +} + +static void bhv_bowser_bomb_interacted(void) { + if (networkBowserBombHit == 0) { + networkBowserBombHit = -o->oSyncID; + network_send_object(o); + } + networkBowserBombHit = 0; + + spawn_object(o, MODEL_BOWSER_FLAMES, bhvBowserBombExplosion); + create_sound_spawner(SOUND_GENERAL_BOWSER_BOMB_EXPLOSION); + set_camera_shake_from_point(SHAKE_POS_LARGE, o->oPosX, o->oPosY, o->oPosZ); + o->activeFlags = ACTIVE_FLAG_DEACTIVATED; +} + void bhv_bowser_bomb_loop(void) { - if (obj_check_if_collided_with_object(o, gMarioObject) == 1) { - o->oInteractStatus &= ~INT_STATUS_INTERACTED; - spawn_object(o, MODEL_EXPLOSION, bhvExplosion); - o->activeFlags = ACTIVE_FLAG_DEACTIVATED; + if (!network_sync_object_initialized(o)) { + struct SyncObject* so = network_init_object(o, SYNC_DISTANCE_ONLY_EVENTS); + so->syncDeathEvent = FALSE; + network_init_object_field(o, &networkBowserBombHit); } - if (o->oInteractStatus & INT_STATUS_HIT_MINE) - { - spawn_object(o, MODEL_BOWSER_FLAMES, bhvBowserBombExplosion); - create_sound_spawner(SOUND_GENERAL_BOWSER_BOMB_EXPLOSION); - set_camera_shake_from_point(SHAKE_POS_LARGE, o->oPosX, o->oPosY, o->oPosZ); - o->activeFlags = ACTIVE_FLAG_DEACTIVATED; + struct MarioState* marioState = nearest_mario_state_to_object(o); + struct Object* player = marioState->marioObj; + + if (networkBowserBombHit == o->oSyncID || (marioState->playerIndex == 0 && obj_check_if_collided_with_object(o, player) == 1)) { + bhv_bowser_bomb_hit_player(); + } + + if (networkBowserBombHit == -o->oSyncID || o->oInteractStatus & INT_STATUS_HIT_MINE) { + bhv_bowser_bomb_interacted(); } set_object_visibility(o, 7000);