From 05da53f0344416a5f14211a73f1f48d72c88b954 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Wed, 2 Dec 2026 14:38:56 +0400 Subject: feat(ui): drive a strategic warbot with an automatic gunner --- crates/fparkan-runtime/src/unit_combat.rs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (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 59c9ec64..799f0009 100644 --- a/crates/fparkan-runtime/src/unit_combat.rs +++ b/crates/fparkan-runtime/src/unit_combat.rs @@ -60,6 +60,7 @@ pub fn autonomous_firing_effect_phases( .loaded .as_ref() .and_then(|mission| mission.boarding) + .filter(|boarding| boarding.controls_weapons()) .map(|boarding| boarding.cockpit.handle); engine .autodemo_combat @@ -363,6 +364,16 @@ impl AutoDemoCombat { &self.pose_failures } + pub(super) fn weapons(&self, handle: ObjectHandle) -> Option<&PlayerWeapons> { + Some( + &self + .units + .iter() + .find(|unit| unit.handle == handle)? + .weapons, + ) + } + pub(super) fn turret_aim(&self, handle: ObjectHandle, component: usize) -> Option { self.units .iter() @@ -624,9 +635,9 @@ impl AutoDemoCombat { .and_then(|identity| identity.owner_id); let guard = owner .is_some_and(|owner| self.guard_clans.get(usize::from(owner.0)) == Some(&true)); - let manually_controlled = mission - .boarding - .is_some_and(|boarding| boarding.cockpit.handle == unit.handle); + let manually_controlled = mission.boarding.is_some_and(|boarding| { + boarding.cockpit.handle == unit.handle && boarding.controls_weapons() + }); // shortcut: free warbots defend from their current position until the // default Behavior task and its pursuit rules are wired. let defends_from_position = matches!( -- cgit v1.2.3