Added basic namechanger 'dz_misc_namechanger'

This commit is contained in:
Wizzard 2023-09-21 12:16:03 -04:00
parent 72dc42006f
commit 8a5b96505b
7 changed files with 109 additions and 1 deletions

View File

@ -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=-lm
OBJS=obj/main.c.o obj/globals.c.o obj/cvars.c.o obj/hooks.c.o obj/detour.c.o obj/util.c.o obj/features/movement.c.o obj/features/anti_aim.c.o obj/features/esp.c.o obj/features/chams.c.o obj/features/aim.c.o obj/features/misc.c.o obj/game_detection.c.o
OBJS=obj/main.c.o obj/globals.c.o obj/cvars.c.o obj/hooks.c.o obj/detour.c.o obj/util.c.o obj/features/movement.c.o obj/features/anti_aim.c.o obj/features/namechanger.c.o obj/features/esp.c.o obj/features/chams.c.o obj/features/aim.c.o obj/features/misc.c.o obj/game_detection.c.o
BIN=libhlcheat.so
.PHONY: clean all inject

View File

@ -34,6 +34,7 @@ Also make sure to check out [[https://github.com/deboogerxyz/ahc][deboogerxyz/ah
| Chams | =dz_visuals_chams= | off/players/hands/all |
| Crosshair | =dz_visuals_crosshair= | off/length |
| Tracers | =dz_visuals_tracers= | off/on |
| Namechanger| =dz_misc_namechanger= | off/team/enemy/all |
#+begin_quote
*Note:* Aimbot FOV goes from 0 (off) to 180 (all enemies)

View File

@ -20,6 +20,7 @@ DECL_CVAR(visuals_friendly);
DECL_CVAR(movement_antiaim);
DECL_CVAR(movement_antiaim_view);
DECL_CVAR(movement_fakeduck);
DECL_CVAR(misc_namechanger);
bool cvars_init(void) {
@ -38,6 +39,7 @@ bool cvars_init(void) {
REGISTER_CVAR(movement_antiaim, 0);
REGISTER_CVAR(movement_antiaim_view, 0);
REGISTER_CVAR(movement_fakeduck, 0);
REGISTER_CVAR(misc_namechanger, 0);
if (IsCS16()) {
REGISTER_CVAR(visuals_tracers, 0);
} else {

View File

@ -33,6 +33,9 @@ void aimbot(usercmd_t* cmd);
void custom_crosshair(void);
void bullet_tracers(usercmd_t* cmd);
/* src/features/namechanger.c */
void check_namechanger_mode_and_execute(usercmd_t* cmd);
/* src/features/anti_aim.c */
void anti_aim(usercmd_t* cmd);

100
src/features/namechanger.c Normal file
View File

@ -0,0 +1,100 @@
#include <stdint.h>
#include <cstring>
#include <algorithm>
#include <vector>
#include "features.h"
#include "../include/globals.h"
#include "../include/cvars.h"
#include "../include/util.h"
#include "../include/game_detection.h"
static int change_counter = 0;
#define NAME_CHANGE_INTERVAL 10
static int last_name_idx = -1;
void change_name(const char* new_name) {
if (!new_name) return;
char command[256];
snprintf(command, sizeof(command), "name \"%s\u200B\"", new_name);
i_engine->pfnClientCmd(command);
}
std::vector<char*> get_valid_names(bool (*filter)(cl_entity_t*)) {
int max_players = 32;
std::vector<char*> valid_names;
for (int i = 0; i < max_players; i++) {
cl_entity_t* ent = get_player(i);
if (!ent) continue;
if (!filter || filter(ent)) {
valid_names.push_back(get_name(i));
}
}
return valid_names;
}
void change_name_from_list(std::vector<char*>& names) {
if (names.empty()) return;
last_name_idx = (last_name_idx + 1) % names.size();
char* name = names[last_name_idx];
if (name) {
change_name(name);
printf("Changing name to: %s\n", name);
}
}
void change_name_teammates() {
auto names = get_valid_names(is_friend);
std::random_shuffle(names.begin(), names.end());
change_name_from_list(names);
}
void change_name_enemies() {
auto names = get_valid_names([](cl_entity_t* ent) -> bool {
return !is_friend(ent);
});
std::random_shuffle(names.begin(), names.end());
change_name_from_list(names);
}
void change_name_all_players() {
auto names = get_valid_names(nullptr);
std::random_shuffle(names.begin(), names.end());
change_name_from_list(names);
}
void change_name_based_on_mode(usercmd_t* cmd) {
if (!CVAR_ON(misc_namechanger)) return;
if (++change_counter < NAME_CHANGE_INTERVAL) {
return;
}
change_counter = 0;
switch ((int)dz_misc_namechanger->value) {
case 1:
change_name_teammates();
break;
case 2:
change_name_enemies();
break;
case 3:
change_name_all_players();
break;
default:
break;
}
}
void check_namechanger_mode_and_execute(usercmd_t* cmd) {
if (!CVAR_ON(misc_namechanger)) return;
change_name_based_on_mode(cmd);
}

View File

@ -65,6 +65,7 @@ void h_CL_CreateMove(float frametime, usercmd_t* cmd, int active) {
aimbot(cmd);
bullet_tracers(cmd);
anti_aim(cmd);
check_namechanger_mode_and_execute(cmd);
correct_movement(cmd, old_angles);
vec_clamp(cmd->viewangles);

View File

@ -46,6 +46,7 @@ DECL_CVAR_EXTERN(visuals_friendly);
DECL_CVAR_EXTERN(movement_antiaim);
DECL_CVAR_EXTERN(movement_antiaim_view);
DECL_CVAR_EXTERN(movement_fakeduck);
DECL_CVAR_EXTERN(misc_namechanger)
/*----------------------------------------------------------------------------*/