Fix Antibackstab
This commit is contained in:
parent
1a366efc92
commit
c825d9a749
@ -15,6 +15,10 @@ static settings::Bool silent{ "antibackstab.silent", "1" };
|
|||||||
static settings::Float angle{ "antibackstab.angle", "107.5" };
|
static settings::Float angle{ "antibackstab.angle", "107.5" };
|
||||||
static settings::Bool sayno{ "antibackstab.nope", "0" };
|
static settings::Bool sayno{ "antibackstab.nope", "0" };
|
||||||
|
|
||||||
|
namespace hacks::tf2::autobackstab
|
||||||
|
{
|
||||||
|
extern bool angleCheck(CachedEntity *from, CachedEntity *to, std::optional<Vector> target_pos, Vector from_angle);
|
||||||
|
}
|
||||||
namespace hacks::tf2::antibackstab
|
namespace hacks::tf2::antibackstab
|
||||||
{
|
{
|
||||||
bool noaa = false;
|
bool noaa = false;
|
||||||
@ -117,11 +121,12 @@ void CreateMove()
|
|||||||
noaa = true;
|
noaa = true;
|
||||||
if (current_user_cmd->buttons & IN_ATTACK)
|
if (current_user_cmd->buttons & IN_ATTACK)
|
||||||
return;
|
return;
|
||||||
const Vector &A = LOCAL_E->m_vecOrigin();
|
Vector spy_angle;
|
||||||
const Vector &B = spy->m_vecOrigin();
|
spy_angle = CE_VECTOR(spy, netvar.m_angEyeAngles);
|
||||||
diff = (A - B);
|
fClampAngle(spy_angle);
|
||||||
if (diff.y < 0 || CE_INT(spy, netvar.iClass) == tf_class::tf_heavy)
|
bool couldbebackstabbed = hacks::tf2::autobackstab::angleCheck(spy, LOCAL_E, std::nullopt, spy_angle);
|
||||||
current_user_cmd->viewangles.x = 180.0f;
|
if (couldbebackstabbed || CE_INT(spy, netvar.iClass) == tf_class::tf_heavy)
|
||||||
|
current_user_cmd->viewangles.x = 150.0f;
|
||||||
if (silent)
|
if (silent)
|
||||||
g_pLocalPlayer->bUseSilentAngles = true;
|
g_pLocalPlayer->bUseSilentAngles = true;
|
||||||
if (sayno)
|
if (sayno)
|
||||||
|
@ -15,6 +15,37 @@ namespace hacks::tf2::autobackstab
|
|||||||
static settings::Bool enabled("autobackstab.enabled", "false");
|
static settings::Bool enabled("autobackstab.enabled", "false");
|
||||||
static settings::Int mode("autobackstab.mode", "0");
|
static settings::Int mode("autobackstab.mode", "0");
|
||||||
|
|
||||||
|
bool angleCheck(CachedEntity *from, CachedEntity *to, std::optional<Vector> target_pos, Vector from_angle)
|
||||||
|
{
|
||||||
|
Vector tarAngle = CE_VECTOR(to, netvar.m_angEyeAngles);
|
||||||
|
|
||||||
|
Vector wsc_spy_to_victim;
|
||||||
|
if (target_pos)
|
||||||
|
wsc_spy_to_victim = *target_pos - from->m_vecOrigin();
|
||||||
|
else
|
||||||
|
wsc_spy_to_victim = to->m_vecOrigin() - from->m_vecOrigin();
|
||||||
|
wsc_spy_to_victim.z = 0;
|
||||||
|
wsc_spy_to_victim.NormalizeInPlace();
|
||||||
|
|
||||||
|
Vector eye_spy;
|
||||||
|
AngleVectors2(VectorToQAngle(from_angle), &eye_spy);
|
||||||
|
eye_spy.z = 0;
|
||||||
|
eye_spy.NormalizeInPlace();
|
||||||
|
|
||||||
|
Vector eye_victim;
|
||||||
|
AngleVectors2(VectorToQAngle(tarAngle), &eye_victim);
|
||||||
|
eye_victim.z = 0;
|
||||||
|
eye_victim.NormalizeInPlace();
|
||||||
|
|
||||||
|
if (DotProduct(wsc_spy_to_victim, eye_victim) <= 0.0f)
|
||||||
|
return false;
|
||||||
|
if (DotProduct(wsc_spy_to_victim, eye_spy) <= 0.5f)
|
||||||
|
return false;
|
||||||
|
if (DotProduct(eye_spy, eye_victim) <= -0.3f)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static bool angleCheck(CachedEntity *target, std::optional<Vector> target_pos, Vector local_angle)
|
static bool angleCheck(CachedEntity *target, std::optional<Vector> target_pos, Vector local_angle)
|
||||||
{
|
{
|
||||||
Vector tarAngle = CE_VECTOR(target, netvar.m_angEyeAngles);
|
Vector tarAngle = CE_VECTOR(target, netvar.m_angEyeAngles);
|
||||||
|
Reference in New Issue
Block a user