From b3c16e04d673e2a01e76dd33721f14d6e3528000 Mon Sep 17 00:00:00 2001 From: Grinch_ Date: Tue, 18 Jan 2022 14:46:54 +0600 Subject: [PATCH] Port freecam & hardmode to III & VC --- src/game.cpp | 104 +++++++++++++++++++++++++++++++----------------- src/game.h | 45 ++++++++++----------- src/vehicle.cpp | 5 --- src/version.h | 2 +- 4 files changed, 89 insertions(+), 67 deletions(-) diff --git a/src/game.cpp b/src/game.cpp index 62b4aa7..e13aa38 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -87,6 +87,19 @@ Game::Game() CPlayerPed* pPlayer = FindPlayerPed(); int hplayer = CPools::GetPedRef(pPlayer); + if (m_HardMode::m_bEnabled) + { + if (pPlayer->m_fHealth > 50.0f) + pPlayer->m_fHealth = 50.0f; + + pPlayer->m_fArmour = 0.0f; + +#ifdef GTASA + CStats::SetStatValue(STAT_MAX_HEALTH, 350.0f); + CStats::SetStatValue(STAT_STAMINA, 0.0f); +#endif + } + #ifdef GTASA if (m_bScreenShot) { @@ -97,16 +110,6 @@ Game::Game() } } - if (m_HardMode::m_bEnabled) - { - if (pPlayer->m_fHealth > 50.0f) - pPlayer->m_fHealth = 50.0f; - - pPlayer->m_fArmour = 0.0f; - CStats::SetStatValue(STAT_MAX_HEALTH, 350.0f); - CStats::SetStatValue(STAT_STAMINA, 0.0f); - } - static int m_nSolidWaterObj; if (m_bSolidWater) { @@ -141,6 +144,8 @@ Game::Game() } } +#endif + if (freeCam.Pressed()) { if (m_Freecam::m_bEnabled) @@ -158,7 +163,6 @@ Game::Game() { FreeCam(); } -#endif // improve this later static uint syncTimer; @@ -220,50 +224,56 @@ void SetPlayerMission(std::string& rootkey, std::string& name, std::string& id) } } -#ifdef GTASA void Game::FreeCam() { - int delta = (CTimer::m_snTimeInMillisecondsNonClipped - - CTimer::m_snPreviousTimeInMillisecondsNonClipped); + int delta = (CTimer::m_snTimeInMilliseconds - CTimer::m_snPreviousTimeInMilliseconds); int ratio = 1 / (1 + (delta * m_Freecam::m_nMul)); int speed = m_Freecam::m_nMul + m_Freecam::m_nMul * ratio * delta; if (!m_Freecam::m_bInitDone) { - CPlayerPed* player = FindPlayerPed(-1); + CPlayerPed* player = FindPlayerPed(); Command(0, true); - m_Freecam::m_bHudState = patch::Get(0xBA6769); // hud - m_Freecam::m_bRadarState = patch::Get(0xBA676C); // radar - patch::Set(0xBA6769, 0); // hud - patch::Set(0xBA676C, 2); // radar + m_Freecam::m_bHudState = patch::Get(BY_GAME(0xBA6769, 0x86963A, NULL)); // hud + patch::Set(BY_GAME(0xBA6769, 0x86963A, NULL), 0); // hud + m_Freecam::m_bRadarState = patch::Get(BY_GAME(0xBA676C, 0xA10AB6, NULL)); // radar - CVector player_pos = player->GetPosition(); + CVector playerPos = player->GetPosition(); CPad::GetPad(0)->DisablePlayerControls = true; - Command(player_pos.x, player_pos.y, player_pos.z, &m_Freecam::m_nPed); + Command(playerPos.x, playerPos.y, playerPos.z, &m_Freecam::m_nPed); m_Freecam::m_pPed = CPools::GetPed(m_Freecam::m_nPed); - m_Freecam::m_pPed->m_bIsVisible = false; - - Command(m_Freecam::m_nPed, true); - Command(m_Freecam::m_nPed, false); - Command(m_Freecam::m_nPed, false); m_Freecam::m_fTotalMouse.x = player->GetHeading() + 89.6f; m_Freecam::m_fTotalMouse.y = 0; + playerPos.z -= 20; - m_Freecam::m_bInitDone = true; - player_pos.z -= 20; - m_Freecam::m_pPed->SetPosn(player_pos); + Command(m_Freecam::m_nPed, true); + Command(m_Freecam::m_nPed, false); +#ifdef GTASA + m_Freecam::m_pPed->m_bIsVisible = false; + Command(m_Freecam::m_nPed, false); + m_Freecam::m_pPed->SetPosn(playerPos); TheCamera.LerpFOV(TheCamera.FindCamFOV(), m_Freecam::m_fFOV, 1000, true); Command(true); + patch::Set(0xBA676C, 2); // disable radar +#else + m_Freecam::m_pPed->m_nFlags.bIsVisible = false; + m_Freecam::m_pPed->m_nFlags.bUseCollision = false; + m_Freecam::m_pPed->SetPosition(playerPos); + patch::Set(0xA10AB6, 1); // disable radar +#endif + + m_Freecam::m_bInitDone = true; } CVector pos = m_Freecam::m_pPed->GetPosition(); - Command(&m_Freecam::m_fMouse.x, &m_Freecam::m_fMouse.y); + m_Freecam::m_fMouse.x = CPad::NewMouseControllerState.X; + m_Freecam::m_fMouse.y = CPad::NewMouseControllerState.Y; m_Freecam::m_fTotalMouse.x = m_Freecam::m_fTotalMouse.x - m_Freecam::m_fMouse.x / 250; m_Freecam::m_fTotalMouse.y = m_Freecam::m_fTotalMouse.y + m_Freecam::m_fMouse.y / 3; @@ -279,10 +289,15 @@ void Game::FreeCam() if (freeCamTeleportPlayer.Pressed()) { - CPlayerPed* player = FindPlayerPed(-1); + CPlayerPed* player = FindPlayerPed(); CVector pos = m_Freecam::m_pPed->GetPosition(); - CEntity* player_entity = FindPlayerEntity(-1); - pos.z = CWorld::FindGroundZFor3DCoord(pos.x, pos.y, 1000, nullptr, &player_entity) + 0.5f; + +#ifdef GTASA + CEntity* playerEntity = FindPlayerEntity(-1); + pos.z = CWorld::FindGroundZFor3DCoord(pos.x, pos.y, 1000, nullptr, &playerEntity) + 0.5f; +#else + pos.z = CWorld::FindGroundZFor3DCoord(pos.x, pos.y, 1000, nullptr) + 0.5f; +#endif Command(CPools::GetPedRef(player), pos.x, pos.y, pos.z); // disble them again cause they get enabled @@ -330,6 +345,7 @@ void Game::FreeCam() pos.y += speed * sin(angle * 3.14159f / 180.0f); } +#ifdef GTASA if (CPad::NewMouseControllerState.wheelUp) { if (m_Freecam::m_fFOV > 10.0f) @@ -356,6 +372,10 @@ void Game::FreeCam() Command(m_Freecam::m_nPed, 0.0, 0.0, 20.0, 90.0, 180, m_Freecam::m_fTotalMouse.y, 0.0, 2); m_Freecam::m_pPed->SetPosn(pos); CIplStore::AddIplsNeededAtPosn(pos); +#else + m_Freecam::m_pPed->m_placement.SetHeading(m_Freecam::m_fTotalMouse.x); + m_Freecam::m_pPed->SetPosition(pos); +#endif } void Game::ClearFreecamStuff() @@ -363,15 +383,17 @@ void Game::ClearFreecamStuff() m_Freecam::m_bInitDone = false; Command(0, false); patch::Set(BY_GAME(0xBA6769, 0x86963A, NULL), m_Freecam::m_bHudState); // hud - patch::Set(0xBA676C, m_Freecam::m_bRadarState); // radar + patch::Set(BY_GAME(0xBA676C, 0xA10AB6, NULL), m_Freecam::m_bRadarState); // radar CPad::GetPad(0)->DisablePlayerControls = false; Command(m_Freecam::m_nPed); m_Freecam::m_pPed = nullptr; + +#ifdef GTASA Command(false); +#endif Command(); } -#endif void Game::Draw() { @@ -479,7 +501,6 @@ of LS without completing missions")) { Command(m_bMissionTimer); } -#ifdef GTASA if (Ui::CheckboxWithHint("Hard mode", &m_HardMode::m_bEnabled, "Makes the game more challanging to play. \n\ Lowers armour, health, stamina etc.")) { @@ -489,19 +510,28 @@ Lowers armour, health, stamina etc.")) { m_HardMode::m_fBacArmour = player->m_fArmour; m_HardMode::m_fBacHealth = player->m_fHealth; + +#ifdef GTASA m_HardMode::m_fBacMaxHealth = CStats::GetStatValue(STAT_MAX_HEALTH); m_HardMode::m_fBacStamina = CStats::GetStatValue(STAT_STAMINA); +#else + m_HardMode::m_fBacMaxHealth = 100.0f; +#endif player->m_fHealth = 50.0f; } else { player->m_fArmour = m_HardMode::m_fBacArmour; + +#ifdef GTASA CStats::SetStatValue(STAT_STAMINA, m_HardMode::m_fBacStamina); CStats::SetStatValue(STAT_MAX_HEALTH, m_HardMode::m_fBacMaxHealth); +#endif player->m_fHealth = m_HardMode::m_fBacHealth; - CWeaponInfo::LoadWeaponData(); } } +#ifdef GTASA + if (Ui::CheckboxWithHint("Keep stuff", &m_bKeepStuff, "Keep stuff after arrest/death")) { Command(m_bKeepStuff); diff --git a/src/game.h b/src/game.h index f386c84..a3ad87c 100644 --- a/src/game.h +++ b/src/game.h @@ -9,27 +9,6 @@ private: static inline bool m_bDisableReplay; static inline bool m_bMissionTimer; -#ifdef GTASA - static inline bool m_bForbiddenArea = true; // wanted level when going outside playable aea - static inline bool m_bSolidWater; // walk on water hack - static inline bool m_bScreenShot; - static inline bool m_bKeepStuff; - static inline ResourceStore m_StatData{ "stat", eResourceType::TYPE_TEXT }; - - static inline std::vector m_DayNames = - { - "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" - }; - - struct m_RandomCheats - { - static inline bool m_bEnabled; - static inline bool m_bProgressBar = true; - static inline std::string m_EnabledCheats[92][2]; - static inline int m_nInterval = 10; - static inline CJson m_Json = CJson("cheat name"); - static inline uint m_nTimer; - }; struct m_Freecam { static inline bool m_bEnabled; @@ -52,14 +31,32 @@ private: static inline float m_fBacStamina = 0.0f; }; +#ifdef GTASA + static inline bool m_bForbiddenArea = true; // wanted level when going outside playable aea + static inline bool m_bSolidWater; // walk on water hack + static inline bool m_bScreenShot; + static inline bool m_bKeepStuff; + static inline ResourceStore m_StatData{ "stat", eResourceType::TYPE_TEXT }; + + static inline std::vector m_DayNames = + { + "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" + }; + + struct m_RandomCheats + { + static inline bool m_bEnabled; + static inline bool m_bProgressBar = true; + static inline std::string m_EnabledCheats[92][2]; + static inline int m_nInterval = 10; + static inline CJson m_Json = CJson("cheat name"); + static inline uint m_nTimer; + }; #endif static void RealTimeClock(); -#ifdef GTASA - // TODO: Update freecam with aap's code static void FreeCam(); static void ClearFreecamStuff(); -#endif public: static inline bool m_bFreezeTime; diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 8102acf..368ea5e 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -692,11 +692,6 @@ void Vehicle::Draw() \nEnabling this would disable\nAll cars have nitro\nAll taxis have nitro"); #elif GTA3 Ui::CheckboxAddress("Perfect handling", 0x95CD66); - static bool bTankMode = false; - if (Ui::CheckboxWithHint("Tank mode", &bTankMode)) - { - Call<0x490EE0>(); - } #endif Ui::CheckboxWithHint("Watertight car", &m_bVehWatertight, "Peds inside won't drown if the vehicle\nis submerged in water"); Ui::CheckboxAddress("Wheels only", BY_GAME(0x96914B, 0xA10B70, 0x95CD78)); diff --git a/src/version.h b/src/version.h index cfa928e..68fd0e0 100644 --- a/src/version.h +++ b/src/version.h @@ -2,5 +2,5 @@ #define MENU_NAME "Cheat Menu" #define MENU_VERSION_NUMBER "3.1" #define MENU_VERSION MENU_VERSION_NUMBER"-beta" -#define BUILD_NUMBER "20220110" +#define BUILD_NUMBER "20220118" #define MENU_TITLE MENU_NAME " v" MENU_VERSION