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/destruction.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/destruction.rs')
| -rw-r--r-- | crates/fparkan-runtime/src/destruction.rs | 33 |
1 files changed, 27 insertions, 6 deletions
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<UnitDestructionEffect> { 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, |
