From 108dd67da99f9832d2e65e5e18f7d25cc2dfc9ed Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Sat, 14 Nov 2026 21:36:18 +0400 Subject: feat(ai): start the highest-priority clan script problem Open the matching Start section after Problems0, expose its arguments, and support completion and unreserved placed-unit selection. Two Fortresses enters its laboratory job and reaches Handler(6). Timing, ties and continuation remain explicit approximations. --- crates/fparkan-runtime/src/mission_events.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'crates/fparkan-runtime/src/mission_events.rs') diff --git a/crates/fparkan-runtime/src/mission_events.rs b/crates/fparkan-runtime/src/mission_events.rs index b97b154f..d040e4f8 100644 --- a/crates/fparkan-runtime/src/mission_events.rs +++ b/crates/fparkan-runtime/src/mission_events.rs @@ -158,6 +158,29 @@ impl MissionEvents { .count() as u32 } + pub(super) fn first_available_placed_unit( + &self, + mission: &super::MissionDocument, + world: &World, + clan: usize, + class: u32, + ) -> Option { + self.placed_clan_objects + .iter() + .find_map(|&(handle, candidate)| { + if candidate != class || self.reserved_units.contains(&(clan, handle)) { + return None; + } + registration_sequence(world, handle).ok()??; + let identity = identity_metadata(world, handle).ok()?; + if identity.owner_id != Some(OwnerId(clan as u16)) { + return None; + } + let object = mission.objects.get(identity.original_id?.0 as usize)?; + Some(object.identity_or_clan_raw) + }) + } + pub(super) fn set_reservation( &mut self, mission: &super::MissionDocument, -- cgit v1.2.3