From 071ec6a8619c9dfd37582c56dd97108aae3e6c6e Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Sat, 14 Nov 2026 20:33:41 +0400 Subject: feat(ai): honor scenario warbot shutdown orders Behavior.dll task dispatch selects ShutDown for order 0x13. Stop autonomous motion and fire until a new supported order is assigned. The field-camp clan now completes Init and all three placed warbots receive the shutdown order. --- crates/fparkan-runtime/src/script_patrol.rs | 33 ++++++++++++++++++----------- 1 file changed, 21 insertions(+), 12 deletions(-) (limited to 'crates/fparkan-runtime/src/script_patrol.rs') diff --git a/crates/fparkan-runtime/src/script_patrol.rs b/crates/fparkan-runtime/src/script_patrol.rs index 6d349c9b..d67874c6 100644 --- a/crates/fparkan-runtime/src/script_patrol.rs +++ b/crates/fparkan-runtime/src/script_patrol.rs @@ -3,6 +3,26 @@ use crate::{MissionDocument, MissionObjectDraft}; use fparkan_script::{Handler15Invocation, Handler15TargetPayload}; use fparkan_world::{handle_by_original_id, ObjectHandle, OriginalObjectId, World}; +pub(super) fn warbot_by_logic_id( + mission: &MissionDocument, + drafts: &[MissionObjectDraft], + world: &World, + id: u32, +) -> Option { + mission + .objects + .iter() + .zip(drafts) + .enumerate() + .find_map(|(index, (object, draft))| { + (id != u32::MAX + && object.identity_or_clan_raw == id + && draft.unit_dat_header_flags == Some(crate::boarding::WARBOT_CLASS)) + .then(|| handle_by_original_id(world, OriginalObjectId(index as u32))) + .flatten() + }) +} + #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub(super) struct ScriptPatrol { pub(super) actor_id: u32, @@ -31,18 +51,7 @@ impl ScriptPatrol { drafts: &[MissionObjectDraft], world: &World, ) -> Option { - let (index, _) = - mission - .objects - .iter() - .zip(drafts) - .enumerate() - .find(|(_, (object, draft))| { - self.actor_id != u32::MAX - && object.identity_or_clan_raw == self.actor_id - && draft.unit_dat_header_flags == Some(crate::boarding::WARBOT_CLASS) - })?; - let handle = handle_by_original_id(world, OriginalObjectId(index as u32))?; + let handle = warbot_by_logic_id(mission, drafts, world, self.actor_id)?; // shortcut: use the verified default radius until per-unit patrol profiles are wired. let radius = match self.radius { 0 | u32::MAX => 60.0, -- cgit v1.2.3