1 .float last_FORWARD_KEY_time;
2 .float last_BACKWARD_KEY_time;
3 .float last_LEFT_KEY_time;
4 .float last_RIGHT_KEY_time;
6 // this indicates the last time a dodge was executed. used to check if another one is allowed
7 // and to ramp up the dodge acceleration in the physics hook.
8 .float last_dodge_time;
10 // set to 1 to indicate dodging has started.. reset by physics hook after dodge has been done..
13 void dodging_Initialize() {
14 self.last_FORWARD_KEY_time = 0;
15 self.last_BACKWARD_KEY_time = 0;
16 self.last_RIGHT_KEY_time = 0;
17 self.last_LEFT_KEY_time = 0;
18 self.last_dodge_time = 0;
19 self.dodge_action = 0;
22 MUTATOR_HOOKFUNCTION(dodging_PlayerPhysics) {
23 // print("physics hook\n");
32 MUTATOR_HOOKFUNCTION(dodging_GetPressedKeys) {
33 //print("dodging_hook\n");
38 if (self.movement_x > 0) // get if movement keys are pressed
39 { // forward key pressed
40 if (!(self.pressedkeys & KEY_FORWARD)) { // is this a state change?
42 ((time - self.last_FORWARD_KEY_time) < self.cvar_cl_dodging_timeout) &&
43 (self.lastflags & FL_ONGROUND) &&
44 ((time - self.last_dodge_time) > cvar("sv_dodging_delay"))
45 ) { // are we allowed to dodge?
46 self.dodge_action = 1;
47 // self.velocity = self.velocity + (cvar("sv_dodging_horiz_speed") * v_forward) + (cvar("sv_dodging_up_speed") * v_up);//'100 0 50';
48 self.last_dodge_time = time;
50 self.last_FORWARD_KEY_time = time;
57 MUTATOR_DEFINITION(dodging)
59 // we need to be called before GetPressedKey does its thing so we can
60 // detect state changes and therefore dodging actions..
61 MUTATOR_HOOK(GetPressedKeys, dodging_GetPressedKeys, CBC_ORDER_ANY);
63 // in the physics hook we actually implement the dodge..
64 MUTATOR_HOOK(PlayerPhysics, dodging_PlayerPhysics, CBC_ORDER_ANY);
66 // this just turns on the cvar. TODO: implement :D
73 // this just turns off the cvar. TODO: implement :D