From 77ab4031f5c140ae5bce4096abab0552a0675ef9 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Sat, 14 Nov 2026 20:58:58 +0400 Subject: feat(ai): dispatch scripted attacks against logical targets Resolve the stock logical target and feed it to unit combat. Mission 20 assigns the attack at startup and continues through the remaining Init commands. All 29 original missions completed 15 minutes without a hard Init or periodic Mission stop. --- crates/fparkan-runtime/src/unit_combat.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'crates/fparkan-runtime/src/unit_combat.rs') diff --git a/crates/fparkan-runtime/src/unit_combat.rs b/crates/fparkan-runtime/src/unit_combat.rs index 97544f6f..03851e36 100644 --- a/crates/fparkan-runtime/src/unit_combat.rs +++ b/crates/fparkan-runtime/src/unit_combat.rs @@ -251,6 +251,23 @@ impl AutoDemoCombat { }) { return None; } + if let Some((target, index)) = + patrol.and_then(|patrol| patrol.attack_target(handle)) + { + // shortcut: aim at the target bounds until the original Attack task is wired. + let state = transform_state(world, target).ok()?; + let (center, radius) = unit_sphere(assets, index, state)?; + let distance = (center[0] - from[0]).hypot(center[1] - from[1]); + return Some(( + handle, + CombatTarget { + handle: target, + center, + radius, + in_range: distance <= FIRE_RANGE, + }, + )); + } let limit = patrol.and_then(|patrol| patrol.attack_limit(world, handle)); if limit.is_some_and(|limit| !limit.allows_attack(position)) { return None; -- cgit v1.2.3