Add vice city support

This commit is contained in:
Grinch_ 2021-08-02 07:41:48 +06:00
parent 3c3dff6716
commit 257192540d
27 changed files with 420 additions and 130 deletions

View File

@ -6,8 +6,10 @@
"${workspaceFolder}/**",
"${PLUGIN_SDK_DIR}/*",
"${DIRECTX9_SDK_DIR}/Include/*",
"${PLUGIN_SDK_DIR}/plugin_sa/*",
"${PLUGIN_SDK_DIR}/plugin_sa/game_sa/*",
// "${PLUGIN_SDK_DIR}/plugin_sa/*",
// "${PLUGIN_SDK_DIR}/plugin_sa/game_sa/*",
"${PLUGIN_SDK_DIR}/plugin_vc/*",
"${PLUGIN_SDK_DIR}/plugin_vc/game_vc/*",
"${PLUGIN_SDK_DIR}/shared/*",
"${PLUGIN_SDK_DIR}/shared/game/*",
"C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.19041.0\\ucrt\\*",
@ -18,7 +20,7 @@
"IS_PLATFORM_WIN",
"_CRT_SECURE_NO_WARNINGS",
"_CRT_NON_CONFORMING_SWPRINTFS",
"GTASA",
"GTAVC",
"_DX9_SDK_INSTALLED",
"PLUGIN_SGV_10US"
],

11
.vscode/launch.json vendored
View File

@ -15,6 +15,17 @@
"environment": [],
"console": "internalConsole"
},
{
"name": "Launch VC",
"type": "cppvsdbg",
"request": "launch",
"program": "F:/GTA Vice City/gta-vc.exe",
"args": [],
"stopAtEntry": false,
"cwd": "C:/Work/GTASanAndreas/",
"environment": [],
"console": "internalConsole"
},
{
"name": "Attach",
"type": "cppvsdbg",

42
.vscode/tasks.json vendored
View File

@ -4,9 +4,9 @@
"version": "2.0.0",
"tasks": [
{
"label": "Build Debug",
"label": "Build DebugSA",
"type": "shell",
"command": "${workspaceFolder}/tools/Debug.bat",
"command": "${workspaceFolder}/tools/DebugSA.bat",
"presentation": {
"echo": true,
"reveal": "always",
@ -21,9 +21,43 @@
}
},
{
"label": "Build Release",
"label": "Build ReleaseSA",
"type": "shell",
"command": "${workspaceFolder}/tools/Release.bat",
"command": "${workspaceFolder}/tools/ReleaseSA.bat",
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared",
"showReuseMessage": false,
"clear": true
},
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "Build DebugVC",
"type": "shell",
"command": "${workspaceFolder}/tools/DebugVC.bat",
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared",
"showReuseMessage": false,
"clear": true
},
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "Build ReleaseVC",
"type": "shell",
"command": "${workspaceFolder}/tools/ReleaseVC.bat",
"presentation": {
"echo": true,
"reveal": "always",

View File

@ -39,7 +39,7 @@ void Animation::PlayCutscene(std::string& rootKey, std::string& cutsceneId, std:
{
if (Util::IsOnCutscene())
{
CHud::SetHelpMessage("Another cutscene is running", false, false, false);
SetHelpMessage("Another cutscene is running", false, false, false);
return;
}
@ -97,7 +97,7 @@ void Animation::Draw()
if (Ui::ListBox("Fighting style", m_FightingStyleList, m_nFightingStyle))
{
Command<Commands::GIVE_MELEE_ATTACK_TO_CHAR>(hPlayer, m_nFightingStyle + 4, 6);
CHud::SetHelpMessage("Fighting anim set", false, false, false);
SetHelpMessage("Fighting anim set", false, false, false);
}
if (Ui::ListBoxStr("Walking style", m_WalkingStyleList, m_nWalkingStyle))
{
@ -114,7 +114,7 @@ void Animation::Draw()
Command<Commands::SET_ANIM_GROUP_FOR_CHAR>(hPlayer, m_nWalkingStyle.c_str());
Command<Commands::REMOVE_ANIMATION>(m_nWalkingStyle.c_str());
}
CHud::SetHelpMessage("Walking anim set", false, false, false);
SetHelpMessage("Walking anim set", false, false, false);
}
ImGui::EndTabItem();
}
@ -189,8 +189,8 @@ void Animation::RemoveAnimation(std::string& ifp, std::string& anim, std::string
{
m_AnimData.m_Json.m_Data["Custom"].erase(anim);
m_AnimData.m_Json.WriteToDisk();
CHud::SetHelpMessage("Animation removed", false, false, false);
SetHelpMessage("Animation removed", false, false, false);
}
else
CHud::SetHelpMessage("You can only remove custom anims", false, false, false);
SetHelpMessage("You can only remove custom anims", false, false, false);
}

View File

@ -7,21 +7,29 @@
void CheatMenu::DrawWindow()
{
ImGuiIO& io = ImGui::GetIO();
static bool game_running = true;
static bool bRunning = true;
#ifdef GTASA
if (FrontEndMenuManager.m_bMenuActive)
#elif GTAVC
if (FrontendMenuManager.m_bMenuVisible)
#endif
{
if (game_running)
if (bRunning)
{
config.WriteToDisk();
game_running = false;
bRunning = false;
m_bShowMouse = false;
}
}
else
{
game_running = true;
bRunning = true;
#ifdef GTASA
if (Globals::m_bShowMenu || m_Commands::m_bShowMenu)
#elif GTAVC
if (Globals::m_bShowMenu)
#endif
{
if (Globals::m_bShowMenu)
{
@ -45,9 +53,13 @@ void CheatMenu::DrawWindow()
ImGui::End();
}
}
#ifdef GTASA
else
{
DrawShortcutsWindow();
}
#endif
}
}
DrawOverlay();
}
@ -65,10 +77,18 @@ CheatMenu::CheatMenu()
Events::processScriptsEvent += []()
{
if (Globals::m_bInit && !FrontEndMenuManager.m_bMenuActive)
if (Globals::m_bInit &&
#ifdef GTASA
!FrontEndMenuManager.m_bMenuActive
#elif GTAVC
!FrontendMenuManager.m_bMenuVisible
#endif
)
{
if (Ui::HotKeyPressed(Menu::m_HotKeys::menuOpen))
{
Globals::m_bShowMenu = !Globals::m_bShowMenu;
}
if (Ui::HotKeyPressed(Menu::m_HotKeys::commandWindow))
{
@ -176,7 +196,9 @@ void MenuThread(void* param)
}
static bool bGameInit = false;
#ifdef GTASA
Hook::ApplyMouseFix();
#endif
// Wait till the game is initialized
Events::initRwEvent += []
@ -222,6 +244,7 @@ BOOL WINAPI DllMain(HINSTANCE hDllHandle, DWORD nReason, LPVOID Reserved)
if (nReason == DLL_PROCESS_ATTACH)
{
uint gameVersion = GetGameVersion();
#ifdef GTASA
if (gameVersion == GAME_10US_HOODLUM || gameVersion == GAME_10US_COMPACT)
{
CreateThread(nullptr, NULL, (LPTHREAD_START_ROUTINE)&MenuThread, nullptr, NULL, nullptr);
@ -230,6 +253,16 @@ BOOL WINAPI DllMain(HINSTANCE hDllHandle, DWORD nReason, LPVOID Reserved)
{
MessageBox(HWND_DESKTOP, "Unknown game version. GTA SA v1.0 US is required.", "CheatMenu", MB_ICONERROR);
}
#elif GTAVC
if (gameVersion == GAME_10EN)
{
CreateThread(nullptr, NULL, (LPTHREAD_START_ROUTINE)&MenuThread, nullptr, NULL, nullptr);
}
else
{
MessageBox(HWND_DESKTOP, "Unknown game version. GTA VC v1.0 EN is required.", "CheatMenu", MB_ICONERROR);
}
#endif
}
return TRUE;

View File

@ -9,26 +9,38 @@
*/
#pragma once
#include "Animation.h"
#include "Game.h"
#include "Hook.h"
#include "Menu.h"
#include "Ped.h"
#include "Player.h"
#include "Teleport.h"
#include "Vehicle.h"
#include "Visual.h"
#include "Weapon.h"
class CheatMenu : Hook, Animation, Game, Menu, Ped, Player, Teleport, Vehicle, Visual, Weapon
#ifdef GTASA
#include "Animation.h"
#include "Game.h"
#include "Ped.h"
#include "Player.h"
#include "Vehicle.h"
#include "Visual.h"
#include "Weapon.h"
class CheatMenu : Hook, Animation, Game, Menu, Ped, Player, Teleport, Vehicle, Visual, Weapon
#elif defined(GTAVC)
class CheatMenu : Hook, Menu, Teleport
#endif
{
private:
#ifdef GTASA
inline static CallbackTable header
{
{"Teleport", &Teleport::Draw}, {"Player", &Player::Draw}, {"Ped", &Ped::Draw},
{"Animation", &Animation::Draw}, {"Vehicle", &Vehicle::Draw}, {"Weapon", &Weapon::Draw},
{"Game", &Game::Draw}, {"Visual", &Visual::Draw}, {"Menu", &Menu::Draw}
};
#elif GTAVC
inline static CallbackTable header
{
{"Teleport", &Teleport::Draw}, {"Menu", &Menu::Draw}
};
#endif
static void ApplyStyle();
static void DrawWindow();

View File

@ -62,7 +62,7 @@ Game::Game()
if (Ui::HotKeyPressed(Menu::m_HotKeys::quickSceenShot))
{
Command<Commands::TAKE_PHOTO>();
CHud::SetHelpMessage("Screenshot taken", false, false, false);
SetHelpMessage("Screenshot taken", false, false, false);
}
}
@ -133,7 +133,7 @@ Game::Game()
if (m_RandomCheats::m_EnabledCheats[i][1] == "true")
{
((void(*)(int))0x00438370)(id); // cheatEnableLegimate(int CheatID)
CHud::SetHelpMessage(m_RandomCheats::m_EnabledCheats[i][0].c_str(), false, false, false);
SetHelpMessage(m_RandomCheats::m_EnabledCheats[i][0].c_str(), false, false, false);
m_RandomCheats::m_nTimer = timer;
}
break;
@ -174,7 +174,7 @@ void SetPlayerMission(std::string& rootkey, std::string& name, std::string& id)
player->SetWantedLevel(0);
Command<Commands::LOAD_AND_LAUNCH_MISSION_INTERNAL>(std::stoi(id));
}
else CHud::SetHelpMessage("Can't start mission now", false, false, false);
else SetHelpMessage("Can't start mission now", false, false, false);
}
void Game::FreeCam()
@ -239,7 +239,7 @@ void Game::FreeCam()
// disble them again cause they get enabled
CHud::bScriptDontDisplayRadar = true;
CHud::m_Wants_To_Draw_Hud = false;
CHud::SetHelpMessage("Player telported", false, false, false);
SetHelpMessage("Player telported", false, false, false);
}
if (KeyPressed(VK_RCONTROL))

View File

@ -9,7 +9,9 @@ LRESULT Hook::WndProc(const HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
if (ImGui::GetIO().WantTextInput)
{
#ifdef GTASA
Call<0x53F1E0>(); // CPad::ClearKeyboardHistory
#endif
return 1;
}
@ -111,8 +113,10 @@ void Hook::RenderFrame(void* ptr)
ImGui_ImplWin32_Init(RsGlobal.ps->window);
#ifdef GTASA
// shift trigger fix
patch::Nop(0x00531155, 5);
#endif
if (Globals::renderer == Render_DirectX9)
{
@ -161,10 +165,26 @@ void Hook::ShowMouse(bool state)
ImGui::GetIO().MouseDrawCursor = state;
#ifdef GTASA
Hook::ApplyMouseFix(); // Reapply the patches
#elif GTAVC
if (m_bShowMouse)
{
patch::SetUChar(0x6020A0, 0xC3); // psSetMousePos
patch::Nop(0x4AB6CA, 5); // don't call CPad::UpdateMouse()
}
else
{
patch::SetUChar(0x6020A0, 0x53);
patch::SetRaw(0x4AB6CA, (char*)"\xE8\x51\x21\x00\x00", 5);
}
#endif
CPad::NewMouseControllerState.X = 0;
CPad::NewMouseControllerState.Y = 0;
CPad::ClearMouseHistory();
CPad::UpdatePads();
m_bMouseVisibility = m_bShowMouse;
Hook::ApplyMouseFix(); // Reapply the patches
}
}
@ -199,6 +219,7 @@ Hook::~Hook()
kiero::shutdown();
}
#ifdef GTASA
struct Mouse
{
unsigned int x, y;
@ -280,3 +301,5 @@ void Hook::ApplyMouseFix()
patch::SetChar(0x746A08, 32); // diMouseOffset
patch::SetChar(0x746A58, 32); // diDeviceoffset
}
#endif

View File

@ -26,7 +26,10 @@ private:
public:
inline static bool m_bShowMouse = false;
inline static std::function<void()> windowCallback = nullptr;
#ifdef GTASA
static void ApplyMouseFix();
#endif
Hook();
~Hook();

View File

@ -1,13 +1,16 @@
#include "pch.h"
#include "MenuInfo.h"
#include "Menu.h"
#include "Teleport.h"
#include "Weapon.h"
#include "Vehicle.h"
#include "Ui.h"
#include "Util.h"
#include "Updater.h"
#ifdef GTASA
#include "Teleport.h"
#include "Weapon.h"
#include "Vehicle.h"
#endif
Menu::Menu()
{
// TODO: use structs
@ -142,7 +145,15 @@ void Menu::DrawOverlay()
GlobalMemoryStatusEx(&memInfo);
int mUsedRam = static_cast<int>((memInfo.ullTotalPhys - memInfo.ullAvailPhys) * 1e-6);
m_Overlay::fMemUsage = 100.0f * (static_cast<float>(mUsedRam) / static_cast<float>(m_Overlay::mTotalRam));
m_Overlay::mFPS = static_cast<size_t>(CTimer::game_FPS);
m_Overlay::mFPS = static_cast<size_t>
(
#ifdef GTASA
CTimer::game_FPS
#elif GTAVC
io.Framerate
#endif
);
m_Overlay::mLastInterval = game_ms;
}
@ -232,7 +243,7 @@ void Menu::ProcessCommands()
}
catch (...)
{
CHud::SetHelpMessage("Invalid value", false, false, false);
SetHelpMessage("Invalid value", false, false, false);
}
}
@ -249,10 +260,11 @@ void Menu::ProcessCommands()
}
catch (...)
{
CHud::SetHelpMessage("Invalid value", false, false, false);
SetHelpMessage("Invalid value", false, false, false);
}
}
#ifdef GTASA
if (command == "tp")
{
try
@ -273,7 +285,7 @@ void Menu::ProcessCommands()
}
catch (...)
{
CHud::SetHelpMessage("Invalid location", false, false, false);
SetHelpMessage("Invalid location", false, false, false);
}
}
@ -286,7 +298,7 @@ void Menu::ProcessCommands()
{
std::string weapon = "-1";
Weapon::GiveWeaponToPlayer(weapon);
CHud::SetHelpMessage("Weapon given", false, false, false);
SetHelpMessage("Weapon given", false, false, false);
}
else
{
@ -297,10 +309,10 @@ void Menu::ProcessCommands()
if (wep_name != "" && pweaponinfo->m_nModelId1 != -1)
{
Weapon::GiveWeaponToPlayer(weapon_name);
CHud::SetHelpMessage("Weapon given", false, false, false);
SetHelpMessage("Weapon given", false, false, false);
}
else
CHud::SetHelpMessage("Invalid command", false, false, false);
SetHelpMessage("Invalid command", false, false, false);
}
return;
@ -315,11 +327,12 @@ void Menu::ProcessCommands()
{
std::string smodel = std::to_string(model);
Vehicle::SpawnVehicle(smodel);
CHud::SetHelpMessage("Vehicle spawned", false, false, false);
SetHelpMessage("Vehicle spawned", false, false, false);
}
else
CHud::SetHelpMessage("Invalid command", false, false, false);
SetHelpMessage("Invalid command", false, false, false);
}
#endif
}
void Menu::Draw()

View File

@ -31,7 +31,7 @@ void Ped::SpawnPed(std::string& model)
{
if (m_SpawnPed::m_List.size() == SPAWN_PED_LIMIT)
{
CHud::SetHelpMessage("Max limit reached", false, false, false);
SetHelpMessage("Max limit reached", false, false, false);
return;
}

View File

@ -120,7 +120,7 @@ Player::Player()
{
if (m_bGodMode)
{
CHud::SetHelpMessage("God mode disabled", false, false, false);
SetHelpMessage("God mode disabled", false, false, false);
patch::Set<bool>(0x96916D, m_bGodMode, false);
player->m_nPhysicalFlags.bBulletProof = false;
@ -132,7 +132,7 @@ Player::Player()
}
else
{
CHud::SetHelpMessage("God mode enabled", false, false, false);
SetHelpMessage("God mode enabled", false, false, false);
m_bGodMode = true;
}
}
@ -223,7 +223,7 @@ void Player::Draw()
std::string text = std::to_string(pos.x) + ", " + std::to_string(pos.y) + ", " + std::to_string(pos.z);
ImGui::SetClipboardText(text.c_str());
CHud::SetHelpMessage("Coordinates copied", false, false, false);
SetHelpMessage("Coordinates copied", false, false, false);
}
ImGui::SameLine();
if (ImGui::Button("Suicide", ImVec2(Ui::GetSize(2))))

View File

@ -4,6 +4,7 @@
#include "Ui.h"
#include "Util.h"
#ifdef GTASA
// FlA
tRadarTrace* CRadar::ms_RadarTrace = reinterpret_cast<tRadarTrace*>(patch::GetPointer(0x5838B0 + 2));
@ -36,6 +37,7 @@ void Teleport::FetchRadarSpriteData()
*/
}
}
#endif
Teleport::Teleport()
{
@ -48,15 +50,20 @@ Teleport::Teleport()
{
CPlayerPed* player = FindPlayerPed();
CEntity* player_entity = FindPlayerEntity(-1);
#ifdef GTASA
CEntity* player_entity = FindPlayerEntity();
m_Teleport::m_fPos.z = CWorld::FindGroundZFor3DCoord(m_Teleport::m_fPos.x, m_Teleport::m_fPos.y,
m_Teleport::m_fPos.z + 100.0f, nullptr, &player_entity) + 1.0f;
#elif GTAVC
m_Teleport::m_fPos.z = CWorld::FindGroundZFor3DCoord(m_Teleport::m_fPos.x, m_Teleport::m_fPos.y,
m_Teleport::m_fPos.z + 100.0f, nullptr) + 1.0f;
#endif
CVehicle* pVeh = player->m_pVehicle;
if (pVeh && player->m_nPedFlags.bInVehicle)
pVeh->Teleport(m_Teleport::m_fPos, false);
if (pVeh && BY_GAME(player->m_nPedFlags.bInVehicle, player->m_pVehicle))
BY_GAME(pVeh->Teleport(m_Teleport::m_fPos, false), pVeh->Teleport(m_Teleport::m_fPos));
else
player->Teleport(m_Teleport::m_fPos, false);
BY_GAME(player->Teleport(m_Teleport::m_fPos, false), player->Teleport(m_Teleport::m_fPos));
m_Teleport::m_bEnabled = false;
Command<Commands::FREEZE_CHAR_POSITION_AND_DONT_LOAD_COLLISION>(CPools::GetPedRef(player), false);
@ -81,13 +88,14 @@ void Teleport::TeleportPlayer(bool get_marker, CVector pos, short interior_id)
CPlayerPed* pPlayer = FindPlayerPed();
CVehicle* pVeh = pPlayer->m_pVehicle;
#ifdef GTASA
if (get_marker)
{
tRadarTrace targetBlip = CRadar::ms_RadarTrace[LOWORD(FrontEndMenuManager.m_nTargetBlipIndex)];
if (targetBlip.m_nBlipSprite != RADAR_SPRITE_WAYPOINT)
{
CHud::SetHelpMessage("Target blip not found. You need to place it on the map first.", false, false, false);
SetHelpMessage("Target blip not found. You need to place it on the map first.", false, false, false);
return;
}
CEntity* pPlayerEntity = FindPlayerEntity(-1);
@ -100,11 +108,13 @@ void Teleport::TeleportPlayer(bool get_marker, CVector pos, short interior_id)
TheCamera.Fade(0, 0);
Command<Commands::FREEZE_CHAR_POSITION_AND_DONT_LOAD_COLLISION>(CPools::GetPedRef(pPlayer), true);
}
#endif
CStreaming::LoadScene(&pos);
CStreaming::LoadSceneCollision(&pos);
CStreaming::LoadAllRequestedModels(false);
#ifdef GTASA
if (pVeh && pPlayer->m_nPedFlags.bInVehicle)
{
pVeh->Teleport(pos, false);
@ -114,14 +124,25 @@ void Teleport::TeleportPlayer(bool get_marker, CVector pos, short interior_id)
else if (pVeh->m_nVehicleClass != VEHICLE_BOAT)
reinterpret_cast<CAutomobile*>(pVeh)->PlaceOnRoadProperly();
pVeh->m_nAreaCode = interior_id;
BY_GAME(pVeh->m_nAreaCode, pVeh->m_nInterior) = interior_id;
}
else
{
pPlayer->Teleport(pos, false);
}
#elif GTAVC
if (pVeh && pPlayer->m_pVehicle)
{
BY_GAME(pVeh->m_nAreaCode, pVeh->m_nInterior) = interior_id;
pVeh->Teleport(pos);
}
else
{
pPlayer->Teleport(pos);
}
#endif
pPlayer->m_nAreaCode = interior_id;
BY_GAME(pPlayer->m_nAreaCode, pPlayer->m_nInterior) = interior_id;
Command<Commands::SET_AREA_VISIBLE>(interior_id);
}
@ -150,7 +171,7 @@ void Teleport::TeleportToLocation(std::string& rootkey, std::string& bLocName, s
}
catch (...)
{
CHud::SetHelpMessage("Invalid location", false, false, false);
SetHelpMessage("Invalid location", false, false, false);
}
}
@ -159,10 +180,10 @@ void Teleport::RemoveTeleportEntry(std::string& category, std::string& key, std:
if (category == "Custom")
{
tp_data.m_Json.m_Data["Custom"].erase(key);
CHud::SetHelpMessage("Location removed", false, false, false);
SetHelpMessage("Location removed", false, false, false);
tp_data.m_Json.WriteToDisk();
}
else CHud::SetHelpMessage("You can only remove custom location", false, false, false);
else SetHelpMessage("You can only remove custom location", false, false, false);
}
void Teleport::Draw()
@ -178,13 +199,14 @@ void Teleport::Draw()
ImGui::Columns(2, nullptr, false);
ImGui::Checkbox("Insert coordinates", &m_bInsertCoord);
ImGui::NextColumn();
#ifdef GTASA
if (Ui::CheckboxWithHint("Quick teleport", &m_bQuickTeleport,
(std::string("Teleport to the location of your radar\ntarget blip using ")
+ Ui::GetHotKeyNameString(Menu::m_HotKeys::quickTeleport)).c_str()))
{
config.SetValue("quick_teleport", m_bQuickTeleport);
}
#endif
ImGui::Columns(1);
ImGui::Spacing();
@ -201,7 +223,7 @@ void Teleport::Draw()
ImGui::Spacing();
if (ImGui::Button("Teleport to Coord", Ui::GetSize(2)))
if (ImGui::Button("Teleport to coord", Ui::GetSize(2)))
{
std::stringstream ss(m_nInputBuffer);
std::string temp;
@ -222,13 +244,21 @@ void Teleport::Draw()
}
catch (...)
{
CHud::SetHelpMessage("Invalid coordinate", false, false, false);
SetHelpMessage("Invalid coordinate", false, false, false);
}
}
ImGui::SameLine();
#ifdef GTASA
if (ImGui::Button("Teleport to marker", Ui::GetSize(2)))
{
TeleportPlayer(true);
}
#else
if (ImGui::Button("Teleport to map center", Ui::GetSize(2)))
{
TeleportPlayer(false, CVector(0, 0, 23));
}
#endif
ImGui::EndChild();
}
ImGui::EndTabItem();
@ -236,7 +266,10 @@ void Teleport::Draw()
if (ImGui::BeginTabItem("Search"))
{
#ifdef GTASA
FetchRadarSpriteData();
#endif
ImGui::Spacing();
Ui::DrawJSON(tp_data.m_Json, tp_data.m_Categories, tp_data.m_Selected, tp_data.m_Filter, &TeleportToLocation,
&RemoveTeleportEntry);

View File

@ -11,7 +11,11 @@ private:
inline static SSearchData tp_data{"teleport"};
inline static char m_nLocationBuffer[INPUT_BUFFER_SIZE];
inline static uint m_nQuickTeleportTimer;
#ifdef GTASA
inline static CJson m_SpriteJson = CJson("radar sprite");
#endif
struct m_Teleport
{
inline static bool m_bEnabled;
@ -20,11 +24,13 @@ private:
};
#ifdef GTASA
/*
Generates radar sprite coordinates on the fly.
Shouldn't get saved in 'teleport.json', needs to be cleared at game shutdown.
*/
static void FetchRadarSpriteData();
#endif
protected:
Teleport();

View File

@ -426,7 +426,7 @@ void Ui::DrawJSON(CJson& json, std::vector<std::string>& combo_items, std::strin
ImGui::EndChild();
}
#ifdef GTASA
void Ui::EditStat(const char* label, const int stat_id, const int min, const int def, const int max)
{
if (ImGui::CollapsingHeader(label))
@ -465,6 +465,7 @@ void Ui::EditStat(const char* label, const int stat_id, const int min, const int
ImGui::Separator();
}
}
#endif
void Ui::FilterWithHint(const char* label, ImGuiTextFilter& filter, const char* hint)
{

View File

@ -68,7 +68,10 @@ public:
static void EditReference(const char* label, T& address, int min = 0, int def = 0, int max = 100);
static void EditRadioButtonAddress(const char* label, std::vector<NamedMemory>& named_mem);
static void EditRadioButtonAddressEx(const char* label, int addr, std::vector<NamedValue>& named_val);
#ifdef GTASA
static void EditStat(const char* label, int stat_id, int min = 0, int def = 0, int max = 1000);
#endif
static void FilterWithHint(const char* label, ImGuiTextFilter& filter, const char* hint);

View File

@ -12,7 +12,7 @@ void Updater::CheckForUpdate()
if (res == E_OUTOFMEMORY || res == INET_E_DOWNLOAD_FAILURE)
{
CHud::SetHelpMessage("Failed to check for updates", false, false, false);
SetHelpMessage("Failed to check for updates", false, false, false);
return;
}
CJson verinfo = CJson("versioninfo");
@ -22,12 +22,12 @@ void Updater::CheckForUpdate()
if (m_LatestVersion > MENU_VERSION_NUMBER)
{
CHud::SetHelpMessage("Update found", false, false, false);
SetHelpMessage("Update found", false, false, false);
m_State = UPDATER_UPDATE_FOUND;
}
else
{
CHud::SetHelpMessage("No update found.", false, false, false);
SetHelpMessage("No update found.", false, false, false);
Updater::m_State = UPDATER_IDLE;
}
}

View File

@ -1,6 +1,5 @@
#include "pch.h"
#include "Util.h"
#include <CCutsceneMgr.h>
#include "psapi.h"
#include "CFileLoader.h"
@ -68,6 +67,44 @@ void* Util::GetTextureFromRaster(RwTexture *pTexture)
return (&raster->renderResource->texture);
}
std::string Util::GetLocationName(CVector* pos)
{
#ifdef GTASA
int hplayer = CPools::GetPedRef(FindPlayerPed());
int interior = 0;
Command<Commands::GET_AREA_VISIBLE>(&interior);
std::string town = "San Andreas";
int city;
Command<Commands::GET_CITY_PLAYER_IS_IN>(&hplayer, &city);
switch (city)
{
case 0:
town = "CS";
break;
case 1:
town = "LS";
break;
case 2:
town = "SF";
break;
case 3:
town = "LV";
break;
}
if (interior == 0)
return CTheZones::FindSmallestZoneForPosition(*pos, true)->GetTranslatedName() + std::string(", ") + town;
return std::string("Interior ") + std::to_string(interior) + ", " + town;
#elif GTAVC
return "Vice City";
#endif
}
#ifdef GTASA
// Thanks DKPac22
RwTexture* Util::LoadTextureFromMemory(char* data, unsigned int size)
{
@ -118,37 +155,6 @@ bool Util::IsOnCutscene()
return CCutsceneMgr::ms_running;
}
std::string Util::GetLocationName(CVector* pos)
{
int hplayer = CPools::GetPedRef(FindPlayerPed());
int interior = 0;
Command<Commands::GET_AREA_VISIBLE>(&interior);
std::string town = "San Andreas";
int city;
Command<Commands::GET_CITY_PLAYER_IS_IN>(&hplayer, &city);
switch (city)
{
case 0:
town = "CS";
break;
case 1:
town = "LS";
break;
case 2:
town = "SF";
break;
case 3:
town = "LV";
break;
}
if (interior == 0)
return CTheZones::FindSmallestZoneForPosition(*pos, true)->GetTranslatedName() + std::string(", ") + town;
return std::string("Interior ") + std::to_string(interior) + ", " + town;
}
int Util::GetLargestGangInZone()
{
int gang_id = 0, max_density = 0;
@ -212,6 +218,7 @@ CPed* Util::GetClosestPed()
}
return nullptr;
}
#endif
void Util::RainbowValues(int& r, int& g, int& b, float speed)
{

View File

@ -11,17 +11,21 @@ static HANDLE self;
class Util
{
public:
#ifdef GTASA
static void ClearCharTasksVehCheck(CPed* ped);
static CPed* GetClosestPed();
static CVehicle* GetClosestVehicle();
static int GetLargestGangInZone();
static bool IsOnCutscene();
static bool IsOnMission();
static RwTexture* LoadTextureFromMemory(char* data, unsigned int size);
#endif
static std::string GetLocationName(CVector* pos);
static bool IsOnMission();
static void RainbowValues(int& r, int& g, int& b, float speed);
static void GetCPUUsageInit();
static double GetCurrentCPUUsage();
static void* GetTextureFromRaster(RwTexture* pTexture);
static void LoadTextureDirectory(SSearchData& data, char* path, bool pass_full_name = false);
static RwTexture* LoadTextureFromMemory(char* data, unsigned int size);
};

View File

@ -39,7 +39,7 @@ Vehicle::Vehicle()
{
player->m_pVehicle->Fix();
player->m_pVehicle->m_fHealth = 1000.0f;
CHud::SetHelpMessage("Vehicle fixed", false, false, false);
SetHelpMessage("Vehicle fixed", false, false, false);
}
if (Ui::HotKeyPressed(Menu::m_HotKeys::vehEngine))
@ -47,9 +47,9 @@ Vehicle::Vehicle()
bool state = !veh->m_nVehicleFlags.bEngineBroken || veh->m_nVehicleFlags.bEngineOn;
if (state)
CHud::SetHelpMessage("Vehicle engine off", false, false, false);
SetHelpMessage("Vehicle engine off", false, false, false);
else
CHud::SetHelpMessage("Vehicle engine on", false, false, false);
SetHelpMessage("Vehicle engine on", false, false, false);
veh->m_nVehicleFlags.bEngineBroken = state;
veh->m_nVehicleFlags.bEngineOn = !state;
@ -168,7 +168,7 @@ void Vehicle::AddComponent(const std::string& component, const bool display_mess
CStreaming::SetModelIsDeletable(icomp);
if (display_message)
CHud::SetHelpMessage("Component added", false, false, false);
SetHelpMessage("Component added", false, false, false);
}
catch (...)
{
@ -188,7 +188,7 @@ void Vehicle::RemoveComponent(const std::string& component, const bool display_m
player->m_pVehicle->RemoveVehicleUpgrade(icomp);
if (display_message)
CHud::SetHelpMessage("Component removed", false, false, false);
SetHelpMessage("Component removed", false, false, false);
}
catch (...)
{
@ -221,7 +221,7 @@ int Vehicle::GetRandomTrainIdForModel(int model)
_end = 10;
break;
default:
CHud::SetHelpMessage("Invalid train model", false, false, false);
SetHelpMessage("Invalid train model", false, false, false);
return -1;
}
int id = Random(_start, _end);
@ -955,7 +955,7 @@ void Vehicle::Draw()
if (ImGui::Button("Reset color", ImVec2(Ui::GetSize())))
{
Paint::ResetNodeColor(veh, Paint::veh_nodes::selected);
CHud::SetHelpMessage("Color reset", false, false, false);
SetHelpMessage("Color reset", false, false, false);
}
ImGui::Spacing();
@ -1036,7 +1036,7 @@ void Vehicle::Draw()
if (ImGui::Button("Remove neon", ImVec2(Ui::GetSize())))
{
RemoveNeon(veh);
CHud::SetHelpMessage("Neon removed", false, false, false);
SetHelpMessage("Neon removed", false, false, false);
}
ImGui::Spacing();
@ -1092,7 +1092,7 @@ void Vehicle::Draw()
if (ImGui::Button("Reset texture", ImVec2(Ui::GetSize())))
{
Paint::ResetNodeTexture(veh, Paint::veh_nodes::selected);
CHud::SetHelpMessage("Texture reset", false, false, false);
SetHelpMessage("Texture reset", false, false, false);
}
ImGui::Spacing();
@ -1167,7 +1167,7 @@ void Vehicle::Draw()
if (ImGui::Button("Reset handling", ImVec2(Ui::GetSize(3))))
{
gHandlingDataMgr.LoadHandlingData();
CHud::SetHelpMessage("Handling reset", false, false, false);
SetHelpMessage("Handling reset", false, false, false);
}
ImGui::SameLine();
@ -1175,7 +1175,7 @@ void Vehicle::Draw()
if (ImGui::Button("Save to file", ImVec2(Ui::GetSize(3))))
{
GenerateHandlingDataFile(pHandling);
CHud::SetHelpMessage("Handling saved", false, false, false);
SetHelpMessage("Handling saved", false, false, false);
}
ImGui::SameLine();

View File

@ -351,13 +351,13 @@ void Visual::Draw()
if (ImGui::Button("Generate timecyc file", Ui::GetSize(2)))
{
GenerateTimecycFile();
CHud::SetHelpMessage("File generated", false, false, false);
SetHelpMessage("File generated", false, false, false);
}
ImGui::SameLine();
if (ImGui::Button("Reset timecyc", Ui::GetSize(2)))
{
CTimeCycle::Initialise();
CHud::SetHelpMessage("Timecyc reset", false, false, false);
SetHelpMessage("Timecyc reset", false, false, false);
}
ImGui::Spacing();

View File

@ -6,6 +6,12 @@
#define DISCORD_INVITE "https://discord.gg/ZzW7kmf"
#define GITHUB_LINK "https://github.com/user-grinch/Cheat-Menu"
#ifdef GTASA
#define BY_GAME(sa, vc) sa
#elif GTAVC
#define BY_GAME(sa, vc) vc
#endif
#include <d3d9.h>
#include <d3d11.h>
#include <d3d11Shader.h>
@ -21,20 +27,14 @@
#include "plugin.h"
#include "CBike.h"
#include "CCamera.h"
#include "CCheat.h"
#include "CClothes.h"
#include "CClock.h"
#include "CCivilianPed.h"
#include "CCutsceneMgr.h"
#include "CGangs.h"
#include "CGangWars.h"
#include "cHandlingDataMgr.h"
#include "CHud.h"
#include "CMenuManager.h"
#include "CModelInfo.h"
#include "CRadar.h"
#include "RenderWare.h"
#include "CShadows.h"
#include "CStats.h"
#include "CStreaming.h"
#include "CTheScripts.h"
@ -46,9 +46,18 @@
#include "CWorld.h"
#include "extensions/ScriptCommands.h"
#include "extensions/Screen.h"
#include "eVehicleClass.h"
#include "extensions/Paths.h"
#ifdef GTASA
#include "CCheat.h"
#include "CClothes.h"
#include "CCutsceneMgr.h"
#include "CRadar.h"
#include "CShadows.h"
#include "eVehicleClass.h"
#include "CGangWars.h"
#endif
#include "../Depend/fla/IDaccess.h"
#include "../Depend/imgui/imgui.h"
#include "../Depend/imgui/imgui_internal.h"
@ -133,3 +142,14 @@ struct SSearchData
std::string m_Selected = "All";
std::vector<std::unique_ptr<STextureStructure>> m_ImagesList;
};
// Common defines
static void SetHelpMessage(const char *message, bool b1, bool b2, bool b3)
{
#if GTAVC
CHud::SetHelpMessage(message, b1, b2);
#elif GTASA
CHud::SetHelpMessage(message, b1, b2, b3);
#endif
}

View File

@ -3,5 +3,5 @@ cd tools
premake5.exe vs2019
cd ../build
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\Tools\VsDevCmd.bat"
MsBuild CheatMenu.sln /property:Configuration=Debug
MsBuild CheatMenu.sln /property:Configuration=Debug /t:CheatMenuSA
cd ..

View File

@ -3,5 +3,5 @@ cd tools
premake5.exe vs2019
cd ../build
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\Tools\VsDevCmd.bat"
MsBuild CheatMenu.sln /property:Configuration=Release
MsBuild CheatMenu.sln /property:Configuration=Debug /t:CheatMenuVC
cd ..

7
tools/ReleaseSA.bat Normal file
View File

@ -0,0 +1,7 @@
@echo off
cd tools
premake5.exe vs2019
cd ../build
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\Tools\VsDevCmd.bat"
MsBuild CheatMenu.sln /property:Configuration=Release /t:CheatMenuSA
cd ..

7
tools/ReleaseVC.bat Normal file
View File

@ -0,0 +1,7 @@
@echo off
cd tools
premake5.exe vs2019
cd ../build
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\Tools\VsDevCmd.bat"
MsBuild CheatMenu.sln /property:Configuration=Release /t:CheatMenuVC
cd ..

View File

@ -6,6 +6,7 @@
PSDK_DIR = os.getenv("PLUGIN_SDK_DIR")
DX9SDK_DIR = os.getenv("DIRECTX9_SDK_DIR")
GTASA_DIR = "C:/Work/GTASanAndreas"
GTAVC_DIR = "F:/GTA Vice City"
if (DX9SDK_DIR == nil) then
error("DIRECTX9_SDK_DIR environment variable not set")
@ -46,7 +47,77 @@ project "Depend"
defines { "NDEBUG", "IS_PLATFORM_WIN" }
optimize "On"
project "CheatMenu"
project "CheatMenuVC"
kind "SharedLib"
targetdir (GTAVC_DIR)
targetextension ".asi"
files {
"../src/CheatMenu.h",
"../src/CheatMenu.cpp",
"../src/pch.h",
"../src/pch.cpp",
"../src/Hook.h",
"../src/Hook.cpp",
"../src/Updater.h",
"../src/Updater.cpp",
"../src/Json.h",
"../src/Json.cpp",
"../src/Teleport.h",
"../src/Teleport.cpp",
"../src/Ui.h",
"../src/Ui.cpp",
"../src/Util.h",
"../src/Util.cpp",
"../src/Menu.h",
"../src/Menu.cpp"
}
includedirs {
PSDK_DIR .. "/plugin_vc/",
PSDK_DIR .. "/plugin_vc/game_vc/",
PSDK_DIR .. "/shared/",
PSDK_DIR .. "/shared/game/"
}
libdirs (PSDK_DIR .. "/output/lib")
defines {
"NDEBUG",
"IS_PLATFORM_WIN" ,
"_CRT_SECURE_NO_WARNINGS",
"_CRT_NON_CONFORMING_SWPRINTFS",
"GTAVC",
"_DX9_SDK_INSTALLED",
"PLUGIN_SGV_10US"
}
pchheader "pch.h"
pchsource "../src/pch.cpp"
filter "configurations:Debug"
symbols "On"
links {
"Depend",
"d3d9",
"d3d11",
"XInput9_1_0",
"Pdh",
"urlmon",
"plugin_vc_d.lib"
}
filter "configurations:Release"
optimize "On"
links {
"Depend",
"d3d9",
"d3d11",
"XInput9_1_0",
"Pdh",
"urlmon",
"plugin_vc.lib"
}
project "CheatMenuSA"
kind "SharedLib"
targetdir (GTASA_DIR)
targetextension ".asi"