Tracers and misc changes
This commit is contained in:
parent
7bcced2930
commit
db2f2c8771
@ -11,8 +11,4 @@ namespace hacks::tf2::antibackstab
|
||||
{
|
||||
|
||||
extern bool noaa;
|
||||
|
||||
void CreateMove();
|
||||
|
||||
void PaintTraverse();
|
||||
} // namespace hacks::tf2::antibackstab
|
||||
|
@ -83,6 +83,7 @@ public:
|
||||
explicit Texture(std::string path) : path{ path }
|
||||
{
|
||||
}
|
||||
Texture(unsigned int id, unsigned int height, unsigned int width);
|
||||
bool load();
|
||||
unsigned int get();
|
||||
~Texture();
|
||||
|
@ -119,7 +119,7 @@ static void doBacktrackStab()
|
||||
|
||||
Vector distcheck = i.entorigin;
|
||||
distcheck.z = g_pLocalPlayer->v_Eye.z;
|
||||
if (distcheck.DistTo(g_pLocalPlayer->v_Eye) < best_scr && distcheck.DistTo(g_pLocalPlayer->v_Eye) > 10.0f)
|
||||
if (distcheck.DistTo(g_pLocalPlayer->v_Eye) < best_scr && distcheck.DistTo(g_pLocalPlayer->v_Eye) > 20.0f)
|
||||
{
|
||||
for (newangle.y = -180.0f; newangle.y < 180.0f; newangle.y += 5.0f)
|
||||
{
|
||||
@ -127,9 +127,25 @@ static void doBacktrackStab()
|
||||
continue;
|
||||
if (!angleCheck(ent, i.entorigin, newangle))
|
||||
continue;
|
||||
Vector hit;
|
||||
|
||||
if (hacks::shared::triggerbot::CheckLineBox(i.collidable.min, i.collidable.max, g_pLocalPlayer->v_Eye, GetForwardVector(g_pLocalPlayer->v_Eye, newangle, swingrange), hit))
|
||||
Vector &min = i.collidable.min;
|
||||
Vector &max = i.collidable.max;
|
||||
|
||||
// Get the min and max for the hitbox
|
||||
Vector minz(fminf(min.x, max.x), fminf(min.y, max.y), fminf(min.z, max.z));
|
||||
Vector maxz(fmaxf(min.x, max.x), fmaxf(min.y, max.y), fmaxf(min.z, max.z));
|
||||
|
||||
// Shrink the hitbox here
|
||||
Vector size = maxz - minz;
|
||||
Vector smod = { size.x * 0.20f, size.y * 0.20f, 0 };
|
||||
|
||||
// Save the changes to the vectors
|
||||
minz += smod;
|
||||
maxz -= smod;
|
||||
maxz.z += 20.0f;
|
||||
|
||||
Vector hit;
|
||||
if (hacks::shared::triggerbot::CheckLineBox(minz, maxz, g_pLocalPlayer->v_Eye, GetForwardVector(g_pLocalPlayer->v_Eye, newangle, swingrange), hit))
|
||||
yangles_tmp.push_back(newangle.y);
|
||||
}
|
||||
if (!yangles_tmp.empty())
|
||||
|
@ -32,6 +32,7 @@ target_sources(cathook PRIVATE
|
||||
"${CMAKE_CURRENT_LIST_DIR}/MiscPlayerInfo.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/NavBot.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Noisemaker.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Tracers.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Trigger.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/UberSpam.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/Walkbot.cpp"
|
||||
|
106
src/hacks/Tracers.cpp
Normal file
106
src/hacks/Tracers.cpp
Normal file
@ -0,0 +1,106 @@
|
||||
#include "common.hpp"
|
||||
#include "PlayerTools.hpp"
|
||||
|
||||
namespace hacks::shared::tracers
|
||||
{
|
||||
|
||||
settings::Bool enabled("tracers.enabled", "false");
|
||||
settings::Float green_dist("tracers.green-distance", "1500");
|
||||
|
||||
// 0 = don't, 1 = yes but only in enemy team, 2 = always
|
||||
settings::Int draw_friendlies("tracers.draw-friends", "1");
|
||||
|
||||
// Extend a line to a certain border
|
||||
// https://stackoverflow.com/a/45056039
|
||||
static inline Vector2D toBorder(float x1, float y1, float x2, float y2, float left, float top, float right, float bottom)
|
||||
{
|
||||
float dx, dy, py, vx, vy;
|
||||
vx = x2 - x1;
|
||||
vy = y2 - y1;
|
||||
dx = vx < 0 ? left : right;
|
||||
dy = py = vy < 0 ? top : bottom;
|
||||
if (vx == 0)
|
||||
{
|
||||
dx = x1;
|
||||
}
|
||||
else if (vy == 0)
|
||||
{
|
||||
dy = y1;
|
||||
}
|
||||
else
|
||||
{
|
||||
dy = y1 + (vy / vx) * (dx - x1);
|
||||
if (dy < top || dy > bottom)
|
||||
{
|
||||
dx = x1 + (vx / vy) * (py - y1);
|
||||
dy = py;
|
||||
}
|
||||
}
|
||||
return { dx, dy };
|
||||
}
|
||||
|
||||
inline std::optional<rgba_t> getColor(CachedEntity *ent)
|
||||
{
|
||||
auto state = playerlist::AccessData(ent->player_info.friendsID);
|
||||
if (state.state == playerlist::k_EState::DEFAULT)
|
||||
{
|
||||
if (!ent->m_bEnemy())
|
||||
return std::nullopt;
|
||||
float dist = ent->m_vecOrigin().DistTo(LOCAL_E->m_vecOrigin());
|
||||
// if (dist < *red_alert)
|
||||
// return colors::red;
|
||||
// if (dist < *yellow_alert)
|
||||
// return colors::orange;
|
||||
return colors::Health(std::min(dist, *green_dist), *green_dist);
|
||||
// return colors::white;
|
||||
}
|
||||
if (!player_tools::shouldTargetSteamId(ent->player_info.friendsID))
|
||||
{
|
||||
if (*draw_friendlies == 1)
|
||||
{
|
||||
if (ent->m_bEnemy())
|
||||
return colors::blu;
|
||||
}
|
||||
else if (*draw_friendlies == 2)
|
||||
return colors::blu;
|
||||
return std::nullopt;
|
||||
}
|
||||
if (!ent->m_bEnemy())
|
||||
return std::nullopt;
|
||||
return playerlist::Color(ent->player_info.friendsID);
|
||||
}
|
||||
|
||||
void draw()
|
||||
{
|
||||
if (!enabled || CE_BAD(LOCAL_E) || !LOCAL_E->m_bAlivePlayer())
|
||||
return;
|
||||
// Loop all players
|
||||
for (int i = 1; i < g_IEngine->GetMaxClients(); i++)
|
||||
{
|
||||
// Get and check player
|
||||
auto ent = ENTITY(i);
|
||||
if (CE_BAD(ent) || !ent->m_bAlivePlayer())
|
||||
continue;
|
||||
if (ent == LOCAL_E)
|
||||
continue;
|
||||
auto color = getColor(ent);
|
||||
if (!color)
|
||||
continue;
|
||||
|
||||
Vector out;
|
||||
if (!draw::WorldToScreen(ent->m_vecOrigin(), out))
|
||||
{
|
||||
// We need to flip on both x and y axis in case m_vecOrigin its not actually on screen
|
||||
out.x = draw::width - out.x;
|
||||
out.y = draw::height - out.y;
|
||||
|
||||
auto extended = toBorder(draw::width / 2, draw::height / 2, out.x, out.y, 0, 0, draw::width, draw::height);
|
||||
out.x = extended.x;
|
||||
out.y = extended.y;
|
||||
}
|
||||
draw::Line(draw::width / 2, draw::height / 2, out.x - draw::width / 2, out.y - draw::height / 2, *color, 2);
|
||||
}
|
||||
}
|
||||
|
||||
InitRoutine init([]() { EC::Register(EC::Draw, draw, "DRAW_tracers"); });
|
||||
} // namespace hacks::shared::tracers
|
@ -121,7 +121,7 @@ std::unique_ptr<font> center_screen{ nullptr };
|
||||
namespace draw
|
||||
{
|
||||
|
||||
int texture_white = 0;
|
||||
unsigned int texture_white = 0;
|
||||
|
||||
void Initialize()
|
||||
{
|
||||
@ -147,7 +147,7 @@ void String(int x, int y, rgba_t rgba, const char *text, fonts::font &font)
|
||||
glez::draw::outlined_string(x, y, text, font, rgba, colors::black, nullptr, nullptr);
|
||||
#else
|
||||
rgba = rgba * 255.0f;
|
||||
g_ISurface->DrawSetTextPos(x, y - 2);
|
||||
g_ISurface->DrawSetTextPos(x, y);
|
||||
g_ISurface->DrawSetTextFont(font);
|
||||
g_ISurface->DrawSetTextColor(rgba.r, rgba.g, rgba.b, rgba.a);
|
||||
|
||||
@ -165,45 +165,51 @@ void Line(float x1, float y1, float x2_offset, float y2_offset, rgba_t color, fl
|
||||
glez::draw::line(x1, y1, x2_offset, y2_offset, color, thickness);
|
||||
#else
|
||||
color = color * 255.0f;
|
||||
g_ISurface->DrawSetTexture(texture_white);
|
||||
g_ISurface->DrawSetColor(color.r, color.g, color.b, color.a);
|
||||
if (thickness > 1.0f)
|
||||
{
|
||||
g_ISurface->DrawSetTexture(texture_white);
|
||||
// Dirty
|
||||
x1 += 0.5f;
|
||||
y1 += 0.5f;
|
||||
|
||||
// Dirty
|
||||
x1 += 0.5f;
|
||||
y1 += 0.5f;
|
||||
float length = sqrtf(x2_offset * x2_offset + y2_offset * y2_offset);
|
||||
x2_offset *= (length - 1.0f) / length;
|
||||
y2_offset *= (length - 1.0f) / length;
|
||||
|
||||
float length = sqrtf(x2_offset * x2_offset + y2_offset * y2_offset);
|
||||
x2_offset *= (length - 1.0f) / length;
|
||||
y2_offset *= (length - 1.0f) / length;
|
||||
float nx = x2_offset;
|
||||
float ny = y2_offset;
|
||||
|
||||
float nx = x2_offset;
|
||||
float ny = y2_offset;
|
||||
float ex = x1 + x2_offset;
|
||||
float ey = y1 + y2_offset;
|
||||
|
||||
float ex = x1 + x2_offset;
|
||||
float ey = y1 + y2_offset;
|
||||
if (length <= 1.0f)
|
||||
return;
|
||||
|
||||
if (length <= 1.0f)
|
||||
return;
|
||||
nx /= length;
|
||||
ny /= length;
|
||||
|
||||
nx /= length;
|
||||
ny /= length;
|
||||
float th = thickness;
|
||||
|
||||
float th = thickness;
|
||||
nx *= th * 0.5f;
|
||||
ny *= th * 0.5f;
|
||||
|
||||
nx *= th * 0.5f;
|
||||
ny *= th * 0.5f;
|
||||
float px = ny;
|
||||
float py = -nx;
|
||||
|
||||
float px = ny;
|
||||
float py = -nx;
|
||||
vgui::Vertex_t vertices[4];
|
||||
|
||||
vgui::Vertex_t vertices[4];
|
||||
vertices[2].m_Position = { float(x1) - nx + px, float(y1) - ny + py };
|
||||
vertices[1].m_Position = { float(x1) - nx - px, float(y1) - ny - py };
|
||||
vertices[3].m_Position = { ex + nx + px, ey + ny + py };
|
||||
vertices[0].m_Position = { ex + nx - px, ey + ny - py };
|
||||
|
||||
vertices[2].m_Position = { float(x1) - nx + px, float(y1) - ny + py };
|
||||
vertices[1].m_Position = { float(x1) - nx - px, float(y1) - ny - py };
|
||||
vertices[3].m_Position = { ex + nx + px, ey + ny + py };
|
||||
vertices[0].m_Position = { ex + nx - px, ey + ny - py };
|
||||
|
||||
g_ISurface->DrawTexturedPolygon(4, vertices);
|
||||
g_ISurface->DrawTexturedPolygon(4, vertices);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_ISurface->DrawLine(x1, y1, x1 + x2_offset, y1 + y2_offset);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -325,15 +331,13 @@ void UpdateWTS()
|
||||
bool WorldToScreen(const Vector &origin, Vector &screen)
|
||||
{
|
||||
float w;
|
||||
screen.z = 0;
|
||||
w = wts[3][0] * origin[0] + wts[3][1] * origin[1] + wts[3][2] * origin[2] + wts[3][3];
|
||||
screen.z = 0;
|
||||
w = wts[3][0] * origin[0] + wts[3][1] * origin[1] + wts[3][2] * origin[2] + wts[3][3];
|
||||
float odw = 1.0f / w;
|
||||
screen.x = (draw::width / 2) + (0.5 * ((wts[0][0] * origin[0] + wts[0][1] * origin[1] + wts[0][2] * origin[2] + wts[0][3]) * odw) * draw::width + 0.5);
|
||||
screen.y = (draw::height / 2) - (0.5 * ((wts[1][0] * origin[0] + wts[1][1] * origin[1] + wts[1][2] * origin[2] + wts[1][3]) * odw) * draw::height + 0.5);
|
||||
if (w > 0.001)
|
||||
{
|
||||
float odw = 1.0f / w;
|
||||
screen.x = (draw::width / 2) + (0.5 * ((wts[0][0] * origin[0] + wts[0][1] * origin[1] + wts[0][2] * origin[2] + wts[0][3]) * odw) * draw::width + 0.5);
|
||||
screen.y = (draw::height / 2) - (0.5 * ((wts[1][0] * origin[0] + wts[1][1] * origin[1] + wts[1][2] * origin[2] + wts[1][3]) * odw) * draw::height + 0.5);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#if ENABLE_ENGINE_DRAWING
|
||||
@ -375,6 +379,11 @@ Texture::~Texture()
|
||||
g_ISurface->DeleteTextureByID(texture_id);
|
||||
}
|
||||
|
||||
Texture::Texture(unsigned int id, unsigned int height, unsigned int width) : texture_id{ id }, m_width{ width }, m_height{ height }
|
||||
{
|
||||
init = true;
|
||||
}
|
||||
|
||||
unsigned int Texture::get()
|
||||
{
|
||||
if (texture_id == 0)
|
||||
|
Reference in New Issue
Block a user