aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-12-01 09:56:17 +0300
committerValentin Popov <valentin@popov.link>2026-12-01 09:56:17 +0300
commitb21189c3089acc1cf24e530db40707aae292813d (patch)
treed53629295bb034fddf36f4b1a5e57ec2aa0eb4d1
parent350df52410d4ae731834c56a9f8eb628e24592fd (diff)
downloadfparkan-b21189c3089acc1cf24e530db40707aae292813d.tar.xz
fparkan-b21189c3089acc1cf24e530db40707aae292813d.zip
fix(gameplay): keep selected suit weapons deployed
-rw-r--r--crates/fparkan-runtime/src/player_weapon.rs44
-rw-r--r--crates/fparkan-runtime/src/weapon_deployment.rs4
-rw-r--r--docs/appendices/knowledge-boundaries.md5
-rw-r--r--docs/tomes/06-behavior.md11
4 files changed, 47 insertions, 17 deletions
diff --git a/crates/fparkan-runtime/src/player_weapon.rs b/crates/fparkan-runtime/src/player_weapon.rs
index 0fe233ac..421f0e7a 100644
--- a/crates/fparkan-runtime/src/player_weapon.rs
+++ b/crates/fparkan-runtime/src/player_weapon.rs
@@ -8,11 +8,19 @@ use fparkan_assets::{
#[derive(Clone, Default)]
pub struct PlayerWeapons {
weapons: Vec<PlayerWeapon>,
- selected: Option<usize>,
+ selection: WeaponSelection,
last_sample_ms: Option<u32>,
clock_ms: f64,
}
+#[derive(Clone, Copy, Default)]
+enum WeaponSelection {
+ #[default]
+ All,
+ StandardSuit,
+ Slot(usize),
+}
+
/// A manual-fire device prepared from its CTLD record and effect rows.
#[derive(Clone)]
pub struct PlayerWeapon {
@@ -141,8 +149,8 @@ impl PlayerWeapons {
/// Selects all weapons with zero, or one weapon by its one-based slot.
pub fn select(&mut self, slot: usize) {
match slot {
- 0 => self.selected = None,
- n if n <= self.weapons.len() => self.selected = Some(n - 1),
+ 0 => self.selection = WeaponSelection::All,
+ n if n <= self.weapons.len() => self.selection = WeaponSelection::Slot(n - 1),
_ => {}
}
}
@@ -168,7 +176,7 @@ impl PlayerWeapons {
.map_or(0, |last| clock_ms.wrapping_sub(last));
self.clock_ms += f64::from(elapsed_ms);
let now = self.clock_ms;
- let selected = self.selected;
+ let selection = self.selection;
self.weapons
.iter_mut()
.enumerate()
@@ -178,7 +186,11 @@ impl PlayerWeapons {
weapon.windup_started = false;
return None;
}
- let selected = selected.is_none_or(|selected| selected == index);
+ let selected = match selection {
+ WeaponSelection::All => true,
+ WeaponSelection::StandardSuit => matches!(index, 0 | 2),
+ WeaponSelection::Slot(slot) => slot == index,
+ };
let mut start =
selected && trigger(index, weapon, &weapon.barrels[weapon.barrel_index].muzzle);
if let Some(deployment) = &mut weapon.deployment {
@@ -367,8 +379,19 @@ pub fn starting_player_weapons(engine: &Engine, cockpit: StartingCockpit) -> Pla
);
}
}
+ let selection = if control
+ .source
+ .name
+ .0
+ .eq_ignore_ascii_case(b"o_tur_ht_02.ctl")
+ {
+ WeaponSelection::StandardSuit
+ } else {
+ WeaponSelection::All
+ };
PlayerWeapons {
weapons,
+ selection,
..PlayerWeapons::default()
}
}
@@ -674,7 +697,7 @@ mod tests {
.into_iter()
.map(|time| time.map(|time| time.0))
.collect();
- assert!(weapons.fire(true, 0).next().is_none());
+ assert!(weapons.fire(false, 0).next().is_none());
assert!(weapons.fire(false, 225).next().is_none());
weapons.apply_firing_pose(hero.component_index, &mut times);
assert_eq!(times[11], Some(44.7));
@@ -694,7 +717,7 @@ mod tests {
(752, 0.0),
] {
let shot = weapons
- .fire(false, now)
+ .fire(now == 500, now)
.next()
.map(|(slot, _, muzzle)| (slot, muzzle.clone()));
assert_eq!(shot.is_some(), now == 626);
@@ -730,8 +753,13 @@ mod tests {
assert!(weapons.fire(false, 753).next().is_none());
assert!(weapons.fire(false, 978).next().is_none());
weapons.apply_firing_pose(hero.component_index, &mut times);
+ assert_eq!(times[11], Some(48.0));
+ weapons.select(2);
+ assert!(weapons.fire(false, 978).next().is_none());
+ assert!(weapons.fire(false, 1203).next().is_none());
+ weapons.apply_firing_pose(hero.component_index, &mut times);
assert_eq!(times[11], Some(45.3));
- assert!(weapons.fire(false, 1253).next().is_none());
+ assert!(weapons.fire(false, 1478).next().is_none());
weapons.apply_firing_pose(hero.component_index, &mut times);
assert_eq!(times[11], Some(42.0));
}
diff --git a/crates/fparkan-runtime/src/weapon_deployment.rs b/crates/fparkan-runtime/src/weapon_deployment.rs
index 0dec287b..4be6f6e8 100644
--- a/crates/fparkan-runtime/src/weapon_deployment.rs
+++ b/crates/fparkan-runtime/src/weapon_deployment.rs
@@ -88,10 +88,8 @@ impl WeaponDeployment {
(track.position_ms - step).max(0.0)
};
}
- // shortcut: use the manual trigger to deploy. Native CTL 24 activation
- // rules beyond the authored tracks and clock still need a live comparison.
self.pending_shot = selected && (self.pending_shot || trigger);
- self.extending = self.pending_shot || cycling;
+ self.extending = selected || cycling;
let start = self.pending_shot
&& self
.tracks
diff --git a/docs/appendices/knowledge-boundaries.md b/docs/appendices/knowledge-boundaries.md
index ac88c28d..3dc3b687 100644
--- a/docs/appendices/knowledge-boundaries.md
+++ b/docs/appendices/knowledge-boundaries.md
@@ -166,8 +166,9 @@ authoring API без динамического подтверждения.
`player_weapon_cycle_approx` отмечает предел в один выстрел орудия
на выборку, открытые режимы наведения, одновременный залп из нескольких
стволов и пополнение боезапаса. Модель героя использует дорожки крепления
-CTL типа 24 и дорожки выстрела типа 2. Точное условие активации и темп
-выстрела требуют сверки в живой миссии. Автономная отдача и полная
+CTL типа 24 и дорожки выстрела типа 2. Выбранное орудие сохраняет боевую
+позу между выстрелами. Сочетания выбора отдельных орудий, спуск во время
+выдвижения и темп выстрела требуют сверки. Автономная отдача и полная
активация дульных эффектов открыты.
`player_projectile_flight_approx` отмечает прямой полёт, открытые
баллистику и разброс. Герой стреляет вдоль оси CPT в текущей позе.
diff --git a/docs/tomes/06-behavior.md b/docs/tomes/06-behavior.md
index e76d2625..4c723e2e 100644
--- a/docs/tomes/06-behavior.md
+++ b/docs/tomes/06-behavior.md
@@ -3000,10 +3000,13 @@ FParkan отдельно проверяет, пора ли корпусу ост
по RVA `0x20900` скорость из CTL приводила к фазам 0,45 на 225 мс, 0,9
на 450 мс и 1 на 500 мс. Обратный ход занимал те же 500 мс.
-В FParkan нажатие огня переводит выбранное оружие в боевое положение.
-Выстрел начинается, когда все дорожки крепления дошли до конца. Короткое
-нажатие сохраняется до готовности. После завершения цикла оружие
-убирается. Точное условие активации у оригинала требует сверки.
+В штатной раскладке стандартного костюма пушка и лазер выбраны одновременно.
+В живом «Огневом рубеже» у их устройств крепления значение фазы в `+0x94` равно
+единице до и после залпа. У остальных креплений оно равно нулю. В FParkan
+выбор орудия запускает дорожки крепления и удерживает боевую позу между
+выстрелами. При снятии выбора дорожки возвращаются к походной позе.
+Если спуск нажат до готовности крепления, FParkan сохраняет запрос до конца
+перехода. Это ожидание и исходные настройки других костюмов открыты.
В изолированном вызове `Control.dll` по RVA `0x1b4f0` смещение узла меняло
дульную точку, а поворот менял и точку, и направление. Стволы всех четырёх