From 79635316902c69a363f1d1a9ebef110d94190356 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Tue, 1 Dec 2026 08:55:10 +0400 Subject: fix(combat): let projectiles destroy mounted warbot parts Resolve mounted model triangles through the sampled socket chain and publish the damage to the assembled Control provider. Remove the damaged geometry, stop weapons whose provider was depleted, and preserve already separated ranges when the chassis later dies. Confirmed with a licensed AutoDemo ray query and two frames around a controlled hit in the Vulkan window. --- crates/fparkan-runtime/src/player_weapon.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'crates/fparkan-runtime/src/player_weapon.rs') diff --git a/crates/fparkan-runtime/src/player_weapon.rs b/crates/fparkan-runtime/src/player_weapon.rs index db24036b..0fe233ac 100644 --- a/crates/fparkan-runtime/src/player_weapon.rs +++ b/crates/fparkan-runtime/src/player_weapon.rs @@ -20,6 +20,7 @@ pub struct PlayerWeapon { pub component_index: usize, pub(super) control_record_index: usize, pub(super) charge: Option, + pub(super) destroyed: bool, pub(super) energy_waits: u64, pub(super) autonomous_fire_distance: f32, /// Name of the projectile prototype. @@ -172,6 +173,11 @@ impl PlayerWeapons { .iter_mut() .enumerate() .filter_map(move |(index, weapon)| { + if weapon.destroyed { + weapon.phase = FirePhase::Idle; + weapon.windup_started = false; + return None; + } let selected = selected.is_none_or(|selected| selected == index); let mut start = selected && trigger(index, weapon, &weapon.barrels[weapon.barrel_index].muzzle); @@ -467,6 +473,7 @@ fn prepare_weapons( component_index, control_record_index, charge: None, + destroyed: false, energy_waits: 0, autonomous_fire_distance: f32::from_bits(record.fixed_words[19]), projectile, @@ -736,6 +743,7 @@ mod tests { component_index: 0, control_record_index: 0, charge: None, + destroyed: false, energy_waits: 0, autonomous_fire_distance: 0.0, projectile: String::from("test"), @@ -785,6 +793,10 @@ mod tests { }); let mut node_times = [None]; assert!(weapons.fire(true, 0).next().is_none()); + let mut interrupted = weapons.clone(); + interrupted.weapons[0].destroyed = true; + assert!(interrupted.fire(true, 11).next().is_none()); + assert!(interrupted.started_windup_sounds(7).next().is_none()); assert_eq!( weapons.started_windup_sounds(7).collect::>(), [FiringEffectInstance { -- cgit v1.2.3