From 39c61520a127acbb4c0a18bc10a96ca9da4d8a35 Mon Sep 17 00:00:00 2001 From: Grinch_ Date: Tue, 29 Dec 2020 02:12:40 +0600 Subject: [PATCH] More weapon options & bug fixes 1. Fixed menu being unopenable when game speed increased 2. Improved sync system time 3. Fixed player model being broken when using ped model 4. Fixed car being spawned buried in some cases 5. Added more weapon options --- src/CheatMenu.cpp | 3 ++- src/Game.cpp | 30 ++++++++++++++++++++++++++-- src/Player.cpp | 16 +++++++++------ src/Vehicle.cpp | 15 +++++--------- src/Visual.cpp | 19 ++++++++++++++++-- src/Weapon.cpp | 51 ++++++++++++++++++++++++++++++++++++++++------- src/Weapon.h | 4 ++++ src/pch.cpp | 1 + src/pch.h | 2 ++ 9 files changed, 113 insertions(+), 28 deletions(-) diff --git a/src/CheatMenu.cpp b/src/CheatMenu.cpp index 0d7f770..e753491 100644 --- a/src/CheatMenu.cpp +++ b/src/CheatMenu.cpp @@ -57,7 +57,8 @@ CheatMenu::CheatMenu() Events::processScriptsEvent += [this] { - if (Globals::init_done && !FrontEndMenuManager.m_bMenuActive && CTimer::m_snTimeInMilliseconds - Globals::last_key_timer > 250) + if (Globals::init_done && !FrontEndMenuManager.m_bMenuActive + && CTimer::m_snTimeInMilliseconds - Globals::last_key_timer > 250*CTimer::ms_fTimeScale) { if (Ui::HotKeyPressed(hotkey::menu_open)) { diff --git a/src/Game.cpp b/src/Game.cpp index 9f33a8c..205aa21 100644 --- a/src/Game.cpp +++ b/src/Game.cpp @@ -43,6 +43,25 @@ uint Game::solid_water_object = 0; CJson Game::random_cheats::name_json = CJson("cheat name"); +// Thanks to aap +void RealTimeClock(void) +{ + static int lastday; + time_t tmp = time(NULL); + struct tm *now = localtime(&tmp); + + if(now->tm_yday != lastday) + CStats::SetStatValue(0x86, CStats::GetStatValue(0x86) + 1.0f); + + lastday = now->tm_yday; + CClock::ms_nGameClockMonth = now->tm_mon+1; + CClock::ms_nGameClockDays = now->tm_mday; + CClock::CurrentDay = now->tm_wday+1; + CClock::ms_nGameClockHours = now->tm_hour; + CClock::ms_nGameClockMinutes = now->tm_min; + CClock::ms_nGameClockSeconds = now->tm_sec; +} + Game::Game() { Events::initGameEvent += [] @@ -294,7 +313,14 @@ of LS without completing missions")) solid_water_object = 0; } } - ImGui::Checkbox("Sync system time", &sync_time); + if (ImGui::Checkbox("Sync system time", &sync_time)) + { + Globals::gsync_time = sync_time; + if (sync_time) + patch::RedirectCall(0x53BFBD, &RealTimeClock); + else + patch::RedirectCall(0x53BFBD, &CClock::Update); + } ImGui::Columns(1); ImGui::EndTabItem(); @@ -342,7 +368,7 @@ of LS without completing missions")) } Ui::EditAddress("Days passed", 0xB79038, 0, 9999); Ui::EditReference("FPS limit", RsGlobal.frameLimit, 1, 30, 60); - Ui::EditReference("Game speed", CTimer::ms_fTimeScale,0, 1, 10); + Ui::EditReference("Game speed", CTimer::ms_fTimeScale,1, 1, 10); Ui::EditFloat("Gravity", 0x863984, -1.0f, 0.008f, 1.0f); if (ImGui::CollapsingHeader("Set time")) diff --git a/src/Player.cpp b/src/Player.cpp index c423959..2bd11f8 100644 --- a/src/Player.cpp +++ b/src/Player.cpp @@ -21,16 +21,20 @@ ImGuiTextFilter Player::custom_skins::filter = ""; bool Player::modloader_installed = false; +static void PlayerModelBrokenFix() +{ + CPlayerPed *player = FindPlayerPed(); + + if (player->m_nModelIndex == 0) + Call<0x5A81E0>(0, player->m_pPlayerData->m_pPedClothesDesc,0xBC1C78,false); +} + Player::Player() { Events::initGameEvent += [] { - /* - Nop call to CClothes::RebuildPlayerIfNeeded - So player model doesn't get fked - This probably gonna fuck me up in future but oh well - */ - patch::Nop(0x44070A,5,false); + // Fix player model being broken after rebuild + patch::RedirectCall(0x5A834D,&PlayerModelBrokenFix); aim_skin_changer = config.GetValue("aim_skin_changer", false); Util::LoadTexturesInDirRecursive(PLUGIN_PATH((char*)"CheatMenu\\clothes\\"), ".jpg", search_categories, clothes_vec); diff --git a/src/Vehicle.cpp b/src/Vehicle.cpp index d14ca79..2982e92 100644 --- a/src/Vehicle.cpp +++ b/src/Vehicle.cpp @@ -69,14 +69,9 @@ Vehicle::Vehicle() { Events::initGameEvent += [] { - std::string dir_path = std::string(Globals::menu_path + "\\CheatMenu\\vehicles\\images\\"); - Util::LoadTexturesInDirRecursive(dir_path.c_str(), ".jpg", spawner::search_categories, spawner::image_vec); - - dir_path = std::string(Globals::menu_path + "\\CheatMenu\\vehicles\\components\\"); - Util::LoadTexturesInDirRecursive(dir_path.c_str(), ".jpg", tune::search_categories, tune::image_vec); - - dir_path = std::string(Globals::menu_path + "\\CheatMenu\\vehicles\\paintjobs\\"); - Util::LoadTexturesInDirRecursive(dir_path.c_str(), ".png", texture9::search_categories, texture9::image_vec); + Util::LoadTexturesInDirRecursive(PLUGIN_PATH((char*)"CheatMenu\\vehicles\\images\\"), ".jpg", spawner::search_categories, spawner::image_vec); + Util::LoadTexturesInDirRecursive(PLUGIN_PATH((char*)"CheatMenu\\vehicles\\components\\"), ".jpg", tune::search_categories, tune::image_vec); + Util::LoadTexturesInDirRecursive(PLUGIN_PATH((char*)"CheatMenu\\vehicles\\paintjobs\\"), ".png", texture9::search_categories, texture9::image_vec); ParseVehiclesIDE(); ParseCarcolsDAT(); @@ -492,7 +487,7 @@ void Vehicle::SpawnVehicle(std::string &smodel) int hveh = 0; if (spawner::spawn_inside) { - Command(imodel, pos.x, pos.y, pos.z + 2.0f, &hveh); + Command(imodel, pos.x, pos.y, pos.z + 3.0f, &hveh); veh = CPools::GetVehicle(hveh); veh->SetHeading(player->GetHeading()); Command(hplayer, hveh); @@ -502,7 +497,7 @@ void Vehicle::SpawnVehicle(std::string &smodel) { player->TransformFromObjectSpace(pos, CVector(0, 10, 0)); - Command(imodel, pos.x, pos.y, pos.z + 2.0f, &hveh); + Command(imodel, pos.x, pos.y, pos.z + 3.0f, &hveh); veh = CPools::GetVehicle(hveh); veh->SetHeading(player->GetHeading()+55.0f); } diff --git a/src/Visual.cpp b/src/Visual.cpp index 73f7873..50a1699 100644 --- a/src/Visual.cpp +++ b/src/Visual.cpp @@ -252,19 +252,34 @@ void Visual::Main() int hour = CClock::ms_nGameClockHours; int minute = CClock::ms_nGameClockMinutes; - if (ImGui::InputInt("Hour", &hour)) + if (Globals::gsync_time) + { + ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true); + ImGui::PushStyleVar(ImGuiStyleVar_Alpha, ImGui::GetStyle().Alpha * 0.5f); + } + + + if (ImGui::InputInt("Hour", &hour) & !Globals::gsync_time) { if (hour < 0) hour = 23; if (hour > 23) hour = 0; CClock::ms_nGameClockHours = hour; } - if (ImGui::InputInt("Minute", &minute)) + if (ImGui::InputInt("Minute", &minute) & !Globals::gsync_time) { if (minute < 0) minute = 59; if (minute > 59) minute = 0; CClock::ms_nGameClockMinutes = minute; } + + if (Globals::gsync_time) + { + ImGui::PopStyleVar(); + ImGui::PopItemFlag(); + Ui::ShowTooltip("Sync system time is enabled.\n(Game/Sync system time)"); + } + ImGui::Spacing(); if (ImGui::BeginTabBar("Timecyc subtab", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll)) { diff --git a/src/Weapon.cpp b/src/Weapon.cpp index d130952..6570d04 100644 --- a/src/Weapon.cpp +++ b/src/Weapon.cpp @@ -11,6 +11,11 @@ bool Weapon::auto_aim = false; bool Weapon::fast_reload = false; bool Weapon::huge_damage = false; bool Weapon::long_range = false; +bool Weapon::rapid_fire = false; +bool Weapon::dual_weild = false; +bool Weapon::move_aim = false; +bool Weapon::move_fire = false; + uchar Weapon::cur_weapon_slot = -1; int Weapon::ammo_count = 99999; @@ -35,8 +40,7 @@ Weapon::Weapon() { Events::initGameEvent += [] { - std::string dir_path = Globals::menu_path + "\\CheatMenu\\weapons\\"; - Util::LoadTexturesInDirRecursive(dir_path.c_str(), ".jpg", Weapon::search_categories, Weapon::weapon_vec); + Util::LoadTexturesInDirRecursive(PLUGIN_PATH((char*)"CheatMenu\\weapons\\"), ".jpg", Weapon::search_categories, Weapon::weapon_vec); }; Events::processScriptsEvent += [] @@ -44,9 +48,7 @@ Weapon::Weapon() CPlayerPed *player = FindPlayerPed(); if (auto_aim) { - float mouseX, mouseY; - Command(&mouseX, &mouseY); - if (static_cast(mouseY/2) == 0 || static_cast(mouseX/2) == 0) + if (CPad::NewMouseControllerState.X == 0 && CPad::NewMouseControllerState.Y == 0) { if (KeyPressed(2)) CCamera::m_bUseMouse3rdPerson = false; @@ -62,15 +64,28 @@ Weapon::Weapon() CWeaponInfo *pweapon_info = CWeaponInfo::GetWeaponInfo(weapon_type, player->GetWeaponSkill(weapon_type)); if (huge_damage) - pweapon_info->m_nDamage = 1000; + pweapon_info->m_nDamage = 5000; if (long_range) { pweapon_info->m_fTargetRange = 1000.0f; pweapon_info->m_fWeaponRange = 1000.0f; pweapon_info->m_fAccuracy = 1.0f; + pweapon_info->m_nFlags.bReload2Start = true; } + if (rapid_fire) + pweapon_info->m_nFlags.bContinuosFire = true; + + if (dual_weild && (weapon_type == WEAPON_PISTOL || weapon_type == WEAPON_MICRO_UZI || weapon_type == WEAPON_TEC9 || weapon_type == WEAPON_SAWNOFF)) + pweapon_info->m_nFlags.bTwinPistol = true; + + if (move_aim) + pweapon_info->m_nFlags.bMoveAim = true; + + if (move_fire) + pweapon_info->m_nFlags.bMoveFire = true; + cur_weapon_slot = slot; } }; @@ -150,6 +165,11 @@ void Weapon::Main() ImGui::Columns(2, 0, false); Ui::CheckboxWithHint("Auto aim", &auto_aim, "Enables aim assist on keyboard\n\nQ = left E = right"); + if (Ui::CheckboxWithHint("Dual weild", &dual_weild,"Dual weild pistol, shawoff, uzi, tec9\n(Other weapons don't work)")) + { + if (!dual_weild) + CWeaponInfo::LoadWeaponData(); + } if (Ui::CheckboxWithHint("Huge damage", &huge_damage)) { if (!huge_damage) @@ -158,13 +178,30 @@ void Weapon::Main() if (Ui::CheckboxWithHint("Fast reload", &fast_reload)) Command(hplayer, fast_reload); - ImGui::NextColumn(); Ui::CheckboxAddress("Infinite ammo", 0x969178); + + ImGui::NextColumn(); + if (Ui::CheckboxWithHint("Long range", &long_range)) { if (!long_range) CWeaponInfo::LoadWeaponData(); } + if (Ui::CheckboxWithHint("Move when aiming", &move_aim)) + { + if (!move_aim) + CWeaponInfo::LoadWeaponData(); + } + if (Ui::CheckboxWithHint("Move when firing", &move_fire)) + { + if (!move_fire) + CWeaponInfo::LoadWeaponData(); + } + if (Ui::CheckboxWithHint("Rapid fire", &rapid_fire)) + { + if (!rapid_fire) + CWeaponInfo::LoadWeaponData(); + } ImGui::Columns(1, 0, false); ImGui::EndChild(); ImGui::EndTabItem(); diff --git a/src/Weapon.h b/src/Weapon.h index 931309d..162389c 100644 --- a/src/Weapon.h +++ b/src/Weapon.h @@ -14,6 +14,10 @@ private: static bool fast_reload; static bool huge_damage; static bool long_range; + static bool rapid_fire; + static bool dual_weild; + static bool move_aim; + static bool move_fire; static int ammo_count; static uchar cur_weapon_slot; diff --git a/src/pch.cpp b/src/pch.cpp index 10a2000..2468461 100644 --- a/src/pch.cpp +++ b/src/pch.cpp @@ -10,6 +10,7 @@ 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"); CJson config = CJson("config"); diff --git a/src/pch.h b/src/pch.h index 5bdf5c6..8dc2e87 100644 --- a/src/pch.h +++ b/src/pch.h @@ -54,6 +54,7 @@ #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" @@ -90,6 +91,7 @@ struct Globals static Renderer renderer; static ID3D11Device* device11; static std::string menu_path; + static bool gsync_time; }; struct TextureStructure