From be3b214702693eab36da4484624327d2cad8beec Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Tue, 1 Dec 2026 06:17:23 +0400 Subject: fix(gameplay): ground the hero when a warbot is destroyed A passenger kept the destroyed chassis root height and carried that offset into walking. In Two Fortresses this left the hero above the entrance to the last bunker. Put the hero on the terrain at the last chassis position, and retain the current elevation when the chassis was on a building floor. The licensed chassis test reproduces the old height and verifies the ejection after projectile damage. The stock Two Fortresses replay confirms the height correction during combat. Workspace checks and a Vulkan validation run from the normal start passed. Native ejection placement and the flying vehicle case remain open. --- crates/fparkan-runtime/src/boarding.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'crates/fparkan-runtime/src/boarding.rs') diff --git a/crates/fparkan-runtime/src/boarding.rs b/crates/fparkan-runtime/src/boarding.rs index 53ce8c81..e9dd7531 100644 --- a/crates/fparkan-runtime/src/boarding.rs +++ b/crates/fparkan-runtime/src/boarding.rs @@ -4,6 +4,7 @@ use super::{ starting_cockpit, Engine, EngineError, MissionControlDeviceTableState, MissionControlDeviceTableStatus, StartingCockpit, SurfaceQuery, TransformState, }; +use crate::player_motion::FLOOR_CLEARANCE; use fparkan_world::{ handle_by_original_id, identity_metadata, set_transform, transform_state, ObjectHandle, }; @@ -16,6 +17,7 @@ pub(super) struct Boarding { pub(super) hero: StartingCockpit, pub(super) can_fly: bool, pub(super) ground: Option, + pub(super) on_building_floor: bool, pub(super) flight_velocity: [f32; 3], } @@ -139,6 +141,7 @@ pub fn board_friendly_warbot( hero, can_fly, ground, + on_building_floor: false, flight_velocity: [0.0; 3], }); mission.player_pitch_bits = 0; @@ -186,6 +189,8 @@ pub fn disembark_warbot(engine: &mut Engine) -> Result, let Some(Boarding { cockpit: vehicle, hero, + can_fly, + on_building_floor, .. }) = mission.boarding else { @@ -211,7 +216,7 @@ pub fn disembark_warbot(engine: &mut Engine) -> Result, .height_at(xy) .map_err(EngineError::Terrain)? { - exit = Some([xy[0], xy[1], ground + 0.02]); + exit = Some([xy[0], xy[1], ground + FLOOR_CLEARANCE]); break; } } @@ -221,6 +226,17 @@ pub fn disembark_warbot(engine: &mut Engine) -> Result, pose.position = exit.map(f32::to_bits); pose.orientation[2] = yaw.to_bits(); set_transform(&mut engine.world, hero.handle, pose)?; + } else if !can_fly && !on_building_floor { + // The passenger still has the destroyed chassis's root height. + let [x, y, _] = pose.position.map(f32::from_bits); + if let Some(ground) = mission + .terrain + .height_at([x, y]) + .map_err(EngineError::Terrain)? + { + pose.position[2] = (ground + FLOOR_CLEARANCE).to_bits(); + set_transform(&mut engine.world, hero.handle, pose)?; + } } mission.boarding = None; mission.player_pitch_bits = 0; -- cgit v1.2.3