Improve anti-backstab
This commit is contained in:
parent
f5d4e8a4a0
commit
0d538523bf
@ -19,8 +19,6 @@ 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 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");
|
||||
|
||||
@ -34,7 +32,6 @@ void SayNope()
|
||||
hack::ExecuteCommand("voicemenu 0 7");
|
||||
last_say = g_GlobalVars->curtime;
|
||||
}
|
||||
|
||||
float GetAngle(CachedEntity *spy)
|
||||
{
|
||||
float yaw, yaw2, anglediff;
|
||||
@ -55,7 +52,6 @@ float GetAngle(CachedEntity *spy)
|
||||
// yaw - yaw2);
|
||||
return anglediff;
|
||||
}
|
||||
|
||||
CachedEntity *ClosestSpy()
|
||||
{
|
||||
CachedEntity *closest, *ent;
|
||||
@ -91,7 +87,8 @@ CachedEntity *ClosestSpy()
|
||||
}
|
||||
return closest;
|
||||
}
|
||||
|
||||
static CatVar test(CV_FLOAT, "a_t", "180", "");
|
||||
static CatVar test2(CV_SWITCH, "a_t2", "0", "");
|
||||
void CreateMove()
|
||||
{
|
||||
CachedEntity *spy;
|
||||
@ -101,53 +98,24 @@ void CreateMove()
|
||||
if (!enabled)
|
||||
return;
|
||||
spy = ClosestSpy();
|
||||
if (spy)
|
||||
static float backup;
|
||||
if (spy && CE_GOOD(spy))
|
||||
{
|
||||
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))
|
||||
ConVar *var = g_ICvar->FindVar("cl_pitchdown");
|
||||
if (!var)
|
||||
return;
|
||||
if (!backup)
|
||||
backup = var->GetFloat();
|
||||
var->SetValue(140.0f);
|
||||
g_pUserCmd->viewangles.x = 140.0f;
|
||||
g_pLocalPlayer->bUseSilentAngles = true;
|
||||
}
|
||||
if (sayno)
|
||||
SayNope();
|
||||
}
|
||||
}
|
||||
|
||||
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));*/
|
||||
else if (!spy || CE_BAD(spy)) {
|
||||
ConVar *var = g_ICvar->FindVar("cl_pitchdown");
|
||||
var->SetValue(backup);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -437,8 +437,8 @@ void CreateMove()
|
||||
g_pLocalPlayer->weapon()->m_iClassID != lastwep)
|
||||
nextattack =
|
||||
CE_FLOAT(g_pLocalPlayer->weapon(), netvar.flNextPrimaryAttack);
|
||||
if (servertime - nextattack > 30.0f)
|
||||
nextattack = servertime - 30.0f;
|
||||
if (servertime - nextattack > 75.0f)
|
||||
nextattack = servertime - 75.0f;
|
||||
if (doom && servertime - nextattack > 0.0f &&
|
||||
(g_pUserCmd->buttons & IN_ATTACK ||
|
||||
g_pUserCmd->buttons & IN_ATTACK2))
|
||||
|
@ -702,7 +702,6 @@ static const std::string list_tf2 = R"(
|
||||
"antibackstab"
|
||||
"antibackstab_nope"
|
||||
"antibackstab_angle"
|
||||
"antibackstab_silent"
|
||||
"antibackstab_distance"
|
||||
]
|
||||
"Spyalert" [
|
||||
|
Reference in New Issue
Block a user