From 31dd73cbf59f5c8fe58b77b373a75033dc5a037a Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Tue, 1 Dec 2026 07:57:23 +0400 Subject: fix(fx): switch warbot smoke with the damage alarm Resolve the matching enable and disable selectors from authored CTL alarm groups. Render node-attached smoke and light only while the live Control alarm is active. Verify the native selector against both DLLs and inspect two Vulkan frames around an ordinary AutoDemo alarm. Independent mode-14 triggers and the damage stage cascade remain open. --- apps/fparkan-game/src/control_effects.rs | 44 +++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 4 deletions(-) (limited to 'apps/fparkan-game/src/control_effects.rs') diff --git a/apps/fparkan-game/src/control_effects.rs b/apps/fparkan-game/src/control_effects.rs index 910bba81..4cee2c16 100644 --- a/apps/fparkan-game/src/control_effects.rs +++ b/apps/fparkan-game/src/control_effects.rs @@ -5,7 +5,8 @@ use super::{ }; use fparkan_fx::clock::{FxInstanceClock, FxPhaseProvider}; use fparkan_runtime::{ - loaded_mission_control_device_tables, AutoDemoCombatEvent, Engine, FiringEffectInstance, + control_damage_alarm_active, loaded_mission_assets, loaded_mission_control_device_tables, + AutoDemoCombatEvent, Engine, FiringEffectInstance, }; use std::collections::{HashMap, HashSet}; @@ -24,6 +25,29 @@ fn owner_control_capacity( )) } +fn owner_alarm_effect( + engine: &Engine, + roots: &[Option], + effect: ControlEffectInstanceKey, +) -> Option { + let control = loaded_mission_assets(engine)? + .object_component_controls + .get(effect.object_index)? + .get(effect.component_index)? + .as_ref()?; + if control.initial_effect_group != Some(effect.table_index) + || !control.alarm_effect_rows.contains(&effect.row_index) + { + return None; + } + Some( + roots + .get(effect.object_index) + .and_then(Option::as_ref) + .is_some_and(|root| control_damage_alarm_active(engine, root.handle)), + ) +} + impl From for ControlEffectInstanceKey { fn from(effect: FiringEffectInstance) -> Self { Self { @@ -73,6 +97,13 @@ impl StaticVulkanApp { }, |index| self.motion_effects.provider(index), |key| weapon_phases.get(&key).copied(), + |key| { + owner_alarm_effect( + self.mission_engine.as_ref()?, + &self.mission_render_roots, + key, + ) + }, ); let mut direct_shot_sounds = activate_firing_flashes( &mut samples, @@ -160,6 +191,7 @@ pub(super) fn advance_control_effect_instances( owner_capacity: impl Fn(usize) -> Option<(f32, f32)>, owner_motion: impl Fn(usize) -> Option, owner_effect_phase: impl Fn(ControlEffectInstanceKey) -> Option, + owner_damage_alarm: impl Fn(ControlEffectInstanceKey) -> Option, ) -> HashMap { let mut specifications = HashMap::new(); for slot in ambient_slots { @@ -202,13 +234,17 @@ pub(super) fn advance_control_effect_instances( let idle = FxPhaseProvider::idle(); let mut provider = idle; let mut resolved = false; + let alarm = (mode == 14 && flags & 0x40 != 0) + .then(|| owner_damage_alarm(key)).flatten(); if mode == 14 { let capacity = owner_capacity(key.object_index) .and_then(|(remaining, capacity)| idle.with_control_capacity(remaining, capacity)); provider = capacity.unwrap_or(idle); if state.clock.is_none() { - eprintln!("render_coverage control_damage_fx_activation_approx=1 (instance={key:?})"); - if capacity.is_none() { + if alarm.is_none() { + eprintln!("render_coverage control_damage_fx_activation_approx=1 (instance={key:?})"); + } + if capacity.is_none() && alarm != Some(false) { eprintln!("render_coverage control_fx_owner_state_stub=1 (missing Control capacity; instance={key:?} mode={mode})"); } } @@ -232,7 +268,7 @@ pub(super) fn advance_control_effect_instances( .expect("prepared FX clock metadata") }); let now_ms = control_clock_ms as f32; - let active = provider.control_effect_active(mode); + let active = alarm.unwrap_or_else(|| provider.control_effect_active(mode)); let phase = clock.update(now_ms).and_then(|()| { clock.phase(now_ms, manager_flag, Some(&provider)) }); -- cgit v1.2.3