From a568eca93b266e38737e333410c8e5dabec2bc65 Mon Sep 17 00:00:00 2001 From: HarcoChen Date: Thu, 12 Nov 2026 22:49:59 +0800 Subject: [PATCH] Fix summon cloning and sacrificed owner cleanup --- .../battle/runtime/kits/dispatch/context.rs | 24 ++++++++++++++----- .../src/solo/preparation/consumables.rs | 1 + 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/crates/engine/src/battle/runtime/kits/dispatch/context.rs b/crates/engine/src/battle/runtime/kits/dispatch/context.rs index 6cd5dc2..2b53e7b 100644 --- a/crates/engine/src/battle/runtime/kits/dispatch/context.rs +++ b/crates/engine/src/battle/runtime/kits/dispatch/context.rs @@ -437,6 +437,16 @@ impl Context<'_> { tile: [i32; 2], duration: f64, ) -> Result, String> { + // A ranged Manifold split creates an independent timed clone. Reusing + // its prepared original would target the skill held by the attack callback. + let split_clone = key == "token_10030_mlyss_wtrman" + && self + .world + .unit(self.unit)? + .operator + .tactical + .mlyss() + .is_ok_and(|state| state.clone_of.is_some()); let prepared = self .host .roster @@ -446,12 +456,14 @@ impl Context<'_> { .iter() .copied() .find(|&id| { - self.world.unit(id).is_ok_and(|u| { - u.deployment.kind == crate::battle::deploy::Kind::Token - && u.deployment.uid.is_some() - && !u.removed - && u.summoner == Some(self.unit) - }) && self.host.tac_def(id).is_ok_and(|def| def.key == key) + !split_clone + && self.world.unit(id).is_ok_and(|u| { + u.deployment.kind == crate::battle::deploy::Kind::Token + && u.deployment.uid.is_some() + && !u.removed + && u.summoner == Some(self.unit) + }) + && self.host.tac_def(id).is_ok_and(|def| def.key == key) }); if let Some(token) = prepared { if !Host::tac_up(self.world, token) && !self.redeploy_free(token)? { diff --git a/crates/engine/src/solo/preparation/consumables.rs b/crates/engine/src/solo/preparation/consumables.rs index d76dc3c..8268989 100644 --- a/crates/engine/src/solo/preparation/consumables.rs +++ b/crates/engine/src/solo/preparation/consumables.rs @@ -121,6 +121,7 @@ impl Preparation { let tier = self.rules.chess[&holder.key].tier; if sacrifice { let mut removed = self.take(self.find(target).unwrap()); + self.remove_tokens(removed.uid); for equipped in removed.items.drain(..) { self.stow(equipped)?; }