From 1f1df22414d96a2090b7d2ae472cae53e8e53837 Mon Sep 17 00:00:00 2001 From: 8dcc <8dcc.git@gmail.com> Date: Thu, 20 Jul 2023 23:20:39 +0200 Subject: [PATCH] Add features folder and bhop --- Makefile | 4 ++-- src/features/include/movement.h | 9 +++++++++ src/features/movement.c | 19 +++++++++++++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 src/features/include/movement.h create mode 100644 src/features/movement.c diff --git a/Makefile b/Makefile index e00afec..1febab7 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ INCLUDES=-Isrc/include/sdk/common -Isrc/include/sdk/public -Isrc/include/sdk/pm_ CFLAGS=-Wall -Wextra -Wno-write-strings -m32 -fPIC $(INCLUDES) LDFLAGS= -OBJS=obj/main.c.o obj/globals.c.o obj/hooks.c.o +OBJS=obj/main.c.o obj/globals.c.o obj/hooks.c.o obj/features/movement.c.o BIN=libhlcheat.so .PHONY: clean all inject @@ -29,5 +29,5 @@ $(BIN): $(OBJS) $(CC) $(CFLAGS) -shared -o $@ $(OBJS) $(LDFLAGS) $(OBJS): obj/%.c.o : src/%.c - @mkdir -p obj/ + @mkdir -p obj/features/ $(CC) $(CFLAGS) -c -o $@ $< $(LDFLAGS) diff --git a/src/features/include/movement.h b/src/features/include/movement.h new file mode 100644 index 0000000..99dcbd4 --- /dev/null +++ b/src/features/include/movement.h @@ -0,0 +1,9 @@ + +#ifndef _MOVEMENT_H +#define _MOVEMENT_H + +#include "../../include/sdk.h" + +void bhop(usercmd_t* cmd); + +#endif /* _MOVEMENT_H */ diff --git a/src/features/movement.c b/src/features/movement.c new file mode 100644 index 0000000..e6478f7 --- /dev/null +++ b/src/features/movement.c @@ -0,0 +1,19 @@ + +#include + +#include "include/movement.h" +#include "../include/sdk.h" +#include "../include/globals.h" + +void bhop(usercmd_t* cmd) { + /* TODO: Check !bhop_var */ + if (false || i_pmove->movetype != MOVETYPE_WALK) + return; + + static bool was_in_air = false; + + if (was_in_air && !(i_pmove->flags & FL_ONGROUND)) + cmd->buttons &= ~IN_JUMP; + + was_in_air = (i_pmove->flags & FL_ONGROUND) == 0; +}