From a25aa2959dbac4d0f2a91299de16e12f492699f3 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Sat, 14 Nov 2026 22:57:44 +0400 Subject: feat(ai): select enemy buildings beyond the clan base radius Connect the initial radius limit and Handler(64) target lookup. Compare target IDs with an isolated GOG ai.dll call at RVA 0xe8e7. Campaign branches still depend on their original timers and free-mind conditions. --- crates/fparkan-runtime/src/clan_script_init.rs | 37 ++++++++++++++------------ 1 file changed, 20 insertions(+), 17 deletions(-) (limited to 'crates/fparkan-runtime/src/clan_script_init.rs') diff --git a/crates/fparkan-runtime/src/clan_script_init.rs b/crates/fparkan-runtime/src/clan_script_init.rs index 3e102be3..c6a070de 100644 --- a/crates/fparkan-runtime/src/clan_script_init.rs +++ b/crates/fparkan-runtime/src/clan_script_init.rs @@ -4,6 +4,10 @@ use fparkan_script::{ }; pub(super) enum InitOrder { + BaseRadius { + clan: usize, + limit: f32, + }, Patrol(ScriptPatrol), Attack { id: u32, @@ -22,6 +26,18 @@ pub(super) enum InitOrder { }, } +pub(super) fn base_radius( + instruction: &ScriptInstruction, + values: &[VarSetDefault], +) -> Option { + let ([68, u32::MAX, u32::MAX, u32::MAX, 6, 1, u32::MAX], &[index]) = + (instruction.header_words, instruction.references.as_slice()) + else { + return None; + }; + values.get(index as usize)?.as_float() +} + pub(super) fn reservation( instruction: &ScriptInstruction, values: &[VarSetDefault], @@ -84,15 +100,6 @@ pub(super) fn stubbed_handler( match (instruction.header_words, instruction.references.as_slice()) { // shortcut: resume Init until the live research context is wired. ([43, u32::MAX, u32::MAX, u32::MAX, 6, 0, u32::MAX], []) => Some(43), - // shortcut: resume Init until the native AI base-area state is wired. - ([68, u32::MAX, u32::MAX, u32::MAX, 6, 1, u32::MAX], [index]) - if matches!( - values.get(*index as usize), - Some(VarSetDefault::FloatBits(_)) - ) => - { - Some(68) - } // shortcut: resume Init until the AI consumer of this setting is wired. ([69, u32::MAX, u32::MAX, u32::MAX, 6, 1, u32::MAX], [index]) if matches!(values.get(*index as usize), Some(VarSetDefault::Dword(_))) => @@ -131,23 +138,19 @@ mod tests { } #[test] - fn base_area_stub_requires_a_float_operand_and_no_result() { + fn base_area_requires_a_float_operand_and_no_result() { let mut instruction = ScriptInstruction { header_words: [68, u32::MAX, u32::MAX, u32::MAX, 6, 1, u32::MAX], references: vec![0], }; let values = [VarSetDefault::FloatBits(500.0_f32.to_bits())]; - let declarations = fparkan_script::parse_varset(b"").unwrap(); + assert_eq!(base_radius(&instruction, &values), Some(500.0)); assert_eq!( - stubbed_handler(&instruction, &values, &declarations), - Some(68) - ); - assert_eq!( - stubbed_handler(&instruction, &[VarSetDefault::Dword(500)], &declarations), + base_radius(&instruction, &[VarSetDefault::Dword(500)]), None ); instruction.header_words[1] = 0; - assert_eq!(stubbed_handler(&instruction, &values, &declarations), None); + assert_eq!(base_radius(&instruction, &values), None); } #[test] -- cgit v1.2.3