diff options
| author | Valentin Popov <valentin@popov.link> | 2026-11-26 11:16:16 +0300 |
|---|---|---|
| committer | Valentin Popov <valentin@popov.link> | 2026-11-26 11:16:16 +0300 |
| commit | dfbdef7d4d1d295ee962dd8aab754ce6be902f8d (patch) | |
| tree | 9c9f2b6fd6f9519ee05868df3f0d950e00318c24 /crates/fparkan-runtime/src/clan_targeting.rs | |
| parent | a519d5efefb4d846a9f65c6b9376fa245215a0f6 (diff) | |
| download | fparkan-dfbdef7d4d1d295ee962dd8aab754ce6be902f8d.tar.xz fparkan-dfbdef7d4d1d295ee962dd8aab754ce6be902f8d.zip | |
fix(ai): follow capture passages through building doors
A stock Two Fortresses run now takes the generator after the capturer descends its authored hallway. Symmetric Res17 door links drive the CTLD animation and unsupported routes retain explicit coverage. Checked the approach and descent in the game window with Vulkan validation and verified the owner transfer in a licensed test.
Diffstat (limited to 'crates/fparkan-runtime/src/clan_targeting.rs')
| -rw-r--r-- | crates/fparkan-runtime/src/clan_targeting.rs | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/crates/fparkan-runtime/src/clan_targeting.rs b/crates/fparkan-runtime/src/clan_targeting.rs index 14ecb4b7..b98afec0 100644 --- a/crates/fparkan-runtime/src/clan_targeting.rs +++ b/crates/fparkan-runtime/src/clan_targeting.rs @@ -1,7 +1,8 @@ use crate::{ - building_passage::capture_entrance, clan_combat_strength::unit_strength, - projectile::unit_sphere, MissionControlDeviceTableState, MissionDocument, MissionObjectDraft, - TerrainWorld, + building_passage::{capture_entrance, CapturePassage}, + clan_combat_strength::unit_strength, + projectile::unit_sphere, + MissionControlDeviceTableState, MissionDocument, MissionObjectDraft, TerrainWorld, }; use fparkan_world::{ handle_by_original_id, identity_metadata, registration_sequence, transform_state, ObjectHandle, @@ -20,6 +21,7 @@ pub(super) struct Capturer { pub(super) struct CaptureApproach { pub(super) unit: ObjectHandle, pub(super) target: ObjectHandle, + pub(super) fallback: bool, point: [f32; 3], } @@ -47,28 +49,35 @@ pub(super) fn send_capturer( let from = unit_pose.position.map(f32::from_bits); let unit_id = identity_metadata(world, unit.handle).ok()?.original_id?; let clearance = unit_sphere(assets, unit_id.0 as usize, unit_pose).map_or(0.0, |(_, r)| r); - let (destination, point) = + let (destination, point, passage) = if let Some(entrance) = capture_entrance(assets, terrain, index, pose, from, clearance) { - // shortcut: stop outside the connected door until movement on the - // indoor links and their gate messages are supported. - (entrance.staging, entrance.capture) + let passage = entrance.legs.map(|legs| CapturePassage { + building: unit.target, + legs, + opening: None, + }); + (entrance.staging, entrance.capture, passage) } else { let point = nearest_platform_point( crate::mission_events::communicator_triangles(assets, index, class, pose)?, from, )?; - ([point[0], point[1]], point) + ([point[0], point[1]], point, None) }; + let indoor_route = passage.is_some(); patrol .get_or_insert_with(crate::unit_patrol::UnitPatrol::scripted) - .move_to(world, unit.handle, destination, false); - eprintln!( - "sim_coverage script_capture_approach_stub=1 unit={} target={} target_id={target_id} destination={destination:?}", - unit.handle.slot, unit.target.slot - ); + .move_to_capture(world, unit.handle, destination, passage); + if !indoor_route { + eprintln!( + "sim_coverage script_capture_approach_stub=1 unit={} target={} target_id={target_id} destination={destination:?}", + unit.handle.slot, unit.target.slot + ); + } Some(CaptureApproach { unit: unit.handle, target: unit.target, + fallback: !indoor_route, point, }) } |
