PM_ClientMovement_Unstick();
// set crouched
- if (PHYS_INPUT_BUTTONS(self) & 16)
+ if (PHYS_INPUT_BUTTON_CROUCH(self))
{
// wants to crouch, this always works..
if (!IS_DUCKED(self))
// swimming
UNSET_ONGROUND(self);
- float jump = PHYS_INPUT_BUTTONS(self) & 2;
+ float jump = PHYS_INPUT_BUTTON_JUMP(self);
// water jump only in certain situations
// this mimics quakeworld code
if (jump && self.waterlevel == WATERLEVEL_SWIMMING && self.velocity_z >= -180)
void PM_Main()
{
+ float buttons = PHYS_INPUT_BUTTON_MASK(self);
#ifdef CSQC
//Con_Printf(" %f", PHYS_INPUT_TIMELENGTH);
- if (!(PHYS_INPUT_BUTTONS(self) & 2)) // !jump
+ if (!(PHYS_INPUT_BUTTON_JUMP(self))) // !jump
UNSET_JUMP_HELD(self); // canjump = true
pmove_waterjumptime -= PHYS_INPUT_TIMELENGTH;
PM_ClientMovement_UpdateStatus();
#ifdef SVQC
anticheat_physics();
#endif
- float buttons = PHYS_INPUT_BUTTONS(self);
if (PM_check_specialcommand(buttons))
return;
PM_check_frozen();
-#ifdef SVQC
- MUTATOR_CALLHOOK(PlayerPhysics);
-#endif
-#ifdef CSQC
- PM_dodging();
-#endif
-
PM_check_blocked();
maxspeed_mod = 1;
self.velocity -= self.conveyor.movedir;
#endif
+#ifdef SVQC
+ MUTATOR_CALLHOOK(PlayerPhysics);
+#endif
+// float forcedodge = 1;
+// if(forcedodge) {
+//#ifdef CSQC
+// PM_dodging_checkpressedkeys();
+//#endif
+// PM_dodging();
+// PM_ClientMovement_Move();
+// return;
+// }
+
#ifdef SVQC
if (!IS_PLAYER(self))
{
PM_ladder(maxspeed_mod);
#endif
- else if ((ITEMS(self) & IT_JETPACK) && PHYS_BUTTON_HOOK(self) && (!PHYS_JETPACK_FUEL || PHYS_AMMO_FUEL(self) > 0 || (ITEMS(self) & IT_UNLIMITED_WEAPON_AMMO)) && !PHYS_FROZEN(self))
+ else if ((ITEMS(self) & IT_JETPACK) && PHYS_INPUT_BUTTON_HOOK(self) && (!PHYS_JETPACK_FUEL || PHYS_AMMO_FUEL(self) > 0 || (ITEMS(self) & IT_UNLIMITED_WEAPON_AMMO)) && !PHYS_FROZEN(self))
PM_jetpack(maxspeed_mod);
else
#ifdef CSQC
// jump if on ground with jump button pressed but only if it has been
// released at least once since the last jump
- if (PHYS_INPUT_BUTTONS(self) & 2)
+ if (PHYS_INPUT_BUTTON_JUMP(self))
{
if (IS_ONGROUND(self) && (!IS_JUMP_HELD(self) || !cvar("cl_movement_track_canjump")))
{
}
else
// we REALLY need this handling to happen, even if the move is not executed
- if (!(PHYS_INPUT_BUTTONS(self) & 2)) // !jump
+ if (!(PHYS_INPUT_BUTTON_JUMP(self))) // !jump
UNSET_JUMP_HELD(self); // canjump = true
-
-#ifdef CSQC
- PM_dodging_checkpressedkeys();
- PM_dodging_updatepressedkeys();
-#endif
}
#ifdef SVQC
#ifdef CSQC
#define PHYS_INPUT_ANGLES(s) input_angles
- #define PHYS_INPUT_BUTTONS(s) input_buttons
- #define PHYS_INPUT_TIMELENGTH input_timelength
- #define PHYS_INPUT_MOVEVALUES(s) input_movevalues
// TODO
#define PHYS_WORLD_ANGLES(s) input_angles
- #define PHYS_DEAD(s) s.csqcmodel_isdead
+ #define PHYS_INPUT_TIMELENGTH input_timelength
- #define PHYS_BUTTON_HOOK(s) (input_buttons & 32)
+ #define PHYS_INPUT_MOVEVALUES(s) input_movevalues
+
+ #define PHYS_INPUT_BUTTON_MASK(s) (input_buttons | 128 * (input_movevalues_x < 0) | 256 * (input_movevalues_x > 0) | 512 * (input_movevalues_y < 0) | 1024 * (input_movevalues_y > 0))
+ #define PHYS_INPUT_BUTTON_ATCK(s) (input_buttons & 1)
+ #define PHYS_INPUT_BUTTON_JUMP(s) (input_buttons & 2)
+ #define PHYS_INPUT_BUTTON_ATCK2(s) (input_buttons & 4)
+ #define PHYS_INPUT_BUTTON_ZOOM(s) (input_buttons & 8)
+ #define PHYS_INPUT_BUTTON_CROUCH(s) (input_buttons & 16)
+ #define PHYS_INPUT_BUTTON_HOOK(s) (input_buttons & 32)
+ #define PHYS_INPUT_BUTTON_USE(s) (input_buttons & 64)
+ #define PHYS_INPUT_BUTTON_BACKWARD(s) (input_buttons & 128)
+ #define PHYS_INPUT_BUTTON_FORWARD(s) (input_buttons & 256)
+ #define PHYS_INPUT_BUTTON_LEFT(s) (input_buttons & 512)
+ #define PHYS_INPUT_BUTTON_RIGHT(s) (input_buttons & 1024)
+
+ #define PHYS_DEAD(s) s.csqcmodel_isdead
#define GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE moveflags & MOVEFLAG_GRAVITYUNAFFECTEDBYTICRATE
#define GAMEPLAYFIX_NOGRAVITYONGROUND cvar("sv_gameplayfix_nogravityonground")
#elif defined(SVQC)
#define PHYS_INPUT_ANGLES(s) s.v_angle
- // TODO: cache
- #define PHYS_INPUT_BUTTONS(s) (s.BUTTON_ATCK + 2 * s.BUTTON_JUMP + 4 * s.BUTTON_ATCK2 + 8 * s.BUTTON_ZOOM + 16 * s.BUTTON_CROUCH + 32 * s.BUTTON_HOOK + 64 * s.BUTTON_USE + 128 * (s.movement_x < 0) + 256 * (s.movement_x > 0) + 512 * (s.movement_y < 0) + 1024 * (s.movement_y > 0))
+ #define PHYS_WORLD_ANGLES(s) s.angles
+
#define PHYS_INPUT_TIMELENGTH frametime
- #define PHYS_INPUT_MOVEVALUES(s) s.movement
- #define PHYS_WORLD_ANGLES(s) s.angles
+ #define PHYS_INPUT_MOVEVALUES(s) s.movement
+ // TODO: cache
+ #define PHYS_INPUT_BUTTON_MASK(s) (s.BUTTON_ATCK | 2 * s.BUTTON_JUMP | 4 * s.BUTTON_ATCK2 | 8 * s.BUTTON_ZOOM | 16 * s.BUTTON_CROUCH | 32 * s.BUTTON_HOOK | 64 * s.BUTTON_USE | 128 * (s.movement_x < 0) | 256 * (s.movement_x > 0) | 512 * (s.movement_y < 0) | 1024 * (s.movement_y > 0))
+ #define PHYS_INPUT_BUTTON_ATCK(s) s.BUTTON_ATCK
+ #define PHYS_INPUT_BUTTON_JUMP(s) s.BUTTON_JUMP
+ #define PHYS_INPUT_BUTTON_ATCK2(s) s.BUTTON_ATCK2
+ #define PHYS_INPUT_BUTTON_ZOOM(s) s.BUTTON_ZOOM
+ #define PHYS_INPUT_BUTTON_CROUCH(s) s.BUTTON_CROUCH
+ #define PHYS_INPUT_BUTTON_HOOK(s) s.BUTTON_HOOK
+ #define PHYS_INPUT_BUTTON_USE(s) s.BUTTON_USE
+ #define PHYS_INPUT_BUTTON_BACKWARD(s) (s.movement_x < 0)
+ #define PHYS_INPUT_BUTTON_FORWARD(s) (s.movement_x > 0)
+ #define PHYS_INPUT_BUTTON_LEFT(s) (s.movement_y < 0)
+ #define PHYS_INPUT_BUTTON_RIGHT(s) (s.movement_y > 0)
#define PHYS_DEAD(s) s.deadflag != DEAD_NO
- #define PHYS_BUTTON_HOOK(s) s.BUTTON_HOOK
-
#define GAMEPLAYFIX_GRAVITYUNAFFECTEDBYTICRATE autocvar_sv_gameplayfix_gravityunaffectedbyticrate
#define GAMEPLAYFIX_NOGRAVITYONGROUND cvar("sv_gameplayfix_nogravityonground")
#define GAMEPLAYFIX_Q2AIRACCELERATE autocvar_sv_gameplayfix_q2airaccelerate
void GetPressedKeys(void) {
MUTATOR_CALLHOOK(GetPressedKeys);
- if (self.movement_x > 0) // get if movement keys are pressed
- { // forward key pressed
- self.pressedkeys |= KEY_FORWARD;
- self.pressedkeys &= ~KEY_BACKWARD;
- }
- else if (self.movement_x < 0)
- { // backward key pressed
- self.pressedkeys |= KEY_BACKWARD;
- self.pressedkeys &= ~KEY_FORWARD;
- }
- else
- { // no x input
- self.pressedkeys &= ~KEY_FORWARD;
- self.pressedkeys &= ~KEY_BACKWARD;
- }
-
- if (self.movement_y > 0)
- { // right key pressed
- self.pressedkeys |= KEY_RIGHT;
- self.pressedkeys &= ~KEY_LEFT;
- }
- else if (self.movement_y < 0)
- { // left key pressed
- self.pressedkeys |= KEY_LEFT;
- self.pressedkeys &= ~KEY_RIGHT;
- }
- else
- { // no y input
- self.pressedkeys &= ~KEY_RIGHT;
- self.pressedkeys &= ~KEY_LEFT;
- }
-
- if (self.BUTTON_JUMP) // get if jump and crouch keys are pressed
- self.pressedkeys |= KEY_JUMP;
- else
- self.pressedkeys &= ~KEY_JUMP;
- if (self.BUTTON_CROUCH)
- self.pressedkeys |= KEY_CROUCH;
- else
- self.pressedkeys &= ~KEY_CROUCH;
-
- if (self.BUTTON_ATCK)
- self.pressedkeys |= KEY_ATCK;
- else
- self.pressedkeys &= ~KEY_ATCK;
- if (self.BUTTON_ATCK2)
- self.pressedkeys |= KEY_ATCK2;
- else
- self.pressedkeys &= ~KEY_ATCK2;
+ #define X(var,bit,flag) (flag ? var |= bit : var &= ~bit)
+ X(self.pressedkeys, KEY_FORWARD, PHYS_INPUT_MOVEVALUES(self)_x > 0);
+ X(self.pressedkeys, KEY_BACKWARD, PHYS_INPUT_MOVEVALUES(self)_x < 0);
+ X(self.pressedkeys, KEY_RIGHT, PHYS_INPUT_MOVEVALUES(self)_y > 0);
+ X(self.pressedkeys, KEY_LEFT, PHYS_INPUT_MOVEVALUES(self)_y < 0);
+
+ X(self.pressedkeys, KEY_JUMP, PHYS_INPUT_BUTTON_JUMP(self));
+ X(self.pressedkeys, KEY_CROUCH, PHYS_INPUT_BUTTON_CROUCH(self));
+ X(self.pressedkeys, KEY_ATCK, PHYS_INPUT_BUTTON_ATCK(self));
+ X(self.pressedkeys, KEY_ATCK2, PHYS_INPUT_BUTTON_ATCK2(self));
+ #undef X
}
/*
#ifdef CSQC
- #define PHYS_DODGING_FRAMETIME (1 / frametime <= 0 ? 60 : frametime)
+ #define PHYS_DODGING_FRAMETIME (1 / (frametime <= 0 ? 60 : frametime))
#define PHYS_DODGING getstati(STAT_DODGING)
#define PHYS_DODGING_DELAY getstatf(STAT_DODGING_DELAY)
#define PHYS_DODGING_TIMEOUT(s) getstatf(STAT_DODGING_TIMEOUT)
addstat(STAT_DODGING_WALL, AS_FLOAT, stat_dodging_wall);
}
-#endif
-#ifdef CSQC
-// instantly updates pressed keys, for use with dodging (may be out of date, but we can't care)
-void PM_dodging_updatepressedkeys()
-{
- #define X(var,bit,flag) (flag ? var |= bit : var &= ~bit)
- X(self.pressedkeys, KEY_FORWARD, PHYS_INPUT_MOVEVALUES(self)_x > 0);
- X(self.pressedkeys, KEY_BACKWARD, PHYS_INPUT_MOVEVALUES(self)_x < 0);
- X(self.pressedkeys, KEY_RIGHT, PHYS_INPUT_MOVEVALUES(self)_y > 0);
- X(self.pressedkeys, KEY_LEFT, PHYS_INPUT_MOVEVALUES(self)_y < 0);
-
- X(self.pressedkeys, KEY_ATCK, PHYS_INPUT_BUTTONS(self) & 1);
- X(self.pressedkeys, KEY_ATCK2, PHYS_INPUT_BUTTONS(self) & 2);
- X(self.pressedkeys, KEY_JUMP, PHYS_INPUT_BUTTONS(self) & 4);
- X(self.pressedkeys, KEY_CROUCH, PHYS_INPUT_BUTTONS(self) & 16);
- #undef X
-}
#endif
// returns 1 if the player is close to a wall
return IS_ONGROUND(self) ? TRUE : FALSE;
}
-void PM_dodging_checkpressedkeys()
+float PM_dodging_checkpressedkeys()
{
if(!PHYS_DODGING)
- return;
+ return FALSE;
float frozen_dodging = (PHYS_FROZEN(self) && PHYS_DODGING_FROZEN);
float frozen_no_doubletap = (frozen_dodging && !PHYS_DODGING_FROZEN_NODOUBLETAP);
// first check if the last dodge is far enough back in time so we can dodge again
if ((time - self.last_dodging_time) < PHYS_DODGING_DELAY)
- return;
+ return FALSE;
makevectors(PHYS_WORLD_ANGLES(self));
if (check_close_to_ground(PHYS_DODGING_HEIGHT_THRESHOLD) != 1
&& check_close_to_wall(PHYS_DODGING_DISTANCE_THRESHOLD) != 1)
- return;
+ return TRUE;
float tap_direction_x = 0;
float tap_direction_y = 0;
dodge_detected = 1; \
self.last_##BTN##_KEY_time = time; \
}
- X(x > 0, FORWARD, x = 1);
- X(x < 0, BACKWARD, x = -1);
- X(y > 0, RIGHT, y = 1);
- X(y < 0, LEFT, y = -1);
+ X(x < 0, BACKWARD, x--);
+ X(x > 0, FORWARD, x++);
+ X(y < 0, LEFT, y--);
+ X(y > 0, RIGHT, y++);
#undef X
if (dodge_detected == 1)
+ 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;
+ self.dodging_direction_x = self.dodging_direction_x * 1.0 / length;
+ self.dodging_direction_y = self.dodging_direction_y * 1.0 / length;
+ return TRUE;
}
+ return FALSE;
}
void PM_dodging()