From 168a85c139011f16abd672cb5cbd974988311ae9 Mon Sep 17 00:00:00 2001 From: Aure7138 <100095051+Aure7138@users.noreply.github.com> Date: Tue, 28 Feb 2023 20:42:23 +0800 Subject: [PATCH] feat(vehicle): no collision and all weapons (#1030) --- src/backend/looped/vehicle/no_collision.cpp | 26 +++++++ .../looped/vehicle/unlimited_weapons.cpp | 26 +++++++ src/core/globals.hpp | 4 +- src/native_hooks/all_scripts.hpp | 71 ++++++++++++++----- src/native_hooks/casino.hpp | 10 --- src/native_hooks/native_hooks.cpp | 5 +- src/pointers.cpp | 12 ++++ src/pointers.hpp | 3 + src/views/vehicle/view_vehicle.cpp | 2 + 9 files changed, 128 insertions(+), 31 deletions(-) create mode 100644 src/backend/looped/vehicle/no_collision.cpp create mode 100644 src/backend/looped/vehicle/unlimited_weapons.cpp delete mode 100644 src/native_hooks/casino.hpp diff --git a/src/backend/looped/vehicle/no_collision.cpp b/src/backend/looped/vehicle/no_collision.cpp new file mode 100644 index 00000000..02928fc2 --- /dev/null +++ b/src/backend/looped/vehicle/no_collision.cpp @@ -0,0 +1,26 @@ +#include "backend/looped_command.hpp" +#include "pointers.hpp" + +namespace big +{ + class veh_no_collision : looped_command + { + using looped_command::looped_command; + + virtual void on_enable() override + { + g_pointers->m_disable_collision->apply(); + } + + virtual void on_tick() override + { + + } + + virtual void on_disable() override + { + g_pointers->m_disable_collision->restore(); + } + }; + veh_no_collision g_veh_no_collision("vehnocollision", "No Collision", "Same as Ped No Collision, except this is global and also affects Ped", g.vehicle.no_collision); +} diff --git a/src/backend/looped/vehicle/unlimited_weapons.cpp b/src/backend/looped/vehicle/unlimited_weapons.cpp new file mode 100644 index 00000000..4206656e --- /dev/null +++ b/src/backend/looped/vehicle/unlimited_weapons.cpp @@ -0,0 +1,26 @@ +#include "backend/looped_command.hpp" +#include "pointers.hpp" + +namespace big +{ + class veh_unlimited_weapons : looped_command + { + using looped_command::looped_command; + + virtual void on_enable() override + { + g_pointers->m_allow_weapons_in_vehicle->apply(); + } + + virtual void on_tick() override + { + + } + + virtual void on_disable() override + { + g_pointers->m_allow_weapons_in_vehicle->restore(); + } + }; + veh_unlimited_weapons g_veh_unlimited_weapons("vehallweapons", "Allow Weapons In Vehicle", "Allows you to use all weapons in vehicle", g.vehicle.unlimited_weapons); +} diff --git a/src/core/globals.hpp b/src/core/globals.hpp index 70b7f5c9..827321a1 100644 --- a/src/core/globals.hpp +++ b/src/core/globals.hpp @@ -591,6 +591,8 @@ namespace big bool localveh_visibility = false; bool localped_visibility = true; bool keep_on_ground = false; + bool no_collision = false; + bool unlimited_weapons = false; NLOHMANN_DEFINE_TYPE_INTRUSIVE(vehicle, speedo_meter, fly, rainbow_paint, speed_unit, god_mode, @@ -598,7 +600,7 @@ namespace big auto_drive_destination, auto_drive_style, auto_drive_speed, auto_turn_signals, boost_behavior, drive_on_water, horn_boost, instant_brake, block_homing, seatbelt, turn_signals, vehicle_jump, keep_vehicle_repaired, no_water_collision, disable_engine_auto_start, change_engine_state_immediately, - vehinvisibility, localveh_visibility, localped_visibility, keep_on_ground) + vehinvisibility, localveh_visibility, localped_visibility, keep_on_ground, no_collision, unlimited_weapons) } vehicle{}; struct weapons diff --git a/src/native_hooks/all_scripts.hpp b/src/native_hooks/all_scripts.hpp index 321f820c..1fde1487 100644 --- a/src/native_hooks/all_scripts.hpp +++ b/src/native_hooks/all_scripts.hpp @@ -66,32 +66,66 @@ namespace big { const auto action = src->get_arg(1); - if (g.weapons.interior_weapon) + if (g.weapons.interior_weapon) // Filtering from the inside of Kosatka { switch (action) { + // case ControllerInputs::INPUT_JUMP: TODO: add as separate feature + case ControllerInputs::INPUT_ATTACK: + case ControllerInputs::INPUT_AIM: + case ControllerInputs::INPUT_DUCK: case ControllerInputs::INPUT_SELECT_WEAPON: + case ControllerInputs::INPUT_COVER: + case ControllerInputs::INPUT_TALK: + case ControllerInputs::INPUT_DETONATE: + case ControllerInputs::INPUT_WEAPON_SPECIAL: + case ControllerInputs::INPUT_WEAPON_SPECIAL_TWO: + case ControllerInputs::INPUT_VEH_AIM: + case ControllerInputs::INPUT_VEH_ATTACK: + case ControllerInputs::INPUT_VEH_ATTACK2: + case ControllerInputs::INPUT_VEH_HEADLIGHT: + case ControllerInputs::INPUT_VEH_NEXT_RADIO: + case ControllerInputs::INPUT_VEH_PREV_RADIO: + case ControllerInputs::INPUT_VEH_NEXT_RADIO_TRACK: + case ControllerInputs::INPUT_VEH_PREV_RADIO_TRACK: + case ControllerInputs::INPUT_VEH_RADIO_WHEEL: + case ControllerInputs::INPUT_VEH_PASSENGER_AIM: + case ControllerInputs::INPUT_VEH_PASSENGER_ATTACK: 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: TODO: add as separate feature - case ControllerInputs::INPUT_TALK: - case ControllerInputs::INPUT_AIM: + case ControllerInputs::INPUT_VEH_ROOF: + case ControllerInputs::INPUT_VEH_JUMP: + case ControllerInputs::INPUT_VEH_FLY_ATTACK: 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: - case ControllerInputs::INPUT_ATTACK: - case ControllerInputs::INPUT_NEXT_WEAPON: - case ControllerInputs::INPUT_PREV_WEAPON: - case ControllerInputs::INPUT_SELECT_NEXT_WEAPON: - case ControllerInputs::INPUT_SELECT_PREV_WEAPON: + case ControllerInputs::INPUT_SELECT_WEAPON_UNARMED: + case ControllerInputs::INPUT_SELECT_WEAPON_MELEE: + case ControllerInputs::INPUT_SELECT_WEAPON_HANDGUN: + case ControllerInputs::INPUT_SELECT_WEAPON_SHOTGUN: + case ControllerInputs::INPUT_SELECT_WEAPON_SMG: + case ControllerInputs::INPUT_SELECT_WEAPON_AUTO_RIFLE: + case ControllerInputs::INPUT_SELECT_WEAPON_SNIPER: + case ControllerInputs::INPUT_SELECT_WEAPON_HEAVY: + case ControllerInputs::INPUT_SELECT_WEAPON_SPECIAL: + case ControllerInputs::INPUT_ATTACK2: + case ControllerInputs::INPUT_MELEE_ATTACK1: + case ControllerInputs::INPUT_MELEE_ATTACK2: + case ControllerInputs::INPUT_VEH_GUN_LEFT: + case ControllerInputs::INPUT_VEH_GUN_RIGHT: + case ControllerInputs::INPUT_VEH_GUN_UP: + case ControllerInputs::INPUT_VEH_GUN_DOWN: + case ControllerInputs::INPUT_VEH_HYDRAULICS_CONTROL_TOGGLE: + case ControllerInputs::INPUT_VEH_MELEE_HOLD: + case ControllerInputs::INPUT_VEH_MELEE_LEFT: + case ControllerInputs::INPUT_VEH_MELEE_RIGHT: + case ControllerInputs::INPUT_VEH_CAR_JUMP: + case ControllerInputs::INPUT_VEH_ROCKET_BOOST: + case ControllerInputs::INPUT_VEH_FLY_BOOST: + case ControllerInputs::INPUT_VEH_PARACHUTE: + case ControllerInputs::INPUT_VEH_BIKE_WINGS: + case ControllerInputs::INPUT_VEH_TRANSFORM: return; } } @@ -106,5 +140,10 @@ namespace big HUD::HUD_FORCE_WEAPON_WHEEL(src->get_arg(0)); } + + void NETWORK_CASINO_CAN_BET(rage::scrNativeCallContext* src) + { + src->set_return_value(TRUE); + } } } \ No newline at end of file diff --git a/src/native_hooks/casino.hpp b/src/native_hooks/casino.hpp deleted file mode 100644 index ebb3db26..00000000 --- a/src/native_hooks/casino.hpp +++ /dev/null @@ -1,10 +0,0 @@ -namespace big -{ - namespace casino - { - void NETWORK_CASINO_CAN_BET(rage::scrNativeCallContext* src) - { - src->set_return_value(TRUE); - } - } -} \ No newline at end of file diff --git a/src/native_hooks/native_hooks.cpp b/src/native_hooks/native_hooks.cpp index 21eb1d2f..d0358bd3 100644 --- a/src/native_hooks/native_hooks.cpp +++ b/src/native_hooks/native_hooks.cpp @@ -6,7 +6,6 @@ #include "shop_controller.hpp" #include "network_session_host.hpp" #include "am_launcher.hpp" -#include "casino.hpp" #include "creator.hpp" #include "crossmap.hpp" @@ -110,6 +109,7 @@ namespace big add_native_detour(0xADF692B254977C0C, all_scripts::SET_CURRENT_PED_WEAPON); add_native_detour(0xFE99B66D079CF6BC, all_scripts::DISABLE_CONTROL_ACTION); add_native_detour(0xEB354E5376BC81A7, all_scripts::HUD_FORCE_WEAPON_WHEEL); + add_native_detour(0x158C16F5E4CF41F8, all_scripts::NETWORK_CASINO_CAN_BET); //bypass casino country restrictions 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); @@ -144,9 +144,6 @@ namespace big add_native_detour(RAGE_JOAAT("fm_lts_creator"), 0x3D3D8B3BE5A83D35, creator::GET_USED_CREATOR_BUDGET); add_native_detour(RAGE_JOAAT("fm_survival_creator"), 0x3D3D8B3BE5A83D35, creator::GET_USED_CREATOR_BUDGET); - //bypass casino country restrictions - add_native_detour(0x158C16F5E4CF41F8, casino::NETWORK_CASINO_CAN_BET); - for (auto& entry : *g_pointers->m_script_program_table) if (entry.m_program) hook_program(entry.m_program); diff --git a/src/pointers.cpp b/src/pointers.cpp index 21d07f9e..e83c6320 100644 --- a/src/pointers.cpp +++ b/src/pointers.cpp @@ -819,6 +819,18 @@ namespace big m_write_player_camera_data_node = ptr.as(); }); + // DC + main_batch.add("DC", "48 8B D1 49 8B CA ? ? ? ? ? 48 8B D1 49 8B CA", [this](memory::handle ptr) + { + m_disable_collision = memory::byte_patch::make(ptr.sub(2).as(), 0xEB).get(); + }); + + // AWIV + main_batch.add("AWIV", "49 3B C9 7C F0 ? ? C3", [this](memory::handle ptr) + { + m_allow_weapons_in_vehicle = memory::byte_patch::make(ptr.add(5).as(), 0x01B0).get(); //In order for the second xref loop not to stop + }); + auto mem_region = memory::module("GTA5.exe"); if (!main_batch.run(mem_region)) { diff --git a/src/pointers.hpp b/src/pointers.hpp index 8775e7f8..e204c0c9 100644 --- a/src/pointers.hpp +++ b/src/pointers.hpp @@ -240,6 +240,9 @@ namespace big PVOID m_receive_pickup{}; PVOID m_write_player_camera_data_node{}; + + memory::byte_patch* m_disable_collision{}; + memory::byte_patch* m_allow_weapons_in_vehicle{}; }; inline pointers* g_pointers{}; diff --git a/src/views/vehicle/view_vehicle.cpp b/src/views/vehicle/view_vehicle.cpp index 922d296e..d308e0ec 100644 --- a/src/views/vehicle/view_vehicle.cpp +++ b/src/views/vehicle/view_vehicle.cpp @@ -76,6 +76,8 @@ namespace big { components::command_checkbox<"localinvisveh">(); } + components::command_checkbox<"vehnocollision">(); + components::command_checkbox<"vehallweapons">(); ImGui::EndGroup(); ImGui::SameLine();