From 352026c1ce039443efc779876b27654d992bfff1 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Tue, 1 Dec 2026 08:12:30 +0400 Subject: fix(combat): propagate the loss of a warbot chassis section Reuse the Control provider traversal after a lethal chassis hit so attached links disappear with the failed section. The GOG Control oracle and a controlled AutoDemo hit confirm the subtree behavior. All 29 missions reached 900 simulated seconds. --- crates/fparkan-runtime/src/projectile.rs | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'crates/fparkan-runtime/src/projectile.rs') diff --git a/crates/fparkan-runtime/src/projectile.rs b/crates/fparkan-runtime/src/projectile.rs index 4666dfd9..5359fc42 100644 --- a/crates/fparkan-runtime/src/projectile.rs +++ b/crates/fparkan-runtime/src/projectile.rs @@ -377,12 +377,33 @@ fn apply_contact_damage( .then(|| super::destruction::part_effect(engine, row, contact)) .flatten(); let updated = apply_loaded_mission_control_node_delta(engine, contact.handle, key, -volume)?; - if updated.is_some() { - if let (Some(effect), Some(events)) = (effect, engine.destruction_effects.as_mut()) { - events.push(effect); + if updated.is_none() { + return Ok(None); + } + if volume >= remaining && matches!(contact.node, Some(ProjectileNode::Chassis(_))) { + let table = engine + .loaded + .as_mut() + .and_then(|mission| { + mission + .control_device_tables + .iter_mut() + .find(|table| table.handle == contact.handle) + }) + .expect("successful damage updated the target table"); + match super::node_stage::propagate_chassis_damage(table, key) { + Ok(true) => { + super::destruction::destroy(engine, contact.handle)?; + return Ok(Some((0.0, true))); + } + Ok(false) => {} + Err(reason) => eprintln!("sim_coverage chassis_depletion_cascade_stub=1 object={} node={key} reason={reason:?}", contact.handle.slot), } } - Ok(updated.map(|_| ((remaining - volume).max(0.0), false))) + if let (Some(effect), Some(events)) = (effect, engine.destruction_effects.as_mut()) { + events.push(effect); + } + Ok(Some(((remaining - volume).max(0.0), false))) } pub(super) fn segment_sphere_fraction( -- cgit v1.2.3