1. Rename 'Auto heal' -> 'Health regen'

2. Block VCMP for VC build
3. Refactor code
This commit is contained in:
Grinch_ 2022-01-13 19:57:08 +06:00
parent b3d4fd10d0
commit 600ef84cef
23 changed files with 132 additions and 148 deletions

View File

@ -295,7 +295,7 @@ void Animation::Draw()
ImGui::EndChild();
}
}
ImGui::EndTabItem();
}
if (ImGui::BeginTabItem("Custom"))

View File

@ -4,7 +4,6 @@
class Animation
{
private:
// Animation player
static inline ResourceStore m_AnimData{ "animation", eResourceType::TYPE_TEXT };
static inline char m_nAnimBuffer[INPUT_BUFFER_SIZE];
@ -13,7 +12,7 @@ private:
static inline bool m_bSecondary; // play animation as secondary
static inline bool m_PedAnim;
static inline CPed *m_pTarget = nullptr;
#ifdef GTASA
// Cutscene player
struct m_Cutscene
@ -36,21 +35,18 @@ private:
};
#endif
protected:
Animation();
public:
static void Draw();
static void PlayAnimation(std::string& rootKey, std::string& anim, std::string& ifp);
static void RemoveAnimation(std::string& rootKey, std::string& anim, std::string& ifp);
#ifdef GTASA
static void PlayCutscene(std::string& rootKey, std::string& cutsceneId, std::string& interior);
#elif GTAVC
static bool _LoadAnimationBlock(const char* szBlockName);
#endif
#ifndef GTASA
static void _PlayAnimation(RpClump* pClump, int animGroup, int animID, float blend);
#endif
public:
Animation();
static void Draw();
};

View File

@ -1,6 +1,6 @@
#include "pch.h"
#include "cheatMenu.h"
#include "menuinfo.h"
#include "version.h"
#include "ui.h"
#include "updater.h"
#include "d3dhook.h"
@ -81,7 +81,7 @@ CheatMenu::CheatMenu()
{
return;
}
ApplyStyle();
// Load menu settings

View File

@ -50,9 +50,8 @@ void D3dHook::ProcessFrame(void* ptr)
}
ImGuiIO& io = ImGui::GetIO();
static bool bInit = false;
if (bInit)
static bool init;
if (init)
{
ProcessMouse();
@ -116,12 +115,11 @@ void D3dHook::ProcessFrame(void* ptr)
}
else
{
bInit = true;
init = true;
ImGui_ImplWin32_Init(RsGlobal.ps->window);
#ifdef GTASA
// shift trigger fix
patch::Nop(0x00531155, 5);
patch::Nop(0x00531155, 5); // shift trigger fix
#endif
if (gRenderer == Render_DirectX9)
@ -191,7 +189,7 @@ void D3dHook::ProcessMouse()
bMouseDisabled = true;
#ifdef GTA3
pad->m_bDisablePlayerControls = true;
#else
#else
pad->DisablePlayerControls = true;
#endif
}
@ -200,7 +198,7 @@ void D3dHook::ProcessMouse()
bMouseDisabled = false;
#ifdef GTA3
pad->m_bDisablePlayerControls = false;
#else
#else
pad->DisablePlayerControls = false;
#endif
}
@ -245,8 +243,14 @@ void D3dHook::ProcessMouse()
bool D3dHook::InjectHook(void *pCallback)
{
static bool hookInjected;
if (hookInjected)
{
return false;
}
ImGui::CreateContext();
/*
Must check for d3d9 first!
Seems to crash with nvidia geforce experience overlay
@ -258,8 +262,7 @@ bool D3dHook::InjectHook(void *pCallback)
kiero::bind(16, (void**)&oReset, hkReset);
kiero::bind(42, (void**)&oEndScene, hkEndScene);
pCallbackFunc = pCallback;
return true;
hookInjected = true;
}
else
{
@ -269,12 +272,11 @@ bool D3dHook::InjectHook(void *pCallback)
gRenderer = Render_DirectX11;
kiero::bind(8, (void**)&oPresent, hkPresent);
pCallbackFunc = pCallback;
return true;
hookInjected = true;
}
}
return false;
return hookInjected;
}
void D3dHook::RemoveHook()

View File

@ -5,17 +5,17 @@ class D3dHook
{
private:
using f_EndScene = HRESULT(CALLBACK*)(IDirect3DDevice9*);
using f_Present11 = HRESULT(CALLBACK*)(IDXGISwapChain*, UINT, UINT);
using f_Present = HRESULT(CALLBACK*)(IDXGISwapChain*, UINT, UINT);
using f_Reset = HRESULT(CALLBACK*)(IDirect3DDevice9*, D3DPRESENT_PARAMETERS*);
static inline WNDPROC oWndProc;
static inline f_Present11 oPresent;
static inline f_Present oPresent;
static inline f_EndScene oEndScene;
static inline f_Reset oReset;
static inline bool mouseShown;
static inline void* pCallbackFunc = nullptr;
static void CALLBACK ProcessFrame(void* ptr);
static LRESULT CALLBACK hkWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
static void ProcessMouse();
@ -28,13 +28,13 @@ private:
static HRESULT CALLBACK hkPresent(IDXGISwapChain* pSwapChain, UINT SyncInterval, UINT Flags);
public:
D3dHook() = delete;
D3dHook(D3dHook const&) = delete;
void operator=(D3dHook const&) = delete;
D3dHook(D3dHook const&) = delete;
void operator=(D3dHook const&) = delete;
static bool GetMouseState();
static bool InjectHook(void *pCallback);
static void RemoveHook();
static bool InjectHook(void *pCallback);
static void RemoveHook();
static void SetMouseState(bool state);
};

View File

@ -1,23 +1,12 @@
#include "pch.h"
#include "cheatmenu.h"
#include "updater.h"
#include "menuinfo.h"
#include "d3dhook.h"
#include "version.h"
void MenuThread(void* param)
{
static bool gameInit;
// Wait till game init
Events::initRwEvent += []
{
gameInit = true;
};
while (!gameInit)
{
Sleep(1000);
}
// wait for game init
Sleep(3000);
/*
Had to put this in place since some people put the folder in root
@ -46,11 +35,11 @@ void MenuThread(void* param)
return;
}
#ifdef GTASA
/*
TODO: Find a better way
Since you could still name it something else
*/
#ifdef GTASA
if (GetModuleHandle("SAMP.dll") || GetModuleHandle("SAMP.asi"))
{
gLog << "Error: CheatMenu doesn't support SAMP" << std::endl;
@ -58,6 +47,13 @@ void MenuThread(void* param)
return;
}
CFastman92limitAdjuster::Init();
#elif GTAVC
if (GetModuleHandle("vcmp-proxy.dll") || GetModuleHandle("vcmp-proxy.asi"))
{
gLog << "Error: CheatMenu doesn't support VCMP" << std::endl;
MessageBox(RsGlobal.ps->window, "VCMP detected. Exiting CheatMenu.", "CheatMenu", MB_ICONERROR);
return;
}
#endif
gLog << "Starting...\nVersion: " MENU_TITLE "\nAuthor: Grinch_\nDiscord: " DISCORD_INVITE "\nMore Info: "
@ -69,12 +65,10 @@ void MenuThread(void* param)
// Checking for updates once a day
time_t now = time(0);
struct tm tstruct = *localtime(&now);
int lastCheckDate = gConfig.GetValue("config.last_update_checked", 0);
if (lastCheckDate != tstruct.tm_mday)
if (gConfig.GetValue("config.update_date", 0) != tstruct.tm_mday)
{
Updater::CheckUpdate();
gConfig.SetValue("config.last_update_checked", tstruct.tm_mday);
gConfig.SetValue("config.update_date", tstruct.tm_mday);
}
while (true)

View File

@ -3,14 +3,12 @@
class Game
{
public:
private:
static inline ResourceStore m_MissionData{ "mission", eResourceType::TYPE_TEXT };
static inline bool m_bDisableCheats;
static inline bool m_bDisableReplay;
static inline bool m_bMissionTimer;
static inline bool m_bFreezeTime;
static inline bool m_bSyncTime;
#ifdef GTASA
static inline bool m_bForbiddenArea = true; // wanted level when going outside playable aea
static inline bool m_bSolidWater; // walk on water hack
@ -56,13 +54,18 @@ public:
#endif
Game();
static void Draw();
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;
static inline bool m_bSyncTime;
Game();
static void Draw();
};

View File

@ -1,20 +1,6 @@
#include "pch.h"
#include "hotkeys.h"
Hotkey aimSkinChanger;
Hotkey freeCam;
Hotkey commandWindow;
Hotkey fixVeh;
Hotkey flipVeh;
Hotkey freeCamTeleportPlayer;
Hotkey godMode;
Hotkey menuOpen;
Hotkey quickSceenShot;
Hotkey quickTeleport;
Hotkey vehEngine;
Hotkey vehInstantStart;
Hotkey vehInstantStop;
bool Hotkey::DrawUI(const char* label)
{
bool active = (m_CurrentHotkey == label);

View File

@ -23,17 +23,3 @@ public:
bool Pressed();
std::string GetNameString();
};
extern Hotkey aimSkinChanger;
extern Hotkey freeCam;
extern Hotkey commandWindow;
extern Hotkey fixVeh;
extern Hotkey flipVeh;
extern Hotkey freeCamTeleportPlayer;
extern Hotkey godMode;
extern Hotkey menuOpen;
extern Hotkey quickSceenShot;
extern Hotkey quickTeleport;
extern Hotkey vehEngine;
extern Hotkey vehInstantStart;
extern Hotkey vehInstantStop;

View File

@ -1,5 +1,5 @@
#include "pch.h"
#include "menuinfo.h"
#include "version.h"
#include "menu.h"
#include "ui.h"
#include "util.h"

View File

@ -1,2 +1,16 @@
#include "pch.h"
CJson gConfig = CJson("config");
CJson gConfig = CJson("config");
Hotkey aimSkinChanger;
Hotkey freeCam;
Hotkey commandWindow;
Hotkey fixVeh;
Hotkey flipVeh;
Hotkey freeCamTeleportPlayer;
Hotkey godMode;
Hotkey menuOpen;
Hotkey quickSceenShot;
Hotkey quickTeleport;
Hotkey vehEngine;
Hotkey vehInstantStart;
Hotkey vehInstantStop;

View File

@ -104,4 +104,18 @@ static void SetHelpMessage(const char *message, bool b1, bool b2, bool b3)
CHud::SetHelpMessage(wc, b1);
delete wc;
#endif
}
}
extern Hotkey aimSkinChanger;
extern Hotkey freeCam;
extern Hotkey commandWindow;
extern Hotkey fixVeh;
extern Hotkey flipVeh;
extern Hotkey freeCamTeleportPlayer;
extern Hotkey godMode;
extern Hotkey menuOpen;
extern Hotkey quickSceenShot;
extern Hotkey quickTeleport;
extern Hotkey vehEngine;
extern Hotkey vehInstantStart;
extern Hotkey vehInstantStop;

View File

@ -41,8 +41,15 @@ private:
#endif
};
};
public:
#ifdef GTASA
static void SpawnPed(std::string& model);
static void BigHeadEffect(CPed *ped);
#else
static void SpawnPed(std::string& cat, std::string& name, std::string& model);
#endif
public:
#ifdef GTASA
static inline CJson m_SpecialPedJson = CJson("ped special");
static inline ResourceStore m_PedData{"ped", eResourceType::TYPE_BOTH, ImVec2(65, 110)};
@ -53,11 +60,4 @@ public:
Ped();
~Ped();
static void Draw();
#ifdef GTASA
static void SpawnPed(std::string& model);
static void BigHeadEffect(CPed *ped);
#else
static void SpawnPed(std::string& cat, std::string& name, std::string& model);
#endif
};

View File

@ -7,29 +7,6 @@
#ifdef GTASA
#include "ped.h"
// hardcoded cloth category names
const char* cloth_category[18] =
{
"Shirts",
"Heads",
"Trousers",
"Shoes",
"Tattoos left lower arm",
"Tattoos left upper arm",
"Tattoos right upper arm",
"Tattoos right lower arm",
"Tattoos back",
"Tattoos left chest",
"Tattoos right chest",
"Tattoos stomach",
"Tattoos lower back",
"Necklaces",
"Watches",
"Glasses",
"Hats",
"Extras"
};
static inline void PlayerModelBrokenFix()
{
CPlayerPed* pPlayer = FindPlayerPed();
@ -147,7 +124,7 @@ Player::Player()
CPlayerPed* player = FindPlayerPed();
int hplayer = CPools::GetPedRef(player);
if (m_bAutoHeal)
if (m_bHealthRegen)
{
static uint lastDmgTimer = 0;
static uint lastHealTimer = 0;
@ -417,7 +394,6 @@ void Player::Draw()
ImGui::BeginChild("CheckboxesChild");
ImGui::Columns(2, 0, false);
Ui::CheckboxWithHint("Auto heal", &m_bAutoHeal, "Player will heal when not taken damage for 5 seconds");
#ifdef GTASA
Ui::CheckboxAddress("Bounty on yourself", 0x96913F);
@ -469,6 +445,7 @@ void Player::Draw()
pPlayer->m_nEntityFlags.bMeleeProof = m_bGodMode;
#endif
}
Ui::CheckboxWithHint("Health regeneration", &m_bHealthRegen, "Player heals if not taken damage for 5 seconds");
#ifdef GTASA
Ui::CheckboxAddress("Higher cycle jumps", 0x969161);
Ui::CheckboxAddress("Infinite oxygen", 0x96916E);
@ -759,7 +736,7 @@ void Player::Draw()
getline(ss, temp, '$');
return temp;
}, nullptr, cloth_category, sizeof(cloth_category) / sizeof(const char*));
}, nullptr, clothNameList, sizeof(clothNameList) / sizeof(const char*));
}
else
{
@ -792,7 +769,7 @@ void Player::Draw()
CClothes::RebuildPlayer(player, false);
}
ImGui::SameLine();
for (const char* clothName : cloth_category)
for (const char* clothName : clothNameList)
{
if (ImGui::Button(clothName, ImVec2(Ui::GetSize(2))))
{

View File

@ -4,7 +4,7 @@
class Player
{
private:
static inline bool m_bAutoHeal;
static inline bool m_bHealthRegen;
static inline bool m_bGodMode;
static inline bool m_bModloaderInstalled;
struct m_KeepPosition
@ -31,14 +31,18 @@ private:
static inline bool m_bEnabled = false;
static inline float m_fOffset = 40.0f;
};
static inline const char* clothNameList[18] =
{
"Shirts", "Heads", "Trousers", "Shoes", "Tattoos left lower arm", "Tattoos left upper arm",
"Tattoos right upper arm", "Tattoos right lower arm", "Tattoos back", "Tattoos left chest",
"Tattoos right chest", "Tattoos stomach", "Tattoos lower back", "Necklaces", "Watches",
"Glasses", "Hats", "Extras"
};
#else
static inline ResourceStore skinData { BY_GAME(NULL, "skin", "ped"), eResourceType::TYPE_TEXT };
#endif
public:
Player();
static void Draw();
#ifdef GTASA
static void ChangePlayerModel(std::string& model);
static void ChangePlayerCloth(std::string& model);
@ -46,4 +50,8 @@ public:
#else
static void ChangePlayerModel(std::string& cat, std::string& name, std::string& id);
#endif
public:
Player();
static void Draw();
};

View File

@ -32,11 +32,12 @@ private:
static void FetchRadarSpriteData();
#endif
protected:
Teleport();
public:
static void Draw();
static void TeleportPlayer(bool get_marker = false, CVector pos = CVector(0, 0, 0), int interior_id = 0);
static void TeleportToLocation(std::string& rootkey, std::string& bLocName, std::string& loc);
static void RemoveTeleportEntry(std::string& rootkey, std::string& key, std::string& val);
public:
Teleport();
static void TeleportPlayer(bool get_marker = false, CVector pos = CVector(0, 0, 0), int interior_id = 0);
static void Draw();
};

View File

@ -2,7 +2,7 @@
#include "util.h"
#include "ui.h"
#include "../depend/imgui/imgui_internal.h"
#include "menuinfo.h"
#include "version.h"
// Really messy code, cleanup someday
bool Ui::DrawTitleBar()

View File

@ -1,6 +1,6 @@
#include "pch.h"
#include "updater.h"
#include "menuinfo.h"
#include "version.h"
bool Updater::IsUpdateAvailable()
{

View File

@ -10,7 +10,7 @@ void Util::SetCarForwardSpeed(CVehicle *pVeh, float speed)
pVeh->m_vecMoveSpeed.x = speedFactor * inVec.x;
pVeh->m_vecMoveSpeed.y = speedFactor * inVec.y;
pVeh->m_vecMoveSpeed.z = speedFactor * inVec.z;
#else
#else
Command<Commands::SET_CAR_FORWARD_SPEED>(CPools::GetVehicleRef(pVeh), 0);
#endif
}

View File

@ -91,6 +91,8 @@ private:
#endif
public:
Vehicle();
~Vehicle();
#ifdef GTASA
static void SpawnVehicle(std::string& name);
#else
@ -99,6 +101,4 @@ public:
static std::string GetNameFromModel(int model);
static int GetModelFromName(const char* name);
static void Draw();
Vehicle();
~Vehicle();
};

View File

@ -38,6 +38,7 @@ private:
static bool TimeCycColorEdit4(const char* label, T* r, T* g, T* b, T* a, ImGuiColorEditFlags flags = 0);
template <typename T>
static void TimecycSlider(const char* label, T* data, int min, int max);
public:
Visual();
static void Draw();

View File

@ -3,10 +3,8 @@
class Weapon
{
public:
private:
#ifdef GTASA
static inline ResourceStore m_WeaponData { "weapon", eResourceType::TYPE_BOTH, ImVec2(65, 65) };
static inline bool m_bAutoAim;
static inline bool m_bRapidFire;
static inline bool m_bDualWeild;
@ -33,7 +31,6 @@ public:
"Da nang boys", "Mafia", "Mountain cloud triad", "Varrio los aztecas", "Gang9", "Gang10"
};
#else
static inline ResourceStore m_WeaponData { "weapon", eResourceType::TYPE_TEXT };
static inline bool m_bInfiniteAmmo;
#endif
static inline bool m_bFastReload;
@ -43,13 +40,18 @@ public:
static inline uchar m_nCurrentWeaponSlot = -1;
static inline int m_nSelectedWeapon;
Weapon();
static void Draw();
public:
#ifdef GTASA
static inline ResourceStore m_WeaponData { "weapon", eResourceType::TYPE_BOTH, ImVec2(65, 65) };
static void GiveWeaponToPlayer(std::string& weapon_type);
static void SetGangWeapon(std::string& weapon_type);
#else
static inline ResourceStore m_WeaponData { "weapon", eResourceType::TYPE_TEXT };
static void GiveWeaponToPlayer(std::string& rootkey, std::string& model, std::string& name);
#endif
Weapon();
static void Draw();
};