From 8d5d5cb73c8be2d95c143aabcc12da599be73b67 Mon Sep 17 00:00:00 2001 From: gir489 <100792176+gir489returns@users.noreply.github.com> Date: Mon, 22 Jul 2024 04:16:16 -0400 Subject: [PATCH] Redesigned triggerbot (#3396) * Redesigned triggerbot to respect the same configuration the user has setup for the aimbot. Triggerbot will not force fire the player's current weapon instead of just silently spawning a bullet. * Delay grabbing player velocity until after we've confirmed the target velocity has at least one tick of information to use. * Fixed some mission peds not being aimbotted/triggerbotted when using only enemies. Removed unused global. * Refactored enemy checks to only run the enemy determination code if the user has it enabled. --- src/backend/looped/weapons/aimbot.cpp | 29 +++++--- src/backend/looped/weapons/triggerbot.cpp | 86 ++++++++++++++++++++++- src/core/scr_globals.hpp | 1 - src/core/settings.hpp | 1 + src/util/entity.cpp | 25 ++++--- src/views/self/view_weapons.cpp | 2 +- 6 files changed, 117 insertions(+), 27 deletions(-) diff --git a/src/backend/looped/weapons/aimbot.cpp b/src/backend/looped/weapons/aimbot.cpp index 321186d9..0d4ab1a9 100644 --- a/src/backend/looped/weapons/aimbot.cpp +++ b/src/backend/looped/weapons/aimbot.cpp @@ -144,19 +144,30 @@ namespace big const auto ped_handle = g_pointers->m_gta.m_ptr_to_handle(ped); - bool is_hated_relationship = false; - bool is_in_combat = PED::IS_PED_IN_COMBAT(ped_handle, self::ped); - switch (PED::GET_RELATIONSHIP_BETWEEN_PEDS(ped_handle, self::ped)) + if (g_aimbot_only_on_enemy.is_enabled()) { + bool is_hated_relationship = false; + bool is_in_combat = PED::IS_PED_IN_COMBAT(ped_handle, self::ped); + auto blip_color = HUD::GET_BLIP_COLOUR(HUD::GET_BLIP_FROM_ENTITY(ped_handle)); + bool is_enemy = PED::GET_PED_CONFIG_FLAG(ped_handle, 38, TRUE) == TRUE || (blip_color == (int)BlipColors::BlipColorEnemy || blip_color == (int)BlipColors::RedMission); + + switch (PED::GET_RELATIONSHIP_BETWEEN_PEDS(ped_handle, self::ped)) + { case Dislike: case Wanted: case Hate: is_hated_relationship = true; + } + + if (!is_hated_relationship && !is_in_combat && !is_enemy) + { + /*if (PED::GET_PED_TYPE(ped_handle) != PED_TYPE_ANIMAL) + LOG(INFO) << " PED_TYPE " << PED::GET_PED_TYPE(ped_handle) << " hated " << is_hated_relationship << " combat " << is_in_combat << " enemy " << is_enemy << " blip_color " << blip_color;*/ + continue; + } } - if ((g_aimbot_only_on_enemy.is_enabled() && (!is_hated_relationship && !is_in_combat)) || is_a_ped_type_we_dont_care_about(ped_handle)) + if (is_a_ped_type_we_dont_care_about(ped_handle)) { - /*if (PED::GET_PED_TYPE(ped_handle) != PED_TYPE_ANIMAL) - LOG(INFO) << " is_hated_relationship " << is_hated_relationship << " GET_PED_TYPE " << PED::GET_PED_TYPE(ped_handle) << " is_in_combat " << is_in_combat;*/ continue; } @@ -274,12 +285,11 @@ namespace big static void adjust_position_for_target_velocity(rage::fvector3& target_position) { const auto target_velocity = get_velocity(m_target); - const auto my_velocity = get_velocity(g_local_player); if (target_velocity == rage::fvector3{}) return; - target_position += (target_velocity - my_velocity); + target_position += (target_velocity - get_velocity(g_local_player)); } virtual void on_tick() override @@ -321,7 +331,8 @@ namespace big self_pos = *self_ped->get_position(); aimbot::find_best_target(self_ped, self_pos); - if (!aimbot::m_target) + g.weapons.aimbot.has_target = aimbot::m_target != nullptr; + if (!g.weapons.aimbot.has_target) { goto exit; } diff --git a/src/backend/looped/weapons/triggerbot.cpp b/src/backend/looped/weapons/triggerbot.cpp index b31a1017..51c86f47 100644 --- a/src/backend/looped/weapons/triggerbot.cpp +++ b/src/backend/looped/weapons/triggerbot.cpp @@ -14,12 +14,92 @@ namespace big Entity crosshair_catch; if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_AIM)) { - if (entity::raycast(&crosshair_catch)) + if (g.weapons.aimbot.enable && g.weapons.aimbot.has_target) + { + PED::SET_PED_RESET_FLAG(self::ped, 65, TRUE); + } + else if (entity::raycast(&crosshair_catch)) { if (ENTITY::IS_ENTITY_A_PED(crosshair_catch) && !ENTITY::IS_ENTITY_DEAD(crosshair_catch, 0)) { - Vector3 coords = ENTITY::GET_ENTITY_BONE_POSTION(crosshair_catch, 0x796E); //SKEL_Head (This will fix the edge case of peds in cars) - PED::SET_PED_SHOOTS_AT_COORD(self::ped, coords.x, coords.y, coords.z, true); + Ped ped = (Ped)crosshair_catch; + CPed* ped_ptr = reinterpret_cast(g_pointers->m_gta.m_handle_to_ptr(ped)); + + if (ped_ptr == nullptr) + return; + + if (g.weapons.aimbot.only_on_player && !ped_ptr->m_player_info) + return; + + if (g.weapons.aimbot.only_on_enemy) + { + bool is_hated_relationship = false; + bool is_in_combat = PED::IS_PED_IN_COMBAT(ped, self::ped); + auto blip_color = HUD::GET_BLIP_COLOUR(HUD::GET_BLIP_FROM_ENTITY(ped)); + bool is_enemy = PED::GET_PED_CONFIG_FLAG(ped, 38, TRUE) == TRUE || (blip_color == (int)BlipColors::BlipColorEnemy || blip_color == (int)BlipColors::RedMission); + + switch (PED::GET_RELATIONSHIP_BETWEEN_PEDS(ped, self::ped)) + { + case Dislike: + case Wanted: + case Hate: is_hated_relationship = true; + } + + if (!is_hated_relationship && !is_in_combat && !is_enemy) + { + return; + } + } + + bool is_a_ped_type_we_dont_care_about; + const auto ped_type = PED::GET_PED_TYPE(ped); + + switch (ped_type) + { + case ePedType::PED_TYPE_PLAYER_0: + case ePedType::PED_TYPE_PLAYER_1: + case ePedType::PED_TYPE_NETWORK_PLAYER: + case ePedType::PED_TYPE_PLAYER_2: + case ePedType::PED_TYPE_CIVMALE: + case ePedType::PED_TYPE_CIVFEMALE: + case ePedType::PED_TYPE_COP: + case ePedType::PED_TYPE_GANG_ALBANIAN: + case ePedType::PED_TYPE_GANG_BIKER_1: + case ePedType::PED_TYPE_GANG_BIKER_2: + case ePedType::PED_TYPE_GANG_ITALIAN: + case ePedType::PED_TYPE_GANG_RUSSIAN: + case ePedType::PED_TYPE_GANG_RUSSIAN_2: + case ePedType::PED_TYPE_GANG_IRISH: + case ePedType::PED_TYPE_GANG_JAMAICAN: + case ePedType::PED_TYPE_GANG_AFRICAN_AMERICAN: + case ePedType::PED_TYPE_GANG_KOREAN: + case ePedType::PED_TYPE_GANG_CHINESE_JAPANESE: + case ePedType::PED_TYPE_GANG_PUERTO_RICAN: + case ePedType::PED_TYPE_DEALER: + case ePedType::PED_TYPE_MEDIC: + case ePedType::PED_TYPE_FIREMAN: + case ePedType::PED_TYPE_CRIMINAL: + case ePedType::PED_TYPE_BUM: + case ePedType::PED_TYPE_PROSTITUTE: + case ePedType::PED_TYPE_SPECIAL: + case ePedType::PED_TYPE_MISSION: + case ePedType::PED_TYPE_SWAT: + case ePedType::PED_TYPE_ANIMAL: + case ePedType::PED_TYPE_ARMY: + { + is_a_ped_type_we_dont_care_about = (g.weapons.aimbot.only_on_ped_type & (1LL << ped_type)) == 0; + } + default: is_a_ped_type_we_dont_care_about = false; + } + + if (is_a_ped_type_we_dont_care_about) + { + return; + } + + //Vector3 coords = ENTITY::GET_ENTITY_BONE_POSTION(crosshair_catch, 0x796E); //SKEL_Head (This will fix the edge case of peds in cars) + //PED::SET_PED_SHOOTS_AT_COORD(self::ped, coords.x, coords.y, coords.z, true); + PED::SET_PED_RESET_FLAG(self::ped, 65, TRUE); } } } diff --git a/src/core/scr_globals.hpp b/src/core/scr_globals.hpp index 88eed84e..3b7a3c86 100644 --- a/src/core/scr_globals.hpp +++ b/src/core/scr_globals.hpp @@ -28,7 +28,6 @@ namespace big::scr_globals static inline const script_global mission_creator_radar_follows_camera(2621443); static inline const script_global mission_creator_exited(1574530); - static inline const script_global in_multiplayer(79389); // g_bInMultiplayer static inline const script_global transition_state(1575011); static inline const script_global sctv_spectator(2697731); // pausemenu_multiplayer function 0xE49C42EC diff --git a/src/core/settings.hpp b/src/core/settings.hpp index d4b0b2fc..594f211c 100644 --- a/src/core/settings.hpp +++ b/src/core/settings.hpp @@ -903,6 +903,7 @@ namespace big int64_t only_on_ped_type = -1; bool only_on_player = false; bool only_on_enemy = false; + bool has_target = false; float fov = 60.f; float distance = 200.f; int32_t selected_bone = (int32_t)ePedBoneType::HEAD; diff --git a/src/util/entity.cpp b/src/util/entity.cpp index fed14123..29308c68 100644 --- a/src/util/entity.cpp +++ b/src/util/entity.cpp @@ -104,8 +104,7 @@ namespace big::entity bool raycast(Entity* ent) { BOOL hit; - Vector3 endCoords; - Vector3 surfaceNormal; + Vector3 dontCare; Vector3 camCoords = CAM::GET_GAMEPLAY_CAM_COORD(); Vector3 rot = CAM::GET_GAMEPLAY_CAM_ROT(2); @@ -116,18 +115,18 @@ namespace big::entity farCoords.y = camCoords.y + dir.y * 1000; farCoords.z = camCoords.z + dir.z * 1000; - int ray = SHAPETEST::START_EXPENSIVE_SYNCHRONOUS_SHAPE_TEST_LOS_PROBE(camCoords.x, - camCoords.y, - camCoords.z, - farCoords.x, - farCoords.y, - farCoords.z, - -1, - 0, - 7); - SHAPETEST::GET_SHAPE_TEST_RESULT(ray, &hit, &endCoords, &surfaceNormal, ent); + auto shape_test = SHAPETEST::START_EXPENSIVE_SYNCHRONOUS_SHAPE_TEST_LOS_PROBE(camCoords.x, + camCoords.y, + camCoords.z, + farCoords.x, + farCoords.y, + farCoords.z, + -1, + 0, + 7); + auto test_result = SHAPETEST::GET_SHAPE_TEST_RESULT(shape_test, &hit, &dontCare, &dontCare, ent); - return (bool)hit; + return (test_result == 2 && hit == TRUE); } bool raycast(Vector3* endcoor) diff --git a/src/views/self/view_weapons.cpp b/src/views/self/view_weapons.cpp index 98d67542..d15401aa 100644 --- a/src/views/self/view_weapons.cpp +++ b/src/views/self/view_weapons.cpp @@ -189,7 +189,7 @@ namespace big ImGui::SameLine(); components::command_checkbox<"aimbot">(); - if (g.weapons.aimbot.enable) + if (g.weapons.aimbot.enable || g.weapons.triggerbot) { components::command_checkbox<"aimonlyatplayer">(); ImGui::SameLine();