From 3caf781850682fbf04958f70636471e546f0d426 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Thu, 26 Nov 2026 16:08:21 +0400 Subject: fix(mission): recognize the exit from the teleporter floor Behavior.dll at 0x18310 evaluates the cylinder with a candidate position queried through 0x14b30. Reuse the authored hero spawn clearance for the floor-level walking probe. Keep the cylinder from the licensed DLL oracle and the asset's original center. The stock Teleport input replay captures the portal, transfers to the lower passage and renders the victory at the glowing exit. Correct the focused fixture to use the actual factory and laboratory communicator floors. --- crates/fparkan-runtime/src/lib.rs | 7 ++++--- crates/fparkan-runtime/src/mission_events.rs | 16 ++++++++++++---- crates/fparkan-runtime/src/player_motion.rs | 21 +++++++++++++-------- docs/appendices/knowledge-boundaries.md | 5 +++-- docs/tomes/06-behavior.md | 6 +++++- 5 files changed, 37 insertions(+), 18 deletions(-) diff --git a/crates/fparkan-runtime/src/lib.rs b/crates/fparkan-runtime/src/lib.rs index a897839b..3b177b0a 100644 --- a/crates/fparkan-runtime/src/lib.rs +++ b/crates/fparkan-runtime/src/lib.rs @@ -18372,8 +18372,8 @@ mod tests { "{after:?}" ); for (time, slot, objective, plate) in [ - (4_001, 4, 1, [750.0_f32, 950.7, 45.88]), - (6_001, 5, 2, [950.7, 869.4, 69.98]), + (4_001, 4, 1, [750.0_f32, 950.7, 40.11]), + (6_001, 5, 2, [950.7, 869.4, 63.98]), (8_001, 3, 4, [1179.28, 1242.12, 101.60]), ] { if slot == 3 { @@ -18405,7 +18405,8 @@ mod tests { set_transform(&mut engine.world, cockpit.handle, pose).unwrap(); assert!(frame(&mut engine, 8_002).unwrap().mission_event.is_none()); assert_eq!(loaded_mission_script_outcome(&engine), active); - pose.position = [1175.335_f32, 1242.098, 79.0].map(f32::to_bits); + // Walking toward the portal on the stock lower tunnel's floor. + pose.position = [1173.7439_f32, 1243.9574, 74.78949].map(f32::to_bits); set_transform(&mut engine.world, cockpit.handle, pose).unwrap(); let event = frame(&mut engine, 8_003).unwrap().mission_event.unwrap(); assert!(event.stop.is_none(), "{event:?}"); diff --git a/crates/fparkan-runtime/src/mission_events.rs b/crates/fparkan-runtime/src/mission_events.rs index fc02236d..62564970 100644 --- a/crates/fparkan-runtime/src/mission_events.rs +++ b/crates/fparkan-runtime/src/mission_events.rs @@ -716,17 +716,22 @@ impl LoadedMissionState { if self.boarding.is_some() || self.script_host_mode != super::MissionMode::SingleMission { return false; } - let hero = self.object_drafts.iter().find(|draft| { + let Some(hero) = self.object_drafts.iter().find(|draft| { draft.unit_dat_header_flags == Some(super::HERO_UNIT_CLASS) && draft.raw_after_resource == 0 - }); + }) else { + return false; + }; let Some(hero_position) = hero - .and_then(|draft| handle_by_original_id(world, draft.original_id?)) + .original_id + .and_then(|id| handle_by_original_id(world, id)) .and_then(|hero| transform_state(world, hero).ok()) .map(|pose| pose.position.map(f32::from_bits)) else { return false; }; + let clearance = crate::player_motion::spawn_floor_clearance(&self.terrain, hero.position) + .unwrap_or_default(); self.object_drafts.iter().enumerate().any(|(index, draft)| { if draft.unit_dat_header_flags != Some(MAIN_TELEPORT_CLASS) { return false; @@ -755,8 +760,11 @@ impl LoadedMissionState { }) else { return false; }; - // shortcut: static node poses and the ordinary Res17 volume until animated triggers are wired. + // shortcut: use the authored spawn clearance to project a + // floor-level walking pose into the native contact volume. + let [x, y, z] = hero_position; inside_exit_volume(center, hero_position) + || inside_exit_volume(center, [x, y, z + clearance]) })) }; hit() == Some(true) diff --git a/crates/fparkan-runtime/src/player_motion.rs b/crates/fparkan-runtime/src/player_motion.rs index 5a999546..18bd2d68 100644 --- a/crates/fparkan-runtime/src/player_motion.rs +++ b/crates/fparkan-runtime/src/player_motion.rs @@ -32,6 +32,18 @@ const WATER_SURFACE: u32 = 0x0002_0000; const WALK_COLLISION_DISTANCE: f32 = 0.16; const WALK_SPEED_FALLBACK: f32 = 8.0; +pub(super) fn spawn_floor_clearance( + terrain: &TerrainWorld, + [x, y, z]: [f32; 3], +) -> Result { + let floor = terrain + .height_at([x, y]) + .map_err(|error| EngineError::Movement(error.to_string()))?; + Ok(floor.map_or(FLOOR_CLEARANCE, |floor| { + (z - floor).clamp(FLOOR_CLEARANCE, STEP_DOWN) + })) +} + /// Player controls sampled once for a simulation step. #[derive(Clone, Copy, Debug, Default)] pub struct PlayerMotion { @@ -433,14 +445,7 @@ fn plan_player_steps( let mut max_floor_clearance = FLOOR_CLEARANCE; if !flying && input.movement != [0.0; 2] { if let Some(draft) = mission.object_drafts.get(cockpit.object_index) { - let [x, y, z] = draft.position; - if let Some(ground) = mission - .terrain - .height_at([x, y]) - .map_err(|err| EngineError::Movement(err.to_string()))? - { - max_floor_clearance = (z - ground).clamp(FLOOR_CLEARANCE, STEP_DOWN); - } + max_floor_clearance = spawn_floor_clearance(&mission.terrain, draft.position)?; } } let Some(resolve) = resolve else { diff --git a/docs/appendices/knowledge-boundaries.md b/docs/appendices/knowledge-boundaries.md index 99ad56a6..074a621c 100644 --- a/docs/appendices/knowledge-boundaries.md +++ b/docs/appendices/knowledge-boundaries.md @@ -261,8 +261,9 @@ seed и общий порядок Control RNG открыты. `control_resource_ пока не использует платную задачу кланового AI; выбор и раскрытие зависимостей открыты. `mission_hero_exit_approx` отмечает зоны входа и выхода в исходной позе -узлов. Вход использует пробу корпуса героя, отбор генераторов охватывает -всю миссию. Открыты исходная проверка контакта, границы нативной +узлов. Вход использует пробу корпуса героя, выход учитывает зазор над +опорой из точки старта. Отбор генераторов охватывает всю миссию. +Открыты положение нативной точки контакта, границы нативной выборки, анимация и ориентация переноса, динамические зоны, размеры из вспомогательных векторов и переход к следующей миссии. `mission_message_ui_stub` также покрывает повторные интерфейсные ветви diff --git a/docs/tomes/06-behavior.md b/docs/tomes/06-behavior.md index 26b8bfe7..f3ea86c5 100644 --- a/docs/tomes/06-behavior.md +++ b/docs/tomes/06-behavior.md @@ -3090,7 +3090,11 @@ FParkan подаёт одну фазу в отрисовку и расчёт п по RVA `0x1914f` проверяет героя и передаёт событие выхода сценарию. FParkan пересчитывает центр по положению здания, его масштабу и -исходной позе узла. Когда герой пешком входит в зону главного телепорта, +исходной позе узла. Оригинальный обход кандидатов по RVA `0x18310` +берёт их положение из матрицы, которую запрашивает функция по RVA +`0x14b30`. Точка опоры FParkan лежит ниже центра героя. Поэтому для +выхода движок проверяет также точку над опорой с зазором из штатного +старта. Когда герой пешком входит в зону главного телепорта, движок вызывает `Hero_Teleported` из сценария миссии. В «Телепорте» команда сценария завершает миссию. Игра выводит «Миссия выполнена» в заголовке окна и ставит в очередь голосовое сообщение о победе. -- cgit v1.2.3