diff options
| author | Valentin Popov <valentin@popov.link> | 2026-11-14 19:33:41 +0300 |
|---|---|---|
| committer | Valentin Popov <valentin@popov.link> | 2026-11-14 19:33:41 +0300 |
| commit | 071ec6a8619c9dfd37582c56dd97108aae3e6c6e (patch) | |
| tree | 85828ac5382fcb26547b92a34a2c2f6b0834a51f /crates/fparkan-runtime/src/script_patrol.rs | |
| parent | 9e9833846e7f8b354493b8962123af4508bc0cda (diff) | |
| download | fparkan-071ec6a8619c9dfd37582c56dd97108aae3e6c6e.tar.xz fparkan-071ec6a8619c9dfd37582c56dd97108aae3e6c6e.zip | |
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.
Diffstat (limited to 'crates/fparkan-runtime/src/script_patrol.rs')
| -rw-r--r-- | crates/fparkan-runtime/src/script_patrol.rs | 33 |
1 files changed, 21 insertions, 12 deletions
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<ObjectHandle> { + 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<ObjectHandle> { - 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, |
