]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
fix walldodging on sloped walls, separate max speed and max air speed
authorMartin Taibr <taibr.martin@gmail.com>
Thu, 17 Aug 2017 15:58:46 +0000 (17:58 +0200)
committerMartin Taibr <taibr.martin@gmail.com>
Thu, 17 Aug 2017 15:58:46 +0000 (17:58 +0200)
mutators.cfg
qcsrc/common/mutators/mutator/dodging/sv_dodging.qc
qcsrc/common/stats.qh

index 012a2adf1bab940b80e47f2add6810002506c481..ed75a548591a47bf885c4bfc8387ec6c0e346c53 100644 (file)
@@ -25,7 +25,8 @@ set sv_dodging_wall_distance_threshold 10 "the maximum distance from a wall that
 set sv_dodging_sound 1 "if 1 dodging makes a sound. if 0 dodging is silent"
 set sv_dodging_frozen 0 "allow dodging while frozen"
 set sv_dodging_frozen_doubletap 0
-set sv_dodging_maxspeed 450 "maximum speed a player can be moving at before they dodge again"
+set sv_dodging_maxspeed 350 "maximum speed a player can be moving at to use the standard dodging from a 'standstill'
+set sv_dodging_air_maxspeed 450 "maximum speed a player can be moving at before they dodge again when air dodging is enabled"
 
 
 // ===========
index b3a938bcb4bf0bdfabae87ae2e76bf60fb17e2d1..2fb8603e46bd04bdea8d34d03a4c244b61590d75 100644 (file)
@@ -16,7 +16,8 @@
 #define PHYS_DODGING_UP_SPEED                          autocvar_sv_dodging_up_speed
 #define PHYS_DODGING_WALL                                      autocvar_sv_dodging_wall_dodging
 #define PHYS_DODGING_AIR                                       autocvar_sv_dodging_air_dodging
-#define PHYS_DODGING_MAXSPEED                          autocvar_sv_dodging_maxspeed // TODO separate max air speed, fix frozen dodging
+#define PHYS_DODGING_MAXSPEED                          autocvar_sv_dodging_maxspeed
+#define PHYS_DODGING_AIR_MAXSPEED                      autocvar_sv_dodging_air_maxspeed
 
 // we ran out of stats slots! TODO: re-enable this when prediction is available for dodging
 #if 0
@@ -35,6 +36,7 @@
 #define PHYS_DODGING_WALL                                      STAT(DODGING_WALL, this)
 #define PHYS_DODGING_AIR                                       STAT(DODGING_AIR, this)
 #define PHYS_DODGING_MAXSPEED                          STAT(DODGING_MAXSPEED, this)
+#define PHYS_DODGING_AIR_MAXSPEED                      STAT(DODGING_AIR_MAXSPEED, this)
 #endif
 
 #ifdef CSQC
@@ -173,20 +175,14 @@ bool PM_dodging_checkpressedkeys(entity this)
 
        if (!dodge_detected) return false;
 
-       makevectors(this.angles);
-
-       bool wall_dodge = false;
+       //LOG_INFOF("dodge keys detected %f, speed %f\n", time, vlen(this.velocity));
 
-       if(!PHYS_DODGING_AIR)
-       if(!is_close_to_ground(this, PHYS_DODGING_HEIGHT_THRESHOLD)) // TODO first check wall wallldodging - this fails for sloped walls
-       {
-               wall_dodge = (PHYS_DODGING_WALL && is_close_to_wall(this, PHYS_DODGING_DISTANCE_THRESHOLD));
-               if(!wall_dodge) // we're not on the ground, and wall dodging isn't allowed, end it!
-                       return false;
-       }
+       makevectors(this.angles);
 
-       if(!wall_dodge && PHYS_DODGING_MAXSPEED && vdist(this.velocity, >, PHYS_DODGING_MAXSPEED))
-               return false;
+       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_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;
 
        this.last_dodging_time = time;
 
index ee13d9d47fb1d7b9603253a5ef5287e79e742b43..41a0e7eb974169d9919e694da085f1c17102051e 100644 (file)
@@ -226,7 +226,8 @@ float autocvar_sv_dodging_ramp_time;
 float autocvar_sv_dodging_up_speed;
 bool autocvar_sv_dodging_wall_dodging;
 bool autocvar_sv_dodging_air_dodging;
-float autocvar_sv_dodging_maxspeed = 450;
+float autocvar_sv_dodging_maxspeed;
+float autocvar_sv_dodging_air_maxspeed;
 #endif
 
 #if 0
@@ -245,6 +246,7 @@ REGISTER_STAT(DODGING_UP_SPEED, float, autocvar_sv_dodging_up_speed)
 REGISTER_STAT(DODGING_WALL, bool, autocvar_sv_dodging_wall_dodging)
 REGISTER_STAT(DODGING_AIR, bool, autocvar_sv_dodging_air_dodging)
 REGISTER_STAT(DODGING_MAXSPEED, float, autocvar_sv_dodging_maxspeed)
+REGISTER_STAT(DODGING_AIR_MAXSPEED, float, autocvar_sv_dodging_air_maxspeed)
 #endif
 /** cvar loopback */
 REGISTER_STAT(DODGING_FROZEN, int, autocvar_sv_dodging_frozen)