]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
- almost working
authorFlorian Paul Schmidt <mista.tapas@gmx.net>
Fri, 19 Mar 2010 22:56:39 +0000 (23:56 +0100)
committerFlorian Paul Schmidt <mista.tapas@gmx.net>
Fri, 19 Mar 2010 22:56:39 +0000 (23:56 +0100)
defaultXonotic.cfg
qcsrc/server/mutators/mutator_dodging.qc

index 8a68ebcdad3b173791fa119fa5d6f4f0612576a4..236dc0dc149af390ca3b232906d58a0f91104b24 100644 (file)
@@ -518,6 +518,7 @@ seta cl_dodging_timeout 0
 set sv_dodging_delay 0.5
 set sv_dodging_up_speed 200
 set sv_dodging_horiz_speed 500
+set sv_dodging_ramp_time 0.2
 
 set leadlimit 0
 
index 282ef4be24640dfe5475b616874d4a9f9fc93f58..46ca34fd89ce8e6987d8d2ec794771daf92d13e4 100644 (file)
@@ -1,22 +1,30 @@
+
+// these are used to store the last key press time for each of the keys..
 .float last_FORWARD_KEY_time;
 .float last_BACKWARD_KEY_time;
 .float last_LEFT_KEY_time;
 .float last_RIGHT_KEY_time;
 
+// these store the movement direction at the time of the dodge action happening.
+.float dodging_direction_x;
+.float dodging_direction_y;
+
 // this indicates the last time a dodge was executed. used to check if another one is allowed
 // and to ramp up the dodge acceleration in the physics hook.
-.float last_dodge_time;
+.float last_dodging_time;
 
 // set to 1 to indicate dodging has started.. reset by physics hook after dodge has been done..
-.float dodge_action;
+.float dodging_action;
 
 void dodging_Initialize() {
        self.last_FORWARD_KEY_time = 0;
        self.last_BACKWARD_KEY_time = 0;
        self.last_RIGHT_KEY_time = 0;
        self.last_LEFT_KEY_time = 0;
-       self.last_dodge_time = 0;
-       self.dodge_action = 0;
+       self.last_dodging_time = 0;
+       self.dodging_action = 0;
+       self.dodging_direction_x = 0;
+       self.dodging_direction_y = 0;
 }
 
 MUTATOR_HOOKFUNCTION(dodging_PlayerPhysics) {
@@ -24,7 +32,15 @@ MUTATOR_HOOKFUNCTION(dodging_PlayerPhysics) {
        if (g_dodging == 0)
                return 0;
 
-       
+       // ramp up dodging speed by adding some velocity each frame..
+       if (self.dodging_action == 1) {
+               self.velocity = self.velocity + self.dodging_direction_y * (cvar("sv_dodging_horiz_speed") * v_right) + self.dodging_direction_x * (cvar("sv_dodging_horiz_speed") * v_forward) + (cvar("sv_dodging_up_speed") * v_up);//'100 0 50';
+               self.dodging_action = 0;
+       }
+
+       // are we done with the dodging ramp yet?
+       if((self.dodging_action == 1) && ((time - self.last_dodging_time) > cvar("sv_dodging_ramp_time")))
+               self.dodging_action = 0;
 
        return 0;
 }
@@ -41,16 +57,35 @@ MUTATOR_HOOKFUNCTION(dodging_GetPressedKeys) {
                        if (
                                ((time - self.last_FORWARD_KEY_time) < self.cvar_cl_dodging_timeout) &&
                                (self.lastflags & FL_ONGROUND) &&
-                               ((time - self.last_dodge_time) > cvar("sv_dodging_delay"))
+                               ((time - self.last_dodging_time) > cvar("sv_dodging_delay"))
                        ) { // are we allowed to dodge?
-                               self.dodge_action = 1;
-                               // self.velocity = self.velocity + (cvar("sv_dodging_horiz_speed") * v_forward) + (cvar("sv_dodging_up_speed") * v_up);//'100 0 50';
-                               self.last_dodge_time = time;
+                               self.dodging_action = 1;
+                               self.dodging_direction_x = self.movement_x;
+                               self.dodging_direction_y = self.movement_y;
+
+
+                               self.last_dodging_time = time;
                        }
                        self.last_FORWARD_KEY_time = time;
                }
        }
 
+       if (self.movement_x < 0) // get if movement keys are pressed
+   {       // forward key pressed
+       if (!(self.pressedkeys & KEY_BACKWARD)) {        // is this a state change?
+                       if (
+                               ((time - self.last_BACKWARD_KEY_time) < self.cvar_cl_dodging_timeout) &&
+                               (self.lastflags & FL_ONGROUND) &&
+                               ((time - self.last_dodging_time) > cvar("sv_dodging_delay"))
+                       ) { // are we allowed to dodge?
+                               self.dodging_action = 1;
+                               // self.velocity = self.velocity + (cvar("sv_dodging_horiz_speed") * v_forward) + (cvar("sv_dodging_up_speed") * v_up);//'100 0 50';
+                               self.last_dodging_time = time;
+                       }
+                       self.last_BACKWARD_KEY_time = time;
+               }
+       }
+
        return 0;
 }