From: Florian Paul Schmidt Date: Sat, 20 Mar 2010 00:24:22 +0000 (+0100) Subject: - almost working.. but what's up with v_right v_up and v_forward? X-Git-Tag: xonotic-v0.1.0preview~680^2~25 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=19e0e44988948d9fdb4b399e35fd67926fbd6afe;p=xonotic%2Fxonotic-data.pk3dir.git - almost working.. but what's up with v_right v_up and v_forward? --- diff --git a/qcsrc/server/mutators/mutator_dodging.qc b/qcsrc/server/mutators/mutator_dodging.qc index 93d5da3e9..805e9bfb8 100644 --- a/qcsrc/server/mutators/mutator_dodging.qc +++ b/qcsrc/server/mutators/mutator_dodging.qc @@ -32,10 +32,18 @@ MUTATOR_HOOKFUNCTION(dodging_PlayerPhysics) { if (g_dodging == 0) return 0; - // ramp up dodging speed by adding some velocity each frame.. + // ramp up dodging speed by adding some velocity each frame.. TODO: do it! :D 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); + //print(vtos(self.v_up), "\n"); + //self.velocity_z = self.velocity_z + cvar("sv_dodging_up_speed") * v_up; + //self.velocity_x = self.velocity_x + self.dodging_direction_x * cvar("sv_dodging_horiz_speed") * v_forward; + //self.velocity_y = self.velocity_y + self.dodging_direction_y * cvar("sv_dodging_horiz_speed") * v_right; + 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); + + // reset state so next dodge can be done correctly self.dodging_action = 0; + self.dodging_direction_x = 0; + self.dodging_direction_y = 0; } // are we done with the dodging ramp yet? @@ -47,53 +55,58 @@ MUTATOR_HOOKFUNCTION(dodging_PlayerPhysics) { MUTATOR_HOOKFUNCTION(dodging_GetPressedKeys) { float length; + float dodge_detected; //print("dodging_hook\n"); if (g_dodging == 0) return 0; - self.dodging_direction_x = 0; - self.dodging_direction_y = 0; + dodge_detected = 0; if (self.movement_x > 0) // get if movement keys are pressed { // forward key pressed if (!(self.pressedkeys & KEY_FORWARD)) { // is this a state change? - if ( + if ( // are we allowed to dodge? ((time - self.last_FORWARD_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? + ) { + dodge_detected = 1; self.dodging_action = 1; - self.dodging_direction_x = 1; + self.dodging_direction_x = 1.0; 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 ( + if (self.movement_x < 0) + { + if (!(self.pressedkeys & KEY_BACKWARD)) { // is this a state change? + if ( // are we allowed to dodge? ((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? + ) { + dodge_detected = 1; self.dodging_action = 1; - self.dodging_direction_x = -1; + self.dodging_direction_x = -1.0; self.last_dodging_time = time; } self.last_BACKWARD_KEY_time = time; } } - // normalize the dodging_direction vector.. - length += self.dodging_direction_x * self.dodging_direction_x; - length += self.dodging_direction_y * self.dodging_direction_y; - length = sqrt(length); - - self.dodging_direction_x *= 1/length; - self.dodging_direction_y *= 1/length; +// if (dodge_detected == 1) { +// // normalize the dodging_direction vector.. +// length = length + self.dodging_direction_x * self.dodging_direction_x; +// length = length + self.dodging_direction_y * self.dodging_direction_y; +// length = sqrt(length); +// +// self.dodging_direction_x = self.dodging_direction_x * 1.0/length; +// self.dodging_direction_y = self.dodging_direction_y * 1.0/length; +// } +// return 0; } @@ -106,14 +119,14 @@ MUTATOR_DEFINITION(dodging) // in the physics hook we actually implement the dodge.. MUTATOR_HOOK(PlayerPhysics, dodging_PlayerPhysics, CBC_ORDER_ANY); - // this just turns on the cvar. TODO: implement :D + // this just turns on the cvar. MUTATOR_ONADD { g_dodging = 1; dodging_Initialize(); } - // this just turns off the cvar. TODO: implement :D + // this just turns off the cvar. MUTATOR_ONREMOVE { g_dodging = 0;