From 30ea854c7c675947db3c406949e96858a258a3ff Mon Sep 17 00:00:00 2001 From: Grinch_ Date: Tue, 2 Feb 2021 13:59:01 +0600 Subject: [PATCH] More hotkeys, hard mode --- src/Game.cpp | 45 ++++++++++++++++++++++++++++++++++++++++++--- src/Game.h | 9 +++++++++ src/Menu.cpp | 20 ++++++++++++++++++++ src/Menu.h | 2 ++ src/Ui.cpp | 6 +++--- src/Vehicle.cpp | 6 ++++++ src/Visual.cpp | 2 +- 7 files changed, 83 insertions(+), 7 deletions(-) diff --git a/src/Game.cpp b/src/Game.cpp index 63eeed7..2285e04 100644 --- a/src/Game.cpp +++ b/src/Game.cpp @@ -1,6 +1,6 @@ #include "pch.h" -#include "Game.h" #include "Menu.h" +#include "Game.h" #include "Ui.h" #include "Util.h" #include "CIplStore.h" @@ -33,6 +33,12 @@ float Game::freecam::mouseY = 0; int Game::freecam::hped = -1; CPed *Game::freecam::ped = nullptr; +bool Game::hard_mode::state = false; +float Game::hard_mode::prev_armour = 0.0f; +float Game::hard_mode::prev_health = 0.0f; +float Game::hard_mode::prev_max_health = 0.0f; +float Game::hard_mode::prev_stamina = 0.0f; + bool Game::disable_cheats = false; bool Game::disable_replay = false; bool Game::forbidden_area_wl = true; @@ -107,6 +113,16 @@ Game::Game() } } + if (hard_mode::state) + { + if (player->m_fHealth > 50.0f) + player->m_fHealth = 50.0f; + + player->m_fArmour = 0.0f; + CStats::SetStatValue(STAT_MAX_HEALTH, 350.0f); + CStats::SetStatValue(STAT_STAMINA, 0.0f); + } + if (solid_water) { CVector pos = player->GetPosition(); @@ -353,11 +369,34 @@ of LS without completing missions")) Ui::CheckboxAddress("Free pay n spray", 0x96C009); - ImGui::NextColumn(); - if (ImGui::Checkbox("Freeze misson timer", &freeze_mission_timer)) Command(freeze_mission_timer); + ImGui::NextColumn(); + + if (Ui::CheckboxWithHint("Hard mode", &hard_mode::state, "Makes the game more challanging to play. " +"Lowers\narmour, health, stamina etc.")) + { + CPlayerPed *player = FindPlayerPed(); + + if (hard_mode::state) + { + hard_mode::prev_armour = player->m_fArmour; + hard_mode::prev_health = player->m_fHealth; + hard_mode::prev_max_health = CStats::GetStatValue(STAT_MAX_HEALTH); + hard_mode::prev_stamina = CStats::GetStatValue(STAT_STAMINA); + player->m_fHealth = 50.0f; + } + else + { + player->m_fArmour = hard_mode::prev_armour; + CStats::SetStatValue(STAT_STAMINA,hard_mode::prev_stamina); + CStats::SetStatValue(STAT_MAX_HEALTH, hard_mode::prev_max_health); + player->m_fHealth = hard_mode::prev_health; + CWeaponInfo::LoadWeaponData(); + } + } + if (Ui::CheckboxWithHint("Keep stuff", &keep_stuff, "Keep stuff after arrest/death")) { Command(keep_stuff); diff --git a/src/Game.h b/src/Game.h index 13e61b0..86e5ad9 100644 --- a/src/Game.h +++ b/src/Game.h @@ -29,6 +29,15 @@ public: static float mouseX, mouseY, tmouseX, tmouseY; }; + struct hard_mode + { + static bool state; + static float prev_health; + static float prev_max_health; + static float prev_armour; + static float prev_stamina; + }; + static bool disable_cheats; static bool disable_replay; static bool forbidden_area_wl; diff --git a/src/Menu.cpp b/src/Menu.cpp index c77b961..6a6fdc4 100644 --- a/src/Menu.cpp +++ b/src/Menu.cpp @@ -28,6 +28,8 @@ HotKeyData Menu::hotkeys::menu_open{}; HotKeyData Menu::hotkeys::quick_ss{}; HotKeyData Menu::hotkeys::quick_tp{}; HotKeyData Menu::hotkeys::veh_engine{}; +HotKeyData Menu::hotkeys::veh_instant_start{}; +HotKeyData Menu::hotkeys::veh_instant_stop{}; bool Menu::commands::show_menu = false; char Menu::commands::input_buffer[INPUT_BUFFER_SIZE] = ""; @@ -78,6 +80,12 @@ Menu::Menu() hotkeys::veh_engine.key1 = config.GetValue("hotkey.veh_engine.key1", VK_NONE); hotkeys::veh_engine.key2 = config.GetValue("hotkey.veh_engine.key2", VK_NONE); + + hotkeys::veh_instant_start.key1 = config.GetValue("hotkey.veh_instant_start.key1", VK_NONE); + hotkeys::veh_instant_start.key2 = config.GetValue("hotkey.veh_instant_start.key2", VK_NONE); + + hotkeys::veh_instant_stop.key1 = config.GetValue("hotkey.veh_instant_stop.key1", VK_NONE); + hotkeys::veh_instant_stop.key2 = config.GetValue("hotkey.veh_instant_stop.key2", VK_NONE); }; } @@ -396,6 +404,18 @@ void Menu::Main() config.SetValue("hotkey.veh_engine.key2", hotkeys::veh_engine.key2); } + if (Ui::HotKey("Vehicle instant start", hotkeys::veh_instant_start)) + { + config.SetValue("hotkey.veh_instant_start.key1", hotkeys::veh_instant_start.key1); + config.SetValue("hotkey.veh_instant_start.key2", hotkeys::veh_instant_start.key2); + } + + if (Ui::HotKey("Vehicle instant stop", hotkeys::veh_instant_stop)) + { + config.SetValue("hotkey.veh_instant_stop.key1", hotkeys::veh_instant_stop.key1); + config.SetValue("hotkey.veh_instant_stop.key2", hotkeys::veh_instant_stop.key2); + } + ImGui::Dummy(ImVec2(0, 10)); ImGui::EndChild(); diff --git a/src/Menu.h b/src/Menu.h index 0f4d0c8..c292ebc 100644 --- a/src/Menu.h +++ b/src/Menu.h @@ -29,6 +29,8 @@ public: static HotKeyData quick_ss; static HotKeyData quick_tp; static HotKeyData veh_engine; + static HotKeyData veh_instant_start; + static HotKeyData veh_instant_stop; }; struct commands { diff --git a/src/Ui.cpp b/src/Ui.cpp index 63e0eb0..db2cfc8 100644 --- a/src/Ui.cpp +++ b/src/Ui.cpp @@ -741,19 +741,19 @@ void Ui::EditFloat(const char *label, const int address, const float min, const int size = ImGui::GetFrameHeight(); if (ImGui::InputFloat(("##" + std::string(label)).c_str(), &val)) - patch::Set(address, val/mul, false); + patch::SetFloat(address, val / mul, false); ImGui::SameLine(0.0, 4.0); if (ImGui::Button("-",ImVec2(size, size)) && val > min) { val -= 1; - patch::Set(address, val / mul, false); + patch::SetFloat(address, val / mul, false); } ImGui::SameLine(0.0, 4.0); if (ImGui::Button("+",ImVec2(size, size)) && val < max) { val += 1; - patch::Set(address, val / mul, false); + patch::SetFloat(address, val / mul, false); } ImGui::SameLine(0.0, 4.0); ImGui::Text("Set"); diff --git a/src/Vehicle.cpp b/src/Vehicle.cpp index 3553073..11a0023 100644 --- a/src/Vehicle.cpp +++ b/src/Vehicle.cpp @@ -119,6 +119,12 @@ Vehicle::Vehicle() veh->m_nVehicleFlags.bEngineBroken = state; veh->m_nVehicleFlags.bEngineOn = !state; } + + if (Ui::HotKeyPressed(Menu::hotkeys::veh_instant_start)) + Command(hveh, 40.0f); + + if (Ui::HotKeyPressed(Menu::hotkeys::veh_instant_stop)) + Command(hveh, 0); if (veh_nodmg) { diff --git a/src/Visual.cpp b/src/Visual.cpp index c621e40..37f33e0 100644 --- a/src/Visual.cpp +++ b/src/Visual.cpp @@ -368,7 +368,7 @@ void Visual::Main() TimecycSlider("Cloud alpha", m_fCloudAlpha, 0, 255); TimecycSlider("Directional mult", m_nDirectionalMult , 0, 255); TimecycSlider("Far clip", m_fFarClip, 0, 2000); - TimecycSlider("Fog start", m_fFogStart, 0, 2000); + TimecycSlider("Fog start", m_fFogStart, 0, 1500); TimecycSlider("High light min intensity", m_nHighLightMinIntensity, 0, 255); TimecycSlider("Light on ground brightness", m_fLightsOnGroundBrightness, 0, 255); TimecycSlider("Light shadow strength", m_nLightShadowStrength, 0, 255);