From 1305f8538255d9cd7724e12134aed694aab413e2 Mon Sep 17 00:00:00 2001 From: Grinch_ Date: Sun, 17 Jul 2022 00:29:32 +0600 Subject: [PATCH] Add nospread, auto unflip, lockCamZoom --- resource/common/locale/English.toml | 10 ++++- src/game.cpp | 65 +++++++++++++++++++++++++++-- src/game.h | 5 +++ src/menu.cpp | 2 +- src/pch.cpp | 2 +- src/pch.h | 2 +- src/util.cpp | 2 +- src/util.h | 2 +- src/vehicle.cpp | 19 ++++++--- src/vehicle.h | 1 + src/weapon.cpp | 12 ++++++ src/weapon.h | 1 + 12 files changed, 108 insertions(+), 15 deletions(-) diff --git a/resource/common/locale/English.toml b/resource/common/locale/English.toml index d04e9a7..f582329 100644 --- a/resource/common/locale/English.toml +++ b/resource/common/locale/English.toml @@ -42,6 +42,10 @@ WalkingStyleSet = "Walking style set" ActivateTimer = "Activate cheat timer" ActivateTimerText = "Time for the next cheat activation" Beach = "Beach" +CameraZoom = "Camera zoom" +CameraZoomLock = "Lock camera zoom" +CameraZoomLockFreecam = "Freecam is enabled. Camera zoom can't work together with freecam mode" +CameraZoomLockInfo = "Note: This will permanently lock camera zoom. Snipers or scopes won't work properly!" Cloudy = "Cloudy" Country = "Country" CurrentDay = "Current day" @@ -99,6 +103,7 @@ PlayerTeleported = "Player teleported" ProgressBar = "Progress bar" Rainy = "Rainy" RandomCheats = "Random cheats" +ResetDefault = "Reset to default" Sandstorm = "Sandstorm" SaveGame = "Save game (might cause game bugs)" Screenshot = "Screenshot shortcut" @@ -132,6 +137,7 @@ TranslatorName = "Grinch_" [Menu] About = "About" Author = "Author" +AutoCheckUpdate = "Check for updates" BugDisclaimer = "If you find bugs or have suggestions, let me know on discord." Build = "Build" CheatMenuNoDir = "Failed to find CheatMenu directory!" @@ -220,7 +226,7 @@ Teleports player to specified coordinates. Example: tp x y z""" TextColor = "Text color" TextOnlyMode = "Text only" -TextOnlyModeHint = "Disables all images and shows only text" +TextOnlyModeHint = "Replace images with their appropriate texts" TPMarkerKey = "Teleport to marker" Usage = "Usage" UpdaterInfo1 = "It's highly recommanded to update to the latest version. Newer version contains new features and bug fixes." @@ -417,6 +423,7 @@ All = "All" AllNitro = "All cars have nitro" AllTaxiNitro = "All taxis have nitro" AnimGroup = "Anim group" +AutoUnflip = "Auto unflip" Big = "Big" BikeFly = "Bikes fly" Black = "Black" @@ -743,6 +750,7 @@ InfiniteAmmo = "Infinite ammo" LongRange = "Long range" MoveWhenAiming = "Move when aiming" MoveWhenFiring = "Move when firing" +NoSpread = "No spread" RapidFire = "Rapid fire" SelectGang = "Select gang" Weapon1 = "Weapon 1" diff --git a/src/game.cpp b/src/game.cpp index 9ed75ed..3e8f43c 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -195,7 +195,15 @@ void Freecam::Clear() Command(m_nPed); m_pPed = nullptr; - Command(false); + // restore lock camera zoom here + if (Game::m_bLockCameraZoom) + { + TheCamera.LerpFOV(TheCamera.FindCamFOV(), Game::m_nCameraZoom, 250, true); + } + else + { + Command(false); + } Command(); } @@ -304,6 +312,7 @@ static void RealTimeClock() void Game::Init() { #ifdef GTASA + Events::drawMenuBackgroundEvent += []() { if (bSaveGameFlag) @@ -605,8 +614,55 @@ void Game::ShowPage() } if (ImGui::BeginTabItem(TEXT("Window.MenusTab"))) { + ImGui::Spacing(); ImGui::BeginChild("##Menus"); #ifdef GTASA + if (ImGui::CollapsingHeader(TEXT("Game.CameraZoom"))) + { + ImGui::Spacing(); + if (Freecam::m_bEnabled) + { + ImGui::TextWrapped(TEXT("Game.CameraZoomLockFreecam")); + } + else + { + if (Widget::Checkbox(TEXT("Game.CameraZoomLock"), &m_bLockCameraZoom)) + { + if (!m_bLockCameraZoom) + { + Command(false); + } + } + ImGui::Spacing(); + if (!m_bLockCameraZoom) + { + ImGui::BeginDisabled(); + } + if (ImGui::SliderInt(TEXT("Game.CameraZoom"), &m_nCameraZoom, 5, 120)) + { + TheCamera.LerpFOV(TheCamera.FindCamFOV(), m_nCameraZoom, 250, true); + Command(true); + } + ImGui::Spacing(); + if (ImGui::Button(TEXT("Game.ResetDefault"), Widget::CalcSize())) + { + m_nCameraZoom = 70.0f; + TheCamera.LerpFOV(TheCamera.FindCamFOV(), 70.0f, 250, true); + Command(true); + } + + if (m_bLockCameraZoom) + { + ImGui::TextWrapped(TEXT("Game.CameraZoomLockInfo")); + } + else + { + ImGui::EndDisabled(); + } + } + ImGui::Spacing(); + ImGui::Separator(); + } if (ImGui::CollapsingHeader(TEXT("Game.CurrentDay"))) { int day = CClock::CurrentDay - 1; @@ -617,7 +673,7 @@ void Game::ShowPage() ImGui::Spacing(); ImGui::Separator(); - }//0xC17040 + } #endif Widget::EditAddr(TEXT("Game.DaysPassed"), BY_GAME(0xB79038, 0x97F1F4, 0x8F2BB8), 0, 9999); Widget::EditAddr(TEXT("Game.FPSLimit"), (uint)&(RsGlobal.maxFPS), 1, 30, 999); @@ -774,7 +830,10 @@ void Game::ShowPage() } ImGui::Spacing(); - ImGui::SliderFloat(TEXT("Game.FieldOfView"), &Freecam::m_fFOV, 5.0f, 120.0f); + if (ImGui::SliderFloat(TEXT("Game.FieldOfView"), &Freecam::m_fFOV, 5.0f, 120.0f) && Freecam::m_bEnabled) + { + TheCamera.LerpFOV(TheCamera.FindCamFOV(), Freecam::m_fFOV, 250, true); + } ImGui::SliderInt(TEXT("Game.MovementSpeed"), &Freecam::m_nMul, 1, 10); ImGui::Dummy(ImVec2(0.0f, 20.0f)); diff --git a/src/game.h b/src/game.h index 2021deb..45587d4 100644 --- a/src/game.h +++ b/src/game.h @@ -68,6 +68,11 @@ public: static inline bool m_bFreezeTime; static inline bool m_bSyncTime; +#ifdef GTASA + static inline int m_nCameraZoom = 70.0f; + static inline bool m_bLockCameraZoom; +#endif + Game() = delete; Game(const Game&) = delete; diff --git a/src/menu.cpp b/src/menu.cpp index 1037e9c..bf3fc5d 100644 --- a/src/menu.cpp +++ b/src/menu.cpp @@ -474,7 +474,7 @@ void Menu::ShowPage() ImGui::Dummy(ImVec2(0, 10)); fixVeh.DrawUI(TEXT("Menu.FixVehKey")); - flipVeh.DrawUI(TEXT("Menu.FlipVehKey")); + unflipVeh.DrawUI(TEXT("Menu.FlipVehKey")); godMode.DrawUI(TEXT("Menu.GodModeKey")); vehEngine.DrawUI(TEXT("Menu.VehEngineKey")); vehInstantStart.DrawUI(TEXT("Menu.VehStartKey")); diff --git a/src/pch.cpp b/src/pch.cpp index 76d0d44..50f923e 100644 --- a/src/pch.cpp +++ b/src/pch.cpp @@ -12,7 +12,7 @@ Hotkey freeCamRight {VK_KEY_D, VK_KEY_D, "Freecam.Right"}; Hotkey freeCamTeleport {VK_RETURN, VK_RETURN, "Freecam.Teleport"}; Hotkey commandWindow {VK_LCONTROL, VK_KEY_C, "CommandWindowToggle"};; Hotkey fixVeh {VK_NONE, VK_NONE, "Vehicle.Fix"}; -Hotkey flipVeh {VK_NONE, VK_NONE, "Vehicle.Flip"}; +Hotkey unflipVeh {VK_NONE, VK_NONE, "Vehicle.Flip"}; Hotkey godMode {VK_NONE, VK_NONE, "GodMode"}; Hotkey menuOpen {VK_LCONTROL, VK_KEY_M, "MenuToggle"}; Hotkey quickSceenShot {VK_F5, VK_F5, "QuickScreenshot"}; diff --git a/src/pch.h b/src/pch.h index 84dbeed..0712447 100644 --- a/src/pch.h +++ b/src/pch.h @@ -107,7 +107,7 @@ extern Hotkey freeCamRight; extern Hotkey freeCamTeleport; extern Hotkey commandWindow; extern Hotkey fixVeh; -extern Hotkey flipVeh; +extern Hotkey unflipVeh; extern Hotkey godMode; extern Hotkey menuOpen; extern Hotkey quickSceenShot; diff --git a/src/util.cpp b/src/util.cpp index 845ef69..2fe4553 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -42,7 +42,7 @@ void Util::FixVehicle(CVehicle *pVeh) pVeh->m_fHealth = 1000.0f; } -void Util::FlipVehicle(CVehicle *pVeh) +void Util::UnFlipVehicle(CVehicle *pVeh) { #ifdef GTASA int hveh = CPools::GetVehicleRef(pVeh); diff --git a/src/util.h b/src/util.h index cd73807..73fd877 100644 --- a/src/util.h +++ b/src/util.h @@ -24,7 +24,7 @@ public: static bool IsOnMission(); #endif - static void FlipVehicle(CVehicle *pVeh); + static void UnFlipVehicle(CVehicle *pVeh); static void FixVehicle(CVehicle *pVeh); static CPed* GetClosestPed(); static CVehicle* GetClosestVehicle(); diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 1f3cf1e..db32a94 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -37,10 +37,15 @@ void Vehicle::Init() if (pPlayer && Util::IsInVehicle()) { int hveh = CPools::GetVehicleRef(pVeh); - - if (flipVeh.Pressed()) + float speed = pVeh->m_vecMoveSpeed.Magnitude() * 50.0f; + if (m_bAutoUnflip && pVeh->IsUpsideDown() && speed < 2.0f) { - Util::FlipVehicle(pVeh); + Util::UnFlipVehicle(pVeh); + } + + if (unflipVeh.Pressed()) + { + Util::UnFlipVehicle(pVeh); } if (fixVeh.Pressed()) @@ -525,13 +530,13 @@ void Vehicle::ShowPage() if (ImGui::Button(TEXT("Vehicle.FlipCar"), ImVec2(Widget::CalcSize(3))) && Util::IsInVehicle()) { - Util::FlipVehicle(pVeh); + Util::UnFlipVehicle(pVeh); } ImGui::Spacing(); - + if (ImGui::BeginTabBar("Vehicle", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll)) - { + { CVehicle* pVeh = pPlayer->m_pVehicle; bool is_driver = pVeh && (pPlayer->m_pVehicle->m_pDriver == pPlayer); @@ -547,6 +552,8 @@ void Vehicle::ShowPage() Widget::CheckboxAddr(TEXT("Vehicle.AllNitro"), 0x969165); #endif + Widget::Checkbox(TEXT("Vehicle.AutoUnflip"), &m_bAutoUnflip); + #ifndef GTA3 Widget::CheckboxAddr(TEXT("Vehicle.AggroDriver"), BY_GAME(0x96914F,0xA10B47, NULL)); Widget::CheckboxAddr(TEXT("Vehicle.AllTaxiNitro"), BY_GAME(0x96918B,0xA10B3A, NULL)); diff --git a/src/vehicle.h b/src/vehicle.h index 0305434..a3e120c 100644 --- a/src/vehicle.h +++ b/src/vehicle.h @@ -4,6 +4,7 @@ class Vehicle { private: + static inline bool m_bAutoUnflip; static inline bool m_bBikeFly; static inline bool m_bDontFallBike; static inline bool m_bVehHeavy; diff --git a/src/weapon.cpp b/src/weapon.cpp index 9c6994b..5cfaeed 100644 --- a/src/weapon.cpp +++ b/src/weapon.cpp @@ -78,6 +78,11 @@ void Weapon::Init() pWeaponInfo->m_nFlags.bMoveAim = true; } + if (m_bNoSpread) + { + pWeaponInfo->m_fAccuracy = 100.0f; + } + if (m_bMoveFire) { pWeaponInfo->m_nFlags.bMoveFire = true; @@ -326,6 +331,13 @@ void Weapon::ShowPage() CWeaponInfo::LoadWeaponData(); } } + if (Widget::Checkbox(TEXT("Weapon.NoSpread"), &m_bNoSpread)) + { + if (!m_bNoSpread) + { + CWeaponInfo::LoadWeaponData(); + } + } if (Widget::Checkbox(TEXT("Weapon.RapidFire"), &m_bRapidFire)) { if (!m_bRapidFire) diff --git a/src/weapon.h b/src/weapon.h index 721aad0..b67e44f 100644 --- a/src/weapon.h +++ b/src/weapon.h @@ -16,6 +16,7 @@ private: static inline bool m_bDualWeild; static inline bool m_bMoveAim; static inline bool m_bMoveFire; + static inline bool m_bNoSpread; static inline int m_nSelectedGang; static inline int m_nGangWeaponList[10][3] = {