2023-07-27 14:19:07 +02:00
|
|
|
|
|
|
|
|
#include "features.h"
|
|
|
|
|
#include "../include/sdk.h"
|
|
|
|
|
#include "../include/globals.h"
|
|
|
|
|
#include "../include/cvars.h"
|
|
|
|
|
#include "../include/util.h"
|
2023-09-19 14:46:59 -04:00
|
|
|
#include "../include/game_detection.h"
|
2023-07-27 14:19:07 +02:00
|
|
|
|
|
|
|
|
void custom_crosshair(void) {
|
2023-09-20 14:51:49 -04:00
|
|
|
if (!CVAR_ON(visuals_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)) */
|
2023-09-20 14:51:49 -04:00
|
|
|
const int len = dz_visuals_crosshair->value;
|
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-07-31 15:55:01 +02:00
|
|
|
void bullet_tracers(usercmd_t* cmd) {
|
|
|
|
|
/* Only draw if we are holding attack and we can shoot */
|
2023-09-20 14:51:49 -04:00
|
|
|
if (!CVAR_ON(visuals_tracers) || !(cmd->buttons & IN_ATTACK) || !can_shoot() || !is_alive(localplayer))
|
2023-07-31 15:55:01 +02:00
|
|
|
return;
|
2023-09-19 14:46:59 -04:00
|
|
|
/* Dirty temp fix for tracers being spammed in CS1.6 */
|
|
|
|
|
if (IsCS16() && (g_flCurrentTime - lastTracerTime < 0.5)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (IsCS16()) {
|
|
|
|
|
}
|
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);
|
2023-09-19 14:46:59 -04:00
|
|
|
lastTracerTime = g_flCurrentTime;
|
2023-07-31 15:55:01 +02:00
|
|
|
}
|
2023-09-19 14:46:59 -04:00
|
|
|
|