From 7f2f07669898e66b2391cfd36dcd7a9ea21bd90f Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Thu, 26 Nov 2026 09:08:32 +0400 Subject: feat(combat): reduce damage with Control protection coefficients Keep the two damage coefficients in the existing tag-27 owner cache and apply the native quadratic clamp to projectile contacts. The calculation matches live GOG damage samples at single precision, and the AutoDemo window reaches combat and replacement after the change. --- crates/fparkan-runtime/src/projectile.rs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 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 3e9b7088..0767ee4e 100644 --- a/crates/fparkan-runtime/src/projectile.rs +++ b/crates/fparkan-runtime/src/projectile.rs @@ -312,16 +312,20 @@ pub fn apply_projectile_contact( contact: ProjectileContact, volume: f32, ) -> Result, ControlResourceAccessError> { - let Some(key) = contact.building_node else { - return apply_projectile_hit(engine, contact.handle, volume); - }; - let row = engine.loaded.as_ref().and_then(|mission| { - let table = mission + let table = engine.loaded.as_ref().and_then(|mission| { + mission .control_device_tables .iter() - .find(|table| table.handle == contact.handle)?; - super::control_node_provider_row(table, key).ok() + .find(|table| table.handle == contact.handle) }); + let volume = super::projectile_damage::resisted_volume( + volume, + table.and_then(|table| table.projectile_resistance_bits), + ); + let Some(key) = contact.building_node else { + return apply_projectile_hit(engine, contact.handle, volume); + }; + let row = table.and_then(|table| super::control_node_provider_row(table, key).ok()); let Some(row) = row else { return Ok(None); }; @@ -334,7 +338,7 @@ pub fn apply_projectile_contact( { return Ok(None); } - // shortcut: keep per-node damage using the projectile NDP volume while armor and splash are open. + // shortcut: feed the projectile NDP volume into the native reduction while impact falloff is open. let effect = (volume >= remaining && engine.destruction_effects.is_some()) .then(|| super::destruction::building_part_effect(row, contact.position)) .flatten(); -- cgit v1.2.3