Merge branch 'james/no-cliff-diving-allowed' into 'master'

Prohibit accidental cliff diving by NPCs

See merge request veloren/veloren!3139
This commit is contained in:
Samuel Keiffer 2022-01-25 16:25:40 +00:00
commit 4803891a29
2 changed files with 20 additions and 1 deletions

View File

@ -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

View File

@ -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 {