From 1af9ac568f0abd43028158bd2f98144c88a5e885 Mon Sep 17 00:00:00 2001 From: Avi Weinstock Date: Sun, 13 Jun 2021 20:38:03 -0400 Subject: [PATCH] Move force-movement e2e check so that it doesn't confer immunity to arrows. --- common/systems/src/phys.rs | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/common/systems/src/phys.rs b/common/systems/src/phys.rs index 1f4521496c..613431035c 100644 --- a/common/systems/src/phys.rs +++ b/common/systems/src/phys.rs @@ -333,21 +333,6 @@ impl<'a> PhysicsData<'a> { }; } - // Don't apply e2e pushback to entities that are in a forced movement state - // (e.g. roll, leapmelee). This allows leaps to work properly (since you won't - // get pushed away before delivering the hit), and allows rolling through an - // enemy when trapped (e.g. with minotaur). This allows using e2e pushback to - // gain speed by jumping out of a roll while in the middle of a collider, this - // is an intentional combat mechanic. - if let Some(cs) = char_state_maybe { - if cs.is_forced_movement() { - return PhysicsMetrics { - entity_entity_collision_checks, - entity_entity_collisions, - }; - } - } - let z_limits = calc_z_limit(char_state_maybe, collider); // Resets touch_entities in physics @@ -440,16 +425,21 @@ impl<'a> PhysicsData<'a> { entity_entity_collisions += 1; } - // Don't apply repulsive force to projectiles or if - // we're - // colliding - // with a terrain-like entity, or if we are a - // terrain-like - // entity + // Don't apply e2e pushback to entities that are in a forced movement state + // (e.g. roll, leapmelee). This allows leaps to work properly (since you won't + // get pushed away before delivering the hit), and allows rolling through an + // enemy when trapped (e.g. with minotaur). This allows using e2e pushback to + // gain speed by jumping out of a roll while in the middle of a collider, this + // is an intentional combat mechanic. + let forced_movement = matches!(char_state_maybe, Some(cs) if cs.is_forced_movement()); + + // Don't apply repulsive force to projectiles or if we're colliding with a + // terrain-like entity, or if we are a terrain-like entity // // Don't apply force when entity is a sticky which is on the // ground (or on the wall) - if !(is_sticky && !is_mid_air) + if !forced_movement && + !(is_sticky && !is_mid_air) && diff.magnitude_squared() > 0.0 && !is_projectile && !matches!(