diff --git a/CHANGELOG.md b/CHANGELOG.md index 6fab2efd77..c40cc1d9f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -90,6 +90,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Agents can flee once again, and more appropriately - Items in hotbar no longer change when sorting inventory - Lantern color changes when swapping lanterns +- NPCs no longer wander off cliffs ## [0.11.0] - 2021-09-11 diff --git a/server/src/sys/agent.rs b/server/src/sys/agent.rs index 2bfba94eda..8e4235bc34 100644 --- a/server/src/sys/agent.rs +++ b/server/src/sys/agent.rs @@ -857,7 +857,8 @@ impl<'a> AgentData<'a> { }); // Stop if we're too close to a wall - // NOTE: costs 1 us (imbris) + // or about to walk off a cliff + // NOTE: costs 1 us (imbris) <- before cliff raycast added agent.bearing *= 0.1 + if read_data .terrain @@ -874,6 +875,23 @@ impl<'a> AgentData<'a> { .cast() .1 .map_or(true, |b| b.is_none()) + && read_data + .terrain + .ray( + self.pos.0 + + Vec3::from(agent.bearing) + .try_normalized() + .unwrap_or_else(Vec3::unit_y), + self.pos.0 + + Vec3::from(agent.bearing) + .try_normalized() + .unwrap_or_else(Vec3::unit_y) + - Vec3::unit_z() * 4.0, + ) + .until(Block::is_solid) + .cast() + .0 + < 3.0 { 0.9 } else {