minor improvements

This commit is contained in:
BenCat07 2018-04-12 15:27:58 +02:00
parent 2b007b3134
commit 720cabd2d9
6 changed files with 62 additions and 21 deletions

View File

@ -14,7 +14,7 @@ namespace tf2
{ {
namespace antibackstab namespace antibackstab
{ {
extern bool noaa;
void CreateMove(); void CreateMove();
void PaintTraverse(); void PaintTraverse();
} }

View File

@ -22,5 +22,9 @@ public:
self, offsets::PlatformOffset(522, offsets::undefined, 522), self, offsets::PlatformOffset(522, offsets::undefined, 522),
0)(self, trace); 0)(self, trace);
} }
inline static int GetSwingRange(IClientEntity* self) {
typedef int (*fn_t)(IClientEntity*);
return vfunc<fn_t>(self, offsets::PlatformOffset(520, offsets::undefined, 520), 0)(self);
}
}; };
} }

View File

@ -1127,8 +1127,7 @@ bool UpdateAimkey()
float EffectiveTargetingRange() float EffectiveTargetingRange()
{ {
if (GetWeaponMode() == weapon_melee) if (GetWeaponMode() == weapon_melee)
return 100.0f; // Melees use a close range, TODO add dynamic range for return (float) re::C_TFWeaponBaseMelee::GetSwingRange(RAW_ENT(LOCAL_W));
// demoknight swords
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

@ -252,6 +252,8 @@ bool ShouldAA(CUserCmd *cmd)
{ {
if (!enabled) if (!enabled)
return false; return false;
if (hacks::tf2::antibackstab::noaa)
return false;
if (cmd->buttons & IN_USE) if (cmd->buttons & IN_USE)
return false; return false;
if ((cmd->buttons & IN_ATTACK) && if ((cmd->buttons & IN_ATTACK) &&

View File

@ -14,12 +14,14 @@ namespace tf2
{ {
namespace antibackstab namespace antibackstab
{ {
bool noaa = false;
static CatVar enabled(CV_SWITCH, "antibackstab", "0", "Enable", static CatVar enabled(CV_SWITCH, "antibackstab", "0", "Enable",
"Main anti-backstab switch"); "Main anti-backstab switch");
static CatVar distance(CV_FLOAT, "antibackstab_distance", "200", "Distance", static CatVar distance(CV_FLOAT, "antibackstab_distance", "200", "Distance",
"Distance Until anti-backstab reacts"); "Distance Until anti-backstab reacts");
static CatVar angle(CV_FLOAT, "antibackstab_angle", "90", "Detection Angle"); 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 sayno(CV_SWITCH, "antibackstab_nope", "0", "Nope!", "Memes"); static CatVar sayno(CV_SWITCH, "antibackstab_nope", "0", "Nope!", "Memes");
void SayNope() void SayNope()
@ -32,6 +34,7 @@ void SayNope()
hack::ExecuteCommand("voicemenu 0 7"); hack::ExecuteCommand("voicemenu 0 7");
last_say = g_GlobalVars->curtime; last_say = g_GlobalVars->curtime;
} }
float GetAngle(CachedEntity *spy) float GetAngle(CachedEntity *spy)
{ {
float yaw, yaw2, anglediff; float yaw, yaw2, anglediff;
@ -52,6 +55,7 @@ float GetAngle(CachedEntity *spy)
// yaw - yaw2); // yaw - yaw2);
return anglediff; return anglediff;
} }
CachedEntity *ClosestSpy() CachedEntity *ClosestSpy()
{ {
CachedEntity *closest, *ent; CachedEntity *closest, *ent;
@ -87,6 +91,7 @@ CachedEntity *ClosestSpy()
} }
return closest; return closest;
} }
void CreateMove() void CreateMove()
{ {
CachedEntity *spy; CachedEntity *spy;
@ -96,24 +101,56 @@ void CreateMove()
if (!enabled) if (!enabled)
return; return;
spy = ClosestSpy(); spy = ClosestSpy();
if (spy && CE_GOOD(spy)) if (spy)
{ {
ConVar *var = g_ICvar->FindVar("cl_pitchdown"); noaa = true;
if (!var) const Vector &A = LOCAL_E->m_vecOrigin;
return; const Vector &B = spy->m_vecOrigin;
Vector angles = CE_VECTOR(spy, netvar.angEyeAngles); diff = (A - B);
yaw2 = acos(diff.x / diff.Length()) * 180.0f / PI;
var->SetValue(360.0f); if (diff.y < 0)
g_pUserCmd->viewangles.x = angles.x + 180.0f; yaw2 = -yaw2;
g_pLocalPlayer->bUseSilentAngles = true; if (yaw2 < -180)
yaw2 += 360;
if (yaw2 > 180)
yaw2 -= 360;
resultangle = -180 + yaw2;
if (resultangle < -180)
resultangle += 360;
g_pUserCmd->viewangles.y = resultangle;
if (silent)
{
// This isn't a spy aimbot.
if (!(g_pUserCmd->buttons & IN_ATTACK))
g_pLocalPlayer->bUseSilentAngles = true;
}
if (sayno) if (sayno)
SayNope(); SayNope();
} }
else if (!spy || CE_BAD(spy)) else
{ noaa = false;
ConVar *var = g_ICvar->FindVar("cl_pitchdown"); }
var->SetValue(89);
} void PaintTraverse()
{
if (!enabled)
return;
/*CachedEntity* spy = ClosestSpy();
if (!spy) return;
const Vector& A = LOCAL_E->m_vecOrigin;
const Vector& B = spy->m_vecOrigin;
const float yaw = g_pLocalPlayer->v_OrigViewangles.y;
const Vector diff = (A - B);
float yaw2 = acos(diff.x / diff.Length()) * 180.0f / PI;
if (diff.y < 0) yaw2 = -yaw2;
float anglediff = yaw - yaw2;
if (anglediff > 180) anglediff -= 360;
if (anglediff < -180) anglediff += 360;
AddSideString(format("closest: ", B.x, ' ', B.y, ' ', B.z));
AddSideString(format("yaw: ", yaw));
AddSideString(format("diff: ", diff.x, ' ', diff.y, ' ', diff.z));
AddSideString(format("yaw2: ", yaw2));
AddSideString(format("anglediff: ", anglediff));*/
} }
} }
} }

View File

@ -580,10 +580,9 @@ bool UpdateAimkey()
// Func to find value of how far to target ents // Func to find value of how far to target ents
float EffectiveTargetingRange() float EffectiveTargetingRange()
{ {
// Melees use a close range, TODO add dynamic range for demoknight swords
if (GetWeaponMode() == weapon_melee) if (GetWeaponMode() == weapon_melee)
{ {
return 100.0f; return re::C_TFWeaponBaseMelee::GetSwingRange(RAW_ENT(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))