Triggerbot, Backtrack and Antibackstab fix

This commit is contained in:
BenCat07 2018-05-23 11:53:37 +02:00
parent 4903da355f
commit 2801311949
7 changed files with 83 additions and 88 deletions

View File

@ -7,6 +7,7 @@
#pragma once #pragma once
#include "common.hpp" #include "common.hpp"
#include <boost/circular_buffer.hpp>
namespace hacks namespace hacks
{ {
@ -40,7 +41,8 @@ struct CIncomingSequence
int sequencenr; int sequencenr;
float curtime; float curtime;
}; };
extern std::deque<CIncomingSequence> sequences; typedef boost::circular_buffer<CIncomingSequence> circular_buf;
extern circular_buf sequences;
extern CatVar latency; extern CatVar latency;
extern CatVar enable; extern CatVar enable;
extern BacktrackData headPositions[32][66]; extern BacktrackData headPositions[32][66];

View File

@ -22,12 +22,13 @@ public:
self, offsets::PlatformOffset(522, offsets::undefined, 522), self, offsets::PlatformOffset(522, offsets::undefined, 522),
0)(self, trace); 0)(self, trace);
} }
inline static float GetSwingRange(IClientEntity *self) inline static float GetSwingRange(CachedEntity *self)
{ {
typedef float (*fn_t)(IClientEntity *); int ret = 48.0f;
return vfunc<fn_t>( if (self->m_iClassID == CL_CLASS(CTFSword) ||
self, offsets::PlatformOffset(520, offsets::undefined, 520), self->m_iClassID == CL_CLASS(CTFKatana))
0)(self); ret = 72.0f;
return ret;
} }
}; };
} }

View File

@ -1047,7 +1047,7 @@ int ClosestHitbox(CachedEntity *target)
// FIXME this will break multithreading if it will be ever implemented. When // FIXME this will break multithreading if it will be ever implemented. When
// implementing it, these should be made non-static // implementing it, these should be made non-static
int closest; int closest;
float closest_fov, fov; float closest_fov, fov = 0.0f;
closest = -1; closest = -1;
closest_fov = 256; closest_fov = 256;
@ -1186,7 +1186,7 @@ bool UpdateAimkey()
float EffectiveTargetingRange() float EffectiveTargetingRange()
{ {
if (GetWeaponMode() == weapon_melee) if (GetWeaponMode() == weapon_melee)
return (float) re::C_TFWeaponBaseMelee::GetSwingRange(RAW_ENT(LOCAL_W)); return (float) re::C_TFWeaponBaseMelee::GetSwingRange(LOCAL_W);
if (g_pLocalPlayer->weapon()->m_iClassID == CL_CLASS(CTFFlameThrower)) if (g_pLocalPlayer->weapon()->m_iClassID == CL_CLASS(CTFFlameThrower))
return 185.0f; // Pyros only have so much untill their flames hit return 185.0f; // Pyros only have so much untill their flames hit

View File

@ -21,7 +21,7 @@ static CatVar distance(CV_FLOAT, "antibackstab_distance", "200", "Distance",
"Distance Until anti-backstab reacts"); "Distance Until anti-backstab reacts");
static CatVar silent(CV_SWITCH, "antibackstab_silent", "1", "Silent", static CatVar silent(CV_SWITCH, "antibackstab_silent", "1", "Silent",
"Works silently without moving your view"); "Works silently without moving your view");
static CatVar angle(CV_FLOAT, "antibackstab_angle", "150", "Detection Angle"); static CatVar angle(CV_FLOAT, "antibackstab_angle", "90", "Detection Angle");
static CatVar sayno(CV_SWITCH, "antibackstab_nope", "0", "Nope!", "Memes"); static CatVar sayno(CV_SWITCH, "antibackstab_nope", "0", "Nope!", "Memes");
void SayNope() void SayNope()
@ -101,34 +101,37 @@ void CreateMove()
if (!enabled) if (!enabled)
return; return;
spy = ClosestSpy(); spy = ClosestSpy();
ConVar *pitchdown = g_ICvar->FindVar("cl_pitchdown");
static int normal_val = pitchdown->GetInt();
if (spy) if (spy)
{ {
noaa = true; noaa = true;
const Vector &A = LOCAL_E->m_vecOrigin; // const Vector &A = LOCAL_E->m_vecOrigin;
const Vector &B = spy->m_vecOrigin; // const Vector &B = spy->m_vecOrigin;
diff = (A - B); // diff = (A - B);
yaw2 = acos(diff.x / diff.Length()) * 180.0f / PI; // yaw2 = acos(diff.x / diff.Length()) * 180.0f / PI;
if (diff.y < 0) // if (diff.y < 0)
yaw2 = -yaw2; // yaw2 = -yaw2;
if (yaw2 < -180) // if (yaw2 < -180)
yaw2 += 360; // yaw2 += 360;
if (yaw2 > 180) // if (yaw2 > 180)
yaw2 -= 360; // yaw2 -= 360;
resultangle = -180 + yaw2; // resultangle = -180 + yaw2;
if (resultangle < -180) // if (resultangle < -180)
resultangle += 360; // resultangle += 360;
g_pUserCmd->viewangles.y = resultangle; // g_pUserCmd->viewangles.y = resultangle;
pitchdown->SetValue(180);
g_pUserCmd->viewangles.x = 140.0f;
if (silent) if (silent)
{
// This isn't a spy aimbot.
if (!(g_pUserCmd->buttons & IN_ATTACK))
g_pLocalPlayer->bUseSilentAngles = true; g_pLocalPlayer->bUseSilentAngles = true;
}
if (sayno) if (sayno)
SayNope(); SayNope();
} }
else else
{
pitchdown->SetValue(normal_val);
noaa = false; noaa = false;
}
} }
void PaintTraverse() void PaintTraverse()

View File

@ -7,6 +7,8 @@
#include "common.hpp" #include "common.hpp"
#include "Backtrack.hpp" #include "Backtrack.hpp"
#include <boost/circular_buffer.hpp>
namespace hacks namespace hacks
{ {
namespace shared namespace shared
@ -22,7 +24,7 @@ CatVar latency(CV_FLOAT, "backtrack_latency", "0", "fake lantency",
BacktrackData headPositions[32][66]; BacktrackData headPositions[32][66];
int lastincomingsequencenumber = 0; int lastincomingsequencenumber = 0;
std::deque<CIncomingSequence> sequences; circular_buf sequences{ 2048 };
void UpdateIncomingSequences() void UpdateIncomingSequences()
{ {
INetChannel *ch = (INetChannel *) g_IEngine->GetNetChannelInfo(); INetChannel *ch = (INetChannel *) g_IEngine->GetNetChannelInfo();
@ -84,18 +86,28 @@ inline Vector angle_vector(Vector meme)
return Vector(cp * cy, cp * sy, -sp); return Vector(cp * cy, cp * sy, -sp);
} }
//======================================================================= //=======================================================================
bool installed = false;
int ticks = 12;
void Init() void Init()
{ {
for (int i = 0; i < 32; i++) for (int i = 0; i < 32; i++)
for (int j = 0; j < 66; j++) for (int j = 0; j < 66; j++)
headPositions[i][j] = headPositions[i][j] =
BacktrackData{ 0, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } }; BacktrackData{ 0, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } };
if (!installed)
{
latency.InstallChangeCallback(
[](IConVar *var, const char *pszOldValue, float flOldValue) {
ticks = max(min(int((float) latency) / 15, 65), 12);
});
installed = true;
}
} }
bool disabled = true; bool disabled = true;
int BestTick = 0; int BestTick = 0;
void Run() void Run()
{ {
int ticks = latency ? (float) latency / 15 : 12;
if (!enable) if (!enable)
{ {
if (!disabled) if (!disabled)
@ -111,7 +123,7 @@ void Run()
if (CE_BAD(LOCAL_E)) if (CE_BAD(LOCAL_E))
return; return;
for (int i = 1; i <= g_IEngine->GetMaxClients(); i++) for (int i = 1; i < g_IEngine->GetMaxClients(); i++)
{ {
CachedEntity *pEntity = ENTITY(i); CachedEntity *pEntity = ENTITY(i);
@ -133,18 +145,16 @@ void Run()
Vector hitboxpos = pEntity->hitboxes.GetHitbox(0)->center; Vector hitboxpos = pEntity->hitboxes.GetHitbox(0)->center;
Vector min = pEntity->hitboxes.GetHitbox(0)->min; Vector min = pEntity->hitboxes.GetHitbox(0)->min;
Vector max = pEntity->hitboxes.GetHitbox(0)->max; Vector max = pEntity->hitboxes.GetHitbox(0)->max;
headPositions[i][cmd->command_number % ticks] = headPositions[i][cmd->command_number % ticks + 1] =
BacktrackData{ cmd->tick_count, hitboxpos, min, max }; BacktrackData{ cmd->tick_count, hitboxpos, min, max };
Vector ViewDir = angle_vector(cmd->viewangles); Vector ViewDir = angle_vector(cmd->viewangles);
float FOVDistance = float FOVDistance =
distance_point_to_line(hitboxpos, g_pLocalPlayer->v_Eye, ViewDir); distance_point_to_line(hitboxpos, g_pLocalPlayer->v_Eye, ViewDir);
if (bestFov > FOVDistance && FOVDistance < 10.0f)
if (bestFov > FOVDistance)
{ {
bestFov = FOVDistance; bestFov = FOVDistance;
iBestTarget = i; iBestTarget = i;
} }
if (iBestTarget != -1) if (iBestTarget != -1)
{ {
int bestTick = 0; int bestTick = 0;
@ -158,7 +168,7 @@ void Run()
tempFOV = distance_point_to_line( tempFOV = distance_point_to_line(
headPositions[iBestTarget][t].hitboxpos, headPositions[iBestTarget][t].hitboxpos,
g_pLocalPlayer->v_Eye, ViewDir); g_pLocalPlayer->v_Eye, ViewDir);
if (bestFOV > tempFOV) if (bestFOV > tempFOV && tempFOV < 10.0f)
bestTick = t, bestFOV = tempFOV; bestTick = t, bestFOV = tempFOV;
} }
@ -175,7 +185,6 @@ void Draw()
return; return;
if (!draw_bt) if (!draw_bt)
return; return;
int ticks = latency ? (float) latency / 15 : 12;
for (int i = 0; i < 32; i++) for (int i = 0; i < 32; i++)
for (int j = 0; j < ticks; j++) for (int j = 0; j < ticks; j++)
{ {

View File

@ -351,28 +351,6 @@ bool IsTargetStateGood(CachedEntity *entity)
// Check for null // Check for null
if (hb) if (hb)
{ {
for (int i = -1; i < 12; i++)
{
if (i > -1)
{
auto min = hacks::shared::backtrack::headPositions
[entity->m_IDX][i]
.min;
auto max = hacks::shared::backtrack::headPositions
[entity->m_IDX][i]
.max;
if (min.x && max.x)
{
hb->min = hacks::shared::backtrack::headPositions
[entity->m_IDX][i]
.min;
hb->max = hacks::shared::backtrack::headPositions
[entity->m_IDX][i]
.max;
}
else
break;
}
// Get the min and max for the hitbox // Get the min and max for the hitbox
Vector minz(std::min(hb->min.x, hb->max.x), Vector minz(std::min(hb->min.x, hb->max.x),
std::min(hb->min.y, hb->max.y), std::min(hb->min.y, hb->max.y),
@ -400,7 +378,6 @@ bool IsTargetStateGood(CachedEntity *entity)
} }
} }
} }
}
// Target passed the tests so return true // Target passed the tests so return true
return false; return false;
@ -660,7 +637,7 @@ float EffectiveTargetingRange()
{ {
if (GetWeaponMode() == weapon_melee) if (GetWeaponMode() == weapon_melee)
{ {
return re::C_TFWeaponBaseMelee::GetSwingRange(RAW_ENT(LOCAL_W)); return re::C_TFWeaponBaseMelee::GetSwingRange(LOCAL_W);
// Pyros only have so much untill their flames hit // Pyros only have so much untill their flames hit
} }
else if (g_pLocalPlayer->weapon()->m_iClassID == CL_CLASS(CTFFlameThrower)) else if (g_pLocalPlayer->weapon()->m_iClassID == CL_CLASS(CTFFlameThrower))

View File

@ -486,6 +486,9 @@ DEFINE_HOOKED_METHOD(CreateMove, bool, void *this_, float input_sample_time,
cmd->viewangles.y); cmd->viewangles.y);
cmd->forwardmove = cos(yaw) * speed; cmd->forwardmove = cos(yaw) * speed;
cmd->sidemove = sin(yaw) * speed; cmd->sidemove = sin(yaw) * speed;
if (hacks::tf2::antibackstab::noaa)
if (cmd->viewangles.x >= 90 && cmd->viewangles.x <= 270)
cmd->forwardmove = -cmd->forwardmove;
} }
ret = false; ret = false;