Files
goldsrc-cheat/src/features/misc.c

82 lines
2.2 KiB
C
Raw Normal View History

2023-07-27 14:19:07 +02:00
#include "features.h"
#include "../include/sdk.h"
#include "../include/globals.h"
#include "../include/util.h"
2023-09-19 14:46:59 -04:00
#include "../include/game_detection.h"
2025-04-04 16:51:40 -04:00
#include "../include/settings.h"
2023-07-27 14:19:07 +02:00
void custom_crosshair(void) {
2025-04-04 16:51:40 -04:00
if (!g_settings.custom_crosshair)
2023-07-27 14:19:07 +02:00
return;
/* Get window size, and then the center. */
int mx = game_info->m_width / 2;
int my = game_info->m_height / 2;
/* The real length is sqrt(2 * (len^2)) */
2025-04-04 16:51:40 -04:00
const int len = 5;
2023-07-27 14:19:07 +02:00
const int gap = 1;
const float w = 1;
const rgb_t col = { 255, 255, 255 };
/*
* 1\ /2
* X
* 3/ \4
*/
gl_drawline(mx - gap, my - gap, mx - gap - len, my - gap - len, w, col);
gl_drawline(mx + gap, my - gap, mx + gap + len, my - gap - len, w, col);
gl_drawline(mx - gap, my + gap, mx - gap - len, my + gap + len, w, col);
gl_drawline(mx + gap, my + gap, mx + gap + len, my + gap + len, w, col);
}
2023-07-31 15:55:01 +02:00
2023-09-19 14:46:59 -04:00
weapon_data_t g_currentWeapon;
static double lastTracerTime = 0;
2023-09-22 00:35:35 -04:00
static bool attackReleased = true;
2023-07-31 15:55:01 +02:00
void bullet_tracers(usercmd_t* cmd) {
2025-04-04 16:51:40 -04:00
if (!g_settings.tracers || !is_alive(localplayer))
2023-09-19 14:46:59 -04:00
return;
if (IsCS16()) {
2023-09-22 00:35:35 -04:00
if (cmd->buttons & IN_ATTACK) {
if (!attackReleased) {
return;
}
attackReleased = false;
} else {
attackReleased = true;
return;
}
if (!can_shoot()) {
return;
}
}
else {
if (!(cmd->buttons & IN_ATTACK) || !can_shoot()) {
return;
}
2023-09-19 14:46:59 -04:00
}
2023-07-31 15:55:01 +02:00
/* Get player eye pos, start of tracer */
vec3_t view_height;
i_engine->pEventAPI->EV_LocalPlayerViewheight(view_height);
vec3_t local_eyes = vec_add(localplayer->origin, view_height);
2023-09-19 14:46:59 -04:00
2023-07-31 15:55:01 +02:00
/* Get forward vector from viewangles */
vec3_t fwd;
i_engine->pfnAngleVectors(cmd->viewangles, fwd, NULL, NULL);
const int tracer_len = 3000;
vec3_t end;
end.x = local_eyes.x + fwd.x * tracer_len;
end.y = local_eyes.y + fwd.y * tracer_len;
end.z = local_eyes.z + fwd.z * tracer_len;
/* NOTE: Change tracer settings here */
const float w = 0.8;
const float time = 2;
draw_tracer(local_eyes, end, (rgb_t){ 66, 165, 245 }, 1, w, time);
}