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
{
extern bool noaa;
void CreateMove();
void PaintTraverse();
}

View File

@ -22,5 +22,9 @@ public:
self, offsets::PlatformOffset(522, offsets::undefined, 522),
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()
{
if (GetWeaponMode() == weapon_melee)
return 100.0f; // Melees use a close range, TODO add dynamic range for
// demoknight swords
return (float) re::C_TFWeaponBaseMelee::GetSwingRange(RAW_ENT(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

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

View File

@ -14,12 +14,14 @@ namespace tf2
{
namespace antibackstab
{
bool noaa = false;
static CatVar enabled(CV_SWITCH, "antibackstab", "0", "Enable",
"Main anti-backstab switch");
static CatVar distance(CV_FLOAT, "antibackstab_distance", "200", "Distance",
"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");
void SayNope()
@ -32,6 +34,7 @@ void SayNope()
hack::ExecuteCommand("voicemenu 0 7");
last_say = g_GlobalVars->curtime;
}
float GetAngle(CachedEntity *spy)
{
float yaw, yaw2, anglediff;
@ -52,6 +55,7 @@ float GetAngle(CachedEntity *spy)
// yaw - yaw2);
return anglediff;
}
CachedEntity *ClosestSpy()
{
CachedEntity *closest, *ent;
@ -87,6 +91,7 @@ CachedEntity *ClosestSpy()
}
return closest;
}
void CreateMove()
{
CachedEntity *spy;
@ -96,24 +101,56 @@ void CreateMove()
if (!enabled)
return;
spy = ClosestSpy();
if (spy && CE_GOOD(spy))
if (spy)
{
ConVar *var = g_ICvar->FindVar("cl_pitchdown");
if (!var)
return;
Vector angles = CE_VECTOR(spy, netvar.angEyeAngles);
var->SetValue(360.0f);
g_pUserCmd->viewangles.x = angles.x + 180.0f;
g_pLocalPlayer->bUseSilentAngles = true;
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;
if (silent)
{
// This isn't a spy aimbot.
if (!(g_pUserCmd->buttons & IN_ATTACK))
g_pLocalPlayer->bUseSilentAngles = true;
}
if (sayno)
SayNope();
}
else if (!spy || CE_BAD(spy))
{
ConVar *var = g_ICvar->FindVar("cl_pitchdown");
var->SetValue(89);
}
else
noaa = false;
}
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
float EffectiveTargetingRange()
{
// Melees use a close range, TODO add dynamic range for demoknight swords
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
}
else if (g_pLocalPlayer->weapon()->m_iClassID == CL_CLASS(CTFFlameThrower))