From ccb359136499c751536aebfc566dd593de538805 Mon Sep 17 00:00:00 2001 From: gir489 <100792176+gir489returns@users.noreply.github.com> Date: Tue, 30 Apr 2024 12:11:43 -0400 Subject: [PATCH] Added "Enable MK1 and MK2 Weapons" feature. (#3000) --- .../commands/self/enable_mk1_variants.cpp | 6 +++++ src/core/settings.hpp | 3 ++- src/native_hooks/freemode.hpp | 22 +++++++++++++++++++ src/native_hooks/native_hooks.cpp | 1 + src/views/self/view_weapons.cpp | 2 ++ 5 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 src/backend/commands/self/enable_mk1_variants.cpp diff --git a/src/backend/commands/self/enable_mk1_variants.cpp b/src/backend/commands/self/enable_mk1_variants.cpp new file mode 100644 index 00000000..c8aae85d --- /dev/null +++ b/src/backend/commands/self/enable_mk1_variants.cpp @@ -0,0 +1,6 @@ +#include "backend/bool_command.hpp" + +namespace big +{ + bool_command g_enable_mk1_variants("enablemk1variants", "ENABLE_BOTH_MK1_AND_MK2_VARIANTS", "ENABLE_BOTH_MK1_AND_MK2_VARIANTS_DESC", g.weapons.enable_mk1_variants); +} \ No newline at end of file diff --git a/src/core/settings.hpp b/src/core/settings.hpp index 4787d508..797c0e6a 100644 --- a/src/core/settings.hpp +++ b/src/core/settings.hpp @@ -884,9 +884,10 @@ namespace big bool triggerbot = false; bool infinite_range = false; bool enable_weapon_hotkeys = false; + bool enable_mk1_variants = false; std::map> weapon_hotkeys{}; - NLOHMANN_DEFINE_TYPE_INTRUSIVE(weapons, ammo_special, custom_weapon, aimbot, infinite_ammo, always_full_ammo, infinite_mag, increased_damage, increase_damage, set_explosion_radius, modify_explosion_radius, no_recoil, no_spread, vehicle_gun_model, increased_c4_limit, increased_flare_limit, rapid_fire, gravity_gun, paintgun, interior_weapon, triggerbot, infinite_range, enable_weapon_hotkeys, weapon_hotkeys) + NLOHMANN_DEFINE_TYPE_INTRUSIVE(weapons, ammo_special, custom_weapon, aimbot, infinite_ammo, always_full_ammo, infinite_mag, increased_damage, increase_damage, set_explosion_radius, modify_explosion_radius, no_recoil, no_spread, vehicle_gun_model, increased_c4_limit, increased_flare_limit, rapid_fire, gravity_gun, paintgun, interior_weapon, triggerbot, infinite_range, enable_weapon_hotkeys, weapon_hotkeys, enable_mk1_variants) } weapons{}; struct window diff --git a/src/native_hooks/freemode.hpp b/src/native_hooks/freemode.hpp index 89c9a5f9..6bafb0cc 100644 --- a/src/native_hooks/freemode.hpp +++ b/src/native_hooks/freemode.hpp @@ -92,5 +92,27 @@ namespace big } } } + + void REMOVE_WEAPON_FROM_PED(rage::scrNativeCallContext* src) + { + auto ped = src->get_arg(0); + auto weapon_hash = src->get_arg(1); + if (g.weapons.enable_mk1_variants) + { + static const std::unordered_set weapon_variants = { + "WEAPON_PISTOL"_J, "WEAPON_SMG"_J, "WEAPON_ASSAULTRIFLE"_J, "WEAPON_CARBINERIFLE"_J, + "WEAPON_COMBATMG"_J, "WEAPON_HEAVYSNIPER"_J, "WEAPON_BULLPUPRIFLE"_J, "WEAPON_MARKSMANRIFLE"_J, + "WEAPON_PUMPSHOTGUN"_J, "WEAPON_REVOLVER"_J, "WEAPON_SNSPISTOL"_J, "WEAPON_SPECIALCARBINE"_J, + //MK2 variants + "WEAPON_PISTOL_MK2"_J, "WEAPON_SMG_MK2"_J, "WEAPON_ASSAULTRIFLE_MK2"_J, "WEAPON_CARBINERIFLE_MK2"_J, + "WEAPON_COMBATMG_MK2"_J, "WEAPON_HEAVYSNIPER_MK2"_J, "WEAPON_BULLPUPRIFLE_MK2"_J, "WEAPON_MARKSMANRIFLE_MK2"_J, + "WEAPON_PUMPSHOTGUN_MK2"_J, "WEAPON_REVOLVER_MK2"_J, "WEAPON_SNSPISTOL_MK2"_J, "WEAPON_SPECIALCARBINE_MK2"_J }; + if (ped == self::ped && weapon_variants.contains(weapon_hash)) + { + return; + } + } + WEAPON::REMOVE_WEAPON_FROM_PED(ped, weapon_hash); + } } } diff --git a/src/native_hooks/native_hooks.cpp b/src/native_hooks/native_hooks.cpp index 5e2b4cac..e1c6d409 100644 --- a/src/native_hooks/native_hooks.cpp +++ b/src/native_hooks/native_hooks.cpp @@ -119,6 +119,7 @@ namespace big add_native_detour("freemode"_J, NativeIndex::SET_BIGMAP_ACTIVE, freemode::SET_BIGMAP_ACTIVE); add_native_detour("freemode"_J, NativeIndex::SET_BLIP_DISPLAY, freemode::SET_BLIP_DISPLAY); add_native_detour("freemode"_J, NativeIndex::NETWORK_HAS_RECEIVED_HOST_BROADCAST_DATA, freemode::NETWORK_HAS_RECEIVED_HOST_BROADCAST_DATA); + add_native_detour("freemode"_J, NativeIndex::REMOVE_WEAPON_FROM_PED, freemode::REMOVE_WEAPON_FROM_PED); add_native_detour("fmmc_launcher"_J, NativeIndex::NETWORK_HAS_RECEIVED_HOST_BROADCAST_DATA, freemode::NETWORK_HAS_RECEIVED_HOST_BROADCAST_DATA); add_native_detour("maintransition"_J, NativeIndex::NETWORK_SESSION_HOST, network::NETWORK_SESSION_HOST); diff --git a/src/views/self/view_weapons.cpp b/src/views/self/view_weapons.cpp index 473204a9..97d4efd7 100644 --- a/src/views/self/view_weapons.cpp +++ b/src/views/self/view_weapons.cpp @@ -91,6 +91,8 @@ namespace big } }); + components::command_checkbox<"enablemk1variants">(); + ImGui::EndGroup(); ImGui::SeparatorText("DEBUG_TAB_MISC"_T.data());