diff options
| author | Valentin Popov <valentin@popov.link> | 2026-11-14 20:10:02 +0300 |
|---|---|---|
| committer | Valentin Popov <valentin@popov.link> | 2026-11-14 20:10:02 +0300 |
| commit | f1f5d8ff590ff4ff64f5e35e23363d7ca6f37088 (patch) | |
| tree | 81522956b6276036ec077811e02f1ac9993a777a /crates/fparkan-runtime/src | |
| parent | 423ef8a52d38721b296791c887ec3674f18e74c8 (diff) | |
| download | fparkan-f1f5d8ff590ff4ff64f5e35e23363d7ca6f37088.tar.xz fparkan-f1f5d8ff590ff4ff64f5e35e23363d7ca6f37088.zip | |
feat(ai): read free clan power in problem scripts
The typed event host stores the finite or negative float result in the script cell. A direct call to ai.dll verifies available minus requested power. Single.01 evaluates the energy branch and reaches its mine resource query.
Diffstat (limited to 'crates/fparkan-runtime/src')
| -rw-r--r-- | crates/fparkan-runtime/src/clan_ai_events.rs | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/crates/fparkan-runtime/src/clan_ai_events.rs b/crates/fparkan-runtime/src/clan_ai_events.rs index e0ed4906..38ef3618 100644 --- a/crates/fparkan-runtime/src/clan_ai_events.rs +++ b/crates/fparkan-runtime/src/clan_ai_events.rs @@ -40,19 +40,29 @@ impl LoadedMissionState { else { continue; }; - let result = varset.declarations.execute_mission_prefix( + let result = varset.declarations.execute_event_prefix( event, bundle.formula_table.as_ref(), &mut state.values, |instruction, values| match instruction.dispatch_selector() { + ScriptDispatchSelector::Handler(3) if instruction.references.is_empty() => { + let [available, _, _, demand, _] = bundle + .behavior_warm_start + .ok_or("Handler(3) requires live Behavior totals")? + .cleared_words + .map(f32::from_bits); + Ok(Some(VarSetDefault::FloatBits( + (available - demand).to_bits(), + ))) + } ScriptDispatchSelector::Handler(49) if instruction.references.is_empty() => { let slots = self .ai_startup_states .iter() .find(|state| state.clan_index == clan); - Ok(Some( + Ok(Some(VarSetDefault::Dword( slots.map_or(0, |state| count_free_minds(&state.record_slots)), - )) + ))) } ScriptDispatchSelector::Handler(34) => { let &[index] = instruction.references.as_slice() else { @@ -61,10 +71,12 @@ impl LoadedMissionState { let Some(&VarSetDefault::Dword(class)) = values.get(index as usize) else { return Err("Handler(34) requires one DWORD operand".to_owned()); }; - Ok(Some(self.mission_events.count_clan_class( - world, - OwnerId(clan as u16), - class, + Ok(Some(VarSetDefault::Dword( + self.mission_events.count_clan_class( + world, + OwnerId(clan as u16), + class, + ), ))) } ScriptDispatchSelector::Handler(65) if instruction.references.is_empty() => { @@ -81,7 +93,7 @@ impl LoadedMissionState { bundle.script_path ); } - Ok(Some(0)) + Ok(Some(VarSetDefault::Dword(0))) } selector => Err(format!("{selector:?}")), }, |
