From: Florian Paul Schmidt Date: Sat, 20 Mar 2010 17:48:59 +0000 (+0100) Subject: - added threshold to dodging code (to make dodging on stairs easier) X-Git-Tag: xonotic-v0.1.0preview~680^2~17 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=40da4667635c5bb65eb75c7a14c4279b4fc316fa;p=xonotic%2Fxonotic-data.pk3dir.git - added threshold to dodging code (to make dodging on stairs easier) --- diff --git a/defaultXonotic.cfg b/defaultXonotic.cfg index ef7f5eb28..c3c6db764 100644 --- a/defaultXonotic.cfg +++ b/defaultXonotic.cfg @@ -518,8 +518,9 @@ seta cl_dodging_timeout 0 "determines how long apart (in seconds) two taps on th set sv_dodging_delay 0.5 "determines how long a player has to wait to be able to dodge again after dodging" set sv_dodging_up_speed 200 "the jump velocity of the dodge" -set sv_dodging_horiz_speed 500 "the horizontal velocity of the dodge" +set sv_dodging_horiz_speed 350 "the horizontal velocity of the dodge" set sv_dodging_ramp_time 0.1 "a ramp so that the horizontal part of the dodge is added smoothly (seconds)" +set sv_dodging_height_threshold 40 "the maximum height above ground where to allow dodging" set leadlimit 0 diff --git a/qcsrc/server/mutators/mutator_dodging.qc b/qcsrc/server/mutators/mutator_dodging.qc index 3c5e884e8..19ed28df9 100644 --- a/qcsrc/server/mutators/mutator_dodging.qc +++ b/qcsrc/server/mutators/mutator_dodging.qc @@ -71,6 +71,9 @@ MUTATOR_HOOKFUNCTION(dodging_PlayerPhysics) { // ramp up dodging speed by adding some velocity each frame.. TODO: do it! :D if (self.dodging_action == 1) { + //disable jump key during dodge accel phase + if (self.movement_z > 0) self.movement_z = 0; + self.velocity = self.velocity + (common_factor * (self.dodging_direction_y * cvar("sv_dodging_horiz_speed")) * v_right) @@ -103,23 +106,36 @@ MUTATOR_HOOKFUNCTION(dodging_GetPressedKeys) { float length; float dodge_detected; + vector trace_start; + vector trace_end; + float height_above_ground; if (g_dodging == 0) return 0; dodge_detected = 0; + // no dodging and jumping at the same time.. + if (self.BUTTON_JUMP) + return 0; + // first check if the last dodge is far enough back in time so we can dodge again if ((time - self.last_dodging_time) < cvar("sv_dodging_delay")) return 0; - // check if our feet are on the ground :D - if (!(self.lastflags & FL_ONGROUND)) - return 0; + // determine height above ground is below a threshold + trace_start = self.origin; + trace_end = self.origin - (100*v_up); + traceline(trace_start, trace_end, TRUE, self); + height_above_ground = self.origin_z - trace_endpos_z; - // TODO: fix! - // self.cvar_cl_dodging_timeout = 0.2; + if (height_above_ground > (fabs(PL_MIN_z) + cvar("sv_dodging_height_threshold"))) + return 0; + + // check if our feet are on the ground or at least close :D + //if (!(self.lastflags & FL_ONGROUND)) + // return 0; if (self.movement_x > 0) { // is this a state change? @@ -127,7 +143,6 @@ MUTATOR_HOOKFUNCTION(dodging_GetPressedKeys) { if ((time - self.last_FORWARD_KEY_time) < self.cvar_cl_dodging_timeout) { dodge_detected = 1; self.dodging_direction_x = 1.0; - self.last_dodging_time = time; } self.last_FORWARD_KEY_time = time; } @@ -139,7 +154,6 @@ MUTATOR_HOOKFUNCTION(dodging_GetPressedKeys) { if ((time - self.last_BACKWARD_KEY_time) < self.cvar_cl_dodging_timeout) { dodge_detected = 1; self.dodging_direction_x = -1.0; - self.last_dodging_time = time; } self.last_BACKWARD_KEY_time = time; } @@ -151,7 +165,6 @@ MUTATOR_HOOKFUNCTION(dodging_GetPressedKeys) { if ((time - self.last_RIGHT_KEY_time) < self.cvar_cl_dodging_timeout) { dodge_detected = 1; self.dodging_direction_y = 1.0; - self.last_dodging_time = time; } self.last_RIGHT_KEY_time = time; } @@ -163,7 +176,6 @@ MUTATOR_HOOKFUNCTION(dodging_GetPressedKeys) { if ((time - self.last_LEFT_KEY_time) < self.cvar_cl_dodging_timeout) { dodge_detected = 1; self.dodging_direction_y = -1.0; - self.last_dodging_time = time; } self.last_LEFT_KEY_time = time; } @@ -172,6 +184,11 @@ MUTATOR_HOOKFUNCTION(dodging_GetPressedKeys) { if (dodge_detected == 1) { + if (self.movement_z > 0) + self.movement_z = 0; + + self.last_dodging_time = time; + self.dodging_action = 1; self.dodging_single_action = 1;