diff options
| author | Valentin Popov <valentin@popov.link> | 2026-11-26 12:39:26 +0300 |
|---|---|---|
| committer | Valentin Popov <valentin@popov.link> | 2026-11-26 12:39:26 +0300 |
| commit | 2bf70f8b1eca48ba40215a4e58aaf6b133d84b18 (patch) | |
| tree | 61deae894a5e3c7aa78f65f3abc25a4a34091ac2 /crates | |
| parent | 54b6e83f62fe52b221dcb7eebff245e9d5b39305 (diff) | |
| download | fparkan-2bf70f8b1eca48ba40215a4e58aaf6b133d84b18.tar.xz fparkan-2bf70f8b1eca48ba40215a4e58aaf6b133d84b18.zip | |
fix(player): capture buildings at the communicator floor
On the stock Constructor map, walk through the factory basement to the communicator and press Enter. The first objective completes and the same path returns to ground level. The green ceiling no longer hides the floor in the contact query.
Diffstat (limited to 'crates')
| -rw-r--r-- | crates/fparkan-runtime/src/lib.rs | 54 | ||||
| -rw-r--r-- | crates/fparkan-runtime/src/mission_events.rs | 14 |
2 files changed, 45 insertions, 23 deletions
diff --git a/crates/fparkan-runtime/src/lib.rs b/crates/fparkan-runtime/src/lib.rs index 9a2b8a56..a67276a3 100644 --- a/crates/fparkan-runtime/src/lib.rs +++ b/crates/fparkan-runtime/src/lib.rs @@ -18214,7 +18214,7 @@ mod tests { ); assert_eq!(capture_building(&mut engine, hero).unwrap(), None); let mut pose = transform_state(&engine.world, hero.handle).unwrap(); - pose.position = [1871.4402_f32, 2020.2354, 61.34749].map(f32::to_bits); + pose.position = [1871.4402_f32, 2020.2354, 56.974].map(f32::to_bits); set_transform(&mut engine.world, hero.handle, pose).unwrap(); assert_eq!(capture_neutral_building(&mut engine, hero).unwrap(), None); let count = |engine: &Engine| { @@ -18567,8 +18567,8 @@ mod tests { ); let mut player_pose = transform_state(&engine.world, cockpit.handle).unwrap(); for (time, logic_id, objective_index, plate) in [ - (2001, 0x8000_0001, 0, [391.3_f32, 740.1, 145.12]), - (4001, 0x8000_0003, 2, [1268.1, 790.6, 160.77]), + (2001, 0x8000_0001, 0, [391.3_f32, 740.1, 140.74]), + (4001, 0x8000_0003, 2, [1268.1, 790.6, 153.55]), ] { let slot = engine .loaded @@ -18584,7 +18584,7 @@ mod tests { identity_metadata(&engine.world, handle).unwrap().owner_id, Some(OwnerId(2)) ); - for z in [plate[2] + 12.0, plate[2] - 6.0] { + for z in [plate[2] + 5.0, plate[2] - 6.0] { player_pose.position = [plate[0], plate[1], z].map(f32::to_bits); set_transform(&mut engine.world, cockpit.handle, player_pose).unwrap(); assert_eq!( @@ -18633,7 +18633,7 @@ mod tests { loaded_mission_script_outcome(&engine), Some(MissionScriptOutcome::Active) ); - player_pose.position = [391.3_f32, 740.1, 145.12].map(f32::to_bits); + player_pose.position = [391.3_f32, 740.1, 140.74].map(f32::to_bits); set_transform(&mut engine.world, cockpit.handle, player_pose).unwrap(); assert_eq!( order_factory_robot(&mut engine, cockpit, 4001).unwrap(), @@ -18642,7 +18642,19 @@ mod tests { assert!(order_factory_robot(&mut engine, cockpit, 4002).is_err()); let early = frame(&mut engine, 64_000).unwrap(); assert!(early.produced_unit.is_none()); - let complete = frame(&mut engine, 64_001).unwrap(); + let wait_for_release = |engine: &mut Engine, now: &mut u32| { + let deadline = *now + 20_000; + while *now < deadline { + *now += 17; + let result = frame(engine, *now).unwrap(); + if result.produced_unit.is_some() { + return result; + } + } + panic!("factory did not release its order by {deadline} ms"); + }; + let mut now = 64_000; + let complete = wait_for_release(&mut engine, &mut now); let robot = complete.produced_unit.expect("finished robot"); assert!(complete.snapshot.objects.contains(&robot.handle)); assert_eq!( @@ -18651,7 +18663,8 @@ mod tests { .owner_id, Some(OwnerId(0)) ); - let next = frame(&mut engine, 66_001).unwrap(); + now += 2_000; + let next = frame(&mut engine, now).unwrap(); assert!(next.produced_unit.is_none()); let event = next.mission_event.unwrap(); assert!(event.stop.is_none(), "{:?}", event.stop); @@ -18660,6 +18673,18 @@ mod tests { loaded_mission_script_outcome(&engine), Some(MissionScriptOutcome::Completed) ); + let factory = mission_object_handle(&engine, OriginalObjectId(0)).unwrap(); + let departure_deadline = now + 20_000; + while engine + .loaded + .as_ref() + .and_then(|mission| mission.unit_patrol.as_ref()) + .is_some_and(|patrol| patrol.has_factory_departure(factory)) + { + assert!(now < departure_deadline, "robot did not leave the factory"); + now += 17; + frame(&mut engine, now).unwrap(); + } assert_eq!( board_friendly_warbot(&mut engine, Some(robot.handle)).unwrap(), None @@ -18702,7 +18727,8 @@ mod tests { ) .unwrap() .unwrap(); - frame_with_player_motion(&mut engine, 66_101, vehicle, motion, false).unwrap(); + now += 100; + frame_with_player_motion(&mut engine, now, vehicle, motion, false).unwrap(); let driven = transform_state(&engine.world, vehicle.handle).unwrap(); assert_ne!(driven.position, robot_pose.position); assert_eq!( @@ -18719,14 +18745,14 @@ mod tests { .position, driven.position ); - player_pose.position = [391.3_f32, 740.1, 145.12].map(f32::to_bits); + player_pose.position = [391.3_f32, 740.1, 140.74].map(f32::to_bits); set_transform(&mut engine.world, cockpit.handle, player_pose).unwrap(); let mut live = vec![robot]; - let mut now = 68_001; for _ in 1..production::RESERVE_SLOTS { let duration = order_factory_robot(&mut engine, cockpit, now).unwrap(); - now += duration; - let result = frame(&mut engine, now).unwrap(); + now += duration - 1; + frame(&mut engine, now).unwrap(); + let result = wait_for_release(&mut engine, &mut now); let new = result.produced_unit.expect("another finished robot"); assert!(live.iter().all(|unit| unit.object_index != new.object_index && result.snapshot.objects.contains(&unit.handle))); @@ -18735,7 +18761,9 @@ mod tests { assert!(order_factory_robot(&mut engine, cockpit, now).is_err()); fparkan_world::request_delete(&mut engine.world, robot.handle).unwrap(); let duration = order_factory_robot(&mut engine, cockpit, now).unwrap(); - let replaced = frame(&mut engine, now + duration).unwrap(); + now += duration - 1; + frame(&mut engine, now).unwrap(); + let replaced = wait_for_release(&mut engine, &mut now); let replacement = replaced.produced_unit.expect("reused slot"); assert_eq!(replacement.object_index, robot.object_index); assert_ne!(replacement.handle, robot.handle); diff --git a/crates/fparkan-runtime/src/mission_events.rs b/crates/fparkan-runtime/src/mission_events.rs index a198bfdd..ec976224 100644 --- a/crates/fparkan-runtime/src/mission_events.rs +++ b/crates/fparkan-runtime/src/mission_events.rs @@ -624,7 +624,6 @@ pub(super) fn communicator_triangles( pose: super::TransformState, ) -> Option<Vec<[[f32; 3]; 3]>> { let is_generator = class == 0x8000_0002; - let floor_only = is_generator || class == MAIN_TELEPORT_CLASS; let material = if is_generator { &b"B_MTP_07G"[..] } else { @@ -679,15 +678,10 @@ pub(super) fn communicator_triangles( transform.try_transform_scaled_point(pose.transform_point(local), scale) }); let (a, b, c) = (a?, b?, c?); - if floor_only { - // These models use the platform material on both the floor and the surface above it. - let winding = - (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0]); - if winding <= 0.0 { - return None; - } - } - Some([a, b, c]) + // The floor and ceiling of the communicator share the same material. + let normal_z = + (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0]); + (normal_z > 0.0).then_some([a, b, c]) }) }) .collect(), |
