From 590c8f39b935f34fc6a4f9c033520c2c0359253d Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Tue, 1 Dec 2026 09:27:02 +0400 Subject: fix(ai): prepend base defence attacks to unit orders The native task dispatcher inserts mode 2 at index zero without replacing the old list. Keep the interrupted order and queued tail, then run the base-defence wait after assigning the group in the stock mission. --- crates/fparkan-runtime/src/clan_combat_groups.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'crates/fparkan-runtime/src/clan_combat_groups.rs') diff --git a/crates/fparkan-runtime/src/clan_combat_groups.rs b/crates/fparkan-runtime/src/clan_combat_groups.rs index 71d8a2a5..50c86e16 100644 --- a/crates/fparkan-runtime/src/clan_combat_groups.rs +++ b/crates/fparkan-runtime/src/clan_combat_groups.rs @@ -147,11 +147,12 @@ impl CombatGroup { drafts: &[MissionObjectDraft], order: Handler15Invocation, ) -> Result<(), String> { - let (0, kind @ (3 | 4), 3) = (order.word_0, order.word_1, order.word_2) else { + let kind = order.word_1; + if order.word_0 != 0 || !matches!((kind, order.word_2), (3, 2 | 3) | (4, 3)) { return Err( - "Handler(28) requires a replacing patrol or attack order on group 0".into(), + "Handler(28) requires a supported patrol or attack order on group 0".into(), ); - }; + } let target = GroupTarget::resolve(world, mission, order.target) .ok_or("Handler(28) target is unavailable")?; for &unit in &self.members { @@ -186,7 +187,11 @@ impl CombatGroup { }; for &unit in &self.members { if let Some((handle, index)) = attack { - patrol.set_attack_target(world, unit, handle, index, point); + if order.word_2 == 2 { + patrol.prepend_attack(world, unit, handle, index); + } else { + patrol.set_attack_target(world, unit, handle, index, point); + } } else { let radius = match order.word_3 { 0 | u32::MAX => 60.0, -- cgit v1.2.3