From 44320618ae750da0ab10e50439bf74405b9eacba Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Wed, 25 Nov 2026 14:58:28 +0400 Subject: feat(ai): queue scripted movement and raid orders Execute Go, Attack and ShutDown through one ordered queue from Init, Mission and clan AI events. Append preserves the active task; replacement clears its tail. Support the appended point patrol ending mission 19's second raid, and count accepted commands by object and order type. Execute the original ai.dll Handler(15) at RVA 0x8054 with its hash guard: move, attack, shutdown and appended patrol reach the unit without a current problem context, with native insertion modes and missing-unit flag 5. Behavior.dll RVA 0x4280 identifies append and replace paths. Native task completion and profile-dependent behavior remain approximate. Test mixed queues, replacement and deferred patrol; run the licensed mission-19 scenario from its stock start through its first movement. Validate fmt, workspace check/tests, release build and all 29 missions for 900 seconds. Mission 19 has both raid messages and no script stops; mission 29's existing counter/construction stops remain. Check the live stock-start window with normal clocks and Vulkan validation. This does not establish mission completion or native movement/combat parity. --- crates/fparkan-runtime/src/unit_patrol.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'crates/fparkan-runtime/src/unit_patrol.rs') diff --git a/crates/fparkan-runtime/src/unit_patrol.rs b/crates/fparkan-runtime/src/unit_patrol.rs index d4c6ae1d..2471b334 100644 --- a/crates/fparkan-runtime/src/unit_patrol.rs +++ b/crates/fparkan-runtime/src/unit_patrol.rs @@ -9,13 +9,18 @@ use super::{ use fparkan_script::{Handler15TargetPayload, ScriptDispatchSelector, VarSet}; use fparkan_terrain::{NavigationQuery, RouteRequest, SurfaceQuery}; use fparkan_world::{set_transform, transform_state}; -use std::collections::{HashSet, VecDeque}; +use std::collections::{BTreeMap, HashSet, VecDeque}; + +mod orders; +pub(super) use orders::supports_order; #[derive(Clone)] pub(super) struct UnitPatrol { center: Option<[f32; 2]>, units: Vec, shut_down: HashSet, + script_orders: Vec<(ObjectHandle, VecDeque)>, + script_order_counts: BTreeMap<(u32, u32), u64>, clock_ms: u32, rng: u32, pub(super) factory_raid_clans: usize, @@ -138,6 +143,8 @@ impl UnitPatrol { center: None, units: Vec::new(), shut_down: HashSet::new(), + script_orders: Vec::new(), + script_order_counts: BTreeMap::new(), clock_ms: 0, rng: 1, factory_raid_clans: 0, @@ -151,6 +158,7 @@ impl UnitPatrol { center: [f32; 2], radius: f32, ) -> bool { + self.script_orders.retain(|(unit, _)| *unit != handle); self.shut_down.remove(&handle); self.units .retain(|unit| transform_state(world, unit.handle).is_ok()); @@ -265,6 +273,7 @@ impl UnitPatrol { } pub(super) fn shut_down(&mut self, handle: ObjectHandle) -> bool { + self.script_orders.retain(|(unit, _)| *unit != handle); // shortcut: stop autonomous movement and fire until the native shutdown task is modeled. self.units.retain(|unit| unit.handle != handle); self.shut_down.insert(handle) @@ -371,6 +380,8 @@ impl UnitPatrol { center: Some(center), units, shut_down: HashSet::new(), + script_orders: Vec::new(), + script_order_counts: BTreeMap::new(), clock_ms: 0, rng: 1, factory_raid_clans: 0, @@ -385,6 +396,7 @@ impl UnitPatrol { targets: &[(ObjectHandle, CombatTarget)], ) -> Result { let mut state = self.clone(); + state.advance_script_orders(world); state.units.retain(|unit| { unit.destinations .as_ref() -- cgit v1.2.3