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/mobile_budget.rs | 36 +++++++++++++++++------------ 1 file changed, 21 insertions(+), 15 deletions(-) (limited to 'crates/fparkan-runtime/src/mobile_budget.rs') diff --git a/crates/fparkan-runtime/src/mobile_budget.rs b/crates/fparkan-runtime/src/mobile_budget.rs index 06dc251e..1df2ab80 100644 --- a/crates/fparkan-runtime/src/mobile_budget.rs +++ b/crates/fparkan-runtime/src/mobile_budget.rs @@ -267,21 +267,24 @@ pub(super) fn read( _ => None, }); for weapon in weapons { - weapon.charge = if mission.control_resources.energy_available(handle) { - devices - .and_then(|devices| devices.iter().find(|device| matches_weapon(device, weapon))) - .and_then(|device| { - let coefficients = device.coefficient_bits?; - let charge = Charge { - capacity: f32::from_bits(coefficients[1]), - cost: f32::from_bits(coefficients[2]), - amount: f32::from_bits(device.weapon_charge_bits?), - }; - [charge.capacity, charge.cost, charge.amount] - .into_iter() - .all(|value| value.is_finite() && !value.is_subnormal()) - .then_some(charge) - }) + let device = devices + .and_then(|devices| devices.iter().find(|device| matches_weapon(device, weapon))); + weapon.destroyed = device + .and_then(|device| crate::control_node_provider_row(table?, device.key).ok()) + .is_some_and(|row| row.current_flags.is_some_and(|flags| flags & 0x10 != 0)); + weapon.charge = if !weapon.destroyed && mission.control_resources.energy_available(handle) { + device.and_then(|device| { + let coefficients = device.coefficient_bits?; + let charge = Charge { + capacity: f32::from_bits(coefficients[1]), + cost: f32::from_bits(coefficients[2]), + amount: f32::from_bits(device.weapon_charge_bits?), + }; + [charge.capacity, charge.cost, charge.amount] + .into_iter() + .all(|value| value.is_finite() && !value.is_subnormal()) + .then_some(charge) + }) } else { None }; @@ -332,6 +335,9 @@ pub(super) fn publish( } for weapon in weapons { weapon.energy_waits = 0; + if weapon.destroyed { + continue; + } let Some(charge) = &weapon.charge else { if available { mission.control_resources.mobile.stub( -- cgit v1.2.3