antiaim from c++14 branch
This commit is contained in:
parent
ed3d38fc9b
commit
cc620ddf88
@ -40,8 +40,8 @@ CatVar::CatVar(CatVar_t type, std::string name, std::string defaults, std::strin
|
||||
g_UnregisteredCatVars.push(this);
|
||||
}
|
||||
|
||||
CatVar::CatVar(CatVar_t type, std::string name, std::string defaults, std::string desc_short, std::string desc_long, CatEnum& cat_enum)
|
||||
: type(type), name(name), defaults(defaults), desc_short(desc_short), desc_long(desc_long), enum_type(&cat_enum), restricted(true) {
|
||||
CatVar::CatVar(CatEnum& cat_enum, std::string name, std::string defaults, std::string desc_short, std::string desc_long)
|
||||
: type(CV_ENUM), name(name), defaults(defaults), desc_short(desc_short), desc_long(desc_long), enum_type(&cat_enum), restricted(true) {
|
||||
min = cat_enum.Minimum();
|
||||
max = cat_enum.Maximum();
|
||||
g_UnregisteredCatVars.push(this);
|
||||
|
@ -54,7 +54,7 @@ public:
|
||||
CatVar(CatVar_t type, std::string name, std::string defaults, std::string desc_short, std::string desc_long);
|
||||
CatVar(CatVar_t type, std::string name, std::string defaults, std::string desc_short, std::string desc_long, float max_val);
|
||||
CatVar(CatVar_t type, std::string name, std::string defaults, std::string desc_short, std::string desc_long, float min_val, float max_val);
|
||||
CatVar(CatVar_t type, std::string name, std::string defaults, std::string desc_short, std::string desc_long, CatEnum& cat_enum);
|
||||
CatVar(CatEnum& cat_enum, std::string name, std::string defaults, std::string desc_short, std::string desc_long);
|
||||
|
||||
inline explicit operator bool() const { return !!convar_parent->m_nValue; }
|
||||
inline explicit operator int() const { return convar_parent->m_nValue; }
|
||||
|
@ -22,7 +22,7 @@ CMenuWindow::CMenuWindow(std::string name, IWidget* parent) : CBaseWindow(name,
|
||||
AddChild(m_pTitle = new CTitleBar(this, "cathook menu"));
|
||||
}
|
||||
|
||||
#define ADDCVAR(x) tab->AddChild(new CCVarContainer(tab, x))
|
||||
#define ADDCVAR(x) tab->AddChild(new CCVarContainer(tab, (x)))
|
||||
#define ADDLABEL(x) tab->AddChild(new CTextLabel("label", tab, x, true))
|
||||
|
||||
void CMenuWindow::AddElements() {
|
||||
@ -171,14 +171,15 @@ void CMenuWindow::AddElements() {
|
||||
ADDCVAR(g_phBunnyhop->v_iAutoJumpSpeed);
|
||||
AddTab("antiaim", "Anti-Aim");
|
||||
tab = GetTab("antiaim");
|
||||
ADDCVAR(g_phAntiAim->v_bEnabled);
|
||||
ADDCVAR(g_phAntiAim->v_PitchMode);
|
||||
ADDCVAR(g_phAntiAim->v_flPitch);
|
||||
ADDCVAR(g_phAntiAim->v_YawMode);
|
||||
ADDCVAR(g_phAntiAim->v_flYaw);
|
||||
ADDCVAR(g_phAntiAim->v_flSpinSpeed);
|
||||
ADDCVAR(g_phAntiAim->v_bNoClamping);
|
||||
ADDCVAR(g_phAntiAim->v_flRoll);
|
||||
ADDCVAR(&hacks::shared::antiaim::enabled);
|
||||
/*ADDCVAR(&hacks::shared::antiaim::lisp);
|
||||
ADDCVAR(&hacks::shared::antiaim::yaw_mode;
|
||||
ADDCVAR(&hacks::shared::antiaim::yaw);
|
||||
ADDCVAR(&hacks::shared::antiaim::pitch);
|
||||
ADDCVAR(&hacks::shared::antiaim::pitch_mode);
|
||||
ADDCVAR(&hacks::shared::antiaim::no_clamping);
|
||||
ADDCVAR(&hacks::shared::antiaim::roll);
|
||||
ADDCVAR(&hacks::shared::antiaim::spin);*/
|
||||
AddTab("spam", "Spam/Killsay");
|
||||
tab = GetTab("spam");
|
||||
ADDLABEL("Spam");
|
||||
|
@ -57,7 +57,6 @@ bool hack::shutdown = false;
|
||||
|
||||
void hack::InitHacks() {
|
||||
ADD_HACK(AutoStrafe);
|
||||
ADD_HACK(AntiAim);
|
||||
if (TF) ADD_HACK(AntiDisguise);
|
||||
if (TF) ADD_HACK(AutoReflect);
|
||||
//ADD_HACK(FollowBot);
|
||||
@ -198,7 +197,6 @@ void hack::Shutdown() {
|
||||
if (hooks::hkStudioRender) hooks::hkStudioRender->Kill();
|
||||
ConVar_Unregister();
|
||||
DELETE_HACK(AutoStrafe);
|
||||
DELETE_HACK(AntiAim);
|
||||
if (TF) DELETE_HACK(AntiDisguise);
|
||||
if (TF) DELETE_HACK(AutoReflect);
|
||||
//DELETE_HACK(FollowBot);
|
||||
|
@ -275,7 +275,7 @@ void Aimbot::ProcessUserCmd(CUserCmd* cmd) {
|
||||
}
|
||||
if (charge >= v_fAutoShootHuntsmanCharge->GetFloat()) {
|
||||
cmd->buttons &= ~IN_ATTACK;
|
||||
g_phAntiAim->AddSafeTicks(3);
|
||||
hacks::shared::antiaim::SetSafeSpace(3);
|
||||
}
|
||||
if (!(cmd->buttons & IN_ATTACK) && m_bSilentHuntsman) {
|
||||
Aim(target_highest, cmd);
|
||||
|
@ -10,78 +10,89 @@
|
||||
#include "../common.h"
|
||||
#include "../sdk.h"
|
||||
|
||||
DEFINE_HACK_SINGLETON(AntiAim);
|
||||
namespace hacks { namespace shared { namespace antiaim {
|
||||
|
||||
AntiAim::AntiAim() {
|
||||
this->v_bEnabled = new CatVar(CV_SWITCH, "aa_enabled", "0", "Enable AntiAim", NULL, "Master AntiAim switch");
|
||||
this->v_flPitch = new CatVar(CV_FLOAT, "aa_pitch", "-89.0", "Pitch", NULL, "Static pitch (up/down)", true, 89.0, -89.0);
|
||||
this->v_flYaw = new CatVar(CV_FLOAT, "aa_yaw", "0.0", "Yaw", NULL, "Static yaw (left/right)", true, 360.0);
|
||||
this->v_flSpinSpeed = new CatVar(CV_FLOAT, "aa_spin", "10.0", "Spin speed", NULL, "Spin speed (in deg/sec)");
|
||||
this->v_PitchMode = new CatVar(CV_ENUM, "aa_pitch_mode", "1", "Pitch mode", new CatEnum({ "KEEP", "STATIC", "RANDOM" }), "Pitch mode");
|
||||
this->v_YawMode = new CatVar(CV_ENUM, "aa_yaw_mode", "3", "Yaw mode", new CatEnum({ "KEEP", "STATIC", "RANDOM", "SPIN" }), "Yaw mode");
|
||||
this->v_bNoClamping = new CatVar(CV_SWITCH, "aa_no_clamp", "0", "Don't clamp angles", NULL, "Use this with STATIC mode for unclamped manual angles");
|
||||
this->v_flRoll = new CatVar(CV_FLOAT, "aa_roll", "0", "Roll", NULL, "Roll angle. ???", true, -180, 180);
|
||||
AddSafeTicks(0);
|
||||
CatVar enabled(CV_SWITCH, "aa_enabled", "0", "Anti-Aim", "Master AntiAim switch");
|
||||
CatVar yaw(CV_FLOAT, "aa_yaw", "0.0", "Yaw", "Static yaw (left/right)", 360.0);
|
||||
CatVar pitch(CV_FLOAT, "aa_pitch", "-89.0", "Pitch", "Static pitch (up/down)", -89.0, 89.0);
|
||||
CatEnum yaw_mode_enum({ "KEEP", "STATIC", "RANDOM", "SPIN" });
|
||||
CatEnum pitch_mode_enum({ "KEEP", "STATIC", "RANDOM" });
|
||||
CatVar yaw_mode(yaw_mode_enum, "aa_yaw_mode", "3", "Yaw mode", "Yaw mode");
|
||||
CatVar pitch_mode(pitch_mode_enum, "aa_pitch_mode", "1", "Pitch mode", "Pitch mode");
|
||||
CatVar roll(CV_FLOAT, "aa_roll", "0", "Roll", "Roll angle (viewangles.z)", -180, 180);
|
||||
CatVar no_clamping(CV_SWITCH, "aa_no_clamp", "0", "Don't clamp angles", "Use this with STATIC mode for unclamped manual angles");
|
||||
CatVar spin(CV_FLOAT, "aa_spin", "10.0", "Spin speed", "Spin speed (degrees/second)");
|
||||
CatVar lisp(CV_SWITCH, "aa_lisp", "0", "Lisp angles", "Big numbers");
|
||||
|
||||
float cur_yaw = 0.0f;
|
||||
int safe_space = 0;
|
||||
|
||||
void SetSafeSpace(int safespace) {
|
||||
if (safespace > safe_space) safe_space = safespace;
|
||||
}
|
||||
|
||||
float yaw = -180;
|
||||
float pitch = -89;
|
||||
|
||||
void AntiAim::AddSafeTicks(int ticks) {
|
||||
m_iSafeTicks = ticks;
|
||||
}
|
||||
|
||||
void AntiAim::ProcessUserCmd(CUserCmd* cmd) {
|
||||
if (!this->v_bEnabled->GetBool()) return;
|
||||
if (cmd->buttons & IN_USE) {
|
||||
return;
|
||||
}
|
||||
if (CE_BAD(LOCAL_W)) return;
|
||||
|
||||
if ((cmd->buttons & IN_ATTACK) && (LOCAL_W->m_iClassID != g_pClassID->CTFCompoundBow)) {
|
||||
if (CanShoot()) return;
|
||||
}
|
||||
if ((cmd->buttons & IN_ATTACK2) && g_pLocalPlayer->weapon()->m_iClassID == g_pClassID->CTFLunchBox) return;
|
||||
|
||||
weaponmode mode = GetWeaponMode(g_pLocalPlayer->entity);
|
||||
if (mode == weapon_melee || mode == weapon_throwable || (mode == weapon_projectile && (LOCAL_W->m_iClassID != g_pClassID->CTFCompoundBow))) {
|
||||
if ((cmd->buttons & IN_ATTACK) || (cmd->buttons & IN_ATTACK2) || g_pLocalPlayer->bAttackLastTick) {
|
||||
AddSafeTicks(4);
|
||||
bool ShouldAA(CUserCmd* cmd) {
|
||||
if (!enabled) return false;
|
||||
if (cmd->buttons & IN_USE) return false;
|
||||
if (cmd->buttons & IN_ATTACK) {
|
||||
if (!(TF2 && g_pLocalPlayer->weapon()->m_iClassID == g_pClassID->CTFCompoundBow)) {
|
||||
if (CanShoot()) return false;
|
||||
}
|
||||
}
|
||||
if ((LOCAL_W->m_iClassID == g_pClassID->CTFCompoundBow) && !(cmd->buttons & IN_ATTACK)) {
|
||||
if (g_pLocalPlayer->bAttackLastTick) AddSafeTicks(4);
|
||||
if ((cmd->buttons & IN_ATTACK2) && g_pLocalPlayer->weapon()->m_iClassID == g_pClassID->CTFLunchBox) return false;
|
||||
switch (GetWeaponMode(g_pLocalPlayer->entity)) {
|
||||
case weapon_projectile:
|
||||
if (g_pLocalPlayer->weapon()->m_iClassID == g_pClassID->CTFCompoundBow) {
|
||||
if (!(cmd->buttons & IN_ATTACK)) {
|
||||
if (g_pLocalPlayer->bAttackLastTick) SetSafeSpace(4);
|
||||
}
|
||||
break;
|
||||
}
|
||||
/* no break */
|
||||
case weapon_melee:
|
||||
case weapon_throwable:
|
||||
if ((cmd->buttons & (IN_ATTACK | IN_ATTACK2)) || g_pLocalPlayer->bAttackLastTick) {
|
||||
SetSafeSpace(4);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (safe_space) {
|
||||
safe_space--;
|
||||
if (safe_space < 0) safe_space = 0;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
float p = cmd->viewangles.x;
|
||||
float y = cmd->viewangles.y;
|
||||
switch (this->v_YawMode->GetInt()) {
|
||||
void ProcessUserCmd(CUserCmd* cmd) {
|
||||
if (!ShouldAA(cmd)) return;
|
||||
float& p = cmd->viewangles.x;
|
||||
float& y = cmd->viewangles.y;
|
||||
switch ((int)yaw_mode) {
|
||||
case 1: // FIXED
|
||||
y = this->v_flYaw->GetFloat();
|
||||
y = (float)yaw;
|
||||
break;
|
||||
case 2: // RANDOM
|
||||
y = RandFloatRange(-180.0f, 180.0f);
|
||||
break;
|
||||
case 3: // SPIN
|
||||
yaw += v_flSpinSpeed->GetFloat();
|
||||
if (yaw > 180) yaw = -180;
|
||||
y = yaw;
|
||||
cur_yaw += (float)spin;
|
||||
if (cur_yaw > 180) cur_yaw = -180;
|
||||
y = cur_yaw;
|
||||
break;
|
||||
}
|
||||
switch (this->v_PitchMode->GetInt()) {
|
||||
switch ((int)pitch_mode) {
|
||||
case 1:
|
||||
p = this->v_flPitch->GetFloat();
|
||||
p = (float)pitch;
|
||||
break;
|
||||
case 2:
|
||||
p = RandFloatRange(-89.0f, 89.0f);
|
||||
break;
|
||||
}
|
||||
|
||||
Vector angl = Vector(p, y, 0);
|
||||
if (!v_bNoClamping->GetBool()) fClampAngle(angl);
|
||||
if (v_flRoll->GetBool()) angl.z = v_flRoll->GetFloat();
|
||||
if (!m_iSafeTicks) {
|
||||
cmd->viewangles = angl;
|
||||
g_pLocalPlayer->bUseSilentAngles = true;
|
||||
} else m_iSafeTicks--;
|
||||
if (!no_clamping) fClampAngle(cmd->viewangles);
|
||||
if (roll) cmd->viewangles.z = (float)roll;
|
||||
g_pLocalPlayer->bUseSilentAngles = true;
|
||||
}
|
||||
|
||||
}}}
|
||||
|
@ -8,27 +8,29 @@
|
||||
#ifndef ANTIAIM_H_
|
||||
#define ANTIAIM_H_
|
||||
|
||||
#include "IHack.h"
|
||||
class CatVar;
|
||||
class CUserCmd;
|
||||
|
||||
class AntiAim : public IHack {
|
||||
public:
|
||||
AntiAim();
|
||||
namespace hacks { namespace shared { namespace antiaim {
|
||||
|
||||
virtual void ProcessUserCmd(CUserCmd*) override;
|
||||
// TODO paste AA from AimTux
|
||||
|
||||
void AddSafeTicks(int ticks);
|
||||
int m_iSafeTicks;
|
||||
extern CatVar enabled;
|
||||
extern CatVar yaw;
|
||||
extern CatVar pitch;
|
||||
extern CatVar yaw_mode;
|
||||
extern CatVar pitch_mode;
|
||||
extern CatVar roll;
|
||||
extern CatVar no_clamping;
|
||||
extern CatVar spin;
|
||||
extern CatVar lisp;
|
||||
|
||||
CatVar* v_bEnabled;
|
||||
CatVar* v_flSpinSpeed;
|
||||
CatVar* v_flYaw;
|
||||
CatVar* v_flPitch;
|
||||
CatVar* v_PitchMode;
|
||||
CatVar* v_YawMode;
|
||||
CatVar* v_bNoClamping;
|
||||
CatVar* v_flRoll;
|
||||
};
|
||||
extern int safe_space;
|
||||
|
||||
DECLARE_HACK_SINGLETON(AntiAim);
|
||||
void SetSafeSpace(int safespace);
|
||||
bool ShouldAA(CUserCmd* cmd);
|
||||
void ProcessUserCmd(CUserCmd* cmd);
|
||||
|
||||
}}}
|
||||
|
||||
#endif /* ANTIAIM_H_ */
|
||||
|
@ -101,7 +101,7 @@ bool CreateMove_hook(void* thisptr, float inputSample, CUserCmd* cmd) {
|
||||
SAFE_CALL(HACK_PROCESS_USERCMD(AutoStrafe, cmd));
|
||||
SAFE_CALL(HACK_PROCESS_USERCMD(Aimbot, cmd));
|
||||
SAFE_CALL(HACK_PROCESS_USERCMD(Airstuck, cmd));
|
||||
SAFE_CALL(HACK_PROCESS_USERCMD(AntiAim, cmd));
|
||||
SAFE_CALL(hacks::shared::antiaim::ProcessUserCmd(cmd));
|
||||
if (TF) SAFE_CALL(HACK_PROCESS_USERCMD(AutoSticky, cmd));
|
||||
if (TF) SAFE_CALL(HACK_PROCESS_USERCMD(AutoReflect, cmd));
|
||||
SAFE_CALL(HACK_PROCESS_USERCMD(Triggerbot, cmd));
|
||||
|
@ -135,7 +135,6 @@ void LevelInit_hook(void* thisptr, const char* newmap) {
|
||||
interfaces::engineClient->ExecuteClientCmd("exec cat_matchexec");
|
||||
LEVEL_INIT(Aimbot);
|
||||
LEVEL_INIT(Airstuck);
|
||||
LEVEL_INIT(AntiAim);
|
||||
if (TF) LEVEL_INIT(AntiDisguise);
|
||||
if (TF) LEVEL_INIT(AutoHeal);
|
||||
if (TF) LEVEL_INIT(AutoReflect);
|
||||
@ -158,7 +157,6 @@ void LevelShutdown_hook(void* thisptr) {
|
||||
g_Settings.bInvalid = true;
|
||||
LEVEL_SHUTDOWN(Aimbot);
|
||||
LEVEL_SHUTDOWN(Airstuck);
|
||||
LEVEL_SHUTDOWN(AntiAim);
|
||||
if (TF) LEVEL_SHUTDOWN(AntiDisguise);
|
||||
if (TF) LEVEL_SHUTDOWN(AutoHeal);
|
||||
if (TF) LEVEL_SHUTDOWN(AutoReflect);
|
||||
|
Reference in New Issue
Block a user