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

View File

@ -22,12 +22,13 @@ public:
self, offsets::PlatformOffset(522, offsets::undefined, 522),
0)(self, trace);
}
inline static float GetSwingRange(IClientEntity *self)
inline static float GetSwingRange(CachedEntity *self)
{
typedef float (*fn_t)(IClientEntity *);
return vfunc<fn_t>(
self, offsets::PlatformOffset(520, offsets::undefined, 520),
0)(self);
int ret = 48.0f;
if (self->m_iClassID == CL_CLASS(CTFSword) ||
self->m_iClassID == CL_CLASS(CTFKatana))
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
// implementing it, these should be made non-static
int closest;
float closest_fov, fov;
float closest_fov, fov = 0.0f;
closest = -1;
closest_fov = 256;
@ -1186,7 +1186,7 @@ bool UpdateAimkey()
float EffectiveTargetingRange()
{
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))
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");
static CatVar silent(CV_SWITCH, "antibackstab_silent", "1", "Silent",
"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");
void SayNope()
@ -100,35 +100,38 @@ void CreateMove()
if (!enabled)
return;
spy = ClosestSpy();
spy = ClosestSpy();
ConVar *pitchdown = g_ICvar->FindVar("cl_pitchdown");
static int normal_val = pitchdown->GetInt();
if (spy)
{
noaa = true;
const Vector &A = LOCAL_E->m_vecOrigin;
const Vector &B = spy->m_vecOrigin;
diff = (A - B);
yaw2 = acos(diff.x / diff.Length()) * 180.0f / PI;
if (diff.y < 0)
yaw2 = -yaw2;
if (yaw2 < -180)
yaw2 += 360;
if (yaw2 > 180)
yaw2 -= 360;
resultangle = -180 + yaw2;
if (resultangle < -180)
resultangle += 360;
g_pUserCmd->viewangles.y = resultangle;
noaa = true;
// const Vector &A = LOCAL_E->m_vecOrigin;
// const Vector &B = spy->m_vecOrigin;
// diff = (A - B);
// yaw2 = acos(diff.x / diff.Length()) * 180.0f / PI;
// if (diff.y < 0)
// yaw2 = -yaw2;
// if (yaw2 < -180)
// yaw2 += 360;
// if (yaw2 > 180)
// yaw2 -= 360;
// resultangle = -180 + yaw2;
// if (resultangle < -180)
// resultangle += 360;
// g_pUserCmd->viewangles.y = resultangle;
pitchdown->SetValue(180);
g_pUserCmd->viewangles.x = 140.0f;
if (silent)
{
// This isn't a spy aimbot.
if (!(g_pUserCmd->buttons & IN_ATTACK))
g_pLocalPlayer->bUseSilentAngles = true;
}
g_pLocalPlayer->bUseSilentAngles = true;
if (sayno)
SayNope();
}
else
{
pitchdown->SetValue(normal_val);
noaa = false;
}
}
void PaintTraverse()

View File

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

View File

@ -351,53 +351,30 @@ bool IsTargetStateGood(CachedEntity *entity)
// Check for null
if (hb)
{
for (int i = -1; i < 12; i++)
// Get the min and max for the hitbox
Vector minz(std::min(hb->min.x, hb->max.x),
std::min(hb->min.y, hb->max.y),
std::min(hb->min.z, hb->max.z));
Vector maxz(std::max(hb->min.x, hb->max.x),
std::max(hb->min.y, hb->max.y),
std::max(hb->min.z, hb->max.z));
// Shrink the hitbox here
Vector size = maxz - minz;
Vector smod = size * 0.05f * (int) accuracy;
// Save the changes to the vectors
minz += smod;
maxz -= smod;
// Trace and test if it hits the smaller hitbox, if it fails
// we
// return false
Vector hit;
if (CheckLineBox(minz, maxz, g_pLocalPlayer->v_Eye, forward,
hit))
{
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
Vector minz(std::min(hb->min.x, hb->max.x),
std::min(hb->min.y, hb->max.y),
std::min(hb->min.z, hb->max.z));
Vector maxz(std::max(hb->min.x, hb->max.x),
std::max(hb->min.y, hb->max.y),
std::max(hb->min.z, hb->max.z));
// Shrink the hitbox here
Vector size = maxz - minz;
Vector smod = size * 0.05f * (int) accuracy;
// Save the changes to the vectors
minz += smod;
maxz -= smod;
// Trace and test if it hits the smaller hitbox, if it fails
// we
// return false
Vector hit;
if (CheckLineBox(minz, maxz, g_pLocalPlayer->v_Eye, forward,
hit))
{
return true;
}
return true;
}
}
}
@ -660,7 +637,7 @@ float EffectiveTargetingRange()
{
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
}
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->forwardmove = cos(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;