aboutsummaryrefslogtreecommitdiff
path: root/crates/fparkan-runtime/src/unit_combat.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-11-14 19:58:58 +0300
committerValentin Popov <valentin@popov.link>2026-11-14 19:58:58 +0300
commit77ab4031f5c140ae5bce4096abab0552a0675ef9 (patch)
tree64763b31961c71bcd6591d65c3631e51b083f145 /crates/fparkan-runtime/src/unit_combat.rs
parente5e9f2a8ddc41f0e1af0e1ada5c1da669d40ceb0 (diff)
downloadfparkan-77ab4031f5c140ae5bce4096abab0552a0675ef9.tar.xz
fparkan-77ab4031f5c140ae5bce4096abab0552a0675ef9.zip
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.
Diffstat (limited to 'crates/fparkan-runtime/src/unit_combat.rs')
-rw-r--r--crates/fparkan-runtime/src/unit_combat.rs17
1 files changed, 17 insertions, 0 deletions
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;