From c4baa5aea1abac26779ec5075232dba724ab6630 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Thu, 26 Nov 2026 17:45:39 +0400 Subject: fix(combat): recognize hits absorbed by shields Use the same impact result for manual fire and autonomous weapons. A shield that spends its charge and absorbs a whole shot completes the impact without reporting an unavailable target. Keep the existing hull damage API for callers that only need remaining health. Checked in a window on the stock Two Fortresses map. The laser first ended at the shield and then reduced hull health after the sector was depleted. At 180 seconds of AutoDemo the false unavailable reports disappear and the destruction sequence is identical. --- crates/fparkan-runtime/src/unit_combat.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'crates/fparkan-runtime/src/unit_combat.rs') diff --git a/crates/fparkan-runtime/src/unit_combat.rs b/crates/fparkan-runtime/src/unit_combat.rs index 03bf5c8d..224213bb 100644 --- a/crates/fparkan-runtime/src/unit_combat.rs +++ b/crates/fparkan-runtime/src/unit_combat.rs @@ -1,5 +1,5 @@ use super::{ - apply_projectile_contact, + apply_projectile_impact, autodemo::MOBILE_UNIT, combat_report::{CombatObject, CombatReport}, player_weapon::prepare_unit_weapons, @@ -9,7 +9,7 @@ use super::{ unit_patrol::UnitPatrol, weapon_pose::WeaponPoses, Engine, MissionAssets, MissionDocument, MissionObjectDraft, ObjectHandle, PlayerProjectile, - PlayerWeapons, + PlayerWeapons, ProjectileImpact, }; use fparkan_vfs::Vfs; use fparkan_world::{identity_metadata, transform_state}; @@ -468,16 +468,20 @@ impl AutoDemoCombat { let target = CombatObject::read(&engine.world, hit.handle); match data .volume - .map(|volume| apply_projectile_contact(engine, hit, volume)) + .map(|volume| apply_projectile_impact(engine, hit, volume)) { - Some(Ok(Some((_, true)))) => { + Some(Ok(ProjectileImpact::ShieldAbsorbed)) => {} + Some(Ok(ProjectileImpact::Damage { removed: true, .. })) => { self.report.destroyed(flight.shooter_identity, target, now); events.push(AutoDemoCombatEvent::Destroyed { shooter: flight.shooter, target: hit.handle, }); } - Some(Ok(Some((remaining, false)))) => { + Some(Ok(ProjectileImpact::Damage { + remaining, + removed: false, + })) => { if let Some(node) = hit.building_node() { events.push(AutoDemoCombatEvent::BuildingHit { shooter: flight.shooter, -- cgit v1.2.3