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/destruction.rs | 33 +++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) (limited to 'crates/fparkan-runtime/src/destruction.rs') diff --git a/crates/fparkan-runtime/src/destruction.rs b/crates/fparkan-runtime/src/destruction.rs index aa02197b..c19e7ed5 100644 --- a/crates/fparkan-runtime/src/destruction.rs +++ b/crates/fparkan-runtime/src/destruction.rs @@ -25,12 +25,16 @@ pub enum DestroyedMesh { Mounted { /// Prepared actor index. object_index: usize, + /// Component and node indices of pieces already separated before the chassis failed. + depleted_nodes: Vec<(usize, usize)>, }, - /// One separated node of a still live chassis. + /// One separated node of a still live warbot. ChassisNode { /// Prepared actor index. object_index: usize, - /// Local node of the root model. + /// Unit DAT component containing the mesh. + component_index: usize, + /// Local node of that model. node: usize, /// World position of the hull at impact. hull_origin: [f32; 3], @@ -86,7 +90,7 @@ pub fn unit_destruction_effect_sources( Some(if class & UNIT_DAT_CONTROL_CLASS_HIGH_BIT != 0 { rows.as_slice() } else if class == super::boarding::WARBOT_CLASS { - &rows[..rows.partition_point(|row| row.unit_component_index == 0)] + rows.as_slice() } else if class & MOBILE_UNIT != 0 { rows.get(..1).unwrap_or_default() } else { @@ -104,7 +108,7 @@ pub(super) fn part_effect( ) -> Option { let (archive, name) = node_effect(row)?; let mesh = match contact.node { - Some(super::ProjectileNode::Chassis(node)) + Some(super::ProjectileNode::Chassis(_) | super::ProjectileNode::Mounted(_)) if row.current_flags.is_some_and(|flags| flags & 2 == 0) => { let id = identity_metadata(&engine.world, contact.handle) @@ -113,7 +117,8 @@ pub(super) fn part_effect( let hull = transform_state(&engine.world, contact.handle).ok()?; Some(DestroyedMesh::ChassisNode { object_index: id.0 as usize, - node: node as usize, + component_index: row.unit_component_index, + node: row.source_row_index, hull_origin: hull.position.map(f32::from_bits), }) } @@ -152,7 +157,23 @@ pub(super) fn pending_effect( .position .map(f32::from_bits); Some(UnitDestructionEffect { - mesh: object_index.map(|object_index| DestroyedMesh::Mounted { object_index }), + mesh: object_index.map(|object_index| { + let depleted_nodes = match &table.node_provider_status { + MissionControlNodeProviderTableStatus::Available(rows) => rows + .iter() + .filter(|row| { + row.unit_component_index != 0 + && row.current_flags.is_some_and(|flags| flags & 0x12 == 0x10) + }) + .map(|row| (row.unit_component_index, row.source_row_index)) + .collect(), + MissionControlNodeProviderTableStatus::Unavailable(_) => Vec::new(), + }; + DestroyedMesh::Mounted { + object_index, + depleted_nodes, + } + }), position, archive, name, -- cgit v1.2.3