CheatMenuSA/CheatMenu/Game.cpp

574 lines
17 KiB
C++
Raw Normal View History

2020-12-02 16:19:16 -05:00
#include "pch.h"
#include "Menu.h"
2021-02-02 02:59:01 -05:00
#include "Game.h"
#include "Ui.h"
#include "Util.h"
2021-01-19 05:02:33 -05:00
#include "CIplStore.h"
2020-12-02 16:19:16 -05:00
// Thanks to aap
void Game::RealTimeClock()
2021-02-24 16:54:45 -05:00
{
static int lastday;
2021-06-18 12:49:11 -04:00
time_t tmp = time(nullptr);
2021-02-24 16:54:45 -05:00
struct tm* now = localtime(&tmp);
if (now->tm_yday != lastday)
CStats::SetStatValue(0x86, CStats::GetStatValue(0x86) + 1.0f);
lastday = now->tm_yday;
2021-02-24 16:54:45 -05:00
CClock::ms_nGameClockMonth = now->tm_mon + 1;
CClock::ms_nGameClockDays = now->tm_mday;
2021-02-24 16:54:45 -05:00
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()
2020-12-02 16:19:16 -05:00
{
2021-06-18 12:49:11 -04:00
m_MissionData.m_Json.LoadData(m_MissionData.m_Categories, m_MissionData.m_Selected);
m_StatData.m_Json.LoadData(m_StatData.m_Categories, m_StatData.m_Selected);
m_Freecam::m_fFOV = TheCamera.FindCamFOV();
2020-12-02 16:19:16 -05:00
2021-02-24 16:54:45 -05:00
// Generate enabled cheats vector
for (auto element : m_RandomCheats::m_Json.m_Data.items())
2021-02-24 16:54:45 -05:00
{
/*
[
cheat_id = [ cheat_name, state (true/false) ]
]
*/
m_RandomCheats::m_EnabledCheats[std::stoi(element.key())][0] = element.value().get<std::string>();
m_RandomCheats::m_EnabledCheats[std::stoi(element.key())][1] = "true";
2021-02-24 16:54:45 -05:00
}
2020-12-02 16:19:16 -05:00
Events::processScriptsEvent += []
{
uint timer = CTimer::m_snTimeInMilliseconds;
2021-06-18 12:49:11 -04:00
CPlayerPed* pPlayer = FindPlayerPed();
int hplayer = CPools::GetPedRef(pPlayer);
2020-12-02 16:19:16 -05:00
2021-06-18 12:49:11 -04:00
if (m_bScreenShot)
2020-12-02 16:19:16 -05:00
{
if (Ui::HotKeyPressed(Menu::m_HotKeys::quickSceenShot))
2020-12-02 16:19:16 -05:00
{
Command<Commands::TAKE_PHOTO>();
CHud::SetHelpMessage("Screenshot taken", false, false, false);
}
}
if (m_HardMode::m_bEnabled)
2021-02-02 02:59:01 -05:00
{
2021-06-18 12:49:11 -04:00
if (pPlayer->m_fHealth > 50.0f)
pPlayer->m_fHealth = 50.0f;
2021-02-02 02:59:01 -05:00
2021-06-18 12:49:11 -04:00
pPlayer->m_fArmour = 0.0f;
2021-02-02 02:59:01 -05:00
CStats::SetStatValue(STAT_MAX_HEALTH, 350.0f);
CStats::SetStatValue(STAT_STAMINA, 0.0f);
}
2021-06-18 12:49:11 -04:00
if (m_bSolidWater)
2020-12-02 16:19:16 -05:00
{
2021-06-18 12:49:11 -04:00
CVector pos = pPlayer->GetPosition();
2020-12-02 16:19:16 -05:00
2021-06-18 12:49:11 -04:00
float waterHeight = 0;
Command<Commands::GET_WATER_HEIGHT_AT_COORDS>(pos.x, pos.y, false, &waterHeight);
2020-12-02 16:19:16 -05:00
2021-06-18 12:49:11 -04:00
if (!Command<Commands::IS_CHAR_IN_ANY_BOAT>(hplayer) && waterHeight != -1000.0f && pos.z > (waterHeight))
2020-12-02 16:19:16 -05:00
{
2021-06-18 12:49:11 -04:00
if (m_nSolidWaterObj == 0)
2020-12-02 16:19:16 -05:00
{
2021-06-18 12:49:11 -04:00
Command<Commands::CREATE_OBJECT>(3095, pos.x, pos.y, waterHeight, &m_nSolidWaterObj);
Command<Commands::SET_OBJECT_VISIBLE>(m_nSolidWaterObj, false);
if (pos.z < (waterHeight + 1))
pPlayer->SetPosn(pos.x, pos.y, waterHeight + 1);
2020-12-02 16:19:16 -05:00
}
else
2021-06-18 12:49:11 -04:00
Command<Commands::SET_OBJECT_COORDINATES>(m_nSolidWaterObj, pos.x, pos.y, waterHeight);
2020-12-02 16:19:16 -05:00
}
else
{
2021-06-18 12:49:11 -04:00
if (m_nSolidWaterObj != 0)
2020-12-02 16:19:16 -05:00
{
2021-06-18 12:49:11 -04:00
Command<Commands::DELETE_OBJECT>(m_nSolidWaterObj);
m_nSolidWaterObj = 0;
2020-12-02 16:19:16 -05:00
}
}
}
// improve this later
2021-06-18 12:49:11 -04:00
if (m_bSyncTime && timer - m_nSyncTimer > 50)
2020-12-02 16:19:16 -05:00
{
2021-06-18 12:49:11 -04:00
std::time_t t = std::time(nullptr);
2020-12-02 16:19:16 -05:00
std::tm* now = std::localtime(&t);
CClock::ms_nGameClockHours = now->tm_hour;
CClock::ms_nGameClockMinutes = now->tm_min;
2021-02-24 16:54:45 -05:00
2021-06-18 12:49:11 -04:00
m_nSyncTimer = timer;
2020-12-02 16:19:16 -05:00
}
if (m_RandomCheats::m_bEnabled
&& (timer - m_RandomCheats::m_nTimer) > (static_cast<uint>(m_RandomCheats::m_nInterval) * 1000))
2020-12-02 16:19:16 -05:00
{
2021-02-24 16:54:45 -05:00
int id = Random(0, 91);
2020-12-02 16:19:16 -05:00
for (int i = 0; i < 92; i++)
{
if (i == id)
{
if (m_RandomCheats::m_EnabledCheats[i][1] == "true")
2020-12-02 16:19:16 -05:00
{
((void(*)(int))0x00438370)(id); // cheatEnableLegimate(int CheatID)
CHud::SetHelpMessage(m_RandomCheats::m_EnabledCheats[i][0].c_str(), false, false, false);
m_RandomCheats::m_nTimer = timer;
2020-12-02 16:19:16 -05:00
}
break;
}
}
}
2021-02-24 16:54:45 -05:00
if (Ui::HotKeyPressed(Menu::m_HotKeys::freeCam))
2020-12-02 16:19:16 -05:00
{
if (m_Freecam::m_bEnabled)
{
m_Freecam::m_bEnabled = false;
2021-01-19 05:02:33 -05:00
ClearFreecamStuff();
}
else m_Freecam::m_bEnabled = true;
2020-12-02 16:19:16 -05:00
}
if (m_Freecam::m_bEnabled)
2021-01-19 05:02:33 -05:00
FreeCam();
2020-12-02 16:19:16 -05:00
};
}
void SetPlayerMission(std::string& rootkey, std::string& name, std::string& id)
{
2021-02-24 16:54:45 -05:00
CPlayerPed* player = FindPlayerPed();
2020-12-02 16:19:16 -05:00
uint hplayer = CPools::GetPedRef(player);
int interior = 0;
2021-02-24 16:54:45 -05:00
Command<0x09E8>(hplayer, &interior);
if (Util::IsOnMission() && interior == 0)
2020-12-02 16:19:16 -05:00
{
player->SetWantedLevel(0);
Command<Commands::LOAD_AND_LAUNCH_MISSION_INTERNAL>(std::stoi(id));
}
else CHud::SetHelpMessage("Can't start mission now", false, false, false);
}
void Game::FreeCam()
2020-12-02 16:19:16 -05:00
{
int deltaSpeed = m_Freecam::m_fSpeed * (CTimer::m_snTimeInMillisecondsNonClipped -
2021-06-18 12:49:11 -04:00
CTimer::m_snPreviousTimeInMillisecondsNonClipped);
2020-12-02 16:19:16 -05:00
if (!m_Freecam::m_bInitDone)
2020-12-02 16:19:16 -05:00
{
2021-02-24 16:54:45 -05:00
CPlayerPed* player = FindPlayerPed(-1);
2020-12-02 16:19:16 -05:00
Command<Commands::SET_EVERYONE_IGNORE_PLAYER>(0, true);
CHud::bScriptDontDisplayRadar = true;
CHud::m_Wants_To_Draw_Hud = false;
2021-01-19 05:02:33 -05:00
CVector player_pos = player->GetPosition();
CPad::GetPad(0)->DisablePlayerControls = true;
Command<Commands::CREATE_RANDOM_CHAR>(player_pos.x, player_pos.y, player_pos.z, &m_Freecam::m_nPed);
m_Freecam::m_pPed = CPools::GetPed(m_Freecam::m_nPed);
m_Freecam::m_pPed->m_bIsVisible = false;
2021-02-24 16:54:45 -05:00
Command<Commands::FREEZE_CHAR_POSITION_AND_DONT_LOAD_COLLISION>(m_Freecam::m_nPed, true);
Command<Commands::SET_CHAR_COLLISION>(m_Freecam::m_nPed, false);
Command<Commands::SET_LOAD_COLLISION_FOR_CHAR_FLAG>(m_Freecam::m_nPed, false);
2020-12-02 16:19:16 -05:00
m_Freecam::m_fTotalMouse.x = player->GetHeading() + 89.6f;
m_Freecam::m_fTotalMouse.y = 0;
2021-01-19 05:02:33 -05:00
m_Freecam::m_bInitDone = true;
2021-01-19 05:02:33 -05:00
player_pos.z -= 20;
m_Freecam::m_pPed->SetPosn(player_pos);
2021-02-08 05:25:06 -05:00
TheCamera.LerpFOV(TheCamera.FindCamFOV(), m_Freecam::m_fFOV, 1000, true);
2021-02-08 05:25:06 -05:00
Command<Commands::CAMERA_PERSIST_FOV>(true);
2020-12-02 16:19:16 -05:00
}
2021-02-08 05:25:06 -05:00
CVector pos = m_Freecam::m_pPed->GetPosition();
2020-12-02 16:19:16 -05:00
Command<Commands::GET_PC_MOUSE_MOVEMENT>(&m_Freecam::m_fMouse.x, &m_Freecam::m_fMouse.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;
2021-02-24 16:54:45 -05:00
if (m_Freecam::m_fTotalMouse.x > 150)
m_Freecam::m_fTotalMouse.y = 150;
2020-12-02 16:19:16 -05:00
if (m_Freecam::m_fTotalMouse.y < -150)
m_Freecam::m_fTotalMouse.y = -150;
2020-12-02 16:19:16 -05:00
if (Ui::HotKeyPressed(Menu::m_HotKeys::freeCamTeleportPlayer))
2021-01-19 05:02:33 -05:00
{
2021-02-24 16:54:45 -05:00
CPlayerPed* player = FindPlayerPed(-1);
CVector pos = m_Freecam::m_pPed->GetPosition();
2021-01-19 05:02:33 -05:00
CEntity* player_entity = FindPlayerEntity(-1);
2021-06-18 12:49:11 -04:00
pos.z = CWorld::FindGroundZFor3DCoord(pos.x, pos.y, 1000, nullptr, &player_entity) + 0.5f;
2021-02-24 16:54:45 -05:00
Command<Commands::SET_CHAR_COORDINATES>(CPools::GetPedRef(player), pos.x, pos.y, pos.z);
2021-01-22 16:47:22 -05:00
// disble them again cause they get enabled
CHud::bScriptDontDisplayRadar = true;
CHud::m_Wants_To_Draw_Hud = false;
2021-06-18 12:49:11 -04:00
CHud::SetHelpMessage("Player telported", false, false, false);
2021-01-19 05:02:33 -05:00
}
2021-02-24 16:54:45 -05:00
2020-12-02 16:19:16 -05:00
if (KeyPressed(VK_RCONTROL))
2021-06-18 12:49:11 -04:00
deltaSpeed /= 2;
2020-12-02 16:19:16 -05:00
if (KeyPressed(VK_RSHIFT))
2021-06-18 12:49:11 -04:00
deltaSpeed *= 2;
2020-12-02 16:19:16 -05:00
if (KeyPressed(VK_KEY_I) || KeyPressed(VK_KEY_K))
{
if (KeyPressed(VK_KEY_K))
2021-06-18 12:49:11 -04:00
deltaSpeed *= -1;
2020-12-02 16:19:16 -05:00
2021-01-19 05:02:33 -05:00
float angle;
Command<Commands::GET_CHAR_HEADING>(m_Freecam::m_nPed, &angle);
2021-06-18 12:49:11 -04:00
pos.x += deltaSpeed * cos(angle * 3.14159f / 180.0f);
pos.y += deltaSpeed * sin(angle * 3.14159f / 180.0f);
pos.z += deltaSpeed * 2 * sin(m_Freecam::m_fTotalMouse.y / 3 * 3.14159f / 180.0f);
2020-12-02 16:19:16 -05:00
}
if (KeyPressed(VK_KEY_J) || KeyPressed(VK_KEY_L))
{
if (KeyPressed(VK_KEY_J))
2021-06-18 12:49:11 -04:00
deltaSpeed *= -1;
2021-01-20 17:55:36 -05:00
2021-01-19 05:02:33 -05:00
float angle;
Command<Commands::GET_CHAR_HEADING>(m_Freecam::m_nPed, &angle);
2021-01-20 17:55:36 -05:00
angle -= 90;
2021-02-24 16:54:45 -05:00
2021-06-18 12:49:11 -04:00
pos.x += deltaSpeed * cos(angle * 3.14159f / 180.0f);
pos.y += deltaSpeed * sin(angle * 3.14159f / 180.0f);
2020-12-02 16:19:16 -05:00
}
2021-02-24 16:54:45 -05:00
if (CPad::NewMouseControllerState.wheelUp)
2021-02-08 05:25:06 -05:00
{
if (m_Freecam::m_fFOV > 10.0f)
m_Freecam::m_fFOV -= 2.0f * deltaSpeed;
2021-02-08 05:25:06 -05:00
TheCamera.LerpFOV(TheCamera.FindCamFOV(), m_Freecam::m_fFOV, 250, true);
2021-02-08 05:25:06 -05:00
Command<Commands::CAMERA_PERSIST_FOV>(true);
}
2021-02-24 16:54:45 -05:00
if (CPad::NewMouseControllerState.wheelDown)
2021-02-08 05:25:06 -05:00
{
if (m_Freecam::m_fFOV < 115.0f)
m_Freecam::m_fFOV += 2.0f * deltaSpeed;
2021-02-24 16:54:45 -05:00
TheCamera.LerpFOV(TheCamera.FindCamFOV(), m_Freecam::m_fFOV, 250, true);
2021-02-08 05:25:06 -05:00
Command<Commands::CAMERA_PERSIST_FOV>(true);
}
m_Freecam::m_pPed->SetHeading(m_Freecam::m_fTotalMouse.x);
Command<Commands::ATTACH_CAMERA_TO_CHAR>(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);
2021-01-19 05:02:33 -05:00
CIplStore::AddIplsNeededAtPosn(pos);
2020-12-02 16:19:16 -05:00
}
void Game::ClearFreecamStuff()
{
m_Freecam::m_bInitDone = false;
Command<Commands::SET_EVERYONE_IGNORE_PLAYER>(0, false);
CHud::bScriptDontDisplayRadar = false;
CHud::m_Wants_To_Draw_Hud = true;
2021-01-19 05:02:33 -05:00
CPad::GetPad(0)->DisablePlayerControls = false;
Command<Commands::DELETE_CHAR>(m_Freecam::m_nPed);
m_Freecam::m_pPed = nullptr;
2021-02-08 05:25:06 -05:00
Command<Commands::CAMERA_PERSIST_FOV>(false);
Command<Commands::RESTORE_CAMERA_JUMPCUT>();
}
void Game::Draw()
2020-12-02 16:19:16 -05:00
{
ImGui::Spacing();
2021-06-18 12:49:11 -04:00
CPlayerPed* pPlayer = FindPlayerPed();
int hplayer = CPools::GetPedRef(pPlayer);
2020-12-02 16:19:16 -05:00
if (ImGui::BeginTabBar("Game", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll))
{
if (ImGui::BeginTabItem("Checkboxes"))
{
ImGui::Spacing();
2021-06-18 12:49:11 -04:00
ImGui::Columns(2, nullptr, false);
if (ImGui::Checkbox("Disable cheats", &m_bDisableCheats))
2020-12-02 16:19:16 -05:00
{
2021-06-18 12:49:11 -04:00
if (m_bDisableCheats)
2020-12-02 16:19:16 -05:00
{
patch::Set<BYTE>(0x4384D0, 0xE9, false);
patch::SetInt(0x4384D1, 0xD0, false);
patch::Nop(0x4384D5, 4, false);
}
else
{
patch::Set<BYTE>(0x4384D0, 0x83, false);
patch::SetInt(0x4384D1, -0x7DF0F908, false);
patch::SetInt(0x4384D5, 0xCC, false);
}
}
2021-06-18 12:49:11 -04:00
if (ImGui::Checkbox("Disable F1 & F3 replay", &m_bDisableReplay))
2020-12-02 16:19:16 -05:00
{
2021-06-18 12:49:11 -04:00
if (m_bDisableReplay)
2020-12-02 16:19:16 -05:00
patch::SetInt(0x460500, 0xC3, false);
else
patch::SetInt(0x460500, 0xBD844BB, false);
}
Ui::CheckboxAddress("Faster clock", 0x96913B);
2021-06-18 12:49:11 -04:00
if (Ui::CheckboxWithHint("Forbidden area wl", &m_bForbiddenArea, "Wanted levels that appears outside \
2020-12-02 16:19:16 -05:00
of LS without completing missions"))
{
2021-06-18 12:49:11 -04:00
if (m_bForbiddenArea)
2020-12-02 16:19:16 -05:00
patch::Set<BYTE>(0x441770, 0x83, false);
else
patch::Set<BYTE>(0x441770, 0xC3, false);
}
Ui::CheckboxAddress("Free pay n spray", 0x96C009);
2021-06-18 12:49:11 -04:00
if (ImGui::Checkbox("Freeze misson timer", &m_bMissionTimer))
Command<Commands::FREEZE_ONSCREEN_TIMER>(m_bMissionTimer);
2020-12-02 16:19:16 -05:00
2021-02-02 02:59:01 -05:00
ImGui::NextColumn();
if (Ui::CheckboxWithHint("Hard mode", &m_HardMode::m_bEnabled, "Makes the game more challanging to play. \n\
2021-02-13 04:08:37 -05:00
Lowers armour, health, stamina etc."))
2021-02-02 02:59:01 -05:00
{
2021-02-24 16:54:45 -05:00
CPlayerPed* player = FindPlayerPed();
2021-02-02 02:59:01 -05:00
if (m_HardMode::m_bEnabled)
2021-02-02 02:59:01 -05:00
{
m_HardMode::m_fBacArmour = player->m_fArmour;
m_HardMode::m_fBacHealth = player->m_fHealth;
m_HardMode::m_fBacMaxHealth = CStats::GetStatValue(STAT_MAX_HEALTH);
m_HardMode::m_fBacStamina = CStats::GetStatValue(STAT_STAMINA);
2021-02-02 02:59:01 -05:00
player->m_fHealth = 50.0f;
}
else
{
player->m_fArmour = m_HardMode::m_fBacArmour;
CStats::SetStatValue(STAT_STAMINA, m_HardMode::m_fBacStamina);
CStats::SetStatValue(STAT_MAX_HEALTH, m_HardMode::m_fBacMaxHealth);
player->m_fHealth = m_HardMode::m_fBacHealth;
2021-02-02 02:59:01 -05:00
CWeaponInfo::LoadWeaponData();
}
}
2021-06-18 12:49:11 -04:00
if (Ui::CheckboxWithHint("Keep stuff", &m_bKeepStuff, "Keep stuff after arrest/death"))
2020-12-02 16:19:16 -05:00
{
2021-06-18 12:49:11 -04:00
Command<Commands::SWITCH_ARREST_PENALTIES>(m_bKeepStuff);
Command<Commands::SWITCH_DEATH_PENALTIES>(m_bKeepStuff);
2020-12-02 16:19:16 -05:00
}
2021-06-18 12:49:11 -04:00
Ui::CheckboxWithHint("Screenshot shortcut", &m_bScreenShot,
(("Take screenshot using ") + Ui::GetHotKeyNameString(Menu::m_HotKeys::quickSceenShot)
2021-06-18 12:49:11 -04:00
+ "\nSaved inside 'GTA San Andreas User Files\\Gallery'").c_str());
if (Ui::CheckboxWithHint("Solid water", &m_bSolidWater,
"Player can walk on water\nTurn this off if you want to swim."))
2020-12-02 16:19:16 -05:00
{
2021-06-18 12:49:11 -04:00
if (!m_bSolidWater && m_nSolidWaterObj != 0)
2020-12-02 16:19:16 -05:00
{
2021-06-18 12:49:11 -04:00
Command<Commands::DELETE_OBJECT>(m_nSolidWaterObj);
m_nSolidWaterObj = 0;
2020-12-02 16:19:16 -05:00
}
}
2021-06-18 12:49:11 -04:00
if (ImGui::Checkbox("Sync system time", &m_bSyncTime))
{
2021-06-18 12:49:11 -04:00
if (m_bSyncTime)
patch::RedirectCall(0x53BFBD, &RealTimeClock);
else
patch::RedirectCall(0x53BFBD, &CClock::Update);
}
2020-12-02 16:19:16 -05:00
ImGui::Columns(1);
ImGui::EndTabItem();
}
if (ImGui::BeginTabItem("Menus"))
{
2021-01-19 05:02:33 -05:00
if (ImGui::CollapsingHeader("Current day"))
{
2021-02-24 16:54:45 -05:00
int day = CClock::CurrentDay - 1;
2021-06-18 12:49:11 -04:00
if (Ui::ListBox("Select day", m_DayNames, day))
2021-02-24 16:54:45 -05:00
CClock::CurrentDay = day + 1;
2021-01-19 05:02:33 -05:00
ImGui::Spacing();
ImGui::Separator();
}
Ui::EditAddress<int>("Days passed", 0xB79038, 0, 9999);
Ui::EditReference("FPS limit", RsGlobal.frameLimit, 1, 30, 60);
if (ImGui::CollapsingHeader("Free cam"))
2020-12-02 16:19:16 -05:00
{
if (Ui::CheckboxWithHint("Enable", &m_Freecam::m_bEnabled, "Forward: I\tBackward: K\
2021-02-08 05:25:06 -05:00
\nLeft: J\t\t Right: L\n\nSlower: RCtrl\tFaster: RShift\n\nZoom: Mouse wheel"))
2020-12-02 16:19:16 -05:00
{
if (!m_Freecam::m_bEnabled)
2021-01-19 05:02:33 -05:00
ClearFreecamStuff();
2020-12-02 16:19:16 -05:00
}
ImGui::Spacing();
2021-02-24 16:54:45 -05:00
if (ImGui::SliderFloat("Field of view", &m_Freecam::m_fFOV, 5.0f, 120.0f))
2021-02-08 05:25:06 -05:00
{
TheCamera.LerpFOV(TheCamera.FindCamFOV(), m_Freecam::m_fFOV, 250.0f, true);
2021-02-08 05:25:06 -05:00
Command<Commands::CAMERA_PERSIST_FOV>(true);
}
ImGui::SliderFloat("Movement Speed", &m_Freecam::m_fSpeed, 0.0f, 0.5f);
2020-12-02 16:19:16 -05:00
ImGui::Spacing();
2021-01-19 05:02:33 -05:00
ImGui::TextWrapped("Press Enter to teleport player to camera location");
2020-12-02 16:19:16 -05:00
ImGui::Spacing();
ImGui::Separator();
}
2021-02-24 16:54:45 -05:00
Ui::EditReference("Game speed", CTimer::ms_fTimeScale, 1, 1, 10);
2020-12-02 16:19:16 -05:00
Ui::EditFloat("Gravity", 0x863984, -1.0f, 0.008f, 1.0f);
if (ImGui::CollapsingHeader("Set time"))
{
int hour = CClock::ms_nGameClockHours;
int minute = CClock::ms_nGameClockMinutes;
if (ImGui::InputInt("Hour", &hour))
{
if (hour < 0) hour = 23;
if (hour > 23) hour = 0;
CClock::ms_nGameClockHours = hour;
}
if (ImGui::InputInt("Minute", &minute))
{
if (minute < 0) minute = 59;
if (minute > 59) minute = 0;
CClock::ms_nGameClockMinutes = minute;
}
ImGui::Spacing();
ImGui::Separator();
}
2021-06-18 12:49:11 -04:00
static std::vector<Ui::NamedMemory> themes{
{"Beach", 0x969159}, {"Country", 0x96917D}, {"Fun house", 0x969176}, {"Ninja", 0x96915C}
};
2020-12-02 16:19:16 -05:00
Ui::EditRadioButtonAddress("Themes", themes);
2021-02-24 16:54:45 -05:00
2020-12-02 16:19:16 -05:00
if (ImGui::CollapsingHeader("Weather"))
{
2021-06-18 12:49:11 -04:00
using func = void(void);
2021-02-24 16:54:45 -05:00
if (ImGui::Button("Foggy", Ui::GetSize(3)))
2020-12-02 16:19:16 -05:00
((func*)0x438F80)();
ImGui::SameLine();
if (ImGui::Button("Overcast", Ui::GetSize(3)))
((func*)0x438F60)();
ImGui::SameLine();
if (ImGui::Button("Rainy", Ui::GetSize(3)))
((func*)0x438F70)();
if (ImGui::Button("Sandstorm", Ui::GetSize(3)))
((func*)0x439590)();
ImGui::SameLine();
if (ImGui::Button("Thunderstorm", Ui::GetSize(3)))
((func*)0x439570)();
ImGui::SameLine();
if (ImGui::Button("Very sunny", Ui::GetSize(3)))
((func*)0x438F50)();
ImGui::Spacing();
ImGui::Separator();
}
ImGui::EndTabItem();
}
if (ImGui::BeginTabItem("Missions"))
{
ImGui::Spacing();
2021-06-18 12:49:11 -04:00
if (!m_bMissionLoaderWarningShown)
2020-12-02 16:19:16 -05:00
{
2021-02-20 17:14:26 -05:00
ImGui::TextWrapped("Mission loader 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();
2021-06-18 12:49:11 -04:00
if (ImGui::Button("Show mission loader", ImVec2(Ui::GetSize())))
m_bMissionLoaderWarningShown = true;
2020-12-02 16:19:16 -05:00
}
else
{
if (ImGui::Button("Fail current mission", ImVec2(Ui::GetSize())))
{
if (!CCutsceneMgr::ms_running)
Command<Commands::FAIL_CURRENT_MISSION>();
}
2020-12-02 16:19:16 -05:00
ImGui::Spacing();
2020-12-02 16:19:16 -05:00
2021-06-18 12:49:11 -04:00
Ui::DrawJSON(m_MissionData.m_Json, m_MissionData.m_Categories, m_MissionData.m_Selected, m_MissionData.m_Filter,
SetPlayerMission, nullptr);
}
2020-12-02 16:19:16 -05:00
ImGui::EndTabItem();
}
if (ImGui::BeginTabItem("Stats"))
{
// similat to Ui::DrawJSON()
ImGui::Spacing();
2021-02-24 16:54:45 -05:00
2020-12-02 16:19:16 -05:00
ImGui::PushItemWidth(ImGui::GetContentRegionAvailWidth() / 2 - 5);
2021-06-18 12:49:11 -04:00
Ui::ListBoxStr("##Categories", m_StatData.m_Categories, m_StatData.m_Selected);
2020-12-02 16:19:16 -05:00
ImGui::SameLine();
2021-06-18 12:49:11 -04:00
Ui::FilterWithHint("##Filter", m_StatData.m_Filter, "Search");
2020-12-02 16:19:16 -05:00
ImGui::PopItemWidth();
ImGui::Spacing();
ImGui::BeginChild("STATCHILD");
2021-06-18 12:49:11 -04:00
for (auto root : m_StatData.m_Json.m_Data.items())
2020-12-02 16:19:16 -05:00
{
2021-06-18 12:49:11 -04:00
if (root.key() == m_StatData.m_Selected || m_StatData.m_Selected == "All")
2020-12-02 16:19:16 -05:00
{
for (auto _data : root.value().items())
{
2021-06-18 12:49:11 -04:00
auto name = _data.value().get<std::string>();
if (m_StatData.m_Filter.PassFilter(name.c_str()))
2020-12-02 16:19:16 -05:00
Ui::EditStat(name.c_str(), std::stoi(_data.key()));
}
}
}
ImGui::EndChild();
ImGui::EndTabItem();
}
if (ImGui::BeginTabItem("Random cheats"))
{
ImGui::Spacing();
ImGui::Checkbox("Enable", &m_RandomCheats::m_bEnabled);
2020-12-02 16:19:16 -05:00
ImGui::Spacing();
ImGui::PushItemWidth(ImGui::GetWindowContentRegionWidth() / 2);
ImGui::SliderInt("Activate cheat timer", &m_RandomCheats::m_nInterval, 5, 60);
2020-12-02 16:19:16 -05:00
Ui::ShowTooltip("Wait time after a cheat is activated.");
ImGui::PopItemWidth();
ImGui::TextWrapped("Select cheats");
ImGui::Separator();
if (ImGui::BeginChild("Cheats list"))
{
for (auto element : m_RandomCheats::m_EnabledCheats)
2020-12-02 16:19:16 -05:00
{
bool selected = (element[1] == "true") ? true : false;
2021-06-18 12:49:11 -04:00
if (ImGui::MenuItem(element[0].c_str(), nullptr, selected))
2020-12-02 16:19:16 -05:00
element[1] = selected ? "false" : "true";
}
ImGui::EndChild();
}
ImGui::EndTabItem();
}
ImGui::EndTabBar();
}
}