Add option to change overlay color, autoheal

This commit is contained in:
Grinch_ 2022-01-02 18:26:07 +06:00
parent c17dc9078f
commit 5f7f04e9c1
7 changed files with 77 additions and 11 deletions

View File

@ -27,6 +27,11 @@ Menu::Menu()
m_Overlay::mSelectedPos = (DISPLAY_POS)gConfig.GetValue("overlay.selected_pos", (int)DISPLAY_POS::BOTTOM_RIGHT); m_Overlay::mSelectedPos = (DISPLAY_POS)gConfig.GetValue("overlay.selected_pos", (int)DISPLAY_POS::BOTTOM_RIGHT);
m_Overlay::fPosX = gConfig.GetValue("overlay.pox", 0); m_Overlay::fPosX = gConfig.GetValue("overlay.pox", 0);
m_Overlay::fPosY = gConfig.GetValue("overlay.posy", 0); m_Overlay::fPosY = gConfig.GetValue("overlay.posy", 0);
m_Overlay::textColor[0] = gConfig.GetValue("overlay.text_color.r", 1.0f);
m_Overlay::textColor[1] = gConfig.GetValue("overlay.text_color.g", 1.0f);
m_Overlay::textColor[2] = gConfig.GetValue("overlay.text_color.b", 1.0f);
m_Overlay::textColor[3] = gConfig.GetValue("overlay.text_color.a", 1.0f);
// Hotkeys // Hotkeys
aimSkinChanger.m_key1 = gConfig.GetValue("hotkey.aim_skin_changer.key1", VK_RETURN); aimSkinChanger.m_key1 = gConfig.GetValue("hotkey.aim_skin_changer.key1", VK_RETURN);
@ -128,15 +133,15 @@ void Menu::DrawOverlay()
} }
ImGui::SetNextWindowBgAlpha(m_Overlay::bTransparent ? 0.0f : 0.5f); ImGui::SetNextWindowBgAlpha(m_Overlay::bTransparent ? 0.0f : 0.5f);
ImGui::PushStyleColor(ImGuiCol_Text, *(ImVec4*)&m_Overlay::textColor);
if (m_bShowMenu && ImGui::Begin("Overlay", nullptr, window_flags)) if (m_bShowMenu && ImGui::Begin("Overlay", nullptr, window_flags))
{ {
CVector pos{0,0,0}; CVector pos{0,0,0};
pos = pPlayer->GetPosition(); pos = pPlayer->GetPosition();
size_t game_ms = CTimer::m_snTimeInMilliseconds; size_t game_ms = CTimer::m_snTimeInMilliseconds;
static size_t interval = 0;
if (game_ms - m_Overlay::mLastInterval > m_Overlay::mInterval) if (game_ms - interval > 1000)
{ {
m_Overlay::fCpuUsage = static_cast<float>(Util::GetCurrentCPUUsage()); m_Overlay::fCpuUsage = static_cast<float>(Util::GetCurrentCPUUsage());
@ -147,7 +152,7 @@ void Menu::DrawOverlay()
m_Overlay::fMemUsage = 100.0f * (static_cast<float>(mUsedRam) / static_cast<float>(m_Overlay::mTotalRam)); m_Overlay::fMemUsage = 100.0f * (static_cast<float>(mUsedRam) / static_cast<float>(m_Overlay::mTotalRam));
m_Overlay::mFPS = static_cast<size_t>(BY_GAME(CTimer::game_FPS, io.Framerate, io.Framerate)); m_Overlay::mFPS = static_cast<size_t>(BY_GAME(CTimer::game_FPS, io.Framerate, io.Framerate));
m_Overlay::mLastInterval = game_ms; interval = game_ms;
} }
if (m_Overlay::bCoord) if (m_Overlay::bCoord)
@ -195,6 +200,7 @@ void Menu::DrawOverlay()
ImGui::End(); ImGui::End();
} }
ImGui::PopStyleColor();
} }
} }
@ -348,7 +354,7 @@ void Menu::Draw()
if (ImGui::Button("Reset config", ImVec2(Ui::GetSize(2)))) if (ImGui::Button("Reset config", ImVec2(Ui::GetSize(2))))
{ {
gConfig.m_Data.clear(); gConfig.m_Data.clear();
SetHelpMessage("Config reset", false, false, false); SetHelpMessage("Config has been reset. Restart the game for it to take effect.", false, false, false);
} }
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::Button("Reset size", ImVec2(Ui::GetSize(2)))) if (ImGui::Button("Reset size", ImVec2(Ui::GetSize(2))))
@ -365,37 +371,65 @@ void Menu::Draw()
ImGui::Spacing(); ImGui::Spacing();
ImGui::Spacing(); ImGui::Spacing();
ImGui::SameLine(); ImGui::SameLine();
if (Ui::ListBox("Overlay", m_Overlay::posNames, (int&)m_Overlay::mSelectedPos)) if (Ui::ListBox("Position", m_Overlay::posNames, (int&)m_Overlay::mSelectedPos))
{
gConfig.SetValue("overlay.selected_pos", m_Overlay::mSelectedPos); gConfig.SetValue("overlay.selected_pos", m_Overlay::mSelectedPos);
}
ImGui::Spacing();
ImGui::SameLine();
if (ImGui::ColorEdit4("Text color", m_Overlay::textColor))
{
gConfig.SetValue("overlay.text_color.r", m_Overlay::textColor[0]);
gConfig.SetValue("overlay.text_color.g", m_Overlay::textColor[1]);
gConfig.SetValue("overlay.text_color.b", m_Overlay::textColor[2]);
gConfig.SetValue("overlay.text_color.a", m_Overlay::textColor[3]);
}
ImGui::Spacing(); ImGui::Spacing();
ImGui::Columns(2, nullptr, false); ImGui::Columns(2, nullptr, false);
if (ImGui::Checkbox("No background", &m_Overlay::bTransparent)) if (ImGui::Checkbox("No background", &m_Overlay::bTransparent))
{
gConfig.SetValue("overlay.transparent", m_Overlay::bTransparent); gConfig.SetValue("overlay.transparent", m_Overlay::bTransparent);
}
if (ImGui::Checkbox("Show coordinates", &m_Overlay::bCoord)) if (ImGui::Checkbox("Show coordinates", &m_Overlay::bCoord))
{
gConfig.SetValue("overlay.coord", m_Overlay::bCoord); gConfig.SetValue("overlay.coord", m_Overlay::bCoord);
}
if (ImGui::Checkbox("Show CPU usage", &m_Overlay::bCpuUsage)) if (ImGui::Checkbox("Show CPU usage", &m_Overlay::bCpuUsage))
{
gConfig.SetValue("overlay.cpu_usage", m_Overlay::bCpuUsage); gConfig.SetValue("overlay.cpu_usage", m_Overlay::bCpuUsage);
}
if (ImGui::Checkbox("Show FPS", &m_Overlay::bFPS)) if (ImGui::Checkbox("Show FPS", &m_Overlay::bFPS))
{
gConfig.SetValue("overlay.fps", m_Overlay::bFPS); gConfig.SetValue("overlay.fps", m_Overlay::bFPS);
}
ImGui::NextColumn(); ImGui::NextColumn();
if (ImGui::Checkbox("Show location", &m_Overlay::bLocName)) if (ImGui::Checkbox("Show location", &m_Overlay::bLocName))
{
gConfig.SetValue("overlay.loc_name", m_Overlay::bLocName); gConfig.SetValue("overlay.loc_name", m_Overlay::bLocName);
}
if (ImGui::Checkbox("Show RAM usage", &m_Overlay::bMemUsage)) if (ImGui::Checkbox("Show RAM usage", &m_Overlay::bMemUsage))
{
gConfig.SetValue("overlay.mem_usage", m_Overlay::bMemUsage); gConfig.SetValue("overlay.mem_usage", m_Overlay::bMemUsage);
}
if (ImGui::Checkbox("Show veh health", &m_Overlay::bVehHealth)) if (ImGui::Checkbox("Show veh health", &m_Overlay::bVehHealth))
{
gConfig.SetValue("overlay.veh_health", m_Overlay::bVehHealth); gConfig.SetValue("overlay.veh_health", m_Overlay::bVehHealth);
}
if (ImGui::Checkbox("Show veh speed", &m_Overlay::bVehSpeed)) if (ImGui::Checkbox("Show veh speed", &m_Overlay::bVehSpeed))
{
gConfig.SetValue("overlay.veh_speed", m_Overlay::bVehSpeed); gConfig.SetValue("overlay.veh_speed", m_Overlay::bVehSpeed);
}
ImGui::Columns(1); ImGui::Columns(1);
@ -507,6 +541,13 @@ void Menu::Draw()
ImGui::Spacing(); ImGui::Spacing();
ImGui::Separator(); ImGui::Separator();
} }
if (ImGui::CollapsingHeader("Teleport"))
{
ImGui::Spacing();
ImGui::TextWrapped("Teleports player to specified coordinates.\nExample: tp x y z");
ImGui::Spacing();
ImGui::Separator();
}
if (ImGui::CollapsingHeader("Quick vehicle spawner")) if (ImGui::CollapsingHeader("Quick vehicle spawner"))
{ {
ImGui::Spacing(); ImGui::Spacing();

View File

@ -33,9 +33,8 @@ private:
static inline DISPLAY_POS mSelectedPos = DISPLAY_POS::BOTTOM_RIGHT; static inline DISPLAY_POS mSelectedPos = DISPLAY_POS::BOTTOM_RIGHT;
static inline float fPosX; static inline float fPosX;
static inline float fPosY; static inline float fPosY;
static inline size_t mInterval = 1000;
static inline size_t mLastInterval = 0;
static inline int mTotalRam = 0; static inline int mTotalRam = 0;
static inline float textColor[4] = {1.0f, 1.0f, 1.0f, 1.0f};
}; };
public: public:

View File

@ -146,6 +146,30 @@ Player::Player()
CPlayerPed* player = FindPlayerPed(); CPlayerPed* player = FindPlayerPed();
int hplayer = CPools::GetPedRef(player); int hplayer = CPools::GetPedRef(player);
if (m_bAutoHeal)
{
static uint lastDmgTimer = 0;
static uint lastHealTimer = 0;
static float health = 0;
float maxHealth = BY_GAME(player->m_fMaxHealth, 100, 100);
if (player->m_fHealth != health)
{
health = player->m_fHealth;
lastDmgTimer = timer;
}
if (player->m_fHealth != maxHealth
&& timer - lastDmgTimer > 5000
&& timer - lastHealTimer > 1000
)
{
player->m_fHealth += 0.2f;
lastHealTimer = timer;
health = player->m_fHealth;
}
}
if (m_KeepPosition::m_bEnabled) if (m_KeepPosition::m_bEnabled)
{ {
if (Command<Commands::IS_CHAR_DEAD>(hplayer)) if (Command<Commands::IS_CHAR_DEAD>(hplayer))
@ -392,6 +416,7 @@ void Player::Draw()
ImGui::BeginChild("CheckboxesChild"); ImGui::BeginChild("CheckboxesChild");
ImGui::Columns(2, 0, false); ImGui::Columns(2, 0, false);
Ui::CheckboxWithHint("Auto heal", &m_bAutoHeal, "Player will heal when not taken damage for 5 seconds");
#ifdef GTASA #ifdef GTASA
Ui::CheckboxAddress("Bounty on yourself", 0x96913F); Ui::CheckboxAddress("Bounty on yourself", 0x96913F);

View File

@ -4,6 +4,7 @@
class Player class Player
{ {
private: private:
static inline bool m_bAutoHeal;
static inline bool m_bGodMode; static inline bool m_bGodMode;
static inline bool m_bModloaderInstalled; static inline bool m_bModloaderInstalled;
struct m_KeepPosition struct m_KeepPosition

View File

@ -14,7 +14,7 @@ public:
#ifdef GTASA #ifdef GTASA
static void ClearCharTasksVehCheck(CPed* ped); static void ClearCharTasksVehCheck(CPed* ped);
static int GetLargestGangInZone(); static int GetLargestGangInZone();
static RwTexture* LoadTextureFromMemory(char* data, unsigned int size); static RwTexture* LoadTextureFromMemory(char* data, unsigned int size);
#endif #endif

View File

@ -684,7 +684,7 @@ void Vehicle::Draw()
Call<0x490EE0>(); Call<0x490EE0>();
} }
#endif #endif
Ui::CheckboxWithHint("Watertight car", &m_bVehWatertight); 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)); Ui::CheckboxAddress("Wheels only", BY_GAME(0x96914B, 0xA10B70, 0x95CD78));
ImGui::Columns(1); ImGui::Columns(1);

View File

@ -549,7 +549,7 @@ void Visual::Draw()
{ {
#ifdef GTASA #ifdef GTASA
ImGui::TextWrapped( ImGui::TextWrapped(
"These options won't work if you got any mods that drastically changes the game hud. i.e. Mobile Hud, GTA 5 Hud etc."); "These options won't work if you got any mods that drastically change the game hud. i.e. Mobile Hud, GTA 5 Hud, VHud etc.");
ImGui::Spacing(); ImGui::Spacing();
Ui::ColorPickerAddress("Armourbar color", *(int*)0x5890FC, ImVec4(225, 225, 225, 255)); Ui::ColorPickerAddress("Armourbar color", *(int*)0x5890FC, ImVec4(225, 225, 225, 255));
Ui::EditAddress<float>("Armourbar posX", 0x866B78, -999, 94, 999); Ui::EditAddress<float>("Armourbar posX", 0x866B78, -999, 94, 999);