]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
DODGING: fixed bug in dodging direction detection
authorFlorian Paul Schmidt <mista.tapas@gmx.net>
Mon, 29 Mar 2010 23:55:42 +0000 (01:55 +0200)
committerFlorian Paul Schmidt <mista.tapas@gmx.net>
Mon, 29 Mar 2010 23:55:42 +0000 (01:55 +0200)
qcsrc/server/mutators/mutator_dodging.qc

index c51ca01db2f1cb4696ed0f594a66705e9ef78783..c555bc73a83db1140128f58cd43b026859ac0a8e 100644 (file)
@@ -175,6 +175,12 @@ MUTATOR_HOOKFUNCTION(dodging_GetPressedKeys) {
        // print("dodging_PlayerPhysics\n");
 
        float length;
+       float move_direction_x;
+       float move_direction_y;
+
+       move_direction_x = 0;
+       move_direction_y = 0;
+
        float dodge_detected;
        if (g_dodging == 0)
                return 0;
@@ -199,44 +205,44 @@ MUTATOR_HOOKFUNCTION(dodging_GetPressedKeys) {
                self.last_JUMP_KEY_time = time;
 
        if (self.movement_x > 0) {
+               move_direction_x = 1.0;
                // is this a state change?
                if (!(self.pressedkeys & KEY_FORWARD)) {
                        if ((time - self.last_FORWARD_KEY_time) < self.cvar_cl_dodging_timeout) { 
                                dodge_detected = 1;
-                               self.dodging_direction_x = 1.0;
                        }
                        self.last_FORWARD_KEY_time = time;
                }
        }
 
        if (self.movement_x < 0) {
+               move_direction_x = -1.0;
                // is this a state change?
                if (!(self.pressedkeys & KEY_BACKWARD)) {
                        if ((time - self.last_BACKWARD_KEY_time) < self.cvar_cl_dodging_timeout)        { 
                                dodge_detected = 1;
-                               self.dodging_direction_x = -1.0;
                        }
                        self.last_BACKWARD_KEY_time = time;
                }
        }
 
        if (self.movement_y > 0) {
+               move_direction_y = 1.0;
                // is this a state change?
                if (!(self.pressedkeys & KEY_RIGHT)) {
                        if ((time - self.last_RIGHT_KEY_time) < self.cvar_cl_dodging_timeout)   { 
                                dodge_detected = 1;
-                               self.dodging_direction_y = 1.0;
                        }
                        self.last_RIGHT_KEY_time = time;
                }
        }
 
        if (self.movement_y < 0) {
+               move_direction_y = -1.0;
                // is this a state change?
                if (!(self.pressedkeys & KEY_LEFT)) {
                        if ((time - self.last_LEFT_KEY_time) < self.cvar_cl_dodging_timeout)    { 
                                dodge_detected = 1;
-                               self.dodging_direction_y = -1.0;
                        }
                        self.last_LEFT_KEY_time = time;
                }
@@ -255,6 +261,9 @@ MUTATOR_HOOKFUNCTION(dodging_GetPressedKeys) {
                self.dodging_action = 1;
                self.dodging_single_action = 1;
 
+               self.dodging_direction_x = move_direction_x;
+               self.dodging_direction_y = move_direction_y;
+
                // normalize the dodging_direction vector.. (unlike UT99) XD
                length = length + self.dodging_direction_x * self.dodging_direction_x;
                length = length + self.dodging_direction_y * self.dodging_direction_y;