From 6e18e9f05c1ae92a54dd671b6e47f3e21e299d4f Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Sat, 14 Nov 2026 21:05:43 +0400 Subject: feat(ai): expose clan roster counts to problem scripts Handler(49) counts free native-format startup slots and Handler(34) reads the live clan roster. The Two Fortresses reaches the research-dependent Handler(65) from every scheduled Problems0 invocation. --- crates/fparkan-runtime/src/mission_events.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (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 1c900819..b97b154f 100644 --- a/crates/fparkan-runtime/src/mission_events.rs +++ b/crates/fparkan-runtime/src/mission_events.rs @@ -152,6 +152,12 @@ pub(super) struct MissionEvents { } impl MissionEvents { + pub(super) fn count_clan_class(&self, world: &World, owner: OwnerId, class: u32) -> u32 { + clan_object_classes(&self.placed_clan_objects, world, owner) + .filter(|&candidate| candidate == class) + .count() as u32 + } + pub(super) fn set_reservation( &mut self, mission: &super::MissionDocument, @@ -714,13 +720,11 @@ impl LoadedMissionState { ScriptDispatchSelector::Handler(34) => { let class = single_dword(instruction, values) .ok_or("Handler(34) requires one DWORD operand")?; - let count = clan_object_classes( - &mission_events.placed_clan_objects, + let count = mission_events.count_clan_class( world, OwnerId(bundle.clan_index as u16), - ) - .filter(|&candidate| candidate == class) - .count() as u32; + class, + ); Ok(Some(count)) } ScriptDispatchSelector::Handler(52) => { -- cgit v1.2.3