From e685cdc62ec2aaf6c08d7ec7d0ce6a87d5b4d78c Mon Sep 17 00:00:00 2001 From: Martin Taibr Date: Thu, 15 Nov 2018 23:39:19 +0100 Subject: [PATCH] deglob dodging --- .../mutators/mutator/dodging/sv_dodging.qc | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/qcsrc/common/mutators/mutator/dodging/sv_dodging.qc b/qcsrc/common/mutators/mutator/dodging/sv_dodging.qc index 6640cb8bf..0378ed7ed 100644 --- a/qcsrc/common/mutators/mutator/dodging/sv_dodging.qc +++ b/qcsrc/common/mutators/mutator/dodging/sv_dodging.qc @@ -113,20 +113,20 @@ REGISTER_MUTATOR(dodging, true); return true; // returns true if the player is close to a wall -bool is_close_to_wall(entity this, float threshold) +bool is_close_to_wall(entity this, float threshold, vector forward, vector right) { - X(v_right); - X(-v_right); - X(v_forward); - X(-v_forward); + X(right); + X(-right); + X(forward); + X(-forward); return false; } -bool is_close_to_ground(entity this, float threshold) +bool is_close_to_ground(entity this, float threshold, vector up) { if (IS_ONGROUND(this)) return true; - X(-v_up); // necessary for dodging down a slope using doubletap (using `+dodge` works anyway) + X(-up); // necessary for dodging down a slope using doubletap (using `+dodge` works anyway) return false; } @@ -180,10 +180,10 @@ bool PM_dodging_checkpressedkeys(entity this) if ((time - this.last_dodging_time) < PHYS_DODGING_DELAY) return false; - makevectors(this.angles); + MAKE_VECTORS_NEW(this.angles, forward, right, up); - bool can_dodge = (is_close_to_ground(this, PHYS_DODGING_HEIGHT_THRESHOLD) && (PHYS_DODGING_MAXSPEED == 0 || vdist(this.velocity, <, PHYS_DODGING_MAXSPEED))); - bool can_wall_dodge = (PHYS_DODGING_WALL && is_close_to_wall(this, PHYS_DODGING_DISTANCE_THRESHOLD)); + bool can_dodge = (is_close_to_ground(this, PHYS_DODGING_HEIGHT_THRESHOLD, up) && (PHYS_DODGING_MAXSPEED == 0 || vdist(this.velocity, <, PHYS_DODGING_MAXSPEED))); + bool can_wall_dodge = (PHYS_DODGING_WALL && is_close_to_wall(this, PHYS_DODGING_DISTANCE_THRESHOLD, forward, right)); bool can_air_dodge = (PHYS_DODGING_AIR && (PHYS_DODGING_AIR_MAXSPEED == 0 || vdist(this.velocity, <, PHYS_DODGING_AIR_MAXSPEED))); if (!can_dodge && !can_wall_dodge && !can_air_dodge) return false; @@ -221,11 +221,11 @@ void PM_dodging(entity this) return; } - // make sure v_up, v_right and v_forward are sane + NEW_VECS(forward, right, up); if(PHYS_DODGING_AIR) - makevectors(this.v_angle); + MAKE_VECTORS(this.v_angle, forward, right, up); else - makevectors(this.angles); + MAKE_VECTORS(this.angles, forward, right, up); // fraction of the force to apply each frame // if we have e.g. 0.5 sec ramptime and a frametime of 0.25, then the ramp code @@ -237,15 +237,15 @@ void PM_dodging(entity this) float velocity_increase = min(common_factor * this.dodging_force_total, this.dodging_force_remaining); this.dodging_force_remaining -= velocity_increase; - this.velocity += this.dodging_direction.x * velocity_increase * v_forward - + this.dodging_direction.y * velocity_increase * v_right; + this.velocity += this.dodging_direction.x * velocity_increase * forward + + this.dodging_direction.y * velocity_increase * right; // the up part of the dodge is a single shot action if (this.dodging_single_action == 1) { UNSET_ONGROUND(this); - this.velocity += PHYS_DODGING_UP_SPEED * v_up; + this.velocity += PHYS_DODGING_UP_SPEED * up; #ifdef SVQC if (autocvar_sv_dodging_sound) -- 2.39.2