From bb332da65d9c35201f43920a3cfe0e427c3b6494 Mon Sep 17 00:00:00 2001 From: Valera <76255437+xzxADIxzx@users.noreply.github.com> Date: Fri, 8 Mar 2024 21:20:34 +0300 Subject: [PATCH] fix enemies desync in cyber grind --- src/Jaket/Content/Enemies.cs | 6 ++++-- src/Jaket/Net/Endpoints/Client.cs | 3 +-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Jaket/Content/Enemies.cs b/src/Jaket/Content/Enemies.cs index 16aa03a1..fc86dc18 100644 --- a/src/Jaket/Content/Enemies.cs +++ b/src/Jaket/Content/Enemies.cs @@ -132,11 +132,13 @@ public static bool SyncDamage(EnemyIdentifier enemyId, float damage, bool explod /// Synchronizes the death of the enemy. public static void SyncDeath(EnemyIdentifier enemyId) { - if (LobbyController.Lobby == null || enemyId.dead || !LobbyController.IsOwner) return; + if (LobbyController.Lobby == null || enemyId.dead) return; if (enemyId.TryGetComponent(out var enemy)) { - Networking.Send(PacketType.KillEntity, w => w.Id(enemy.Id), size: 8); + if (LobbyController.IsOwner) + Networking.Send(PacketType.KillEntity, w => w.Id(enemy.Id), (data, size) => Events.Post2(() => Networking.Redirect(data, size)), 8); + Tools.Destroy(enemy); } } diff --git a/src/Jaket/Net/Endpoints/Client.cs b/src/Jaket/Net/Endpoints/Client.cs index 077a0ae7..9cf31e2f 100644 --- a/src/Jaket/Net/Endpoints/Client.cs +++ b/src/Jaket/Net/Endpoints/Client.cs @@ -26,8 +26,7 @@ public override void Load() // after respawn, Leviathan or hand may be absent, so it must be returned if possible // sometimes players disappear for some unknown reason, and sometimes I destroy them myself - if (entities[id] == null && (type == EntityType.Hand || type == EntityType.Leviathan || type == EntityType.Minotaur_Chase || type == EntityType.Player)) - entities[id] = Entities.Get(id, type); + if (entities[id] == null) entities[id] = Entities.Get(id, type); entities[id]?.Read(r); });