aboutsummaryrefslogtreecommitdiff
path: root/crates/fparkan-runtime/src/projectile.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-11-26 08:08:32 +0300
committerValentin Popov <valentin@popov.link>2026-11-26 08:08:32 +0300
commit7f2f07669898e66b2391cfd36dcd7a9ea21bd90f (patch)
tree6bd648d6ea4e16904a5a2e60412b9371d76dd7cf /crates/fparkan-runtime/src/projectile.rs
parent43462dacb4c78742aeb84bdfac3dccad9933dd20 (diff)
downloadfparkan-7f2f07669898e66b2391cfd36dcd7a9ea21bd90f.tar.xz
fparkan-7f2f07669898e66b2391cfd36dcd7a9ea21bd90f.zip
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.
Diffstat (limited to 'crates/fparkan-runtime/src/projectile.rs')
-rw-r--r--crates/fparkan-runtime/src/projectile.rs20
1 files changed, 12 insertions, 8 deletions
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<Option<(f32, bool)>, 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();