From 77e9c9e8840c33caf7dca00fb194d4f2ba16503e Mon Sep 17 00:00:00 2001 From: Aure7138 <100095051+Aure7138@users.noreply.github.com> Date: Sat, 11 Feb 2023 05:46:40 +0800 Subject: [PATCH] feat: interior weapon (#974) --- src/core/globals.hpp | 3 ++- src/native_hooks/all_scripts.hpp | 44 +++++++++++++++++++++++++++++++ src/native_hooks/native_hooks.cpp | 2 ++ src/views/self/view_weapons.cpp | 1 + 4 files changed, 49 insertions(+), 1 deletion(-) diff --git a/src/core/globals.hpp b/src/core/globals.hpp index 29d5612e..6f0ecfa0 100644 --- a/src/core/globals.hpp +++ b/src/core/globals.hpp @@ -614,10 +614,11 @@ namespace big bool increased_c4_limit = false; bool increased_flare_limit = false; bool rapid_fire = false; + bool interior_weapon = false; NLOHMANN_DEFINE_TYPE_INTRUSIVE(weapons, ammo_special, custom_weapon, force_crosshairs, infinite_ammo, infinite_mag, increased_damage, no_recoil, - no_spread, vehicle_gun_model, increased_c4_limit, increased_flare_limit, rapid_fire, gravity_gun) + no_spread, vehicle_gun_model, increased_c4_limit, increased_flare_limit, rapid_fire, gravity_gun, interior_weapon) } weapons{}; struct window diff --git a/src/native_hooks/all_scripts.hpp b/src/native_hooks/all_scripts.hpp index bcb90f44..a799e8c4 100644 --- a/src/native_hooks/all_scripts.hpp +++ b/src/native_hooks/all_scripts.hpp @@ -5,6 +5,7 @@ #include "fiber_pool.hpp" #include "util/scripts.hpp" #include "hooking.hpp" +#include "gta/enums.hpp" namespace big { @@ -49,5 +50,48 @@ namespace big src->set_return_value(NETWORK::NETWORK_TRY_TO_SET_THIS_SCRIPT_IS_NETWORK_SCRIPT(src->get_arg(0), src->get_arg(1), src->get_arg(2))); } + + void SET_CURRENT_PED_WEAPON(rage::scrNativeCallContext* src) + { + const auto ped = src->get_arg(0); + const auto hash = src->get_arg(1); + + if (g.weapons.interior_weapon && ped == self::ped && hash == RAGE_JOAAT("WEAPON_UNARMED")) + return; + + WEAPON::SET_CURRENT_PED_WEAPON(ped, hash, src->get_arg(2)); + } + + void DISABLE_CONTROL_ACTION(rage::scrNativeCallContext* src) + { + const auto action = src->get_arg(1); + + if (g.weapons.interior_weapon) + { + switch (action) + { + case ControllerInputs::INPUT_SELECT_WEAPON: + case ControllerInputs::INPUT_VEH_SELECT_NEXT_WEAPON: + case ControllerInputs::INPUT_VEH_SELECT_PREV_WEAPON: + case ControllerInputs::INPUT_DETONATE: + case ControllerInputs::INPUT_PICKUP: + case ControllerInputs::INPUT_JUMP: + case ControllerInputs::INPUT_TALK: + case ControllerInputs::INPUT_AIM: + case ControllerInputs::INPUT_MELEE_ATTACK_LIGHT: + case ControllerInputs::INPUT_MELEE_ATTACK_HEAVY: + case ControllerInputs::INPUT_MELEE_ATTACK_ALTERNATE: + case ControllerInputs::INPUT_MELEE_BLOCK: + case ControllerInputs::INPUT_VEH_ATTACK: + case ControllerInputs::INPUT_VEH_ATTACK2: + case ControllerInputs::INPUT_VEH_AIM: + case ControllerInputs::INPUT_VEH_PASSENGER_ATTACK: + case ControllerInputs::INPUT_VEH_FLY_SELECT_NEXT_WEAPON: + return; + } + } + + PAD::DISABLE_CONTROL_ACTION(src->get_arg(0), (int)action, src->get_arg(2)); + } } } \ No newline at end of file diff --git a/src/native_hooks/native_hooks.cpp b/src/native_hooks/native_hooks.cpp index 0c1c9f16..3af77006 100644 --- a/src/native_hooks/native_hooks.cpp +++ b/src/native_hooks/native_hooks.cpp @@ -106,6 +106,8 @@ namespace big add_native_detour(0x812595A0644CE1DE, all_scripts::IS_DLC_PRESENT); add_native_detour(0x1CA59E306ECB80A5, all_scripts::NETWORK_SET_THIS_SCRIPT_IS_NETWORK_SCRIPT); add_native_detour(0xD1110739EEADB592, all_scripts::NETWORK_TRY_TO_SET_THIS_SCRIPT_IS_NETWORK_SCRIPT); + add_native_detour(0xADF692B254977C0C, all_scripts::SET_CURRENT_PED_WEAPON); + add_native_detour(0xFE99B66D079CF6BC, all_scripts::DISABLE_CONTROL_ACTION); add_native_detour(RAGE_JOAAT("carmod_shop"), 0x06843DA7060A026B, carmod_shop::SET_ENTITY_COORDS); add_native_detour(RAGE_JOAAT("carmod_shop"), 0x8E2530AA8ADA980E, carmod_shop::SET_ENTITY_HEADING); diff --git a/src/views/self/view_weapons.cpp b/src/views/self/view_weapons.cpp index 6eccdc6a..919c3ae3 100644 --- a/src/views/self/view_weapons.cpp +++ b/src/views/self/view_weapons.cpp @@ -17,6 +17,7 @@ namespace big components::command_checkbox<"infammo">(); components::command_checkbox<"infclip">(); + ImGui::Checkbox("Interior Weapon", &g.weapons.interior_weapon); ImGui::EndGroup(); ImGui::SameLine();