2023-07-20 23:20:39 +02:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2023-07-22 16:23:15 +02:00
|
|
|
#include "features.h"
|
2023-07-20 23:20:39 +02:00
|
|
|
#include "../include/sdk.h"
|
|
|
|
#include "../include/globals.h"
|
2023-07-21 13:45:21 +02:00
|
|
|
#include "../include/cvars.h"
|
2023-07-20 23:20:39 +02:00
|
|
|
|
2023-07-23 15:38:50 +02:00
|
|
|
static void autostrafe_legit(usercmd_t* cmd) {
|
|
|
|
/* Get mouse delta */
|
|
|
|
int dx = 0, dy = 0;
|
|
|
|
i_engine->pfnVguiWrap2_GetMouseDelta(&dx, &dy);
|
|
|
|
|
|
|
|
if (dx < 0)
|
|
|
|
cmd->sidemove = -450.0f;
|
|
|
|
else if (dx > 0)
|
|
|
|
cmd->sidemove = 450.0f;
|
|
|
|
}
|
|
|
|
|
2023-07-20 23:20:39 +02:00
|
|
|
void bhop(usercmd_t* cmd) {
|
2023-07-21 13:45:21 +02:00
|
|
|
if (!CVAR_ON(bhop) || i_pmove->movetype != MOVETYPE_WALK)
|
2023-07-20 23:20:39 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
static bool was_in_air = false;
|
|
|
|
|
2023-07-21 13:16:38 +02:00
|
|
|
/* 2 frames in air, release jump */
|
2023-07-20 23:20:39 +02:00
|
|
|
if (was_in_air && !(i_pmove->flags & FL_ONGROUND))
|
|
|
|
cmd->buttons &= ~IN_JUMP;
|
|
|
|
|
|
|
|
was_in_air = (i_pmove->flags & FL_ONGROUND) == 0;
|
2023-07-23 15:38:50 +02:00
|
|
|
|
|
|
|
/* Autostrafe if enabled. Check if we are in the air. */
|
|
|
|
if (was_in_air) {
|
|
|
|
switch ((int)cv_autostrafe->value) {
|
|
|
|
case 1:
|
|
|
|
autostrafe_legit(cmd);
|
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2023-07-20 23:20:39 +02:00
|
|
|
}
|