From 4367287f9e07aca6a173a5eaef641a75918d66e0 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Thu, 26 Nov 2026 20:02:16 +0400 Subject: fix(audio): start node-attached laser sounds during wind-up Use the weapon descriptor's Control group to select the mode-1 sound rows. Update them through the existing FX clock and spatial Op2 playback for both manual and autonomous weapons. The GOG Control/Effect entry points confirm the selector, epoch and phase threshold, including retriggering after a sample at the exact phase peak. The stock Two Fortresses helicopter started the original sound at both weapon nodes in a Vulkan window. --- crates/fparkan-runtime/src/unit_combat.rs | 45 +++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'crates/fparkan-runtime/src/unit_combat.rs') diff --git a/crates/fparkan-runtime/src/unit_combat.rs b/crates/fparkan-runtime/src/unit_combat.rs index 224213bb..c43cc302 100644 --- a/crates/fparkan-runtime/src/unit_combat.rs +++ b/crates/fparkan-runtime/src/unit_combat.rs @@ -49,6 +49,8 @@ pub struct FiringEffectInstance { /// One autonomous combat event on the mission clock. #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub enum AutoDemoCombatEvent { + /// The wind-up started a node-attached weapon sound. + WindupSound(FiringEffectInstance), /// A weapon released a projectile. Shot { /// Owner of the weapon. @@ -685,6 +687,11 @@ impl AutoDemoCombat { .unavailable(shooter, "projectile_launch", now, 1); } } + events.extend( + unit.weapons + .started_windup_sounds(unit.index) + .map(AutoDemoCombatEvent::WindupSound), + ); missing += due_missing; if missing > 0 { let count = self @@ -1176,6 +1183,44 @@ mod tests { panic!("the first capturer did not take the generator (moving={capturer_fired_while_moving}, defender={defender_fired})"); } + #[test] + #[ignore = "requires licensed corpus"] + fn licensed_stock_helicopter_starts_both_laser_sound_rows() { + let mut engine = stock_two_fortresses(); + let helicopter = mission_object_handle(&engine, OriginalObjectId(11)).unwrap(); + let mut first_shot = None; + let mut first_windup_by_component = [None; 2]; + + for tick in 0..=60 * 28 { + let now = tick * 1000 / 60; + let result = frame(&mut engine, now).unwrap(); + for event in result.autodemo_combat_events { + match event { + AutoDemoCombatEvent::WindupSound(effect) + if effect.object_index == 11 + && matches!(effect.component_index, 10 | 11) => + { + assert_eq!((effect.table_index, effect.row_index), (0, 1)); + first_windup_by_component[effect.component_index - 10].get_or_insert(now); + } + AutoDemoCombatEvent::Shot { shooter, .. } if shooter == helicopter => { + first_shot.get_or_insert(now); + } + _ => {} + } + } + if first_shot.is_some() && first_windup_by_component.iter().all(Option::is_some) { + break; + } + } + + let first_shot = first_shot.expect("stock helicopter fires"); + let [Some(left), Some(right)] = first_windup_by_component else { + panic!("both authored gun sounds need a wind-up, got {first_windup_by_component:?}"); + }; + assert!(left.min(right) <= first_shot); + } + #[test] #[ignore = "requires licensed corpus"] fn licensed_scripted_patrol_fires_without_a_guard_fallback() { -- cgit v1.2.3