diff options
| author | Valentin Popov <valentin@popov.link> | 2026-11-14 21:57:44 +0300 |
|---|---|---|
| committer | Valentin Popov <valentin@popov.link> | 2026-11-14 21:57:44 +0300 |
| commit | a25aa2959dbac4d0f2a91299de16e12f492699f3 (patch) | |
| tree | 1ecda6259b74d51b33dd4e932623f3824531ff10 /crates/fparkan-runtime/src/clan_script_init.rs | |
| parent | 239c4504d6fcfe0e78559d1587605a7b5707e5c2 (diff) | |
| download | fparkan-a25aa2959dbac4d0f2a91299de16e12f492699f3.tar.xz fparkan-a25aa2959dbac4d0f2a91299de16e12f492699f3.zip | |
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.
Diffstat (limited to 'crates/fparkan-runtime/src/clan_script_init.rs')
| -rw-r--r-- | crates/fparkan-runtime/src/clan_script_init.rs | 37 |
1 files changed, 20 insertions, 17 deletions
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<f32> { + 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] |
