aboutsummaryrefslogtreecommitdiff
path: root/crates/fparkan-runtime/src/control_resources.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-12-01 06:34:52 +0300
committerValentin Popov <valentin@popov.link>2026-12-01 06:34:52 +0300
commit364f8a0984e5cd3b65e81f24e95fcf8cd92aec2d (patch)
tree24734f764a565d376051b322619a6a4c82758601 /crates/fparkan-runtime/src/control_resources.rs
parentc83b6fcdc97a193184552b436086a76679d024ba (diff)
downloadfparkan-364f8a0984e5cd3b65e81f24e95fcf8cd92aec2d.tar.xz
fparkan-364f8a0984e5cd3b65e81f24e95fcf8cd92aec2d.zip
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.
Diffstat (limited to 'crates/fparkan-runtime/src/control_resources.rs')
-rw-r--r--crates/fparkan-runtime/src/control_resources.rs31
1 files changed, 23 insertions, 8 deletions
diff --git a/crates/fparkan-runtime/src/control_resources.rs b/crates/fparkan-runtime/src/control_resources.rs
index 2ab2a0df..b9958229 100644
--- a/crates/fparkan-runtime/src/control_resources.rs
+++ b/crates/fparkan-runtime/src/control_resources.rs
@@ -1,8 +1,8 @@
use crate::{
- control_profile, control_resource_budget_pass, repair_zone, ControlProfileReport,
- LoadedMissionState, MissionControlDeviceTableStatus, MobileBudgetReport,
+ control_profile, control_resource_budget_pass, repair_zone, ControlProfileReport, Engine,
+ MissionControlDeviceTableStatus, MobileBudgetReport,
};
-use fparkan_world::{transform_state, ObjectHandle, World};
+use fparkan_world::{transform_state, ObjectHandle};
use std::collections::BTreeMap;
/// Supported Control budgets; motion callbacks and global RNG ordering remain open.
@@ -49,8 +49,13 @@ impl Resources {
}
}
-pub(super) fn tick(mission: &mut LoadedMissionState, world: &World, now_ms: u32) {
+pub(super) fn tick(engine: &mut Engine, now_ms: u32) {
+ let Some(mission) = &mut engine.loaded else {
+ return;
+ };
+ let world = &engine.world;
let state = &mut mission.control_resources;
+ let mut depleted = Vec::new();
state
.repair_zones
.prepare(&mission.mission_assets, &mission.object_drafts);
@@ -89,7 +94,7 @@ pub(super) fn tick(mission: &mut LoadedMissionState, world: &World, now_ms: u32)
ResourceClock {
frame_ms: now_ms as f32,
resource_ms: now_ms as f32,
- forced: 0,
+ ..ResourceClock::default()
},
));
&mut state
@@ -115,8 +120,8 @@ pub(super) fn tick(mission: &mut LoadedMissionState, world: &World, now_ms: u32)
.owner_profile
.as_ref()
.map_or(0, |profile| profile.current_words[7]);
- match control_profile::refresh(table) {
- Ok(true) => {
+ match control_profile::refresh(table, &mut clock.alarm, seconds) {
+ Ok(control_profile::Refresh::Published) => {
let after = table
.owner_profile
.as_ref()
@@ -132,7 +137,11 @@ pub(super) fn tick(mission: &mut LoadedMissionState, world: &World, now_ms: u32)
);
}
}
- Ok(false) => {}
+ Ok(control_profile::Refresh::Clean) => {}
+ Ok(control_profile::Refresh::Depleted) => {
+ depleted.push(table.handle);
+ continue;
+ }
Err(reason) => {
let count = state
.profiles
@@ -195,6 +204,11 @@ pub(super) fn tick(mission: &mut LoadedMissionState, world: &World, now_ms: u32)
}
}
}
+ for handle in depleted {
+ if let Err(reason) = crate::destruction::destroy(engine, handle) {
+ eprintln!("control_alarm_destruction_failed object={handle:?} reason={reason:?}");
+ }
+ }
}
#[derive(Default)]
@@ -202,6 +216,7 @@ struct ResourceClock {
frame_ms: f32,
resource_ms: f32,
forced: u32,
+ alarm: control_profile::DamageAlarm,
}
impl ResourceClock {