diff options
| author | Valentin Popov <valentin@popov.link> | 2026-12-01 06:57:23 +0300 |
|---|---|---|
| committer | Valentin Popov <valentin@popov.link> | 2026-12-01 06:57:23 +0300 |
| commit | 31dd73cbf59f5c8fe58b77b373a75033dc5a037a (patch) | |
| tree | 7a20ada1d75679b61a6c6716ffe91a10faba4592 /apps | |
| parent | 364f8a0984e5cd3b65e81f24e95fcf8cd92aec2d (diff) | |
| download | fparkan-31dd73cbf59f5c8fe58b77b373a75033dc5a037a.tar.xz fparkan-31dd73cbf59f5c8fe58b77b373a75033dc5a037a.zip | |
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.
Diffstat (limited to 'apps')
| -rw-r--r-- | apps/fparkan-game/src/control_effects.rs | 44 | ||||
| -rw-r--r-- | apps/fparkan-game/src/main.rs | 47 |
2 files changed, 81 insertions, 10 deletions
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<MissionRenderRoot>], + effect: ControlEffectInstanceKey, +) -> Option<bool> { + 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<FiringEffectInstance> 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<FxPhaseProvider>, owner_effect_phase: impl Fn(ControlEffectInstanceKey) -> Option<f32>, + owner_damage_alarm: impl Fn(ControlEffectInstanceKey) -> Option<bool>, ) -> HashMap<ControlEffectInstanceKey, ControlEffectFrameSample> { 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)) }); diff --git a/apps/fparkan-game/src/main.rs b/apps/fparkan-game/src/main.rs index 6f050780..8075ef2c 100644 --- a/apps/fparkan-game/src/main.rs +++ b/apps/fparkan-game/src/main.rs @@ -5706,6 +5706,7 @@ fn append_initial_control_effect_slots( let group_index = row.table_index; let archive = fixed_effect_field(&row.resource.archive); let name = fixed_effect_field(&row.resource.name); + let alarm_controlled = control.alarm_effect_rows.contains(&row.row_index); let windup = row.opcode == 3 && control.typed_records.iter().any(|record| { control @@ -5723,8 +5724,7 @@ fn append_initial_control_effect_slots( ) })?) } else { - // Chassis engine loops use the root. Weapon sounds use their authored node. - if !windup && row.point_offsets[0] != 0 { + if !windup && !alarm_controlled && row.point_offsets[0] != 0 { continue; } None @@ -5754,7 +5754,8 @@ fn append_initial_control_effect_slots( .get(&key) .ok_or_else(|| format!("Control FX {key} was not cached"))?; let header = document.header(); - if row.opcode == 3 && !windup && !matches!(header.time_mode, 5 | 15) { + let alarm_effect = alarm_controlled && header.time_mode == 14 && header.flags & 0x40 != 0; + if row.opcode == 3 && !windup && !alarm_effect && !matches!(header.time_mode, 5 | 15) { continue; } let sound_commands = document @@ -5850,7 +5851,7 @@ fn append_initial_control_effect_slots( ); for (command_index, command) in document.commands().iter().enumerate() { - if row.opcode == 3 && command.opcode != FxOpcode::Op2 { + if row.opcode == 3 && !alarm_effect && command.opcode != FxOpcode::Op2 { continue; } if ambient_effect_op1_supported(command) || command.opcode == FxOpcode::Op2 { @@ -5893,7 +5894,6 @@ fn append_initial_control_effect_slots( } continue; } - let Some(points) = points else { continue }; let Some(kind) = ambient_effect_command_kind(command) else { record_skip("opcode_or_body", 1, false, Some(command_index)); continue; @@ -6071,7 +6071,10 @@ fn append_initial_control_effect_slots( control_table_index: row.table_index, control_row_index: row.row_index, control_point_indices: row.point_offsets, - control_point_owners: points.map(|point| point.raw_signed_field_04), + control_point_owners: match points { + Some(points) => points.map(|point| point.raw_signed_field_04), + None => [owner_node_index as i32, -1, -1], + }, command: command.clone(), command_index, duration_seconds, @@ -14437,6 +14440,7 @@ mod tests { node_data: None, effect_section: PreparedControlEffectSection::Absent, initial_effect_group: None, + alarm_effect_rows: Vec::new(), node_effect_links: Vec::new(), effect_modes: Vec::new(), point_list: None, @@ -19272,6 +19276,7 @@ mod tests { |_| None, |_| None, |_| None, + |_| None, ); assert!(update_control_point_lights( &mut [inactive], @@ -19294,6 +19299,7 @@ mod tests { |_| None, |_| None, |_| None, + |_| None, ); let lights = update_control_point_lights( std::slice::from_mut(&mut slot), @@ -19341,6 +19347,7 @@ mod tests { |_| None, |_| None, |_| None, + |_| None, ); assert_eq!(first.len(), 1); let key = slot.random_instance_key; @@ -19370,6 +19377,7 @@ mod tests { |_| None, |_| None, |_| None, + |_| None, )[&key], first_sample, "a repeated read of the same captured update reuses the shared sample" @@ -19385,6 +19393,7 @@ mod tests { |_| None, |_| None, |_| None, + |_| None, ); let expected = expected_state.advance(SceneSampleId::Replay(8), 500, 1.0); assert_eq!(second[&key].phase_jitter, expected.phase_jitter); @@ -19412,6 +19421,7 @@ mod tests { |_| None, |_| None, |_| None, + |_| None, ); assert_eq!(later[&key].phase, Some(1.0)); assert_eq!(later[&key].elapsed_seconds, 0.5); @@ -19426,6 +19436,7 @@ mod tests { |_| None, |_| None, |_| None, + |_| None, ); assert_eq!(restarted[&key].phase, Some(0.0)); assert_eq!(restarted[&key].elapsed_seconds, 0.0); @@ -19466,6 +19477,7 @@ mod tests { |_| None, |_| None, |_| None, + |_| None, ); assert_eq!(samples[&key].phase, Some(expected)); } @@ -19484,6 +19496,7 @@ mod tests { |_| None, |_| None, |_| None, + |_| None, ); assert_eq!( samples[&key].phase, @@ -19509,12 +19522,34 @@ mod tests { |_| Some((remaining, 100.0)), |_| None, |_| None, + |_| None, ); assert_eq!(samples[&key].phase, expected); if expected.is_none() { assert_eq!(samples[&key].phase_jitter, 0.0); } } + + slot.header_flags = 0x49; + let mut alarm_states = HashMap::new(); + for (frame, active, expected) in + [(15, false, None), (16, true, Some(0.25)), (17, false, None)] + { + let samples = advance_control_effect_instances( + &mut alarm_states, + &[], + std::slice::from_ref(&slot), + &[], + SceneSampleId::Replay(frame), + 5_000 + frame as u32 * 100, + false, + |_| Some((75.0, 100.0)), + |_| None, + |_| None, + |_| Some(active), + ); + assert_eq!(samples[&key].phase, expected); + } } #[test] |
