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
This commit is contained in:
Grinch_ 2021-01-03 17:48:07 +06:00
parent 39c61520a1
commit 233fcd244f
55 changed files with 344 additions and 170 deletions

View File

@ -281,5 +281,6 @@ endfunction()
################################################################################
# Sub-projects
################################################################################
add_subdirectory(src/vendor)
add_subdirectory(src)

View File

@ -1,5 +1,7 @@
#include "pch.h"
#include "Animation.h"
#include "Ui.h"
#include "Util.h"
bool Animation::loop = false;
bool Animation::secondary = false;

View File

@ -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
$<$<CONFIG:Release>:
/SAFESEH:NO;
/OPT:REF;
/LTCG;
/OPT:ICF
/OPT:ICF;
>
$<$<CONFIG:Debug>:
/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/"
"$<$<CONFIG:Release>:"
"vendor/Release/"
">"
"$<$<CONFIG:Debug>:"
"vendor/Debug/"
">"
)

View File

@ -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;
}

View File

@ -1,6 +1,8 @@
#include "pch.h"
#include "Game.h"
#include "Menu.h"
#include "Ui.h"
#include "Util.h"
ImGuiTextFilter Game::filter = "";
std::vector<std::string> 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<Commands::FAIL_CURRENT_MISSION>();
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<Commands::FAIL_CURRENT_MISSION>();
}
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"))

View File

@ -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<void()> 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)

View File

@ -39,37 +39,6 @@ void CJson::LoadData(std::vector<std::string>& 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<std::string>();
}
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

View File

@ -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 <typename T>
T GetValue(std::string&& key, T&& default_val)
@ -41,13 +40,32 @@ public:
}
}
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<std::string>();
}
catch (...) {
return default_val;
}
}
/*
Allows to save values in json hierarchy using '.'
Example: "Menu.Window.X"
*/
template <typename T>
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

View File

@ -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;
}
}

5
src/MenuInfo.h Normal file
View File

@ -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 ")"

View File

@ -1,5 +1,6 @@
#include "pch.h"
#include "NeonAPI.h"
#include "Util.h"
VehicleExtendedData<NeonAPI::NeonData> NeonAPI::VehNeon;
RwTexture* NeonAPI::neon_texture = nullptr;

View File

@ -1,6 +1,7 @@
#include "pch.h"
#include "Paint.h"
#include "NodeName.h"
#include "Util.h"
std::vector<std::string> Paint::veh_nodes::names_vec{ "Default" };
std::string Paint::veh_nodes::selected = "Default";

View File

@ -1,5 +1,5 @@
#pragma once
#include "external/moon/vehicle_renderer.h"
#include "vendor/moon/vehicle_renderer.h"
class Paint : VehicleRenderer
{

View File

@ -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<std::string> 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<CPed*> Ped::spawn_ped::list;
int Ped::spawn_ped::accuracy = 50;
@ -25,14 +28,11 @@ int Ped::spawn_ped::weapon_id = 0;
std::vector<std::string> 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<Ui::NamedMemory>{ {"9mm", 0x96917C}, { "AK47", 0x96917D }, { "Rockets", 0x96917E }});
static std::vector<Ui::NamedMemory> 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<Commands::DELETE_CHAR>(CPools::GetPedRef(ped));
}
}
ImGui::Spacing();
ImGui::Separator();
}
ImGui::EndChild();
ImGui::EndTabItem();
}

View File

@ -16,6 +16,7 @@ private:
static std::vector<std::string> gang_names;
static bool exgangwars_installed;
static int ped_remove_radius;
struct spawn_ped {
static std::vector<CPed*> list;

View File

@ -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();

View File

@ -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<Commands::FREEZE_CHAR_POSITION_AND_DONT_LOAD_COLLISION>(CPools::GetPedRef(player), false);
Command<Commands::SET_CAMERA_BEHIND_PLAYER>();
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<Commands::FREEZE_CHAR_POSITION_AND_DONT_LOAD_COLLISION>(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);
}

View File

@ -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();

View File

@ -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;

View File

@ -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<std::string>& category_vec, std::vector<std::unique_ptr<TextureStructure>> &store_vec);
static bool IsOnMission();

View File

@ -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<Commands::DELETE_CAR>(CPools::GetVehicleRef(veh));
}
}
ImGui::Spacing();
ImGui::Separator();
}
if (ImGui::CollapsingHeader("Traffic options"))
{
static std::vector<Ui::NamedMemory> color{ {"Black", 0x969151}, { "Pink",0x969150 } };

View File

@ -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();

View File

@ -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;

View File

@ -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<Commands::GET_WEAPONTYPE_MODEL>(iweapon_type, &model);
CStreaming::RequestModel(model,PRIORITY_REQUEST);
if (model == 363) // remote bomb
CStreaming::RequestModel(364,PRIORITY_REQUEST); // detonator
CStreaming::LoadAllRequestedModels(false);
Command<Commands::GIVE_WEAPON_TO_CHAR>(hplayer, iweapon_type, ammo_count);
if (model == 363) // remote bomb
Command<Commands::MARK_MODEL_AS_NO_LONGER_NEEDED>(364); // detonator
Command<Commands::MARK_MODEL_AS_NO_LONGER_NEEDED>(model);
}
}

View File

@ -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");

View File

@ -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;
};
@ -104,6 +100,3 @@ struct TextureStructure
extern CJson config;
extern std::ofstream flog;
#include "Ui.h"
#include "Util.h"

112
src/vendor/CMakeLists.txt vendored Normal file
View File

@ -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
"$<$<CONFIG:Release>:"
"_NDEBUG"
">"
"$<$<CONFIG:Debug>:"
"_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
$<$<CONFIG:Release>:
/O2;
/Oi;
/Gy
>
$<$<CONFIG:Debug>:
/Od
>
/std:c++latest;
/sdl-;
/W3;
${DEFAULT_CXX_DEBUG_INFORMATION_FORMAT};
${DEFAULT_CXX_EXCEPTION_HANDLING}
/w44005
)
string(CONCAT "MSVC_RUNTIME_LIBRARY_STR"
$<$<CONFIG:Release>:
MultiThreaded
>
$<$<CONFIG:Debug>:
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
)