else
movespeed = min(movespeed, maxspeed);
- // determine whether the player is pressing forwards or backwards keys
- int keys_fwd;
- if(islocal) // if entity is local player
- {
- if(movement.x > 0)
- keys_fwd = STRAFEHUD_KEYS_FORWARD;
- else if(movement.x < 0)
- keys_fwd = STRAFEHUD_KEYS_BACKWARD;
- else
- keys_fwd = STRAFEHUD_KEYS_NONE;
- }
- else // alternatively determine direction by querying pressed keys
- {
- if((keys & KEY_FORWARD) && !(keys & KEY_BACKWARD))
- keys_fwd = STRAFEHUD_KEYS_FORWARD;
- else if(!(keys & KEY_FORWARD) && (keys & KEY_BACKWARD))
- keys_fwd = STRAFEHUD_KEYS_BACKWARD;
- else
- keys_fwd = STRAFEHUD_KEYS_NONE;
- }
-
+ int keys_fwd = StrafeHUD_DetermineForwardKeys(movement, keys, islocal);
float wishangle = StrafeHUD_DetermineWishAngle(movement, keys, islocal);
float absolute_wishangle = fabs(wishangle); // unmodified by side strafing code
bool strafekeys = fabs(wishangle) > 45;
return wishangle;
}
+// determine whether the player is pressing forwards or backwards keys
+int StrafeHUD_DetermineForwardKeys(vector movement, int keys, bool islocal)
+{
+ if(islocal) // if entity is local player
+ {
+ if(movement.x > 0)
+ return STRAFEHUD_KEYS_FORWARD;
+ else if(movement.x < 0)
+ return STRAFEHUD_KEYS_BACKWARD;
+ else
+ return STRAFEHUD_KEYS_NONE;
+ }
+ else // alternatively determine direction by querying pressed keys
+ {
+ if((keys & KEY_FORWARD) && !(keys & KEY_BACKWARD))
+ return STRAFEHUD_KEYS_FORWARD;
+ else if(!(keys & KEY_FORWARD) && (keys & KEY_BACKWARD))
+ return STRAFEHUD_KEYS_BACKWARD;
+ else
+ return STRAFEHUD_KEYS_NONE;
+ }
+}
+
float StrafeHUD_DetermineHudAngle(float absolute_wishangle, float absolute_overturnangle, float strafity)
{
float StrafeHUD_DetermineWaterLevel(entity);
float StrafeHUD_DetermineFrameTime();
float StrafeHUD_DetermineWishAngle(vector, int, bool);
+int StrafeHUD_DetermineForwardKeys(vector, int, bool);
float StrafeHUD_DetermineHudAngle(float, float, float);
float StrafeHUD_DetermineDirection(float, float, float);
bool StrafeHUD_DetermineJumpHeld(entity, int, bool);