From 6f746b8e31de323a55e2a47d8117faca2aa93a50 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Wed, 25 Nov 2026 23:42:11 +0400 Subject: fix(combat): launch AI projectiles from mounted weapon CPTs Resolve weapon node poses and EXTO socket chains on the CPU, replace each mounted component root with its socket, and transform the selected CPT into the world. Test terrain sight lines from each barrel rather than the hull. Share initial Control pose sampling with the window renderer. Count missing mounts and animation fallbacks by original object ID without losing history when an object dies. Checked Control.dll RVA 0x1b4f0 by native invocation, including nonuniform scale and a rotated world matrix. cargo fmt/check/test workspace pass, as do licensed stock AutoDemo and scripted patrol/factory regressions. All 29 stock missions reach --sim-report 900 with no script interruption or weapon pose fallback. Both games were observed in stock AutoDemo windows. AI turret aim, recoil and first-shot chronology remain approximate; this change does not establish full G7 or G8 gameplay parity. --- apps/fparkan-game/src/main.rs | 59 ++------------------------------ apps/fparkan-game/src/script_coverage.rs | 6 ++++ 2 files changed, 8 insertions(+), 57 deletions(-) (limited to 'apps/fparkan-game') diff --git a/apps/fparkan-game/src/main.rs b/apps/fparkan-game/src/main.rs index cc7061ae..ef7602ea 100644 --- a/apps/fparkan-game/src/main.rs +++ b/apps/fparkan-game/src/main.rs @@ -2,6 +2,8 @@ //! `FParkan` render-planning composition root. +use fparkan_runtime::initial_component_node_times as static_preview_node_times; + mod camera_capture; #[cfg(windows)] mod control_effects; @@ -7135,63 +7137,6 @@ fn multiply_unit_quaternions(left: [f32; 4], right: [f32; 4]) -> [f32; 4] { /// interpolated overlay mask. MSH component hierarchy, animation sampling, /// lightmaps, and gameplay visibility are handled by the preview bridge below. -fn static_preview_node_times( - node_count: usize, - bindings: &[PreparedControlNodeBinding], -) -> Result>, String> { - let mut node_times = vec![Some(AnimationTime(0.0)); node_count]; - for binding in bindings { - // Disabled rows are filtered while loading CTLD, but preserve the - // native guard here in case a caller constructs MissionAssets itself. - if binding.flags & 4 != 0 { - continue; - } - if binding.node_index >= node_count { - return Err(format!( - "control binding node {} is outside model node count {node_count}", - binding.node_index - )); - } - if !binding.frame_a.is_finite() - || !binding.frame_b.is_finite() - || !binding.initial_blend.is_finite() - || binding.frame_a < 0.0 - || binding.frame_b < 0.0 - { - return Err(format!( - "control binding for node {} contains an invalid frame or blend", - binding.node_index - )); - } - - let mut blend = binding.initial_blend; - if binding.flags & 1 != 0 { - if blend > 1.0 { - blend -= 1.0; - } - if blend < 0.0 { - blend += 1.0; - } - } else { - blend = blend.clamp(0.0, 1.0); - } - if binding.flags & 2 != 0 { - blend = 1.0 - blend; - } - let sample_time = (1.0 - blend) * binding.frame_a + blend * binding.frame_b; - if !sample_time.is_finite() || sample_time < 0.0 { - return Err(format!( - "control binding for node {} produced a negative or non-finite sample time unsupported by the static sampler", - binding.node_index - )); - } - // Source order is significant: native initialization writes each - // enabled row in turn, so a later row for the same node wins. - node_times[binding.node_index] = Some(AnimationTime(sample_time)); - } - Ok(node_times) -} - fn static_preview_component_pose_buffer( model: &ModelAsset, bindings: &[PreparedControlNodeBinding], diff --git a/apps/fparkan-game/src/script_coverage.rs b/apps/fparkan-game/src/script_coverage.rs index a01f16fa..a59e8c42 100644 --- a/apps/fparkan-game/src/script_coverage.rs +++ b/apps/fparkan-game/src/script_coverage.rs @@ -21,6 +21,12 @@ pub(super) fn log_script_init(engine: &Engine, mission: &str) { } pub(super) fn log_clan_ai_stops(report: &SimulationReport) { + for ((object, component), (count, reason)) in &report.weapon_poses.fallbacks { + eprintln!("sim_coverage unit_weapon_pose_fallback={count} object={object} component={component} reason={reason}"); + } + for (object, count) in &report.weapon_poses.missing { + eprintln!("sim_coverage unit_weapon_pose_stub={count} object={object}"); + } for &(clan, result, count) in &report.clan_research_scan_queries { eprintln!("sim_coverage script_research_scan_status={count} clan={clan} result={result}"); } -- cgit v1.2.3