From 1845cc73af5738436a19432ea7fd8458cbd2e27d Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Tue, 20 Oct 2026 21:44:42 +0200 Subject: [PATCH] fix: end crystals take their entity ids when the fight places them Like the dragon, a spike's crystal gets its id from the entity counter as EndCrystal's constructor does, instead of only once a client tracks it: a player the level serves without a client can then aim at it. The fight's control status lists each crystal's id and position. Co-Authored-By: Claude Opus 5.5 (cherry picked from commit e32e5031c141fbd8c882847729beec92a65179a3) --- crates/horizon-client/src/game/dragon.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/crates/horizon-client/src/game/dragon.rs b/crates/horizon-client/src/game/dragon.rs index bd5ca1209..e0d6b67cc 100644 --- a/crates/horizon-client/src/game/dragon.rs +++ b/crates/horizon-client/src/game/dragon.rs @@ -797,6 +797,12 @@ impl Game<'_> { d.id = self.next_entity + 1; self.next_entity += 9; } + // The spikes' crystals too (EndCrystal's constructor): an id whether + // or not a client has tracked them yet, to be aimed at by it. + for c in self.crystals.iter_mut().filter(|c| c.id == 0) { + self.next_entity += 1; + c.id = self.next_entity; + } self.tick_crystals(); self.tick_dragon(); } @@ -2716,6 +2722,11 @@ impl Game<'_> { })), "players": self.fight.players, "crystals": self.crystals.len(), + // The tracked id (0 until tracked) and position of each crystal. + "crystal_list": self.crystals.iter().map(|c| serde_json::json!({ + "id": c.id, + "position": [c.position.x, c.position.y, c.position.z], + })).collect::>(), "alive_crystals": self.fight.alive_crystals, "killed": self.fight.killed, "exit_portal": self.fight.exit_portal,