X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;ds=sidebyside;f=qcsrc%2Fcommon%2Fmutators%2Fmutator%2Fdodging%2Fsv_dodging.qc;h=9dda6aeb31149ddb5f80b2f7030490f31822619c;hb=6d100a71dd5633df98e3f11dbddfcb6b9546c9d6;hp=d20814ce7c045f04390645e8b156842b5236338e;hpb=cd4892b9fcd32bd4887f0b3bc2503894520945c7;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/mutators/mutator/dodging/sv_dodging.qc b/qcsrc/common/mutators/mutator/dodging/sv_dodging.qc index d20814ce7..9dda6aeb3 100644 --- a/qcsrc/common/mutators/mutator/dodging/sv_dodging.qc +++ b/qcsrc/common/mutators/mutator/dodging/sv_dodging.qc @@ -1,5 +1,21 @@ #include "sv_dodging.qh" +#define PHYS_DODGING g_dodging +#define PHYS_DODGING_DELAY autocvar_sv_dodging_delay +#define PHYS_DODGING_DISTANCE_THRESHOLD autocvar_sv_dodging_wall_distance_threshold +#define PHYS_DODGING_FROZEN_NODOUBLETAP autocvar_sv_dodging_frozen_doubletap +#define PHYS_DODGING_HEIGHT_THRESHOLD autocvar_sv_dodging_height_threshold +#define PHYS_DODGING_HORIZ_SPEED autocvar_sv_dodging_horiz_speed +#define PHYS_DODGING_HORIZ_SPEED_FROZEN autocvar_sv_dodging_horiz_speed_frozen +#define PHYS_DODGING_RAMP_TIME autocvar_sv_dodging_ramp_time +#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 +#define PHYS_DODGING_PRESSED_KEYS(s) (s).pressedkeys + +// we ran out of stats slots! TODO: re-enable this when prediction is available for dodging +#if 0 #define PHYS_DODGING STAT(DODGING, this) #define PHYS_DODGING_DELAY STAT(DODGING_DELAY, this) #define PHYS_DODGING_DISTANCE_THRESHOLD STAT(DODGING_DISTANCE_THRESHOLD, this) @@ -11,7 +27,8 @@ #define PHYS_DODGING_UP_SPEED STAT(DODGING_UP_SPEED, this) #define PHYS_DODGING_WALL STAT(DODGING_WALL, this) #define PHYS_DODGING_AIR STAT(DODGING_AIR, this) -#define PHYS_DODGING_PRESSED_KEYS(s) (s).pressedkeys +#define PHYS_DODGING_MAXSPEED STAT(DODGING_MAXSPEED, this) +#endif #ifdef CSQC #define PHYS_DODGING_FRAMETIME (1 / (frametime <= 0 ? 60 : frametime)) @@ -109,13 +126,13 @@ bool check_close_to_ground(entity this, float threshold) return IS_ONGROUND(this) ? true : false; } -float PM_dodging_checkpressedkeys(entity this) +bool PM_dodging_checkpressedkeys(entity this) { if(!PHYS_DODGING) return false; - float frozen_dodging = (PHYS_FROZEN(this) && PHYS_DODGING_FROZEN(this)); - float frozen_no_doubletap = (frozen_dodging && !PHYS_DODGING_FROZEN_NODOUBLETAP); + bool frozen_dodging = (PHYS_FROZEN(this) && PHYS_DODGING_FROZEN(this)); + bool frozen_no_doubletap = (frozen_dodging && !PHYS_DODGING_FROZEN_NODOUBLETAP); // first check if the last dodge is far enough back in time so we can dodge again if ((time - this.last_dodging_time) < PHYS_DODGING_DELAY) @@ -123,10 +140,18 @@ float PM_dodging_checkpressedkeys(entity this) makevectors(this.angles); + bool wall_dodge = false; + if(!PHYS_DODGING_AIR) - if (check_close_to_ground(this, PHYS_DODGING_HEIGHT_THRESHOLD) != 1 - && check_close_to_wall(this, PHYS_DODGING_DISTANCE_THRESHOLD) != 1) - return true; + if(!check_close_to_ground(this, PHYS_DODGING_HEIGHT_THRESHOLD)) + { + wall_dodge = check_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 true; + } + + if(!wall_dodge && PHYS_DODGING_MAXSPEED && vdist(this.velocity, >, PHYS_DODGING_MAXSPEED)) + return false; float tap_direction_x = 0; float tap_direction_y = 0; @@ -138,7 +163,9 @@ float PM_dodging_checkpressedkeys(entity this) if(!(PHYS_DODGING_PRESSED_KEYS(this) & KEY_##BTN) || frozen_no_doubletap) { \ tap_direction_##RESULT; \ if ((time - this.last_##BTN##_KEY_time) < PHYS_DODGING_TIMEOUT(this) || frozen_no_doubletap) \ - dodge_detected = true; \ + dodge_detected = true; \ + if(PHYS_INPUT_BUTTON_DODGE(this)) \ + dodge_detected = true; \ this.last_##BTN##_KEY_time = time; \ } X(x < 0, BACKWARD, x--);