diff options
| author | Valentin Popov <valentin@popov.link> | 2026-12-01 07:55:10 +0300 |
|---|---|---|
| committer | Valentin Popov <valentin@popov.link> | 2026-12-01 07:55:10 +0300 |
| commit | 79635316902c69a363f1d1a9ebef110d94190356 (patch) | |
| tree | 806e345cc9d5553cea330483b828cb080bd22061 /crates/fparkan-runtime/src/player_weapon.rs | |
| parent | 777f48345c7faf891ac105fc4a831114914aff5d (diff) | |
| download | fparkan-79635316902c69a363f1d1a9ebef110d94190356.tar.xz fparkan-79635316902c69a363f1d1a9ebef110d94190356.zip | |
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.
Diffstat (limited to 'crates/fparkan-runtime/src/player_weapon.rs')
| -rw-r--r-- | crates/fparkan-runtime/src/player_weapon.rs | 12 |
1 files changed, 12 insertions, 0 deletions
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<crate::mobile_budget::Charge>, + 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::<Vec<_>>(), [FiringEffectInstance { |
