Add correct_movement, call from CL_CreateMove
This commit is contained in:
parent
dcd38dc950
commit
611182e394
|
@ -9,5 +9,6 @@ void bhop(usercmd_t* cmd);
|
||||||
|
|
||||||
/* src/features/esp.c */
|
/* src/features/esp.c */
|
||||||
void esp(void);
|
void esp(void);
|
||||||
|
void correct_movement(usercmd_t* cmd, vec3_t old_angles);
|
||||||
|
|
||||||
#endif /* FEATURES_H_ */
|
#endif /* FEATURES_H_ */
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
#include "features.h"
|
#include "features.h"
|
||||||
#include "../include/sdk.h"
|
#include "../include/sdk.h"
|
||||||
#include "../include/globals.h"
|
#include "../include/globals.h"
|
||||||
#include "../include/cvars.h"
|
#include "../include/cvars.h"
|
||||||
|
#include "../include/util.h"
|
||||||
|
|
||||||
static void autostrafe_legit(usercmd_t* cmd) {
|
static void autostrafe_legit(usercmd_t* cmd) {
|
||||||
/* Get mouse delta */
|
/* Get mouse delta */
|
||||||
|
@ -41,3 +43,24 @@ void bhop(usercmd_t* cmd) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Unfortunately I don't know shit about math, so this is pasted from:
|
||||||
|
* https://github.com/deboogerxyz/ahc/blob/0492646e28dd7234a8cd431d37b152dc18a21b04/ahc.c#L377
|
||||||
|
*/
|
||||||
|
void correct_movement(usercmd_t* cmd, vec3_t old_angles) {
|
||||||
|
float old_y = old_angles[1] + (old_angles[1] < 0 ? 360 : 0);
|
||||||
|
float new_y = cmd->viewangles[1] + (cmd->viewangles[1] < 0 ? 360 : 0);
|
||||||
|
float delta = (new_y < old_y) ? fabsf(new_y - old_y)
|
||||||
|
: 360 - fabsf(new_y - old_y);
|
||||||
|
|
||||||
|
delta = 360 - delta;
|
||||||
|
|
||||||
|
float forward = cmd->forwardmove;
|
||||||
|
float side = cmd->sidemove;
|
||||||
|
|
||||||
|
cmd->forwardmove =
|
||||||
|
cos(DEG2RAD(delta)) * forward + cos(DEG2RAD(delta + 90)) * side;
|
||||||
|
cmd->sidemove =
|
||||||
|
sin(DEG2RAD(delta)) * forward + sin(DEG2RAD(delta + 90)) * side;
|
||||||
|
}
|
||||||
|
|
|
@ -19,10 +19,14 @@ bool hooks_init(void) {
|
||||||
void h_CL_CreateMove(float frametime, usercmd_t* cmd, int active) {
|
void h_CL_CreateMove(float frametime, usercmd_t* cmd, int active) {
|
||||||
ORIGINAL(CL_CreateMove, frametime, cmd, active);
|
ORIGINAL(CL_CreateMove, frametime, cmd, active);
|
||||||
|
|
||||||
|
vec3_t old_angles = cmd->viewangles;
|
||||||
|
|
||||||
/* Declared in globals.c */
|
/* Declared in globals.c */
|
||||||
localplayer = i_engine->GetLocalPlayer();
|
localplayer = i_engine->GetLocalPlayer();
|
||||||
|
|
||||||
bhop(cmd);
|
bhop(cmd);
|
||||||
|
|
||||||
|
correct_movement(cmd, old_angles);
|
||||||
}
|
}
|
||||||
|
|
||||||
int h_HUD_Redraw(float time, int intermission) {
|
int h_HUD_Redraw(float time, int intermission) {
|
||||||
|
|
Loading…
Reference in New Issue