From 364f8a0984e5cd3b65e81f24e95fcf8cd92aec2d Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Tue, 1 Dec 2026 07:34:52 +0400 Subject: fix(combat): apply critical damage on the Control resource tick Use the alarm entry amount for sequential wear and disable the onboard repair device before recomputing motion limits. Match the Control.dll alarm and recovery vector. In the stock AutoDemo the affected warbot now loses its remaining movement instead of keeping its last limit. Alarm effects and the full native node cascade remain approximate. --- crates/fparkan-runtime/src/projectile.rs | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 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 312371d8..4666dfd9 100644 --- a/crates/fparkan-runtime/src/projectile.rs +++ b/crates/fparkan-runtime/src/projectile.rs @@ -10,7 +10,7 @@ use fparkan_render::LegacyIron3dEulerTransform; use fparkan_resource::{resource_name, CachedResourceRepository}; use fparkan_terrain::{FullSurfaceMask, SurfaceQuery, TerrainError}; use fparkan_vfs::Vfs; -use fparkan_world::{handle_by_original_id, request_delete, transform_state, ObjectHandle}; +use fparkan_world::{handle_by_original_id, transform_state, ObjectHandle}; use std::sync::Arc; pub(super) const ANIMAL_UNIT_CLASS: u32 = 0x2000_0000; @@ -369,7 +369,8 @@ fn apply_contact_damage( && matches!(contact.node, Some(ProjectileNode::Chassis(_))) && row.current_flags.is_some_and(|flags| flags & 1 != 0) { - return destroy_projectile_target(engine, contact.handle).map(Some); + super::destruction::destroy(engine, contact.handle)?; + return Ok(Some((0.0, true))); } // shortcut: feed the projectile NDP volume into the native reduction while impact falloff is open. let effect = (volume >= remaining && engine.destruction_effects.is_some()) @@ -432,24 +433,13 @@ pub fn apply_projectile_hit( // shortcut: use the projectile provider volume directly, with immediate // removal on root depletion until native damage and death timing are wired. if volume >= remaining { - return destroy_projectile_target(engine, handle).map(Some); + super::destruction::destroy(engine, handle)?; + return Ok(Some((0.0, true))); } apply_loaded_mission_control_node_delta(engine, handle, 0, -volume)?; Ok(Some((remaining - volume, false))) } -fn destroy_projectile_target( - engine: &mut Engine, - handle: ObjectHandle, -) -> Result<(f32, bool), ControlResourceAccessError> { - let effect = super::destruction::pending_effect(engine, handle); - request_delete(&mut engine.world, handle).map_err(ControlResourceAccessError::World)?; - if let (Some(effect), Some(events)) = (effect, engine.destruction_effects.as_mut()) { - events.push(effect); - } - Ok((0.0, true)) -} - #[cfg(test)] mod tests { use super::*; -- cgit v1.2.3