Merge branch 'zesterer/damage-fixes' into 'master'

Fixed weird fall damage application

See merge request veloren/veloren!3962
This commit is contained in:
Joshua Barretto 2023-06-01 13:42:29 +00:00
commit bcc6b84e48
3 changed files with 21 additions and 6 deletions

View File

@ -68,6 +68,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Default audio volume should be less likely to destroy ear drums
- Creatures flee less quickly when low on health
- All `/build_area_*` commands have been renamed to `/area_*`, and you will have to pass an additional area type
- Collision damage can now be applied in horizontal axes, in addition to the vertical axis
### Removed

View File

@ -1605,10 +1605,6 @@ fn box_voxel_collision<T: BaseVol<Vox = Block> + ReadVol>(
on_ceiling = true;
}
if resolve_dir.magnitude_squared() > 0.0 {
land_on_ground(entity, *vel, resolve_dir.normalized());
}
// When the resolution direction is non-vertical, we must be colliding
// with a wall
//
@ -1642,7 +1638,11 @@ fn box_voxel_collision<T: BaseVol<Vox = Block> + ReadVol>(
} {
// ...block-hop!
pos.0.z = pos.0.z.max(block_aabb.max.z);
// Apply fall damage, in the vertical axis, and correct velocity
land_on_ground(entity, *vel, Vec3::unit_z());
vel.0.z = vel.0.z.max(0.0);
// Push the character on to the block very slightly
// to avoid jitter due to imprecision
if (vel.0 * resolve_dir).xy().magnitude_squared() < 1.0_f32.powi(2) {
@ -1652,7 +1652,10 @@ fn box_voxel_collision<T: BaseVol<Vox = Block> + ReadVol>(
break;
}
// If not, correct the velocity
// If not, correct the velocity, applying collision damage as we do
if resolve_dir.magnitude_squared() > 0.0 {
land_on_ground(entity, *vel, resolve_dir.normalized());
}
vel.0 = vel.0.map2(
resolve_dir,
|e, d| {

View File

@ -603,7 +603,18 @@ pub fn handle_land_on_ground(
) {
let ecs = server.state.ecs();
let relative_vel = vel.dot(-surface_normal);
// HACK: Certain ability movements currently take us above the fall damage
// threshold in the horizontal axis. This factor dampens velocity in the
// horizontal axis when applying fall damage.
let horizontal_damp = 0.5
+ vel
.try_normalized()
.unwrap_or_default()
.dot(Vec3::unit_z())
.abs()
* 0.5;
let relative_vel = vel.dot(-surface_normal) * horizontal_damp;
// The second part of this if statement disables all fall damage when in the
// water. This was added as a *temporary* fix a bug that causes you to take