From e41c602359730f1a7b34f333df6d0f12b369a04f Mon Sep 17 00:00:00 2001 From: Kacpherek Date: Mon, 26 Oct 2026 21:46:00 +0100 Subject: [PATCH] Keep picking up a banner next to a raider even when its path was cached as unreachable --- crates/horizon-client/src/game/raids.rs | 36 +++++++++++++++---------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/crates/horizon-client/src/game/raids.rs b/crates/horizon-client/src/game/raids.rs index e34d9feed..dd3f3f29e 100644 --- a/crates/horizon-client/src/game/raids.rs +++ b/crates/horizon-client/src/game/raids.rs @@ -856,23 +856,31 @@ impl Game<'_> { && raids.get(id).is_some_and(|r| r.leader(s.wave).is_none()) && !leaders.contains(&(id, s.wave)) { + let in_reach = |(i, _, p): &&(usize, u32, Vec3)| { + !taken.contains(i) + && (p.x - position.x).abs() <= range + && (p.z - position.z).abs() <= range + && (p.y - position.y).abs() <= 8.0 + }; + let by_distance = |a: &&(usize, u32, Vec3), b: &&(usize, u32, Vec3)| { + a.2.distance_squared(position) + .total_cmp(&b.2.distance_squared(position)) + }; + // The unreachable cache only picks the navigation target; + // a banner next to the raider is still picked up. let near = banners .iter() - .filter(|(i, item, p)| { - !taken.contains(i) - && !s - .unreachable_banners - .iter() - .any(|&(b, until)| b == *item && now < until) - && (p.x - position.x).abs() <= range - && (p.z - position.z).abs() <= range - && (p.y - position.y).abs() <= 8.0 + .filter(in_reach) + .filter(|(_, item, _)| { + !s.unreachable_banners + .iter() + .any(|&(b, until)| b == *item && now < until) }) - .min_by(|a, b| { - a.2.distance_squared(position) - .total_cmp(&b.2.distance_squared(position)) - }); - if let Some((i, item, p)) = near { + .min_by(by_distance); + let nearest = banners.iter().filter(in_reach).min_by(by_distance); + let adjacent = + nearest.filter(|(_, _, p)| p.distance_squared(position) < 1.414 * 1.414); + if let Some((i, item, p)) = adjacent.or(near) { s.banner_at = Some([p.x, p.y, p.z]); s.banner_item = *item; if p.distance_squared(position) < 1.414 * 1.414 {