Finish visual tab

This commit is contained in:
Grinch_ 2021-10-25 20:03:27 +06:00
parent 26a671c4e5
commit 2a18a72b9e
47 changed files with 7444 additions and 7291 deletions

View File

@ -1,11 +0,0 @@
---
# We'll use defaults from the LLVM style, but with 4 columns indentation.
BasedOnStyle: Microsoft
IndentWidth: 4
---
Language: Cpp
# Force pointers to the type for C++.
DerivePointerAlignment: false
PointerAlignment: Right
AccessModifierOffset: -4
---

View File

@ -1,211 +1,210 @@
#include "animation.h"
#include "pch.h" #include "pch.h"
#include "animation.h"
#ifdef GTASA #ifdef GTASA
#include "ui.h" #include "ui.h"
#include "util.h" #include "util.h"
Animation::Animation() Animation::Animation()
{ {
Events::processScriptsEvent += [this] { Events::processScriptsEvent += [this]
if (m_Cutscene::m_bRunning) {
{ if (m_Cutscene::m_bRunning)
if (Command<Commands::HAS_CUTSCENE_FINISHED>()) {
{ if (Command<Commands::HAS_CUTSCENE_FINISHED>())
CPlayerPed *pPlayer = FindPlayerPed(); {
if (!pPlayer) CPlayerPed* pPlayer = FindPlayerPed();
{ if (!pPlayer)
return; {
} return;
}
pPlayer->m_nAreaCode = m_Cutscene::m_nInterior; pPlayer->m_nAreaCode = m_Cutscene::m_nInterior;
Command<Commands::SET_AREA_VISIBLE>(pPlayer->m_nAreaCode); Command<Commands::SET_AREA_VISIBLE>(pPlayer->m_nAreaCode);
m_Cutscene::m_nInterior = 0; m_Cutscene::m_nInterior = 0;
TheCamera.Fade(0, 1); TheCamera.Fade(0, 1);
} }
} }
else else
{ {
if (m_Cutscene::m_SceneName != "" && Command<Commands::HAS_CUTSCENE_LOADED>()) if (m_Cutscene::m_SceneName != "" && Command<Commands::HAS_CUTSCENE_LOADED>())
{ {
Command<Commands::START_CUTSCENE>(); Command<Commands::START_CUTSCENE>();
m_Cutscene::m_bRunning = true; m_Cutscene::m_bRunning = true;
} }
} }
}; };
} }
void Animation::PlayCutscene(std::string &rootKey, std::string &cutsceneId, std::string &interior) void Animation::PlayCutscene(std::string& rootKey, std::string& cutsceneId, std::string& interior)
{ {
if (Util::IsOnCutscene()) if (Util::IsOnCutscene())
{ {
SetHelpMessage("Another cutscene is running", false, false, false); SetHelpMessage("Another cutscene is running", false, false, false);
return; return;
} }
CPlayerPed *pPlayer = FindPlayerPed(); CPlayerPed* pPlayer = FindPlayerPed();
if (!pPlayer) if (!pPlayer)
{ {
return; return;
} }
m_Cutscene::m_SceneName = cutsceneId; m_Cutscene::m_SceneName = cutsceneId;
Command<Commands::LOAD_CUTSCENE>(cutsceneId.c_str()); Command<Commands::LOAD_CUTSCENE>(cutsceneId.c_str());
m_Cutscene::m_nInterior = pPlayer->m_nAreaCode; m_Cutscene::m_nInterior = pPlayer->m_nAreaCode;
pPlayer->m_nAreaCode = std::stoi(interior); pPlayer->m_nAreaCode = std::stoi(interior);
Command<Commands::SET_AREA_VISIBLE>(pPlayer->m_nAreaCode); Command<Commands::SET_AREA_VISIBLE>(pPlayer->m_nAreaCode);
} }
void Animation::Draw() void Animation::Draw()
{ {
if (ImGui::BeginTabBar("Animation", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll)) if (ImGui::BeginTabBar("Animation", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll))
{ {
ImGui::Spacing(); ImGui::Spacing();
CPlayerPed *pPlayer = FindPlayerPed(); CPlayerPed* pPlayer = FindPlayerPed();
int hPlayer = CPools::GetPedRef(pPlayer); int hPlayer = CPools::GetPedRef(pPlayer);
ImGui::Spacing(); ImGui::Spacing();
if (ImGui::BeginTabItem("Anims")) if (ImGui::BeginTabItem("Anims"))
{ {
ImGui::Spacing(); ImGui::Spacing();
if (ImGui::Button("Stop animation", Ui::GetSize())) if (ImGui::Button("Stop animation", Ui::GetSize()))
{ {
if (hPlayer) if (hPlayer)
{ {
Command<Commands::CLEAR_CHAR_TASKS>(hPlayer); Command<Commands::CLEAR_CHAR_TASKS>(hPlayer);
} }
} }
ImGui::Spacing(); ImGui::Spacing();
ImGui::Columns(2, nullptr, false); ImGui::Columns(2, nullptr, false);
ImGui::Checkbox("Loop", &m_Loop); ImGui::Checkbox("Loop", &m_Loop);
Ui::ShowTooltip("Keep playing the animation on repeat"); Ui::ShowTooltip("Keep playing the animation on repeat");
ImGui::NextColumn(); ImGui::NextColumn();
ImGui::Checkbox("Secondary", &m_bSecondary); ImGui::Checkbox("Secondary", &m_bSecondary);
Ui::ShowTooltip("Player can move while playing the animation"); Ui::ShowTooltip("Player can move while playing the animation");
ImGui::Columns(1); ImGui::Columns(1);
ImGui::Spacing(); ImGui::Spacing();
if (ImGui::BeginChild("Anims Child")) if (ImGui::BeginChild("Anims Child"))
{ {
ImGui::Spacing(); ImGui::Spacing();
Ui::DrawJSON(m_AnimData, PlayAnimation, RemoveAnimation); Ui::DrawJSON(m_AnimData, PlayAnimation, RemoveAnimation);
ImGui::EndChild(); ImGui::EndChild();
} }
ImGui::EndTabItem(); ImGui::EndTabItem();
} }
if (ImGui::BeginTabItem("Misc")) if (ImGui::BeginTabItem("Misc"))
{ {
ImGui::Spacing(); ImGui::Spacing();
if (Ui::ListBox("Fighting style", m_FightingStyleList, m_nFightingStyle)) if (Ui::ListBox("Fighting style", m_FightingStyleList, m_nFightingStyle))
{ {
Command<Commands::GIVE_MELEE_ATTACK_TO_CHAR>(hPlayer, m_nFightingStyle + 4, 6); Command<Commands::GIVE_MELEE_ATTACK_TO_CHAR>(hPlayer, m_nFightingStyle + 4, 6);
SetHelpMessage("Fighting anim set", false, false, false); SetHelpMessage("Fighting anim set", false, false, false);
} }
if (Ui::ListBoxStr("Walking style", m_WalkingStyleList, m_nWalkingStyle)) if (Ui::ListBoxStr("Walking style", m_WalkingStyleList, m_nWalkingStyle))
{ {
if (m_nWalkingStyle == "default") if (m_nWalkingStyle == "default")
{ {
patch::Set<DWORD>(0x609A4E, 0x4D48689); patch::Set<DWORD>(0x609A4E, 0x4D48689);
patch::Set<WORD>(0x609A52, 0); patch::Set<WORD>(0x609A52, 0);
} }
else else
{ {
patch::Nop(0x609A4E, 6); patch::Nop(0x609A4E, 6);
Command<Commands::REQUEST_ANIMATION>(m_nWalkingStyle.c_str()); Command<Commands::REQUEST_ANIMATION>(m_nWalkingStyle.c_str());
Command<Commands::LOAD_ALL_MODELS_NOW>(); Command<Commands::LOAD_ALL_MODELS_NOW>();
Command<Commands::SET_ANIM_GROUP_FOR_CHAR>(hPlayer, m_nWalkingStyle.c_str()); Command<Commands::SET_ANIM_GROUP_FOR_CHAR>(hPlayer, m_nWalkingStyle.c_str());
Command<Commands::REMOVE_ANIMATION>(m_nWalkingStyle.c_str()); Command<Commands::REMOVE_ANIMATION>(m_nWalkingStyle.c_str());
} }
SetHelpMessage("Walking anim set", false, false, false); SetHelpMessage("Walking anim set", false, false, false);
} }
ImGui::EndTabItem(); ImGui::EndTabItem();
} }
if (ImGui::BeginTabItem("Custom")) if (ImGui::BeginTabItem("Custom"))
{ {
ImGui::InputTextWithHint("IFP name", "ped", m_nIfpBuffer, INPUT_BUFFER_SIZE); ImGui::InputTextWithHint("IFP name", "ped", m_nIfpBuffer, INPUT_BUFFER_SIZE);
ImGui::InputTextWithHint("Anim name", "cower", m_nAnimBuffer, INPUT_BUFFER_SIZE); ImGui::InputTextWithHint("Anim name", "cower", m_nAnimBuffer, INPUT_BUFFER_SIZE);
ImGui::Spacing(); ImGui::Spacing();
if (ImGui::Button("Add animation", Ui::GetSize())) if (ImGui::Button("Add animation", Ui::GetSize()))
{ {
m_AnimData.m_pJson->m_Data["Custom"][m_nAnimBuffer] = ("0, " + std::string(m_nIfpBuffer)); m_AnimData.m_pJson->m_Data["Custom"][m_nAnimBuffer] = ("0, " + std::string(m_nIfpBuffer));
m_AnimData.m_pJson->WriteToDisk(); m_AnimData.m_pJson->WriteToDisk();
} }
ImGui::EndTabItem(); ImGui::EndTabItem();
} }
if (ImGui::BeginTabItem("Cutscene")) if (ImGui::BeginTabItem("Cutscene"))
{ {
ImGui::Spacing(); ImGui::Spacing();
if (ImGui::Button("Stop cutscene", Ui::GetSize())) if (ImGui::Button("Stop cutscene", Ui::GetSize()))
{ {
if (m_Cutscene::m_bRunning) if (m_Cutscene::m_bRunning)
{ {
Command<Commands::CLEAR_CUTSCENE>(); Command<Commands::CLEAR_CUTSCENE>();
m_Cutscene::m_bRunning = false; m_Cutscene::m_bRunning = false;
m_Cutscene::m_SceneName = ""; m_Cutscene::m_SceneName = "";
CPlayerPed *player = FindPlayerPed(); CPlayerPed* player = FindPlayerPed();
player->m_nAreaCode = m_Cutscene::m_nInterior; player->m_nAreaCode = m_Cutscene::m_nInterior;
Command<Commands::SET_AREA_VISIBLE>(player->m_nAreaCode); Command<Commands::SET_AREA_VISIBLE>(player->m_nAreaCode);
m_Cutscene::m_nInterior = 0; m_Cutscene::m_nInterior = 0;
TheCamera.Fade(0, 1); TheCamera.Fade(0, 1);
} }
} }
ImGui::Spacing(); ImGui::Spacing();
if (ImGui::BeginChild("Cutscene Child")) if (ImGui::BeginChild("Cutscene Child"))
{ {
ImGui::Spacing(); ImGui::Spacing();
Ui::DrawJSON(m_Cutscene::m_Data, PlayCutscene, nullptr); Ui::DrawJSON(m_Cutscene::m_Data, PlayCutscene, nullptr);
ImGui::EndChild(); ImGui::EndChild();
} }
ImGui::EndTabItem(); ImGui::EndTabItem();
} }
ImGui::EndTabBar(); ImGui::EndTabBar();
} }
} }
void Animation::PlayAnimation(std::string &ifp, std::string &anim, std::string &ifpRepeat) void Animation::PlayAnimation(std::string& ifp, std::string& anim, std::string& ifpRepeat)
{ {
int hplayer = CPools::GetPedRef(FindPlayerPed()); int hplayer = CPools::GetPedRef(FindPlayerPed());
if (ifp != "PED") if (ifp != "PED")
{ {
Command<Commands::REQUEST_ANIMATION>(ifp.c_str()); Command<Commands::REQUEST_ANIMATION>(ifp.c_str());
Command<Commands::LOAD_ALL_MODELS_NOW>(); Command<Commands::LOAD_ALL_MODELS_NOW>();
} }
Command<Commands::CLEAR_CHAR_TASKS>(hplayer); Command<Commands::CLEAR_CHAR_TASKS>(hplayer);
if (m_bSecondary) if (m_bSecondary)
{ {
Command<Commands::TASK_PLAY_ANIM_SECONDARY>(hplayer, anim.c_str(), ifp.c_str(), 4.0, m_Loop, 0, 0, 0, -1); Command<Commands::TASK_PLAY_ANIM_SECONDARY>(hplayer, anim.c_str(), ifp.c_str(), 4.0, m_Loop, 0, 0, 0, -1);
} }
else else
{ {
Command<Commands::TASK_PLAY_ANIM>(hplayer, anim.c_str(), ifp.c_str(), 4.0, m_Loop, 0, 0, 0, -1); Command<Commands::TASK_PLAY_ANIM>(hplayer, anim.c_str(), ifp.c_str(), 4.0, m_Loop, 0, 0, 0, -1);
} }
if (ifp != "PED") if (ifp != "PED")
{ {
Command<Commands::REMOVE_ANIMATION>(ifp.c_str()); Command<Commands::REMOVE_ANIMATION>(ifp.c_str());
} }
} }
void Animation::RemoveAnimation(std::string &ifp, std::string &anim, std::string &ifpRepeat) void Animation::RemoveAnimation(std::string& ifp, std::string& anim, std::string& ifpRepeat)
{ {
if (ifp == "Custom") if (ifp == "Custom")
{ {
m_AnimData.m_pJson->m_Data["Custom"].erase(anim); m_AnimData.m_pJson->m_Data["Custom"].erase(anim);
m_AnimData.m_pJson->WriteToDisk(); m_AnimData.m_pJson->WriteToDisk();
SetHelpMessage("Animation removed", false, false, false); SetHelpMessage("Animation removed", false, false, false);
} }
else else
{ {
SetHelpMessage("You can only remove custom anims", false, false, false); SetHelpMessage("You can only remove custom anims", false, false, false);
} }
} }
#endif #endif

View File

@ -5,44 +5,45 @@
class Animation class Animation
{ {
private: private:
// Animation player
static inline ResourceStore m_AnimData{"animation", eResourceType::TYPE_TEXT};
static inline char m_nAnimBuffer[INPUT_BUFFER_SIZE];
static inline char m_nIfpBuffer[INPUT_BUFFER_SIZE];
static inline bool m_Loop; // loop animation
static inline bool m_bSecondary; // play animation as secondary
// Cutscene player // Animation player
struct m_Cutscene static inline ResourceStore m_AnimData{ "animation", eResourceType::TYPE_TEXT };
{ static inline char m_nAnimBuffer[INPUT_BUFFER_SIZE];
static inline ResourceStore m_Data{"cutscene", eResourceType::TYPE_TEXT}; static inline char m_nIfpBuffer[INPUT_BUFFER_SIZE];
static inline std::string m_SceneName; static inline bool m_Loop; // loop animation
static inline int m_nInterior; // player interior backup static inline bool m_bSecondary; // play animation as secondary
static inline bool m_bRunning;
};
static inline int m_nFightingStyle; // Cutscene player
static inline std::string m_nWalkingStyle = "default"; struct m_Cutscene
static inline std::vector<std::string> m_FightingStyleList = {"Default", "Boxing", "Kung fu", "Kick Boxing", {
"Punch Kick"}; static inline ResourceStore m_Data{ "cutscene", eResourceType::TYPE_TEXT };
static inline std::vector<std::string> m_WalkingStyleList = { static inline std::string m_SceneName;
"default", "man", "shuffle", "oldman", "gang1", "gang2", "oldfatman", "fatman", static inline int m_nInterior; // player interior backup
"jogger", "drunkman", "blindman", "swat", "woman", "shopping", "busywoman", "sexywoman", static inline bool m_bRunning;
"pro", "oldwoman", "fatwoman", "jogwoman", "oldfatwoman", "skate"}; };
static inline int m_nFightingStyle;
static inline std::string m_nWalkingStyle = "default";
static inline std::vector<std::string> m_FightingStyleList =
{ "Default", "Boxing", "Kung fu", "Kick Boxing", "Punch Kick" };
static inline std::vector<std::string> m_WalkingStyleList =
{
"default", "man", "shuffle", "oldman", "gang1", "gang2", "oldfatman",
"fatman", "jogger", "drunkman", "blindman", "swat", "woman", "shopping", "busywoman",
"sexywoman", "pro", "oldwoman", "fatwoman", "jogwoman", "oldfatwoman", "skate"
};
protected: protected:
Animation(); Animation();
public: public:
static void Draw(); static void Draw();
static void PlayAnimation(std::string &rootKey, std::string &anim, std::string &ifp); static void PlayAnimation(std::string& rootKey, std::string& anim, std::string& ifp);
static void PlayCutscene(std::string &rootKey, std::string &cutsceneId, std::string &interior); static void PlayCutscene(std::string& rootKey, std::string& cutsceneId, std::string& interior);
static void RemoveAnimation(std::string &rootKey, std::string &anim, std::string &ifp); static void RemoveAnimation(std::string& rootKey, std::string& anim, std::string& ifp);
}; };
#else #else
// Dummy Class for VC & III // Dummy Class for VC & III
class Animation class Animation{};
{
};
#endif #endif

View File

@ -1,184 +1,183 @@
#include "pch.h"
#include "cheatMenu.h" #include "cheatMenu.h"
#include "menuinfo.h" #include "menuinfo.h"
#include "pch.h"
#include "ui.h" #include "ui.h"
#include "updater.h" #include "updater.h"
void CheatMenu::DrawWindow() void CheatMenu::DrawWindow()
{ {
ImGuiIO &io = ImGui::GetIO(); ImGuiIO& io = ImGui::GetIO();
static bool bRunning = true; static bool bRunning = true;
if (BY_GAME(FrontEndMenuManager.m_bMenuActive, FrontendMenuManager.m_bMenuVisible, if (BY_GAME(FrontEndMenuManager.m_bMenuActive, FrontendMenuManager.m_bMenuVisible, FrontEndMenuManager.m_bMenuActive))
FrontEndMenuManager.m_bMenuActive)) {
{ if (bRunning)
if (bRunning) {
{ gConfig.WriteToDisk();
gConfig.WriteToDisk(); bRunning = false;
bRunning = false; m_bShowMouse = false;
m_bShowMouse = false; }
} }
} else
else {
{ bRunning = true;
bRunning = true; if (m_bShowMenu || BY_GAME(m_Commands::m_bShowMenu, true, true))
if (m_bShowMenu || BY_GAME(m_Commands::m_bShowMenu, true, true)) {
{ if (m_bShowMenu)
if (m_bShowMenu) {
{ static ImVec2 fScreenSize = ImVec2(-1, -1);
static ImVec2 fScreenSize = ImVec2(-1, -1); ImVec2 size(screen::GetScreenWidth(), screen::GetScreenHeight());
ImVec2 size(screen::GetScreenWidth(), screen::GetScreenHeight());
if (fScreenSize.x != -1 && fScreenSize.y != -1)
{
m_fMenuSize.x += (size.x - fScreenSize.x) / 4.0f;
m_fMenuSize.y += (size.y - fScreenSize.y) / 1.2f;
}
ImGui::SetNextWindowSize(m_fMenuSize);
if (fScreenSize.x != -1 && fScreenSize.y != -1) if (ImGui::Begin(MENU_TITLE, &m_bShowMenu, ImGuiWindowFlags_NoCollapse))
{ {
m_fMenuSize.x += (size.x - fScreenSize.x) / 4.0f; ImGui::PushStyleVar(ImGuiStyleVar_WindowMinSize, ImVec2(250, 350));
m_fMenuSize.y += (size.y - fScreenSize.y) / 1.2f; ImGui::PushStyleVar(ImGuiStyleVar_FramePadding,
} ImVec2(ImGui::GetWindowWidth() / 85, ImGui::GetWindowHeight() / 200));
ImGui::SetNextWindowSize(m_fMenuSize);
if (ImGui::Begin(MENU_TITLE, &m_bShowMenu, ImGuiWindowFlags_NoCollapse)) if (Updater::m_State == UPDATER_UPDATE_FOUND)
{ Updater::ShowUpdateScreen();
ImGui::PushStyleVar(ImGuiStyleVar_WindowMinSize, ImVec2(250, 350)); else
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, Ui::DrawHeaders(header);
ImVec2(ImGui::GetWindowWidth() / 85, ImGui::GetWindowHeight() / 200));
if (Updater::m_State == UPDATER_UPDATE_FOUND) m_fMenuSize = ImGui::GetWindowSize();
Updater::ShowUpdateScreen(); gConfig.SetValue("window.sizeX", m_fMenuSize.x);
else gConfig.SetValue("window.sizeY", m_fMenuSize.y);
Ui::DrawHeaders(header);
m_fMenuSize = ImGui::GetWindowSize(); ImGui::PopStyleVar(2);
gConfig.SetValue("window.sizeX", m_fMenuSize.x); ImGui::End();
gConfig.SetValue("window.sizeY", m_fMenuSize.y); }
}
ImGui::PopStyleVar(2);
ImGui::End();
}
}
#ifdef GTASA #ifdef GTASA
else else
{ {
DrawShortcutsWindow(); DrawShortcutsWindow();
} }
#endif #endif
} }
} }
DrawOverlay(); DrawOverlay();
} }
CheatMenu::CheatMenu() CheatMenu::CheatMenu()
{ {
ApplyStyle(); ApplyStyle();
windowCallback = std::bind(&DrawWindow); windowCallback = std::bind(&DrawWindow);
// Load menu settings // Load menu settings
Ui::m_HeaderId = gConfig.GetValue("window.id", std::string("")); Ui::m_HeaderId = gConfig.GetValue("window.id", std::string(""));
m_fMenuSize.x = gConfig.GetValue("window.sizeX", screen::GetScreenWidth() / 4.0f); m_fMenuSize.x = gConfig.GetValue("window.sizeX", screen::GetScreenWidth() / 4.0f);
m_fMenuSize.y = gConfig.GetValue("window.sizeY", screen::GetScreenHeight() / 1.2f); m_fMenuSize.y = gConfig.GetValue("window.sizeY", screen::GetScreenHeight() / 1.2f);
srand(CTimer::m_snTimeInMilliseconds); srand(CTimer::m_snTimeInMilliseconds);
Events::processScriptsEvent += []() { Events::processScriptsEvent += []()
if (!BY_GAME(FrontEndMenuManager.m_bMenuActive, FrontendMenuManager.m_bMenuVisible, {
FrontEndMenuManager.m_bMenuActive)) if (!BY_GAME(FrontEndMenuManager.m_bMenuActive, FrontendMenuManager.m_bMenuVisible, FrontEndMenuManager.m_bMenuActive))
{ {
if (menuOpen.Pressed()) if (menuOpen.Pressed())
{ {
m_bShowMenu = !m_bShowMenu; m_bShowMenu = !m_bShowMenu;
} }
if (commandWindow.Pressed()) if (commandWindow.Pressed())
{ {
if (m_Commands::m_bShowMenu) if (m_Commands::m_bShowMenu)
{ {
ProcessCommands(); ProcessCommands();
strcpy(m_Commands::m_nInputBuffer, ""); strcpy(m_Commands::m_nInputBuffer, "");
} }
m_Commands::m_bShowMenu = !m_Commands::m_bShowMenu; m_Commands::m_bShowMenu = !m_Commands::m_bShowMenu;
} }
if (m_bShowMouse != m_bShowMenu) if (m_bShowMouse != m_bShowMenu)
{ {
if (m_bShowMouse) // Only write when the menu closes if (m_bShowMouse) // Only write when the menu closes
{ {
gConfig.WriteToDisk(); gConfig.WriteToDisk();
} }
m_bShowMouse = m_bShowMenu; m_bShowMouse = m_bShowMenu;
} }
} }
}; };
} }
void CheatMenu::ApplyStyle() void CheatMenu::ApplyStyle()
{ {
ImGuiStyle *style = &ImGui::GetStyle(); ImGuiStyle* style = &ImGui::GetStyle();
ImVec4 *colors = style->Colors; ImVec4* colors = style->Colors;
style->WindowRounding = 1; style->WindowRounding = 1;
style->ScrollbarRounding = 1; style->ScrollbarRounding = 1;
style->GrabRounding = 1; style->GrabRounding = 1;
style->WindowRounding = 1; style->WindowRounding = 1;
style->ChildRounding = 1; style->ChildRounding = 1;
style->ScrollbarRounding = 1; style->ScrollbarRounding = 1;
style->GrabRounding = 1; style->GrabRounding = 1;
style->FrameRounding = 0; style->FrameRounding = 0;
style->TabRounding = 1.0; style->TabRounding = 1.0;
style->AntiAliasedLines = true; style->AntiAliasedLines = true;
style->AntiAliasedFill = true; style->AntiAliasedFill = true;
style->Alpha = 1; style->Alpha = 1;
style->FrameBorderSize = 0; style->FrameBorderSize = 0;
style->ChildBorderSize = 0; style->ChildBorderSize = 0;
style->TabBorderSize = 0; style->TabBorderSize = 0;
style->WindowBorderSize = 0; style->WindowBorderSize = 0;
style->PopupBorderSize = 0; style->PopupBorderSize = 0;
colors[ImGuiCol_Text] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f); colors[ImGuiCol_Text] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f);
colors[ImGuiCol_TextDisabled] = ImVec4(0.50f, 0.50f, 0.50f, 1.00f); colors[ImGuiCol_TextDisabled] = ImVec4(0.50f, 0.50f, 0.50f, 1.00f);
colors[ImGuiCol_WindowBg] = ImVec4(0.06f, 0.06f, 0.06f, 0.94f); colors[ImGuiCol_WindowBg] = ImVec4(0.06f, 0.06f, 0.06f, 0.94f);
colors[ImGuiCol_ChildBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); colors[ImGuiCol_ChildBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
colors[ImGuiCol_PopupBg] = ImVec4(0.08f, 0.08f, 0.08f, 0.94f); colors[ImGuiCol_PopupBg] = ImVec4(0.08f, 0.08f, 0.08f, 0.94f);
colors[ImGuiCol_Border] = ImVec4(0.43f, 0.43f, 0.50f, 0.50f); colors[ImGuiCol_Border] = ImVec4(0.43f, 0.43f, 0.50f, 0.50f);
colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
colors[ImGuiCol_FrameBg] = ImVec4(0.16f, 0.29f, 0.48f, 0.54f); colors[ImGuiCol_FrameBg] = ImVec4(0.16f, 0.29f, 0.48f, 0.54f);
colors[ImGuiCol_FrameBgHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.40f); colors[ImGuiCol_FrameBgHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.40f);
colors[ImGuiCol_FrameBgActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.67f); colors[ImGuiCol_FrameBgActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.67f);
colors[ImGuiCol_TitleBg] = ImVec4(0.04f, 0.04f, 0.04f, 1.00f); colors[ImGuiCol_TitleBg] = ImVec4(0.04f, 0.04f, 0.04f, 1.00f);
colors[ImGuiCol_TitleBgActive] = ImVec4(0.16f, 0.29f, 0.48f, 1.00f); colors[ImGuiCol_TitleBgActive] = ImVec4(0.16f, 0.29f, 0.48f, 1.00f);
colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.00f, 0.00f, 0.00f, 0.51f); colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.00f, 0.00f, 0.00f, 0.51f);
colors[ImGuiCol_MenuBarBg] = ImVec4(0.14f, 0.14f, 0.14f, 1.00f); colors[ImGuiCol_MenuBarBg] = ImVec4(0.14f, 0.14f, 0.14f, 1.00f);
colors[ImGuiCol_ScrollbarBg] = ImVec4(0.02f, 0.02f, 0.02f, 0.53f); colors[ImGuiCol_ScrollbarBg] = ImVec4(0.02f, 0.02f, 0.02f, 0.53f);
colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.31f, 0.31f, 0.31f, 1.00f); colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.31f, 0.31f, 0.31f, 1.00f);
colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.41f, 0.41f, 0.41f, 1.00f); colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.41f, 0.41f, 0.41f, 1.00f);
colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.51f, 0.51f, 0.51f, 1.00f); colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.51f, 0.51f, 0.51f, 1.00f);
colors[ImGuiCol_CheckMark] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); colors[ImGuiCol_CheckMark] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
colors[ImGuiCol_SliderGrab] = ImVec4(0.24f, 0.52f, 0.88f, 1.00f); colors[ImGuiCol_SliderGrab] = ImVec4(0.24f, 0.52f, 0.88f, 1.00f);
colors[ImGuiCol_SliderGrabActive] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); colors[ImGuiCol_SliderGrabActive] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
colors[ImGuiCol_Button] = ImVec4(0.26f, 0.59f, 0.98f, 0.40f); colors[ImGuiCol_Button] = ImVec4(0.26f, 0.59f, 0.98f, 0.40f);
colors[ImGuiCol_ButtonHovered] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); colors[ImGuiCol_ButtonHovered] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
colors[ImGuiCol_ButtonActive] = ImVec4(0.06f, 0.53f, 0.98f, 1.00f); colors[ImGuiCol_ButtonActive] = ImVec4(0.06f, 0.53f, 0.98f, 1.00f);
colors[ImGuiCol_Header] = ImVec4(0.26f, 0.59f, 0.98f, 0.0f); colors[ImGuiCol_Header] = ImVec4(0.26f, 0.59f, 0.98f, 0.0f);
colors[ImGuiCol_HeaderHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.80f); colors[ImGuiCol_HeaderHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.80f);
colors[ImGuiCol_HeaderActive] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); colors[ImGuiCol_HeaderActive] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
colors[ImGuiCol_Separator] = ImVec4(0.43f, 0.43f, 0.50f, 0.50f); colors[ImGuiCol_Separator] = ImVec4(0.43f, 0.43f, 0.50f, 0.50f);
colors[ImGuiCol_SeparatorHovered] = ImVec4(0.10f, 0.40f, 0.75f, 0.78f); colors[ImGuiCol_SeparatorHovered] = ImVec4(0.10f, 0.40f, 0.75f, 0.78f);
colors[ImGuiCol_SeparatorActive] = ImVec4(0.10f, 0.40f, 0.75f, 1.00f); colors[ImGuiCol_SeparatorActive] = ImVec4(0.10f, 0.40f, 0.75f, 1.00f);
colors[ImGuiCol_ResizeGrip] = ImVec4(0.26f, 0.59f, 0.98f, 0.0f); colors[ImGuiCol_ResizeGrip] = ImVec4(0.26f, 0.59f, 0.98f, 0.0f);
colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.67f); colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.67f);
colors[ImGuiCol_ResizeGripActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.95f); colors[ImGuiCol_ResizeGripActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.95f);
colors[ImGuiCol_Tab] = ImVec4(0.18f, 0.35f, 0.58f, 0.86f); colors[ImGuiCol_Tab] = ImVec4(0.18f, 0.35f, 0.58f, 0.86f);
colors[ImGuiCol_TabHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.80f); colors[ImGuiCol_TabHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.80f);
colors[ImGuiCol_TabActive] = ImVec4(0.20f, 0.41f, 0.68f, 1.00f); colors[ImGuiCol_TabActive] = ImVec4(0.20f, 0.41f, 0.68f, 1.00f);
colors[ImGuiCol_TabUnfocused] = ImVec4(0.07f, 0.10f, 0.15f, 0.97f); colors[ImGuiCol_TabUnfocused] = ImVec4(0.07f, 0.10f, 0.15f, 0.97f);
colors[ImGuiCol_TabUnfocusedActive] = ImVec4(0.14f, 0.26f, 0.42f, 1.00f); colors[ImGuiCol_TabUnfocusedActive] = ImVec4(0.14f, 0.26f, 0.42f, 1.00f);
colors[ImGuiCol_PlotLines] = ImVec4(0.61f, 0.61f, 0.61f, 1.00f); colors[ImGuiCol_PlotLines] = ImVec4(0.61f, 0.61f, 0.61f, 1.00f);
colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f); colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f);
colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f); colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.60f, 0.00f, 1.00f); colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.60f, 0.00f, 1.00f);
colors[ImGuiCol_TextSelectedBg] = ImVec4(0.26f, 0.59f, 0.98f, 0.35f); colors[ImGuiCol_TextSelectedBg] = ImVec4(0.26f, 0.59f, 0.98f, 0.35f);
colors[ImGuiCol_DragDropTarget] = ImVec4(1.00f, 1.00f, 0.00f, 0.90f); colors[ImGuiCol_DragDropTarget] = ImVec4(1.00f, 1.00f, 0.00f, 0.90f);
colors[ImGuiCol_NavHighlight] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); colors[ImGuiCol_NavHighlight] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
colors[ImGuiCol_NavWindowingHighlight] = ImVec4(1.00f, 1.00f, 1.00f, 0.70f); colors[ImGuiCol_NavWindowingHighlight] = ImVec4(1.00f, 1.00f, 1.00f, 0.70f);
colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.20f); colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.20f);
colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.26f, 0.59f, 0.98f, 0.35f); colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.26f, 0.59f, 0.98f, 0.35f);
} }

View File

@ -9,9 +9,6 @@
*/ */
#pragma once #pragma once
#ifndef GTA3
#include "visual.h"
#endif
#include "animation.h" #include "animation.h"
#include "game.h" #include "game.h"
#include "hook.h" #include "hook.h"
@ -20,24 +17,15 @@
#include "player.h" #include "player.h"
#include "teleport.h" #include "teleport.h"
#include "vehicle.h" #include "vehicle.h"
#include "visual.h"
#include "weapon.h" #include "weapon.h"
#ifndef GTA3
class CheatMenu : Hook, Animation, Game, Menu, Ped, Player, Teleport, Vehicle, Visual, Weapon class CheatMenu : Hook, Animation, Game, Menu, Ped, Player, Teleport, Vehicle, Visual, Weapon
#else
class CheatMenu : Hook, Animation, Game, Menu, Ped, Player, Teleport, Vehicle, Weapon
#endif
{ {
private: private:
static inline bool m_bShowMenu = false; static inline bool m_bShowMenu = false;
static inline ImVec2 m_fMenuSize = ImVec2(screen::GetScreenWidth() / 4, screen::GetScreenHeight() / 1.2); static inline ImVec2 m_fMenuSize = ImVec2(screen::GetScreenWidth() / 4, screen::GetScreenHeight() / 1.2);
#ifdef GTA3
static inline CallbackTable header{
{"Teleport", &Teleport::Draw}, {"Player", &Player::Draw}, {"Ped", &Ped::Draw}, {"Dummy", nullptr},
{"Vehicle", &Vehicle::Draw}, {"Weapon", &Weapon::Draw}, {"Game", &Game::Draw}, {"Menu", &Menu::Draw},
};
#else
static inline CallbackTable header{ static inline CallbackTable header{
{"Teleport", &Teleport::Draw}, {"Player", &Player::Draw}, {"Ped", &Ped::Draw}, {"Teleport", &Teleport::Draw}, {"Player", &Player::Draw}, {"Ped", &Ped::Draw},
#ifdef GTASA #ifdef GTASA
@ -46,8 +34,8 @@ private:
{"Dummy", nullptr}, {"Dummy", nullptr},
#endif #endif
{"Vehicle", &Vehicle::Draw}, {"Weapon", &Weapon::Draw}, {"Game", &Game::Draw}, {"Vehicle", &Vehicle::Draw}, {"Weapon", &Weapon::Draw}, {"Game", &Game::Draw},
{"Visual", &Visual::Draw}, {"Menu", &Menu::Draw}}; {"Visual", &Visual::Draw}, {"Menu", &Menu::Draw}
#endif };
static void ApplyStyle(); static void ApplyStyle();
static void DrawWindow(); static void DrawWindow();

View File

@ -1,100 +1,101 @@
#include "cheatmenu.h"
#include "hook.h"
#include "menuinfo.h"
#include "pch.h" #include "pch.h"
#include "hook.h"
#include "cheatmenu.h"
#include "updater.h" #include "updater.h"
#include "menuinfo.h"
void MenuThread(void *param) void MenuThread(void* param)
{ {
/* /*
Had to put this in place since some people put the folder in root Had to put this in place since some people put the folder in root
directory and the asi in modloader. Why?? directory and the asi in modloader. Why??
TODO: Unlikely they'd even read the log so have to do something else TODO: Unlikely they'd even read the log so have to do something else
*/ */
if (!std::filesystem::is_directory(PLUGIN_PATH((char *)"CheatMenu"))) if (!std::filesystem::is_directory(PLUGIN_PATH((char*)"CheatMenu")))
{ {
gLog << "CheatMenu folder not found. You need to put both \"CheatMenu.asi\" & \"CheatMenu\" folder in the same " gLog << "CheatMenu folder not found. You need to put both \"CheatMenu.asi\" & \"CheatMenu\" folder in the same directory" << std::endl;
"directory" return;
<< std::endl; }
return;
}
#ifdef GTASA #ifdef GTASA
Hook::ApplyMouseFix(); Hook::ApplyMouseFix();
#endif #endif
static bool bGameInit = false; static bool bGameInit = false;
// Wait till game init // Wait till game init
Events::initRwEvent += [] { bGameInit = true; }; Events::initRwEvent += []
{
bGameInit = true;
};
while (!bGameInit) while (!bGameInit)
{ {
Sleep(1000); Sleep(1000);
} }
#ifdef GTASA #ifdef GTASA
/* /*
TODO: Find a better way TODO: Find a better way
Since you could still name it something else Since you could still name it something else
*/ */
if (GetModuleHandle("SAMP.dll") || GetModuleHandle("SAMP.asi")) if (GetModuleHandle("SAMP.dll") || GetModuleHandle("SAMP.asi"))
{ {
MessageBox(RsGlobal.ps->window, "SAMP detected. Exiting CheatMenu.", "CheatMenu", MB_ICONERROR); MessageBox(RsGlobal.ps->window, "SAMP detected. Exiting CheatMenu.", "CheatMenu", MB_ICONERROR);
return; return;
} }
CFastman92limitAdjuster::Init(); CFastman92limitAdjuster::Init();
#endif #endif
gLog << "Starting...\nVersion: " MENU_TITLE "\nAuthor: Grinch_\nDiscord: " DISCORD_INVITE gLog << "Starting...\nVersion: " MENU_TITLE "\nAuthor: Grinch_\nDiscord: " DISCORD_INVITE "\nMore Info: "
"\nMore Info: " GITHUB_LINK "\n" GITHUB_LINK "\n" << std::endl;
<< std::endl; CheatMenu menu;
CheatMenu menu;
// 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) // Checking for updates once a day
{ time_t now = time(0);
Updater::CheckForUpdate(); struct tm tstruct = *localtime(&now);
gConfig.SetValue("config.last_update_checked", tstruct.tm_mday); int lastCheckDate = gConfig.GetValue("config.last_update_checked", 0);
}
while (true) if (lastCheckDate != tstruct.tm_mday)
{ {
Sleep(5000); Updater::CheckForUpdate();
gConfig.SetValue("config.last_update_checked", tstruct.tm_mday);
}
if (Updater::m_State == UPDATER_CHECKING) while (true)
{ {
Updater::CheckForUpdate(); Sleep(5000);
}
} if (Updater::m_State == UPDATER_CHECKING)
{
Updater::CheckForUpdate();
}
}
} }
BOOL WINAPI DllMain(HINSTANCE hDllHandle, DWORD nReason, LPVOID Reserved) BOOL WINAPI DllMain(HINSTANCE hDllHandle, DWORD nReason, LPVOID Reserved)
{ {
if (nReason == DLL_PROCESS_ATTACH) if (nReason == DLL_PROCESS_ATTACH)
{ {
uint gameVersion = GetGameVersion(); uint gameVersion = GetGameVersion();
if (gameVersion == BY_GAME(GAME_10US_HOODLUM, GAME_10EN, GAME_10EN)) if (gameVersion == BY_GAME(GAME_10US_HOODLUM, GAME_10EN, GAME_10EN))
{ {
CreateThread(nullptr, NULL, (LPTHREAD_START_ROUTINE)&MenuThread, nullptr, NULL, nullptr); CreateThread(nullptr, NULL, (LPTHREAD_START_ROUTINE)&MenuThread, nullptr, NULL, nullptr);
} }
else else
{ {
#ifdef GTASA #ifdef GTASA
MessageBox(HWND_DESKTOP, "Unknown game version. GTA SA v1.0 US is required.", "CheatMenu", MB_ICONERROR); MessageBox(HWND_DESKTOP, "Unknown game version. GTA SA v1.0 US is required.", "CheatMenu", MB_ICONERROR);
#elif GTAVC #elif GTAVC
MessageBox(HWND_DESKTOP, "Unknown game version. GTA VC v1.0 EN is required.", "CheatMenu", MB_ICONERROR); MessageBox(HWND_DESKTOP, "Unknown game version. GTA VC v1.0 EN is required.", "CheatMenu", MB_ICONERROR);
#else // GTA3 #else // GTA3
MessageBox(HWND_DESKTOP, "Unknown game version. GTA III v1.0 EN is required.", "CheatMenu", MB_ICONERROR); MessageBox(HWND_DESKTOP, "Unknown game version. GTA III v1.0 EN is required.", "CheatMenu", MB_ICONERROR);
#endif #endif
} }
} }
return TRUE; return TRUE;
} }

View File

@ -1,191 +1,192 @@
#include "filehandler.h"
#include "pch.h" #include "pch.h"
#include "filehandler.h"
#include "visual.h" #include "visual.h"
// TODO: Clean up this mess, use structures instead? // TODO: Clean up this mess, use structures instead?
void FileHandler::GenerateHandlingFile(int pHandling, std::map<int, std::string> &storeMap) void FileHandler::GenerateHandlingFile(int pHandling, std::map<int, std::string>& storeMap)
{ {
FILE *fp = fopen("handling.txt", "w"); FILE* fp = fopen("handling.txt", "w");
std::string handlingId = storeMap[FindPlayerPed()->m_pVehicle->m_nModelIndex]; std::string handlingId = storeMap[FindPlayerPed()->m_pVehicle->m_nModelIndex];
float fMass = patch::Get<float>(pHandling + 0x4); float fMass = patch::Get<float>(pHandling + 0x4);
float fTurnMass = patch::Get<float>(pHandling + 0xC); float fTurnMass = patch::Get<float>(pHandling + 0xC);
float fDragMult = patch::Get<float>(pHandling + 0x10); float fDragMult = patch::Get<float>(pHandling + 0x10);
float CentreOfMassX = patch::Get<float>(pHandling + 0x14); float CentreOfMassX = patch::Get<float>(pHandling + 0x14);
float CentreOfMassY = patch::Get<float>(pHandling + 0x18); float CentreOfMassY = patch::Get<float>(pHandling + 0x18);
float CentreOfMassZ = patch::Get<float>(pHandling + 0x1C); float CentreOfMassZ = patch::Get<float>(pHandling + 0x1C);
int nPercentSubmerged = patch::Get<int>(pHandling + 0x20); int nPercentSubmerged = patch::Get<int>(pHandling + 0x20);
float fTractionMultiplier = patch::Get<float>(pHandling + 0x28); float fTractionMultiplier = patch::Get<float>(pHandling + 0x28);
float fTractionLoss = patch::Get<float>(pHandling + 0xA4); float fTractionLoss = patch::Get<float>(pHandling + 0xA4);
float TractionBias = patch::Get<float>(pHandling + 0xA8); float TractionBias = patch::Get<float>(pHandling + 0xA8);
float fEngineAcceleration = patch::Get<float>(pHandling + 0x7C) * 12500; float fEngineAcceleration = patch::Get<float>(pHandling + 0x7C) * 12500;
float fEngineInertia = patch::Get<float>(pHandling + 0x80); float fEngineInertia = patch::Get<float>(pHandling + 0x80);
int nDriveType = patch::Get<BYTE>(pHandling + 0x74); int nDriveType = patch::Get<BYTE>(pHandling + 0x74);
int nEngineType = patch::Get<BYTE>(pHandling + 0x75); int nEngineType = patch::Get<BYTE>(pHandling + 0x75);
float BrakeDeceleration = patch::Get<float>(pHandling + 0x94) * 2500; float BrakeDeceleration = patch::Get<float>(pHandling + 0x94) * 2500;
float BrakeBias = patch::Get<float>(pHandling + 0x98); float BrakeBias = patch::Get<float>(pHandling + 0x98);
int ABS = patch::Get<BYTE>(pHandling + 0x9C); int ABS = patch::Get<BYTE>(pHandling + 0x9C);
float SteeringLock = patch::Get<float>(pHandling + 0xA0); float SteeringLock = patch::Get<float>(pHandling + 0xA0);
float SuspensionForceLevel = patch::Get<float>(pHandling + 0xAC); float SuspensionForceLevel = patch::Get<float>(pHandling + 0xAC);
float SuspensionDampingLevel = patch::Get<float>(pHandling + 0xB0); float SuspensionDampingLevel = patch::Get<float>(pHandling + 0xB0);
float SuspensionHighSpdComDamp = patch::Get<float>(pHandling + 0xB4); float SuspensionHighSpdComDamp = patch::Get<float>(pHandling + 0xB4);
float Suspension_upper_limit = patch::Get<float>(pHandling + 0xB8); float Suspension_upper_limit = patch::Get<float>(pHandling + 0xB8);
float Suspension_lower_limit = patch::Get<float>(pHandling + 0xBC); float Suspension_lower_limit = patch::Get<float>(pHandling + 0xBC);
float Suspension_bias = patch::Get<float>(pHandling + 0xC0); float Suspension_bias = patch::Get<float>(pHandling + 0xC0);
float Suspension_anti_dive_multiplier = patch::Get<float>(pHandling + 0xC4); float Suspension_anti_dive_multiplier = patch::Get<float>(pHandling + 0xC4);
float fCollisionDamageMultiplier = patch::Get<float>(pHandling + 0xC8) * 0.338; float fCollisionDamageMultiplier = patch::Get<float>(pHandling + 0xC8) * 0.338;
int nMonetaryValue = patch::Get<int>(pHandling + 0xD8); int nMonetaryValue = patch::Get<int>(pHandling + 0xD8);
int MaxVelocity = patch::Get<float>(pHandling + 0x84); int MaxVelocity = patch::Get<float>(pHandling + 0x84);
MaxVelocity = MaxVelocity * 206 + (MaxVelocity - 0.918668) * 1501; MaxVelocity = MaxVelocity * 206 + (MaxVelocity - 0.918668) * 1501;
int modelFlags = patch::Get<int>(pHandling + 0xCC); int modelFlags = patch::Get<int>(pHandling + 0xCC);
int handlingFlags = patch::Get<int>(pHandling + 0xD0); int handlingFlags = patch::Get<int>(pHandling + 0xD0);
int front_lights = patch::Get<BYTE>(pHandling + 0xDC); int front_lights = patch::Get<BYTE>(pHandling + 0xDC);
int rear_lights = patch::Get<BYTE>(pHandling + 0xDD); int rear_lights = patch::Get<BYTE>(pHandling + 0xDD);
int vehicle_anim_group = patch::Get<BYTE>(pHandling + 0xDE); int vehicle_anim_group = patch::Get<BYTE>(pHandling + 0xDE);
int nNumberOfGears = patch::Get<BYTE>(pHandling + 0x76); int nNumberOfGears = patch::Get<BYTE>(pHandling + 0x76);
float fSeatOffsetDistance = patch::Get<float>(pHandling + 0xD4); float fSeatOffsetDistance = patch::Get<float>(pHandling + 0xD4);
// TODO: make this more readable // TODO: make this more readable
fprintf(fp, fprintf(
"\n%s\t%.5g\t%.5g\t%.5g\t%.5g\t%.5g\t%.5g\t%d\t%.5g\t%.5g\t%.5g\t%d\t%d\t%.5g\t%.5g\t%c\t%c\t%.5g\t%.5g\t%" fp,
"d\t%.5g\t%.5g\t%.5g\t%.5g\t%.5g\t%.5g\t%.5g\t%.5g\t%.5g\t%.5g\t%d\t%d\t%d\t%d\t%d\t%d", "\n%s\t%.5g\t%.5g\t%.5g\t%.5g\t%.5g\t%.5g\t%d\t%.5g\t%.5g\t%.5g\t%d\t%d\t%.5g\t%.5g\t%c\t%c\t%.5g\t%.5g\t%d\t%.5g\t%.5g\t%.5g\t%.5g\t%.5g\t%.5g\t%.5g\t%.5g\t%.5g\t%.5g\t%d\t%d\t%d\t%d\t%d\t%d",
handlingId.c_str(), fMass, fTurnMass, fDragMult, CentreOfMassX, CentreOfMassY, CentreOfMassZ, handlingId.c_str(), fMass, fTurnMass, fDragMult, CentreOfMassX, CentreOfMassY, CentreOfMassZ, nPercentSubmerged,
nPercentSubmerged, fTractionMultiplier, fTractionLoss, TractionBias, nNumberOfGears, MaxVelocity, fTractionMultiplier, fTractionLoss, TractionBias, nNumberOfGears,
fEngineAcceleration, fEngineInertia, nDriveType, nEngineType, BrakeDeceleration, BrakeBias, ABS, MaxVelocity, fEngineAcceleration, fEngineInertia, nDriveType, nEngineType, BrakeDeceleration, BrakeBias, ABS,
SteeringLock, SuspensionForceLevel, SuspensionDampingLevel, SuspensionHighSpdComDamp, SteeringLock, SuspensionForceLevel, SuspensionDampingLevel,
Suspension_upper_limit, Suspension_lower_limit, Suspension_bias, Suspension_anti_dive_multiplier, SuspensionHighSpdComDamp, Suspension_upper_limit, Suspension_lower_limit, Suspension_bias,
fSeatOffsetDistance, fCollisionDamageMultiplier, nMonetaryValue, modelFlags, handlingFlags, front_lights, Suspension_anti_dive_multiplier, fSeatOffsetDistance,
rear_lights, vehicle_anim_group); fCollisionDamageMultiplier, nMonetaryValue, modelFlags, handlingFlags, front_lights, rear_lights,
vehicle_anim_group);
fclose(fp); fclose(fp);
} }
void FileHandler::FetchColorData(std::vector<std::vector<float>> &storeVec) void FileHandler::FetchColorData(std::vector<std::vector<float>>& storeVec)
{ {
std::string m_FilePath = GAME_PATH((char *)"/data/carcols.dat"); std::string m_FilePath = GAME_PATH((char*)"/data/carcols.dat");
if (std::filesystem::exists(m_FilePath)) if (std::filesystem::exists(m_FilePath))
{ {
std::ifstream file(m_FilePath); std::ifstream file(m_FilePath);
std::string line; std::string line;
bool bIsCar = false; bool bIsCar = false;
bool bIsCol = false; bool bIsCol = false;
int nLineCount = 0; int nLineCount = 0;
while (getline(file, line)) while (getline(file, line))
{ {
// skip commented & emety lines // skip commented & emety lines
if (line[0] == '#' || line == "") if (line[0] == '#' || line == "")
{ {
continue; continue;
} }
// section blocks // section blocks
if (line[0] == 'c' && line[1] == 'a' && line[2] == 'r') if (line[0] == 'c' && line[1] == 'a' && line[2] == 'r')
{ {
bIsCar = true; bIsCar = true;
continue; continue;
} }
if (line[0] == 'c' && line[1] == 'o' && line[2] == 'l') if (line[0] == 'c' && line[1] == 'o' && line[2] == 'l')
{ {
bIsCol = true; bIsCol = true;
continue; continue;
} }
if (line[0] == 'e' && line[1] == 'n' && line[2] == 'd') if (line[0] == 'e' && line[1] == 'n' && line[2] == 'd')
{ {
bIsCar = false; bIsCar = false;
bIsCol = false; bIsCol = false;
continue; continue;
} }
if (bIsCol) if (bIsCol)
{ {
try try
{ {
std::string temp; std::string temp;
std::stringstream ss(line); std::stringstream ss(line);
// fix one instance where . is used instead of , // fix one instance where . is used instead of ,
std::replace(temp.begin(), temp.end(), '.', ','); std::replace(temp.begin(), temp.end(), '.', ',');
// Format: red, green, blue // Format: red, green, blue
int r, g, b; int r,g,b;
getline(ss, temp, ','); getline(ss, temp, ',');
r = std::stoi(temp); r = std::stoi(temp);
getline(ss, temp, ','); getline(ss, temp, ',');
g = std::stoi(temp); g = std::stoi(temp);
getline(ss, temp, ','); getline(ss, temp, ',');
b = std::stoi(temp); b = std::stoi(temp);
storeVec.push_back({r / 255.0f, g / 255.0f, b / 255.0f}); storeVec.push_back({r / 255.0f, g / 255.0f, b / 255.0f});
++nLineCount; ++nLineCount;
} }
catch (...) catch (...)
{ {
gLog << "Error parsing carcols.dat, " << line << std::endl; gLog << "Error parsing carcols.dat, " << line << std::endl;
} }
} }
} }
file.close(); file.close();
} }
else else
{ {
gLog << "Carcols.dat not found"; gLog << "Carcols.dat not found";
} }
} }
void FileHandler::FetchHandlingID(std::map<int, std::string> &storeMap) void FileHandler::FetchHandlingID(std::map<int, std::string>& storeMap)
{ {
std::string m_FilePath = GAME_PATH((char *)"/data/vehicles.ide"); std::string m_FilePath = GAME_PATH((char*)"/data/vehicles.ide");
if (std::filesystem::exists(m_FilePath)) if (std::filesystem::exists(m_FilePath))
{ {
std::ifstream file(m_FilePath); std::ifstream file(m_FilePath);
std::string line; std::string line;
while (getline(file, line)) while (getline(file, line))
{ {
/* /*
Format: model, modelname, txdname, type, handlingId, ... Format: model, modelname, txdname, type, handlingId, ...
Skip if first thing isn't model id Skip if first thing isn't model id
*/ */
if (line[0] <= '0' || line[0] >= '9') if (line[0] <= '0' || line[0] >= '9')
{ {
continue; continue;
} }
// running inside try block to handle user errors, mostly commas // running inside try block to handle user errors, mostly commas
try try
{ {
std::string temp; std::string temp;
std::stringstream ss(line); std::stringstream ss(line);
// get model // get model
getline(ss, temp, ','); getline(ss, temp, ',');
int model = std::stoi(temp); int model = std::stoi(temp);
// get modelname, txd, type, handlingId // get modelname, txd, type, handlingId
getline(ss, temp, ','); getline(ss, temp, ',');
getline(ss, temp, ','); getline(ss, temp, ',');
getline(ss, temp, ','); getline(ss, temp, ',');
getline(ss, temp, ','); getline(ss, temp, ',');
temp.erase(std::remove_if(temp.begin(), temp.end(), ::isspace), temp.end()); temp.erase(std::remove_if(temp.begin(), temp.end(), ::isspace), temp.end());
storeMap[model] = temp; storeMap[model] = temp;
} }
catch (...) catch (...)
{ {
gLog << "Error parsing vehicles.ide, " << line << std::endl; gLog << "Error parsing vehicles.ide, " << line << std::endl;
} }
} }
file.close(); file.close();
} }
else else
{ {
gLog << "Vehicle.ide not found"; gLog << "Vehicle.ide not found";
} }

View File

@ -1,23 +1,24 @@
#pragma once #pragma once
#include <map> #include <map>
#include <string>
#include <vector> #include <vector>
#include <string>
class FileHandler class FileHandler
{ {
public: public:
FileHandler() = delete; FileHandler() = delete;
FileHandler(FileHandler &) = delete; FileHandler(FileHandler&) = delete;
/* /*
Parses data/carcols.dat file and stores color data Parses data/carcols.dat file and stores color data
TODO: Implement something that also parses modloader data TODO: Implement something that also parses modloader data
*/ */
static void FetchColorData(std::vector<std::vector<float>> &storeVec); static void FetchColorData(std::vector<std::vector<float>>& storeVec);
/* /*
Parses data/vehicles.ide file and stores handingId in a map Parses data/vehicles.ide file and stores handingId in a map
TODO: Implement something that also parses modloader data TODO: Implement something that also parses modloader data
*/ */
static void FetchHandlingID(std::map<int, std::string> &storeMap); static void FetchHandlingID(std::map<int, std::string>& storeMap);
static void GenerateHandlingFile(int pHandling, std::map<int, std::string> &storeMap); static void GenerateHandlingFile(int pHandling, std::map<int, std::string>& storeMap);
}; };

File diff suppressed because it is too large Load Diff

View File

@ -3,63 +3,65 @@
class Game class Game
{ {
public: public:
static inline ResourceStore m_MissionData{"mission", eResourceType::TYPE_TEXT}; static inline ResourceStore m_MissionData{ "mission", eResourceType::TYPE_TEXT };
static inline bool m_bDisableCheats; static inline bool m_bDisableCheats;
static inline bool m_bDisableReplay; static inline bool m_bDisableReplay;
static inline bool m_bMissionTimer; static inline bool m_bMissionTimer;
static inline bool m_bFreezeTime; static inline bool m_bFreezeTime;
static inline bool m_bSyncTime; static inline bool m_bSyncTime;
#ifdef GTASA #ifdef GTASA
static inline bool m_bForbiddenArea = true; // wanted level when going outside playable aea static inline bool m_bForbiddenArea = true; // wanted level when going outside playable aea
static inline bool m_bSolidWater; // walk on water hack static inline bool m_bSolidWater; // walk on water hack
static inline bool m_bScreenShot; static inline bool m_bScreenShot;
static inline bool m_bKeepStuff; static inline bool m_bKeepStuff;
static inline ResourceStore m_StatData{"stat", eResourceType::TYPE_TEXT}; static inline ResourceStore m_StatData{ "stat", eResourceType::TYPE_TEXT };
static inline std::vector<std::string> m_DayNames = {"Sunday", "Monday", "Tuesday", "Wednesday", static inline std::vector<std::string> m_DayNames =
"Thursday", "Friday", "Saturday"}; {
"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
struct m_RandomCheats };
{
static inline bool m_bEnabled;
static inline bool m_bProgressBar = true;
static inline std::string m_EnabledCheats[92][2];
static inline int m_nInterval = 10;
static inline CJson m_Json = CJson("cheat name");
static inline uint m_nTimer;
};
struct m_Freecam
{
static inline bool m_bEnabled;
static inline int m_nMul = 1;
static inline float m_fFOV = 60.0f;
static inline bool m_bInitDone;
static inline CPed *m_pPed;
static inline int m_nPed = -1;
static inline CVector m_fMouse;
static inline CVector m_fTotalMouse;
static inline BYTE m_bHudState;
static inline BYTE m_bRadarState;
};
struct m_HardMode
{
static inline bool m_bEnabled;
static inline float m_fBacHealth = 0.0f;
static inline float m_fBacMaxHealth = 0.0f;
static inline float m_fBacArmour = 0.0f;
static inline float m_fBacStamina = 0.0f;
};
struct m_RandomCheats
{
static inline bool m_bEnabled;
static inline bool m_bProgressBar = true;
static inline std::string m_EnabledCheats[92][2];
static inline int m_nInterval = 10;
static inline CJson m_Json = CJson("cheat name");
static inline uint m_nTimer;
};
struct m_Freecam
{
static inline bool m_bEnabled;
static inline int m_nMul = 1;
static inline float m_fFOV = 60.0f;
static inline bool m_bInitDone;
static inline CPed* m_pPed;
static inline int m_nPed = -1;
static inline CVector m_fMouse;
static inline CVector m_fTotalMouse;
static inline BYTE m_bHudState;
static inline BYTE m_bRadarState;
};
struct m_HardMode
{
static inline bool m_bEnabled;
static inline float m_fBacHealth = 0.0f;
static inline float m_fBacMaxHealth = 0.0f;
static inline float m_fBacArmour = 0.0f;
static inline float m_fBacStamina = 0.0f;
};
#endif #endif
Game(); Game();
static void Draw(); static void Draw();
static void RealTimeClock(); static void RealTimeClock();
#ifdef GTASA #ifdef GTASA
// TODO: Update freecam with aap's code // TODO: Update freecam with aap's code
static void FreeCam(); static void FreeCam();
static void ClearFreecamStuff(); static void ClearFreecamStuff();
#endif #endif
}; };

View File

@ -1,350 +1,350 @@
#include "pch.h"
#include "hook.h" #include "hook.h"
#include "../depend/imgui/imgui_impl_dx11.h"
#include "../depend/imgui/imgui_impl_dx9.h"
#include "../depend/imgui/imgui_impl_win32.h"
#include "../depend/kiero/kiero.h" #include "../depend/kiero/kiero.h"
#include "../depend/kiero/minhook/MinHook.h" #include "../depend/kiero/minhook/MinHook.h"
#include "pch.h" #include "../depend/imgui/imgui_impl_dx9.h"
#include "../depend/imgui/imgui_impl_dx11.h"
#include "../depend/imgui/imgui_impl_win32.h"
#include <dinput.h> #include <dinput.h>
#define DIMOUSE ((LPDIRECTINPUTDEVICE8)(RsGlobal.ps->diMouse)) #define DIMOUSE ((LPDIRECTINPUTDEVICE8)(RsGlobal.ps->diMouse))
LRESULT Hook::WndProc(const HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) LRESULT Hook::WndProc(const HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{ {
ImGui_ImplWin32_WndProcHandler(hWnd, uMsg, wParam, lParam); ImGui_ImplWin32_WndProcHandler(hWnd, uMsg, wParam, lParam);
if (ImGui::GetIO().WantTextInput) if (ImGui::GetIO().WantTextInput)
{ {
#ifdef GTASA #ifdef GTASA
Call<0x53F1E0>(); // CPad::ClearKeyboardHistory Call<0x53F1E0>(); // CPad::ClearKeyboardHistory
#endif #endif
return 1; return 1;
} }
return CallWindowProc(oWndProc, hWnd, uMsg, wParam, lParam); return CallWindowProc(oWndProc, hWnd, uMsg, wParam, lParam);
} }
HRESULT Hook::Reset(IDirect3DDevice9 *pDevice, D3DPRESENT_PARAMETERS *pPresentationParameters) HRESULT Hook::Reset(IDirect3DDevice9* pDevice, D3DPRESENT_PARAMETERS* pPresentationParameters)
{ {
ImGui_ImplDX9_InvalidateDeviceObjects(); ImGui_ImplDX9_InvalidateDeviceObjects();
return oReset(pDevice, pPresentationParameters); return oReset(pDevice, pPresentationParameters);
} }
void Hook::RenderFrame(void *ptr) void Hook::RenderFrame(void* ptr)
{ {
if (!ImGui::GetCurrentContext()) if (!ImGui::GetCurrentContext())
{ {
return; return;
} }
ImGuiIO &io = ImGui::GetIO(); ImGuiIO& io = ImGui::GetIO();
static bool bInit = false; static bool bInit = false;
if (bInit) if (bInit)
{ {
ShowMouse(m_bShowMouse); ShowMouse(m_bShowMouse);
// handle window scaling here // handle window scaling here
static ImVec2 fScreenSize = ImVec2(-1, -1); static ImVec2 fScreenSize = ImVec2(-1, -1);
ImVec2 size(screen::GetScreenWidth(), screen::GetScreenHeight()); ImVec2 size(screen::GetScreenWidth(), screen::GetScreenHeight());
if (fScreenSize.x != size.x && fScreenSize.y != size.y) if (fScreenSize.x != size.x && fScreenSize.y != size.y)
{ {
int fontSize = static_cast<int>(size.y / 54.85f); // manually tested int fontSize = static_cast<int>(size.y / 54.85f); // manually tested
io.FontDefault = io.Fonts->AddFontFromFileTTF("C:/Windows/Fonts/trebucbd.ttf", fontSize); io.FontDefault = io.Fonts->AddFontFromFileTTF("C:/Windows/Fonts/trebucbd.ttf", fontSize);
io.Fonts->Build(); io.Fonts->Build();
if (gRenderer == Render_DirectX9) if (gRenderer == Render_DirectX9)
{ {
ImGui_ImplDX9_InvalidateDeviceObjects(); ImGui_ImplDX9_InvalidateDeviceObjects();
} }
else else
{ {
ImGui_ImplDX11_InvalidateDeviceObjects(); ImGui_ImplDX11_InvalidateDeviceObjects();
} }
ImGuiStyle *style = &ImGui::GetStyle(); ImGuiStyle* style = &ImGui::GetStyle();
float scaleX = size.x / 1366.0f; float scaleX = size.x / 1366.0f;
float scaleY = size.y / 768.0f; float scaleY = size.y / 768.0f;
style->FramePadding = ImVec2(5 * scaleX, 3 * scaleY); style->FramePadding = ImVec2(5 * scaleX, 3 * scaleY);
style->ItemSpacing = ImVec2(8 * scaleX, 4 * scaleY); style->ItemSpacing = ImVec2(8 * scaleX, 4 * scaleY);
style->ScrollbarSize = 12 * scaleX; style->ScrollbarSize = 12 * scaleX;
style->IndentSpacing = 20 * scaleX; style->IndentSpacing = 20 * scaleX;
style->ItemInnerSpacing = ImVec2(4 * scaleX, 4 * scaleY); style->ItemInnerSpacing = ImVec2(4 * scaleX, 4 * scaleY);
fScreenSize = size; fScreenSize = size;
} }
ImGui_ImplWin32_NewFrame(); ImGui_ImplWin32_NewFrame();
if (gRenderer == Render_DirectX9) if (gRenderer == Render_DirectX9)
{ {
ImGui_ImplDX9_NewFrame(); ImGui_ImplDX9_NewFrame();
} }
else else
{ {
ImGui_ImplDX11_NewFrame(); ImGui_ImplDX11_NewFrame();
} }
ImGui::NewFrame(); ImGui::NewFrame();
if (windowCallback != nullptr) if (windowCallback != nullptr)
{ {
windowCallback(); windowCallback();
} }
ImGui::EndFrame(); ImGui::EndFrame();
ImGui::Render(); ImGui::Render();
if (gRenderer == Render_DirectX9) if (gRenderer == Render_DirectX9)
{ {
ImGui_ImplDX9_RenderDrawData(ImGui::GetDrawData()); ImGui_ImplDX9_RenderDrawData(ImGui::GetDrawData());
} }
else else
{ {
ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData()); ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
} }
} }
else else
{ {
bInit = true; bInit = true;
ImGuiStyle &style = ImGui::GetStyle(); ImGuiStyle& style = ImGui::GetStyle();
ImGui_ImplWin32_Init(RsGlobal.ps->window); ImGui_ImplWin32_Init(RsGlobal.ps->window);
#ifdef GTASA #ifdef GTASA
// shift trigger fix // shift trigger fix
patch::Nop(0x00531155, 5); patch::Nop(0x00531155, 5);
#endif #endif
if (gRenderer == Render_DirectX9) if (gRenderer == Render_DirectX9)
{ {
ImGui_ImplDX9_Init(reinterpret_cast<IDirect3DDevice9 *>(ptr)); ImGui_ImplDX9_Init(reinterpret_cast<IDirect3DDevice9*>(ptr));
} }
else else
{ {
// for dx11 device ptr is swapchain // for dx11 device ptr is swapchain
reinterpret_cast<IDXGISwapChain *>(ptr)->GetDevice(__uuidof(ID3D11Device), &ptr); reinterpret_cast<IDXGISwapChain*>(ptr)->GetDevice(__uuidof(ID3D11Device), &ptr);
ID3D11DeviceContext *context; ID3D11DeviceContext* context;
reinterpret_cast<ID3D11Device *>(ptr)->GetImmediateContext(&context); reinterpret_cast<ID3D11Device*>(ptr)->GetImmediateContext(&context);
ImGui_ImplDX11_Init(reinterpret_cast<ID3D11Device *>(ptr), context); ImGui_ImplDX11_Init(reinterpret_cast<ID3D11Device*>(ptr), context);
} }
ImGui_ImplWin32_EnableDpiAwareness(); ImGui_ImplWin32_EnableDpiAwareness();
io.IniFilename = nullptr; io.IniFilename = nullptr;
io.LogFilename = nullptr; io.LogFilename = nullptr;
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad;
style.WindowTitleAlign = ImVec2(0.5, 0.5); style.WindowTitleAlign = ImVec2(0.5, 0.5);
oWndProc = (WNDPROC)SetWindowLongPtr(RsGlobal.ps->window, GWL_WNDPROC, (LRESULT)WndProc); oWndProc = (WNDPROC)SetWindowLongPtr(RsGlobal.ps->window, GWL_WNDPROC, (LRESULT)WndProc);
} }
} }
HRESULT Hook::Dx9Handler(IDirect3DDevice9 *pDevice) HRESULT Hook::Dx9Handler(IDirect3DDevice9* pDevice)
{ {
RenderFrame(pDevice); RenderFrame(pDevice);
return oEndScene(pDevice); return oEndScene(pDevice);
} }
HRESULT Hook::Dx11Handler(IDXGISwapChain *pSwapChain, UINT SyncInterval, UINT Flags) HRESULT Hook::Dx11Handler(IDXGISwapChain* pSwapChain, UINT SyncInterval, UINT Flags)
{ {
RenderFrame(pSwapChain); RenderFrame(pSwapChain);
return oPresent11(pSwapChain, SyncInterval, Flags); return oPresent11(pSwapChain, SyncInterval, Flags);
} }
void Hook::ShowMouse(bool state) void Hook::ShowMouse(bool state)
{ {
// Disable player controls for controllers // Disable player controls for controllers
bool bMouseDisabled = false; bool bMouseDisabled = false;
bool isController; bool isController;
#ifdef GTA3 #ifdef GTA3
isController = !patch::Get<BYTE>(0x5F03D8); isController = !patch::Get<BYTE>(0x5F03D8);
#elif GTAVC #elif GTAVC
isController = patch::Get<BYTE>(0x86968B); isController = patch::Get<BYTE>(0x86968B);
#else // GTASA #else // GTASA
isController = patch::Get<BYTE>(0xBA6818); isController = patch::Get<BYTE>(0xBA6818);
#endif #endif
if (isController && (m_bShowMouse || bMouseDisabled))
{ if (isController && (m_bShowMouse || bMouseDisabled))
{
#ifdef GTASA #ifdef GTASA
CPlayerPed *player = FindPlayerPed(); CPlayerPed *player = FindPlayerPed();
CPad *pad = player ? player->GetPadFromPlayer() : NULL; CPad *pad = player ? player->GetPadFromPlayer() : NULL;
#else #else
CPad *pad = CPad::GetPad(0); CPad *pad = CPad::GetPad(0);
#endif #endif
if (pad) if (pad)
{ {
if (m_bShowMouse) if (m_bShowMouse)
{ {
bMouseDisabled = true; bMouseDisabled = true;
#ifdef GTA3 #ifdef GTA3
pad->m_bDisablePlayerControls = true; pad->m_bDisablePlayerControls = true;
#else // GTAVC & GTASA #else //GTAVC & GTASA
pad->DisablePlayerControls = true; pad->DisablePlayerControls = true;
#endif #endif
} }
else else
{ {
bMouseDisabled = false; bMouseDisabled = false;
#ifdef GTA3 #ifdef GTA3
pad->m_bDisablePlayerControls = false; pad->m_bDisablePlayerControls = false;
#else // GTAVC & GTASA #else //GTAVC & GTASA
pad->DisablePlayerControls = false; pad->DisablePlayerControls = false;
#endif #endif
} }
} }
} }
if (m_bMouseVisibility != m_bShowMouse) if (m_bMouseVisibility != m_bShowMouse)
{ {
ImGui::GetIO().MouseDrawCursor = state; ImGui::GetIO().MouseDrawCursor = state;
#ifdef GTASA #ifdef GTASA
Hook::ApplyMouseFix(); // Reapply the patches Hook::ApplyMouseFix(); // Reapply the patches
#else #else
if (m_bShowMouse) if (m_bShowMouse)
{ {
patch::SetUChar(BY_GAME(0, 0x6020A0, 0x580D20), 0xC3); // psSetMousePos patch::SetUChar(BY_GAME(0, 0x6020A0, 0x580D20), 0xC3); // psSetMousePos
patch::Nop(BY_GAME(0, 0x4AB6CA, 0x49272F), 5); // don't call CPad::UpdateMouse() patch::Nop(BY_GAME(0, 0x4AB6CA, 0x49272F), 5); // don't call CPad::UpdateMouse()
} }
else else
{ {
patch::SetUChar(BY_GAME(0, 0x6020A0, 0x580D20), 0x53); patch::SetUChar(BY_GAME(0, 0x6020A0, 0x580D20), 0x53);
#ifdef GTAVC #ifdef GTAVC
patch::SetRaw(0x4AB6CA, (char *)"\xE8\x51\x21\x00\x00", 5); patch::SetRaw(0x4AB6CA, (char*)"\xE8\x51\x21\x00\x00", 5);
#else // GTA3 #else // GTA3
patch::SetRaw(0x49272F, (char *)"\xE8\x6C\xF5\xFF\xFF", 5); patch::SetRaw(0x49272F, (char*)"\xE8\x6C\xF5\xFF\xFF", 5);
#endif #endif
} }
#endif #endif
CPad::NewMouseControllerState.X = 0; CPad::NewMouseControllerState.X = 0;
CPad::NewMouseControllerState.Y = 0; CPad::NewMouseControllerState.Y = 0;
#ifdef GTA3 #ifdef GTA3
CPad::GetPad(0)->ClearMouseHistory(); CPad::GetPad(0)->ClearMouseHistory();
#else // GTAVC & GTASA #else // GTAVC & GTASA
CPad::ClearMouseHistory(); CPad::ClearMouseHistory();
#endif #endif
CPad::UpdatePads(); CPad::UpdatePads();
m_bMouseVisibility = m_bShowMouse; m_bMouseVisibility = m_bShowMouse;
} }
} }
Hook::Hook() Hook::Hook()
{ {
ImGui::CreateContext(); ImGui::CreateContext();
// Nvidia Overlay crash fix // Nvidia Overlay crash fix
if (init(kiero::RenderType::D3D9) == kiero::Status::Success) if (init(kiero::RenderType::D3D9) == kiero::Status::Success)
{ {
gRenderer = Render_DirectX9; gRenderer = Render_DirectX9;
kiero::bind(16, (void **)&oReset, Reset); kiero::bind(16, (void**)&oReset, Reset);
kiero::bind(42, (void **)&oEndScene, Dx9Handler); kiero::bind(42, (void**)&oEndScene, Dx9Handler);
} }
else else
{ {
// gtaRenderHook // gtaRenderHook
if (init(kiero::RenderType::D3D11) == kiero::Status::Success) if (init(kiero::RenderType::D3D11) == kiero::Status::Success)
{ {
gRenderer = Render_DirectX11; gRenderer = Render_DirectX11;
kiero::bind(8, (void **)&oPresent11, Dx11Handler); kiero::bind(8, (void**)&oPresent11, Dx11Handler);
} }
} }
} }
Hook::~Hook() Hook::~Hook()
{ {
SetWindowLongPtr(RsGlobal.ps->window, GWL_WNDPROC, (LRESULT)oWndProc); SetWindowLongPtr(RsGlobal.ps->window, GWL_WNDPROC, (LRESULT)oWndProc);
ImGui_ImplDX9_Shutdown(); ImGui_ImplDX9_Shutdown();
ImGui_ImplWin32_Shutdown(); ImGui_ImplWin32_Shutdown();
ImGui::DestroyContext(); ImGui::DestroyContext();
kiero::shutdown(); kiero::shutdown();
} }
#ifdef GTASA #ifdef GTASA
struct Mouse struct Mouse
{ {
unsigned int x, y; unsigned int x, y;
unsigned int wheelDelta; unsigned int wheelDelta;
unsigned char buttons[8]; unsigned char buttons[8];
}; };
struct MouseInfo struct MouseInfo
{ {
int x, y, wheelDelta; int x, y, wheelDelta;
} mouseInfo; } mouseInfo;
static BOOL __stdcall _SetCursorPos(int X, int Y) static BOOL __stdcall _SetCursorPos(int X, int Y)
{ {
if (Hook::m_bShowMouse || GetActiveWindow() != RsGlobal.ps->window) if (Hook::m_bShowMouse || GetActiveWindow() != RsGlobal.ps->window)
{ {
return 1; return 1;
} }
mouseInfo.x = X; mouseInfo.x = X;
mouseInfo.y = Y; mouseInfo.y = Y;
return SetCursorPos(X, Y); return SetCursorPos(X, Y);
} }
static LRESULT __stdcall _DispatchMessage(MSG *lpMsg) static LRESULT __stdcall _DispatchMessage(MSG* lpMsg)
{ {
if (lpMsg->message == WM_MOUSEWHEEL && !Hook::m_bShowMouse) if (lpMsg->message == WM_MOUSEWHEEL && !Hook::m_bShowMouse)
{ {
mouseInfo.wheelDelta += GET_WHEEL_DELTA_WPARAM(lpMsg->wParam); mouseInfo.wheelDelta += GET_WHEEL_DELTA_WPARAM(lpMsg->wParam);
} }
return DispatchMessageA(lpMsg); return DispatchMessageA(lpMsg);
} }
static int _cdecl _GetMouseState(Mouse *pMouse) static int _cdecl _GetMouseState(Mouse* pMouse)
{ {
if (Hook::m_bShowMouse || !RsGlobal.ps->diMouse) if (Hook::m_bShowMouse || !RsGlobal.ps->diMouse)
{ {
DIMOUSE->Unacquire(); DIMOUSE->Unacquire();
return -1; return -1;
} }
if (DIMOUSE->GetDeviceState(sizeof(Mouse), pMouse) < 0)
{
if (DIMOUSE->Acquire() == DIERR_NOTINITIALIZED)
{
while (DIMOUSE->Acquire() == DIERR_NOTINITIALIZED);
}
}
if (DIMOUSE->GetDeviceState(sizeof(Mouse), pMouse) < 0) pMouse->wheelDelta = mouseInfo.wheelDelta;
{ mouseInfo.wheelDelta = 0;
if (DIMOUSE->Acquire() == DIERR_NOTINITIALIZED) pMouse->buttons[0] = (GetAsyncKeyState(1) >> 8);
{ pMouse->buttons[1] = (GetAsyncKeyState(2) >> 8);
while (DIMOUSE->Acquire() == DIERR_NOTINITIALIZED) pMouse->buttons[2] = (GetAsyncKeyState(4) >> 8);
; pMouse->buttons[3] = (GetAsyncKeyState(5) >> 8);
} pMouse->buttons[4] = (GetAsyncKeyState(6) >> 8);
}
return 0;
pMouse->wheelDelta = mouseInfo.wheelDelta;
mouseInfo.wheelDelta = 0;
pMouse->buttons[0] = (GetAsyncKeyState(1) >> 8);
pMouse->buttons[1] = (GetAsyncKeyState(2) >> 8);
pMouse->buttons[2] = (GetAsyncKeyState(4) >> 8);
pMouse->buttons[3] = (GetAsyncKeyState(5) >> 8);
pMouse->buttons[4] = (GetAsyncKeyState(6) >> 8);
return 0;
} }
void Hook::ApplyMouseFix() void Hook::ApplyMouseFix()
{ {
patch::ReplaceFunctionCall(0x53F417, _GetMouseState); patch::ReplaceFunctionCall(0x53F417, _GetMouseState);
patch::Nop(0x57C59B, 1); patch::Nop(0x57C59B, 1);
patch::ReplaceFunctionCall(0x57C59C, _SetCursorPos); patch::ReplaceFunctionCall(0x57C59C, _SetCursorPos);
patch::Nop(0x81E5D4, 1); patch::Nop(0x81E5D4, 1);
patch::ReplaceFunctionCall(0x81E5D5, _SetCursorPos); patch::ReplaceFunctionCall(0x81E5D5, _SetCursorPos);
patch::Nop(0x74542D, 1); patch::Nop(0x74542D, 1);
patch::ReplaceFunctionCall(0x74542E, _SetCursorPos); patch::ReplaceFunctionCall(0x74542E, _SetCursorPos);
patch::Nop(0x748A7C, 1); patch::Nop(0x748A7C, 1);
patch::ReplaceFunctionCall(0x748A7D, _DispatchMessage); patch::ReplaceFunctionCall(0x748A7D, _DispatchMessage);
patch::SetChar(0x746A08, 32); // diMouseOffset patch::SetChar(0x746A08, 32); // diMouseOffset
patch::SetChar(0x746A58, 32); // diDeviceoffset patch::SetChar(0x746A58, 32); // diDeviceoffset
} }
#endif #endif

View File

@ -1,36 +1,36 @@
#pragma once #pragma once
#include "pch.h" #include "pch.h"
using f_EndScene = HRESULT(CALLBACK *)(IDirect3DDevice9 *); using f_EndScene = HRESULT(CALLBACK*)(IDirect3DDevice9*);
using f_Present11 = HRESULT(CALLBACK *)(IDXGISwapChain *, UINT, UINT); using f_Present11 = HRESULT(CALLBACK*)(IDXGISwapChain*, UINT, UINT);
using f_Reset = HRESULT(CALLBACK *)(IDirect3DDevice9 *, D3DPRESENT_PARAMETERS *); using f_Reset = HRESULT(CALLBACK*)(IDirect3DDevice9*, D3DPRESENT_PARAMETERS*);
extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
class Hook class Hook
{ {
private: private:
static inline WNDPROC oWndProc; static inline WNDPROC oWndProc;
static inline f_Present11 oPresent11; static inline f_Present11 oPresent11;
static inline f_EndScene oEndScene; static inline f_EndScene oEndScene;
static inline f_Reset oReset; static inline f_Reset oReset;
static inline bool m_bMouseVisibility; static inline bool m_bMouseVisibility;
static void CALLBACK RenderFrame(void *ptr); static void CALLBACK RenderFrame(void* ptr);
static HRESULT CALLBACK Dx9Handler(IDirect3DDevice9 *pDevice); static HRESULT CALLBACK Dx9Handler(IDirect3DDevice9* pDevice);
static HRESULT CALLBACK Dx11Handler(IDXGISwapChain *pSwapChain, UINT SyncInterval, UINT Flags); static HRESULT CALLBACK Dx11Handler(IDXGISwapChain* pSwapChain, UINT SyncInterval, UINT Flags);
static HRESULT CALLBACK Reset(IDirect3DDevice9 *pDevice, D3DPRESENT_PARAMETERS *pPresentationParameters); static HRESULT CALLBACK Reset(IDirect3DDevice9* pDevice, D3DPRESENT_PARAMETERS* pPresentationParameters);
static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
static void ShowMouse(bool state); static void ShowMouse(bool state);
public: public:
static inline bool m_bShowMouse = false; static inline bool m_bShowMouse = false;
static inline std::function<void()> windowCallback = nullptr; static inline std::function<void()> windowCallback = nullptr;
#ifdef GTASA #ifdef GTASA
static void ApplyMouseFix(); static void ApplyMouseFix();
#endif #endif
Hook(); Hook();
~Hook(); ~Hook();
}; };

View File

@ -1,5 +1,5 @@
#include "hotkeys.h"
#include "pch.h" #include "pch.h"
#include "hotkeys.h"
Hotkey aimSkinChanger; Hotkey aimSkinChanger;
Hotkey freeCam; Hotkey freeCam;
@ -15,124 +15,124 @@ Hotkey vehEngine;
Hotkey vehInstantStart; Hotkey vehInstantStart;
Hotkey vehInstantStop; Hotkey vehInstantStop;
bool Hotkey::DrawUI(const char *label) bool Hotkey::DrawUI(const char* label)
{ {
bool active = m_CurrentHotkey == label; bool active = m_CurrentHotkey == label;
bool state = false; bool state = false;
if (active) if (active)
{ {
ImGui::PushStyleColor(ImGuiCol_Button, ImGui::GetStyle().Colors[ImGuiCol_ButtonActive]); ImGui::PushStyleColor(ImGuiCol_Button, ImGui::GetStyle().Colors[ImGuiCol_ButtonActive]);
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImGui::GetStyle().Colors[ImGuiCol_ButtonActive]); ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImGui::GetStyle().Colors[ImGuiCol_ButtonActive]);
for (int key = 3; key != 135; ++key) for (int key = 3; key != 135; ++key)
{ {
if (KeyPressed(key)) if (KeyPressed(key))
{ {
m_key1 = key; m_key1 = key;
break; break;
} }
} }
for (int key = 135; key != 3; --key) for (int key = 135; key != 3; --key)
{ {
if (KeyPressed(key)) if (KeyPressed(key))
{ {
m_key2 = key; m_key2 = key;
break; break;
} }
} }
} }
std::string text; std::string text;
if (m_key1 != VK_NONE) if (m_key1 != VK_NONE)
{ {
text = key_names[m_key1 - 1]; text = key_names[m_key1 - 1];
} }
else else
{ {
text = "None"; text = "None";
} }
if (m_key1 != m_key2) if (m_key1 != m_key2)
{ {
text += (" + " + key_names[m_key2 - 1]); text += (" + " + key_names[m_key2 - 1]);
} }
if (ImGui::Button((text + std::string("##") + std::string(label)).c_str(), if (ImGui::Button((text + std::string("##") + std::string(label)).c_str(),
ImVec2(ImGui::GetWindowContentRegionWidth() / 3.5, ImGui::GetFrameHeight()))) ImVec2(ImGui::GetWindowContentRegionWidth() / 3.5, ImGui::GetFrameHeight())))
{ {
if (!active) if (!active)
{ {
m_CurrentHotkey = label; m_CurrentHotkey = label;
} }
} }
if (active && ImGui::IsMouseClicked(ImGuiMouseButton_Left)) if (active && ImGui::IsMouseClicked(ImGuiMouseButton_Left))
{ {
m_CurrentHotkey = ""; m_CurrentHotkey = "";
state = true; state = true;
} }
if (ImGui::IsMouseClicked(ImGuiMouseButton_Right)) if (ImGui::IsMouseClicked(ImGuiMouseButton_Right))
{ {
if (ImGui::IsItemHovered()) if (ImGui::IsItemHovered())
{ {
m_key1 = VK_NONE; m_key1 = VK_NONE;
m_key2 = VK_NONE; m_key2 = VK_NONE;
} }
else else
{ {
m_CurrentHotkey = ""; m_CurrentHotkey = "";
} }
state = true; state = true;
} }
ImGui::SameLine(); ImGui::SameLine();
ImGui::Text(label); ImGui::Text(label);
if (active) if (active)
{ {
ImGui::PopStyleColor(2); ImGui::PopStyleColor(2);
} }
return state; return state;
} }
bool Hotkey::Pressed() bool Hotkey::Pressed()
{ {
if (KeyPressed(m_key1) && KeyPressed(m_key2)) if (KeyPressed(m_key1) && KeyPressed(m_key2))
m_bPressed = true; m_bPressed = true;
else else
{ {
if (m_bPressed) if (m_bPressed)
{ {
m_bPressed = false; m_bPressed = false;
return m_CurrentHotkey == ""; return m_CurrentHotkey == "";
} }
} }
return false; return false;
} }
std::string Hotkey::GetNameString() std::string Hotkey::GetNameString()
{ {
std::string text; std::string text;
if (m_key1 != VK_NONE) if (m_key1 != VK_NONE)
{ {
text = key_names[m_key1 - 1]; text = key_names[m_key1 - 1];
} }
else else
{ {
text = "None"; text = "None";
} }
if (m_key1 != m_key2) if (m_key1 != m_key2)
{ {
text += (" + " + key_names[m_key2 - 1]); text += (" + " + key_names[m_key2 - 1]);
} }
return text; return text;
} }

View File

@ -10,13 +10,13 @@ private:
public: public:
int m_key1; int m_key1;
int m_key2; int m_key2;
Hotkey(int key1 = -1, int key2 = -1) : m_key1(key1), m_key2(key2) Hotkey(int key1 = -1, int key2 = -1)
{ : m_key1(key1), m_key2(key2)
} {}
// Draws ui to change the hotkeys from frontend // Draws ui to change the hotkeys from frontend
bool DrawUI(const char *label); bool DrawUI(const char* label);
bool Pressed(); bool Pressed();
std::string GetNameString(); std::string GetNameString();
}; };

View File

@ -1,47 +1,47 @@
#include "json.h"
#include "pch.h" #include "pch.h"
#include "json.h"
CJson::CJson(const char *name) CJson::CJson(const char* name)
{ {
if (name == "" || !std::filesystem::is_directory(PLUGIN_PATH((char *)"CheatMenu"))) if (name == "" || !std::filesystem::is_directory(PLUGIN_PATH((char*)"CheatMenu")))
{ {
return; return;
} }
m_FilePath = PLUGIN_PATH((char *)"/CheatMenu/json/") + std::string(name) + ".json"; m_FilePath = PLUGIN_PATH((char*)"/CheatMenu/json/") + std::string(name) + ".json";
if (std::filesystem::exists(m_FilePath)) if (std::filesystem::exists(m_FilePath))
{ {
try try
{ {
std::ifstream file(m_FilePath); std::ifstream file(m_FilePath);
file >> m_Data; file >> m_Data;
file.close(); file.close();
} }
catch (...) catch (...)
{ {
gLog << "Error trying to read " << m_FilePath << std::endl; gLog << "Error trying to read " << m_FilePath << std::endl;
m_Data = "{}"_json; m_Data = "{}"_json;
} }
} }
else else
{ {
m_Data = "{}"_json; m_Data = "{}"_json;
if (m_FilePath.find("config")) if (m_FilePath.find("config"))
{ {
gLog << "Creating config.json file" << std::endl; gLog << "Creating config.json file" << std::endl;
} }
else else
{ {
gLog << "Failed to locate file " << m_FilePath << std::endl; gLog << "Failed to locate file " << m_FilePath << std::endl;
} }
} }
} }
void CJson::WriteToDisk() void CJson::WriteToDisk()
{ {
std::ofstream file(m_FilePath); std::ofstream file(m_FilePath);
file << m_Data.dump(4, ' ', false, nlohmann::json::error_handler_t::replace) << std::endl; file << m_Data.dump(4, ' ', false, nlohmann::json::error_handler_t::replace) << std::endl;
file.close(); file.close();
} }

View File

@ -2,117 +2,122 @@
#include "../depend/json.hpp" #include "../depend/json.hpp"
/* /*
Wrapper class for nlohmann::json Wrapper class for nlohmann::json
Contains helper methods Contains helper methods
*/ */
class CJson class CJson
{ {
private: private:
std::string m_FilePath; std::string m_FilePath;
public: public:
nlohmann::json m_Data; nlohmann::json m_Data;
/* /*
Returns a value from json structure hierarchy using '.' Returns a value from json structure hierarchy using '.'
Example: "Menu.Window.X" Example: "Menu.Window.X"
*/ */
// specialize since typeid(std::string) doesn't work // specialize since typeid(std::string) doesn't work
template <typename T> T GetValue(std::string &&key, T &&defaultVal) template <typename T>
{ T GetValue(std::string&& key, T&& defaultVal)
try {
{ try
std::stringstream ss(key); {
std::string line; std::stringstream ss(key);
std::string line;
nlohmann::json *json = &m_Data; nlohmann::json* json = &m_Data;
while (getline(ss, line, '.')) while (getline(ss, line, '.'))
{ {
json = &((*json)[line]); json = &((*json)[line]);
} }
// json library bugs with bool, using int instead // json library bugs with bool, using int instead
if (typeid(T) == typeid(bool)) if (typeid(T) == typeid(bool))
{ {
return ((json->get<int>() == 1) ? true : false); return ((json->get<int>() == 1) ? true : false);
} }
return json->get<T>(); return json->get<T>();
} }
catch (...) catch (...)
{ {
return defaultVal; return defaultVal;
} }
} }
template <> std::string GetValue(std::string &&key, std::string &&defaultVal) template <>
{ std::string GetValue(std::string&& key, std::string&& defaultVal)
try {
{ try
std::stringstream ss(key); {
std::string line; std::stringstream ss(key);
std::string line;
nlohmann::json *json = &m_Data; nlohmann::json* json = &m_Data;
while (getline(ss, line, '.')) while (getline(ss, line, '.'))
{ {
json = &((*json)[line]); json = &((*json)[line]);
} }
return json->get<std::string>(); return json->get<std::string>();
} }
catch (...) catch (...)
{ {
return defaultVal; return defaultVal;
} }
} }
/* /*
Allows to save values in json hierarchy using '.' Allows to save values in json hierarchy using '.'
Example: "Menu.Window.X" Example: "Menu.Window.X"
*/ */
template <typename T> void SetValue(std::string &&key, T &val) template <typename T>
{ void SetValue(std::string&& key, T& val)
std::stringstream ss(key); {
std::string line; std::stringstream ss(key);
std::string line;
nlohmann::json *json = &m_Data; nlohmann::json* json = &m_Data;
while (getline(ss, line, '.')) while (getline(ss, line, '.'))
{ {
json = &((*json)[line]); json = &((*json)[line]);
}
// json library bugs with bool, using int instead }
if (typeid(T) == typeid(bool))
{
*json = (val ? 1 : 0);
}
else
{
*json = val;
}
}
template <> void SetValue(std::string &&key, std::string &val) // json library bugs with bool, using int instead
{ if (typeid(T) == typeid(bool))
std::stringstream ss(key); {
std::string line; *json = (val ? 1 : 0);
}
else
{
*json = val;
}
}
nlohmann::json *json = &m_Data; template <>
void SetValue(std::string&& key, std::string& val)
{
std::stringstream ss(key);
std::string line;
while (getline(ss, line, '.')) nlohmann::json* json = &m_Data;
{
json = &((*json)[line]);
}
*json = val; while (getline(ss, line, '.'))
} {
json = &((*json)[line]);
}
/* *json = val;
Saves json data to disk }
*/
void WriteToDisk(); /*
CJson(const char *text = ""); Saves json data to disk
*/
void WriteToDisk();
CJson(const char* text = "");
}; };

File diff suppressed because it is too large Load Diff

View File

@ -3,48 +3,50 @@
class Menu class Menu
{ {
private: private:
enum DISPLAY_POS
{
CUSTOM,
TOP_LEFT,
TOP_RIGHT,
BOTTOM_LEFT,
BOTTOM_RIGHT
};
struct m_Overlay enum DISPLAY_POS
{ {
static inline bool bCoord = false; CUSTOM,
static inline bool bFPS = false; TOP_LEFT,
static inline int mFPS = 0; TOP_RIGHT,
static inline bool bLocName = false; BOTTOM_LEFT,
static inline bool bTransparent = false; BOTTOM_RIGHT
static inline bool bVehHealth = false; };
static inline bool bVehSpeed = false;
static inline bool bCpuUsage = false; struct m_Overlay
static inline float fCpuUsage = 0.0f; {
static inline bool bMemUsage = false; static inline bool bCoord = false;
static inline float fMemUsage = 0.0f; static inline bool bFPS = false;
static inline std::vector<std::string> posNames = {"Custom", "Top left", "Top right", "Bottom left", static inline int mFPS = 0;
"Bottom right"}; static inline bool bLocName = false;
static inline DISPLAY_POS mSelectedPos = DISPLAY_POS::BOTTOM_RIGHT; static inline bool bTransparent = false;
static inline float fPosX = 0.0f; static inline bool bVehHealth = false;
static inline float fPosY = 0.0f; static inline bool bVehSpeed = false;
static inline size_t mInterval = 1000; static inline bool bCpuUsage = false;
static inline size_t mLastInterval = 0; static inline float fCpuUsage = 0.0f;
static inline int mTotalRam = 0; static inline bool bMemUsage = false;
}; static inline float fMemUsage = 0.0f;
static inline std::vector<std::string> posNames = {
"Custom", "Top left", "Top right", "Bottom left", "Bottom right"
};
static inline DISPLAY_POS mSelectedPos = DISPLAY_POS::BOTTOM_RIGHT;
static inline float fPosX = 0.0f;
static inline float fPosY = 0.0f;
static inline size_t mInterval = 1000;
static inline size_t mLastInterval = 0;
static inline int mTotalRam = 0;
};
public: public:
struct m_Commands struct m_Commands
{ {
static inline bool m_bShowMenu = false; static inline bool m_bShowMenu = false;
static inline char m_nInputBuffer[INPUT_BUFFER_SIZE] = ""; static inline char m_nInputBuffer[INPUT_BUFFER_SIZE] = "";
}; };
Menu(); Menu();
static void Draw(); static void Draw();
static void DrawOverlay(); static void DrawOverlay();
static void DrawShortcutsWindow(); static void DrawShortcutsWindow();
static void ProcessCommands(); static void ProcessCommands();
}; };

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#define MENU_NAME "Cheat Menu" #define MENU_NAME "Cheat Menu"
#define MENU_VERSION_NUMBER "3.0" #define MENU_VERSION_NUMBER "3.0"
#define MENU_VERSION MENU_VERSION_NUMBER "-beta" #define MENU_VERSION MENU_VERSION_NUMBER"-beta"
#define BUILD_NUMBER "20211020" #define BUILD_NUMBER "20211020"
#define MENU_TITLE MENU_NAME " v" MENU_VERSION "(" BUILD_NUMBER ")" #define MENU_TITLE MENU_NAME " v" MENU_VERSION "(" BUILD_NUMBER ")"

View File

@ -1,184 +1,254 @@
#include "neon.h"
#include "pch.h" #include "pch.h"
#include "neon.h"
#include "util.h" #include "util.h"
// Neon sprite // Neon sprite
const unsigned char neon_mask[1689] = { const unsigned char neon_mask[1689] =
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, {
0x40, 0x00, 0x00, 0x00, 0x80, 0x08, 0x06, 0x00, 0x00, 0x00, 0xbb, 0x81, 0x6f, 0x6a, 0x00, 0x00, 0x00, 0x09, 0x70, 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00,
0x48, 0x59, 0x73, 0x00, 0x00, 0x0b, 0x13, 0x00, 0x00, 0x0b, 0x13, 0x01, 0x00, 0x9a, 0x9c, 0x18, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00,
0x20, 0x63, 0x48, 0x52, 0x4d, 0x00, 0x00, 0x7a, 0x25, 0x00, 0x00, 0x80, 0x83, 0x00, 0x00, 0xf9, 0xff, 0x00, 0x00, 0x00, 0x80, 0x08, 0x06, 0x00, 0x00, 0x00, 0xbb, 0x81, 0x6f, 0x6a,
0x80, 0xe9, 0x00, 0x00, 0x75, 0x30, 0x00, 0x00, 0xea, 0x60, 0x00, 0x00, 0x3a, 0x98, 0x00, 0x00, 0x17, 0x6f, 0x92, 0x00, 0x00, 0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x0b,
0x5f, 0xc5, 0x46, 0x00, 0x00, 0x06, 0x1f, 0x49, 0x44, 0x41, 0x54, 0x78, 0xda, 0xec, 0x5d, 0xdb, 0x8e, 0xe4, 0x2a, 0x13, 0x00, 0x00, 0x0b, 0x13, 0x01, 0x00, 0x9a, 0x9c, 0x18, 0x00,
0x0c, 0x64, 0xa3, 0xf3, 0x10, 0x45, 0x49, 0x2b, 0xe2, 0xff, 0xbf, 0x11, 0x45, 0x09, 0x42, 0x79, 0x9b, 0xf3, 0x34, 0x00, 0x00, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x00, 0x00, 0x7a, 0x25,
0xda, 0xde, 0x08, 0x70, 0xd9, 0x18, 0x42, 0x66, 0x1a, 0x69, 0xb4, 0xdb, 0x37, 0x3a, 0x55, 0x2e, 0x97, 0x0d, 0xdd, 0x00, 0x00, 0x80, 0x83, 0x00, 0x00, 0xf9, 0xff, 0x00, 0x00, 0x80,
0x6a, 0xfe, 0x7c, 0x7d, 0x7d, 0x99, 0x86, 0x63, 0x01, 0x9f, 0x77, 0xb4, 0xba, 0xa0, 0x3f, 0x95, 0x09, 0x58, 0x14, 0xe9, 0x00, 0x00, 0x75, 0x30, 0x00, 0x00, 0xea, 0x60, 0x00, 0x00,
0xe6, 0x38, 0x9e, 0x46, 0x00, 0x02, 0xda, 0x26, 0xee, 0x77, 0xad, 0xc9, 0xd0, 0x24, 0x60, 0x11, 0x82, 0x36, 0x02, 0x3a, 0x98, 0x00, 0x00, 0x17, 0x6f, 0x92, 0x5f, 0xc5, 0x46, 0x00,
0x32, 0x8e, 0xde, 0x08, 0x58, 0x98, 0xa0, 0x2d, 0x03, 0xb0, 0xab, 0x49, 0x82, 0x06, 0x01, 0x4b, 0x21, 0x70, 0x14, 0x00, 0x06, 0x1f, 0x49, 0x44, 0x41, 0x54, 0x78, 0xda, 0xec, 0x5d,
0x74, 0x15, 0x22, 0x4a, 0x09, 0x40, 0xc1, 0x53, 0xf7, 0xa1, 0xd1, 0x77, 0xbd, 0x10, 0x80, 0x4a, 0xde, 0x0a, 0x14, 0xdb, 0x8e, 0xe4, 0x2a, 0x0c, 0x64, 0xa3, 0xf3, 0x10, 0x45, 0x49,
0xe0, 0x84, 0x6a, 0x38, 0x5a, 0x11, 0xa0, 0x01, 0x7e, 0x8d, 0xbc, 0x7e, 0x63, 0x12, 0xa1, 0x42, 0x82, 0x16, 0x01, 0x2b, 0xe2, 0xff, 0xbf, 0x11, 0x45, 0x09, 0x42, 0x79, 0x9b, 0xf3,
0x96, 0x41, 0xc4, 0x9a, 0x99, 0xbb, 0x39, 0x09, 0x5c, 0x02, 0x16, 0x66, 0xe4, 0x53, 0x51, 0x7f, 0x45, 0xe6, 0xd9, 0x34, 0xda, 0xde, 0x08, 0x70, 0xd9, 0x18, 0x42, 0x66, 0x1a, 0x69,
0x41, 0x22, 0x9c, 0xa6, 0x31, 0x72, 0x08, 0xa8, 0x01, 0x7e, 0x36, 0xc6, 0x78, 0x90, 0x08, 0x0e, 0x09, 0x4d, 0x08, 0xb4, 0xdb, 0x37, 0x3a, 0x55, 0x2e, 0x97, 0x0d, 0xdd, 0x6a, 0xfe,
0x48, 0x81, 0x4f, 0x49, 0xfe, 0x0a, 0x3c, 0x36, 0x7c, 0x6b, 0x12, 0x50, 0x02, 0x16, 0x41, 0xe4, 0x63, 0x51, 0x9f, 0x7c, 0x7d, 0x7d, 0x99, 0x86, 0x63, 0x01, 0x9f, 0x77, 0xb4, 0xba,
0x13, 0x24, 0x78, 0x06, 0x11, 0xaa, 0x24, 0x0c, 0xca, 0x2d, 0xae, 0x04, 0xfc, 0xf7, 0xed, 0xd8, 0xe3, 0xaf, 0x88, 0xa0, 0x3f, 0x95, 0x09, 0x58, 0x14, 0xe6, 0x38, 0x9e, 0x46, 0x00,
0x92, 0x2c, 0x68, 0xbe, 0xd0, 0x18, 0x04, 0xaf, 0xb1, 0x05, 0xe0, 0xdf, 0x81, 0x4e, 0x97, 0xbf, 0xeb, 0xe3, 0x73, 0x02, 0xda, 0x26, 0xee, 0x77, 0xad, 0xc9, 0xd0, 0x24, 0x60, 0x11,
0xc6, 0x30, 0x45, 0x60, 0xb5, 0x08, 0x40, 0xc0, 0xbf, 0x12, 0xe0, 0xcd, 0x05, 0xf0, 0xf4, 0x36, 0xc7, 0x14, 0x51, 0x82, 0x36, 0x02, 0x32, 0x8e, 0xde, 0x08, 0x58, 0x98, 0xa0, 0x2d,
0xc0, 0x95, 0x84, 0x95, 0x59, 0x82, 0x97, 0x52, 0x02, 0x16, 0x01, 0xf3, 0xaf, 0x4b, 0x34, 0xaf, 0x51, 0xbf, 0x02, 0x03, 0xb0, 0xab, 0x49, 0x82, 0x06, 0x01, 0x4b, 0x21, 0x70, 0x14,
0x9e, 0x12, 0xff, 0xa7, 0x48, 0xb0, 0x77, 0x2a, 0x80, 0x92, 0x7e, 0xcc, 0xe5, 0x63, 0x20, 0x4d, 0x42, 0x01, 0x14, 0x74, 0x15, 0x22, 0x4a, 0x09, 0x40, 0xc1, 0x53, 0xf7, 0xa1, 0xd1,
0x09, 0xb9, 0xca, 0xc3, 0x52, 0xc1, 0x50, 0x18, 0x7d, 0x4b, 0x94, 0xba, 0x58, 0xbe, 0x5f, 0x41, 0x4f, 0x89, 0xdb, 0x77, 0xbd, 0x10, 0x80, 0x4a, 0xde, 0x0a, 0x14, 0xe0, 0x84, 0x6a,
0x29, 0x12, 0x90, 0x54, 0x68, 0xe2, 0x01, 0xa9, 0x31, 0x67, 0x22, 0x9b, 0x03, 0x9e, 0x52, 0xcb, 0x75, 0x4e, 0x24, 0x38, 0x5a, 0x11, 0xa0, 0x01, 0x7e, 0x8d, 0xbc, 0x7e, 0x63, 0x12,
0x15, 0xac, 0x36, 0x01, 0x36, 0x23, 0xbb, 0xf7, 0xe8, 0xc7, 0x0c, 0xcf, 0x10, 0x60, 0x29, 0x52, 0x26, 0xa2, 0x3c, 0xa1, 0x42, 0x82, 0x16, 0x01, 0x96, 0x41, 0xc4, 0x9a, 0x99, 0xbb,
0x16, 0xed, 0x56, 0x0d, 0xc2, 0xda, 0x9f, 0x32, 0x3e, 0x29, 0x78, 0x8e, 0xb2, 0xe6, 0x4c, 0x6f, 0xc0, 0xee, 0x0b, 0x39, 0x09, 0x5c, 0x02, 0x16, 0x66, 0xe4, 0x53, 0x51, 0x7f, 0x45,
0xb8, 0x29, 0x60, 0x41, 0xe3, 0x2b, 0x01, 0x3f, 0x31, 0x53, 0xa1, 0x48, 0x05, 0x03, 0x53, 0xfe, 0x68, 0xf4, 0x0d, 0xe6, 0xd9, 0x41, 0x22, 0x9c, 0xa6, 0x31, 0x72, 0x08, 0xa8, 0x01,
0xe0, 0x03, 0xc6, 0x18, 0x33, 0x0a, 0x48, 0xa0, 0x54, 0x50, 0x6c, 0x82, 0x4b, 0x85, 0xe8, 0xe7, 0xc0, 0x8f, 0x09, 0x7e, 0x36, 0xc6, 0x78, 0x90, 0x08, 0x0e, 0x09, 0x4d, 0x08, 0x48,
0x22, 0x26, 0x66, 0xea, 0x89, 0xda, 0xe3, 0xd2, 0x2a, 0x50, 0x12, 0x7d, 0x54, 0x0d, 0x57, 0x52, 0x67, 0xe2, 0xfd, 0x81, 0x4f, 0x49, 0xfe, 0x0a, 0x3c, 0x36, 0x7c, 0x6b, 0x12, 0x50,
0x6e, 0x2f, 0x83, 0x14, 0xe8, 0x31, 0x03, 0x76, 0x14, 0x92, 0xb7, 0x12, 0x4b, 0x72, 0x31, 0x01, 0x16, 0x94, 0xff, 0x02, 0x16, 0x41, 0xe4, 0x63, 0x51, 0x9f, 0x13, 0x24, 0x78, 0x06,
0x4c, 0xd4, 0x73, 0x24, 0xca, 0x1c, 0x52, 0xa5, 0x66, 0xb8, 0x68, 0x2a, 0xe0, 0x55, 0x49, 0x3d, 0x94, 0x0a, 0x28, 0x11, 0xaa, 0x24, 0x0c, 0xca, 0x2d, 0xae, 0x04, 0xfc, 0xf7, 0xed,
0x33, 0x64, 0x99, 0xf8, 0x50, 0x58, 0xff, 0x73, 0xdd, 0x9b, 0x66, 0xf4, 0x29, 0xf0, 0xc8, 0xce, 0x14, 0x3b, 0x05, 0xd8, 0xe3, 0xaf, 0x88, 0x92, 0x2c, 0x68, 0xbe, 0xd0, 0x18, 0x04,
0x90, 0x09, 0x38, 0x46, 0x74, 0x2a, 0x7a, 0xca, 0xa4, 0xa5, 0x46, 0x4e, 0x1f, 0x60, 0x13, 0x52, 0x9b, 0x19, 0xe6, 0xaf, 0xb1, 0x05, 0xe0, 0xdf, 0x81, 0x4e, 0x97, 0xbf, 0xeb, 0xe3,
0x27, 0x4d, 0x83, 0x6a, 0x63, 0xa8, 0x94, 0xff, 0x1a, 0xf2, 0x47, 0x5f, 0xc3, 0xf5, 0x81, 0x25, 0x45, 0x00, 0x37, 0x73, 0xc6, 0x30, 0x45, 0x60, 0xb5, 0x08, 0x40, 0xc0, 0xbf, 0x12,
0xff, 0x6b, 0x44, 0x9e, 0xe3, 0x31, 0x2a, 0x3e, 0xc0, 0x55, 0xc0, 0x5a, 0xe0, 0x01, 0xb5, 0x87, 0xa8, 0x1c, 0x0e, 0xe0, 0xcd, 0x05, 0xf0, 0xf4, 0x36, 0xc7, 0x14, 0x51, 0xc0, 0x95,
0xcc, 0xfa, 0x2f, 0x6d, 0x7e, 0x6a, 0x37, 0x5b, 0x73, 0x4b, 0x0f, 0x78, 0x11, 0xf2, 0xd7, 0x24, 0x62, 0x14, 0x80, 0x84, 0x95, 0x59, 0x82, 0x97, 0x52, 0x02, 0x16, 0x01, 0xf3, 0xaf,
0x5f, 0x6b, 0x11, 0xb0, 0x0a, 0xa2, 0x3f, 0x56, 0x8c, 0x3a, 0x55, 0x0e, 0x21, 0x15, 0x0f, 0x40, 0xfd, 0xb7, 0x8c, 0x4b, 0x34, 0xaf, 0x51, 0xbf, 0x02, 0x9e, 0x12, 0xff, 0xa7, 0x48,
0x1e, 0x60, 0x32, 0x0f, 0x1b, 0x43, 0xa6, 0x02, 0x58, 0x81, 0xfc, 0x6b, 0x44, 0x7f, 0x04, 0xab, 0xc1, 0x2c, 0x49, 0xb0, 0x77, 0x2a, 0x80, 0x92, 0x7e, 0xcc, 0xe5, 0x63, 0x20, 0x4d,
0x83, 0x5a, 0xab, 0xc1, 0xb1, 0x93, 0xf9, 0x48, 0x35, 0x7f, 0x13, 0x70, 0x30, 0xf3, 0x5f, 0xb2, 0x01, 0xd2, 0xaa, 0x42, 0x01, 0x14, 0x09, 0xb9, 0xca, 0xc3, 0x52, 0xc1, 0x50, 0x18,
0x1a, 0xb0, 0x3e, 0x4a, 0x1b, 0x88, 0x26, 0xc8, 0x66, 0xea, 0xac, 0xd4, 0xf8, 0x90, 0xcf, 0x07, 0xa8, 0x79, 0xd5, 0x7d, 0x4b, 0x94, 0xba, 0x58, 0xbe, 0x5f, 0x41, 0x4f, 0x89, 0xdb,
0x48, 0xff, 0x8f, 0xb9, 0x10, 0x2a, 0xdd, 0xf5, 0xa9, 0x65, 0x98, 0xdf, 0x73, 0xf9, 0x8b, 0x6a, 0x37, 0x29, 0x01, 0x29, 0x12, 0x90, 0x54, 0x68, 0xe2, 0x01, 0xa9, 0x31, 0x67, 0x22,
0x5c, 0xf9, 0x6b, 0x01, 0xbd, 0x3e, 0x37, 0x44, 0x54, 0x70, 0xbe, 0x3d, 0x37, 0x64, 0x7a, 0x95, 0x5d, 0x62, 0x82, 0x9b, 0x03, 0x9e, 0x52, 0xcb, 0x75, 0x4e, 0x24, 0x15, 0xac, 0x36,
0xb6, 0x30, 0x7a, 0x31, 0xf9, 0x87, 0x4a, 0xb9, 0x1f, 0x12, 0xd7, 0x32, 0x97, 0x6c, 0x88, 0xe4, 0xf2, 0x7f, 0x06, 0x01, 0x36, 0x23, 0xbb, 0xf7, 0xe8, 0xc7, 0x0c, 0xcf, 0x10, 0x60,
0xca, 0x91, 0xb6, 0xd4, 0xa7, 0x0c, 0xc9, 0x31, 0x1f, 0x61, 0x77, 0x85, 0xdc, 0x32, 0x38, 0xdf, 0x98, 0xe7, 0xa5, 0x29, 0x52, 0x26, 0xa2, 0x3c, 0x16, 0xed, 0x56, 0x0d, 0xc2, 0xda,
0xf3, 0x5b, 0x0d, 0x02, 0x24, 0x0d, 0x4b, 0x0d, 0x90, 0xd4, 0x7b, 0xcd, 0xc0, 0xea, 0x70, 0x41, 0x5a, 0xe1, 0x95, 0x9f, 0x32, 0x3e, 0x29, 0x78, 0x8e, 0xb2, 0xe6, 0x4c, 0x6f, 0xc0,
0xb8, 0xa0, 0x1e, 0x5b, 0xdf, 0x99, 0xc0, 0x64, 0xb9, 0x0a, 0x78, 0x01, 0x51, 0x19, 0xcd, 0x43, 0xc7, 0x60, 0xb0, 0xee, 0x0b, 0xb8, 0x29, 0x60, 0x41, 0xe3, 0x2b, 0x01, 0x3f, 0x31,
0x9d, 0xa0, 0xbb, 0x73, 0x1f, 0x35, 0xc3, 0x89, 0xb9, 0x8a, 0x25, 0x37, 0x44, 0x7a, 0x5a, 0xed, 0x55, 0xa9, 0x36, 0x53, 0xa1, 0x48, 0x05, 0x03, 0x53, 0xfe, 0x68, 0xf4, 0x0d, 0xe0,
0x43, 0x06, 0xf4, 0x4a, 0xa8, 0x60, 0xea, 0x90, 0x24, 0xae, 0x11, 0x8a, 0xaa, 0x40, 0x4f, 0xf9, 0x3f, 0x82, 0xcd, 0x03, 0xc6, 0x18, 0x33, 0x0a, 0x48, 0xa0, 0x54, 0x50, 0x6c, 0x82,
0x50, 0x76, 0x35, 0x78, 0x30, 0x0d, 0xb0, 0xf7, 0x31, 0x49, 0x53, 0x40, 0xcb, 0x00, 0xbb, 0x01, 0xa7, 0xd9, 0x08, 0x4b, 0x85, 0xe8, 0xe7, 0xc0, 0x8f, 0x09, 0x22, 0x26, 0x66, 0xea,
0x3d, 0x25, 0xff, 0xd9, 0xef, 0xcf, 0x59, 0x0c, 0x21, 0x1d, 0x59, 0xaf, 0x2a, 0x58, 0x35, 0x4c, 0x30, 0x74, 0x92, 0x89, 0xda, 0xe3, 0xd2, 0x2a, 0x50, 0x12, 0x7d, 0x54, 0x0d, 0x57,
0x06, 0xaa, 0xd7, 0x31, 0x34, 0xca, 0xbf, 0x3b, 0x15, 0xf0, 0xd2, 0x2e, 0x83, 0x3f, 0x6a, 0xfc, 0x74, 0x02, 0xe6, 0x52, 0x67, 0xe2, 0xfd, 0x6e, 0x2f, 0x83, 0x14, 0xe8, 0x31, 0x03,
0xdf, 0x4e, 0xc0, 0xaf, 0x57, 0x80, 0xff, 0x28, 0x40, 0x91, 0x80, 0xa7, 0x96, 0xc1, 0xfd, 0xb7, 0x97, 0x41, 0x96, 0x76, 0x14, 0x92, 0xb7, 0x12, 0x4b, 0x72, 0x31, 0x01, 0x16, 0x94,
0x02, 0x1c, 0x93, 0xf9, 0xf3, 0x01, 0x0a, 0x30, 0x26, 0xf3, 0x01, 0x09, 0xaa, 0x00, 0x0f, 0x5e, 0x44, 0x78, 0x58, 0xff, 0x4c, 0xd4, 0x73, 0x24, 0xca, 0x1c, 0x52, 0xa5, 0x66, 0xb8,
0x7a, 0x40, 0x04, 0x78, 0xd3, 0xcf, 0x28, 0x21, 0xd8, 0xa5, 0x08, 0x58, 0xa4, 0x06, 0xd2, 0xe9, 0x08, 0xda, 0x0a, 0x68, 0x2a, 0xe0, 0x55, 0x49, 0x3d, 0x94, 0x0a, 0x28, 0x33, 0x64,
0xa0, 0xde, 0xe0, 0xbc, 0x11, 0xec, 0x99, 0xb8, 0x26, 0x8f, 0xaa, 0x60, 0xc8, 0x3c, 0xb8, 0x3d, 0xd4, 0x07, 0xde, 0x99, 0xf8, 0x50, 0x58, 0xff, 0x73, 0xdd, 0x9b, 0x66, 0xf4, 0x29,
0xaf, 0x77, 0x97, 0x2a, 0xc0, 0x75, 0x08, 0x2e, 0xd4, 0xf0, 0x07, 0x6a, 0x4f, 0x50, 0x6a, 0x84, 0xa1, 0x01, 0xf8, 0xf0, 0xc8, 0xce, 0x14, 0x3b, 0x05, 0x90, 0x09, 0x38, 0x46, 0x74,
0x98, 0xfc, 0x03, 0xa7, 0x04, 0xa2, 0x1e, 0xb0, 0x77, 0xee, 0x03, 0xea, 0xad, 0xb0, 0x23, 0xd8, 0x0b, 0x1d, 0xe6, 0x2a, 0x7a, 0xca, 0xa4, 0xa5, 0x46, 0x4e, 0x1f, 0x60, 0x13, 0x52,
0x3b, 0xa5, 0xd6, 0xe4, 0x0f, 0x2d, 0x68, 0x2e, 0x86, 0xce, 0x4a, 0x69, 0x10, 0x04, 0xef, 0x85, 0x18, 0xe0, 0x21, 0x9b, 0x19, 0xe6, 0x27, 0x4d, 0x83, 0x6a, 0x63, 0xa8, 0x94, 0xff,
0x21, 0xe0, 0x6e, 0x2f, 0x28, 0x99, 0xdf, 0x71, 0x3d, 0xc0, 0x5d, 0x7c, 0x20, 0x55, 0x06, 0x43, 0x45, 0x12, 0x50, 0x1a, 0xf2, 0x47, 0x5f, 0xc3, 0xf5, 0x81, 0x25, 0x45, 0x00, 0x37,
0xf3, 0xfb, 0xbe, 0xed, 0x39, 0x06, 0xc8, 0x5d, 0x0c, 0x21, 0xa0, 0xce, 0x86, 0xab, 0xc8, 0x09, 0x6c, 0x82, 0xb2, 0xff, 0x6b, 0x44, 0x9e, 0xe3, 0x31, 0x2a, 0x3e, 0xc0, 0x55, 0xc0,
0x98, 0x90, 0x6f, 0x89, 0x6d, 0xe6, 0xdf, 0x7d, 0x75, 0x6f, 0xfe, 0xee, 0xb5, 0x05, 0x00, 0x60, 0x60, 0x10, 0x12, 0x5a, 0xe0, 0x01, 0xb5, 0x87, 0xa8, 0x1c, 0x0e, 0xcc, 0xfa, 0x2f,
0x18, 0x3e, 0x13, 0x34, 0x5a, 0x78, 0x6e, 0x23, 0xe4, 0x15, 0x65, 0x1e, 0xde, 0xfe, 0x34, 0xbc, 0x80, 0x2d, 0xff, 0x6d, 0x7e, 0x6a, 0x37, 0x5b, 0x73, 0x4b, 0x0f, 0x78, 0x11, 0xf2,
0x77, 0x02, 0x0e, 0xd0, 0x07, 0xa4, 0x69, 0x10, 0x03, 0x4e, 0xdd, 0x87, 0x44, 0xbf, 0x98, 0x3c, 0xea, 0xab, 0xb2, 0xd7, 0x24, 0x62, 0x14, 0x80, 0x5f, 0x6b, 0x11, 0xb0, 0x0a, 0xa2,
0xc8, 0xba, 0x40, 0xed, 0x62, 0x14, 0x8c, 0x32, 0x55, 0xfe, 0x9c, 0xe6, 0x6a, 0x50, 0xd2, 0x13, 0xdc, 0x35, 0x1f, 0x3f, 0x56, 0x8c, 0x3a, 0x55, 0x0e, 0x21, 0x15, 0x0f, 0x40, 0xfd,
0xf9, 0xeb, 0x73, 0xb9, 0x14, 0x70, 0x09, 0x73, 0xf1, 0x60, 0xee, 0x9f, 0x95, 0xc0, 0x87, 0x44, 0xe4, 0x3d, 0x37, 0xb7, 0x8c, 0x1e, 0x60, 0x32, 0x0f, 0x1b, 0x43, 0xa6, 0x02, 0x58,
0xff, 0x91, 0x56, 0x98, 0x6b, 0x88, 0x3d, 0xb6, 0xc6, 0x6a, 0x1b, 0x22, 0x9b, 0x52, 0x5f, 0xa0, 0xd9, 0xf9, 0x85, 0x81, 0xfc, 0x6b, 0x44, 0x7f, 0x04, 0xab, 0xc1, 0x2c, 0x49, 0x83,
0x4c, 0xf9, 0x73, 0x89, 0x7f, 0x8b, 0x3d, 0x80, 0x4a, 0x83, 0xd0, 0x20, 0xf7, 0x43, 0x46, 0x89, 0x9b, 0x86, 0x02, 0x5a, 0xab, 0xc1, 0xb1, 0x93, 0xf9, 0x48, 0x35, 0x7f, 0x13, 0x70,
0x20, 0xf6, 0x6e, 0x96, 0x7f, 0x28, 0x58, 0xa3, 0x88, 0x15, 0xb0, 0x15, 0x2e, 0x8e, 0x6a, 0x0e, 0xce, 0x06, 0xee, 0x30, 0xf3, 0x5f, 0xb2, 0x01, 0xd2, 0xaa, 0x1a, 0xb0, 0x3e, 0x4a,
0x11, 0x23, 0x80, 0xfb, 0x8b, 0xac, 0xad, 0xab, 0x41, 0x60, 0x44, 0x1e, 0x56, 0xee, 0x50, 0x89, 0x6d, 0x8d, 0x1d, 0x1b, 0x88, 0x26, 0xc8, 0x66, 0xea, 0xac, 0xd4, 0xf8, 0x90, 0xcf,
0xa3, 0x53, 0x10, 0x88, 0x0d, 0xe8, 0x07, 0x0e, 0x2e, 0x01, 0x57, 0x36, 0xb7, 0x06, 0x4a, 0x68, 0xb6, 0xc5, 0x86, 0x07, 0xa8, 0x79, 0xd5, 0x48, 0xff, 0x8f, 0xb9, 0x10, 0x2a, 0xdd,
0xee, 0x07, 0x68, 0x6c, 0x90, 0x8c, 0x0a, 0xf2, 0x47, 0xca, 0x5f, 0x11, 0x01, 0x87, 0x62, 0x8e, 0xd6, 0xd8, 0x38, 0xf5, 0xa9, 0x65, 0x98, 0xdf, 0x73, 0xf9, 0x8b, 0x6a, 0x37, 0x29,
0x55, 0xcd, 0xff, 0xd2, 0xb5, 0x40, 0xad, 0x8f, 0xcd, 0x4e, 0x46, 0xf4, 0xb9, 0xf9, 0xcf, 0x26, 0xc0, 0x01, 0x3e, 0x01, 0x5c, 0xf9, 0x6b, 0x01, 0xbd, 0x3e, 0x37, 0x44, 0x54, 0x70,
0xf0, 0xde, 0x87, 0x53, 0x52, 0x3d, 0x2b, 0x44, 0x5f, 0x54, 0xfe, 0x6a, 0xaf, 0x06, 0x29, 0x33, 0x3c, 0x85, 0xd1, 0xbe, 0x3d, 0x37, 0x64, 0x7a, 0x95, 0x5d, 0x62, 0x82, 0xb6, 0x30,
0xa7, 0xfa, 0x13, 0x96, 0xfc, 0x35, 0x08, 0xd8, 0x81, 0x9c, 0x0c, 0x42, 0xe9, 0xa7, 0xfc, 0xc5, 0x6b, 0x36, 0x61, 0x7a, 0x31, 0xf9, 0x87, 0x4a, 0xb9, 0x1f, 0x12, 0xd7, 0x32, 0x97,
0x03, 0x22, 0x13, 0x30, 0x0d, 0xb8, 0x1b, 0x24, 0x27, 0xa1, 0x88, 0x20, 0xf4, 0x21, 0x87, 0xe6, 0x3f, 0xb7, 0x0f, 0x6c, 0x88, 0xe4, 0xf2, 0x7f, 0x06, 0xca, 0x91, 0xb6, 0xd4, 0xa7,
0xa8, 0xa1, 0x02, 0x64, 0xb1, 0x43, 0x75, 0x80, 0x1b, 0x57, 0xf6, 0x25, 0x29, 0x50, 0xa2, 0x82, 0x20, 0xf0, 0x8f, 0x0c, 0xc9, 0x31, 0x1f, 0x61, 0x77, 0x85, 0xdc, 0x32, 0x38, 0xdf,
0xeb, 0x3c, 0x52, 0xf3, 0x4b, 0x2a, 0x7b, 0xe0, 0x3c, 0x99, 0xa9, 0x82, 0x12, 0x12, 0x72, 0x4d, 0x97, 0x07, 0xcd, 0x98, 0xe7, 0xa5, 0xf3, 0x5b, 0x0d, 0x02, 0x24, 0x0d, 0x4b, 0x0d,
0x4f, 0xb5, 0x0f, 0x70, 0x80, 0x0a, 0xf6, 0xc8, 0x45, 0x72, 0x48, 0x08, 0x0c, 0xe9, 0xab, 0x44, 0xbf, 0x56, 0x19, 0x90, 0xd4, 0x7b, 0xcd, 0xc0, 0xea, 0x70, 0x41, 0x5a, 0xe1, 0x95,
0x44, 0xbe, 0x49, 0x12, 0x08, 0x52, 0x10, 0xe9, 0xe7, 0x72, 0x5f, 0xa5, 0x0c, 0x1e, 0xc0, 0xa4, 0x31, 0x15, 0xa4, 0xb8, 0xa0, 0x1e, 0x5b, 0xdf, 0x99, 0xc0, 0x64, 0xb9, 0x0a, 0x78,
0x1a, 0x24, 0xe4, 0xf3, 0x80, 0x90, 0x01, 0x4f, 0x75, 0x7d, 0x4d, 0x4c, 0x30, 0x97, 0x12, 0x1b, 0x51, 0x0d, 0x42, 0x01, 0x51, 0x19, 0xcd, 0x43, 0xc7, 0x60, 0xb0, 0x9d, 0xa0, 0xbb,
0x02, 0x74, 0xce, 0xfc, 0x3c, 0x21, 0x7d, 0x24, 0xf7, 0x8f, 0x12, 0x02, 0x0e, 0x01, 0xcb, 0xfb, 0x45, 0x01, 0xa9, 0x73, 0x1f, 0x35, 0xc3, 0x89, 0xb9, 0x8a, 0x25, 0x37, 0x44, 0x7a,
0x56, 0x39, 0x24, 0xa2, 0x4e, 0x81, 0x2f, 0x2a, 0x7b, 0x9a, 0x1e, 0xe0, 0x88, 0x54, 0xd8, 0x13, 0x40, 0x02, 0x60, 0x5a, 0xed, 0x55, 0xa9, 0x36, 0x43, 0x06, 0xf4, 0x4a, 0xa8, 0x60,
0x8e, 0x14, 0x78, 0xb4, 0xf1, 0x39, 0x6a, 0x10, 0xe0, 0x18, 0xa9, 0x10, 0x23, 0x21, 0xe6, 0x0b, 0x21, 0xf2, 0xb8, 0xea, 0x90, 0x24, 0xae, 0x11, 0x8a, 0xaa, 0x40, 0x4f, 0xf9, 0x3f,
0x07, 0xbb, 0xbd, 0xea, 0x0a, 0x38, 0x0a, 0xfd, 0x60, 0x8f, 0xf8, 0x42, 0xec, 0x50, 0x15, 0x4f, 0x94, 0xbb, 0x0d, 0x82, 0xcd, 0x50, 0x76, 0x35, 0x78, 0x30, 0x0d, 0xb0, 0xf7, 0x31,
0x0c, 0x00, 0x6b, 0x7c, 0x8e, 0xd9, 0xf9, 0x1c, 0xb4, 0xf4, 0x39, 0x6a, 0xeb, 0x73, 0xd8, 0x9a, 0x06, 0x01, 0x08, 0x49, 0x53, 0x40, 0xcb, 0x00, 0xbb, 0x01, 0xa7, 0xd9, 0x08, 0x3d,
0xf0, 0x1f, 0x73, 0xdc, 0x9e, 0x16, 0x09, 0xe8, 0xfe, 0x43, 0x77, 0x07, 0x2e, 0x72, 0x3d, 0x01, 0xb9, 0xef, 0x71, 0x25, 0xff, 0xd9, 0xef, 0xcf, 0x59, 0x0c, 0x21, 0x1d, 0x59, 0xaf,
0x47, 0x6e, 0x4a, 0x48, 0x40, 0x15, 0xc0, 0x5d, 0xe1, 0xdd, 0x4e, 0x00, 0x27, 0x25, 0x72, 0xf7, 0x3f, 0xf6, 0xd8, 0x2a, 0x58, 0x35, 0x4c, 0x30, 0x74, 0x92, 0x06, 0xaa, 0xd7, 0x31,
0x5d, 0x8a, 0x04, 0x6e, 0xf4, 0x91, 0xce, 0xae, 0xbb, 0x83, 0x97, 0x39, 0x44, 0xe4, 0xc8, 0x78, 0xf4, 0xd1, 0xdb, 0x34, 0xca, 0xbf, 0x3b, 0x15, 0xf0, 0xd2, 0x2e, 0x83, 0x3f, 0x6a,
0x52, 0x32, 0x4c, 0x6b, 0xd0, 0x2d, 0x09, 0x90, 0x12, 0x72, 0xb4, 0xba, 0xa0, 0xff, 0x07, 0x00, 0x48, 0x04, 0x71, 0xfc, 0x74, 0x02, 0xe6, 0xdf, 0x4e, 0xc0, 0xaf, 0x57, 0x80, 0xff,
0x83, 0x9e, 0xcc, 0x51, 0xce, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82}; 0x28, 0x40, 0x91, 0x80, 0xa7, 0x96, 0xc1, 0xfd, 0xb7, 0x97, 0x41,
0x96, 0x02, 0x1c, 0x93, 0xf9, 0xf3, 0x01, 0x0a, 0x30, 0x26, 0xf3,
0x01, 0x09, 0xaa, 0x00, 0x0f, 0x5e, 0x44, 0x78, 0x58, 0x7a, 0x40,
0x04, 0x78, 0xd3, 0xcf, 0x28, 0x21, 0xd8, 0xa5, 0x08, 0x58, 0xa4,
0x06, 0xd2, 0xe9, 0x08, 0xda, 0x0a, 0xa0, 0xde, 0xe0, 0xbc, 0x11,
0xec, 0x99, 0xb8, 0x26, 0x8f, 0xaa, 0x60, 0xc8, 0x3c, 0xb8, 0x3d,
0xd4, 0x07, 0xde, 0xaf, 0x77, 0x97, 0x2a, 0xc0, 0x75, 0x08, 0x2e,
0xd4, 0xf0, 0x07, 0x6a, 0x4f, 0x50, 0x6a, 0x84, 0xa1, 0x01, 0xf8,
0x98, 0xfc, 0x03, 0xa7, 0x04, 0xa2, 0x1e, 0xb0, 0x77, 0xee, 0x03,
0xea, 0xad, 0xb0, 0x23, 0xd8, 0x0b, 0x1d, 0xe6, 0x3b, 0xa5, 0xd6,
0xe4, 0x0f, 0x2d, 0x68, 0x2e, 0x86, 0xce, 0x4a, 0x69, 0x10, 0x04,
0xef, 0x85, 0x18, 0xe0, 0x21, 0x21, 0xe0, 0x6e, 0x2f, 0x28, 0x99,
0xdf, 0x71, 0x3d, 0xc0, 0x5d, 0x7c, 0x20, 0x55, 0x06, 0x43, 0x45,
0x12, 0x50, 0xf3, 0xfb, 0xbe, 0xed, 0x39, 0x06, 0xc8, 0x5d, 0x0c,
0x21, 0xa0, 0xce, 0x86, 0xab, 0xc8, 0x09, 0x6c, 0x82, 0xb2, 0x98,
0x90, 0x6f, 0x89, 0x6d, 0xe6, 0xdf, 0x7d, 0x75, 0x6f, 0xfe, 0xee,
0xb5, 0x05, 0x00, 0x60, 0x60, 0x10, 0x12, 0x18, 0x3e, 0x13, 0x34,
0x5a, 0x78, 0x6e, 0x23, 0xe4, 0x15, 0x65, 0x1e, 0xde, 0xfe, 0x34,
0xbc, 0x80, 0x2d, 0xff, 0x77, 0x02, 0x0e, 0xd0, 0x07, 0xa4, 0x69,
0x10, 0x03, 0x4e, 0xdd, 0x87, 0x44, 0xbf, 0x98, 0x3c, 0xea, 0xab,
0xb2, 0xc8, 0xba, 0x40, 0xed, 0x62, 0x14, 0x8c, 0x32, 0x55, 0xfe,
0x9c, 0xe6, 0x6a, 0x50, 0xd2, 0x13, 0xdc, 0x35, 0x1f, 0xf9, 0xeb,
0x73, 0xb9, 0x14, 0x70, 0x09, 0x73, 0xf1, 0x60, 0xee, 0x9f, 0x95,
0xc0, 0x87, 0x44, 0xe4, 0x3d, 0x37, 0xff, 0x91, 0x56, 0x98, 0x6b,
0x88, 0x3d, 0xb6, 0xc6, 0x6a, 0x1b, 0x22, 0x9b, 0x52, 0x5f, 0xa0,
0xd9, 0xf9, 0x85, 0x4c, 0xf9, 0x73, 0x89, 0x7f, 0x8b, 0x3d, 0x80,
0x4a, 0x83, 0xd0, 0x20, 0xf7, 0x43, 0x46, 0x89, 0x9b, 0x86, 0x02,
0x20, 0xf6, 0x6e, 0x96, 0x7f, 0x28, 0x58, 0xa3, 0x88, 0x15, 0xb0,
0x15, 0x2e, 0x8e, 0x6a, 0x0e, 0xce, 0x06, 0xee, 0x11, 0x23, 0x80,
0xfb, 0x8b, 0xac, 0xad, 0xab, 0x41, 0x60, 0x44, 0x1e, 0x56, 0xee,
0x50, 0x89, 0x6d, 0x8d, 0x1d, 0xa3, 0x53, 0x10, 0x88, 0x0d, 0xe8,
0x07, 0x0e, 0x2e, 0x01, 0x57, 0x36, 0xb7, 0x06, 0x4a, 0x68, 0xb6,
0xc5, 0x86, 0xee, 0x07, 0x68, 0x6c, 0x90, 0x8c, 0x0a, 0xf2, 0x47,
0xca, 0x5f, 0x11, 0x01, 0x87, 0x62, 0x8e, 0xd6, 0xd8, 0x38, 0x55,
0xcd, 0xff, 0xd2, 0xb5, 0x40, 0xad, 0x8f, 0xcd, 0x4e, 0x46, 0xf4,
0xb9, 0xf9, 0xcf, 0x26, 0xc0, 0x01, 0x3e, 0xf0, 0xde, 0x87, 0x53,
0x52, 0x3d, 0x2b, 0x44, 0x5f, 0x54, 0xfe, 0x6a, 0xaf, 0x06, 0x29,
0x33, 0x3c, 0x85, 0xd1, 0xa7, 0xfa, 0x13, 0x96, 0xfc, 0x35, 0x08,
0xd8, 0x81, 0x9c, 0x0c, 0x42, 0xe9, 0xa7, 0xfc, 0xc5, 0x6b, 0x36,
0x61, 0x03, 0x22, 0x13, 0x30, 0x0d, 0xb8, 0x1b, 0x24, 0x27, 0xa1,
0x88, 0x20, 0xf4, 0x21, 0x87, 0xe6, 0x3f, 0xb7, 0x0f, 0xa8, 0xa1,
0x02, 0x64, 0xb1, 0x43, 0x75, 0x80, 0x1b, 0x57, 0xf6, 0x25, 0x29,
0x50, 0xa2, 0x82, 0x20, 0xf0, 0x8f, 0xeb, 0x3c, 0x52, 0xf3, 0x4b,
0x2a, 0x7b, 0xe0, 0x3c, 0x99, 0xa9, 0x82, 0x12, 0x12, 0x72, 0x4d,
0x97, 0x07, 0xcd, 0x4f, 0xb5, 0x0f, 0x70, 0x80, 0x0a, 0xf6, 0xc8,
0x45, 0x72, 0x48, 0x08, 0x0c, 0xe9, 0xab, 0x44, 0xbf, 0x56, 0x19,
0x44, 0xbe, 0x49, 0x12, 0x08, 0x52, 0x10, 0xe9, 0xe7, 0x72, 0x5f,
0xa5, 0x0c, 0x1e, 0xc0, 0xa4, 0x31, 0x15, 0xa4, 0x1a, 0x24, 0xe4,
0xf3, 0x80, 0x90, 0x01, 0x4f, 0x75, 0x7d, 0x4d, 0x4c, 0x30, 0x97,
0x12, 0x1b, 0x51, 0x0d, 0x42, 0x02, 0x74, 0xce, 0xfc, 0x3c, 0x21,
0x7d, 0x24, 0xf7, 0x8f, 0x12, 0x02, 0x0e, 0x01, 0xcb, 0xfb, 0x45,
0x01, 0xa9, 0x56, 0x39, 0x24, 0xa2, 0x4e, 0x81, 0x2f, 0x2a, 0x7b,
0x9a, 0x1e, 0xe0, 0x88, 0x54, 0xd8, 0x13, 0x40, 0x02, 0x60, 0x8e,
0x14, 0x78, 0xb4, 0xf1, 0x39, 0x6a, 0x10, 0xe0, 0x18, 0xa9, 0x10,
0x23, 0x21, 0xe6, 0x0b, 0x21, 0xf2, 0xb8, 0x07, 0xbb, 0xbd, 0xea,
0x0a, 0x38, 0x0a, 0xfd, 0x60, 0x8f, 0xf8, 0x42, 0xec, 0x50, 0x15,
0x4f, 0x94, 0xbb, 0x0d, 0x0c, 0x00, 0x6b, 0x7c, 0x8e, 0xd9, 0xf9,
0x1c, 0xb4, 0xf4, 0x39, 0x6a, 0xeb, 0x73, 0xd8, 0x9a, 0x06, 0x01,
0x08, 0xf0, 0x1f, 0x73, 0xdc, 0x9e, 0x16, 0x09, 0xe8, 0xfe, 0x43,
0x77, 0x07, 0x2e, 0x72, 0x3d, 0x01, 0xb9, 0xef, 0x71, 0x47, 0x6e,
0x4a, 0x48, 0x40, 0x15, 0xc0, 0x5d, 0xe1, 0xdd, 0x4e, 0x00, 0x27,
0x25, 0x72, 0xf7, 0x3f, 0xf6, 0xd8, 0x5d, 0x8a, 0x04, 0x6e, 0xf4,
0x91, 0xce, 0xae, 0xbb, 0x83, 0x97, 0x39, 0x44, 0xe4, 0xc8, 0x78,
0xf4, 0xd1, 0xdb, 0x52, 0x32, 0x4c, 0x6b, 0xd0, 0x2d, 0x09, 0x90,
0x12, 0x72, 0xb4, 0xba, 0xa0, 0xff, 0x07, 0x00, 0x48, 0x04, 0x71,
0x83, 0x9e, 0xcc, 0x51, 0xce, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45,
0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
Neon::Neon() Neon::Neon()
{ {
Events::processScriptsEvent += [this] { Events::processScriptsEvent += [this]
if (!m_pNeonTexture) {
{ if (!m_pNeonTexture)
m_pNeonTexture = Util::LoadTextureFromMemory((char *)neon_mask, sizeof(neon_mask)); {
} m_pNeonTexture = Util::LoadTextureFromMemory((char*)neon_mask, sizeof(neon_mask));
}; }
};
Events::vehicleRenderEvent += [](CVehicle *pVeh) { Events::vehicleRenderEvent += [](CVehicle* pVeh)
NeonData *data = &m_VehNeon.Get(pVeh); {
if (data->m_bNeonInstalled && !pVeh->IsUpsideDown()) NeonData* data = &m_VehNeon.Get(pVeh);
{ if (data->m_bNeonInstalled && !pVeh->IsUpsideDown())
CVector Pos = CModelInfo::GetModelInfo(pVeh->m_nModelIndex)->m_pColModel->m_boundBox.m_vecMin; {
CVector center = pVeh->TransformFromObjectSpace(CVector(0.0f, 0.0f, 0.0f)); CVector Pos = CModelInfo::GetModelInfo(pVeh->m_nModelIndex)->m_pColModel->m_boundBox.m_vecMin;
CVector up = pVeh->TransformFromObjectSpace(CVector(0.0f, -Pos.y - data->m_fVal, 0.0f)) - center; CVector center = pVeh->TransformFromObjectSpace(CVector(0.0f, 0.0f, 0.0f));
CVector right = pVeh->TransformFromObjectSpace(CVector(Pos.x + data->m_fVal, 0.0f, 0.0f)) - center; CVector up = pVeh->TransformFromObjectSpace(CVector(0.0f, -Pos.y - data->m_fVal, 0.0f)) - center;
CShadows::StoreShadowToBeRendered(5, m_pNeonTexture, &center, up.x, up.y, right.x, right.y, 180, CVector right = pVeh->TransformFromObjectSpace(CVector(Pos.x + data->m_fVal, 0.0f, 0.0f)) - center;
data->m_Color.r, data->m_Color.g, data->m_Color.b, 2.0f, false, 1.0f, 0, CShadows::StoreShadowToBeRendered(5, m_pNeonTexture, &center, up.x, up.y, right.x, right.y, 180, data->m_Color.r,
true); data->m_Color.g, data->m_Color.b, 2.0f, false, 1.0f, 0, true);
if (data->m_bPulsing) if (data->m_bPulsing)
{ {
size_t delta = CTimer::m_snTimeInMilliseconds - CTimer::m_snPreviousTimeInMilliseconds; size_t delta = CTimer::m_snTimeInMilliseconds - CTimer::m_snPreviousTimeInMilliseconds;
if (data->m_fVal < 0.0f) if (data->m_fVal < 0.0f)
{ {
data->m_bIncrement = true; data->m_bIncrement = true;
} }
if (data->m_fVal > 0.3f) if (data->m_fVal > 0.3f)
{ {
data->m_bIncrement = false; data->m_bIncrement = false;
} }
if (data->m_bIncrement) if (data->m_bIncrement)
{ {
data->m_fVal += 0.0003f * delta; data->m_fVal += 0.0003f * delta;
} }
else else
{ {
data->m_fVal -= 0.0003f * delta; data->m_fVal -= 0.0003f * delta;
} }
} }
} }
}; };
} }
Neon::~Neon() Neon::~Neon()
{ {
if (m_pNeonTexture) if (m_pNeonTexture)
{ {
RwTextureDestroy(m_pNeonTexture); RwTextureDestroy(m_pNeonTexture);
m_pNeonTexture = nullptr; m_pNeonTexture = nullptr;
} }
} }
bool Neon::IsNeonInstalled(CVehicle *pVeh) bool Neon::IsNeonInstalled(CVehicle* pVeh)
{ {
return m_VehNeon.Get(pVeh).m_bNeonInstalled; return m_VehNeon.Get(pVeh).m_bNeonInstalled;
} }
bool Neon::IsPulsingEnabled(CVehicle *pVeh) bool Neon::IsPulsingEnabled(CVehicle* pVeh)
{ {
return m_VehNeon.Get(pVeh).m_bPulsing; return m_VehNeon.Get(pVeh).m_bPulsing;
} }
void Neon::SetPulsing(CVehicle *pVeh, bool state) void Neon::SetPulsing(CVehicle* pVeh, bool state)
{ {
m_VehNeon.Get(pVeh).m_bPulsing = state; m_VehNeon.Get(pVeh).m_bPulsing = state;
} }
void Neon::InstallNeon(CVehicle *pVeh, int red, int green, int blue) void Neon::InstallNeon(CVehicle* pVeh, int red, int green, int blue)
{ {
CRGBA &color = m_VehNeon.Get(pVeh).m_Color; CRGBA& color = m_VehNeon.Get(pVeh).m_Color;
color.r = red; color.r = red;
color.g = green; color.g = green;
color.b = blue; color.b = blue;
color.a = 255; color.a = 255;
m_VehNeon.Get(pVeh).m_bNeonInstalled = true; m_VehNeon.Get(pVeh).m_bNeonInstalled = true;
} }
void Neon::RemoveNeon(CVehicle *pVeh) void Neon::RemoveNeon(CVehicle* pVeh)
{ {
m_VehNeon.Get(pVeh).m_bNeonInstalled = false; m_VehNeon.Get(pVeh).m_bNeonInstalled = false;
} }

View File

@ -4,32 +4,32 @@
class Neon class Neon
{ {
private: private:
class NeonData class NeonData
{ {
public: public:
CRGBA m_Color; CRGBA m_Color;
bool m_bNeonInstalled; bool m_bNeonInstalled;
float m_fVal; float m_fVal;
bool m_bIncrement; bool m_bIncrement;
bool m_bPulsing; bool m_bPulsing;
NeonData(CVehicle *pVeh) NeonData(CVehicle* pVeh)
{ {
m_bNeonInstalled = false; m_bNeonInstalled = false;
m_fVal = 0.0; m_fVal = 0.0;
m_bIncrement = true; m_bIncrement = true;
} }
}; };
static inline RwTexture *m_pNeonTexture = nullptr; // pointer to the neon mask texture static inline RwTexture* m_pNeonTexture = nullptr; // pointer to the neon mask texture
static inline VehicleExtendedData<NeonData> m_VehNeon; static inline VehicleExtendedData<NeonData> m_VehNeon;
public: public:
Neon(); Neon();
~Neon(); ~Neon();
static void InstallNeon(CVehicle *veh, int red, int green, int blue); static void InstallNeon(CVehicle* veh, int red, int green, int blue);
static bool IsNeonInstalled(CVehicle *veh); static bool IsNeonInstalled(CVehicle* veh);
static bool IsPulsingEnabled(CVehicle *veh); static bool IsPulsingEnabled(CVehicle* veh);
static void SetPulsing(CVehicle *veh, bool state); static void SetPulsing(CVehicle* veh, bool state);
static void RemoveNeon(CVehicle *veh); static void RemoveNeon(CVehicle* veh);
}; };

View File

@ -22,277 +22,279 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE. // SOFTWARE.
#include "pch.h"
#include "paint.h" #include "paint.h"
#include "NodeName.h" #include "NodeName.h"
#include "pch.h"
#include "util.h" #include "util.h"
Paint::Paint() Paint::Paint()
{ {
Events::vehicleRenderEvent.before += [](CVehicle *pVeh) { Events::vehicleRenderEvent.before += [](CVehicle* pVeh)
VehData &data = m_VehData.Get(pVeh); {
VehData& data = m_VehData.Get(pVeh);
// reset custom color if color id changed // reset custom color if color id changed
if (pVeh->m_nPrimaryColor != data.primary_color || pVeh->m_nSecondaryColor != data.secondary_color) if (pVeh->m_nPrimaryColor != data.primary_color
{ || pVeh->m_nSecondaryColor != data.secondary_color)
for (auto &it : data.materialProperties) {
data.resetMaterialColor(it.first); for (auto& it : data.materialProperties)
data.resetMaterialColor(it.first);
data.primary_color = pVeh->m_nPrimaryColor; data.primary_color = pVeh->m_nPrimaryColor;
data.secondary_color = pVeh->m_nSecondaryColor; data.secondary_color = pVeh->m_nSecondaryColor;
} }
for (auto &it : data.materialProperties) for (auto& it : data.materialProperties)
{ {
if (it.second._recolor) if (it.second._recolor)
{ {
it.second._originalColor = it.first->color; it.second._originalColor = it.first->color;
it.first->color = it.second._color; it.first->color = it.second._color;
it.second._originalGeometryFlags = it.second._geometry->flags; it.second._originalGeometryFlags = it.second._geometry->flags;
it.second._geometry->flags |= rpGEOMETRYMODULATEMATERIALCOLOR; it.second._geometry->flags |= rpGEOMETRYMODULATEMATERIALCOLOR;
} }
if (it.second._retexture) if (it.second._retexture)
{ {
auto tex = it.second._texture; auto tex = it.second._texture;
if (tex) if (tex)
{ {
it.second._originalTexture = it.first->texture; it.second._originalTexture = it.first->texture;
it.first->texture = tex; it.first->texture = tex;
} }
else else
{ {
it.second._retexture = false; it.second._retexture = false;
} }
} }
} }
}; };
ThiscallEvent<AddressList<0x55332A, H_CALL>, PRIORITY_BEFORE, ArgPickN<CVehicle *, 0>, void(CVehicle *)> ThiscallEvent<AddressList<0x55332A, H_CALL>, PRIORITY_BEFORE, ArgPickN<CVehicle*, 0>, void(CVehicle*)> vehicleResetAfterRender;
vehicleResetAfterRender; vehicleResetAfterRender += [](CVehicle* pVeh)
vehicleResetAfterRender += [](CVehicle *pVeh) { {
for (auto &it : m_VehData.Get(pVeh).materialProperties) for (auto& it : m_VehData.Get(pVeh).materialProperties)
{ {
if (it.second._recolor) if (it.second._recolor)
{ {
it.first->color = it.second._originalColor; it.first->color = it.second._originalColor;
it.second._geometry->flags = it.second._originalGeometryFlags; it.second._geometry->flags = it.second._originalGeometryFlags;
} }
if (it.second._retexture) if (it.second._retexture)
{ {
it.first->texture = it.second._originalTexture; it.first->texture = it.second._originalTexture;
} }
} }
}; };
} }
void Paint::VehData::setMaterialColor(RpMaterial *material, RpGeometry *geometry, RwRGBA color, bool filter_mat) void Paint::VehData::setMaterialColor(RpMaterial* material, RpGeometry* geometry, RwRGBA color, bool filter_mat)
{ {
auto &matProps = materialProperties[material]; auto& matProps = materialProperties[material];
if (!filter_mat || (material->color.red == 0x3C && material->color.green == 0xFF && material->color.blue == 0x00) || if (!filter_mat
(material->color.red == 0xFF && material->color.green == 0x00 && material->color.blue == 0xAF)) || (material->color.red == 0x3C && material->color.green == 0xFF && material->color.blue == 0x00)
{ || (material->color.red == 0xFF && material->color.green == 0x00 && material->color.blue == 0xAF))
matProps._recolor = true; {
matProps._color = color; matProps._recolor = true;
matProps._geometry = geometry; matProps._color = color;
} matProps._geometry = geometry;
}
} }
void Paint::VehData::setMaterialTexture(RpMaterial *material, RwTexture *texture, bool filter_mat) void Paint::VehData::setMaterialTexture(RpMaterial* material, RwTexture* texture, bool filter_mat)
{ {
auto &matProps = materialProperties[material]; auto& matProps = materialProperties[material];
if (!filter_mat || (material->color.red == 0x3C && material->color.green == 0xFF && material->color.blue == 0x00) || if (!filter_mat
(material->color.red == 0xFF && material->color.green == 0x00 && material->color.blue == 0xAF)) || (material->color.red == 0x3C && material->color.green == 0xFF && material->color.blue == 0x00)
{ || (material->color.red == 0xFF && material->color.green == 0x00 && material->color.blue == 0xAF))
matProps._retexture = true; {
matProps._texture = texture; matProps._retexture = true;
} matProps._texture = texture;
}
} }
void Paint::VehData::resetMaterialColor(RpMaterial *material) void Paint::VehData::resetMaterialColor(RpMaterial* material)
{ {
auto &matProps = materialProperties[material]; auto& matProps = materialProperties[material];
matProps._recolor = false; matProps._recolor = false;
matProps._color = {0, 0, 0, 0}; matProps._color = {0, 0, 0, 0};
} }
void Paint::VehData::resetMaterialTexture(RpMaterial *material) void Paint::VehData::resetMaterialTexture(RpMaterial* material)
{ {
auto &matProps = materialProperties[material]; auto& matProps = materialProperties[material];
matProps._retexture = false; matProps._retexture = false;
matProps._texture = nullptr; matProps._texture = nullptr;
} }
void Paint::NodeWrapperRecursive(RwFrame *frame, CVehicle *pVeh, std::function<void(RwFrame *)> func) void Paint::NodeWrapperRecursive(RwFrame* frame, CVehicle* pVeh, std::function<void(RwFrame*)> func)
{ {
if (frame) if (frame)
{ {
func(frame); func(frame);
if (RwFrame *newFrame = frame->child) if (RwFrame* newFrame = frame->child)
NodeWrapperRecursive(newFrame, pVeh, func); NodeWrapperRecursive(newFrame, pVeh, func);
if (RwFrame *newFrame = frame->next) if (RwFrame* newFrame = frame->next)
NodeWrapperRecursive(newFrame, pVeh, func); NodeWrapperRecursive(newFrame, pVeh, func);
} }
return; return;
} }
void Paint::UpdateNodeListRecursive(CVehicle *pVeh) void Paint::UpdateNodeListRecursive(CVehicle* pVeh)
{ {
RwFrame *frame = (RwFrame *)pVeh->m_pRwClump->object.parent; RwFrame* frame = (RwFrame*)pVeh->m_pRwClump->object.parent;
NodeWrapperRecursive(frame, pVeh, [](RwFrame *frame) { NodeWrapperRecursive(frame, pVeh, [](RwFrame* frame)
const std::string name = GetFrameNodeName(frame); {
const std::string name = GetFrameNodeName(frame);
if (!(std::find(veh_nodes::names_vec.begin(), veh_nodes::names_vec.end(), name) != veh_nodes::names_vec.end())) if (!(std::find(veh_nodes::names_vec.begin(), veh_nodes::names_vec.end(), name) != veh_nodes::names_vec.end()))
veh_nodes::names_vec.push_back(name); veh_nodes::names_vec.push_back(name);
}); });
} }
void Paint::SetNodeColor(CVehicle *pVeh, std::string node_name, CRGBA color, bool filter_mat) void Paint::SetNodeColor(CVehicle* pVeh, std::string node_name, CRGBA color, bool filter_mat)
{ {
RwFrame *frame = (RwFrame *)pVeh->m_pRwClump->object.parent; RwFrame* frame = (RwFrame*)pVeh->m_pRwClump->object.parent;
NodeWrapperRecursive(frame, pVeh, [&](RwFrame *frame) { NodeWrapperRecursive(frame, pVeh, [&](RwFrame* frame)
const std::string name = GetFrameNodeName(frame); {
const std::string name = GetFrameNodeName(frame);
struct ST struct ST
{ {
CRGBA _color; CRGBA _color;
bool _filter; bool _filter;
} st; } st;
st._color = color; st._color = color;
st._filter = filter_mat; st._filter = filter_mat;
if (node_name == "Default" || node_name == name) if (node_name == "Default" || node_name == name)
{ {
RwFrameForAllObjects( RwFrameForAllObjects(frame, [](RwObject* object, void* data) -> RwObject*
frame, {
[](RwObject *object, void *data) -> RwObject * { if (object->type == rpATOMIC)
if (object->type == rpATOMIC) {
{ RpAtomic* atomic = reinterpret_cast<RpAtomic*>(object);
RpAtomic *atomic = reinterpret_cast<RpAtomic *>(object);
ST *st = reinterpret_cast<ST *>(data); ST* st = reinterpret_cast<ST*>(data);
CRGBA *color = &st->_color; CRGBA* color = &st->_color;
bool filter_mat = st->_filter; bool filter_mat = st->_filter;
VehData &data = m_VehData.Get(FindPlayerPed()->m_pVehicle); VehData& data = m_VehData.Get(FindPlayerPed()->m_pVehicle);
for (int i = 0; i < atomic->geometry->matList.numMaterials; ++i) for (int i = 0; i < atomic->geometry->matList.numMaterials; ++i)
data.setMaterialColor(atomic->geometry->matList.materials[i], atomic->geometry, data.setMaterialColor(atomic->geometry->matList.materials[i], atomic->geometry,
{color->r, color->g, color->b, 255}, filter_mat); {color->r, color->g, color->b, 255}, filter_mat);
} }
return object; return object;
}, }, &st);
&st); }
} });
});
} }
void Paint::SetNodeTexture(CVehicle *pVeh, std::string node_name, std::string texturename, bool filter_mat) void Paint::SetNodeTexture(CVehicle* pVeh, std::string node_name, std::string texturename, bool filter_mat)
{ {
RwFrame *frame = (RwFrame *)pVeh->m_pRwClump->object.parent; RwFrame* frame = (RwFrame*)pVeh->m_pRwClump->object.parent;
RwTexture *texture = nullptr; RwTexture* texture = nullptr;
for (auto const &tex : m_TextureData.m_ImagesList) for (auto const& tex : m_TextureData.m_ImagesList)
{ {
if (tex.get()->m_FileName == texturename) if (tex.get()->m_FileName == texturename)
{ {
texture = tex.get()->m_pRwTexture; texture = tex.get()->m_pRwTexture;
break; break;
} }
} }
NodeWrapperRecursive(frame, pVeh, [&](RwFrame *frame) { NodeWrapperRecursive(frame, pVeh, [&](RwFrame* frame)
const std::string name = GetFrameNodeName(frame); {
const std::string name = GetFrameNodeName(frame);
struct ST struct ST
{ {
RwTexture *_tex; RwTexture* _tex;
bool _filter; bool _filter;
} st; } st;
st._tex = texture; st._tex = texture;
st._filter = filter_mat; st._filter = filter_mat;
if (node_name == "Default" || node_name == name) if (node_name == "Default" || node_name == name)
{ {
RwFrameForAllObjects( RwFrameForAllObjects(frame, [](RwObject* object, void* data) -> RwObject*
frame, {
[](RwObject *object, void *data) -> RwObject * { if (object->type == rpATOMIC)
if (object->type == rpATOMIC) {
{ RpAtomic* atomic = reinterpret_cast<RpAtomic*>(object);
RpAtomic *atomic = reinterpret_cast<RpAtomic *>(object);
ST *st = reinterpret_cast<ST *>(data); ST* st = reinterpret_cast<ST*>(data);
VehData &data = m_VehData.Get(FindPlayerPed()->m_pVehicle); VehData& data = m_VehData.Get(FindPlayerPed()->m_pVehicle);
for (int i = 0; i < atomic->geometry->matList.numMaterials; ++i) for (int i = 0; i < atomic->geometry->matList.numMaterials; ++i)
{ {
data.setMaterialTexture(atomic->geometry->matList.materials[i], st->_tex, st->_filter); data.setMaterialTexture(atomic->geometry->matList.materials[i], st->_tex,
} st->_filter);
} }
return object; }
}, return object;
&st); }, &st);
} }
}); });
} }
void Paint::ResetNodeColor(CVehicle *pVeh, std::string node_name) void Paint::ResetNodeColor(CVehicle* pVeh, std::string node_name)
{ {
RwFrame *frame = (RwFrame *)pVeh->m_pRwClump->object.parent; RwFrame* frame = (RwFrame*)pVeh->m_pRwClump->object.parent;
NodeWrapperRecursive(frame, pVeh, [&](RwFrame *frame) { NodeWrapperRecursive(frame, pVeh, [&](RwFrame* frame)
const std::string name = GetFrameNodeName(frame); {
const std::string name = GetFrameNodeName(frame);
if (node_name == "Default" || node_name == name) if (node_name == "Default" || node_name == name)
{ {
RwFrameForAllObjects( RwFrameForAllObjects(frame, [](RwObject* object, void* data) -> RwObject*
frame, {
[](RwObject *object, void *data) -> RwObject * { if (object->type == rpATOMIC)
if (object->type == rpATOMIC) {
{ RpAtomic* atomic = reinterpret_cast<RpAtomic*>(object);
RpAtomic *atomic = reinterpret_cast<RpAtomic *>(object); VehData& data = m_VehData.Get(FindPlayerPed()->m_pVehicle);
VehData &data = m_VehData.Get(FindPlayerPed()->m_pVehicle);
for (int i = 0; i < atomic->geometry->matList.numMaterials; ++i) for (int i = 0; i < atomic->geometry->matList.numMaterials; ++i)
data.resetMaterialColor(atomic->geometry->matList.materials[i]); data.resetMaterialColor(atomic->geometry->matList.materials[i]);
} }
return object; return object;
}, }, nullptr);
nullptr); }
} });
});
} }
void Paint::ResetNodeTexture(CVehicle *pVeh, std::string node_name) void Paint::ResetNodeTexture(CVehicle* pVeh, std::string node_name)
{ {
RwFrame *frame = (RwFrame *)pVeh->m_pRwClump->object.parent; RwFrame* frame = (RwFrame*)pVeh->m_pRwClump->object.parent;
NodeWrapperRecursive(frame, pVeh, [&](RwFrame *frame) { NodeWrapperRecursive(frame, pVeh, [&](RwFrame* frame)
const std::string name = GetFrameNodeName(frame); {
const std::string name = GetFrameNodeName(frame);
if (node_name == "Default" || node_name == name) if (node_name == "Default" || node_name == name)
{ {
RwFrameForAllObjects( RwFrameForAllObjects(frame, [](RwObject* object, void* data) -> RwObject*
frame, {
[](RwObject *object, void *data) -> RwObject * { if (object->type == rpATOMIC)
if (object->type == rpATOMIC) {
{ RpAtomic* atomic = reinterpret_cast<RpAtomic*>(object);
RpAtomic *atomic = reinterpret_cast<RpAtomic *>(object);
VehData &data = m_VehData.Get(FindPlayerPed()->m_pVehicle); VehData& data = m_VehData.Get(FindPlayerPed()->m_pVehicle);
for (int i = 0; i < atomic->geometry->matList.numMaterials; ++i) for (int i = 0; i < atomic->geometry->matList.numMaterials; ++i)
data.resetMaterialTexture(atomic->geometry->matList.materials[i]); data.resetMaterialTexture(atomic->geometry->matList.materials[i]);
} }
return object; return object;
}, }, nullptr);
nullptr); }
} });
});
} }

View File

@ -27,59 +27,64 @@
class Paint class Paint
{ {
private: private:
// store vehicle specific data // store vehicle specific data
struct VehData struct VehData
{ {
struct MaterialProperties struct MaterialProperties
{ {
MaterialProperties() MaterialProperties() :
: _color{0, 0, 0, 0}, _recolor(false), _retexture(false), _color{0, 0, 0, 0},
_geometry(nullptr), _originalColor{0, 0, 0, 0}, _originalTexture(nullptr), _originalGeometryFlags(0) _recolor(false),
{ _retexture(false),
} _geometry(nullptr),
_originalColor{0, 0, 0, 0},
_originalTexture(nullptr),
_originalGeometryFlags(0)
{
}
RwRGBA _color; RwRGBA _color;
RwTexture *_texture; RwTexture* _texture;
bool _recolor; bool _recolor;
bool _retexture; bool _retexture;
RpGeometry *_geometry; RpGeometry* _geometry;
RwRGBA _originalColor; RwRGBA _originalColor;
RwTexture *_originalTexture; RwTexture* _originalTexture;
RwInt32 _originalGeometryFlags; RwInt32 _originalGeometryFlags;
}; };
// carcols color id // carcols color id
uchar primary_color = 0; uchar primary_color = 0;
uchar secondary_color = 0; uchar secondary_color = 0;
std::unordered_map<RpMaterial *, MaterialProperties> materialProperties; std::unordered_map<RpMaterial*, MaterialProperties> materialProperties;
VehData(CVehicle *veh) VehData(CVehicle* veh)
{ {
primary_color = veh->m_nPrimaryColor; primary_color = veh->m_nPrimaryColor;
secondary_color = veh->m_nSecondaryColor; secondary_color = veh->m_nSecondaryColor;
} }
void setMaterialColor(RpMaterial *material, RpGeometry *geometry, RwRGBA color, bool filter_mat = false); void setMaterialColor(RpMaterial* material, RpGeometry* geometry, RwRGBA color, bool filter_mat = false);
void setMaterialTexture(RpMaterial *material, RwTexture *texture, bool filter_mat = false); void setMaterialTexture(RpMaterial* material, RwTexture* texture, bool filter_mat = false);
void resetMaterialColor(RpMaterial *material); void resetMaterialColor(RpMaterial* material);
void resetMaterialTexture(RpMaterial *material); void resetMaterialTexture(RpMaterial* material);
}; };
static inline VehicleExtendedData<VehData> m_VehData; static inline VehicleExtendedData<VehData> m_VehData;
protected: protected:
static inline ResourceStore m_TextureData{"textures", eResourceType::TYPE_IMAGE, ImVec2(100, 80)}; static inline ResourceStore m_TextureData { "textures", eResourceType::TYPE_IMAGE, ImVec2(100, 80) };
struct veh_nodes struct veh_nodes
{ {
static inline std::vector<std::string> names_vec{"Default"}; static inline std::vector<std::string> names_vec{"Default"};
static inline std::string selected = "Default"; static inline std::string selected = "Default";
}; };
Paint(); Paint();
static void UpdateNodeListRecursive(CVehicle *pVeh); static void UpdateNodeListRecursive(CVehicle* pVeh);
static void NodeWrapperRecursive(RwFrame *frame, CVehicle *pVeh, std::function<void(RwFrame *)> func); static void NodeWrapperRecursive(RwFrame* frame, CVehicle* pVeh, std::function<void(RwFrame*)> func);
static void SetNodeColor(CVehicle *pVeh, std::string node_name, CRGBA color, bool filter_mat = false); static void SetNodeColor(CVehicle* pVeh, std::string node_name, CRGBA color, bool filter_mat = false);
static void SetNodeTexture(CVehicle *pVeh, std::string node_name, std::string texturename, bool filter_mat = false); static void SetNodeTexture(CVehicle* pVeh, std::string node_name, std::string texturename, bool filter_mat = false);
static void ResetNodeColor(CVehicle *veh, std::string node_name); static void ResetNodeColor(CVehicle* veh, std::string node_name);
static void ResetNodeTexture(CVehicle *pVeh, std::string node_name); static void ResetNodeTexture(CVehicle* pVeh, std::string node_name);
}; };

View File

@ -1,5 +1,5 @@
#pragma once #pragma once
#pragma warning(disable : 4503 4244 4005) #pragma warning(disable:4503 4244 4005)
#define INPUT_BUFFER_SIZE 64 #define INPUT_BUFFER_SIZE 64
#define SPAWN_PED_LIMIT 20 #define SPAWN_PED_LIMIT 20
@ -14,74 +14,72 @@
#define BY_GAME(sa, vc, iii) iii #define BY_GAME(sa, vc, iii) iii
#endif #endif
#include <d3d9.h>
#include <d3d11.h> #include <d3d11.h>
#include <d3d11Shader.h> #include <d3d11Shader.h>
#include <d3d9.h>
#include <filesystem> #include <filesystem>
#include <fstream> #include <fstream>
#include <functional> #include <functional>
#include <iostream>
#include <memory> #include <memory>
#include <iostream>
#include <sstream> #include <sstream>
#include <vector> #include <vector>
#include <windows.h> #include <windows.h>
#include <plugin.h>
#include <CCamera.h> #include <CCamera.h>
#include <CCivilianPed.h>
#include <CClock.h> #include <CClock.h>
#include <CCivilianPed.h>
#include <CGangs.h> #include <CGangs.h>
#include <CHud.h> #include <CHud.h>
#include <CMenuManager.h> #include <CMenuManager.h>
#include <CModelInfo.h> #include <CModelInfo.h>
#include <RenderWare.h>
#include <CStats.h> #include <CStats.h>
#include <CStreaming.h> #include <CStreaming.h>
#include <CTheScripts.h> #include <CTheScripts.h>
#include <CTimeCycle.h>
#include <CTimer.h> #include <CTimer.h>
#include <CTimeCycle.h>
#include <CTrain.h> #include <CTrain.h>
#include <CWeather.h> #include <CWeather.h>
#include <CWorld.h> #include <CWorld.h>
#include <RenderWare.h>
#include <extensions/Paths.h>
#include <extensions/Screen.h>
#include <extensions/ScriptCommands.h> #include <extensions/ScriptCommands.h>
#include <plugin.h> #include <extensions/Screen.h>
#include <extensions/Paths.h>
#ifndef GTA3 #ifndef GTA3
#include <CBike.h> #include <CBike.h>
#include <cHandlingDataMgr.h>
#include <CTheZones.h> #include <CTheZones.h>
#include <CZoneInfo.h> #include <CZoneInfo.h>
#include <cHandlingDataMgr.h>
#endif #endif
#ifdef GTASA #ifdef GTASA
#include <CCheat.h> #include <CCheat.h>
#include <CClothes.h> #include <CClothes.h>
#include <CCutsceneMgr.h> #include <CCutsceneMgr.h>
#include <CGangWars.h>
#include <CRadar.h> #include <CRadar.h>
#include <CShadows.h> #include <CShadows.h>
#include <eVehicleClass.h> #include <eVehicleClass.h>
#include <CGangWars.h>
#endif #endif
#include "../depend/fla/IDaccess.h" #include "../depend/fla/IDaccess.h"
#include "../depend/imgui/imgui.h" #include "../depend/imgui/imgui.h"
#include "hotkeys.h"
#include "json.h" #include "json.h"
#include "resourcestore.h" #include "hotkeys.h"
#include "vKeys.h" #include "vKeys.h"
#include "resourcestore.h"
using CallbackTable = std::vector<std::pair<std::string, void (*)()>>; using CallbackTable = std::vector<std::pair<std::string, void(*)()>>;
using namespace plugin; using namespace plugin;
enum eRenderer enum eRenderer
{ {
Render_DirectX9, Render_DirectX9,
Render_DirectX11, Render_DirectX11,
Render_Unknown Render_Unknown
}; };
static eRenderer gRenderer = Render_Unknown; static eRenderer gRenderer = Render_Unknown;
@ -94,13 +92,13 @@ extern CJson gConfig;
static void SetHelpMessage(const char *message, bool b1, bool b2, bool b3) static void SetHelpMessage(const char *message, bool b1, bool b2, bool b3)
{ {
#if GTASA #if GTASA
CHud::SetHelpMessage(message, b1, b2, b3); CHud::SetHelpMessage(message, b1, b2, b3);
#elif GTAVC #elif GTAVC
CHud::SetHelpMessage(message, b1, b2); CHud::SetHelpMessage(message, b1, b2);
#else // GTA3 #else // GTA3
const size_t cSize = strlen(message) + 1; const size_t cSize = strlen(message)+1;
wchar_t *wc = new wchar_t[cSize]; wchar_t* wc = new wchar_t[cSize];
mbstowcs(wc, message, cSize); mbstowcs (wc, message, cSize);
CHud::SetHelpMessage((wchar_t *)wc, b1); CHud::SetHelpMessage((wchar_t*)wc, b1);
#endif #endif
} }

View File

@ -1,5 +1,5 @@
#include "ped.h"
#include "pch.h" #include "pch.h"
#include "ped.h"
#include "ui.h" #include "ui.h"
#include "util.h" #include "util.h"
#include "weapon.h" #include "weapon.h"
@ -12,395 +12,395 @@
Ped::Ped() Ped::Ped()
{ {
#ifdef GTASA #ifdef GTASA
if (GetModuleHandle("ExGangWars.asi")) if (GetModuleHandle("ExGangWars.asi"))
{ {
m_bExGangWarsInstalled = true; m_bExGangWarsInstalled = true;
} }
/* /*
Taken from gta chaos mod by Lordmau5 Taken from gta chaos mod by Lordmau5
https://github.com/gta-chaos-mod/Trilogy-ASI-Script https://github.com/gta-chaos-mod/Trilogy-ASI-Script
TODO: Implement in VC too TODO: Implement in VC too
*/ */
Events::pedRenderEvent += [](CPed *ped) { Events::pedRenderEvent += [](CPed *ped)
if (m_bBigHead || m_bThinBody) {
{
auto animHier = GetAnimHierarchyFromSkinClump(ped->m_pRwClump);
auto matrices = RpHAnimHierarchyGetMatrixArray(animHier);
RwV3d scale = {0.7f, 0.7f, 0.7f}; if (m_bBigHead || m_bThinBody)
if (m_bThinBody) {
{ auto animHier = GetAnimHierarchyFromSkinClump (ped->m_pRwClump);
for (int i = 1; i <= 52; i++) auto matrices = RpHAnimHierarchyGetMatrixArray (animHier);
{
RwMatrixScale(&matrices[RpHAnimIDGetIndex(animHier, i)], &scale, rwCOMBINEPRECONCAT); RwV3d scale = {0.7f, 0.7f, 0.7f};
} if (m_bThinBody)
} {
scale = {3.0f, 3.0f, 3.0f}; for (int i = 1; i <= 52; i++)
if (m_bBigHead) {
{ RwMatrixScale (&matrices[RpHAnimIDGetIndex (animHier, i)], &scale, rwCOMBINEPRECONCAT);
for (int i = BONE_NECK; i <= BONE_HEAD; i++) }
{ }
RwMatrixScale(&matrices[RpHAnimIDGetIndex(animHier, i)], &scale, rwCOMBINEPRECONCAT); scale = {3.0f, 3.0f, 3.0f};
} if (m_bBigHead)
} {
} for (int i = BONE_NECK; i <= BONE_HEAD; i++)
}; {
RwMatrixScale (&matrices[RpHAnimIDGetIndex (animHier, i)], &scale, rwCOMBINEPRECONCAT);
}
}
}
};
#endif #endif
} }
Ped::~Ped() Ped::~Ped()
{ {
for (CPed *ped : m_SpawnPed::m_List) for (CPed* ped : m_SpawnPed::m_List)
{ {
CWorld::Remove(ped); CWorld::Remove(ped);
ped->Remove(); ped->Remove();
} }
} }
#ifdef GTASA #ifdef GTASA
void Ped::SpawnPed(std::string &model) void Ped::SpawnPed(std::string& model)
#else // GTA3 & GTAVC #else // GTA3 & GTAVC
void Ped::SpawnPed(std::string &cat, std::string &name, std::string &model) void Ped::SpawnPed(std::string& cat, std::string& name, std::string& model)
#endif #endif
{ {
if (m_SpawnPed::m_List.size() == SPAWN_PED_LIMIT) if (m_SpawnPed::m_List.size() == SPAWN_PED_LIMIT)
{ {
SetHelpMessage("Max limit reached", false, false, false); SetHelpMessage("Max limit reached", false, false, false);
return; return;
} }
if (BY_GAME(m_PedData.m_pJson->m_Data.contains(model), true, true)) if (BY_GAME(m_PedData.m_pJson->m_Data.contains(model), true, true))
{ {
CPlayerPed *player = FindPlayerPed(); CPlayerPed* player = FindPlayerPed();
CVector pos = player->GetPosition(); CVector pos = player->GetPosition();
pos.y += 1; pos.y += 1;
CPed *ped; CPed* ped;
int hplayer; int hplayer;
static size_t currentSlot = 1; static size_t currentSlot = 1;
#ifdef GTASA #ifdef GTASA
if (m_SpecialPedJson.m_Data.contains(model)) if (m_SpecialPedJson.m_Data.contains(model))
{ {
std::string name; std::string name;
if (m_SpecialPedJson.m_Data.contains(model)) if (m_SpecialPedJson.m_Data.contains(model))
name = m_SpecialPedJson.m_Data[model].get<std::string>().c_str(); name = m_SpecialPedJson.m_Data[model].get<std::string>().c_str();
else else
name = model; name = model;
CStreaming::RequestSpecialChar(currentSlot, name.c_str(), PRIORITY_REQUEST); CStreaming::RequestSpecialChar(currentSlot, name.c_str(), PRIORITY_REQUEST);
CStreaming::LoadAllRequestedModels(true); CStreaming::LoadAllRequestedModels(true);
Command<Commands::CREATE_CHAR>(m_SpawnPed::m_nSelectedPedType + 4, 290 + currentSlot, pos.x, pos.y, Command<Commands::CREATE_CHAR>(m_SpawnPed::m_nSelectedPedType + 4, 290 + currentSlot, pos.x, pos.y, pos.z + 1, &hplayer);
pos.z + 1, &hplayer); CStreaming::SetSpecialCharIsDeletable(290 + currentSlot);
CStreaming::SetSpecialCharIsDeletable(290 + currentSlot);
// SA has 10 slots // SA has 10 slots
++currentSlot; ++currentSlot;
if (currentSlot > 10) if (currentSlot > 10)
{ {
currentSlot = 1; currentSlot = 1;
} }
} }
#else // GTA3 & GTAVC #else // GTA3 & GTAVC
if (cat == "Special") // Special model if (cat == "Special") // Special model
{ {
#ifdef GTA3 #ifdef GTA3
SetHelpMessage("Spawning special peds isn't implemented yet.", false, false, false); SetHelpMessage("Spawning special peds isn't implemented yet.", false, false, false);
return; return;
#else // GTAVC #else // GTAVC
Command<Commands::LOAD_SPECIAL_CHARACTER>(currentSlot, model.c_str()); Command<Commands::LOAD_SPECIAL_CHARACTER>(currentSlot, model.c_str());
Command<Commands::LOAD_ALL_MODELS_NOW>(); Command<Commands::LOAD_ALL_MODELS_NOW>();
Command<Commands::CREATE_CHAR>(m_SpawnPed::m_nSelectedPedType + 4, 108+currentSlot, pos.x, pos.y, pos.z + 1, &hplayer);
Command<Commands::UNLOAD_SPECIAL_CHARACTER>(currentSlot);
Command<Commands::CREATE_CHAR>(m_SpawnPed::m_nSelectedPedType + 4, 108 + currentSlot, pos.x, pos.y, ++currentSlot;
pos.z + 1, &hplayer); if (currentSlot > 21)
Command<Commands::UNLOAD_SPECIAL_CHARACTER>(currentSlot); {
currentSlot = 1;
++currentSlot; }
if (currentSlot > 21)
{
currentSlot = 1;
}
#endif #endif
} }
#endif #endif
else else
{ {
int iModel = std::stoi(model); int iModel = std::stoi(model);
CStreaming::RequestModel(iModel, eStreamingFlags::PRIORITY_REQUEST); CStreaming::RequestModel(iModel, eStreamingFlags::PRIORITY_REQUEST);
CStreaming::LoadAllRequestedModels(false); CStreaming::LoadAllRequestedModels(false);
Command<Commands::CREATE_CHAR>(m_SpawnPed::m_nSelectedPedType + 4, iModel, pos.x, pos.y, pos.z + 1, Command<Commands::CREATE_CHAR>(m_SpawnPed::m_nSelectedPedType + 4, iModel, pos.x, pos.y, pos.z + 1, &hplayer);
&hplayer); CStreaming::SetModelIsDeletable(iModel);
CStreaming::SetModelIsDeletable(iModel); }
}
ped = CPools::GetPed(hplayer); ped = CPools::GetPed(hplayer);
if (m_SpawnPed::m_bPedMove) if (m_SpawnPed::m_bPedMove)
{ {
m_SpawnPed::m_List.push_back(ped); m_SpawnPed::m_List.push_back(ped);
} }
else else
{ {
Command<Commands::MARK_CHAR_AS_NO_LONGER_NEEDED>(hplayer); Command<Commands::MARK_CHAR_AS_NO_LONGER_NEEDED>(hplayer);
} }
ped->m_nPedFlags.bPedIsBleeding = m_SpawnPed::m_bPedBleed; ped->m_nPedFlags.bPedIsBleeding = m_SpawnPed::m_bPedBleed;
#ifdef GTA3 #ifdef GTA3
ped->m_nWepAccuracy = m_SpawnPed::m_nAccuracy; ped->m_nWepAccuracy = m_SpawnPed::m_nAccuracy;
#else #else
ped->m_nWeaponAccuracy = m_SpawnPed::m_nAccuracy; ped->m_nWeaponAccuracy = m_SpawnPed::m_nAccuracy;
#endif #endif
ped->m_fHealth = m_SpawnPed::m_nPedHealth; ped->m_fHealth = m_SpawnPed::m_nPedHealth;
#ifdef GTASA #ifdef GTASA
if (m_SpawnPed::m_nWeaponId != 0) if (m_SpawnPed::m_nWeaponId != 0)
{ {
int model = 0; int model = 0;
Command<Commands::GET_WEAPONTYPE_MODEL>(m_SpawnPed::m_nWeaponId, &model); Command<Commands::GET_WEAPONTYPE_MODEL>(m_SpawnPed::m_nWeaponId, &model);
CStreaming::RequestModel(model, PRIORITY_REQUEST); CStreaming::RequestModel(model, PRIORITY_REQUEST);
CStreaming::LoadAllRequestedModels(false); CStreaming::LoadAllRequestedModels(false);
Command<Commands::GIVE_WEAPON_TO_CHAR>(hplayer, m_SpawnPed::m_nWeaponId, 999); Command<Commands::GIVE_WEAPON_TO_CHAR>(hplayer, m_SpawnPed::m_nWeaponId, 999);
} }
#endif #endif
} }
} }
void Ped::Draw() void Ped::Draw()
{ {
if (ImGui::BeginTabBar("Ped", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll)) if (ImGui::BeginTabBar("Ped", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll))
{ {
if (ImGui::BeginTabItem("Checkboxes")) if (ImGui::BeginTabItem("Checkboxes"))
{ {
ImGui::Spacing(); ImGui::Spacing();
ImGui::BeginChild("CheckboxesChild"); ImGui::BeginChild("CheckboxesChild");
ImGui::Columns(2, 0, false); ImGui::Columns(2, 0, false);
#ifdef GTASA #ifdef GTASA
Ui::CheckboxWithHint("Big head effect", &m_bBigHead); Ui::CheckboxWithHint("Big head effect", &m_bBigHead);
Ui::CheckboxAddress("Elvis everywhere", 0x969157); Ui::CheckboxAddress("Elvis everywhere", 0x969157);
Ui::CheckboxAddress("Everyone is armed", 0x969140); Ui::CheckboxAddress("Everyone is armed", 0x969140);
Ui::CheckboxAddress("Gangs control streets", 0x96915B); Ui::CheckboxAddress("Gangs control streets", 0x96915B);
Ui::CheckboxAddress("Gangs everywhere", 0x96915A); Ui::CheckboxAddress("Gangs everywhere", 0x96915A);
Ui::CheckboxWithHint("Gang wars", &CGangWars::bGangWarsActive); Ui::CheckboxWithHint("Gang wars", &CGangWars::bGangWarsActive);
ImGui::NextColumn(); ImGui::NextColumn();
Ui::CheckboxAddress("Peds mayhem", 0x96913E); Ui::CheckboxAddress("Peds mayhem", 0x96913E);
Ui::CheckboxAddress("Peds attack with rockets", 0x969158); Ui::CheckboxAddress("Peds attack with rockets", 0x969158);
Ui::CheckboxAddress("Peds riot", 0x969175); Ui::CheckboxAddress("Peds riot", 0x969175);
Ui::CheckboxAddress("Slut magnet", 0x96915D); Ui::CheckboxAddress("Slut magnet", 0x96915D);
Ui::CheckboxWithHint("Thin body effect", &m_bThinBody); Ui::CheckboxWithHint("Thin body effect", &m_bThinBody);
#elif GTAVC #elif GTAVC
Ui::CheckboxAddress("No prostitutes", 0xA10B99); Ui::CheckboxAddress("No prostitutes", 0xA10B99);
Ui::CheckboxAddress("Slut magnet", 0xA10B5F); Ui::CheckboxAddress("Slut magnet", 0xA10B5F);
ImGui::NextColumn(); ImGui::NextColumn();
Ui::CheckboxAddress("Weapons for all", 0xA10AB3); Ui::CheckboxAddress("Weapons for all", 0xA10AB3);
#else // GTA3 #else // GTA3
// Bad idea lol // Bad idea lol
static bool pedsMayhem; static bool pedsMayhem;
if (Ui::CheckboxWithHint("Peds mayhem", &pedsMayhem)) if (Ui::CheckboxWithHint("Peds mayhem", &pedsMayhem))
{ {
Call<0x4911C0>(); Call<0x4911C0>();
} }
static bool everyoneAttacksPlayer; static bool everyoneAttacksPlayer;
if (Ui::CheckboxWithHint("Everyone attacks players", &everyoneAttacksPlayer)) if (Ui::CheckboxWithHint("Everyone attacks players", &everyoneAttacksPlayer))
{ {
Call<0x491270>(); Call<0x491270>();
} }
ImGui::NextColumn(); ImGui::NextColumn();
Ui::CheckboxAddress("Nasty limbs", 0x95CD44); Ui::CheckboxAddress("Nasty limbs", 0x95CD44);
Ui::CheckboxAddress("Weapons for all", 0x95CCF6); Ui::CheckboxAddress("Weapons for all", 0x95CCF6);
#endif #endif
ImGui::Columns(1); ImGui::Columns(1);
ImGui::EndChild(); ImGui::EndChild();
ImGui::EndTabItem(); ImGui::EndTabItem();
} }
if (ImGui::BeginTabItem("Menus")) if (ImGui::BeginTabItem("Menus"))
{ {
ImGui::Spacing(); ImGui::Spacing();
ImGui::BeginChild("MenusChild"); ImGui::BeginChild("MenusChild");
#ifdef GTASA #ifdef GTASA
if (ImGui::CollapsingHeader("Gang wars")) if (ImGui::CollapsingHeader("Gang wars"))
{ {
if (ImGui::Button("Start gang war", ImVec2(Ui::GetSize(2)))) if (ImGui::Button("Start gang war", ImVec2(Ui::GetSize(2))))
{ {
if (Util::GetLargestGangInZone() == 1) if (Util::GetLargestGangInZone() == 1)
{ {
CGangWars::StartDefensiveGangWar(); CGangWars::StartDefensiveGangWar();
} }
else else
{ {
CGangWars::StartOffensiveGangWar(); CGangWars::StartOffensiveGangWar();
} }
CGangWars::bGangWarsActive = true; CGangWars::bGangWarsActive = true;
} }
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::Button("End gang war", ImVec2(Ui::GetSize(2)))) if (ImGui::Button("End gang war", ImVec2(Ui::GetSize(2))))
{ {
CGangWars::EndGangWar(true); CGangWars::EndGangWar(true);
} }
ImGui::Dummy(ImVec2(0, 20)); ImGui::Dummy(ImVec2(0, 20));
ImGui::TextWrapped("Gang zone density:"); ImGui::TextWrapped("Gang zone density:");
ImGui::Spacing(); ImGui::Spacing();
ImGui::PushItemWidth(ImGui::GetWindowContentRegionWidth() / 2); ImGui::PushItemWidth(ImGui::GetWindowContentRegionWidth() / 2);
for (int i = 0; i != 10; ++i) for (int i = 0; i != 10; ++i)
{ {
CVector pos = FindPlayerPed()->GetPosition(); CVector pos = FindPlayerPed()->GetPosition();
CZone szone = CZone(); CZone szone = CZone();
CZone *pZone = &szone; CZone* pZone = &szone;
CZoneInfo *zoneInfo = CTheZones::GetZoneInfo(&pos, &pZone); CZoneInfo* zoneInfo = CTheZones::GetZoneInfo(&pos, &pZone);
int density = zoneInfo->m_nGangDensity[i]; int density = zoneInfo->m_nGangDensity[i];
if (ImGui::SliderInt(m_GangNames[i].c_str(), &density, 0, 127)) if (ImGui::SliderInt(m_GangNames[i].c_str(), &density, 0, 127))
{ {
zoneInfo->m_nGangDensity[i] = static_cast<char>(density); zoneInfo->m_nGangDensity[i] = static_cast<char>(density);
Command<Commands::CLEAR_SPECIFIC_ZONES_TO_TRIGGER_GANG_WAR>(); Command<Commands::CLEAR_SPECIFIC_ZONES_TO_TRIGGER_GANG_WAR>();
CGangWars::bGangWarsActive = true; CGangWars::bGangWarsActive = true;
} }
} }
ImGui::PopItemWidth(); ImGui::PopItemWidth();
ImGui::Spacing(); ImGui::Spacing();
if (!m_bExGangWarsInstalled) if (!m_bExGangWarsInstalled)
{ {
ImGui::TextWrapped("You'll need ExGangWars plugin to display some turf colors"); ImGui::TextWrapped("You'll need ExGangWars plugin to display some turf colors");
ImGui::Spacing(); ImGui::Spacing();
if (ImGui::Button("Download ExGangWars", Ui::GetSize(1))) if (ImGui::Button("Download ExGangWars", Ui::GetSize(1)))
{ {
ShellExecute(NULL, "open", "https://gtaforums.com/topic/682194-extended-gang-wars/", NULL, NULL, ShellExecute(NULL, "open", "https://gtaforums.com/topic/682194-extended-gang-wars/", NULL, NULL,
SW_SHOWNORMAL); SW_SHOWNORMAL);
} }
} }
ImGui::Spacing(); ImGui::Spacing();
ImGui::Separator(); ImGui::Separator();
} }
#endif #endif
Ui::EditReference<float>("Pedestrian density multiplier", CPopulation::PedDensityMultiplier, 0, 1, 10); Ui::EditReference<float>("Pedestrian density multiplier", CPopulation::PedDensityMultiplier, 0, 1, 10);
#ifdef GTASA #ifdef GTASA
if (ImGui::CollapsingHeader("Recruit anyone")) if (ImGui::CollapsingHeader("Recruit anyone"))
{ {
static std::vector<Ui::NamedMemory> selectWeapon{ static std::vector<Ui::NamedMemory> selectWeapon{
{"9mm", 0x96917C}, {"AK47", 0x96917D}, {"Rockets", 0x96917E}}; {"9mm", 0x96917C}, {"AK47", 0x96917D}, {"Rockets", 0x96917E}
Ui::RadioButtonAddress("Select weapon", selectWeapon); };
ImGui::Spacing(); Ui::RadioButtonAddress("Select weapon", selectWeapon);
ImGui::Separator(); ImGui::Spacing();
} ImGui::Separator();
}
#endif #endif
if (ImGui::CollapsingHeader("Remove peds in radius")) if (ImGui::CollapsingHeader("Remove peds in radius"))
{ {
ImGui::InputInt("Radius", &m_nPedRemoveRadius); ImGui::InputInt("Radius", &m_nPedRemoveRadius);
ImGui::Spacing(); ImGui::Spacing();
if (ImGui::Button("Remove peds", Ui::GetSize(1))) if (ImGui::Button("Remove peds", Ui::GetSize(1)))
{ {
CPlayerPed *player = FindPlayerPed(); CPlayerPed* player = FindPlayerPed();
for (CPed *ped : CPools::ms_pPedPool) for (CPed* ped : CPools::ms_pPedPool)
{ {
if (DistanceBetweenPoints(ped->GetPosition(), player->GetPosition()) < m_nPedRemoveRadius && if (DistanceBetweenPoints(ped->GetPosition(), player->GetPosition()) < m_nPedRemoveRadius
ped->m_pVehicle == nullptr && ped != player) && ped->m_pVehicle == nullptr && ped != player)
{ {
Command<Commands::DELETE_CHAR>(CPools::GetPedRef(ped)); Command<Commands::DELETE_CHAR>(CPools::GetPedRef(ped));
} }
} }
} }
ImGui::Spacing(); ImGui::Spacing();
ImGui::Separator(); ImGui::Separator();
} }
ImGui::EndChild(); ImGui::EndChild();
ImGui::EndTabItem(); ImGui::EndTabItem();
} }
if (ImGui::BeginTabItem("Spawn")) if (ImGui::BeginTabItem("Spawn"))
{ {
ImGui::Spacing(); ImGui::Spacing();
if (ImGui::Button("Remove frozen peds", Ui::GetSize(1))) if (ImGui::Button("Remove frozen peds", Ui::GetSize(1)))
{ {
for (CPed *ped : m_SpawnPed::m_List) for (CPed* ped : m_SpawnPed::m_List)
{ {
CWorld::Remove(ped); CWorld::Remove(ped);
ped->Remove(); ped->Remove();
} }
m_SpawnPed::m_List.clear(); m_SpawnPed::m_List.clear();
} }
ImGui::Spacing(); ImGui::Spacing();
if (ImGui::BeginTabBar("SpawnPedBar")) if (ImGui::BeginTabBar("SpawnPedBar"))
{ {
ImGui::Spacing(); ImGui::Spacing();
if (ImGui::BeginTabItem("Spawner")) if (ImGui::BeginTabItem("Spawner"))
{ {
ImGui::Spacing(); ImGui::Spacing();
#ifdef GTASA #ifdef GTASA
Ui::DrawImages(m_PedData, SpawnPed, nullptr, Ui::DrawImages(m_PedData, SpawnPed, nullptr,
[](std::string str) { return m_PedData.m_pJson->m_Data[str].get<std::string>(); }); [](std::string str) { return m_PedData.m_pJson->m_Data[str].get<std::string>(); });
#else // GTA3 & GTAVC #else // GTA3 & GTAVC
Ui::DrawJSON(m_PedData, SpawnPed, nullptr); Ui::DrawJSON(m_PedData, SpawnPed, nullptr);
#endif #endif
ImGui::EndTabItem(); ImGui::EndTabItem();
} }
if (ImGui::BeginTabItem("Config")) if (ImGui::BeginTabItem("Config"))
{ {
ImGui::Spacing(); ImGui::Spacing();
ImGui::BeginChild("PedCOnfig"); ImGui::BeginChild("PedCOnfig");
ImGui::Columns(2, 0, false); ImGui::Columns(2, 0, false);
Ui::CheckboxWithHint("Don't move", &m_SpawnPed::m_bPedMove); Ui::CheckboxWithHint("Don't move", &m_SpawnPed::m_bPedMove);
ImGui::NextColumn(); ImGui::NextColumn();
Ui::CheckboxWithHint("Ped bleed", &m_SpawnPed::m_bPedBleed); Ui::CheckboxWithHint("Ped bleed", &m_SpawnPed::m_bPedBleed);
ImGui::Columns(1); ImGui::Columns(1);
ImGui::Spacing(); ImGui::Spacing();
ImGui::SliderInt("Accuracy", &m_SpawnPed::m_nAccuracy, 0.0, 100.0); ImGui::SliderInt("Accuracy", &m_SpawnPed::m_nAccuracy, 0.0, 100.0);
if (ImGui::InputInt("Health", &m_SpawnPed::m_nPedHealth)) if (ImGui::InputInt("Health", &m_SpawnPed::m_nPedHealth))
{ {
if (m_SpawnPed::m_nPedHealth > 1000) if (m_SpawnPed::m_nPedHealth > 1000)
{ {
m_SpawnPed::m_nPedHealth = 1000; m_SpawnPed::m_nPedHealth = 1000;
} }
if (m_SpawnPed::m_nPedHealth < 0) if (m_SpawnPed::m_nPedHealth < 0)
{ {
m_SpawnPed::m_nPedHealth = 0; m_SpawnPed::m_nPedHealth = 0;
} }
} }
Ui::ListBox("Ped type", m_SpawnPed::m_PedTypeList, m_SpawnPed::m_nSelectedPedType); Ui::ListBox("Ped type", m_SpawnPed::m_PedTypeList, m_SpawnPed::m_nSelectedPedType);
ImGui::Spacing(); ImGui::Spacing();
ImGui::Text("Selected weapon: %s", m_SpawnPed::m_nWeaponName.c_str()); ImGui::Text("Selected weapon: %s", m_SpawnPed::m_nWeaponName.c_str());
ImGui::Spacing(); ImGui::Spacing();
#ifdef GTASA #ifdef GTASA
Ui::DrawImages( Ui::DrawImages(Weapon::m_WeaponData,
Weapon::m_WeaponData, [](std::string str) { m_SpawnPed::m_nWeaponId = std::stoi(str); }, [](std::string str) { m_SpawnPed::m_nWeaponId = std::stoi(str); },
nullptr, nullptr,
[](std::string str) { [](std::string str)
m_SpawnPed::m_nWeaponName = Weapon::m_WeaponData.m_pJson->m_Data[str].get<std::string>(); {
return m_SpawnPed::m_nWeaponName; m_SpawnPed::m_nWeaponName = Weapon::m_WeaponData.m_pJson->m_Data[str].get<std::string>();
}, return m_SpawnPed::m_nWeaponName;
[](std::string str) { },
return str != "-1"; /*Jetpack*/ [](std::string str) { return str != "-1"; /*Jetpack*/ }
}); );
#else // GTA3 & GTAVC #else // GTA3 & GTAVC
Ui::DrawJSON( Ui::DrawJSON(Weapon::m_WeaponData,
Weapon::m_WeaponData, [](std::string& root, std::string& key, std::string& id)
[](std::string &root, std::string &key, std::string &id) { {
m_SpawnPed::m_nWeaponId = std::stoi(id); m_SpawnPed::m_nWeaponId = std::stoi(id);
m_SpawnPed::m_nWeaponName = key; m_SpawnPed::m_nWeaponName = key;
}, },
nullptr); nullptr);
#endif #endif
ImGui::Spacing(); ImGui::Spacing();
ImGui::EndChild(); ImGui::EndChild();
ImGui::EndTabItem(); ImGui::EndTabItem();
} }
ImGui::EndTabBar(); ImGui::EndTabBar();
} }
ImGui::EndTabItem(); ImGui::EndTabItem();
} }
ImGui::EndTabBar(); ImGui::EndTabBar();
} }
} }

View File

@ -9,75 +9,63 @@ class Ped
{ {
private: private:
#ifdef GTASA #ifdef GTASA
static inline bool m_bBigHead; static inline bool m_bBigHead;
static inline bool m_bThinBody; static inline bool m_bThinBody;
static inline CJson m_SpecialPedJson = CJson("ped special"); static inline CJson m_SpecialPedJson = CJson("ped special");
static inline ResourceStore m_PedData{"ped", eResourceType::TYPE_BOTH, ImVec2(65, 110)}; static inline ResourceStore m_PedData{"ped", eResourceType::TYPE_BOTH, ImVec2(65, 110)};
static inline std::vector<std::string> m_GangNames = { static inline std::vector<std::string> m_GangNames =
"Ballas", "Grove street families", "Los santos vagos", "San fierro rifa", "Da nang boys", {
"Mafia", "Mountain cloud triad", "Varrio los aztecas", "Gang9", "Gang10"}; "Ballas", "Grove street families", "Los santos vagos", "San fierro rifa",
"Da nang boys", "Mafia", "Mountain cloud triad", "Varrio los aztecas", "Gang9", "Gang10"
};
#else // GTA3 & GTAVC #else // GTA3 & GTAVC
static inline ResourceStore m_PedData{"ped", eResourceType::TYPE_TEXT}; static inline ResourceStore m_PedData{"ped", eResourceType::TYPE_TEXT};
#endif #endif
static inline bool m_bImagesLoaded; static inline bool m_bImagesLoaded;
static inline bool m_bExGangWarsInstalled; static inline bool m_bExGangWarsInstalled;
static inline int m_nPedRemoveRadius = 5; static inline int m_nPedRemoveRadius = 5;
struct m_SpawnPed struct m_SpawnPed
{ {
static inline std::vector<CPed *> m_List; static inline std::vector<CPed*> m_List;
static inline int m_nAccuracy = 50; static inline int m_nAccuracy = 50;
static inline int m_nPedHealth = 100; static inline int m_nPedHealth = 100;
static inline bool m_bPedMove; static inline bool m_bPedMove;
static inline bool m_bPedBleed; static inline bool m_bPedBleed;
static inline int m_nSelectedPedType; static inline int m_nSelectedPedType;
static inline int m_nWeaponId; static inline int m_nWeaponId;
static inline std::string m_nWeaponName = "None"; static inline std::string m_nWeaponName = "None";
static inline std::vector<std::string> m_PedTypeList = { static inline std::vector<std::string> m_PedTypeList =
{
#ifdef GTASA #ifdef GTASA
"Civ Male", "Civ Male", "Civ Female", "Cop", "Ballas", "Grove Street Families", "Los Santos Vagos",
"Civ Female", "San Fierro Rifa", "Da Nang Boys", "Mafia", "Mountain Cloud Triads", "Varrio Los Aztecas",
"Cop", "Gang 9", "Medic", "Dealer", "Criminal", "Fireman", "Prostitute"
"Ballas",
"Grove Street Families",
"Los Santos Vagos",
"San Fierro Rifa",
"Da Nang Boys",
"Mafia",
"Mountain Cloud Triads",
"Varrio Los Aztecas",
"Gang 9",
"Medic",
"Dealer",
"Criminal",
"Fireman",
"Prostitute"
#elif GTAVC #elif GTAVC
"Civ Male", "Civ Female", "Cop (crash)", "Cubans", "Haitians", "Streetwannabe's", "Diaz' Gang", "Civ Male", "Civ Female", "Cop (crash)", "Cubans", "Haitians", "Streetwannabe's", "Diaz' Gang",
"Security Guards", "Biker Gang", "Vercetti Gang", "Golfers", "Gang 9", "Emergency", "Fireman", "Security Guards", "Biker Gang", "Vercetti Gang", "Golfers", "Gang 9", "Emergency",
"Criminal", "Unused", "Prostitute", "Special" "Fireman", "Criminal", "Unused", "Prostitute", "Special"
#else // GTA3 #else // GTA3
"Civ Male", "Civ Female", "Cop", "Leones", "Triads", "Diablos", "Yakuza", "Civ Male", "Civ Female", "Cop", "Leones", "Triads", "Diablos", "Yakuza", "Yardies", "Colombians",
"Yardies", "Colombians", "Hoods", "unused", "unused", "Emergency", "Fireman", "Hoods", "unused", "unused", "Emergency", "Fireman", "Criminal", "unused", "Prostitute", "Special"
"Criminal", "unused", "Prostitute", "Special"
#endif #endif
}; };
}; };
friend class Player; friend class Player;
#ifdef GTASA #ifdef GTASA
friend class Weapon; friend class Weapon;
#endif #endif
public: public:
Ped(); Ped();
~Ped(); ~Ped();
static void Draw(); static void Draw();
#ifdef GTASA #ifdef GTASA
static void SpawnPed(std::string &model); static void SpawnPed(std::string& model);
static void BigHeadEffect(CPed *ped); static void BigHeadEffect(CPed *ped);
#else // GTA3 & GTAVC #else // GTA3 & GTAVC
static void SpawnPed(std::string &cat, std::string &name, std::string &model); static void SpawnPed(std::string& cat, std::string& name, std::string& model);
#endif #endif
}; };

File diff suppressed because it is too large Load Diff

View File

@ -4,46 +4,45 @@
class Player class Player
{ {
private: private:
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
{ {
static inline bool m_bEnabled = false; static inline bool m_bEnabled = false;
static inline CVector m_fPos; static inline CVector m_fPos;
}; };
#ifdef GTASA #ifdef GTASA
static inline bool m_bAimSkinChanger; static inline bool m_bAimSkinChanger;
static inline bool m_bDrunkEffect; static inline bool m_bDrunkEffect;
static inline bool m_bFastSprint; static inline bool m_bFastSprint;
static inline int m_nUiBodyState; static inline int m_nUiBodyState;
static inline ResourceStore m_ClothData{"clothes", eResourceType::TYPE_IMAGE, ImVec2(70, 100)}; static inline ResourceStore m_ClothData { "clothes" , eResourceType::TYPE_IMAGE, ImVec2(70, 100)};
struct m_CustomSkins struct m_CustomSkins
{ {
static inline std::string m_Path = paths::GetGameDirPathA() + std::string("\\modloader\\Custom Skins\\"); static inline std::string m_Path = paths::GetGameDirPathA() + std::string("\\modloader\\Custom Skins\\");;
; static inline ImGuiTextFilter m_Filter;
static inline ImGuiTextFilter m_Filter; static inline std::vector<std::string> m_List;
static inline std::vector<std::string> m_List; };
};
struct m_TopDownCamera struct m_TopDownCamera
{ {
static inline bool m_bEnabled = false; static inline bool m_bEnabled = false;
static inline float m_fOffset = 40.0f; static inline float m_fOffset = 40.0f;
}; };
#else // GTA3 & GTAVC #else // GTA3 & GTAVC
static inline ResourceStore skinData{BY_GAME(NULL, "skin", "ped"), eResourceType::TYPE_TEXT}; static inline ResourceStore skinData{ BY_GAME(NULL, "skin", "ped"), eResourceType::TYPE_TEXT };
#endif #endif
public: public:
Player(); Player();
static void Draw(); static void Draw();
#ifdef GTASA #ifdef GTASA
static void ChangePlayerModel(std::string &model); static void ChangePlayerModel(std::string& model);
static void ChangePlayerCloth(std::string &model); static void ChangePlayerCloth(std::string& model);
static void TopDownCameraView(); static void TopDownCameraView();
#else // GTA3 & GTAVC #else // GTA3 & GTAVC
static void ChangePlayerModel(std::string &cat, std::string &name, std::string &id); static void ChangePlayerModel(std::string& cat, std::string& name, std::string& id);
#endif #endif
}; };

View File

@ -1,10 +1,12 @@
#include "pch.h"
#include "CFileLoader.h" #include "CFileLoader.h"
#include "extensions/Paths.h" #include "extensions/Paths.h"
#include "pch.h"
ResourceStore::ResourceStore(const char *text, eResourceType type, ImVec2 imageSize) : m_ImageSize(imageSize) ResourceStore::ResourceStore(const char* text, eResourceType type, ImVec2 imageSize)
: m_ImageSize(imageSize)
{ {
if (type == eResourceType::TYPE_TEXT || type == eResourceType::TYPE_BOTH) if (type == eResourceType::TYPE_TEXT
|| type == eResourceType::TYPE_BOTH)
{ {
m_pJson = std::make_unique<CJson>(text); m_pJson = std::make_unique<CJson>(text);
@ -17,14 +19,16 @@ ResourceStore::ResourceStore(const char *text, eResourceType type, ImVec2 imageS
} }
} }
} }
if (type == eResourceType::TYPE_IMAGE || type == eResourceType::TYPE_BOTH) if (type == eResourceType::TYPE_IMAGE
|| type == eResourceType::TYPE_BOTH)
{ {
/* /*
Textures need to be loaded from main thread Textures need to be loaded from main thread
Loading it directly here doesn't work Loading it directly here doesn't work
*/ */
Events::processScriptsEvent += [text, this]() { Events::processScriptsEvent += [text, this]()
{
if (!m_bTexturesLoaded) if (!m_bTexturesLoaded)
{ {
LoadTextureResource(text); LoadTextureResource(text);
@ -34,30 +38,30 @@ ResourceStore::ResourceStore(const char *text, eResourceType type, ImVec2 imageS
} }
} }
static void *GetTextureFromRaster(RwTexture *pTexture) static void* GetTextureFromRaster(RwTexture* pTexture)
{ {
RwRasterEx *raster = (RwRasterEx *)(&pTexture->raster->parent); RwRasterEx* raster = (RwRasterEx*)(&pTexture->raster->parent);
return (&raster->m_pRenderResource->texture); return (&raster->m_pRenderResource->texture);
} }
void ResourceStore::LoadTextureResource(std::string &&name) void ResourceStore::LoadTextureResource(std::string&& name)
{ {
std::string fullPath = PLUGIN_PATH((char *)"CheatMenu\\") + name + ".txd"; std::string fullPath = PLUGIN_PATH((char*)"CheatMenu\\") + name + ".txd";
RwTexDictionary *pRwTexDictionary = CFileLoader::LoadTexDictionary(fullPath.c_str()); RwTexDictionary* pRwTexDictionary = CFileLoader::LoadTexDictionary(fullPath.c_str());
if (pRwTexDictionary) if (pRwTexDictionary)
{ {
RwLinkList *pRLL = (RwLinkList *)pRwTexDictionary->texturesInDict.link.next; RwLinkList *pRLL = (RwLinkList*)pRwTexDictionary->texturesInDict.link.next;
RwTexDictionary *pEndDic; RwTexDictionary *pEndDic;
do do
{ {
pEndDic = (RwTexDictionary *)pRLL->link.next; pEndDic = (RwTexDictionary*)pRLL->link.next;
RwTexture *pTex = (RwTexture *)&pRLL[-1]; RwTexture *pTex = (RwTexture*)&pRLL[-1];
m_ImagesList.push_back(std::make_unique<TextureResource>()); m_ImagesList.push_back(std::make_unique<TextureResource>());
m_ImagesList.back().get()->m_pRwTexture = pTex; m_ImagesList.back().get()->m_pRwTexture = pTex;
// Fetch IDirec9Texture9* from RwTexture* // Fetch IDirec9Texture9* from RwTexture*
m_ImagesList.back().get()->m_pTexture = GetTextureFromRaster(pTex); m_ImagesList.back().get()->m_pTexture = GetTextureFromRaster(pTex);
@ -84,7 +88,8 @@ void ResourceStore::LoadTextureResource(std::string &&name)
{ {
m_Categories.push_back(m_ImagesList.back().get()->m_CategoryName); m_Categories.push_back(m_ImagesList.back().get()->m_CategoryName);
} }
pRLL = (RwLinkList *)pEndDic; pRLL = (RwLinkList*)pEndDic;
} while (pEndDic != (RwTexDictionary *)&pRwTexDictionary->texturesInDict); }
} while ( pEndDic != (RwTexDictionary*)&pRwTexDictionary->texturesInDict );
}
} }

View File

@ -1,61 +1,62 @@
#include <string>
#include <rw/rwcore.h>
#include "json.h"
#include "../depend/imgui/imgui.h" #include "../depend/imgui/imgui.h"
#include "d3d9.h" #include "d3d9.h"
#include "json.h"
#include <rw/rwcore.h>
#include <string>
struct RwD3D9Raster struct RwD3D9Raster
{ {
union { union
IDirect3DTexture9 *texture; {
IDirect3DSurface9 *surface; IDirect3DTexture9* texture;
}; IDirect3DSurface9* surface;
unsigned char *palette; };
unsigned char alpha; unsigned char* palette;
unsigned char cubeTextureFlags; /* 0x01 IS_CUBEMAP_TEX */ unsigned char alpha;
unsigned char textureFlags; /* 0x10 IS_COMPRESSED */ unsigned char cubeTextureFlags; /* 0x01 IS_CUBEMAP_TEX */
unsigned char lockedLevel; unsigned char textureFlags; /* 0x10 IS_COMPRESSED */
IDirect3DSurface9 *lockedSurface; unsigned char lockedLevel;
D3DLOCKED_RECT lockedRect; IDirect3DSurface9* lockedSurface;
D3DFORMAT format; D3DLOCKED_RECT lockedRect;
IDirect3DSwapChain9 *swapChain; D3DFORMAT format;
HWND *hwnd; IDirect3DSwapChain9* swapChain;
HWND* hwnd;
}; };
struct RwRasterEx : public RwRaster struct RwRasterEx : public RwRaster
{ {
RwD3D9Raster *m_pRenderResource; RwD3D9Raster *m_pRenderResource;
}; };
struct TextureResource struct TextureResource
{ {
std::string m_FileName; std::string m_FileName;
std::string m_CategoryName; std::string m_CategoryName;
RwTexture *m_pRwTexture = nullptr; RwTexture *m_pRwTexture = nullptr;
void *m_pTexture = nullptr; void *m_pTexture = nullptr;
}; };
enum eResourceType enum eResourceType
{ {
TYPE_IMAGE, TYPE_IMAGE,
TYPE_TEXT, TYPE_TEXT,
TYPE_BOTH, TYPE_BOTH,
}; };
using TextureResourceList = std::vector<std::unique_ptr<TextureResource>>; using TextureResourceList = std::vector<std::unique_ptr<TextureResource>>;
class ResourceStore class ResourceStore
{ {
private: private:
void LoadTextureResource(std::string &&path); void LoadTextureResource(std::string&& path);
public: public:
ImGuiTextFilter m_Filter = ""; ImGuiTextFilter m_Filter = "";
std::vector<std::string> m_Categories = {"All"}; std::vector<std::string> m_Categories = {"All"};
std::string m_Selected = "All"; std::string m_Selected = "All";
std::unique_ptr<CJson> m_pJson; std::unique_ptr<CJson> m_pJson;
TextureResourceList m_ImagesList; TextureResourceList m_ImagesList;
ImVec2 m_ImageSize; ImVec2 m_ImageSize;
bool m_bTexturesLoaded = false; bool m_bTexturesLoaded = false;
ResourceStore(const char *text, eResourceType type = TYPE_IMAGE, ImVec2 imageSize = ImVec2(64, 64)); ResourceStore(const char* text, eResourceType type = TYPE_IMAGE, ImVec2 imageSize = ImVec2(64, 64));
}; };

View File

@ -1,297 +1,293 @@
#include "pch.h"
#include "teleport.h" #include "teleport.h"
#include "menu.h" #include "menu.h"
#include "pch.h"
#include "ui.h" #include "ui.h"
#include "util.h" #include "util.h"
#ifdef GTASA #ifdef GTASA
// FlA // FlA
tRadarTrace *CRadar::ms_RadarTrace = reinterpret_cast<tRadarTrace *>(patch::GetPointer(0x5838B0 + 2)); tRadarTrace* CRadar::ms_RadarTrace = reinterpret_cast<tRadarTrace*>(patch::GetPointer(0x5838B0 + 2));
void Teleport::FetchRadarSpriteData() void Teleport::FetchRadarSpriteData()
{ {
uint cur_timer = CTimer::m_snTimeInMilliseconds; uint cur_timer = CTimer::m_snTimeInMilliseconds;
static uint timer = cur_timer; static uint timer = cur_timer;
// Update the radar list each 5 seconds // Update the radar list each 5 seconds
if (cur_timer - timer < 5000) if (cur_timer - timer < 5000)
{ {
return; return;
} }
m_tpData.m_pJson->m_Data.erase("Radar"); m_tpData.m_pJson->m_Data.erase("Radar");
// 175 is the max number of sprites, FLA can increase this limit, might need to update this // 175 is the max number of sprites, FLA can increase this limit, might need to update this
for (int i = 0; i != 175; ++i) for (int i = 0; i != 175; ++i)
{ {
CVector pos = CRadar::ms_RadarTrace[i].m_vPosition; CVector pos = CRadar::ms_RadarTrace[i].m_vPosition;
uchar sprite = CRadar::ms_RadarTrace[i].m_nBlipSprite; uchar sprite = CRadar::ms_RadarTrace[i].m_nBlipSprite;
auto sprite_name = m_SpriteJson.m_Data[std::to_string(sprite)].get<std::string>(); auto sprite_name = m_SpriteJson.m_Data[std::to_string(sprite)].get<std::string>();
std::string key_name = sprite_name + ", " + Util::GetLocationName(&pos); std::string key_name = sprite_name + ", " + Util::GetLocationName(&pos);
m_tpData.m_pJson->m_Data["Radar"][key_name] = m_tpData.m_pJson->m_Data["Radar"][key_name] = "0, " + std::to_string(pos.x) + ", " + std::to_string(pos.y) + ", " +
"0, " + std::to_string(pos.x) + ", " + std::to_string(pos.y) + ", " + std::to_string(pos.z); std::to_string(pos.z);
/* /*
"Radar" : { "Radar" : {
"key_name" : "0, x, y, z", "key_name" : "0, x, y, z",
} }
*/ */
} }
} }
#endif #endif
Teleport::Teleport() Teleport::Teleport()
{ {
m_bQuickTeleport = gConfig.GetValue("quick_teleport", false); m_bQuickTeleport = gConfig.GetValue("quick_teleport", false);
Events::processScriptsEvent += [] { Events::processScriptsEvent += []
if ((m_Teleport::m_bEnabled == true) && ((CTimer::m_snTimeInMilliseconds - m_Teleport::m_nTimer) > 500)) {
{ if ((m_Teleport::m_bEnabled == true) && ((CTimer::m_snTimeInMilliseconds - m_Teleport::m_nTimer) > 500))
CPlayerPed *player = FindPlayerPed(); {
CPlayerPed* player = FindPlayerPed();
#ifdef GTASA #ifdef GTASA
CEntity *player_entity = FindPlayerEntity(-1); CEntity* player_entity = FindPlayerEntity(-1);
m_Teleport::m_fPos.z = m_Teleport::m_fPos.z = CWorld::FindGroundZFor3DCoord(m_Teleport::m_fPos.x, m_Teleport::m_fPos.y,
CWorld::FindGroundZFor3DCoord(m_Teleport::m_fPos.x, m_Teleport::m_fPos.y, m_Teleport::m_fPos.z + 100.0f, m_Teleport::m_fPos.z + 100.0f, nullptr, &player_entity) + 1.0f;
nullptr, &player_entity) +
1.0f;
#else // GTA3 & GTAVC #else // GTA3 & GTAVC
m_Teleport::m_fPos.z = CWorld::FindGroundZFor3DCoord(m_Teleport::m_fPos.x, m_Teleport::m_fPos.y, 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) + m_Teleport::m_fPos.z + 100.0f, nullptr) + 1.0f;
1.0f; #endif
#endif CVehicle* pVeh = player->m_pVehicle;
CVehicle *pVeh = player->m_pVehicle;
if (pVeh && BY_GAME(player->m_nPedFlags.bInVehicle, player->m_pVehicle, player->m_pVehicle)) if (pVeh && BY_GAME(player->m_nPedFlags.bInVehicle, player->m_pVehicle, player->m_pVehicle))
{ {
BY_GAME(pVeh->Teleport(m_Teleport::m_fPos, false), pVeh->Teleport(m_Teleport::m_fPos)); BY_GAME(pVeh->Teleport(m_Teleport::m_fPos, false, false), pVeh->Teleport(m_Teleport::m_fPos));
} }
else else
{ {
BY_GAME(player->Teleport(m_Teleport::m_fPos, false), player->Teleport(m_Teleport::m_fPos)); BY_GAME(player->Teleport(m_Teleport::m_fPos, false, false), player->Teleport(m_Teleport::m_fPos));
} }
m_Teleport::m_bEnabled = false; m_Teleport::m_bEnabled = false;
Command<Commands::FREEZE_CHAR_POSITION_AND_DONT_LOAD_COLLISION>(CPools::GetPedRef(player), false); Command<Commands::FREEZE_CHAR_POSITION_AND_DONT_LOAD_COLLISION>(CPools::GetPedRef(player), false);
Command<Commands::RESTORE_CAMERA_JUMPCUT>(); Command<Commands::RESTORE_CAMERA_JUMPCUT>();
TheCamera.Fade(0, 1); TheCamera.Fade(0, 1);
} }
if (m_bQuickTeleport) if (m_bQuickTeleport)
{ {
if (quickTeleport.Pressed() && ((CTimer::m_snTimeInMilliseconds - m_nQuickTeleportTimer) > 500)) if (quickTeleport.Pressed()
{ && ((CTimer::m_snTimeInMilliseconds - m_nQuickTeleportTimer) > 500))
m_nQuickTeleportTimer = CTimer::m_snTimeInMilliseconds; {
TeleportPlayer(true); m_nQuickTeleportTimer = CTimer::m_snTimeInMilliseconds;
} TeleportPlayer(true);
} }
}; }
};
} }
void Teleport::TeleportPlayer(bool get_marker, CVector pos, int interior_id) void Teleport::TeleportPlayer(bool get_marker, CVector pos, int interior_id)
{ {
CPlayerPed *pPlayer = FindPlayerPed(); CPlayerPed* pPlayer = FindPlayerPed();
CVehicle *pVeh = pPlayer->m_pVehicle; CVehicle* pVeh = pPlayer->m_pVehicle;
#ifdef GTASA #ifdef GTASA
if (get_marker) if (get_marker)
{ {
tRadarTrace targetBlip = CRadar::ms_RadarTrace[LOWORD(FrontEndMenuManager.m_nTargetBlipIndex)]; tRadarTrace targetBlip = CRadar::ms_RadarTrace[LOWORD(FrontEndMenuManager.m_nTargetBlipIndex)];
if (targetBlip.m_nBlipSprite != RADAR_SPRITE_WAYPOINT) if (targetBlip.m_nBlipSprite != RADAR_SPRITE_WAYPOINT)
{ {
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; return;
} }
CEntity *pPlayerEntity = FindPlayerEntity(-1); CEntity* pPlayerEntity = FindPlayerEntity(-1);
pos = targetBlip.m_vPosition; pos = targetBlip.m_vPosition;
pos.z = CWorld::FindGroundZFor3DCoord(pos.x, pos.y, 1000, nullptr, &pPlayerEntity) + 50.f; pos.z = CWorld::FindGroundZFor3DCoord(pos.x, pos.y, 1000, nullptr, &pPlayerEntity) + 50.f;
m_Teleport::m_fPos = pos; m_Teleport::m_fPos = pos;
m_Teleport::m_nTimer = CTimer::m_snTimeInMilliseconds; m_Teleport::m_nTimer = CTimer::m_snTimeInMilliseconds;
m_Teleport::m_bEnabled = true; m_Teleport::m_bEnabled = true;
TheCamera.Fade(0, 0); TheCamera.Fade(0, 0);
Command<Commands::FREEZE_CHAR_POSITION_AND_DONT_LOAD_COLLISION>(CPools::GetPedRef(pPlayer), true); Command<Commands::FREEZE_CHAR_POSITION_AND_DONT_LOAD_COLLISION>(CPools::GetPedRef(pPlayer), true);
} }
#endif #endif
#ifdef GTA3 #ifdef GTA3
CStreaming::LoadScene(pos); CStreaming::LoadScene(pos);
#else #else
CStreaming::LoadScene(&pos); CStreaming::LoadScene(&pos);
CStreaming::LoadSceneCollision(&pos); CStreaming::LoadSceneCollision(&pos);
#endif #endif
CStreaming::LoadAllRequestedModels(false); CStreaming::LoadAllRequestedModels(false);
#ifdef GTASA #ifdef GTASA
if (pVeh && pPlayer->m_nPedFlags.bInVehicle) if (pVeh && pPlayer->m_nPedFlags.bInVehicle)
{ {
pVeh->Teleport(pos, false); pVeh->Teleport(pos, false);
if (pVeh->m_nVehicleClass == VEHICLE_BIKE)
reinterpret_cast<CBike*>(pVeh)->PlaceOnRoadProperly();
else if (pVeh->m_nVehicleClass != VEHICLE_BOAT)
reinterpret_cast<CAutomobile*>(pVeh)->PlaceOnRoadProperly();
if (pVeh->m_nVehicleClass == VEHICLE_BIKE) BY_GAME(pVeh->m_nAreaCode, pVeh->m_nInterior) = interior_id;
reinterpret_cast<CBike *>(pVeh)->PlaceOnRoadProperly(); }
else if (pVeh->m_nVehicleClass != VEHICLE_BOAT) else
reinterpret_cast<CAutomobile *>(pVeh)->PlaceOnRoadProperly(); {
pPlayer->Teleport(pos, false);
BY_GAME(pVeh->m_nAreaCode, pVeh->m_nInterior) = interior_id; }
}
else
{
pPlayer->Teleport(pos, false);
}
#else // GTA3 & GTAVC #else // GTA3 & GTAVC
if (pVeh && pPlayer->m_pVehicle) if (pVeh && pPlayer->m_pVehicle)
{ {
#ifndef GTA3 #ifndef GTA3
BY_GAME(pPlayer->m_nAreaCode, pPlayer->m_nInterior, NULL) = interior_id; BY_GAME(pPlayer->m_nAreaCode, pPlayer->m_nInterior, NULL) = interior_id;
#endif #endif
pVeh->Teleport(pos); pVeh->Teleport(pos);
} }
else else
{ {
pPlayer->Teleport(pos); pPlayer->Teleport(pos);
} }
#endif #endif
#ifndef GTA3 #ifndef GTA3
BY_GAME(pPlayer->m_nAreaCode, pPlayer->m_nInterior, NULL) = interior_id; BY_GAME(pPlayer->m_nAreaCode, pPlayer->m_nInterior, NULL) = interior_id;
#endif #endif
Command<Commands::SET_AREA_VISIBLE>(interior_id); Command<Commands::SET_AREA_VISIBLE>(interior_id);
} }
void Teleport::TeleportToLocation(std::string &rootkey, std::string &bLocName, std::string &loc) void Teleport::TeleportToLocation(std::string& rootkey, std::string& bLocName, std::string& loc)
{ {
try try
{ {
int dimension = 0; int dimension = 0;
CVector pos; CVector pos;
sscanf(loc.c_str(), "%d,%f,%f,%f", &dimension, &pos.x, &pos.y, &pos.z); sscanf(loc.c_str(), "%d,%f,%f,%f", &dimension, &pos.x, &pos.y, &pos.z);
TeleportPlayer(false, pos, dimension); TeleportPlayer(false, pos, dimension);
} }
catch (...) catch (...)
{ {
SetHelpMessage("Invalid location", false, false, false); SetHelpMessage("Invalid location", false, false, false);
} }
} }
void Teleport::RemoveTeleportEntry(std::string &category, std::string &key, std::string &val) void Teleport::RemoveTeleportEntry(std::string& category, std::string& key, std::string& val)
{ {
if (category == "Custom") if (category == "Custom")
{ {
m_tpData.m_pJson->m_Data["Custom"].erase(key); m_tpData.m_pJson->m_Data["Custom"].erase(key);
SetHelpMessage("Location removed", false, false, false); SetHelpMessage("Location removed", false, false, false);
m_tpData.m_pJson->WriteToDisk(); m_tpData.m_pJson->WriteToDisk();
} }
else else
{ {
SetHelpMessage("You can only remove custom location", false, false, false); SetHelpMessage("You can only remove custom location", false, false, false);
} }
} }
void Teleport::Draw() void Teleport::Draw()
{ {
if (ImGui::BeginTabBar("Teleport", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll)) if (ImGui::BeginTabBar("Teleport", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll))
{ {
ImGui::Spacing(); ImGui::Spacing();
if (ImGui::BeginTabItem("Teleport")) if (ImGui::BeginTabItem("Teleport"))
{ {
ImGui::Spacing(); ImGui::Spacing();
if (ImGui::BeginChild("Teleport Child")) if (ImGui::BeginChild("Teleport Child"))
{ {
ImGui::Columns(2, nullptr, false); ImGui::Columns(2, nullptr, false);
ImGui::Checkbox("Insert coordinates", &m_bInsertCoord); ImGui::Checkbox("Insert coordinates", &m_bInsertCoord);
ImGui::NextColumn(); ImGui::NextColumn();
#ifdef GTASA #ifdef GTASA
if (Ui::CheckboxWithHint( if (Ui::CheckboxWithHint("Quick teleport", &m_bQuickTeleport,
"Quick teleport", &m_bQuickTeleport, std::string(std::string("Teleport to the location of your radar\ntarget blip using ")
std::string(std::string("Teleport to the location of your radar\ntarget blip using ") + + quickTeleport.GetNameString()).c_str()))
quickTeleport.GetNameString()) {
.c_str())) gConfig.SetValue("quick_teleport", m_bQuickTeleport);
{ }
gConfig.SetValue("quick_teleport", m_bQuickTeleport); #endif
} ImGui::Columns(1);
#endif ImGui::Spacing();
ImGui::Columns(1);
ImGui::Spacing();
if (m_bInsertCoord) if (m_bInsertCoord)
{ {
CVector pos = FindPlayerPed()->GetPosition(); CVector pos = FindPlayerPed()->GetPosition();
strcpy(m_nInputBuffer, strcpy(m_nInputBuffer,
(std::to_string(static_cast<int>(pos.x)) + ", " + std::to_string(static_cast<int>(pos.y)) + (std::to_string(static_cast<int>(pos.x)) + ", " + std::to_string(static_cast<int>(pos.y)) +
", " + std::to_string(static_cast<int>(pos.z))) ", " + std::to_string(static_cast<int>(pos.z))).c_str());
.c_str()); }
}
ImGui::InputTextWithHint("Coordinates", "x, y, z", m_nInputBuffer, IM_ARRAYSIZE(m_nInputBuffer)); ImGui::InputTextWithHint("Coordinates", "x, y, z", m_nInputBuffer, IM_ARRAYSIZE(m_nInputBuffer));
ImGui::Spacing(); ImGui::Spacing();
if (ImGui::Button("Teleport to coord", Ui::GetSize(2))) if (ImGui::Button("Teleport to coord", Ui::GetSize(2)))
{ {
CVector pos{0, 0, 10}; CVector pos{0, 0, 10};
try try
{ {
sscanf(m_nInputBuffer, "%f,%f,%f", &pos.x, &pos.y, &pos.z); sscanf(m_nInputBuffer,"%f,%f,%f", &pos.x, &pos.y, &pos.z);
pos.z += 1.0f; pos.z += 1.0f;
TeleportPlayer(false, pos); TeleportPlayer(false, pos);
} }
catch (...) catch (...)
{ {
SetHelpMessage("Invalid coordinate", false, false, false); SetHelpMessage("Invalid coordinate", false, false, false);
} }
} }
ImGui::SameLine(); ImGui::SameLine();
#ifdef GTASA #ifdef GTASA
if (ImGui::Button("Teleport to marker", Ui::GetSize(2))) if (ImGui::Button("Teleport to marker", Ui::GetSize(2)))
{ {
TeleportPlayer(true); TeleportPlayer(true);
} }
#else #else
if (ImGui::Button("Teleport to map center", Ui::GetSize(2))) if (ImGui::Button("Teleport to map center", Ui::GetSize(2)))
{ {
TeleportPlayer(false, CVector(0, 0, 23)); TeleportPlayer(false, CVector(0, 0, 23));
} }
#endif #endif
ImGui::EndChild(); ImGui::EndChild();
} }
ImGui::EndTabItem(); ImGui::EndTabItem();
} }
if (ImGui::BeginTabItem("Search")) if (ImGui::BeginTabItem("Search"))
{ {
#ifdef GTASA #ifdef GTASA
FetchRadarSpriteData(); FetchRadarSpriteData();
#endif #endif
ImGui::Spacing(); ImGui::Spacing();
Ui::DrawJSON(m_tpData, TeleportToLocation, RemoveTeleportEntry); Ui::DrawJSON(m_tpData, TeleportToLocation,RemoveTeleportEntry);
ImGui::EndTabItem(); ImGui::EndTabItem();
} }
if (ImGui::BeginTabItem("Custom")) if (ImGui::BeginTabItem("Custom"))
{ {
ImGui::Spacing(); ImGui::Spacing();
ImGui::InputTextWithHint("Location", "Groove Street", m_nLocationBuffer, IM_ARRAYSIZE(m_nInputBuffer)); ImGui::InputTextWithHint("Location", "Groove Street", m_nLocationBuffer, IM_ARRAYSIZE(m_nInputBuffer));
ImGui::InputTextWithHint("Coordinates", "x, y, z", m_nInputBuffer, IM_ARRAYSIZE(m_nInputBuffer)); ImGui::InputTextWithHint("Coordinates", "x, y, z", m_nInputBuffer, IM_ARRAYSIZE(m_nInputBuffer));
ImGui::Spacing(); ImGui::Spacing();
if (ImGui::Button("Add location", Ui::GetSize())) if (ImGui::Button("Add location", Ui::GetSize()))
{ {
m_tpData.m_pJson->m_Data["Custom"][m_nLocationBuffer] = ("0, " + std::string(m_nInputBuffer)); m_tpData.m_pJson->m_Data["Custom"][m_nLocationBuffer] = ("0, " + std::string(m_nInputBuffer));
#ifdef GTASA #ifdef GTASA
// Clear the Radar coordinates // Clear the Radar coordinates
m_tpData.m_pJson->m_Data.erase("Radar"); m_tpData.m_pJson->m_Data.erase("Radar");
m_tpData.m_pJson->m_Data["Radar"] = {}; m_tpData.m_pJson->m_Data["Radar"] = {};
#endif #endif
m_tpData.m_pJson->WriteToDisk(); m_tpData.m_pJson->WriteToDisk();
} }
ImGui::EndTabItem(); ImGui::EndTabItem();
} }
ImGui::EndTabBar(); ImGui::EndTabBar();
} }
} }

View File

@ -1,42 +1,42 @@
#pragma once #pragma once
#include "pch.h"
#include <vector> #include <vector>
#include "pch.h"
class Teleport class Teleport
{ {
private: private:
static inline bool m_bInsertCoord; static inline bool m_bInsertCoord;
static inline bool m_bQuickTeleport; static inline bool m_bQuickTeleport;
static inline char m_nInputBuffer[INPUT_BUFFER_SIZE]; static inline char m_nInputBuffer[INPUT_BUFFER_SIZE];
static inline ResourceStore m_tpData{"teleport", eResourceType::TYPE_TEXT}; static inline ResourceStore m_tpData{ "teleport", eResourceType::TYPE_TEXT };
static inline char m_nLocationBuffer[INPUT_BUFFER_SIZE]; static inline char m_nLocationBuffer[INPUT_BUFFER_SIZE];
static inline uint m_nQuickTeleportTimer; static inline uint m_nQuickTeleportTimer;
#ifdef GTASA #ifdef GTASA
static inline CJson m_SpriteJson = CJson("radar sprite"); static inline CJson m_SpriteJson = CJson("radar sprite");
#endif #endif
struct m_Teleport struct m_Teleport
{ {
static inline bool m_bEnabled; static inline bool m_bEnabled;
static inline CVector m_fPos = {-1, -1, -1}; static inline CVector m_fPos = { -1, -1, -1 };
static inline uint m_nTimer; static inline uint m_nTimer;
}; };
#ifdef GTASA #ifdef GTASA
/* /*
Generates radar sprite coordinates on the fly. Generates radar sprite coordinates on the fly.
Shouldn't get saved in 'teleport.json', needs to be cleared at game shutdown. Shouldn't get saved in 'teleport.json', needs to be cleared at game shutdown.
*/ */
static void FetchRadarSpriteData(); static void FetchRadarSpriteData();
#endif #endif
protected: protected:
Teleport(); Teleport();
public: public:
static void Draw(); static void Draw();
static void TeleportPlayer(bool get_marker = false, CVector pos = CVector(0, 0, 0), int interior_id = 0); 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 TeleportToLocation(std::string& rootkey, std::string& bLocName, std::string& loc);
static void RemoveTeleportEntry(std::string &rootkey, std::string &key, std::string &val); static void RemoveTeleportEntry(std::string& rootkey, std::string& key, std::string& val);
}; };

View File

@ -1,49 +1,49 @@
#pragma once #pragma once
uchar *m_nAmbientRed = (uchar *)BY_GAME(0x560C61, 0x9388C8);
uchar *m_nAmbientGreen = (uchar *)BY_GAME(0x55F4D6, 0x78D508);
uchar *m_nAmbientBlue = (uchar *)BY_GAME(0x55F4E8, 0x813D48);
uchar *m_nAmbientRed_Obj = (uchar *)BY_GAME(0x55F4FA, 0x7D53B0);
uchar *m_nAmbientGreen_Obj = (uchar *)BY_GAME(0x55F50C, 0x7D9370);
uchar *m_nAmbientBlue_Obj = (uchar *)BY_GAME(0x55F51E, 0x94C038);
uchar *m_nSkyTopRed = (uchar *)BY_GAME(0x55F531, 0x94BE98);
uchar *m_nSkyTopGreen = (uchar *)BY_GAME(0x55F53D, 0x933A58);
uchar *m_nSkyTopBlue = (uchar *)BY_GAME(0x55F549, 0x94A170);
uchar *m_nSkyBottomRed = (uchar *)BY_GAME(0x55F555, 0x7E44A0);
uchar *m_nSkyBottomGreen = (uchar *)BY_GAME(0x55F561, 0x7E9CD0);
uchar *m_nSkyBottomBlue = (uchar *)BY_GAME(0x55F56D, 0x92D420);
uchar *m_nSunCoreRed = (uchar *)BY_GAME(0x55F59D, 0x944098);
uchar *m_nSunCoreGreen = (uchar *)BY_GAME(0x55F5A9, 0x7D94C0);
uchar *m_nSunCoreBlue = (uchar *)BY_GAME(0x55F5B5, 0x8614F8);
uchar *m_nSunCoronaRed = (uchar *)BY_GAME(0x55F579, 0x78CCD8);
uchar *m_nSunCoronaGreen = (uchar *)BY_GAME(0x55F585, 0x7DBC08);
uchar *m_nSunCoronaBlue = (uchar *)BY_GAME(0x55F591, 0x7D1818);
uchar *m_nLowCloudsRed = (uchar *)BY_GAME(0x55F653, 0x8100C0);
uchar *m_nLowCloudsGreen = (uchar *)BY_GAME(0x55F65F, 0x94AEA0);
uchar *m_nLowCloudsBlue = (uchar *)BY_GAME(0x55F66B, 0x94BDF0);
uchar *m_fLightsOnGroundBrightness = (uchar *)BY_GAME(0x55F640, 0x92D378);
uchar *m_nPoleShadowStrength = (uchar *)BY_GAME(0x55F60F, 0x812090);
uchar *m_nLightShadowStrength = (uchar *)BY_GAME(0x55F603, 0x811828);
uchar *m_nShadowStrength = (uchar *)BY_GAME(0x55F5F7, 0x92D260);
uchar *m_fSpriteBrightness = (uchar *)BY_GAME(0x55F5E4, 0x7D5308);
uchar *m_fSpriteSize = (uchar *)BY_GAME(0x55F5D2, 0x94B848);
uchar *m_fSunSize = (uchar *)BY_GAME(0x55F5C0, 0x818720);
short *m_fFogStart = (short *)BY_GAME(0x55F62E, 0x94D638);
short *m_fFarClip = (short *)BY_GAME(0x55F61B, 0x94D4E8);
uchar *m_fWaterRed = (uchar *)BY_GAME(0x55F69C, 0x7E5560);
uchar *m_fWaterGreen = (uchar *)BY_GAME(0x55F6B0, 0x7DE148);
uchar *m_fWaterBlue = (uchar *)BY_GAME(0x55F6C3, 0x862248);
uchar *m_fWaterAlpha = (uchar *)BY_GAME(0x55F6D6, 0x7DDAE0);
#ifdef GTASA #ifdef GTASA
uchar *m_nAmbientRed = (uchar *)0x560C61;
uchar *m_nAmbientGreen = (uchar *)0x55F4D6;
uchar *m_nAmbientBlue = (uchar *)0x55F4E8;
uchar *m_nAmbientRed_Obj = (uchar *)0x55F4FA;
uchar *m_nAmbientGreen_Obj = (uchar *)0x55F50C;
uchar *m_nAmbientBlue_Obj = (uchar *)0x55F51E;
uchar *m_nSkyTopRed = (uchar *)0x55F531;
uchar *m_nSkyTopGreen = (uchar *)0x55F53D;
uchar *m_nSkyTopBlue = (uchar *)0x55F549;
uchar *m_nSkyBottomRed = (uchar *)0x55F555;
uchar *m_nSkyBottomGreen = (uchar *)0x55F561;
uchar *m_nSkyBottomBlue = (uchar *)0x55F56D;
uchar *m_nSunCoreRed = (uchar *)0x55F59D;
uchar *m_nSunCoreGreen = (uchar *)0x55F5A9;
uchar *m_nSunCoreBlue = (uchar *)0x55F5B5;
uchar *m_nSunCoronaRed = (uchar *)0x55F579;
uchar *m_nSunCoronaGreen = (uchar *)0x55F585;
uchar *m_nSunCoronaBlue = (uchar *)0x55F591;
uchar *m_nLowCloudsRed = (uchar *)0x55F653;
uchar *m_nLowCloudsGreen = (uchar *)0x55F65F;
uchar *m_nLowCloudsBlue = (uchar *)0x55F66B;
uchar *m_fLightsOnGroundBrightness = (uchar *)0x55F640;
uchar *m_nPoleShadowStrength = (uchar *)0x55F60F;
uchar *m_nLightShadowStrength = (uchar *)0x55F603;
uchar *m_nShadowStrength = (uchar *)0x55F5F7;
uchar *m_fSpriteBrightness = (uchar *)0x55F5E4;
uchar *m_fSpriteSize = (uchar *)0x55F5D2;
uchar *m_fSunSize = (uchar *)0x55F5C0;
short *m_fFogStart = (short *)0x55F62E;
short *m_fFarClip = (short *)0x55F61B;
uchar *m_fWaterRed = (uchar *)0x55F69C;
uchar *m_fWaterGreen = (uchar *)0x55F6B0;
uchar *m_fWaterBlue = (uchar *)0x55F6C3;
uchar *m_fWaterAlpha = (uchar *)0x55F6D6;
uchar *m_fPostFx2Alpha = (uchar *)0x55F77D; uchar *m_fPostFx2Alpha = (uchar *)0x55F77D;
uchar *m_fPostFx2Blue = (uchar *)0x55F767; uchar *m_fPostFx2Blue = (uchar *)0x55F767;
uchar *m_fPostFx2Green = (uchar *)0x55F751; uchar *m_fPostFx2Green = (uchar *)0x55F751;
@ -63,6 +63,49 @@ uchar *m_nHighLightMinIntensity = (uchar *)0x55F7A9;
uchar *m_fCloudAlpha = (uchar *)0x55F793; uchar *m_fCloudAlpha = (uchar *)0x55F793;
#elif GTAVC #elif GTAVC
uchar *m_nAmbientRed = (uchar *)0x9388C8;
uchar *m_nAmbientGreen = (uchar *)0x78D508;
uchar *m_nAmbientBlue = (uchar *)0x813D48;
uchar *m_nAmbientRed_Obj = (uchar *)0x7D53B0;
uchar *m_nAmbientGreen_Obj = (uchar *)0x7D9370;
uchar *m_nAmbientBlue_Obj = (uchar *)0x94C038;
uchar *m_nSkyTopRed = (uchar *)0x94BE98;
uchar *m_nSkyTopGreen = (uchar *)0x933A58;
uchar *m_nSkyTopBlue = (uchar *)0x94A170;
uchar *m_nSkyBottomRed = (uchar *)0x7E44A0;
uchar *m_nSkyBottomGreen = (uchar *)0x7E9CD0;
uchar *m_nSkyBottomBlue = (uchar *)0x92D420;
uchar *m_nSunCoreRed = (uchar *)0x944098;
uchar *m_nSunCoreGreen = (uchar *)0x7D94C0;
uchar *m_nSunCoreBlue = (uchar *)0x8614F8;
uchar *m_nSunCoronaRed = (uchar *)0x78CCD8;
uchar *m_nSunCoronaGreen = (uchar *)0x7DBC08;
uchar *m_nSunCoronaBlue = (uchar *)0x7D1818;
uchar *m_nLowCloudsRed = (uchar *)0x8100C0;
uchar *m_nLowCloudsGreen = (uchar *)0x94AEA0;
uchar *m_nLowCloudsBlue = (uchar *)0x94BDF0;
uchar *m_fLightsOnGroundBrightness = (uchar *)0x92D378;
uchar *m_nPoleShadowStrength = (uchar *)0x812090;
uchar *m_nLightShadowStrength = (uchar *)0x811828;
uchar *m_nShadowStrength = (uchar *)0x92D260;
uchar *m_fSpriteBrightness = (uchar *)0x7D5308;
uchar *m_fSpriteSize = (uchar *)0x94B848;
uchar *m_fSunSize = (uchar *)0x818720;
short *m_fFogStart = (short *)0x94D638;
short *m_fFarClip = (short *)0x94D4E8;
uchar *m_fWaterRed = (uchar *)0x7E5560;
uchar *m_fWaterGreen = (uchar *)0x7DE148;
uchar *m_fWaterBlue = (uchar *)0x862248;
uchar *m_fWaterAlpha = (uchar *)0x7DDAE0;
uchar *m_nAmbientBlRed = (uchar *)0x78D5B0; uchar *m_nAmbientBlRed = (uchar *)0x78D5B0;
uchar *m_nAmbientBlGreen = (uchar *)0x861430; uchar *m_nAmbientBlGreen = (uchar *)0x861430;
uchar *m_nAmbientBlBlue = (uchar *)0x811740; uchar *m_nAmbientBlBlue = (uchar *)0x811740;
@ -86,4 +129,57 @@ uchar *m_nBottomCloudsBlue = (uchar *)0x7D9630;
uchar *m_nBlurRed = (uchar *)0x94B790; uchar *m_nBlurRed = (uchar *)0x94B790;
uchar *m_nBlurGreen = (uchar *)0x8621A0; uchar *m_nBlurGreen = (uchar *)0x8621A0;
uchar *m_nBlurBlue = (uchar *)0x945728; uchar *m_nBlurBlue = (uchar *)0x945728;
#else // GTA3
uchar *m_nAmbientRed = (uchar *)0x86AF78;
uchar *m_nAmbientGreen = (uchar *)0x665308;
uchar *m_nAmbientBlue = (uchar *)0x72CF88;
uchar *m_nDirRed = (uchar *)0x6FAB78;
uchar *m_nDirGreen = (uchar *)0x6F4528;
uchar *m_nDirBlue = (uchar *)0x83CE58;
uchar *m_nSkyTopRed = (uchar *)0x87FB90;
uchar *m_nSkyTopGreen = (uchar *)0x8460A8;
uchar *m_nSkyTopBlue = (uchar *)0x87B158;
uchar *m_nSkyBottomRed = (uchar *)0x6FA960;
uchar *m_nSkyBottomGreen = (uchar *)0x70D6A8;
uchar *m_nSkyBottomBlue = (uchar *)0x83D288;
uchar *m_nSunCoreRed = (uchar *)0x878360;
uchar *m_nSunCoreGreen = (uchar *)0x6EE088;
uchar *m_nSunCoreBlue = (uchar *)0x773A68;
uchar *m_nSunCoronaRed = (uchar *)0x664B60;
uchar *m_nSunCoronaGreen = (uchar *)0x6F01E0;
uchar *m_nSunCoronaBlue = (uchar *)0x6E6340;
uchar *m_nShadowStrength = (uchar *)0x83CFD8;
uchar *m_nLightShadowStrength = (uchar *)0x72B0F8;
uchar *m_nTreeShadowStrength = (uchar *)0x733450;
uchar *m_fSunSize = (uchar *)0x733510;
uchar *m_fSpriteSize = (uchar *)0x87F820;
uchar *m_fSpriteBrightness = (uchar *)0x6E96F0;
short *m_fFarClip = (short *)0x8804E0;
short *m_fFogStart = (short *)0x8806C8;
uchar *m_fLightsOnGroundBrightness = (uchar *)0x83D108;
uchar *m_nLowCloudsRed = (uchar *)0x726770;
uchar *m_nLowCloudsGreen = (uchar *)0x87BF08;
uchar *m_nLowCloudsBlue = (uchar *)0x87FA10;
uchar *m_nTopCloudsRed = (uchar *)0x70F2B0;
uchar *m_nTopCloudsGreen = (uchar *)0x72D288;
uchar *m_nTopCloudsBlue = (uchar *)0x86B108;
uchar *m_nBottomCloudsRed = (uchar *)0x6E8DA8;
uchar *m_nBottomCloudsGreen = (uchar *)0x715AA8;
uchar *m_nBottomCloudsBlue = (uchar *)0x6EE2D0;
uchar *m_fWaterRed = (uchar *)0x87C7E0;
uchar *m_fWaterGreen = (uchar *)0x774C10;
uchar *m_fWaterBlue = (uchar *)0x8784E0;
uchar *m_fWaterAlpha = (uchar *)0x733690;
#endif #endif

1319
src/ui.cpp

File diff suppressed because it is too large Load Diff

262
src/ui.h
View File

@ -4,183 +4,183 @@
class Ui class Ui
{ {
public: public:
struct NamedMemory struct NamedMemory
{ {
std::string name; std::string name;
int addr; int addr;
}; };
struct NamedValue struct NamedValue
{ {
std::string name; std::string name;
int value; int value;
}; };
struct JsonPopUpData struct JsonPopUpData
{ {
std::function<void(std::string &, std::string &, std::string &)> function; std::function<void(std::string&, std::string&, std::string&)> function;
std::string key; std::string key;
std::string rootKey; std::string rootKey;
std::string value; std::string value;
}; };
struct ImgPopUpData struct ImgPopUpData
{ {
std::function<void(std::string &)> function; std::function<void(std::string&)> function;
std::string value; std::string value;
}; };
static inline std::string m_HeaderId; static inline std::string m_HeaderId;
static inline JsonPopUpData jsonPopup; static inline JsonPopUpData jsonPopup;
static inline ImgPopUpData imgPopup; static inline ImgPopUpData imgPopup;
Ui() = delete;
Ui(Ui &) = delete;
static void CenterdText(const std::string &text); Ui() = delete;
static bool ColorButton(int color_id, std::vector<float> &color, ImVec2 size); Ui(Ui&) = delete;
static bool CheckboxAddress(const char *label, int addr = NULL, const char *hint = nullptr);
static bool CheckboxAddressEx(const char *label, int addr = NULL, int enabled_val = 1, int disabled_val = 0,
const char *hint = nullptr);
static bool CheckboxAddressVar(const char *label, bool val, int addr, const char *hint = nullptr);
static bool CheckboxAddressVarEx(const char *label, bool val, int addr, int enabled_val, int disabled_val,
const char *hint = nullptr);
static bool CheckboxBitFlag(const char *label, uint flag, const char *hint = nullptr);
static bool CheckboxWithHint(const char *label, bool *state, const char *hint = nullptr, bool is_disabled = false);
static void DrawHeaders(CallbackTable &data);
static void DrawJSON(ResourceStore &data, static void CenterdText(const std::string& text);
std::function<void(std::string &, std::string &, std::string &)> func_left_click, static bool ColorButton(int color_id, std::vector<float>& color, ImVec2 size);
std::function<void(std::string &, std::string &, std::string &)> func_right_click); static bool CheckboxAddress(const char* label, int addr = NULL, const char* hint = nullptr);
static void DrawImages(ResourceStore &store, std::function<void(std::string &)> on_left_click, static bool CheckboxAddressEx(const char* label, int addr = NULL, int enabled_val = 1, int disabled_val = 0,
std::function<void(std::string &)> on_right_click, const char* hint = nullptr);
std::function<std::string(std::string &)> get_name_func, static bool CheckboxAddressVar(const char* label, bool val, int addr, const char* hint = nullptr);
std::function<bool(std::string &)> verify_func = nullptr, static bool CheckboxAddressVarEx(const char* label, bool val, int addr, int enabled_val, int disabled_val,
const char **custom_names = nullptr, size_t length = 0); const char* hint = nullptr);
static bool CheckboxBitFlag(const char* label, uint flag, const char* hint = nullptr);
static bool CheckboxWithHint(const char* label, bool* state, const char* hint = nullptr, bool is_disabled = false);
static void DrawHeaders(CallbackTable& data);
template <typename T> static void DrawJSON(ResourceStore& data,
static void EditAddress(const char *label, int address, int min = 0, int def = 0, int max = 100); std::function<void(std::string&, std::string&, std::string&)> func_left_click,
static void EditBits(const char *label, int address, const std::vector<std::string> &names); std::function<void(std::string&, std::string&, std::string&)> func_right_click);
static void EditFloat(const char *label, int address, float min, float def, float max, float mul = 1, static void DrawImages(ResourceStore &store, std::function<void(std::string&)> on_left_click,
float change = 1.0f); std::function<void(std::string&)> on_right_click,
template <typename T> std::function<std::string(std::string&)> get_name_func,
static void EditReference(const char *label, T &address, int min = 0, int def = 0, int max = 100); std::function<bool(std::string&)> verify_func = nullptr,
static void EditRadioButtonAddress(const char *label, std::vector<NamedMemory> &named_mem); const char** custom_names = nullptr, size_t length = 0);
static void EditRadioButtonAddressEx(const char *label, int addr, std::vector<NamedValue> &named_val);
template <typename T>
static void EditAddress(const char* label, int address, int min = 0, int def = 0, int max = 100);
static void EditBits(const char* label, int address, const std::vector<std::string>& names);
static void EditFloat(const char* label, int address, float min, float def, float max, float mul = 1, float change = 1.0f);
template <typename T>
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 #ifdef GTASA
static void EditStat(const char *label, int stat_id, int min = 0, int def = 0, int max = 1000); static void EditStat(const char* label, int stat_id, int min = 0, int def = 0, int max = 1000);
#endif #endif
static void FilterWithHint(const char *label, ImGuiTextFilter &filter, const char *hint); static void FilterWithHint(const char* label, ImGuiTextFilter& filter, const char* hint);
static ImVec2 GetSize(short count = 1, bool spacing = true); static ImVec2 GetSize(short count = 1, bool spacing = true);
static bool ListBox(const char *label, std::vector<std::string> &all_items, int &selected); static bool ListBox(const char* label, std::vector<std::string>& all_items, int& selected);
static bool ListBoxStr(const char *label, std::vector<std::string> &all_items, std::string &selected); static bool ListBoxStr(const char* label, std::vector<std::string>& all_items, std::string& selected);
static bool ListBoxCustomNames(const char *label, std::vector<std::string> &all_items, std::string &selected, static bool ListBoxCustomNames(const char* label, std::vector<std::string>& all_items, std::string& selected, const char* custom_names[] = nullptr, size_t length = 0);
const char *custom_names[] = nullptr, size_t length = 0);
static void RadioButtonAddress(const char *label, std::vector<NamedMemory> &named_mem); static void RadioButtonAddress(const char* label, std::vector<NamedMemory>& named_mem);
static void RadioButtonAddressEx(const char *label, int addr, std::vector<NamedValue> &named_val); static void RadioButtonAddressEx(const char* label, int addr, std::vector<NamedValue>& named_val);
static void ColorPickerAddress(const char *label, int base_addr, ImVec4 &&default_color); static void ColorPickerAddress(const char* label, int base_addr, ImVec4&& default_color);
static void ShowTooltip(const char *text); static void ShowTooltip(const char* text);
}; };
template <typename T> template <typename T>
void Ui::EditAddress(const char *label, const int address, const int min, const int def, const int max) void Ui::EditAddress(const char* label, const int address, const int min, const int def, const int max)
{ {
if (ImGui::CollapsingHeader(label)) if (ImGui::CollapsingHeader(label))
{ {
int val = patch::Get<T>(address, false); int val = patch::Get<T>(address, false);
int items = 3; int items = 3;
if (min == def) if (min == def)
items = 2; items = 2;
ImGui::Columns(items, nullptr, false); ImGui::Columns(items, nullptr, false);
ImGui::Text(("Min: " + std::to_string(min)).c_str()); ImGui::Text(("Min: " + std::to_string(min)).c_str());
if (items == 3) if (items == 3)
{ {
ImGui::NextColumn(); ImGui::NextColumn();
ImGui::Text(("Def: " + std::to_string(def)).c_str()); ImGui::Text(("Def: " + std::to_string(def)).c_str());
} }
ImGui::NextColumn(); ImGui::NextColumn();
ImGui::Text(("Max: " + std::to_string(max)).c_str()); ImGui::Text(("Max: " + std::to_string(max)).c_str());
ImGui::Columns(1); ImGui::Columns(1);
ImGui::Spacing(); ImGui::Spacing();
if (ImGui::InputInt(("Set value##" + std::string(label)).c_str(), &val)) if (ImGui::InputInt(("Set value##" + std::string(label)).c_str(), &val))
patch::Set<T>(address, val, false); patch::Set<T>(address, val, false);
ImGui::Spacing(); ImGui::Spacing();
if (val < min) if (val < min)
val = min; val = min;
if (val > max) if (val > max)
val = max; val = max;
if (ImGui::Button(("Minimum##" + std::string(label)).c_str(), GetSize(items))) if (ImGui::Button(("Minimum##" + std::string(label)).c_str(), GetSize(items)))
patch::Set<T>(address, min, false); patch::Set<T>(address, min, false);
if (items == 3) if (items == 3)
{ {
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::Button(("Default##" + std::string(label)).c_str(), GetSize(3))) if (ImGui::Button(("Default##" + std::string(label)).c_str(), GetSize(3)))
patch::Set<T>(address, def, false); patch::Set<T>(address, def, false);
} }
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::Button(("Maximum##" + std::string(label)).c_str(), GetSize(items))) if (ImGui::Button(("Maximum##" + std::string(label)).c_str(), GetSize(items)))
patch::Set<T>(address, max, false); patch::Set<T>(address, max, false);
ImGui::Spacing(); ImGui::Spacing();
ImGui::Separator(); ImGui::Separator();
} }
} }
template <typename T> void Ui::EditReference(const char *label, T &address, const int min, const int def, const int max) template <typename T>
void Ui::EditReference(const char* label, T& address, const int min, const int def, const int max)
{ {
if (ImGui::CollapsingHeader(label)) if (ImGui::CollapsingHeader(label))
{ {
int val = static_cast<int>(address); int val = static_cast<int>(address);
ImGui::Columns(3, nullptr, false); ImGui::Columns(3, nullptr, false);
ImGui::Text(("Min: " + std::to_string(min)).c_str()); ImGui::Text(("Min: " + std::to_string(min)).c_str());
ImGui::NextColumn(); ImGui::NextColumn();
ImGui::Text(("Def: " + std::to_string(def)).c_str()); ImGui::Text(("Def: " + std::to_string(def)).c_str());
ImGui::NextColumn(); ImGui::NextColumn();
ImGui::Text(("Max: " + std::to_string(max)).c_str()); ImGui::Text(("Max: " + std::to_string(max)).c_str());
ImGui::Columns(1); ImGui::Columns(1);
ImGui::Spacing(); ImGui::Spacing();
if (ImGui::InputInt(("Set value##" + std::string(label)).c_str(), &val)) if (ImGui::InputInt(("Set value##" + std::string(label)).c_str(), &val))
address = static_cast<float>(val); address = static_cast<float>(val);
ImGui::Spacing(); ImGui::Spacing();
if (ImGui::Button(("Minimum##" + std::string(label)).c_str(), GetSize(3))) if (ImGui::Button(("Minimum##" + std::string(label)).c_str(), GetSize(3)))
address = static_cast<float>(min); address = static_cast<float>(min);
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::Button(("Default##" + std::string(label)).c_str(), GetSize(3))) if (ImGui::Button(("Default##" + std::string(label)).c_str(), GetSize(3)))
address = static_cast<float>(def); address = static_cast<float>(def);
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::Button(("Maximum##" + std::string(label)).c_str(), GetSize(3))) if (ImGui::Button(("Maximum##" + std::string(label)).c_str(), GetSize(3)))
address = static_cast<float>(max); address = static_cast<float>(max);
ImGui::Spacing(); ImGui::Spacing();
ImGui::Separator(); ImGui::Separator();
} }
} }

View File

@ -1,78 +1,76 @@
#include "updater.h"
#include "menuinfo.h"
#include "pch.h" #include "pch.h"
#include "updater.h"
#include "ui.h" #include "ui.h"
#include "menuinfo.h"
#include "util.h" #include "util.h"
void Updater::CheckForUpdate() void Updater::CheckForUpdate()
{ {
const char *link = "https://api.github.com/repos/user-grinch/Cheat-Menu/tags"; const char* link = "https://api.github.com/repos/user-grinch/Cheat-Menu/tags";
char *path = PLUGIN_PATH((char *)"CheatMenu/json/versioninfo.json"); char* path = PLUGIN_PATH((char*)"CheatMenu/json/versioninfo.json");
HRESULT res = URLDownloadToFile(NULL, link, path, 0, NULL); HRESULT res = URLDownloadToFile(NULL, link, path, 0, NULL);
if (res == E_OUTOFMEMORY || res == INET_E_DOWNLOAD_FAILURE) if (res == E_OUTOFMEMORY || res == INET_E_DOWNLOAD_FAILURE)
{ {
SetHelpMessage("Failed to check for updates", false, false, false); SetHelpMessage("Failed to check for updates", false, false, false);
return; return;
} }
CJson verinfo = CJson("versioninfo");
CJson verinfo = CJson("versioninfo"); // fetch the version number
if (verinfo.m_Data.empty())
{
m_LatestVersion = MENU_VERSION_NUMBER;
}
else
{
m_LatestVersion = verinfo.m_Data.items().begin().value()["name"].get<std::string>();
}
// fetch the version number if (m_LatestVersion > MENU_VERSION_NUMBER)
if (verinfo.m_Data.empty()) {
{ SetHelpMessage("Update found", false, false, false);
m_LatestVersion = MENU_VERSION_NUMBER; m_State = UPDATER_UPDATE_FOUND;
} }
else else
{ {
m_LatestVersion = verinfo.m_Data.items().begin().value()["name"].get<std::string>(); SetHelpMessage("No update found.", false, false, false);
} Updater::m_State = UPDATER_IDLE;
}
if (m_LatestVersion > MENU_VERSION_NUMBER)
{
SetHelpMessage("Update found", false, false, false);
m_State = UPDATER_UPDATE_FOUND;
}
else
{
SetHelpMessage("No update found.", false, false, false);
Updater::m_State = UPDATER_IDLE;
}
} }
void Updater::ShowUpdateScreen() void Updater::ShowUpdateScreen()
{ {
ImGui::Dummy(ImVec2(0, 20)); ImGui::Dummy(ImVec2(0, 20));
Ui::CenterdText("A new version of the mod is available."); Ui::CenterdText("A new version of the mod is available.");
Ui::CenterdText(std::string("Current version: ") + MENU_VERSION); Ui::CenterdText(std::string("Current version: ") + MENU_VERSION);
Ui::CenterdText("Latest version: " + Updater::m_LatestVersion); Ui::CenterdText("Latest version: " + Updater::m_LatestVersion);
ImGui::Dummy(ImVec2(0, 10)); ImGui::Dummy(ImVec2(0, 10));
ImGui::TextWrapped("In order to keep using the menu, you need to update to the latest version." ImGui::TextWrapped("In order to keep using the menu, you need to update to the latest version."
" This is to ensure everything is using the most up-to-date version."); " This is to ensure everything is using the most up-to-date version.");
ImGui::Dummy(ImVec2(0, 10)); ImGui::Dummy(ImVec2(0, 10));
ImGui::TextWrapped("To know what changes are made or to download, click on the \"Download page\" button." ImGui::TextWrapped("To know what changes are made or to download, click on the \"Download page\" button."
" Follow the instructions there. If you're still having issues, let me know on discord."); " Follow the instructions there. If you're still having issues, let me know on discord.");
ImGui::Dummy(ImVec2(0, 5)); ImGui::Dummy(ImVec2(0, 5));
if (ImGui::Button("Discord server", ImVec2(Ui::GetSize(3)))) if (ImGui::Button("Discord server", ImVec2(Ui::GetSize(3))))
{ {
ShellExecute(NULL, "open", DISCORD_INVITE, NULL, NULL, SW_SHOWNORMAL); ShellExecute(NULL, "open", DISCORD_INVITE, NULL, NULL, SW_SHOWNORMAL);
} }
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::Button("Download page", Ui::GetSize(3))) if (ImGui::Button("Download page", Ui::GetSize(3)))
{ {
ShellExecute( ShellExecute(NULL, "open", std::string("https://github.com/user-grinch/Cheat-Menu/releases/tag/" +
NULL, "open", Updater::m_LatestVersion).c_str(), NULL, NULL, SW_SHOWNORMAL);
std::string("https://github.com/user-grinch/Cheat-Menu/releases/tag/" + Updater::m_LatestVersion).c_str(), }
NULL, NULL, SW_SHOWNORMAL);
}
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::Button("Hide page", Ui::GetSize(3))) if (ImGui::Button("Hide page", Ui::GetSize(3)))
{ {
Updater::m_State = UPDATER_IDLE; Updater::m_State = UPDATER_IDLE;
} }
} }

View File

@ -3,17 +3,17 @@
enum UPDATER_STATE enum UPDATER_STATE
{ {
UPDATER_IDLE, UPDATER_IDLE,
UPDATER_CHECKING, UPDATER_CHECKING,
UPDATER_UPDATE_FOUND UPDATER_UPDATE_FOUND
}; };
class Updater class Updater
{ {
public: public:
static inline UPDATER_STATE m_State = UPDATER_IDLE; static inline UPDATER_STATE m_State = UPDATER_IDLE;
static inline std::string m_LatestVersion; static inline std::string m_LatestVersion;
static void CheckForUpdate(); static void CheckForUpdate();
static void ShowUpdateScreen(); static void ShowUpdateScreen();
}; };

View File

@ -1,220 +1,220 @@
#include "util.h"
#include "pch.h" #include "pch.h"
#include "util.h"
#include "psapi.h" #include "psapi.h"
std::string Util::GetLocationName(CVector *pos) std::string Util::GetLocationName(CVector* pos)
{ {
CPlayerPed *pPlayer = FindPlayerPed(); CPlayerPed *pPlayer = FindPlayerPed();
#ifdef GTASA #ifdef GTASA
int hplayer = CPools::GetPedRef(pPlayer); int hplayer = CPools::GetPedRef(pPlayer);
int interior = 0; int interior = 0;
Command<Commands::GET_AREA_VISIBLE>(&interior); Command<Commands::GET_AREA_VISIBLE>(&interior);
std::string town = "San Andreas"; std::string town = "San Andreas";
int city; int city;
Command<Commands::GET_CITY_PLAYER_IS_IN>(&hplayer, &city); Command<Commands::GET_CITY_PLAYER_IS_IN>(&hplayer, &city);
switch (city) switch (city)
{ {
case 0: case 0:
town = "CS"; town = "CS";
break; break;
case 1: case 1:
town = "LS"; town = "LS";
break; break;
case 2: case 2:
town = "SF"; town = "SF";
break; break;
case 3: case 3:
town = "LV"; town = "LV";
break; break;
} }
if (interior == 0) if (interior == 0)
return CTheZones::FindSmallestZoneForPosition(*pos, true)->GetTranslatedName() + std::string(", ") + town; return CTheZones::FindSmallestZoneForPosition(*pos, true)->GetTranslatedName() + std::string(", ") + town;
return std::string("Interior ") + std::to_string(interior) + ", " + town; return std::string("Interior ") + std::to_string(interior) + ", " + town;
#elif GTAVC #elif GTAVC
if (pPlayer) if (pPlayer)
{ {
return std::to_string(pPlayer->m_nInterior) + ", Vice City"; return std::to_string(pPlayer->m_nInterior) + ", Vice City" ;
} }
else else
{ {
return "Vice City"; return "Vice City";
} }
#else #else
return "Liberty City"; return "Liberty City";
#endif #endif
} }
#ifdef GTASA #ifdef GTASA
// Thanks DKPac22 // Thanks DKPac22
RwTexture *Util::LoadTextureFromMemory(char *data, unsigned int size) RwTexture* Util::LoadTextureFromMemory(char* data, unsigned int size)
{ {
patch::SetChar(0x7CF9CA, rwSTREAMMEMORY); patch::SetChar(0x7CF9CA, rwSTREAMMEMORY);
RwMemory memoryImage; RwMemory memoryImage;
RwInt32 width, height, depth, flags; RwInt32 width, height, depth, flags;
memoryImage.start = (RwUInt8 *)data; memoryImage.start = (RwUInt8*)data;
memoryImage.length = size; memoryImage.length = size;
RwImage *image = RtPNGImageRead((char *)&memoryImage); RwImage* image = RtPNGImageRead((char*)&memoryImage);
RwImageFindRasterFormat(image, 4, &width, &height, &depth, &flags); RwImageFindRasterFormat(image, 4, &width, &height, &depth, &flags);
RwRaster *raster = RwRasterCreate(width, height, depth, flags); RwRaster* raster = RwRasterCreate(width, height, depth, flags);
RwRasterSetFromImage(raster, image); RwRasterSetFromImage(raster, image);
RwImageDestroy(image); RwImageDestroy(image);
patch::SetChar(0x7CF9CA, rwSTREAMFILENAME); patch::SetChar(0x7CF9CA, rwSTREAMFILENAME);
return RwTextureCreate(raster); return RwTextureCreate(raster);
} }
void Util::ClearCharTasksVehCheck(CPed *ped) void Util::ClearCharTasksVehCheck(CPed* ped)
{ {
uint hped = CPools::GetPedRef(ped); uint hped = CPools::GetPedRef(ped);
uint hveh = NULL; uint hveh = NULL;
bool veh_engine = true; bool veh_engine = true;
float speed; float speed;
if (ped->m_nPedFlags.bInVehicle) if (ped->m_nPedFlags.bInVehicle)
{ {
hveh = CPools::GetVehicleRef(ped->m_pVehicle); hveh = CPools::GetVehicleRef(ped->m_pVehicle);
veh_engine = ped->m_pVehicle->m_nVehicleFlags.bEngineOn; veh_engine = ped->m_pVehicle->m_nVehicleFlags.bEngineOn;
speed = ped->m_pVehicle->m_vecMoveSpeed.Magnitude() * 50.0f; speed = ped->m_pVehicle->m_vecMoveSpeed.Magnitude() * 50.0f;
} }
Command<Commands::CLEAR_CHAR_TASKS_IMMEDIATELY>(hped); Command<Commands::CLEAR_CHAR_TASKS_IMMEDIATELY>(hped);
if (hveh) if (hveh)
{ {
Command<Commands::TASK_WARP_CHAR_INTO_CAR_AS_DRIVER>(hped, hveh); Command<Commands::TASK_WARP_CHAR_INTO_CAR_AS_DRIVER>(hped, hveh);
ped->m_pVehicle->m_nVehicleFlags.bEngineOn = veh_engine; ped->m_pVehicle->m_nVehicleFlags.bEngineOn = veh_engine;
Command<Commands::SET_CAR_FORWARD_SPEED>(hveh, speed); Command<Commands::SET_CAR_FORWARD_SPEED>(hveh, speed);
} }
} }
bool Util::IsOnMission() bool Util::IsOnMission()
{ {
return FindPlayerPed()->CanPlayerStartMission() && return FindPlayerPed()->CanPlayerStartMission() && !*(patch::Get<char*>(0x5D5380, false) +
!*(patch::Get<char *>(0x5D5380, false) + CTheScripts::OnAMissionFlag); CTheScripts::OnAMissionFlag);
} }
int Util::GetLargestGangInZone() int Util::GetLargestGangInZone()
{ {
int gang_id = 0, max_density = 0; int gang_id = 0, max_density = 0;
for (int i = 0; i != 10; ++i) for (int i = 0; i != 10; ++i)
{ {
CVector pos = FindPlayerPed()->GetPosition(); CVector pos = FindPlayerPed()->GetPosition();
CZoneInfo *zone_info = CTheZones::GetZoneInfo(&pos, nullptr); CZoneInfo* zone_info = CTheZones::GetZoneInfo(&pos, nullptr);
int density = zone_info->m_nGangDensity[i]; int density = zone_info->m_nGangDensity[i];
if (density > max_density) if (density > max_density)
{ {
max_density = density; max_density = density;
gang_id = i; gang_id = i;
} }
} }
return gang_id; return gang_id;
} }
#endif #endif
// implemention of opcode 0AB5 (STORE_CLOSEST_ENTITIES) // implemention of opcode 0AB5 (STORE_CLOSEST_ENTITIES)
// https://github.com/cleolibrary/CLEO4/blob/916d400f4a731ba1dd0ff16e52bdb056f42b7038/source/CCustomOpcodeSystem.cpp#L1671 // https://github.com/cleolibrary/CLEO4/blob/916d400f4a731ba1dd0ff16e52bdb056f42b7038/source/CCustomOpcodeSystem.cpp#L1671
CVehicle *Util::GetClosestVehicle() CVehicle* Util::GetClosestVehicle()
{ {
CPlayerPed *player = FindPlayerPed(); CPlayerPed* player = FindPlayerPed();
#ifdef GTASA #ifdef GTASA
CPedIntelligence *pedintel; CPedIntelligence* pedintel;
if (player && (pedintel = player->m_pIntelligence)) if (player && (pedintel = player->m_pIntelligence))
{ {
CVehicle *veh = nullptr; CVehicle* veh = nullptr;
for (int i = 0; i < 16; i++) for (int i = 0; i < 16; i++)
{ {
veh = static_cast<CVehicle *>(pedintel->m_vehicleScanner.m_apEntities[i]); veh = static_cast<CVehicle*>(pedintel->m_vehicleScanner.m_apEntities[i]);
if (veh && !veh->m_nVehicleFlags.bFadeOut) if (veh && !veh->m_nVehicleFlags.bFadeOut)
break; break;
veh = nullptr; veh = nullptr;
} }
return veh; return veh;
} }
return nullptr; return nullptr;
#else // GTAVC & GTA3 #else // GTAVC & GTA3
CVehicle *pClosestVeh = nullptr;
float distance = 999.0f;
CVehicle *pClosestVeh = nullptr; CVector playerPos = player->GetPosition();
float distance = 999.0f;
CVector playerPos = player->GetPosition(); for (CVehicle *pVeh : CPools::ms_pVehiclePool)
{
CVector pos = pVeh->GetPosition();
float dist = DistanceBetweenPoints(playerPos, pos);
for (CVehicle *pVeh : CPools::ms_pVehiclePool) if (dist < distance)
{ {
CVector pos = pVeh->GetPosition(); pClosestVeh = pVeh;
float dist = DistanceBetweenPoints(playerPos, pos); distance = dist;
}
if (dist < distance) }
{ return pClosestVeh;
pClosestVeh = pVeh;
distance = dist;
}
}
return pClosestVeh;
#endif #endif
} }
CPed *Util::GetClosestPed() CPed* Util::GetClosestPed()
{ {
CPlayerPed *player = FindPlayerPed(); CPlayerPed* player = FindPlayerPed();
#ifdef GTASA #ifdef GTASA
CPedIntelligence *pedintel; CPedIntelligence* pedintel;
if (player && (pedintel = player->m_pIntelligence)) if (player && (pedintel = player->m_pIntelligence))
{ {
CPed *ped = nullptr; CPed* ped = nullptr;
for (int i = 0; i < 16; i++) for (int i = 0; i < 16; i++)
{ {
ped = static_cast<CPed *>(pedintel->m_pedScanner.m_apEntities[i]); ped = static_cast<CPed*>(pedintel->m_pedScanner.m_apEntities[i]);
if (ped && ped != player && (ped->m_nCreatedBy & 0xFF) == 1 && !ped->m_nPedFlags.bFadeOut) if (ped && ped != player && (ped->m_nCreatedBy & 0xFF) == 1 && !ped->m_nPedFlags.bFadeOut)
break; break;
ped = nullptr; ped = nullptr;
} }
return ped; return ped;
} }
return nullptr; return nullptr;
#else // GTA3 & GTAVC #else // GTA3 & GTAVC
return player->m_apNearPeds[0]; return player->m_apNearPeds[0];
#endif #endif
} }
bool Util::IsOnCutscene() bool Util::IsOnCutscene()
{ {
return BY_GAME(CCutsceneMgr::ms_running, *(bool *)0xA10AB2, *(bool *)0x95CCF5); return BY_GAME(CCutsceneMgr::ms_running, *(bool*)0xA10AB2, *(bool*)0x95CCF5);
} }
void Util::RainbowValues(int &r, int &g, int &b, float speed) void Util::RainbowValues(int& r, int& g, int& b, float speed)
{ {
int timer = CTimer::m_snTimeInMilliseconds / 150; int timer = CTimer::m_snTimeInMilliseconds / 150;
r = sin(timer * speed) * 127 + 128; r = sin(timer * speed) * 127 + 128;
g = sin(timer * speed + 2) * 127 + 128; g = sin(timer * speed + 2) * 127 + 128;
b = sin(timer * speed + 4) * 127 + 128; b = sin(timer * speed + 4) * 127 + 128;
} }
void Util::GetCPUUsageInit() void Util::GetCPUUsageInit()
{ {
PdhOpenQuery(nullptr, NULL, &cpuQuery); PdhOpenQuery(nullptr, NULL, &cpuQuery);
PdhAddEnglishCounter(cpuQuery, "\\Processor(_Total)\\% Processor Time", NULL, &cpuTotal); PdhAddEnglishCounter(cpuQuery, "\\Processor(_Total)\\% Processor Time", NULL, &cpuTotal);
PdhCollectQueryData(cpuQuery); PdhCollectQueryData(cpuQuery);
} }
double Util::GetCurrentCPUUsage() double Util::GetCurrentCPUUsage()
{ {
PDH_FMT_COUNTERVALUE counterVal; PDH_FMT_COUNTERVALUE counterVal;
PdhCollectQueryData(cpuQuery); PdhCollectQueryData(cpuQuery);
PdhGetFormattedCounterValue(cpuTotal, PDH_FMT_DOUBLE, nullptr, &counterVal); PdhGetFormattedCounterValue(cpuTotal, PDH_FMT_DOUBLE, nullptr, &counterVal);
return counterVal.doubleValue; return counterVal.doubleValue;
} }

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "pdh.h"
#include "tchar.h" #include "tchar.h"
#include "pdh.h"
static PDH_HQUERY cpuQuery; static PDH_HQUERY cpuQuery;
static PDH_HCOUNTER cpuTotal; static PDH_HCOUNTER cpuTotal;
@ -11,18 +11,19 @@ static HANDLE self;
class Util class Util
{ {
public: 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
static CPed *GetClosestPed(); static CPed* GetClosestPed();
static CVehicle *GetClosestVehicle(); static CVehicle* GetClosestVehicle();
static std::string GetLocationName(CVector *pos); static std::string GetLocationName(CVector* pos);
static bool IsOnMission(); static bool IsOnMission();
static bool IsOnCutscene(); static bool IsOnCutscene();
static void RainbowValues(int &r, int &g, int &b, float speed); static void RainbowValues(int& r, int& g, int& b, float speed);
static void GetCPUUsageInit(); static void GetCPUUsageInit();
static double GetCurrentCPUUsage(); static double GetCurrentCPUUsage();
}; };

File diff suppressed because it is too large Load Diff

View File

@ -12,119 +12,98 @@ class Vehicle
#endif #endif
{ {
private: private:
static inline bool m_bBikeFly; static inline bool m_bBikeFly;
static inline bool m_bDontFallBike; static inline bool m_bDontFallBike;
static inline bool m_bVehHeavy; static inline bool m_bVehHeavy;
static inline bool m_bVehWatertight; static inline bool m_bVehWatertight;
static inline bool m_bNoDamage; static inline bool m_bNoDamage;
static inline int m_nDoorMenuButton; static inline int m_nDoorMenuButton;
static inline std::string m_DoorNames[6] = { static inline std::string m_DoorNames[6] =
"Hood", "Boot", "Front left door", "Front right door", "Rear left door", "Rear right door"}; { "Hood", "Boot", "Front left door", "Front right door", "Rear left door", "Rear right door" };
static inline int m_nVehRemoveRadius; static inline int m_nVehRemoveRadius;
static inline bool m_bLockSpeed; static inline bool m_bLockSpeed;
static inline float m_fLockSpeed; static inline float m_fLockSpeed;
static inline std::vector<std::vector<float>> m_CarcolsColorData; static inline std::vector<std::vector<float>> m_CarcolsColorData;
struct m_Color struct m_Color
{ {
static inline bool m_bMatFilter = true; static inline bool m_bMatFilter = true;
static inline int m_nRadioButton = 1; static inline int m_nRadioButton = 1;
static inline float m_fColorPicker[3]{0, 0, 0}; static inline float m_fColorPicker[3]{ 0, 0, 0 };
}; };
#ifdef GTASA #ifdef GTASA
static inline bool m_bDisableColDetection; static inline bool m_bDisableColDetection;
static inline std::map<int, std::string> m_VehicleIDE; static inline std::map<int, std::string> m_VehicleIDE;
struct m_Neon struct m_Neon
{ {
static inline float m_fColorPicker[3]{0, 0, 0}; static inline float m_fColorPicker[3]{ 0, 0, 0 };
static inline bool m_bRainbowEffect; static inline bool m_bRainbowEffect;
static inline uint m_nRainbowTimer; static inline uint m_nRainbowTimer;
static inline bool m_bApplyOnTraffic; static inline bool m_bApplyOnTraffic;
static inline uint m_bTrafficTimer; static inline uint m_bTrafficTimer;
}; };
static inline ResourceStore m_TuneData{"components", eResourceType::TYPE_IMAGE, ImVec2(100, 80)}; static inline ResourceStore m_TuneData { "components", eResourceType::TYPE_IMAGE, ImVec2(100, 80) };
#endif #endif
struct m_Spawner struct m_Spawner
{ {
#ifdef GTASA #ifdef GTASA
static inline ResourceStore m_VehData{"vehicles", eResourceType::TYPE_IMAGE, ImVec2(100, 75)}; static inline ResourceStore m_VehData { "vehicles", eResourceType::TYPE_IMAGE, ImVec2(100, 75)};
#else // GTA3 & GTAVC #else // GTA3 & GTAVC
static inline ResourceStore m_VehData{"vehicle", eResourceType::TYPE_TEXT}; static inline ResourceStore m_VehData{"vehicle", eResourceType::TYPE_TEXT};
#endif #endif
static inline bool m_bSpawnInside = true; static inline bool m_bSpawnInside = true;
static inline bool m_bSpawnInAir = true; static inline bool m_bSpawnInAir = true;
static inline char m_nLicenseText[9]; static inline char m_nLicenseText[9];
}; };
struct m_UnlimitedNitro struct m_UnlimitedNitro
{ {
static inline bool m_bEnabled; static inline bool m_bEnabled;
static inline bool m_bCompAdded; static inline bool m_bCompAdded;
}; };
#ifdef GTASA #ifdef GTASA
static inline std::vector<std::string>(m_HandlingFlagNames) = // 32 flags static inline std::vector<std::string>(m_HandlingFlagNames) = // 32 flags
{"1G_BOOST", "2G_BOOST", "NPC_ANTI_ROLL", "NPC_NEUTRAL_HANDL", {
"NO_HANDBRAKE", "STEER_REARWHEELS", "HB_REARWHEEL_STEER", "ALT_STEER_OPT", "1G_BOOST", "2G_BOOST", "NPC_ANTI_ROLL", "NPC_NEUTRAL_HANDL", "NO_HANDBRAKE", "STEER_REARWHEELS",
"WHEEL_F_NARROW2", "WHEEL_F_NARROW", "WHEEL_F_WIDE", "WHEEL_F_WIDE2", "HB_REARWHEEL_STEER", "ALT_STEER_OPT",
"WHEEL_R_NARROW2", "WHEEL_R_NARROW", "WHEEL_R_WIDE", "WHEEL_R_WIDE2", "WHEEL_F_NARROW2", "WHEEL_F_NARROW", "WHEEL_F_WIDE", "WHEEL_F_WIDE2", "WHEEL_R_NARROW2", "WHEEL_R_NARROW",
"HYDRAULIC_GEOM", "HYDRAULIC_INST", "HYDRAULIC_NONE", "NOS_INST", "WHEEL_R_WIDE", "WHEEL_R_WIDE2",
"OFFROAD_ABILITY", "OFFROAD_ABILITY2", "HALOGEN_LIGHTS", "PROC_REARWHEEL_1ST", "HYDRAULIC_GEOM", "HYDRAULIC_INST", "HYDRAULIC_NONE", "NOS_INST", "OFFROAD_ABILITY", "OFFROAD_ABILITY2",
"USE_MAXSP_LIMIT", "LOW_RIDER", "STREET_RACER", "SWINGING_CHASSIS", "HALOGEN_LIGHTS", "PROC_REARWHEEL_1ST",
"Unused 1", "Unused 2", "Unused 3", "Unused 4"}; "USE_MAXSP_LIMIT", "LOW_RIDER", "STREET_RACER", "SWINGING_CHASSIS", "Unused 1", "Unused 2", "Unused 3",
"Unused 4"
};
static inline std::vector<std::string>(m_ModelFlagNames) = // 32 flags static inline std::vector<std::string>(m_ModelFlagNames) = // 32 flags
{"IS_VAN", {
"IS_BUS", "IS_VAN", "IS_BUS", "IS_LOW", "IS_BIG", "REVERSE_BONNET", "HANGING_BOOT", "TAILGATE_BOOT", "NOSWING_BOOT",
"IS_LOW", "NO_DOORS", "TANDEM_SEATS",
"IS_BIG", "SIT_IN_BOAT", "CONVERTIBLE", "NO_EXHAUST", "DOUBLE_EXHAUST", "NO1FPS_LOOK_BEHIND", "FORCE_DOOR_CHECK",
"REVERSE_BONNET", "AXLE_F_NOTILT", "AXLE_F_SOLID", "AXLE_F_MCPHERSON",
"HANGING_BOOT", "AXLE_F_REVERSE", "AXLE_R_NOTILT", "AXLE_R_SOLID", "AXLE_R_MCPHERSON", "AXLE_R_REVERSE", "IS_BIKE", "IS_HELI",
"TAILGATE_BOOT", "IS_PLANE", "IS_BOAT", "BOUNCE_PANELS",
"NOSWING_BOOT", "DOUBLE_RWHEELS", "FORCE_GROUND_CLEARANCE", "IS_HATCHBAC1K"
"NO_DOORS", };
"TANDEM_SEATS",
"SIT_IN_BOAT",
"CONVERTIBLE",
"NO_EXHAUST",
"DOUBLE_EXHAUST",
"NO1FPS_LOOK_BEHIND",
"FORCE_DOOR_CHECK",
"AXLE_F_NOTILT",
"AXLE_F_SOLID",
"AXLE_F_MCPHERSON",
"AXLE_F_REVERSE",
"AXLE_R_NOTILT",
"AXLE_R_SOLID",
"AXLE_R_MCPHERSON",
"AXLE_R_REVERSE",
"IS_BIKE",
"IS_HELI",
"IS_PLANE",
"IS_BOAT",
"BOUNCE_PANELS",
"DOUBLE_RWHEELS",
"FORCE_GROUND_CLEARANCE",
"IS_HATCHBAC1K"};
#endif #endif
private: private:
static void FixVehicle(CVehicle *pVeh); static void FixVehicle(CVehicle *pVeh);
#ifdef GTASA #ifdef GTASA
static void AddComponent(const std::string &component, bool display_message = true); static void AddComponent(const std::string& component, bool display_message = true);
static void RemoveComponent(const std::string &component, bool display_message = true); static void RemoveComponent(const std::string& component, bool display_message = true);
static int GetRandomTrainIdForModel(int model); static int GetRandomTrainIdForModel(int model);
static void GenerateHandlingDataFile(int phandling); static void GenerateHandlingDataFile(int phandling);
#endif #endif
public: public:
#ifdef GTASA #ifdef GTASA
static void SpawnVehicle(std::string &name); static void SpawnVehicle(std::string& name);
#else // GTA3 & GTAVC #else // GTA3 & GTAVC
static void SpawnVehicle(std::string &rootkey, std::string &vehName, std::string &model); static void SpawnVehicle(std::string& rootkey, std::string& vehName, std::string& model);
#endif #endif
static std::string GetNameFromModel(int model); static std::string GetNameFromModel(int model);
static int GetModelFromName(const char *name); static int GetModelFromName(const char* name);
static void Draw(); static void Draw();
Vehicle(); Vehicle();
}; };

File diff suppressed because it is too large Load Diff

View File

@ -4,52 +4,48 @@
class Visual class Visual
{ {
private: private:
static inline bool m_bLockWeather; static inline bool m_bLockWeather;
#ifdef GTASA #ifdef GTASA
static inline bool m_bInvisibleWater; static inline bool m_bInvisibleWater;
static inline bool m_bNoWater; static inline bool m_bNoWater;
static inline bool m_bDisableHydrant; static inline bool m_bDisableHydrant;
#endif #endif
// Timecyc stuff // Timecyc stuff
static inline int m_nTimecycHour = 8; static inline int m_nTimecycHour = 8;
static inline std::vector<std::string> m_WeatherNames{"EXTRASUNNY LA", "SUNNY LA", static inline std::vector<std::string> m_WeatherNames
"EXTRASUNNY SMOG LA", "SUNNY SMOG LA", {
"CLOUDY LA", "SUNNY SF", "EXTRASUNNY LA", "SUNNY LA", "EXTRASUNNY SMOG LA", "SUNNY SMOG LA", "CLOUDY LA", "SUNNY SF", "EXTRASUNNY SF",
"EXTRASUNNY SF", "CLOUDY SF", "CLOUDY SF", "RAINY SF", "FOGGY SF",
"RAINY SF", "FOGGY SF", "SUNNY VEGAS", "EXTRASUNNY VEGAS", "CLOUDY VEGAS", "EXTRASUNNY COUNTRYSIDE", "SUNNY COUNTRYSIDE",
"SUNNY VEGAS", "EXTRASUNNY VEGAS", "CLOUDY COUNTRYSIDE", "RAINY COUNTRYSIDE",
"CLOUDY VEGAS", "EXTRASUNNY COUNTRYSIDE", "EXTRASUNNY DESERT", "SUNNY DESERT", "SANDSTORM DESERT", "UNDERWATER", "EXTRACOLOURS 1", "EXTRACOLOURS 2"
"SUNNY COUNTRYSIDE", "CLOUDY COUNTRYSIDE", };
"RAINY COUNTRYSIDE", "EXTRASUNNY DESERT",
"SUNNY DESERT", "SANDSTORM DESERT",
"UNDERWATER", "EXTRACOLOURS 1",
"EXTRACOLOURS 2"};
static void GenerateTimecycFile();
static int CalcArrayIndex();
static bool TimeCycColorEdit3(const char *label, uchar *r, uchar *g, uchar *b, ImGuiColorEditFlags flags = 0);
static bool TimeCycColorEdit4(const char *label, uchar *r, uchar *g, uchar *b, uchar *a,
ImGuiColorEditFlags flags = 0);
template <typename T> static void TimecycSlider(const char *label, T *data, int min, int max);
static void GenerateTimecycFile();
static int CalcArrayIndex();
static bool TimeCycColorEdit3(const char* label, uchar* r, uchar* g, uchar* b, ImGuiColorEditFlags flags = 0);
static bool TimeCycColorEdit4(const char* label, uchar* r, uchar* g, uchar* b, uchar* a, ImGuiColorEditFlags flags = 0);
template <typename T>
static void TimecycSlider(const char* label, T* data, int min, int max);
public: public:
Visual(); Visual();
static void Draw(); static void Draw();
}; };
template <typename T> void Visual::TimecycSlider(const char *label, T *ptr, int min, int max) template <typename T>
void Visual::TimecycSlider(const char* label, T* ptr, int min, int max)
{ {
int val = CalcArrayIndex(); int val = CalcArrayIndex();
#ifdef GTASA #ifdef GTASA
// Compatable with 24h TimeCyc // Compatable with 24h TimeCyc
T *arr = static_cast<T *>(patch::GetPointer(int(ptr))); T* arr = static_cast<T*>(patch::GetPointer(int(ptr)));
#else // GTA3 & GTAVC #else // GTA3 & GTAVC
T *arr = static_cast<T *>(ptr); T* arr = static_cast<T*>(ptr);
#endif #endif
int a = arr[val]; int a = arr[val];
if (ImGui::SliderInt(label, &a, min, max)) if (ImGui::SliderInt(label, &a, min, max))
arr[val] = static_cast<T>(a); arr[val] = static_cast<T>(a);
} }

View File

@ -1,206 +1,210 @@
#pragma once #pragma once
#define VK_NONE -1 #define VK_NONE -1
#define VK_KEY_0 0x30 #define VK_KEY_0 0x30
#define VK_KEY_1 0x31 #define VK_KEY_1 0x31
#define VK_KEY_2 0x32 #define VK_KEY_2 0x32
#define VK_KEY_3 0x33 #define VK_KEY_3 0x33
#define VK_KEY_4 0x34 #define VK_KEY_4 0x34
#define VK_KEY_5 0x35 #define VK_KEY_5 0x35
#define VK_KEY_6 0x36 #define VK_KEY_6 0x36
#define VK_KEY_7 0x37 #define VK_KEY_7 0x37
#define VK_KEY_8 0x38 #define VK_KEY_8 0x38
#define VK_KEY_9 0x39 #define VK_KEY_9 0x39
#define VK_KEY_A 0x41 #define VK_KEY_A 0x41
#define VK_KEY_B 0x42 #define VK_KEY_B 0x42
#define VK_KEY_C 0x43 #define VK_KEY_C 0x43
#define VK_KEY_D 0x44 #define VK_KEY_D 0x44
#define VK_KEY_E 0x45 #define VK_KEY_E 0x45
#define VK_KEY_F 0x46 #define VK_KEY_F 0x46
#define VK_KEY_G 0x47 #define VK_KEY_G 0x47
#define VK_KEY_H 0x48 #define VK_KEY_H 0x48
#define VK_KEY_I 0x49 #define VK_KEY_I 0x49
#define VK_KEY_J 0x4A #define VK_KEY_J 0x4A
#define VK_KEY_K 0x4B #define VK_KEY_K 0x4B
#define VK_KEY_L 0x4C #define VK_KEY_L 0x4C
#define VK_KEY_M 0x4D #define VK_KEY_M 0x4D
#define VK_KEY_N 0x4E #define VK_KEY_N 0x4E
#define VK_KEY_O 0x4F #define VK_KEY_O 0x4F
#define VK_KEY_P 0x50 #define VK_KEY_P 0x50
#define VK_KEY_Q 0x51 #define VK_KEY_Q 0x51
#define VK_KEY_R 0x52 #define VK_KEY_R 0x52
#define VK_KEY_S 0x53 #define VK_KEY_S 0x53
#define VK_KEY_T 0x54 #define VK_KEY_T 0x54
#define VK_KEY_U 0x55 #define VK_KEY_U 0x55
#define VK_KEY_V 0x56 #define VK_KEY_V 0x56
#define VK_KEY_W 0x57 #define VK_KEY_W 0x57
#define VK_KEY_X 0x58 #define VK_KEY_X 0x58
#define VK_KEY_Y 0x59 #define VK_KEY_Y 0x59
#define VK_KEY_Z 0x5A #define VK_KEY_Z 0x5A
static std::string key_names[]{"LMB",
"RMB", static std::string key_names[]
"Cancel", {
"MMB", "LMB",
"X1MB", "RMB",
"X2MB", "Cancel",
"Unknown1", "MMB",
"Back", "X1MB",
"Tab", "X2MB",
"Reserved1", "Unknown1",
"Reserved2", "Back",
"Clear", "Tab",
"Enter", "Reserved1",
"Unknown2", "Reserved2",
"Unknown3", "Clear",
"Shift", "Enter",
"Ctrl", "Unknown2",
"Alt", "Unknown3",
"Pause", "Shift",
"Capslock", "Ctrl",
"IME", "Alt",
"IME2", "Pause",
"IME3", "Capslock",
"Unknown4", "IME",
"IME4", "IME2",
"Unknown5", "IME3",
"Esc", "Unknown4",
"IME5" "IME4",
"IME6", "Unknown5",
"IME7", "Esc",
"IME8", "IME5"
"IME9", "IME6",
"Space", "IME7",
"Pup", "IME8",
"Pdown", "IME9",
"End", "Space",
"Home", "Pup",
"Left", "Pdown",
"Up", "End",
"Right", "Home",
"Down", "Left",
"Select", "Up",
"Print", "Right",
"Execute", "Down",
"Print Screen", "Select",
"INS", "Print",
"Del", "Execute",
"Help", "Print Screen",
"0", "INS",
"1", "Del",
"2", "Help",
"3", "0",
"4", "1",
"5", "2",
"6", "3",
"7", "4",
"8", "5",
"9", "6",
"Unknown6", "7",
"Unknown7", "8",
"Unknown8", "9",
"Unknown9", "Unknown6",
"Unknown10", "Unknown7",
"Unknown11", "Unknown8",
"Unknown12", "Unknown9",
"A", "Unknown10",
"B", "Unknown11",
"C", "Unknown12",
"D", "A",
"E", "B",
"F", "C",
"G", "D",
"H", "E",
"I", "F",
"J", "G",
"K", "H",
"L", "I",
"M", "J",
"N", "K",
"O", "L",
"P", "M",
"Q", "N",
"R", "O",
"S", "P",
"T", "Q",
"U", "R",
"V", "S",
"W", "T",
"X", "U",
"Y", "V",
"Z", "W",
"LWin", "X",
"RWin", "Y",
"Apps", "Z",
"Unknown11", "LWin",
"Sleep", "RWin",
"Numpad 0", "Apps",
"Numpad 1", "Unknown11",
"Numpad 2", "Sleep",
"Numpad 3", "Numpad 0",
"Numpad 4", "Numpad 1",
"Numpad 5", "Numpad 2",
"Numpad 6", "Numpad 3",
"Numpad 7", "Numpad 4",
"Numpad 8", "Numpad 5",
"Numpad 9", "Numpad 6",
"Multiply", "Numpad 7",
"Add", "Numpad 8",
"Separator", "Numpad 9",
"Substract", "Multiply",
"Decimal", "Add",
"Divide", "Separator",
"F1", "Substract",
"F2", "Decimal",
"F3", "Divide",
"F4", "F1",
"F5", "F2",
"F6", "F3",
"F7", "F4",
"F8", "F5",
"F9", "F6",
"F10", "F7",
"F11", "F8",
"F12", "F9",
"F13", "F10",
"F14", "F11",
"F15", "F12",
"F16", "F13",
"F17", "F14",
"F18", "F15",
"F19", "F16",
"F20", "F17",
"F21", "F18",
"F22", "F19",
"F23", "F20",
"F24", "F21",
"Unknown12", "F22",
"Unknown13", "F23",
"Unknown14", "F24",
"Unknown15", "Unknown12",
"Unknown16", "Unknown13",
"Unknown17", "Unknown14",
"Unknown18", "Unknown15",
"Numlock", "Unknown16",
"Scroll", "Unknown17",
"Unknown19", "Unknown18",
"Unknown20", "Numlock",
"Unknown21", "Scroll",
"Unknown22", "Unknown19",
"Unknown23", "Unknown20",
"Unknown24", "Unknown21",
"Unknown25", "Unknown22",
"Unknown26", "Unknown23",
"Unknown27", "Unknown24",
"Unknown28", "Unknown25",
"Unknown29", "Unknown26",
"Unknown30", "Unknown27",
"Unknown31", "Unknown28",
"Unknown32", "Unknown29",
"Unknown33", "Unknown30",
"LShift", "Unknown31",
"RShift", "Unknown32",
"LCtrl", "Unknown33",
"RCtrl", "LShift",
"LMenu", "RShift",
"RMenu"}; "LCtrl",
"RCtrl",
"LMenu",
"RMenu"
};

View File

@ -1,413 +1,404 @@
#include "weapon.h"
#include "CWeaponInfo.h"
#include "pch.h" #include "pch.h"
#include "ped.h" #include "weapon.h"
#include "ui.h" #include "ui.h"
#include "util.h" #include "util.h"
#include "ped.h"
#include "CWeaponInfo.h"
Weapon::Weapon() Weapon::Weapon()
{ {
Events::processScriptsEvent += [] { Events::processScriptsEvent += []
CPlayerPed *player = FindPlayerPed(); {
CPlayerPed* player = FindPlayerPed();
#ifdef GTASA #ifdef GTASA
if (m_bAutoAim) if (m_bAutoAim)
{ {
if (CPad::NewMouseControllerState.X == 0 && CPad::NewMouseControllerState.Y == 0) if (CPad::NewMouseControllerState.X == 0 && CPad::NewMouseControllerState.Y == 0)
{ {
if (KeyPressed(2)) if (KeyPressed(2))
{ {
CCamera::m_bUseMouse3rdPerson = false; CCamera::m_bUseMouse3rdPerson = false;
} }
} }
else else
{ {
CCamera::m_bUseMouse3rdPerson = true; CCamera::m_bUseMouse3rdPerson = true;
} }
} }
#endif #endif
uchar slot = BY_GAME(player->m_nActiveWeaponSlot, player->m_nActiveWeaponSlot, player->m_nCurrentWeapon);
if (m_nCurrentWeaponSlot != slot) uchar slot = BY_GAME(player->m_nActiveWeaponSlot, player->m_nActiveWeaponSlot, player->m_nCurrentWeapon);
{ if (m_nCurrentWeaponSlot != slot)
{
#ifdef GTA3 #ifdef GTA3
eWeaponType weaponType = player->m_aWeapons[slot].m_eWeaponType; eWeaponType weaponType = player->m_aWeapons[slot].m_eWeaponType;
#else #else
eWeaponType weaponType = player->m_aWeapons[slot].m_nType; eWeaponType weaponType = player->m_aWeapons[slot].m_nType;
#endif #endif
#ifdef GTASA #ifdef GTASA
CWeaponInfo *pWeaponInfo = CWeaponInfo::GetWeaponInfo(weaponType, player->GetWeaponSkill(weaponType)); CWeaponInfo* pWeaponInfo = CWeaponInfo::GetWeaponInfo(weaponType, player->GetWeaponSkill(weaponType));
#else // GTA3 & GTAVC #else // GTA3 & GTAVC
CWeaponInfo *pWeaponInfo = CWeaponInfo::GetWeaponInfo(weaponType); CWeaponInfo* pWeaponInfo = CWeaponInfo::GetWeaponInfo(weaponType);
if (m_bInfiniteAmmo) if(m_bInfiniteAmmo)
{ {
Command<Commands::SET_PLAYER_AMMO>(0, weaponType, 999999); Command<Commands::SET_PLAYER_AMMO>(0, weaponType, 999999);
} }
#endif #endif
if (m_bHugeDamage) if (m_bHugeDamage)
{ {
pWeaponInfo->m_nDamage = 1000; pWeaponInfo->m_nDamage = 1000;
} }
if (m_bLongRange) if (m_bLongRange)
{ {
#ifdef GTASA #ifdef GTASA
pWeaponInfo->m_fTargetRange = 1000.0f; pWeaponInfo->m_fTargetRange = 1000.0f;
pWeaponInfo->m_fWeaponRange = 1000.0f; pWeaponInfo->m_fWeaponRange = 1000.0f;
pWeaponInfo->m_fAccuracy = 1.0f; pWeaponInfo->m_fAccuracy = 1.0f;
pWeaponInfo->m_nFlags.bReload2Start = true; pWeaponInfo->m_nFlags.bReload2Start = true;
#else // GTA3 & GTAVC #else // GTA3 & GTAVC
pWeaponInfo->m_fRange = 1000.0f; pWeaponInfo->m_fRange = 1000.0f;
#endif #endif
} }
#ifdef GTASA #ifdef GTASA
if (m_bRapidFire && if (m_bRapidFire && weaponType != BY_GAME(WEAPON_MINIGUN, WEAPONTYPE_MINIGUN)) // mingun doesn't work with rapidfire
weaponType != BY_GAME(WEAPON_MINIGUN, WEAPONTYPE_MINIGUN)) // mingun doesn't work with rapidfire {
{ pWeaponInfo->m_nFlags.bContinuosFire = true;
pWeaponInfo->m_nFlags.bContinuosFire = true;
}
if (m_bDualWeild && (weaponType == WEAPON_PISTOL || weaponType == WEAPON_MICRO_UZI || }
weaponType == WEAPON_TEC9 || weaponType == WEAPON_SAWNOFF))
{
pWeaponInfo->m_nFlags.bTwinPistol = true;
}
if (m_bMoveAim) if (m_bDualWeild && (weaponType == WEAPON_PISTOL || weaponType == WEAPON_MICRO_UZI || weaponType ==
{ WEAPON_TEC9 || weaponType == WEAPON_SAWNOFF))
pWeaponInfo->m_nFlags.bMoveAim = true; {
} pWeaponInfo->m_nFlags.bTwinPistol = true;
}
if (m_bMoveFire) if (m_bMoveAim)
{ {
pWeaponInfo->m_nFlags.bMoveFire = true; pWeaponInfo->m_nFlags.bMoveAim = true;
} }
if (m_bMoveFire)
{
pWeaponInfo->m_nFlags.bMoveFire = true;
}
#endif #endif
m_nCurrentWeaponSlot = slot; m_nCurrentWeaponSlot = slot;
} }
}; };
} }
#ifdef GTASA #ifdef GTASA
void Weapon::SetGangWeapon(std::string &weapon_type) void Weapon::SetGangWeapon(std::string& weapon_type)
{ {
m_nGangWeaponList[m_nSelectedGang][m_nSelectedWeapon] = std::stoi(weapon_type); m_nGangWeaponList[m_nSelectedGang][m_nSelectedWeapon] = std::stoi(weapon_type);
CGangs::SetGangWeapons(m_nSelectedGang, m_nGangWeaponList[m_nSelectedGang][0], CGangs::SetGangWeapons(m_nSelectedGang, m_nGangWeaponList[m_nSelectedGang][0], m_nGangWeaponList[m_nSelectedGang][1],
m_nGangWeaponList[m_nSelectedGang][1], m_nGangWeaponList[m_nSelectedGang][2]); m_nGangWeaponList[m_nSelectedGang][2]);
} }
#else // GTA3 & GTAVC #else // GTA3 & GTAVC
// Implementation of SA opcode 0x555 // Implementation of SA opcode 0x555
static void ClearPlayerWeapon(eWeaponType weaponType) static void ClearPlayerWeapon(eWeaponType weaponType)
{ {
CPlayerPed *pPlayer = FindPlayerPed(); CPlayerPed *pPlayer = FindPlayerPed();
#ifdef GTA3 #ifdef GTA3
int weaponSlot = pPlayer->GetWeaponSlot(weaponType); int weaponSlot = pPlayer->GetWeaponSlot(weaponType);
#else #else
int weaponSlot = CWeaponInfo::GetWeaponInfo(weaponType)->m_WeaponSlot; int weaponSlot = CWeaponInfo::GetWeaponInfo(weaponType)->m_WeaponSlot;
#endif #endif
if (weaponSlot != -1) if ( weaponSlot != -1 )
{ {
CWeapon *pWeapon = &pPlayer->m_aWeapons[weaponSlot]; CWeapon *pWeapon = &pPlayer->m_aWeapons[weaponSlot];
#ifdef GTA3 #ifdef GTA3
if (pWeapon->m_eWeaponType == weaponType) if (pWeapon->m_eWeaponType == weaponType)
{ {
if (pPlayer->m_nCurrentWeapon == weaponSlot) if (pPlayer->m_nCurrentWeapon == weaponSlot)
{ {
Command<Commands::SET_CURRENT_PLAYER_WEAPON>(0, WEAPONTYPE_UNARMED); Command<Commands::SET_CURRENT_PLAYER_WEAPON>(0, WEAPONTYPE_UNARMED);
} }
// This doesn't work for melee weapons aka bats, chainsaw etc // This doesn't work for melee weapons aka bats, chainsaw etc
pWeapon->m_eWeaponState = WEAPONSTATE_OUT_OF_AMMO; pWeapon->m_eWeaponState = WEAPONSTATE_OUT_OF_AMMO;
pWeapon->m_nAmmoTotal = 0; pWeapon->m_nAmmoTotal = 0;
pWeapon->m_nAmmoInClip = 0; pWeapon->m_nAmmoInClip = 0;
} }
#else #else
if (pWeapon->m_nType == weaponType) if (pWeapon->m_nType == weaponType)
{ {
if (pPlayer->m_nActiveWeaponSlot == weaponSlot) if (pPlayer->m_nActiveWeaponSlot == weaponSlot)
{ {
CWeaponInfo *pWeaponInfo = CWeaponInfo::GetWeaponInfo(WEAPONTYPE_UNARMED); CWeaponInfo *pWeaponInfo = CWeaponInfo::GetWeaponInfo(WEAPONTYPE_UNARMED);
pPlayer->SetCurrentWeapon(pWeaponInfo->m_WeaponSlot); pPlayer->SetCurrentWeapon(pWeaponInfo->m_WeaponSlot);
} }
pWeapon->Shutdown(); pWeapon->Shutdown();
} }
#endif #endif
} }
} }
// Implementation of opcode 0x605 (CLEO) // Implementation of opcode 0x605 (CLEO)
static eWeaponType GetWeaponTypeFromModel(int model) static eWeaponType GetWeaponTypeFromModel(int model)
{ {
eWeaponType weaponType = WEAPONTYPE_UNARMED; eWeaponType weaponType = WEAPONTYPE_UNARMED;
for (size_t i = 0; i < 37; i++) for (size_t i = 0; i < 37; i++)
{ {
int temp = CallAndReturn<int, BY_GAME(NULL, 0x4418B0, 0x430690)>(i); // int __cdecl CPickups::ModelForWeapon(int a1)
int temp = if (temp == model)
CallAndReturn<int, BY_GAME(NULL, 0x4418B0, 0x430690)>(i); // int __cdecl CPickups::ModelForWeapon(int a1) {
weaponType = (eWeaponType)i;
break;
}
}
if (temp == model) return weaponType;
{
weaponType = (eWeaponType)i;
break;
}
}
return weaponType;
} }
#endif #endif
#ifdef GTASA #ifdef GTASA
void Weapon::GiveWeaponToPlayer(std::string &weapon_type) void Weapon::GiveWeaponToPlayer(std::string& weapon_type)
{ {
CPlayerPed *player = FindPlayerPed(); CPlayerPed* player = FindPlayerPed();
int hplayer = CPools::GetPedRef(player); int hplayer = CPools::GetPedRef(player);
if (weapon_type == "-1") // Jetpack if (weapon_type == "-1") // Jetpack
{ {
Command<Commands::TASK_JETPACK>(hplayer); Command<Commands::TASK_JETPACK>(hplayer);
} }
else if (weapon_type == "-2") // CellPhone else if (weapon_type == "-2") // CellPhone
{ {
CStreaming::RequestModel(330, PRIORITY_REQUEST); CStreaming::RequestModel(330, PRIORITY_REQUEST);
CStreaming::LoadAllRequestedModels(false); CStreaming::LoadAllRequestedModels(false);
player->ClearWeaponTarget(); player->ClearWeaponTarget();
player->SetCurrentWeapon(WEAPON_UNARMED); player->SetCurrentWeapon(WEAPON_UNARMED);
player->AddWeaponModel(330); player->AddWeaponModel(330);
Command<Commands::MARK_MODEL_AS_NO_LONGER_NEEDED>(330); Command<Commands::MARK_MODEL_AS_NO_LONGER_NEEDED>(330);
} }
else else
{ {
int iweapon_type = std::stoi(weapon_type); int iweapon_type = std::stoi(weapon_type);
int model = NULL; int model = NULL;
Command<Commands::GET_WEAPONTYPE_MODEL>(iweapon_type, &model); Command<Commands::GET_WEAPONTYPE_MODEL>(iweapon_type, &model);
CStreaming::RequestModel(model, PRIORITY_REQUEST); CStreaming::RequestModel(model, PRIORITY_REQUEST);
if (model == 363) // remote bomb if (model == 363) // remote bomb
{ {
CStreaming::RequestModel(364, PRIORITY_REQUEST); // detonator CStreaming::RequestModel(364, PRIORITY_REQUEST); // detonator
} }
CStreaming::LoadAllRequestedModels(false); CStreaming::LoadAllRequestedModels(false);
Command<Commands::GIVE_WEAPON_TO_CHAR>(hplayer, iweapon_type, m_nAmmoCount); Command<Commands::GIVE_WEAPON_TO_CHAR>(hplayer, iweapon_type, m_nAmmoCount);
if (model == 363) // remote bomb if (model == 363) // remote bomb
{ {
Command<Commands::MARK_MODEL_AS_NO_LONGER_NEEDED>(364); // detonator Command<Commands::MARK_MODEL_AS_NO_LONGER_NEEDED>(364); // detonator
} }
Command<Commands::MARK_MODEL_AS_NO_LONGER_NEEDED>(model); Command<Commands::MARK_MODEL_AS_NO_LONGER_NEEDED>(model);
} }
} }
#else // GTA3 & GTAVC #else // GTA3 & GTAVC
void Weapon::GiveWeaponToPlayer(std::string &rootkey, std::string &name, std::string &model) void Weapon::GiveWeaponToPlayer(std::string& rootkey, std::string& name, std::string& model)
{ {
CPlayerPed *player = FindPlayerPed(); CPlayerPed* player = FindPlayerPed();
int hplayer = CPools::GetPedRef(player); int hplayer = CPools::GetPedRef(player);
int iModel = std::stoi(model); int iModel = std::stoi(model);
CStreaming::RequestModel(iModel, PRIORITY_REQUEST); CStreaming::RequestModel(iModel, PRIORITY_REQUEST);
CStreaming::LoadAllRequestedModels(false); CStreaming::LoadAllRequestedModels(false);
eWeaponType weaponType = GetWeaponTypeFromModel(iModel); eWeaponType weaponType = GetWeaponTypeFromModel(iModel);
Command<Commands::GIVE_WEAPON_TO_CHAR>(hplayer, weaponType, m_nAmmoCount); Command<Commands::GIVE_WEAPON_TO_CHAR>(hplayer, weaponType, m_nAmmoCount);
Command<Commands::MARK_MODEL_AS_NO_LONGER_NEEDED>(iModel); Command<Commands::MARK_MODEL_AS_NO_LONGER_NEEDED>(iModel);
#ifdef GTA3 #ifdef GTA3
Command<Commands::SET_CURRENT_PLAYER_WEAPON>(0, weaponType); Command<Commands::SET_CURRENT_PLAYER_WEAPON>(0, weaponType);
#endif #endif
} }
#endif #endif
void Weapon::Draw() void Weapon::Draw()
{ {
CPlayerPed *pPlayer = FindPlayerPed(); CPlayerPed* pPlayer = FindPlayerPed();
uint hplayer = CPools::GetPedRef(pPlayer); uint hplayer = CPools::GetPedRef(pPlayer);
ImGui::Spacing(); ImGui::Spacing();
if (ImGui::Button("Drop weapon", Ui::GetSize(3))) if (ImGui::Button("Drop weapon", Ui::GetSize(3)))
{ {
float x, y, z; float x, y, z;
Command<Commands::GET_OFFSET_FROM_CHAR_IN_WORLD_COORDS>(hplayer, 0.0, 3.0, 0.0, &x, &y, &z); Command<Commands::GET_OFFSET_FROM_CHAR_IN_WORLD_COORDS>(hplayer, 0.0, 3.0, 0.0, &x, &y, &z);
#ifdef GTA3 #ifdef GTA3
eWeaponType weaponType = pPlayer->m_aWeapons[pPlayer->m_nCurrentWeapon].m_eWeaponType; eWeaponType weaponType = pPlayer->m_aWeapons[pPlayer->m_nCurrentWeapon].m_eWeaponType;
#else #else
eWeaponType weaponType = pPlayer->m_aWeapons[pPlayer->m_nActiveWeaponSlot].m_nType; eWeaponType weaponType = pPlayer->m_aWeapons[pPlayer->m_nActiveWeaponSlot].m_nType;
#endif #endif
if (weaponType) if (weaponType)
{ {
int model = 0, pickup = 0; int model = 0, pickup = 0;
#ifdef GTASA #ifdef GTASA
Command<Commands::GET_WEAPONTYPE_MODEL>(weaponType, &model); Command<Commands::GET_WEAPONTYPE_MODEL>(weaponType, &model);
#else // GTA3 & GTAVC #else // GTA3 & GTAVC
model = CallAndReturn<int, BY_GAME(NULL, 0x4418B0, 0x430690)>( model = CallAndReturn<int, BY_GAME(NULL, 0x4418B0, 0x430690)>(weaponType); // int __cdecl CPickups::ModelForWeapon(int a1)
weaponType); // int __cdecl CPickups::ModelForWeapon(int a1)
#endif #endif
Command<Commands::CREATE_PICKUP_WITH_AMMO>(model, 3, 999, x, y, z, &pickup); Command<Commands::CREATE_PICKUP_WITH_AMMO>(model, 3, 999, x, y, z, &pickup);
#ifdef GTASA #ifdef GTASA
Command<Commands::REMOVE_WEAPON_FROM_CHAR>(hplayer, weaponType); Command<Commands::REMOVE_WEAPON_FROM_CHAR>(hplayer, weaponType);
#else // GTA3 & GTAVC #else // GTA3 & GTAVC
ClearPlayerWeapon(weaponType); ClearPlayerWeapon(weaponType);
#endif #endif
} }
} }
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::Button("Remove all", Ui::GetSize(3))) if (ImGui::Button("Remove all", Ui::GetSize(3)))
{ {
pPlayer->ClearWeapons(); pPlayer->ClearWeapons();
} }
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::Button("Remove current", Ui::GetSize(3))) if (ImGui::Button("Remove current", Ui::GetSize(3)))
{ {
#ifdef GTASA #ifdef GTASA
Command<Commands::REMOVE_WEAPON_FROM_CHAR>(hplayer, pPlayer->m_aWeapons[pPlayer->m_nActiveWeaponSlot].m_nType); Command<Commands::REMOVE_WEAPON_FROM_CHAR>(hplayer, pPlayer->m_aWeapons[pPlayer->m_nActiveWeaponSlot].m_nType);
#elif GTAVC #elif GTAVC
ClearPlayerWeapon(pPlayer->m_aWeapons[pPlayer->m_nActiveWeaponSlot].m_nType); ClearPlayerWeapon(pPlayer->m_aWeapons[pPlayer->m_nActiveWeaponSlot].m_nType);
#else // GTA3 #else // GTA3
ClearPlayerWeapon(pPlayer->m_aWeapons[pPlayer->m_nCurrentWeapon].m_eWeaponType); ClearPlayerWeapon(pPlayer->m_aWeapons[pPlayer->m_nCurrentWeapon].m_eWeaponType);
#endif #endif
} }
ImGui::Spacing(); ImGui::Spacing();
if (ImGui::BeginTabBar("Ped", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll)) if (ImGui::BeginTabBar("Ped", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll))
{ {
if (ImGui::BeginTabItem("Checkboxes")) if (ImGui::BeginTabItem("Checkboxes"))
{ {
ImGui::Spacing(); ImGui::Spacing();
ImGui::BeginChild("CheckboxesChild"); ImGui::BeginChild("CheckboxesChild");
ImGui::Spacing(); ImGui::Spacing();
ImGui::SameLine(); ImGui::SameLine();
ImGui::Text("Info"); ImGui::Text("Info");
Ui::ShowTooltip("Weapon tweaks apply globally\nto every ped weapon type"); Ui::ShowTooltip("Weapon tweaks apply globally\nto every ped weapon type");
ImGui::Columns(2, 0, false); ImGui::Columns(2, 0, false);
#ifdef GTASA #ifdef GTASA
Ui::CheckboxWithHint("Fast aim", &m_bAutoAim, Ui::CheckboxWithHint("Fast aim", &m_bAutoAim, "Enables aim assist on keyboard\n\nQ = left E = right\n\nPress Q and E to switch targets.\nMoving mouse removes the target!");
"Enables aim assist on keyboard\n\nQ = left E = right\n\nPress Q and E to switch " if (Ui::CheckboxWithHint("Dual wield", &m_bDualWeild,
"targets.\nMoving mouse removes the target!"); "Dual wield pistol, shawoff, uzi, tec9\n(Other weapons don't work)"))
if (Ui::CheckboxWithHint("Dual wield", &m_bDualWeild, {
"Dual wield pistol, shawoff, uzi, tec9\n(Other weapons don't work)")) if (!m_bDualWeild)
{ {
if (!m_bDualWeild) CWeaponInfo::LoadWeaponData();
{ }
CWeaponInfo::LoadWeaponData(); }
}
}
#endif #endif
if (Ui::CheckboxWithHint("Huge damage", &m_bHugeDamage, if (Ui::CheckboxWithHint("Huge damage", &m_bHugeDamage, "Also enable 'Long range' if weapon range is short"))
"Also enable 'Long range' if weapon range is short")) {
{ if (!m_bHugeDamage)
if (!m_bHugeDamage) {
{ CWeaponInfo::LoadWeaponData();
CWeaponInfo::LoadWeaponData(); }
} }
} if (Ui::CheckboxWithHint("Fast reload", &m_bFastReload))
if (Ui::CheckboxWithHint("Fast reload", &m_bFastReload)) {
{ Command<Commands::SET_PLAYER_FAST_RELOAD>(hplayer, m_bFastReload);
Command<Commands::SET_PLAYER_FAST_RELOAD>(hplayer, m_bFastReload); }
}
#ifdef GTASA #ifdef GTASA
Ui::CheckboxAddress("Infinite ammo", 0x969178); Ui::CheckboxAddress("Infinite ammo", 0x969178);
ImGui::NextColumn(); ImGui::NextColumn();
#else #else
ImGui::NextColumn(); ImGui::NextColumn();
Ui::CheckboxWithHint("Infinite ammo", &m_bInfiniteAmmo); Ui::CheckboxWithHint("Infinite ammo", &m_bInfiniteAmmo);
#endif #endif
if (Ui::CheckboxWithHint("Long range", &m_bLongRange)) if (Ui::CheckboxWithHint("Long range", &m_bLongRange))
{ {
if (!m_bLongRange) if (!m_bLongRange)
{ {
CWeaponInfo::LoadWeaponData(); CWeaponInfo::LoadWeaponData();
} }
} }
#ifdef GTASA #ifdef GTASA
if (Ui::CheckboxWithHint("Move when aiming", &m_bMoveAim)) if (Ui::CheckboxWithHint("Move when aiming", &m_bMoveAim))
{ {
if (!m_bMoveAim) if (!m_bMoveAim)
{ {
CWeaponInfo::LoadWeaponData(); CWeaponInfo::LoadWeaponData();
} }
} }
if (Ui::CheckboxWithHint("Move when firing", &m_bMoveFire)) if (Ui::CheckboxWithHint("Move when firing", &m_bMoveFire))
{ {
if (!m_bMoveFire) if (!m_bMoveFire)
{ {
CWeaponInfo::LoadWeaponData(); CWeaponInfo::LoadWeaponData();
} }
} }
if (Ui::CheckboxWithHint("Rapid fire", &m_bRapidFire)) if (Ui::CheckboxWithHint("Rapid fire", &m_bRapidFire))
{ {
if (!m_bRapidFire) if (!m_bRapidFire)
{ {
CWeaponInfo::LoadWeaponData(); CWeaponInfo::LoadWeaponData();
} }
} }
#endif #endif
ImGui::Columns(1, 0, false); ImGui::Columns(1, 0, false);
ImGui::EndChild(); ImGui::EndChild();
ImGui::EndTabItem(); ImGui::EndTabItem();
} }
if (ImGui::BeginTabItem("Spawn")) if (ImGui::BeginTabItem("Spawn"))
{ {
ImGui::Spacing(); ImGui::Spacing();
if (ImGui::InputInt("Ammo", &m_nAmmoCount)) if (ImGui::InputInt("Ammo", &m_nAmmoCount))
{ {
m_nAmmoCount = (m_nAmmoCount < 0) ? 0 : m_nAmmoCount; m_nAmmoCount = (m_nAmmoCount < 0) ? 0 : m_nAmmoCount;
m_nAmmoCount = (m_nAmmoCount > 99999) ? 99999 : m_nAmmoCount; m_nAmmoCount = (m_nAmmoCount > 99999) ? 99999 : m_nAmmoCount;
} }
#ifdef GTASA #ifdef GTASA
Ui::DrawImages( Ui::DrawImages(m_WeaponData, GiveWeaponToPlayer, nullptr,
m_WeaponData, GiveWeaponToPlayer, nullptr, [](std::string str) { return m_WeaponData.m_pJson->m_Data[str].get<std::string>(); },
[](std::string str) { return m_WeaponData.m_pJson->m_Data[str].get<std::string>(); }, [](std::string str) { return str != "0"; /*Unarmed*/ }
[](std::string str) { );
return str != "0"; /*Unarmed*/
});
#else // GTA3 & GTAVC #else // GTA3 & GTAVC
Ui::DrawJSON(m_WeaponData, GiveWeaponToPlayer, nullptr); Ui::DrawJSON(m_WeaponData, GiveWeaponToPlayer, nullptr);
#endif #endif
ImGui::EndTabItem(); ImGui::EndTabItem();
} }
#ifdef GTASA #ifdef GTASA
if (ImGui::BeginTabItem("Gang weapon editor")) if (ImGui::BeginTabItem("Gang weapon editor"))
{ {
ImGui::Spacing(); ImGui::Spacing();
Ui::ListBox("Select gang", Ped::m_GangNames, m_nSelectedGang); Ui::ListBox("Select gang", Ped::m_GangNames, m_nSelectedGang);
ImGui::Columns(3, 0, false); ImGui::Columns(3, 0, false);
ImGui::RadioButton("Weap 1", &m_nSelectedWeapon, 0); ImGui::RadioButton("Weap 1", &m_nSelectedWeapon, 0);
ImGui::NextColumn(); ImGui::NextColumn();
ImGui::RadioButton("Weap 2", &m_nSelectedWeapon, 1); ImGui::RadioButton("Weap 2", &m_nSelectedWeapon, 1);
ImGui::NextColumn(); ImGui::NextColumn();
ImGui::RadioButton("Weap 3", &m_nSelectedWeapon, 2); ImGui::RadioButton("Weap 3", &m_nSelectedWeapon, 2);
ImGui::Columns(1); ImGui::Columns(1);
ImGui::Spacing(); ImGui::Spacing();
ImGui::Text( ImGui::Text("Current weapon: %s",
"Current weapon: %s", m_WeaponData.m_pJson->m_Data[std::to_string(m_nGangWeaponList[m_nSelectedGang][m_nSelectedWeapon])].get<
m_WeaponData.m_pJson->m_Data[std::to_string(m_nGangWeaponList[m_nSelectedGang][m_nSelectedWeapon])] std::string>().c_str());
.get<std::string>() ImGui::Spacing();
.c_str()); Ui::DrawImages(m_WeaponData, SetGangWeapon, nullptr,
ImGui::Spacing(); [](std::string str) { return m_WeaponData.m_pJson->m_Data[str].get<std::string>(); },
Ui::DrawImages( [](std::string str) { return str != "-1"; /*Jetpack*/ }
m_WeaponData, SetGangWeapon, nullptr, );
[](std::string str) { return m_WeaponData.m_pJson->m_Data[str].get<std::string>(); }, ImGui::EndTabItem();
[](std::string str) { }
return str != "-1"; /*Jetpack*/
});
ImGui::EndTabItem();
}
#endif #endif
ImGui::EndTabBar(); ImGui::EndTabBar();
} }
} }

View File

@ -5,51 +5,52 @@ class Weapon
{ {
public: public:
#ifdef GTASA #ifdef GTASA
static inline ResourceStore m_WeaponData{"weapon", eResourceType::TYPE_BOTH, ImVec2(65, 65)}; static inline ResourceStore m_WeaponData{ "weapon", eResourceType::TYPE_BOTH, ImVec2(65, 65) };
static inline bool m_bAutoAim; static inline bool m_bAutoAim;
static inline bool m_bRapidFire; static inline bool m_bRapidFire;
static inline bool m_bDualWeild; static inline bool m_bDualWeild;
static inline bool m_bMoveAim; static inline bool m_bMoveAim;
static inline bool m_bMoveFire; static inline bool m_bMoveFire;
static inline int m_nSelectedGang; static inline int m_nSelectedGang;
#else // GTA3 & GTAVC #else // GTA3 & GTAVC
static inline ResourceStore m_WeaponData{"weapon", eResourceType::TYPE_TEXT}; static inline ResourceStore m_WeaponData{ "weapon", eResourceType::TYPE_TEXT };
static inline bool m_bInfiniteAmmo; static inline bool m_bInfiniteAmmo;
#endif #endif
static inline bool m_bFastReload; static inline bool m_bFastReload;
static inline bool m_bHugeDamage; static inline bool m_bHugeDamage;
static inline bool m_bLongRange; static inline bool m_bLongRange;
static inline int m_nAmmoCount = 99999; static inline int m_nAmmoCount = 99999;
static inline uchar m_nCurrentWeaponSlot = -1; static inline uchar m_nCurrentWeaponSlot = -1;
static inline int m_nSelectedWeapon; static inline int m_nSelectedWeapon;
#ifdef GTASA #ifdef GTASA
static inline int m_nGangWeaponList[10][3] = { static inline int m_nGangWeaponList[10][3] =
{WEAPON_PISTOL, WEAPON_MICRO_UZI, WEAPON_UNARMED}, // Ballas {
{WEAPON_PISTOL, WEAPON_UNARMED, WEAPON_UNARMED}, // Grove {WEAPON_PISTOL, WEAPON_MICRO_UZI, WEAPON_UNARMED}, // Ballas
{WEAPON_PISTOL, WEAPON_UNARMED, WEAPON_UNARMED}, // Vagos {WEAPON_PISTOL, WEAPON_UNARMED, WEAPON_UNARMED}, // Grove
{WEAPON_UNARMED, WEAPON_UNARMED, WEAPON_UNARMED}, // SF Rifa {WEAPON_PISTOL, WEAPON_UNARMED, WEAPON_UNARMED}, // Vagos
{WEAPON_PISTOL, WEAPON_MICRO_UZI, WEAPON_UNARMED}, // Da Nang Boys {WEAPON_UNARMED, WEAPON_UNARMED, WEAPON_UNARMED}, // SF Rifa
{WEAPON_DESERT_EAGLE, WEAPON_UNARMED, WEAPON_UNARMED}, // Mafia {WEAPON_PISTOL, WEAPON_MICRO_UZI, WEAPON_UNARMED}, // Da Nang Boys
{WEAPON_PISTOL, WEAPON_AK47, WEAPON_UNARMED}, // Triads {WEAPON_DESERT_EAGLE, WEAPON_UNARMED, WEAPON_UNARMED}, // Mafia
{WEAPON_PISTOL, WEAPON_MICRO_UZI, WEAPON_UNARMED}, // VLA {WEAPON_PISTOL, WEAPON_AK47, WEAPON_UNARMED}, // Triads
{WEAPON_UNARMED, WEAPON_UNARMED, WEAPON_UNARMED}, // Gang 9 {WEAPON_PISTOL, WEAPON_MICRO_UZI, WEAPON_UNARMED}, // VLA
{WEAPON_UNARMED, WEAPON_UNARMED, WEAPON_UNARMED}, // Gang 10 {WEAPON_UNARMED, WEAPON_UNARMED, WEAPON_UNARMED}, // Gang 9
}; {WEAPON_UNARMED, WEAPON_UNARMED, WEAPON_UNARMED}, // Gang 10
};
#endif #endif
Weapon(); Weapon();
static void Draw(); static void Draw();
#ifdef GTASA #ifdef GTASA
static void GiveWeaponToPlayer(std::string &weapon_type); static void GiveWeaponToPlayer(std::string& weapon_type);
#else // GTA3 & GTAVC #else // GTA3 & GTAVC
static void GiveWeaponToPlayer(std::string &rootkey, std::string &model, std::string &name); static void GiveWeaponToPlayer(std::string& rootkey, std::string& model, std::string& name);
#endif #endif
#ifdef GTASA #ifdef GTASA
static void SetGangWeapon(std::string &weapon_type); static void SetGangWeapon(std::string& weapon_type);
#endif #endif
}; };

View File

@ -88,6 +88,9 @@ project "CheatMenuIII"
"../src/weapon.cpp", "../src/weapon.cpp",
"../src/game.h", "../src/game.h",
"../src/game.cpp", "../src/game.cpp",
"../src/timecyc.h",
"../src/visual.h",
"../src/visual.cpp",
"../src/filehandler.h", "../src/filehandler.h",
"../src/filehandler.cpp", "../src/filehandler.cpp",
"../src/dllmain.cpp" "../src/dllmain.cpp"