Optimized Aimbot code. (#2653)
* Fixed hypot call not considering the Z coordinates. Refactored class-based variables. Fixed on_player/on_enemy/on_police/on_npc config variables not being persisted to disk.
This commit is contained in:
parent
dd27ea2340
commit
deac08e856
@ -5,20 +5,20 @@
|
|||||||
#include <numbers>
|
#include <numbers>
|
||||||
namespace big
|
namespace big
|
||||||
{
|
{
|
||||||
inline Vector3 aim_lock;
|
|
||||||
inline Vector3 smooth_factor;
|
|
||||||
inline bool using_aimbot_first_time = true;
|
|
||||||
inline Entity target_entity;
|
|
||||||
|
|
||||||
class aimbot : looped_command
|
class aimbot : looped_command
|
||||||
{
|
{
|
||||||
|
static inline Vector3 aim_lock;
|
||||||
|
static inline Vector3 smooth_factor;
|
||||||
|
static inline bool initalized;
|
||||||
|
static inline Entity target_entity;
|
||||||
|
|
||||||
using looped_command::looped_command;
|
using looped_command::looped_command;
|
||||||
virtual void on_tick() override
|
virtual void on_tick() override
|
||||||
{
|
{
|
||||||
float local_fov_change = g.weapons.aimbot.fov;
|
float local_fov_change = g.weapons.aimbot.fov;
|
||||||
for (auto ped : entity::get_entities(false, true))
|
for (auto ped : entity::get_entities(false, true))
|
||||||
{
|
{
|
||||||
if (!ENTITY::IS_ENTITY_DEAD(ped, 0)) // Tracetype is always 17. LOS check
|
if (!ENTITY::IS_ENTITY_DEAD(ped, 0))
|
||||||
{
|
{
|
||||||
int relation = PED::GET_RELATIONSHIP_BETWEEN_PEDS(ped, self::ped); // relation for enemy check
|
int relation = PED::GET_RELATIONSHIP_BETWEEN_PEDS(ped, self::ped); // relation for enemy check
|
||||||
int type = PED::GET_PED_TYPE(ped); // for police check, cop types are 6, swat is 27
|
int type = PED::GET_PED_TYPE(ped); // for police check, cop types are 6, swat is 27
|
||||||
@ -52,13 +52,12 @@ namespace big
|
|||||||
// Update aim lock coords
|
// Update aim lock coords
|
||||||
aimbot_handler:
|
aimbot_handler:
|
||||||
{
|
{
|
||||||
if (!ENTITY::HAS_ENTITY_CLEAR_LOS_TO_ENTITY(self::ped, ped, 17))
|
if (!ENTITY::HAS_ENTITY_CLEAR_LOS_TO_ENTITY_ADJUST_FOR_COVER(self::ped, ped, 17))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Jump to here to handle instead of continue statements
|
// Jump to here to handle instead of continue statements
|
||||||
target_entity = ped;
|
target_entity = ped;
|
||||||
aim_lock =
|
aim_lock = ENTITY::GET_ENTITY_BONE_POSTION(ped, PED::GET_PED_BONE_INDEX(ped, g.weapons.aimbot.selected_bone));
|
||||||
ENTITY::GET_WORLD_POSITION_OF_ENTITY_BONE(ped, PED::GET_PED_BONE_INDEX(ped, g.weapons.aimbot.selected_bone));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -66,14 +65,14 @@ namespace big
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (PED::GET_PED_CONFIG_FLAG(self::ped, 78, 0))
|
if (PLAYER::IS_PLAYER_FREE_AIMING(self::id))
|
||||||
{
|
{
|
||||||
Vector3 camera_target;
|
Vector3 camera_target;
|
||||||
|
|
||||||
if (g.weapons.aimbot.smoothing)
|
if (g.weapons.aimbot.smoothing)
|
||||||
{
|
{
|
||||||
//Avoid buggy cam
|
//Avoid buggy cam
|
||||||
if (using_aimbot_first_time)
|
if (!initalized)
|
||||||
{
|
{
|
||||||
Vector3 cam_coords = CAM::GET_GAMEPLAY_CAM_COORD();
|
Vector3 cam_coords = CAM::GET_GAMEPLAY_CAM_COORD();
|
||||||
Vector3 cam_rot = CAM::GET_GAMEPLAY_CAM_ROT(0);
|
Vector3 cam_rot = CAM::GET_GAMEPLAY_CAM_ROT(0);
|
||||||
@ -82,8 +81,8 @@ namespace big
|
|||||||
Vector3 multiply = cam_direction * distance;
|
Vector3 multiply = cam_direction * distance;
|
||||||
Vector3 front_cam = cam_coords + multiply;
|
Vector3 front_cam = cam_coords + multiply;
|
||||||
camera_target = front_cam - CAM::GET_GAMEPLAY_CAM_COORD();
|
camera_target = front_cam - CAM::GET_GAMEPLAY_CAM_COORD();
|
||||||
smooth_factor = camera_target;
|
smooth_factor = camera_target;
|
||||||
using_aimbot_first_time = false;
|
initalized = true;
|
||||||
}
|
}
|
||||||
Vector3 target = aim_lock - CAM::GET_GAMEPLAY_CAM_COORD();
|
Vector3 target = aim_lock - CAM::GET_GAMEPLAY_CAM_COORD();
|
||||||
smooth_factor.x += (target.x - smooth_factor.x) * g.weapons.aimbot.smoothing_speed / 10.f;
|
smooth_factor.x += (target.x - smooth_factor.x) * g.weapons.aimbot.smoothing_speed / 10.f;
|
||||||
@ -101,10 +100,9 @@ namespace big
|
|||||||
if (aim_lock.x == 0.f && aim_lock.y == 0.f && aim_lock.z == 0.f)
|
if (aim_lock.x == 0.f && aim_lock.y == 0.f && aim_lock.z == 0.f)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
float RADPI = 180.0f / std::numbers::pi;
|
constexpr float RADPI = 180.0f / std::numbers::pi;
|
||||||
float camera_heading = atan2f(camera_target.x, camera_target.y) * RADPI;
|
float magnitude = std::hypot(camera_target.x, camera_target.y, camera_target.z);
|
||||||
float magnitude = sqrtf(camera_target.x * camera_target.x + camera_target.y * camera_target.y
|
float camera_heading = atan2f(camera_target.x, camera_target.y) * RADPI;
|
||||||
+ camera_target.z * camera_target.z);
|
|
||||||
|
|
||||||
float camera_pitch = asinf(camera_target.z / magnitude) * RADPI;
|
float camera_pitch = asinf(camera_target.z / magnitude) * RADPI;
|
||||||
float self_heading = ENTITY::GET_ENTITY_HEADING(self::ped);
|
float self_heading = ENTITY::GET_ENTITY_HEADING(self::ped);
|
||||||
@ -131,12 +129,12 @@ namespace big
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
target_entity = 0;
|
target_entity = 0;
|
||||||
using_aimbot_first_time = true;
|
initalized = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
virtual void on_disable() override
|
virtual void on_disable() override
|
||||||
{
|
{
|
||||||
using_aimbot_first_time = true;
|
initalized = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -853,7 +853,7 @@ namespace big
|
|||||||
float fov = 90.f;
|
float fov = 90.f;
|
||||||
float distance = 200.f;
|
float distance = 200.f;
|
||||||
uint32_t selected_bone = 0x796E; // Default to head
|
uint32_t selected_bone = 0x796E; // Default to head
|
||||||
NLOHMANN_DEFINE_TYPE_INTRUSIVE(aimbot, enable, smoothing, smoothing_speed, fov, distance, selected_bone)
|
NLOHMANN_DEFINE_TYPE_INTRUSIVE(aimbot, enable, smoothing, smoothing_speed, on_player, on_enemy, on_police, on_npc, fov, distance)
|
||||||
} aimbot{};
|
} aimbot{};
|
||||||
|
|
||||||
struct flying_axe
|
struct flying_axe
|
||||||
|
@ -50,7 +50,7 @@ namespace big
|
|||||||
command_arguments _args(args);
|
command_arguments _args(args);
|
||||||
command->call(_args);
|
command->call(_args);
|
||||||
}
|
}
|
||||||
if (ImGui::IsItemHovered())
|
if (ImGui::IsItemHovered() && !command->get_description().empty())
|
||||||
ImGui::SetTooltip(command->get_description().c_str());
|
ImGui::SetTooltip(command->get_description().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ namespace big
|
|||||||
|
|
||||||
if (ImGui::Button(label_override.value_or(command->get_label()).data()))
|
if (ImGui::Button(label_override.value_or(command->get_label()).data()))
|
||||||
command->call(player, args);
|
command->call(player, args);
|
||||||
if (ImGui::IsItemHovered())
|
if (ImGui::IsItemHovered() && !command->get_description().empty())
|
||||||
ImGui::SetTooltip(command->get_description().c_str());
|
ImGui::SetTooltip(command->get_description().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,7 +80,7 @@ namespace big
|
|||||||
bool updated;
|
bool updated;
|
||||||
if (updated = ImGui::Checkbox(label_override.value_or(command->get_label()).data(), &command->is_enabled()))
|
if (updated = ImGui::Checkbox(label_override.value_or(command->get_label()).data(), &command->is_enabled()))
|
||||||
command->refresh();
|
command->refresh();
|
||||||
if (ImGui::IsItemHovered())
|
if (ImGui::IsItemHovered() && !command->get_description().empty())
|
||||||
ImGui::SetTooltip(command->get_description().c_str());
|
ImGui::SetTooltip(command->get_description().c_str());
|
||||||
|
|
||||||
return updated;
|
return updated;
|
||||||
@ -98,7 +98,7 @@ namespace big
|
|||||||
command->get_lower_bound(),
|
command->get_lower_bound(),
|
||||||
command->get_upper_bound());
|
command->get_upper_bound());
|
||||||
|
|
||||||
if (ImGui::IsItemHovered())
|
if (ImGui::IsItemHovered() && !command->get_description().empty())
|
||||||
ImGui::SetTooltip(command->get_description().c_str());
|
ImGui::SetTooltip(command->get_description().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,7 +114,7 @@ namespace big
|
|||||||
command->get_lower_bound(),
|
command->get_lower_bound(),
|
||||||
command->get_upper_bound());
|
command->get_upper_bound());
|
||||||
|
|
||||||
if (ImGui::IsItemHovered())
|
if (ImGui::IsItemHovered() && !command->get_description().empty())
|
||||||
ImGui::SetTooltip(command->get_description().c_str());
|
ImGui::SetTooltip(command->get_description().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,7 +130,7 @@ namespace big
|
|||||||
command->get_lower_bound(),
|
command->get_lower_bound(),
|
||||||
command->get_upper_bound());
|
command->get_upper_bound());
|
||||||
|
|
||||||
if (ImGui::IsItemHovered())
|
if (ImGui::IsItemHovered() && !command->get_description().empty())
|
||||||
ImGui::SetTooltip(command->get_description().c_str());
|
ImGui::SetTooltip(command->get_description().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user