From eb80ac54bd5aeb85bf81288a159f4aafe3eafc03 Mon Sep 17 00:00:00 2001 From: Aure7138 <100095051+Aure7138@users.noreply.github.com> Date: Wed, 30 Nov 2022 03:16:07 +0800 Subject: [PATCH] feat: Fast Respawn, Rapid Fire, removed static offsets (#649) Closes #495 Fixes #635 --- src/backend/backend.cpp | 2 ++ src/backend/looped/looped.hpp | 2 ++ src/backend/looped/self/fast_respawn.cpp | 17 ++++++++++++++ src/backend/looped/self/godmode.cpp | 27 ---------------------- src/backend/looped/vehicle/vehicle_god.cpp | 26 --------------------- src/backend/looped/weapons/rapid_fire.cpp | 26 +++++++++++++++++++++ src/core/globals.hpp | 6 +++++ src/util/water.hpp | 16 ------------- src/views/self/view_self.cpp | 1 + src/views/self/view_weapons.cpp | 17 ++++++++++---- 10 files changed, 67 insertions(+), 73 deletions(-) create mode 100644 src/backend/looped/self/fast_respawn.cpp create mode 100644 src/backend/looped/weapons/rapid_fire.cpp delete mode 100644 src/util/water.hpp diff --git a/src/backend/backend.cpp b/src/backend/backend.cpp index 3c4b65f6..7781100a 100644 --- a/src/backend/backend.cpp +++ b/src/backend/backend.cpp @@ -43,6 +43,7 @@ namespace big looped::self_unlimited_oxygen(); looped::self_no_water_collision(); looped::self_mobile_radio(); + looped::self_fast_respawn(); script::get_current()->yield(); } @@ -67,6 +68,7 @@ namespace big looped::weapons_repair_gun(); looped::weapons_steal_vehicle_gun(); looped::weapons_vehicle_gun(); + looped::weapons_rapid_fire(); script::get_current()->yield(); } diff --git a/src/backend/looped/looped.hpp b/src/backend/looped/looped.hpp index 486a158e..40dcb8ae 100644 --- a/src/backend/looped/looped.hpp +++ b/src/backend/looped/looped.hpp @@ -32,6 +32,7 @@ namespace big static void self_unlimited_oxygen(); static void self_no_water_collision(); static void self_mobile_radio(); + static void self_fast_respawn(); static void session_local_time(); @@ -72,5 +73,6 @@ namespace big static void weapons_repair_gun(); static void weapons_steal_vehicle_gun(); static void weapons_vehicle_gun(); + static void weapons_rapid_fire(); }; } diff --git a/src/backend/looped/self/fast_respawn.cpp b/src/backend/looped/self/fast_respawn.cpp new file mode 100644 index 00000000..ac647ba0 --- /dev/null +++ b/src/backend/looped/self/fast_respawn.cpp @@ -0,0 +1,17 @@ +#include "backend/looped/looped.hpp" +#include "natives.hpp" + +namespace big +{ + void looped::self_fast_respawn() + { + if (g->self.fast_respawn) + { + if(PED::IS_PED_DEAD_OR_DYING(self::ped, true)) + { + PED::RESURRECT_PED(self::ped); + ENTITY::SET_ENTITY_COORDS_NO_OFFSET(self::ped, self::pos.x, self::pos.y, self::pos.z, 0, 0, 0); + } + } + } +} \ No newline at end of file diff --git a/src/backend/looped/self/godmode.cpp b/src/backend/looped/self/godmode.cpp index 913ba628..8c81df94 100644 --- a/src/backend/looped/self/godmode.cpp +++ b/src/backend/looped/self/godmode.cpp @@ -1,5 +1,4 @@ #include "backend/looped/looped.hpp" -#include "util/water.hpp" namespace big { @@ -13,12 +12,6 @@ namespace big return; } - float* water_collision_ptr = nullptr; - if (g_local_player->m_navigation != nullptr) - { - water_collision_ptr = water::get_water_collision_ptr(g_local_player->m_navigation); - } - uint32_t bits = g->self.proof_mask; uint32_t changed_bits = bits ^ last_bits; uint32_t changed_or_enabled_bits = bits | changed_bits; @@ -28,26 +21,6 @@ namespace big uint32_t unchanged_bits = g_local_player->m_damage_bits & ~changed_or_enabled_bits; g_local_player->m_damage_bits = unchanged_bits | bits; last_bits = bits; - - - if (changed_or_enabled_bits & (uint32_t)eEntityProofs::WATER) - { - water::reset_ped_oxygen_time(g_local_player); - - if (water_collision_ptr != nullptr && *water_collision_ptr != 0.f) - { - last_water_collistion_strength = *water_collision_ptr; - *water_collision_ptr = 0; - } - - return; - } - } - - if (last_water_collistion_strength != 0 && water_collision_ptr != nullptr) - { - *water_collision_ptr = last_water_collistion_strength; - last_water_collistion_strength = 0; } } } \ No newline at end of file diff --git a/src/backend/looped/vehicle/vehicle_god.cpp b/src/backend/looped/vehicle/vehicle_god.cpp index ac1abfde..2cd14429 100644 --- a/src/backend/looped/vehicle/vehicle_god.cpp +++ b/src/backend/looped/vehicle/vehicle_god.cpp @@ -1,6 +1,5 @@ #include "backend/looped/looped.hpp" #include "util/misc.hpp" -#include "util/water.hpp" namespace big { @@ -25,12 +24,6 @@ namespace big g_local_player->m_vehicle->m_deform_god = 0x9C; } - float* water_collision_ptr = nullptr; - if (g_local_player->m_vehicle->m_navigation != nullptr) - { - water_collision_ptr = water::get_water_collision_ptr(g_local_player->m_vehicle->m_navigation); - } - uint32_t bits = g->vehicle.proof_mask; uint32_t changed_bits = bits ^ last_bits; uint32_t changed_or_enabled_bits = bits | changed_bits; @@ -40,25 +33,6 @@ namespace big uint32_t unchanged_bits = g_local_player->m_vehicle->m_damage_bits & ~changed_or_enabled_bits; g_local_player->m_vehicle->m_damage_bits = unchanged_bits | bits; last_bits = bits; - - if (changed_or_enabled_bits & (uint32_t)eEntityProofs::WATER) - { - water::reset_ped_oxygen_time(g_local_player); - - if (water_collision_ptr != nullptr && *water_collision_ptr != 0.f) - { - last_water_collistion_strength = *water_collision_ptr; - *water_collision_ptr = 0; - } - - return; - } - } - - if (last_water_collistion_strength != 0 && water_collision_ptr != nullptr) - { - *water_collision_ptr = last_water_collistion_strength; - last_water_collistion_strength = 0; } } } \ No newline at end of file diff --git a/src/backend/looped/weapons/rapid_fire.cpp b/src/backend/looped/weapons/rapid_fire.cpp new file mode 100644 index 00000000..544aefbb --- /dev/null +++ b/src/backend/looped/weapons/rapid_fire.cpp @@ -0,0 +1,26 @@ +#include "backend/looped/looped.hpp" +#include "natives.hpp" +#include "gta/enums.hpp" +#include "util/math.hpp" + +namespace big +{ + void looped::weapons_rapid_fire() + { + if (g->weapons.rapid_fire) + { + if(!HUD::IS_PAUSE_MENU_ACTIVE()) + { + if (PAD::IS_DISABLED_CONTROL_PRESSED(0, (int)ControllerInputs::INPUT_ATTACK)) + { + Vector3 direction = math::rotation_to_direction(CAM::GET_GAMEPLAY_CAM_ROT(0)); + Vector3 start = CAM::GET_GAMEPLAY_CAM_COORD() + direction; + Vector3 end = start + direction * 200.0; + Hash weapon_hash; + WEAPON::GET_CURRENT_PED_WEAPON(self::ped, &weapon_hash, false); + MISC::SHOOT_SINGLE_BULLET_BETWEEN_COORDS(start.x, start.y, start.z, end.x, end.y, end.z, WEAPON::GET_WEAPON_DAMAGE(weapon_hash, 0), true, weapon_hash, self::ped, true, false, -1.0); + } + } + } + } +} \ No newline at end of file diff --git a/src/core/globals.hpp b/src/core/globals.hpp index 88a44433..6edbd19a 100644 --- a/src/core/globals.hpp +++ b/src/core/globals.hpp @@ -187,6 +187,7 @@ namespace big bool force_show_hud_element = false; bool force_show_hud = false; bool mobile_radio = false; + bool fast_respawn = false; }; struct session @@ -359,6 +360,7 @@ namespace big bool no_spread = false; char vehicle_gun_model[12] = "bus"; bool bypass_c4_limit = false; + bool rapid_fire = false; }; struct window @@ -648,6 +650,7 @@ namespace big this->self.unlimited_oxygen = j["self"]["unlimited_oxygen"]; this->self.no_water_collision = j["self"]["no_water_collision"]; this->self.mobile_radio = j["self"]["mobile_radio"]; + this->self.fast_respawn = j["self"]["fast_respawn"]; this->session.log_chat_messages = j["session"]["log_chat_messages"]; this->session.log_text_messages = j["session"]["log_text_messages"]; @@ -753,6 +756,7 @@ namespace big this->weapons.no_recoil = j["weapons"]["no_recoil"]; this->weapons.no_spread = j["weapons"]["no_spread"]; this->weapons.bypass_c4_limit = j["weapons"]["bypass_c4_limit"]; + this->weapons.rapid_fire = j["weapons"]["rapid_fire"]; this->weapons.ammo_special.type = (eAmmoSpecialType)j["weapons"]["ammo_special"]["type"]; this->weapons.ammo_special.toggle = j["weapons"]["ammo_special"]["toggle"]; @@ -990,6 +994,7 @@ namespace big { "unlimited_oxygen", this->self.unlimited_oxygen }, { "no_water_collision", this->self.no_water_collision }, { "mobile_radio", this->self.mobile_radio }, + { "fast_respawn", this->self.fast_respawn }, } }, { @@ -1141,6 +1146,7 @@ namespace big { "no_recoil", this->weapons.no_recoil }, { "no_spread", this->weapons.no_spread }, { "bypass_c4_limit", this->weapons.bypass_c4_limit }, + { "rapid_fire", this->weapons.rapid_fire }, } }, { diff --git a/src/util/water.hpp b/src/util/water.hpp deleted file mode 100644 index 0dd65087..00000000 --- a/src/util/water.hpp +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once - -namespace big::water -{ - inline float* get_water_collision_ptr(CNavigation* nav) - { - auto nav_addr = (uint64_t)nav; - return (float*)(*(uint64_t*)(nav_addr + 0x10) + 0x54); - } - - inline void reset_ped_oxygen_time(CPed* ped) - { - auto ped_addr = (uint64_t)ped; - *(float*)(*(uint64_t*)(ped_addr + 0x10A0) + 0x278) = 0; - } -} diff --git a/src/views/self/view_self.cpp b/src/views/self/view_self.cpp index c55c81fd..afd1e605 100644 --- a/src/views/self/view_self.cpp +++ b/src/views/self/view_self.cpp @@ -56,6 +56,7 @@ namespace big ImGui::Checkbox("Free Cam", &g->self.free_cam); ImGui::Checkbox("Disable Phone", &g->tunables.disable_phone); ImGui::Checkbox("Unlimited Oxygen", &g->self.unlimited_oxygen); + ImGui::Checkbox("Fast Respawn", &g->self.fast_respawn); ImGui::EndGroup(); ImGui::SameLine(); diff --git a/src/views/self/view_weapons.cpp b/src/views/self/view_weapons.cpp index acadb31c..91ef78cc 100644 --- a/src/views/self/view_weapons.cpp +++ b/src/views/self/view_weapons.cpp @@ -12,13 +12,15 @@ namespace big { void view::weapons() { components::sub_title("Ammo"); + + ImGui::BeginGroup(); + ImGui::Checkbox("Infinite Ammo", &g->weapons.infinite_ammo); - - ImGui::SameLine(); - ImGui::Checkbox("Infinite Clip", &g->weapons.infinite_mag); - ImGui::Checkbox("Enable Special Ammo", &g->weapons.ammo_special.toggle); + ImGui::EndGroup(); + ImGui::SameLine(); + ImGui::BeginGroup(); if (ImGui::Checkbox("Bypass C4 Limit", &g->weapons.bypass_c4_limit)) { @@ -27,6 +29,13 @@ namespace big else g_pointers->m_bypass_max_count_of_active_sticky_bombs->restore(); } + ImGui::Checkbox("Rapid Fire", &g->weapons.rapid_fire); + + ImGui::EndGroup(); + + ImGui::Separator(); + + ImGui::Checkbox("Enable Special Ammo", &g->weapons.ammo_special.toggle); eAmmoSpecialType selected_ammo = g->weapons.ammo_special.type; eExplosionTag selected_explosion = g->weapons.ammo_special.explosion_tag;