Skip to content
This repository has been archived by the owner on Nov 5, 2018. It is now read-only.

Closest bone #745

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/ATGUI/Tabs/aimbottab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ static ItemDefinitionIndex currentWeapon = ItemDefinitionIndex::INVALID;
static bool enabled = false;
static bool silent = false;
static bool friendly = false;
static bool closestBone = false;
static Bone bone = Bone::BONE_HEAD;
static ButtonCode_t aimkey = ButtonCode_t::MOUSE_MIDDLE;
static bool aimkeyOnly = false;
Expand Down Expand Up @@ -46,6 +47,7 @@ void UI::ReloadWeaponSettings()
enabled = Settings::Aimbot::weapons.at(index).enabled;
silent = Settings::Aimbot::weapons.at(index).silent;
friendly = Settings::Aimbot::weapons.at(index).friendly;
closestBone = Settings::Aimbot::weapons.at(index).closestBone;
bone = Settings::Aimbot::weapons.at(index).bone;
aimkey = Settings::Aimbot::weapons.at(index).aimkey;
aimkeyOnly = Settings::Aimbot::weapons.at(index).aimkeyOnly;
Expand Down Expand Up @@ -88,7 +90,7 @@ void UI::UpdateWeaponSettings()
Settings::Aimbot::weapons[currentWeapon] = AimbotWeapon_t();

AimbotWeapon_t settings = {
enabled, silent, friendly, bone, aimkey, aimkeyOnly,
enabled, silent, friendly, closestBone, bone, aimkey, aimkeyOnly,
smoothEnabled, smoothValue, smoothType, smoothSaltEnabled, smoothSaltMultiplier,
errorMarginEnabled, errorMarginValue,
autoAimEnabled, autoAimValue, aimStepEnabled, aimStepValue,
Expand Down Expand Up @@ -160,6 +162,9 @@ void Aimbot::RenderTab()
{
ImGui::Text("Target");
ImGui::Separator();
if (ImGui::Checkbox("Closest Bone", &closestBone))
UI::UpdateWeaponSettings();
SetTooltip("Aims at the bone closest to your crosshair");
ImGui::Columns(2, NULL, true);
{
if (ImGui::Checkbox("Friendly", &friendly))
Expand Down
33 changes: 29 additions & 4 deletions src/Hacks/aimbot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
bool Settings::Aimbot::enabled = false;
bool Settings::Aimbot::silent = false;
bool Settings::Aimbot::friendly = false;
bool Settings::Aimbot::closestBone = false;
Bone Settings::Aimbot::bone = Bone::BONE_HEAD;
ButtonCode_t Settings::Aimbot::aimkey = ButtonCode_t::MOUSE_MIDDLE;
bool Settings::Aimbot::aimkeyOnly = false;
Expand Down Expand Up @@ -58,7 +59,7 @@ std::unordered_map<Hitbox, std::vector<const char*>, Util::IntHash<Hitbox>> hitb
};

std::unordered_map<ItemDefinitionIndex, AimbotWeapon_t, Util::IntHash<ItemDefinitionIndex>> Settings::Aimbot::weapons = {
{ ItemDefinitionIndex::INVALID, { false, false, false, Bone::BONE_HEAD, ButtonCode_t::MOUSE_MIDDLE, false, false, 1.0f, SmoothType::SLOW_END, false, 0.0f, false, 0.0f, true, 180.0f, false, 25.0f, false, false, 2.0f, 2.0f, false, false, false, false, false, false, false, false, 10.0f, false, false, false, 5.0f } },
{ ItemDefinitionIndex::INVALID, { false, false, false, false, Bone::BONE_HEAD, ButtonCode_t::MOUSE_MIDDLE, false, false, 1.0f, SmoothType::SLOW_END, false, 0.0f, false, 0.0f, true, 180.0f, false, 25.0f, false, false, 2.0f, 2.0f, false, false, false, false, false, false, false, false, 10.0f, false, false, false, 5.0f } },
};

static const char* targets[] = { "pelvis", "", "", "spine_0", "spine_1", "spine_2", "spine_3", "neck_0", "head_0" };
Expand Down Expand Up @@ -172,7 +173,8 @@ C_BasePlayer* GetClosestPlayer(CUserCmd* cmd, bool visible, Bone& bestBone, floa
if (std::find(Aimbot::friends.begin(), Aimbot::friends.end(), entityInformation.xuid) != Aimbot::friends.end())
continue;

Vector eVecTarget = player->GetBonePosition((int) Settings::Aimbot::bone);
Bone targetBone = Settings::Aimbot::bone;
Vector eVecTarget = player->GetBonePosition((int) targetBone);
Vector pVecTarget = localplayer->GetEyePosition();

QAngle viewAngles;
Expand All @@ -182,6 +184,29 @@ C_BasePlayer* GetClosestPlayer(CUserCmd* cmd, bool visible, Bone& bestBone, floa
float fov = Math::GetFov(viewAngles, Math::CalcAngle(pVecTarget, eVecTarget));
float real_distance = GetRealDistanceFOV(distance, Math::CalcAngle(pVecTarget, eVecTarget), cmd);
int hp = player->GetHealth();

if (Settings::Aimbot::closestBone)
{
for (int i = (int)Bone::BONE_PELVIS; i < (int)Bone::BONE_HEAD; i++)
{
if (i == 1 || i == 2)
continue;

Bone testBone = static_cast<Bone>(i);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix spaces to tabs

Vector mVecTarget = player->GetBonePosition((int) testBone);
float m_distance = pVecTarget.DistTo(mVecTarget);
float m_fov = Math::GetFov(viewAngles, Math::CalcAngle(pVecTarget, mVecTarget));
float m_real_distance = GetRealDistanceFOV(m_distance, Math::CalcAngle(pVecTarget, mVecTarget), cmd);

if (m_real_distance < real_distance)
{
distance = m_distance;
fov = m_fov;
real_distance = m_real_distance;
targetBone = testBone;
}
}
}

if (aimTargetType == AimTargetType::DISTANCE && distance > bestDistance)
continue;
Expand All @@ -195,10 +220,10 @@ C_BasePlayer* GetClosestPlayer(CUserCmd* cmd, bool visible, Bone& bestBone, floa
if (aimTargetType == AimTargetType::HP && hp > bestHp)
continue;

if (visible && !Settings::Aimbot::AutoWall::enabled && !Entity::IsVisible(player, Settings::Aimbot::bone))
if (visible && !Settings::Aimbot::AutoWall::enabled && !Entity::IsVisible(player, targetBone))
continue;

bestBone = static_cast<Bone>(Entity::GetBoneByName(player, targets[(int) Settings::Aimbot::bone]));
bestBone = static_cast<Bone>(Entity::GetBoneByName(player, targets[(int) targetBone]));

if (Settings::Aimbot::AutoWall::enabled)
{
Expand Down
4 changes: 3 additions & 1 deletion src/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ void Settings::LoadDefaultsOrSave(std::string path)
weaponSetting["Enabled"] = i.second.enabled;
weaponSetting["Silent"] = i.second.silent;
weaponSetting["Friendly"] = i.second.friendly;
weaponSetting["ClosestBone"] = i.second.closestBone;
weaponSetting["TargetBone"] = (int) i.second.bone;
weaponSetting["AimKey"] = Util::GetButtonName(i.second.aimkey);
weaponSetting["AimKeyOnly"] = i.second.aimkeyOnly;
Expand Down Expand Up @@ -507,7 +508,7 @@ void Settings::LoadConfig(std::string path)
Fonts::SetupFonts();

Settings::Aimbot::weapons = {
{ ItemDefinitionIndex::INVALID, { false, false, false, Bone::BONE_HEAD, ButtonCode_t::MOUSE_MIDDLE, false, false, 1.0f, SmoothType::SLOW_END, false, 0.0f, false, 0.0f, true, 180.0f, false, 25.0f, false, false, 2.0f, 2.0f, false, false, false, false, false, false, false, false, 10.0f, false, false, false, 5.0f } },
{ ItemDefinitionIndex::INVALID, { false, false, false, false, Bone::BONE_HEAD, ButtonCode_t::MOUSE_MIDDLE, false, false, 1.0f, SmoothType::SLOW_END, false, 0.0f, false, 0.0f, true, 180.0f, false, 25.0f, false, false, 2.0f, 2.0f, false, false, false, false, false, false, false, false, 10.0f, false, false, false, 5.0f } },
};

for (Json::ValueIterator itr = settings["Aimbot"]["weapons"].begin(); itr != settings["Aimbot"]["weapons"].end(); itr++)
Expand All @@ -534,6 +535,7 @@ void Settings::LoadConfig(std::string path)
weaponSetting["Enabled"].asBool(),
weaponSetting["Silent"].asBool(),
weaponSetting["Friendly"].asBool(),
weaponSetting["ClosestBone"].asBool(),
(Bone) weaponSetting["TargetBone"].asInt(),
Util::GetButtonCode(weaponSetting["AimKey"].asCString()),
weaponSetting["AimKeyOnly"].asBool(),
Expand Down
7 changes: 5 additions & 2 deletions src/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,15 @@ enum class SpammerType : int

struct AimbotWeapon_t
{
bool enabled, silent, friendly;
bool enabled, silent, friendly, closestBone;
Bone bone;
SmoothType smoothType;
ButtonCode_t aimkey;
bool aimkeyOnly, smoothEnabled, smoothSaltEnabled, errorMarginEnabled, autoAimEnabled, aimStepEnabled, rcsEnabled, rcsAlwaysOn;
float smoothAmount, smoothSaltMultiplier, errorMarginValue, autoAimFov, aimStepValue, rcsAmountX, rcsAmountY, autoWallValue, autoSlowMinDamage;
bool autoPistolEnabled, autoShootEnabled, autoScopeEnabled, noShootEnabled, ignoreJumpEnabled, smokeCheck, flashCheck, autoWallEnabled, autoWallBones[6], autoAimRealDistance, autoSlow, predEnabled;

AimbotWeapon_t(bool enabled, bool silent, bool friendly, Bone bone, ButtonCode_t aimkey, bool aimkeyOnly,
AimbotWeapon_t(bool enabled, bool silent, bool friendly, bool closestBone, Bone bone, ButtonCode_t aimkey, bool aimkeyOnly,
bool smoothEnabled, float smoothValue, SmoothType smoothType, bool smoothSaltEnabled, float smoothSaltMultiplier,
bool errorMarginEnabled, float errorMarginValue,
bool autoAimEnabled, float autoAimValue, bool aimStepEnabled, float aimStepValue,
Expand All @@ -165,6 +165,7 @@ struct AimbotWeapon_t
this->enabled = enabled;
this->silent = silent;
this->friendly = friendly;
this->closestBone = closestBone;
this->bone = bone;
this->aimkey = aimkey;
this->aimkeyOnly = aimkeyOnly;
Expand Down Expand Up @@ -215,6 +216,7 @@ struct AimbotWeapon_t
return this->enabled == another.enabled &&
this->silent == another.silent &&
this->friendly == another.friendly &&
this->closestBone == another.closestBone &&
this->bone == another.bone &&
this->aimkey == another.aimkey &&
this->aimkeyOnly == another.aimkeyOnly &&
Expand Down Expand Up @@ -318,6 +320,7 @@ namespace Settings
extern bool enabled;
extern bool silent;
extern bool friendly;
extern bool closestBone;
extern Bone bone;
extern ButtonCode_t aimkey;
extern bool aimkeyOnly;
Expand Down