diff --git a/common/src/path.rs b/common/src/path.rs index 1797a1d5ec..ca32734b38 100644 --- a/common/src/path.rs +++ b/common/src/path.rs @@ -110,7 +110,7 @@ impl Chaser { { let pos_to_tgt = pos.distance(tgt); - if pos_to_tgt < min_dist { + if ((pos - tgt) * Vec3::new(1.0, 1.0, 0.3)).magnitude_squared() < min_dist.powf(2.0) { return None; } diff --git a/common/src/sys/agent.rs b/common/src/sys/agent.rs index e08dcb3b87..8302c1da9b 100644 --- a/common/src/sys/agent.rs +++ b/common/src/sys/agent.rs @@ -74,7 +74,7 @@ impl<'a> System<'a> for Sys { const AVG_FOLLOW_DIST: f32 = 6.0; const MAX_FOLLOW_DIST: f32 = 12.0; const MAX_CHASE_DIST: f32 = 24.0; - const SIGHT_DIST: f32 = 20.0; + const SIGHT_DIST: f32 = 30.0; const MIN_ATTACK_DIST: f32 = 3.25; const PATROL_DIST: f32 = 32.0; @@ -83,9 +83,9 @@ impl<'a> System<'a> for Sys { match &mut agent.activity { Activity::Idle(wander_pos, chaser) => { if let Some(patrol_origin) = agent.patrol_origin { - if thread_rng().gen::() < 0.002 { + if thread_rng().gen::() < 0.005 { *wander_pos = - if thread_rng().gen::() < 0.5 { + if thread_rng().gen::() < 0.7 { Some(patrol_origin.map(|e| { e + thread_rng().gen_range(-1.0, 1.0) * PATROL_DIST })) @@ -157,7 +157,7 @@ impl<'a> System<'a> for Sys { inputs.look_dir = tgt_pos.0 - pos.0; inputs.move_dir = Vec2::from(tgt_pos.0 - pos.0) .try_normalized() - .unwrap_or(Vec2::zero()) + .unwrap_or(Vec2::unit_y()) * 0.01; inputs.primary.set_state(true); } else if dist < MAX_CHASE_DIST { diff --git a/world/src/sim/mod.rs b/world/src/sim/mod.rs index 0eb8e9399e..ddc2fc41a4 100644 --- a/world/src/sim/mod.rs +++ b/world/src/sim/mod.rs @@ -1458,21 +1458,25 @@ impl WorldSim { let mut pos = Vec2::new(i as i32, j as i32); // Slide the waypoints down hills - loop { + for _ in 0..32 { let last_pos = pos; - let alt = this.get(pos + Vec2::new(1, 0))?.alt; - const MAX_HEIGHT_DIFF: f32 = 5.0; - if this.get(pos + Vec2::new(1, 0))?.alt + MAX_HEIGHT_DIFF < alt { - pos.x += 1; - } - if this.get(pos + Vec2::new(-1, 0))?.alt + MAX_HEIGHT_DIFF < alt { - pos.x -= 1; - } - if this.get(pos + Vec2::new(0, 1))?.alt + MAX_HEIGHT_DIFF < alt { - pos.y += 1; - } - if this.get(pos + Vec2::new(0, -1))?.alt + MAX_HEIGHT_DIFF < alt { - pos.y -= 1; + let chunk = this.get(pos)?; + + for dir in [ + Vec2::new(1, 0), + Vec2::new(-1, 0), + Vec2::new(0, 1), + Vec2::new(0, -1), + ] + .iter() + { + const MAX_HEIGHT_DIFF: f32 = 8.0; + let tgt_chunk = this.get(pos + *dir)?; + if tgt_chunk.alt + MAX_HEIGHT_DIFF < chunk.alt + && !tgt_chunk.is_underwater + { + pos += *dir; + } } if last_pos == pos {