diff --git a/src/game/behaviors/bouncing_fireball.inc.c b/src/game/behaviors/bouncing_fireball.inc.c index 89dcfd18..9df5b0ec 100644 --- a/src/game/behaviors/bouncing_fireball.inc.c +++ b/src/game/behaviors/bouncing_fireball.inc.c @@ -28,19 +28,37 @@ void bhv_bouncing_fireball_flame_loop(void) { } void bhv_bouncing_fireball_loop(void) { + if (!network_sync_object_initialized(o)) { + network_init_object(o, SYNC_DISTANCE_ONLY_EVENTS); + network_init_object_field(o, &o->oAction); + network_init_object_field(o, &o->oPrevAction); + network_init_object_field(o, &o->oTimer); + } + + struct Object* player = nearest_player_to_object(o); + int distanceToPlayer = dist_between_objects(o, player); + struct Object *sp2C; f32 sp28; switch (o->oAction) { case 0: - if (o->oDistanceToMario < 2000.0f) + if (distanceToPlayer < 2000.0f) o->oAction = 1; break; case 1: - sp2C = spawn_object(o, MODEL_RED_FLAME, bhvBouncingFireballFlame); - sp28 = (10 - o->oTimer) * 0.5; - obj_scale_xyz(sp2C, sp28, sp28, sp28); - if (o->oTimer == 0) - obj_become_tangible(sp2C); + if (network_owns_object(o)) { + sp2C = spawn_object(o, MODEL_RED_FLAME, bhvBouncingFireballFlame); + sp28 = (10 - o->oTimer) * 0.5; + obj_scale_xyz(sp2C, sp28, sp28, sp28); + if (o->oTimer == 0) + obj_become_tangible(sp2C); + + struct Object* spawn_objects[] = { sp2C }; + u32 models[] = { MODEL_RED_FLAME }; + network_send_spawn_objects(spawn_objects, models, 1); + + network_send_object(o); + } if (o->oTimer > 10) o->oAction++; break; diff --git a/src/pc/network/packets/packet_spawn_objects.c b/src/pc/network/packets/packet_spawn_objects.c index 2f6772f3..67a3c87c 100644 --- a/src/pc/network/packets/packet_spawn_objects.c +++ b/src/pc/network/packets/packet_spawn_objects.c @@ -60,6 +60,9 @@ void network_send_spawn_objects(struct Object* objects[], u32 models[], u8 objec packet_write(&p, &behaviorId, sizeof(enum BehaviorId)); packet_write(&p, &o->activeFlags, sizeof(s16)); packet_write(&p, o->rawData.asU32, sizeof(s32) * 80); + packet_write(&p, &o->header.gfx.scale[0], sizeof(f32)); + packet_write(&p, &o->header.gfx.scale[1], sizeof(f32)); + packet_write(&p, &o->header.gfx.scale[2], sizeof(f32)); } network_send(&p); @@ -93,11 +96,15 @@ void network_receive_spawn_objects(struct Packet* p) { struct Object* spawned[MAX_SPAWN_OBJECTS_PER_PACKET] = { 0 }; for (u8 i = 0; i < objectCount; i++) { struct SpawnObjectData data = { 0 }; + Vec3f scale = { 0 }; packet_read(p, &data.parentId, sizeof(u8)); packet_read(p, &data.model, sizeof(u32)); packet_read(p, &data.behaviorId, sizeof(enum BehaviorId)); packet_read(p, &data.activeFlags, sizeof(s16)); packet_read(p, &data.rawData, sizeof(s32) * 80); + packet_read(p, &scale[0], sizeof(f32)); + packet_read(p, &scale[1], sizeof(f32)); + packet_read(p, &scale[2], sizeof(f32)); struct Object* parentObj = NULL; if (data.parentId == (u8)-1) { @@ -126,6 +133,10 @@ void network_receive_spawn_objects(struct Packet* p) { struct Object* o = spawn_object(parentObj, data.model, behavior); memcpy(o->rawData.asU32, data.rawData, sizeof(u32) * 80); + o->header.gfx.scale[0] = scale[0]; + o->header.gfx.scale[1] = scale[1]; + o->header.gfx.scale[2] = scale[2]; + // correct the temporary parent with the object itself if (data.parentId == (u8)-1) { o->parentObj = o; }