From 233fcd244f771ae1770b6d9821bf0abdae43fb8e Mon Sep 17 00:00:00 2001 From: Grinch_ Date: Sun, 3 Jan 2021 17:48:07 +0600 Subject: [PATCH] New stuff & fixes 1. Improved project structure #46 2. Refactored internal json code 3. Fixed command console not working 4. Added veh command in command console 5. Added options to remove ped and car in certain radius 6. Added teleport fade effect 7. Fixed getting buried when teleporting 8. Fixed an issue with bomb remote --- CMakeLists.txt | 1 + src/Animation.cpp | 2 + src/CMakeLists.txt | 90 ++------------ src/CheatMenu.cpp | 12 +- src/Game.cpp | 25 +++- src/Hook.cpp | 14 +-- src/Json.cpp | 31 ----- src/Json.h | 40 ++++++- src/Menu.cpp | 27 ++++- src/MenuInfo.h | 5 + src/NeonAPI.cpp | 1 + src/Paint.cpp | 1 + src/Paint.h | 2 +- src/Ped.cpp | 29 ++++- src/Ped.h | 1 + src/Player.cpp | 3 +- src/Teleport.cpp | 7 +- src/Ui.cpp | 5 +- src/Util.cpp | 28 ++++- src/Util.h | 4 +- src/Vehicle.cpp | 35 +++++- src/Vehicle.h | 6 +- src/Visual.cpp | 2 + src/Weapon.cpp | 10 ++ src/pch.cpp | 2 - src/pch.h | 19 +-- src/vendor/CMakeLists.txt | 112 ++++++++++++++++++ src/{external => vendor}/imgui/imconfig.h | 0 src/{external => vendor}/imgui/imgui.cpp | 0 src/{external => vendor}/imgui/imgui.h | 0 src/{external => vendor}/imgui/imgui_demo.cpp | 0 src/{external => vendor}/imgui/imgui_draw.cpp | 0 .../imgui/imgui_impl_dx11.cpp | 0 .../imgui/imgui_impl_dx11.h | 0 .../imgui/imgui_impl_dx9.cpp | 0 .../imgui/imgui_impl_dx9.h | 0 .../imgui/imgui_impl_win32.cpp | 0 .../imgui/imgui_impl_win32.h | 0 .../imgui/imgui_internal.h | 0 .../imgui/imgui_widgets.cpp | 0 .../imgui/imstb_rectpack.h | 0 .../imgui/imstb_textedit.h | 0 .../imgui/imstb_truetype.h | 0 src/{external => vendor}/imgui/stb_image.h | 0 src/{external => vendor}/json.hpp | 0 src/{external => vendor}/kiero/kiero.cpp | 0 src/{external => vendor}/kiero/kiero.h | 0 .../kiero/minhook/include/MinHook.h | 0 .../minhook/lib/libMinHook-x86-v140-md.lib | Bin .../minhook/lib/libMinHook-x86-v140-mdd.lib | Bin .../minhook/lib/libMinHook-x86-v140-mt.lib | Bin .../minhook/lib/libMinHook-x86-v140-mtd.lib | Bin .../moon/pool_object_extender.h | 0 .../moon/vehicle_renderer.cpp | 0 .../moon/vehicle_renderer.h | 0 55 files changed, 344 insertions(+), 170 deletions(-) create mode 100644 src/MenuInfo.h create mode 100644 src/vendor/CMakeLists.txt rename src/{external => vendor}/imgui/imconfig.h (100%) rename src/{external => vendor}/imgui/imgui.cpp (100%) rename src/{external => vendor}/imgui/imgui.h (100%) rename src/{external => vendor}/imgui/imgui_demo.cpp (100%) rename src/{external => vendor}/imgui/imgui_draw.cpp (100%) rename src/{external => vendor}/imgui/imgui_impl_dx11.cpp (100%) rename src/{external => vendor}/imgui/imgui_impl_dx11.h (100%) rename src/{external => vendor}/imgui/imgui_impl_dx9.cpp (100%) rename src/{external => vendor}/imgui/imgui_impl_dx9.h (100%) rename src/{external => vendor}/imgui/imgui_impl_win32.cpp (100%) rename src/{external => vendor}/imgui/imgui_impl_win32.h (100%) rename src/{external => vendor}/imgui/imgui_internal.h (100%) rename src/{external => vendor}/imgui/imgui_widgets.cpp (100%) rename src/{external => vendor}/imgui/imstb_rectpack.h (100%) rename src/{external => vendor}/imgui/imstb_textedit.h (100%) rename src/{external => vendor}/imgui/imstb_truetype.h (100%) rename src/{external => vendor}/imgui/stb_image.h (100%) rename src/{external => vendor}/json.hpp (100%) rename src/{external => vendor}/kiero/kiero.cpp (100%) rename src/{external => vendor}/kiero/kiero.h (100%) rename src/{external => vendor}/kiero/minhook/include/MinHook.h (100%) rename src/{external => vendor}/kiero/minhook/lib/libMinHook-x86-v140-md.lib (100%) rename src/{external => vendor}/kiero/minhook/lib/libMinHook-x86-v140-mdd.lib (100%) rename src/{external => vendor}/kiero/minhook/lib/libMinHook-x86-v140-mt.lib (100%) rename src/{external => vendor}/kiero/minhook/lib/libMinHook-x86-v140-mtd.lib (100%) rename src/{external => vendor}/moon/pool_object_extender.h (100%) rename src/{external => vendor}/moon/vehicle_renderer.cpp (100%) rename src/{external => vendor}/moon/vehicle_renderer.h (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 75ed59b..0a93655 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -281,5 +281,6 @@ endfunction() ################################################################################ # Sub-projects ################################################################################ +add_subdirectory(src/vendor) add_subdirectory(src) diff --git a/src/Animation.cpp b/src/Animation.cpp index 2cbfd1c..b550e9f 100644 --- a/src/Animation.cpp +++ b/src/Animation.cpp @@ -1,5 +1,7 @@ #include "pch.h" #include "Animation.h" +#include "Ui.h" +#include "Util.h" bool Animation::loop = false; bool Animation::secondary = false; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 10d431f..c0a5197 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,23 +1,13 @@ ################################################################################ # Source groups ################################################################################ -set(no_group_source_files +set(src_files "Animation.cpp" "Animation.h" "CheatMenu.cpp" "CheatMenu.h" "Events.cpp" "Events.h" - "external/imgui/imgui_impl_dx11.cpp" - "external/imgui/imgui_impl_dx11.h" - "external/imgui/stb_image.h" - "external/json.hpp" - "external/kiero/kiero.cpp" - "external/kiero/kiero.h" - "external/kiero/minhook/include/MinHook.h" - "external/moon/pool_object_extender.h" - "external/moon/vehicle_renderer.h" - "external/moon/vehicle_renderer.cpp" "Game.cpp" "Game.h" "Hook.cpp" @@ -26,6 +16,7 @@ set(no_group_source_files "Json.h" "Menu.cpp" "Menu.h" + "MenuInfo.h" "NeonAPI.cpp" "NeonAPI.h" "Paint.cpp" @@ -50,35 +41,11 @@ set(no_group_source_files "Weapon.cpp" "Weapon.h" ) -source_group("" FILES ${no_group_source_files}) - -set(external - "external/imgui/imconfig.h" - "external/imgui/imgui.cpp" - "external/imgui/imgui.h" - "external/imgui/imgui_demo.cpp" - "external/imgui/imgui_draw.cpp" - "external/imgui/imgui_impl_dx9.cpp" - "external/imgui/imgui_impl_dx9.h" - "external/imgui/imgui_impl_win32.cpp" - "external/imgui/imgui_impl_win32.h" - "external/imgui/imgui_internal.h" - "external/imgui/imgui_widgets.cpp" - "external/imgui/imstb_rectpack.h" - "external/imgui/imstb_textedit.h" - "external/imgui/imstb_truetype.h" -) -source_group("external" FILES ${external}) - -set(ALL_FILES - ${no_group_source_files} - ${external} -) ################################################################################ # Target ################################################################################ -add_library(${PROJECT_NAME} SHARED ${ALL_FILES}) +add_library(${PROJECT_NAME} SHARED ${src_files}) add_precompiled_header(${PROJECT_NAME} "pch.h" "pch.cpp") @@ -155,48 +122,15 @@ if(MSVC) string(CONCAT FILE_CL_OPTIONS "/Y-" ) - source_file_compile_options(external/imgui/imgui_impl_dx11.cpp ${FILE_CL_OPTIONS}) - string(CONCAT FILE_CL_OPTIONS - "/Y-" - ) - source_file_compile_options(external/kiero/kiero.cpp ${FILE_CL_OPTIONS}) - string(CONCAT FILE_CL_OPTIONS - "/Y-" - ) - source_file_compile_options(external/moon/vehicle_renderer.cpp ${FILE_CL_OPTIONS}) - string(CONCAT FILE_CL_OPTIONS - "/Y-" - ) - source_file_compile_options(external/imgui/imgui.cpp ${FILE_CL_OPTIONS}) - string(CONCAT FILE_CL_OPTIONS - "/Y-" - ) - source_file_compile_options(external/imgui/imgui_demo.cpp ${FILE_CL_OPTIONS}) - string(CONCAT FILE_CL_OPTIONS - "/Y-" - ) - source_file_compile_options(external/imgui/imgui_draw.cpp ${FILE_CL_OPTIONS}) - string(CONCAT FILE_CL_OPTIONS - "/Y-" - ) - source_file_compile_options(external/imgui/imgui_impl_dx9.cpp ${FILE_CL_OPTIONS}) - string(CONCAT FILE_CL_OPTIONS - "/Y-" - ) - source_file_compile_options(external/imgui/imgui_impl_win32.cpp ${FILE_CL_OPTIONS}) - string(CONCAT FILE_CL_OPTIONS - "/Y-" - ) - source_file_compile_options(external/imgui/imgui_widgets.cpp ${FILE_CL_OPTIONS}) target_link_options(${PROJECT_NAME} PRIVATE $<$: - /SAFESEH:NO; /OPT:REF; /LTCG; - /OPT:ICF + /OPT:ICF; > $<$: /DEBUG:FULL; + /SAFESEH:NO; > /SUBSYSTEM:WINDOWS ) @@ -218,21 +152,23 @@ add_custom_command_if( ################################################################################ target_link_libraries(${PROJECT_NAME} PUBLIC optimized plugin -optimized libMinHook-x86-v140-mt -optimized libMinHook-x86-v140-md debug plugin_d -debug libMinHook-x86-v140-mtd -debug libMinHook-x86-v140-mdd d3d9 d3dx9 d3d11 d3dx11 XInput9_1_0 +Vendor ) target_link_directories(${PROJECT_NAME} PUBLIC "${PLUGIN_SDK_DIR}/output/lib/" - "$ENV{DIRECTX9_SDK_DIR}/lib/x86/" - "external/kiero/minhook/lib/" + "${DX9_DIR}/lib/x86/" + "$<$:" + "vendor/Release/" + ">" + "$<$:" + "vendor/Debug/" + ">" ) diff --git a/src/CheatMenu.cpp b/src/CheatMenu.cpp index e753491..f24a319 100644 --- a/src/CheatMenu.cpp +++ b/src/CheatMenu.cpp @@ -1,5 +1,7 @@ #include "pch.h" #include "CheatMenu.h" +#include "MenuInfo.h" +#include "Ui.h" unsortedMap CheatMenu::header{ { "Teleport", &Teleport::Main },{ "Player", &Player::Main },{ "Ped", &Ped::Main }, @@ -10,7 +12,7 @@ unsortedMap CheatMenu::header{ void CheatMenu::ProcessMenu() { ImGui::SetNextWindowSize(Globals::menu_size); - if (ImGui::Begin(Globals::menu_title.c_str(), &Globals::show_menu, ImGuiWindowFlags_NoCollapse)) + if (ImGui::Begin(MENU_TITLE, &Globals::show_menu, ImGuiWindowFlags_NoCollapse)) { ImGui::PushStyleVar(ImGuiStyleVar_WindowMinSize, ImVec2(250, 350)); ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(ImGui::GetWindowWidth() / 85, ImGui::GetWindowHeight() / 200)); @@ -49,7 +51,7 @@ CheatMenu::CheatMenu() Events::initRwEvent += []() { // Load menu settings - Globals::header_id = config.GetValueStr("window.id",""); + Globals::header_id = config.GetValue("window.id",std::string("")); Globals::menu_size.x = config.GetValue("window.sizeX", screen::GetScreenWidth() / 4.0f); Globals::menu_size.y = config.GetValue("window.sizeY", screen::GetScreenHeight() / 1.2f); srand(CTimer::m_snTimeInMilliseconds); @@ -68,7 +70,13 @@ CheatMenu::CheatMenu() if (Ui::HotKeyPressed(hotkey::command_window)) { + if (Menu::commands::show_menu) + { + Menu::ProcessCommands(); + strcpy(commands::input_buffer,""); + } Menu::commands::show_menu = !Menu::commands::show_menu; + Globals::last_key_timer = CTimer::m_snTimeInMilliseconds; } diff --git a/src/Game.cpp b/src/Game.cpp index 205aa21..dff10a1 100644 --- a/src/Game.cpp +++ b/src/Game.cpp @@ -1,6 +1,8 @@ #include "pch.h" #include "Game.h" #include "Menu.h" +#include "Ui.h" +#include "Util.h" ImGuiTextFilter Game::filter = ""; std::vector Game::search_categories; @@ -43,6 +45,8 @@ uint Game::solid_water_object = 0; CJson Game::random_cheats::name_json = CJson("cheat name"); +static bool mission_warning_shown = false; + // Thanks to aap void RealTimeClock(void) { @@ -431,15 +435,26 @@ of LS without completing missions")) { ImGui::Spacing(); - if (ImGui::Button("Fail current mission", ImVec2(Ui::GetSize()))) + if (!mission_warning_shown) { - if (!CCutsceneMgr::ms_running) - Command(); + ImGui::TextWrapped("Mission selector might cause unintended changes to your game. \ +It's recommanded not to save your game after using this. Use it at your own risk!"); + ImGui::Spacing(); + if (ImGui::Button("Show mission selector", ImVec2(Ui::GetSize())))\ + mission_warning_shown = true; } + else + { + if (ImGui::Button("Fail current mission", ImVec2(Ui::GetSize()))) + { + if (!CCutsceneMgr::ms_running) + Command(); + } - ImGui::Spacing(); + ImGui::Spacing(); - Ui::DrawJSON(json, search_categories, selected_item, filter, SetPlayerMission, nullptr); + Ui::DrawJSON(json, search_categories, selected_item, filter, SetPlayerMission, nullptr); + } ImGui::EndTabItem(); } if (ImGui::BeginTabItem("Stats")) diff --git a/src/Hook.cpp b/src/Hook.cpp index 9451734..9136ca2 100644 --- a/src/Hook.cpp +++ b/src/Hook.cpp @@ -1,7 +1,7 @@ #include "pch.h" #include "Hook.h" -#include "external/kiero/kiero.h" -#include "external/kiero/minhook/include/MinHook.h" +#include "vendor/kiero/kiero.h" +#include "vendor/kiero/minhook/include/MinHook.h" WNDPROC Hook::oWndProc = NULL; f_Reset Hook::oReset9 = NULL; @@ -15,7 +15,6 @@ std::function Hook::window_func = NULL; LRESULT Hook::InputProc(const HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { - ImGui_ImplWin32_WndProcHandler(hWnd, uMsg, wParam, lParam); if (ImGui::GetIO().WantTextInput) @@ -60,14 +59,6 @@ HRESULT Hook::PresentDx9(IDirect3DDevice9 *pDevice, RECT* pSourceRect, RECT* pDe Globals::font_screen_size = ImVec2(screen::GetScreenWidth(), screen::GetScreenHeight()); } - static RwBool fullscreen = RsGlobal.ps->fullScreen; - if (fullscreen != RsGlobal.ps->fullScreen) - { - flog << "LETS GO" << std::endl; - fullscreen = RsGlobal.ps->fullScreen; - ImGui_ImplDX9_InvalidateDeviceObjects(); - } - ImGui_ImplDX9_NewFrame(); ImGui_ImplWin32_NewFrame(); ImGui::NewFrame(); @@ -164,6 +155,7 @@ HRESULT Hook::PresentDx11(IDXGISwapChain* pSwapChain, UINT SyncInterval, UINT Fl return oPresent11(pSwapChain, SyncInterval, Flags); } +// Thanks imring void Hook::ShowMouse(bool state) { if (state) diff --git a/src/Json.cpp b/src/Json.cpp index f65bb35..467cc38 100644 --- a/src/Json.cpp +++ b/src/Json.cpp @@ -39,37 +39,6 @@ void CJson::LoadData(std::vector& vec, std::string& selected) // Te vec.push_back(element.key()); } -std::string CJson::GetValueStr(std::string&& key, std::string&& default_val) -{ - try { - std::stringstream ss(key); - std::string line; - - nlohmann::json *json = &data; - - while (getline(ss, line, '.')) - json = &((*json)[line]); - - return json->get(); - } - catch (...) { - return default_val; - } -} - -void CJson::SetValueStr(std::string&& key, std::string& val) -{ - std::stringstream ss(key); - std::string line; - - nlohmann::json *json = &data; - - while (getline(ss, line, '.')) - json = &((*json)[line]); - - *json = val; -} - CJson::~CJson() { // Saving here won't work on crash diff --git a/src/Json.h b/src/Json.h index a6da729..eb35790 100644 --- a/src/Json.h +++ b/src/Json.h @@ -1,5 +1,5 @@ #pragma once -#include "external\json.hpp" +#include "vendor\json.hpp" class CJson { @@ -13,8 +13,7 @@ public: Returns a value from json structure hierarchy using '.' Example: "Menu.Window.X" */ - // overload since typeid(std::string) doesn't work - std::string GetValueStr(std::string&& key, std::string&& default_val); + // specialize since typeid(std::string) doesn't work template T GetValue(std::string&& key, T&& default_val) @@ -40,6 +39,25 @@ public: return default_val; } } + + template<> + std::string GetValue(std::string&& key, std::string&& default_val) + { + try { + std::stringstream ss(key); + std::string line; + + nlohmann::json *json = &data; + + while (getline(ss, line, '.')) + json = &((*json)[line]); + + return json->get(); + } + catch (...) { + return default_val; + } + } /* Allows to save values in json hierarchy using '.' @@ -47,7 +65,7 @@ public: */ template - void SetValue(std::string&& key, T&& val) + void SetValue(std::string&& key, T& val) { std::stringstream ss(key); std::string line; @@ -64,7 +82,19 @@ public: *json = val; } - void SetValueStr(std::string&& key, std::string& val); + template<> + void SetValue(std::string&& key, std::string& val) + { + std::stringstream ss(key); + std::string line; + + nlohmann::json *json = &data; + + while (getline(ss, line, '.')) + json = &((*json)[line]); + + *json = val; + } /* Loads the section names into a category vector. Used to create drop down category menus diff --git a/src/Menu.cpp b/src/Menu.cpp index f2163a7..d34861f 100644 --- a/src/Menu.cpp +++ b/src/Menu.cpp @@ -1,7 +1,11 @@ #include "pch.h" +#include "MenuInfo.h" #include "Menu.h" #include "Teleport.h" #include "Weapon.h" +#include "Vehicle.h" +#include "Ui.h" +#include "Util.h" bool Menu::overlay::coord = false; bool Menu::overlay::fps = false; @@ -150,7 +154,12 @@ void Menu::ProcessShortcutsWindow() ImGui::SetNextItemWidth(resX); ImGui::SetKeyboardFocusHere(-1); - ImGui::InputTextWithHint("##TEXTFIELD", "Enter command", commands::input_buffer, INPUT_BUFFER_SIZE); + if (ImGui::InputTextWithHint("##TEXTFIELD", "Enter command", commands::input_buffer, INPUT_BUFFER_SIZE, ImGuiInputTextFlags_EnterReturnsTrue)) + { + ProcessCommands(); + commands::show_menu = false; + strcpy(commands::input_buffer,""); + } ImGui::PopStyleVar(2); ImGui::End(); @@ -239,6 +248,22 @@ void Menu::ProcessCommands() CHud::SetHelpMessage("Invalid command", false, false, false); } + return; + } + if (command == "veh") + { + std::string veh_name; + ss >> veh_name; + + int model = Vehicle::GetModelFromName(veh_name.c_str()); + if (model != 0) + { + Vehicle::SpawnVehicle(std::to_string(model)); + CHud::SetHelpMessage("Vehicle spawned", false, false, false); + } + else + CHud::SetHelpMessage("Invalid command", false, false, false); + return; } } diff --git a/src/MenuInfo.h b/src/MenuInfo.h new file mode 100644 index 0000000..0a0e3b3 --- /dev/null +++ b/src/MenuInfo.h @@ -0,0 +1,5 @@ +#pragma once +#define MENU_NAME "Cheat Menu" +#define MENU_VERSION "2.5-beta" +#define BUILD_NUMBER "20210103" +#define MENU_TITLE MENU_NAME " v" MENU_VERSION "(" BUILD_NUMBER ")" \ No newline at end of file diff --git a/src/NeonAPI.cpp b/src/NeonAPI.cpp index 672cec8..ecf3988 100644 --- a/src/NeonAPI.cpp +++ b/src/NeonAPI.cpp @@ -1,5 +1,6 @@ #include "pch.h" #include "NeonAPI.h" +#include "Util.h" VehicleExtendedData NeonAPI::VehNeon; RwTexture* NeonAPI::neon_texture = nullptr; diff --git a/src/Paint.cpp b/src/Paint.cpp index 57ac225..25301c1 100644 --- a/src/Paint.cpp +++ b/src/Paint.cpp @@ -1,6 +1,7 @@ #include "pch.h" #include "Paint.h" #include "NodeName.h" +#include "Util.h" std::vector Paint::veh_nodes::names_vec{ "Default" }; std::string Paint::veh_nodes::selected = "Default"; diff --git a/src/Paint.h b/src/Paint.h index fa58863..85af5f9 100644 --- a/src/Paint.h +++ b/src/Paint.h @@ -1,5 +1,5 @@ #pragma once -#include "external/moon/vehicle_renderer.h" +#include "vendor/moon/vehicle_renderer.h" class Paint : VehicleRenderer { diff --git a/src/Ped.cpp b/src/Ped.cpp index 872965c..4c32533 100644 --- a/src/Ped.cpp +++ b/src/Ped.cpp @@ -1,5 +1,7 @@ #include "pch.h" #include "Ped.h" +#include "Ui.h" +#include "Util.h" ImGuiTextFilter Ped::filter = ""; std::string Ped::selected_item = "All"; @@ -13,6 +15,7 @@ std::vector Ped::gang_names = { "Ballas", "Grove street families", "Da nang boys", "Mafia", "Mountain cloud triad", "Varrio los aztecas", "Gang9", "Gang10" }; bool Ped::exgangwars_installed = false; +int Ped::ped_remove_radius = 5; std::vector Ped::spawn_ped::list; int Ped::spawn_ped::accuracy = 50; @@ -25,14 +28,11 @@ int Ped::spawn_ped::weapon_id = 0; std::vector Ped::spawn_ped::ped_type = {"Civ male","Civ female","Cop","Ballas","Grove Street Families","Los Santos Vagos", "San Fierro Rifa","Da Nang Boys","Mafia","Mountain Cloud Triads","Varrio Los Aztecas", "Gang 9","Medic","Dealer","Criminal","Fireman","Prostitute"}; - - Ped::Ped() { Events::initGameEvent += [] { - std::string dir_path = Globals::menu_path +"\\CheatMenu\\peds\\"; - Util::LoadTexturesInDirRecursive(dir_path.c_str(), ".jpg", search_categories, peds_vec); + Util::LoadTexturesInDirRecursive(PLUGIN_PATH((char*)"CheatMenu\\peds\\"), ".jpg", search_categories, peds_vec); if (LoadLibraryW(L"ExGangWars.asi")) exgangwars_installed = true; @@ -200,11 +200,28 @@ void Ped::Main() if (ImGui::CollapsingHeader("Recruit anyone")) { - Ui::RadioButtonAddress("Select weapon", std::vector{ {"9mm", 0x96917C}, { "AK47", 0x96917D }, { "Rockets", 0x96917E }}); + static std::vector select_weapon{ {"9mm", 0x96917C}, { "AK47", 0x96917D }, { "Rockets", 0x96917E }}; + Ui::RadioButtonAddress("Select weapon", select_weapon); + ImGui::Spacing(); + ImGui::Separator(); + } + if (ImGui::CollapsingHeader("Remove peds in radius")) + { + ImGui::InputInt("Radius", &ped_remove_radius); + ImGui::Spacing(); + if (ImGui::Button("Remove peds",Ui::GetSize(1))) + { + CPlayerPed *player = FindPlayerPed(); + for (CPed *ped : CPools::ms_pPedPool) + { + if (DistanceBetweenPoints(ped->GetPosition(),player->GetPosition()) < ped_remove_radius + && ped->m_pVehicle == nullptr && ped != player) + Command(CPools::GetPedRef(ped)); + } + } ImGui::Spacing(); ImGui::Separator(); } - ImGui::EndChild(); ImGui::EndTabItem(); } diff --git a/src/Ped.h b/src/Ped.h index 0a317ae..4624b74 100644 --- a/src/Ped.h +++ b/src/Ped.h @@ -16,6 +16,7 @@ private: static std::vector gang_names; static bool exgangwars_installed; + static int ped_remove_radius; struct spawn_ped { static std::vector list; diff --git a/src/Player.cpp b/src/Player.cpp index 2bd11f8..576d2a4 100644 --- a/src/Player.cpp +++ b/src/Player.cpp @@ -1,8 +1,9 @@ #include "pch.h" #include "Player.h" #include "Ped.h" -#include "CCheat.h" #include "Menu.h" +#include "Ui.h" +#include "Util.h" bool Player::keep_position::state = false; CVector Player::keep_position::pos = CVector(); diff --git a/src/Teleport.cpp b/src/Teleport.cpp index d174eac..7362340 100644 --- a/src/Teleport.cpp +++ b/src/Teleport.cpp @@ -1,6 +1,8 @@ #include "pch.h" #include "Teleport.h" #include "Menu.h" +#include "Ui.h" +#include "Util.h" bool Teleport::insert_coord = false; bool Teleport::quick_teleport = false; @@ -75,6 +77,7 @@ Teleport::Teleport() STeleport::_bool = false; Command(CPools::GetPedRef(player), false); Command(); + TheCamera.Fade(0,1); } if (quick_teleport) @@ -111,7 +114,7 @@ void Teleport::TeleportPlayer(bool get_marker, CVector* pos, short interior_id) Teleport::STeleport::pos = *pos; Teleport::STeleport::timer = CTimer::m_snTimeInMilliseconds; Teleport::STeleport::_bool = true; - + TheCamera.Fade(0,0); Command(CPools::GetPedRef(player), true); } @@ -221,7 +224,7 @@ void Teleport::Main() pos.y = std::stof(temp); getline(ss, temp, ','); - pos.z = std::stof(temp); + pos.z = std::stof(temp) + 1.0f; Teleport::TeleportPlayer(false,&pos); } diff --git a/src/Ui.cpp b/src/Ui.cpp index 090c782..259d57b 100644 --- a/src/Ui.cpp +++ b/src/Ui.cpp @@ -99,7 +99,7 @@ void Ui::DrawHeaders(unsortedMap& data) if (ImGui::Button(btn_text, GetSize(3, false))) { Globals::header_id = btn_text; - config.SetValueStr("window.id", Globals::header_id); + config.SetValue("window.id", Globals::header_id); func = it->second; } @@ -117,8 +117,7 @@ void Ui::DrawHeaders(unsortedMap& data) // Show Welcome page ImGui::NewLine(); - std::string title = "Welcome to " + Globals::menu_title; - Ui::CenterdText(title.c_str()); + Ui::CenterdText("Welcome to Cheat Menu"); Ui::CenterdText("Author: Grinch_"); ImGui::NewLine(); diff --git a/src/Util.cpp b/src/Util.cpp index 73efee8..d3938b2 100644 --- a/src/Util.cpp +++ b/src/Util.cpp @@ -1,6 +1,6 @@ #include "pch.h" #include "Util.h" -#include "external/imgui/stb_image.h" +#include "vendor/imgui/stb_image.h" void Util::ClearCharTasksVehCheck(CPed* ped) { @@ -166,10 +166,11 @@ int Util::GetLargestGangInZone() return gang_id; } -// partial implemention of opcode 0AB5 (STORE_CLOSEST_ENTITIES) +// implemention of opcode 0AB5 (STORE_CLOSEST_ENTITIES) // https://github.com/cleolibrary/CLEO4/blob/916d400f4a731ba1dd0ff16e52bdb056f42b7038/source/CCustomOpcodeSystem.cpp#L1671 -CVehicle* Util::GetClosestVehicle(CPlayerPed* player) +CVehicle* Util::GetClosestVehicle() { + CPlayerPed *player = FindPlayerPed(); CPedIntelligence *pedintel; if (player && (pedintel = player->m_pIntelligence)) { @@ -187,6 +188,27 @@ CVehicle* Util::GetClosestVehicle(CPlayerPed* player) return nullptr; } +CPed* Util::GetClosestPed() +{ + CPlayerPed *player = FindPlayerPed(); + CPedIntelligence * pedintel; + if (player && (pedintel = player->m_pIntelligence)) + { + CPed *ped = nullptr; + + for (int i = 0; i < 16; i++) + { + ped = (CPed*)pedintel->m_pedScanner.m_apEntities[i]; + if (ped && ped != player && (ped->m_nCreatedBy & 0xFF) == 1 && !ped->m_nPedFlags.bFadeOut) + break; + ped = nullptr; + } + + return ped; + } + return nullptr; +} + void Util::RainbowValues(int &r, int&g, int &b, float speed) { int timer = CTimer::m_snTimeInMilliseconds/150; diff --git a/src/Util.h b/src/Util.h index 892f884..63be040 100644 --- a/src/Util.h +++ b/src/Util.h @@ -1,4 +1,5 @@ #pragma once + class Util { private: @@ -6,7 +7,8 @@ private: public: static void ClearCharTasksVehCheck(CPed* ped); - static CVehicle *GetClosestVehicle(CPlayerPed* player); + static CPed *GetClosestPed(); + static CVehicle *GetClosestVehicle(); static int GetLargestGangInZone(); static void LoadTexturesInDirRecursive(const char * path, const char * file_ext, std::vector& category_vec, std::vector> &store_vec); static bool IsOnMission(); diff --git a/src/Vehicle.cpp b/src/Vehicle.cpp index 2982e92..66d1b2e 100644 --- a/src/Vehicle.cpp +++ b/src/Vehicle.cpp @@ -1,12 +1,14 @@ #include "pch.h" #include "Vehicle.h" +#include "Ui.h" +#include "Util.h" bool Vehicle::bike_fly = false; bool Vehicle::dont_fall_bike = false; bool Vehicle::veh_heavy = false; bool Vehicle::veh_watertight = false; bool Vehicle::veh_nodmg = false; - +int Vehicle::veh_remove_radius = 5; bool Vehicle::lock_speed = false; float Vehicle::lock_speed_val = 0; @@ -517,6 +519,17 @@ std::string Vehicle::GetNameFromModel(int model) return (const char*)info + 0x32; } +int Vehicle::GetModelFromName(const char* name) +{ + int model = 0; + CBaseModelInfo* model_info = CModelInfo::GetModelInfo((char*)name,&model); + + if (model > 0 && model < 1000000 && GetNameFromModel(model) != "") + return model; + else + return 0; +} + Vehicle::~Vehicle() { } @@ -753,7 +766,7 @@ void Vehicle::Main() { CPlayerPed *player = FindPlayerPed(); int hplayer = CPools::GetPedRef(player); - CVehicle *veh = Util::GetClosestVehicle(player); + CVehicle *veh = Util::GetClosestVehicle(); if (veh) { @@ -786,7 +799,23 @@ void Vehicle::Main() ImGui::Spacing(); ImGui::Separator(); } - + if (ImGui::CollapsingHeader("Remove vehicles in radius")) + { + ImGui::InputInt("Radius", &veh_remove_radius); + ImGui::Spacing(); + if (ImGui::Button("Remove vehicles",Ui::GetSize(1))) + { + CPlayerPed *player = FindPlayerPed(); + for (CVehicle *veh : CPools::ms_pVehiclePool) + { + if (DistanceBetweenPoints(veh->GetPosition(),player->GetPosition()) < veh_remove_radius + && player->m_pVehicle != veh) + Command(CPools::GetVehicleRef(veh)); + } + } + ImGui::Spacing(); + ImGui::Separator(); + } if (ImGui::CollapsingHeader("Traffic options")) { static std::vector color{ {"Black", 0x969151}, { "Pink",0x969150 } }; diff --git a/src/Vehicle.h b/src/Vehicle.h index 95d41fa..6251172 100644 --- a/src/Vehicle.h +++ b/src/Vehicle.h @@ -12,6 +12,7 @@ private: static bool veh_nodmg; static int door_menu_button; static std::string door_names[6]; + static int veh_remove_radius; static bool lock_speed; static float lock_speed_val; @@ -69,17 +70,16 @@ private: static bool enabled; static bool comp_added; }; - +public: static void AddComponent(const std::string& component, const bool display_message = true); static void RemoveComponent(const std::string& component, const bool display_message = true); static std::string GetNameFromModel(int model); + static int Vehicle::GetModelFromName(const char* name); static void SpawnVehicle(std::string &name); static int GetRandomTrainIdForModel(int model); static void ParseVehiclesIDE(); static void ParseCarcolsDAT(); static void GenerateHandlingDataFile(int phandling); - -public: Vehicle(); ~Vehicle(); static void Main(); diff --git a/src/Visual.cpp b/src/Visual.cpp index 50a1699..f3cdfdc 100644 --- a/src/Visual.cpp +++ b/src/Visual.cpp @@ -1,5 +1,7 @@ #include "pch.h" #include "Visual.h" +#include "Ui.h" +#include "Util.h" bool Visual::lock_weather = false; int Visual::weather_type_backup = 0; diff --git a/src/Weapon.cpp b/src/Weapon.cpp index 6570d04..a06022c 100644 --- a/src/Weapon.cpp +++ b/src/Weapon.cpp @@ -1,5 +1,7 @@ #include "pch.h" #include "Weapon.h" +#include "Ui.h" +#include "Util.h" ImGuiTextFilter Weapon::filter = ""; std::string Weapon::selected_item = "All"; @@ -117,9 +119,17 @@ void Weapon::GiveWeaponToPlayer(std::string& weapon_type) Command(iweapon_type, &model); CStreaming::RequestModel(model,PRIORITY_REQUEST); + + if (model == 363) // remote bomb + CStreaming::RequestModel(364,PRIORITY_REQUEST); // detonator + CStreaming::LoadAllRequestedModels(false); Command(hplayer, iweapon_type, ammo_count); + + if (model == 363) // remote bomb + Command(364); // detonator + Command(model); } } diff --git a/src/pch.cpp b/src/pch.cpp index 2468461..a02df6e 100644 --- a/src/pch.cpp +++ b/src/pch.cpp @@ -3,13 +3,11 @@ std::string Globals::header_id = ""; int Globals::last_key_timer = 0; ImVec2 Globals::menu_size = ImVec2(screen::GetScreenWidth()/4, screen::GetScreenHeight()/1.2); -std::string Globals::menu_title = std::string("Cheat Menu v") + std::string(MENU_VERSION) + " (" BUILD_NUMBER + ")"; ImVec2 Globals::font_screen_size = ImVec2(-1, -1); bool Globals::show_menu = false; bool Globals::init_done = false; Renderer Globals::renderer = Render_Unknown; ID3D11Device *Globals::device11 = nullptr; -std::string Globals::menu_path = paths::GetPluginDirPathA(); bool Globals::gsync_time = false; std::ofstream flog = std::ofstream("CheatMenu.log"); diff --git a/src/pch.h b/src/pch.h index 8dc2e87..d0d63ee 100644 --- a/src/pch.h +++ b/src/pch.h @@ -3,8 +3,6 @@ #define INPUT_BUFFER_SIZE 64 #define SPAWN_PED_LIMIT 20 -#define MENU_VERSION "2.5-beta" -#define BUILD_NUMBER "20201227" #define STB_IMAGE_IMPLEMENTATION #define DISCORD_INVITE "https://discord.gg/ZzW7kmf" #define GITHUB_LINK "https://github.com/user-grinch/Cheat-Menu" @@ -53,11 +51,11 @@ #include "eVehicleClass.h" #include "extensions\Paths.h" -#include "external/imgui/imgui.h" -#include "external/imgui/imgui_internal.h" -#include "external/imgui/imgui_impl_dx9.h" -#include "external/imgui/imgui_impl_dx11.h" -#include "external/imgui/imgui_impl_win32.h" +#include "vendor/imgui/imgui.h" +#include "vendor/imgui/imgui_internal.h" +#include "vendor/imgui/imgui_impl_dx9.h" +#include "vendor/imgui/imgui_impl_dx11.h" +#include "vendor/imgui/imgui_impl_win32.h" #include "Events.h" #include "Json.h" @@ -84,13 +82,11 @@ struct Globals static std::string header_id; static int last_key_timer; static ImVec2 menu_size; - static std::string menu_title; static ImVec2 font_screen_size; static bool show_menu; static bool init_done; static Renderer renderer; static ID3D11Device* device11; - static std::string menu_path; static bool gsync_time; }; @@ -103,7 +99,4 @@ struct TextureStructure }; extern CJson config; -extern std::ofstream flog; - -#include "Ui.h" -#include "Util.h" \ No newline at end of file +extern std::ofstream flog; \ No newline at end of file diff --git a/src/vendor/CMakeLists.txt b/src/vendor/CMakeLists.txt new file mode 100644 index 0000000..e2f0718 --- /dev/null +++ b/src/vendor/CMakeLists.txt @@ -0,0 +1,112 @@ +################################################################################ +# Build Vendor.lib +# All the external libraries that shouldn't need to be compiled often +################################################################################ +cmake_minimum_required(VERSION 3.0) +project(Vendor) + +set(vendor_files + "imgui/imconfig.h" + "imgui/imgui.cpp" + "imgui/imgui.h" + "imgui/imgui_demo.cpp" + "imgui/imgui_draw.cpp" + "imgui/imgui_impl_dx9.cpp" + "imgui/imgui_impl_dx9.h" + "imgui/imgui_impl_dx11.cpp" + "imgui/imgui_impl_dx11.h" + "imgui/imgui_impl_win32.cpp" + "imgui/imgui_impl_win32.h" + "imgui/imgui_internal.h" + "imgui/imgui_widgets.cpp" + "imgui/imstb_rectpack.h" + "imgui/imstb_textedit.h" + "imgui/imstb_truetype.h" + "imgui/stb_image.h" + "json.hpp" + "kiero/kiero.cpp" + "kiero/kiero.h" + "kiero/minhook/include/MinHook.h" + "moon/pool_object_extender.h" + "moon/vehicle_renderer.h" + "moon/vehicle_renderer.cpp" +) + +add_library(${PROJECT_NAME} STATIC ${vendor_files}) + +target_compile_definitions(${PROJECT_NAME} PRIVATE + "$<$:" + "_NDEBUG" + ">" + "$<$:" + "_DEBUG" + ">" + "_CRT_SECURE_NO_WARNINGS;" + "_CRT_NON_CONFORMING_SWPRINTFS;" + "GTASA;" + "GTAGAME_NAME=\"San Andreas\";" + "GTAGAME_ABBR=\"SA\";" + "GTAGAME_ABBRLOW=\"sa\";" + "GTAGAME_PROTAGONISTNAME=\"CJ\";" + "GTAGAME_CITYNAME=\"San Andreas\";" + "_LA_SUPPORT;" + "_DX9_SDK_INSTALLED;" + "PLUGIN_SGV_10US;" + "_MBCS" +) + +include_directories( + "$ENV{PLUGIN_SDK_DIR}/plugin_sa" + "$ENV{PLUGIN_SDK_DIR}/plugin_sa/game_sa" + "$ENV{PLUGIN_SDK_DIR}/shared" + "$ENV{PLUGIN_SDK_DIR}/shared/game" + "$ENV{DIRECTX9_SDK_DIR}/include" +) + +target_compile_options(${PROJECT_NAME} PRIVATE + $<$: + /O2; + /Oi; + /Gy + > + $<$: + /Od + > + /std:c++latest; + /sdl-; + /W3; + ${DEFAULT_CXX_DEBUG_INFORMATION_FORMAT}; + ${DEFAULT_CXX_EXCEPTION_HANDLING} + /w44005 +) + +string(CONCAT "MSVC_RUNTIME_LIBRARY_STR" + $<$: + MultiThreaded + > + $<$: + MultiThreadedDebug + > +) + +set_target_properties(${PROJECT_NAME} PROPERTIES + MSVC_RUNTIME_LIBRARY ${MSVC_RUNTIME_LIBRARY_STR} +) + +target_link_directories(${PROJECT_NAME} PUBLIC + ${CMAKE_SOURCE_DIR}"/src/vendor/kiero/minhook/lib/" +) + +target_link_libraries(${PROJECT_NAME} PUBLIC + optimized plugin + debug plugin_d + d3d9 + d3dx9 + d3d11 + d3dx11 + XInput9_1_0 + optimized libMinHook-x86-v140-mt + optimized libMinHook-x86-v140-md + debug libMinHook-x86-v140-mtd + debug libMinHook-x86-v140-mdd +) \ No newline at end of file diff --git a/src/external/imgui/imconfig.h b/src/vendor/imgui/imconfig.h similarity index 100% rename from src/external/imgui/imconfig.h rename to src/vendor/imgui/imconfig.h diff --git a/src/external/imgui/imgui.cpp b/src/vendor/imgui/imgui.cpp similarity index 100% rename from src/external/imgui/imgui.cpp rename to src/vendor/imgui/imgui.cpp diff --git a/src/external/imgui/imgui.h b/src/vendor/imgui/imgui.h similarity index 100% rename from src/external/imgui/imgui.h rename to src/vendor/imgui/imgui.h diff --git a/src/external/imgui/imgui_demo.cpp b/src/vendor/imgui/imgui_demo.cpp similarity index 100% rename from src/external/imgui/imgui_demo.cpp rename to src/vendor/imgui/imgui_demo.cpp diff --git a/src/external/imgui/imgui_draw.cpp b/src/vendor/imgui/imgui_draw.cpp similarity index 100% rename from src/external/imgui/imgui_draw.cpp rename to src/vendor/imgui/imgui_draw.cpp diff --git a/src/external/imgui/imgui_impl_dx11.cpp b/src/vendor/imgui/imgui_impl_dx11.cpp similarity index 100% rename from src/external/imgui/imgui_impl_dx11.cpp rename to src/vendor/imgui/imgui_impl_dx11.cpp diff --git a/src/external/imgui/imgui_impl_dx11.h b/src/vendor/imgui/imgui_impl_dx11.h similarity index 100% rename from src/external/imgui/imgui_impl_dx11.h rename to src/vendor/imgui/imgui_impl_dx11.h diff --git a/src/external/imgui/imgui_impl_dx9.cpp b/src/vendor/imgui/imgui_impl_dx9.cpp similarity index 100% rename from src/external/imgui/imgui_impl_dx9.cpp rename to src/vendor/imgui/imgui_impl_dx9.cpp diff --git a/src/external/imgui/imgui_impl_dx9.h b/src/vendor/imgui/imgui_impl_dx9.h similarity index 100% rename from src/external/imgui/imgui_impl_dx9.h rename to src/vendor/imgui/imgui_impl_dx9.h diff --git a/src/external/imgui/imgui_impl_win32.cpp b/src/vendor/imgui/imgui_impl_win32.cpp similarity index 100% rename from src/external/imgui/imgui_impl_win32.cpp rename to src/vendor/imgui/imgui_impl_win32.cpp diff --git a/src/external/imgui/imgui_impl_win32.h b/src/vendor/imgui/imgui_impl_win32.h similarity index 100% rename from src/external/imgui/imgui_impl_win32.h rename to src/vendor/imgui/imgui_impl_win32.h diff --git a/src/external/imgui/imgui_internal.h b/src/vendor/imgui/imgui_internal.h similarity index 100% rename from src/external/imgui/imgui_internal.h rename to src/vendor/imgui/imgui_internal.h diff --git a/src/external/imgui/imgui_widgets.cpp b/src/vendor/imgui/imgui_widgets.cpp similarity index 100% rename from src/external/imgui/imgui_widgets.cpp rename to src/vendor/imgui/imgui_widgets.cpp diff --git a/src/external/imgui/imstb_rectpack.h b/src/vendor/imgui/imstb_rectpack.h similarity index 100% rename from src/external/imgui/imstb_rectpack.h rename to src/vendor/imgui/imstb_rectpack.h diff --git a/src/external/imgui/imstb_textedit.h b/src/vendor/imgui/imstb_textedit.h similarity index 100% rename from src/external/imgui/imstb_textedit.h rename to src/vendor/imgui/imstb_textedit.h diff --git a/src/external/imgui/imstb_truetype.h b/src/vendor/imgui/imstb_truetype.h similarity index 100% rename from src/external/imgui/imstb_truetype.h rename to src/vendor/imgui/imstb_truetype.h diff --git a/src/external/imgui/stb_image.h b/src/vendor/imgui/stb_image.h similarity index 100% rename from src/external/imgui/stb_image.h rename to src/vendor/imgui/stb_image.h diff --git a/src/external/json.hpp b/src/vendor/json.hpp similarity index 100% rename from src/external/json.hpp rename to src/vendor/json.hpp diff --git a/src/external/kiero/kiero.cpp b/src/vendor/kiero/kiero.cpp similarity index 100% rename from src/external/kiero/kiero.cpp rename to src/vendor/kiero/kiero.cpp diff --git a/src/external/kiero/kiero.h b/src/vendor/kiero/kiero.h similarity index 100% rename from src/external/kiero/kiero.h rename to src/vendor/kiero/kiero.h diff --git a/src/external/kiero/minhook/include/MinHook.h b/src/vendor/kiero/minhook/include/MinHook.h similarity index 100% rename from src/external/kiero/minhook/include/MinHook.h rename to src/vendor/kiero/minhook/include/MinHook.h diff --git a/src/external/kiero/minhook/lib/libMinHook-x86-v140-md.lib b/src/vendor/kiero/minhook/lib/libMinHook-x86-v140-md.lib similarity index 100% rename from src/external/kiero/minhook/lib/libMinHook-x86-v140-md.lib rename to src/vendor/kiero/minhook/lib/libMinHook-x86-v140-md.lib diff --git a/src/external/kiero/minhook/lib/libMinHook-x86-v140-mdd.lib b/src/vendor/kiero/minhook/lib/libMinHook-x86-v140-mdd.lib similarity index 100% rename from src/external/kiero/minhook/lib/libMinHook-x86-v140-mdd.lib rename to src/vendor/kiero/minhook/lib/libMinHook-x86-v140-mdd.lib diff --git a/src/external/kiero/minhook/lib/libMinHook-x86-v140-mt.lib b/src/vendor/kiero/minhook/lib/libMinHook-x86-v140-mt.lib similarity index 100% rename from src/external/kiero/minhook/lib/libMinHook-x86-v140-mt.lib rename to src/vendor/kiero/minhook/lib/libMinHook-x86-v140-mt.lib diff --git a/src/external/kiero/minhook/lib/libMinHook-x86-v140-mtd.lib b/src/vendor/kiero/minhook/lib/libMinHook-x86-v140-mtd.lib similarity index 100% rename from src/external/kiero/minhook/lib/libMinHook-x86-v140-mtd.lib rename to src/vendor/kiero/minhook/lib/libMinHook-x86-v140-mtd.lib diff --git a/src/external/moon/pool_object_extender.h b/src/vendor/moon/pool_object_extender.h similarity index 100% rename from src/external/moon/pool_object_extender.h rename to src/vendor/moon/pool_object_extender.h diff --git a/src/external/moon/vehicle_renderer.cpp b/src/vendor/moon/vehicle_renderer.cpp similarity index 100% rename from src/external/moon/vehicle_renderer.cpp rename to src/vendor/moon/vehicle_renderer.cpp diff --git a/src/external/moon/vehicle_renderer.h b/src/vendor/moon/vehicle_renderer.h similarity index 100% rename from src/external/moon/vehicle_renderer.h rename to src/vendor/moon/vehicle_renderer.h