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

View File

@ -5,44 +5,45 @@
class Animation
{
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
struct m_Cutscene
{
static inline ResourceStore m_Data{"cutscene", eResourceType::TYPE_TEXT};
static inline std::string m_SceneName;
static inline int m_nInterior; // player interior backup
static inline bool m_bRunning;
};
// 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
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"};
// Cutscene player
struct m_Cutscene
{
static inline ResourceStore m_Data{ "cutscene", eResourceType::TYPE_TEXT };
static inline std::string m_SceneName;
static inline int m_nInterior; // player interior backup
static inline bool m_bRunning;
};
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:
Animation();
Animation();
public:
static void Draw();
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 RemoveAnimation(std::string &rootKey, std::string &anim, std::string &ifp);
static void Draw();
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 RemoveAnimation(std::string& rootKey, std::string& anim, std::string& ifp);
};
#else
// Dummy Class for VC & III
class Animation
{
};
class Animation{};
#endif

View File

@ -1,184 +1,183 @@
#include "pch.h"
#include "cheatMenu.h"
#include "menuinfo.h"
#include "pch.h"
#include "ui.h"
#include "updater.h"
void CheatMenu::DrawWindow()
{
ImGuiIO &io = ImGui::GetIO();
static bool bRunning = true;
ImGuiIO& io = ImGui::GetIO();
static bool bRunning = true;
if (BY_GAME(FrontEndMenuManager.m_bMenuActive, FrontendMenuManager.m_bMenuVisible,
FrontEndMenuManager.m_bMenuActive))
{
if (bRunning)
{
gConfig.WriteToDisk();
bRunning = false;
m_bShowMouse = false;
}
}
else
{
bRunning = true;
if (m_bShowMenu || BY_GAME(m_Commands::m_bShowMenu, true, true))
{
if (m_bShowMenu)
{
static ImVec2 fScreenSize = ImVec2(-1, -1);
ImVec2 size(screen::GetScreenWidth(), screen::GetScreenHeight());
if (BY_GAME(FrontEndMenuManager.m_bMenuActive, FrontendMenuManager.m_bMenuVisible, FrontEndMenuManager.m_bMenuActive))
{
if (bRunning)
{
gConfig.WriteToDisk();
bRunning = false;
m_bShowMouse = false;
}
}
else
{
bRunning = true;
if (m_bShowMenu || BY_GAME(m_Commands::m_bShowMenu, true, true))
{
if (m_bShowMenu)
{
static ImVec2 fScreenSize = ImVec2(-1, -1);
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)
{
m_fMenuSize.x += (size.x - fScreenSize.x) / 4.0f;
m_fMenuSize.y += (size.y - fScreenSize.y) / 1.2f;
}
ImGui::SetNextWindowSize(m_fMenuSize);
if (ImGui::Begin(MENU_TITLE, &m_bShowMenu, ImGuiWindowFlags_NoCollapse))
{
ImGui::PushStyleVar(ImGuiStyleVar_WindowMinSize, ImVec2(250, 350));
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding,
ImVec2(ImGui::GetWindowWidth() / 85, ImGui::GetWindowHeight() / 200));
if (ImGui::Begin(MENU_TITLE, &m_bShowMenu, ImGuiWindowFlags_NoCollapse))
{
ImGui::PushStyleVar(ImGuiStyleVar_WindowMinSize, ImVec2(250, 350));
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding,
ImVec2(ImGui::GetWindowWidth() / 85, ImGui::GetWindowHeight() / 200));
if (Updater::m_State == UPDATER_UPDATE_FOUND)
Updater::ShowUpdateScreen();
else
Ui::DrawHeaders(header);
if (Updater::m_State == UPDATER_UPDATE_FOUND)
Updater::ShowUpdateScreen();
else
Ui::DrawHeaders(header);
m_fMenuSize = ImGui::GetWindowSize();
gConfig.SetValue("window.sizeX", m_fMenuSize.x);
gConfig.SetValue("window.sizeY", m_fMenuSize.y);
m_fMenuSize = ImGui::GetWindowSize();
gConfig.SetValue("window.sizeX", m_fMenuSize.x);
gConfig.SetValue("window.sizeY", m_fMenuSize.y);
ImGui::PopStyleVar(2);
ImGui::End();
}
}
ImGui::PopStyleVar(2);
ImGui::End();
}
}
#ifdef GTASA
else
{
DrawShortcutsWindow();
}
else
{
DrawShortcutsWindow();
}
#endif
}
}
DrawOverlay();
}
}
DrawOverlay();
}
CheatMenu::CheatMenu()
{
ApplyStyle();
windowCallback = std::bind(&DrawWindow);
ApplyStyle();
windowCallback = std::bind(&DrawWindow);
// Load menu settings
Ui::m_HeaderId = gConfig.GetValue("window.id", std::string(""));
m_fMenuSize.x = gConfig.GetValue("window.sizeX", screen::GetScreenWidth() / 4.0f);
m_fMenuSize.y = gConfig.GetValue("window.sizeY", screen::GetScreenHeight() / 1.2f);
srand(CTimer::m_snTimeInMilliseconds);
// Load menu settings
Ui::m_HeaderId = gConfig.GetValue("window.id", std::string(""));
m_fMenuSize.x = gConfig.GetValue("window.sizeX", screen::GetScreenWidth() / 4.0f);
m_fMenuSize.y = gConfig.GetValue("window.sizeY", screen::GetScreenHeight() / 1.2f);
srand(CTimer::m_snTimeInMilliseconds);
Events::processScriptsEvent += []() {
if (!BY_GAME(FrontEndMenuManager.m_bMenuActive, FrontendMenuManager.m_bMenuVisible,
FrontEndMenuManager.m_bMenuActive))
{
if (menuOpen.Pressed())
{
m_bShowMenu = !m_bShowMenu;
}
Events::processScriptsEvent += []()
{
if (!BY_GAME(FrontEndMenuManager.m_bMenuActive, FrontendMenuManager.m_bMenuVisible, FrontEndMenuManager.m_bMenuActive))
{
if (menuOpen.Pressed())
{
m_bShowMenu = !m_bShowMenu;
}
if (commandWindow.Pressed())
{
if (m_Commands::m_bShowMenu)
{
ProcessCommands();
strcpy(m_Commands::m_nInputBuffer, "");
}
m_Commands::m_bShowMenu = !m_Commands::m_bShowMenu;
}
if (commandWindow.Pressed())
{
if (m_Commands::m_bShowMenu)
{
ProcessCommands();
strcpy(m_Commands::m_nInputBuffer, "");
}
m_Commands::m_bShowMenu = !m_Commands::m_bShowMenu;
}
if (m_bShowMouse != m_bShowMenu)
{
if (m_bShowMouse) // Only write when the menu closes
{
gConfig.WriteToDisk();
}
if (m_bShowMouse != m_bShowMenu)
{
if (m_bShowMouse) // Only write when the menu closes
{
gConfig.WriteToDisk();
}
m_bShowMouse = m_bShowMenu;
}
}
};
m_bShowMouse = m_bShowMenu;
}
}
};
}
void CheatMenu::ApplyStyle()
{
ImGuiStyle *style = &ImGui::GetStyle();
ImVec4 *colors = style->Colors;
ImGuiStyle* style = &ImGui::GetStyle();
ImVec4* colors = style->Colors;
style->WindowRounding = 1;
style->ScrollbarRounding = 1;
style->GrabRounding = 1;
style->WindowRounding = 1;
style->ChildRounding = 1;
style->ScrollbarRounding = 1;
style->GrabRounding = 1;
style->FrameRounding = 0;
style->TabRounding = 1.0;
style->AntiAliasedLines = true;
style->AntiAliasedFill = true;
style->Alpha = 1;
style->WindowRounding = 1;
style->ScrollbarRounding = 1;
style->GrabRounding = 1;
style->WindowRounding = 1;
style->ChildRounding = 1;
style->ScrollbarRounding = 1;
style->GrabRounding = 1;
style->FrameRounding = 0;
style->TabRounding = 1.0;
style->AntiAliasedLines = true;
style->AntiAliasedFill = true;
style->Alpha = 1;
style->FrameBorderSize = 0;
style->ChildBorderSize = 0;
style->TabBorderSize = 0;
style->WindowBorderSize = 0;
style->PopupBorderSize = 0;
style->FrameBorderSize = 0;
style->ChildBorderSize = 0;
style->TabBorderSize = 0;
style->WindowBorderSize = 0;
style->PopupBorderSize = 0;
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_WindowBg] = ImVec4(0.06f, 0.06f, 0.06f, 0.94f);
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_Border] = ImVec4(0.43f, 0.43f, 0.50f, 0.50f);
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_FrameBgHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.40f);
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_TitleBgActive] = ImVec4(0.16f, 0.29f, 0.48f, 1.00f);
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_ScrollbarBg] = ImVec4(0.02f, 0.02f, 0.02f, 0.53f);
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_ScrollbarGrabActive] = ImVec4(0.51f, 0.51f, 0.51f, 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_SliderGrabActive] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
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_ButtonActive] = ImVec4(0.06f, 0.53f, 0.98f, 1.00f);
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_HeaderActive] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
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_SeparatorActive] = ImVec4(0.10f, 0.40f, 0.75f, 1.00f);
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_ResizeGripActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.95f);
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_TabActive] = ImVec4(0.20f, 0.41f, 0.68f, 1.00f);
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_PlotLines] = ImVec4(0.61f, 0.61f, 0.61f, 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_PlotHistogramHovered] = ImVec4(1.00f, 0.60f, 0.00f, 1.00f);
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_NavHighlight] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
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_ModalWindowDimBg] = ImVec4(0.26f, 0.59f, 0.98f, 0.35f);
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_WindowBg] = ImVec4(0.06f, 0.06f, 0.06f, 0.94f);
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_Border] = ImVec4(0.43f, 0.43f, 0.50f, 0.50f);
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_FrameBgHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.40f);
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_TitleBgActive] = ImVec4(0.16f, 0.29f, 0.48f, 1.00f);
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_ScrollbarBg] = ImVec4(0.02f, 0.02f, 0.02f, 0.53f);
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_ScrollbarGrabActive] = ImVec4(0.51f, 0.51f, 0.51f, 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_SliderGrabActive] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
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_ButtonActive] = ImVec4(0.06f, 0.53f, 0.98f, 1.00f);
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_HeaderActive] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
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_SeparatorActive] = ImVec4(0.10f, 0.40f, 0.75f, 1.00f);
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_ResizeGripActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.95f);
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_TabActive] = ImVec4(0.20f, 0.41f, 0.68f, 1.00f);
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_PlotLines] = ImVec4(0.61f, 0.61f, 0.61f, 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_PlotHistogramHovered] = ImVec4(1.00f, 0.60f, 0.00f, 1.00f);
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_NavHighlight] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
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_ModalWindowDimBg] = ImVec4(0.26f, 0.59f, 0.98f, 0.35f);
}

View File

@ -9,9 +9,6 @@
*/
#pragma once
#ifndef GTA3
#include "visual.h"
#endif
#include "animation.h"
#include "game.h"
#include "hook.h"
@ -20,24 +17,15 @@
#include "player.h"
#include "teleport.h"
#include "vehicle.h"
#include "visual.h"
#include "weapon.h"
#ifndef GTA3
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:
static inline bool m_bShowMenu = false;
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{
{"Teleport", &Teleport::Draw}, {"Player", &Player::Draw}, {"Ped", &Ped::Draw},
#ifdef GTASA
@ -46,8 +34,8 @@ private:
{"Dummy", nullptr},
#endif
{"Vehicle", &Vehicle::Draw}, {"Weapon", &Weapon::Draw}, {"Game", &Game::Draw},
{"Visual", &Visual::Draw}, {"Menu", &Menu::Draw}};
#endif
{"Visual", &Visual::Draw}, {"Menu", &Menu::Draw}
};
static void ApplyStyle();
static void DrawWindow();

View File

@ -1,100 +1,101 @@
#include "cheatmenu.h"
#include "hook.h"
#include "menuinfo.h"
#include "pch.h"
#include "hook.h"
#include "cheatmenu.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
directory and the asi in modloader. Why??
/*
Had to put this in place since some people put the folder in root
directory and the asi in modloader. Why??
TODO: Unlikely they'd even read the log so have to do something else
*/
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 "
"directory"
<< std::endl;
return;
}
TODO: Unlikely they'd even read the log so have to do something else
*/
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 directory" << std::endl;
return;
}
#ifdef GTASA
Hook::ApplyMouseFix();
Hook::ApplyMouseFix();
#endif
static bool bGameInit = false;
static bool bGameInit = false;
// Wait till game init
Events::initRwEvent += [] { bGameInit = true; };
// Wait till game init
Events::initRwEvent += []
{
bGameInit = true;
};
while (!bGameInit)
{
Sleep(1000);
}
while (!bGameInit)
{
Sleep(1000);
}
#ifdef GTASA
/*
TODO: Find a better way
Since you could still name it something else
*/
if (GetModuleHandle("SAMP.dll") || GetModuleHandle("SAMP.asi"))
{
MessageBox(RsGlobal.ps->window, "SAMP detected. Exiting CheatMenu.", "CheatMenu", MB_ICONERROR);
return;
}
CFastman92limitAdjuster::Init();
if (GetModuleHandle("SAMP.dll") || GetModuleHandle("SAMP.asi"))
{
MessageBox(RsGlobal.ps->window, "SAMP detected. Exiting CheatMenu.", "CheatMenu", MB_ICONERROR);
return;
}
CFastman92limitAdjuster::Init();
#endif
gLog << "Starting...\nVersion: " MENU_TITLE "\nAuthor: Grinch_\nDiscord: " DISCORD_INVITE
"\nMore Info: " GITHUB_LINK "\n"
<< std::endl;
CheatMenu menu;
gLog << "Starting...\nVersion: " MENU_TITLE "\nAuthor: Grinch_\nDiscord: " DISCORD_INVITE "\nMore Info: "
GITHUB_LINK "\n" << std::endl;
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)
{
Updater::CheckForUpdate();
gConfig.SetValue("config.last_update_checked", tstruct.tm_mday);
}
// 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);
while (true)
{
Sleep(5000);
if (lastCheckDate != tstruct.tm_mday)
{
Updater::CheckForUpdate();
gConfig.SetValue("config.last_update_checked", tstruct.tm_mday);
}
if (Updater::m_State == UPDATER_CHECKING)
{
Updater::CheckForUpdate();
}
}
while (true)
{
Sleep(5000);
if (Updater::m_State == UPDATER_CHECKING)
{
Updater::CheckForUpdate();
}
}
}
BOOL WINAPI DllMain(HINSTANCE hDllHandle, DWORD nReason, LPVOID Reserved)
{
if (nReason == DLL_PROCESS_ATTACH)
{
uint gameVersion = GetGameVersion();
if (gameVersion == BY_GAME(GAME_10US_HOODLUM, GAME_10EN, GAME_10EN))
{
CreateThread(nullptr, NULL, (LPTHREAD_START_ROUTINE)&MenuThread, nullptr, NULL, nullptr);
}
else
{
if (nReason == DLL_PROCESS_ATTACH)
{
uint gameVersion = GetGameVersion();
if (gameVersion == BY_GAME(GAME_10US_HOODLUM, GAME_10EN, GAME_10EN))
{
CreateThread(nullptr, NULL, (LPTHREAD_START_ROUTINE)&MenuThread, nullptr, NULL, nullptr);
}
else
{
#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
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
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
}
}
}
}
return TRUE;
return TRUE;
}

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -3,63 +3,65 @@
class Game
{
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_bDisableReplay;
static inline bool m_bMissionTimer;
static inline bool m_bFreezeTime;
static inline bool m_bSyncTime;
static inline bool m_bDisableCheats;
static inline bool m_bDisableReplay;
static inline bool m_bMissionTimer;
static inline bool m_bFreezeTime;
static inline bool m_bSyncTime;
#ifdef GTASA
static inline bool m_bForbiddenArea = true; // wanted level when going outside playable aea
static inline bool m_bSolidWater; // walk on water hack
static inline bool m_bScreenShot;
static inline bool m_bKeepStuff;
static inline ResourceStore m_StatData{"stat", eResourceType::TYPE_TEXT};
static inline std::vector<std::string> m_DayNames = {"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;
};
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_bScreenShot;
static inline bool m_bKeepStuff;
static inline ResourceStore m_StatData{ "stat", eResourceType::TYPE_TEXT };
static inline std::vector<std::string> m_DayNames =
{
"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;
};
#endif
Game();
static void Draw();
static void RealTimeClock();
Game();
static void Draw();
static void RealTimeClock();
#ifdef GTASA
// TODO: Update freecam with aap's code
static void FreeCam();
static void ClearFreecamStuff();
// TODO: Update freecam with aap's code
static void FreeCam();
static void ClearFreecamStuff();
#endif
};

View File

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

View File

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

View File

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

View File

@ -10,13 +10,13 @@ private:
public:
int m_key1;
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
bool DrawUI(const char *label);
bool DrawUI(const char* label);
bool Pressed();
std::string GetNameString();
};

View File

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

View File

@ -2,117 +2,122 @@
#include "../depend/json.hpp"
/*
Wrapper class for nlohmann::json
Contains helper methods
Wrapper class for nlohmann::json
Contains helper methods
*/
class CJson
{
private:
std::string m_FilePath;
std::string m_FilePath;
public:
nlohmann::json m_Data;
nlohmann::json m_Data;
/*
Returns a value from json structure hierarchy using '.'
Example: "Menu.Window.X"
*/
// specialize since typeid(std::string) doesn't work
/*
Returns a value from json structure hierarchy using '.'
Example: "Menu.Window.X"
*/
// specialize since typeid(std::string) doesn't work
template <typename T> T GetValue(std::string &&key, T &&defaultVal)
{
try
{
std::stringstream ss(key);
std::string line;
template <typename T>
T GetValue(std::string&& key, T&& defaultVal)
{
try
{
std::stringstream ss(key);
std::string line;
nlohmann::json *json = &m_Data;
nlohmann::json* json = &m_Data;
while (getline(ss, line, '.'))
{
json = &((*json)[line]);
}
while (getline(ss, line, '.'))
{
json = &((*json)[line]);
}
// json library bugs with bool, using int instead
if (typeid(T) == typeid(bool))
{
return ((json->get<int>() == 1) ? true : false);
}
return json->get<T>();
}
catch (...)
{
return defaultVal;
}
}
// json library bugs with bool, using int instead
if (typeid(T) == typeid(bool))
{
return ((json->get<int>() == 1) ? true : false);
}
return json->get<T>();
}
catch (...)
{
return defaultVal;
}
}
template <> std::string GetValue(std::string &&key, std::string &&defaultVal)
{
try
{
std::stringstream ss(key);
std::string line;
template <>
std::string GetValue(std::string&& key, std::string&& defaultVal)
{
try
{
std::stringstream ss(key);
std::string line;
nlohmann::json *json = &m_Data;
nlohmann::json* json = &m_Data;
while (getline(ss, line, '.'))
{
json = &((*json)[line]);
}
while (getline(ss, line, '.'))
{
json = &((*json)[line]);
}
return json->get<std::string>();
}
catch (...)
{
return defaultVal;
}
}
return json->get<std::string>();
}
catch (...)
{
return defaultVal;
}
}
/*
Allows to save values in json hierarchy using '.'
Example: "Menu.Window.X"
*/
template <typename T> void SetValue(std::string &&key, T &val)
{
std::stringstream ss(key);
std::string line;
/*
Allows to save values in json hierarchy using '.'
Example: "Menu.Window.X"
*/
template <typename T>
void SetValue(std::string&& key, T& val)
{
std::stringstream ss(key);
std::string line;
nlohmann::json *json = &m_Data;
nlohmann::json* json = &m_Data;
while (getline(ss, line, '.'))
{
json = &((*json)[line]);
}
while (getline(ss, 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)
{
std::stringstream ss(key);
std::string line;
// json library bugs with bool, using int instead
if (typeid(T) == typeid(bool))
{
*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, '.'))
{
json = &((*json)[line]);
}
nlohmann::json* json = &m_Data;
*json = val;
}
while (getline(ss, line, '.'))
{
json = &((*json)[line]);
}
/*
Saves json data to disk
*/
void WriteToDisk();
CJson(const char *text = "");
*json = val;
}
/*
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
{
private:
enum DISPLAY_POS
{
CUSTOM,
TOP_LEFT,
TOP_RIGHT,
BOTTOM_LEFT,
BOTTOM_RIGHT
};
struct m_Overlay
{
static inline bool bCoord = false;
static inline bool bFPS = false;
static inline int mFPS = 0;
static inline bool bLocName = false;
static inline bool bTransparent = false;
static inline bool bVehHealth = false;
static inline bool bVehSpeed = false;
static inline bool bCpuUsage = false;
static inline float fCpuUsage = 0.0f;
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;
};
enum DISPLAY_POS
{
CUSTOM,
TOP_LEFT,
TOP_RIGHT,
BOTTOM_LEFT,
BOTTOM_RIGHT
};
struct m_Overlay
{
static inline bool bCoord = false;
static inline bool bFPS = false;
static inline int mFPS = 0;
static inline bool bLocName = false;
static inline bool bTransparent = false;
static inline bool bVehHealth = false;
static inline bool bVehSpeed = false;
static inline bool bCpuUsage = false;
static inline float fCpuUsage = 0.0f;
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:
struct m_Commands
{
static inline bool m_bShowMenu = false;
static inline char m_nInputBuffer[INPUT_BUFFER_SIZE] = "";
};
struct m_Commands
{
static inline bool m_bShowMenu = false;
static inline char m_nInputBuffer[INPUT_BUFFER_SIZE] = "";
};
Menu();
static void Draw();
static void DrawOverlay();
static void DrawShortcutsWindow();
static void ProcessCommands();
Menu();
static void Draw();
static void DrawOverlay();
static void DrawShortcutsWindow();
static void ProcessCommands();
};

View File

@ -1,6 +1,6 @@
#pragma once
#define MENU_NAME "Cheat Menu"
#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 MENU_TITLE MENU_NAME " v" MENU_VERSION "(" BUILD_NUMBER ")"

View File

@ -1,184 +1,254 @@
#include "neon.h"
#include "pch.h"
#include "neon.h"
#include "util.h"
// Neon sprite
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,
0x48, 0x59, 0x73, 0x00, 0x00, 0x0b, 0x13, 0x00, 0x00, 0x0b, 0x13, 0x01, 0x00, 0x9a, 0x9c, 0x18, 0x00, 0x00, 0x00,
0x20, 0x63, 0x48, 0x52, 0x4d, 0x00, 0x00, 0x7a, 0x25, 0x00, 0x00, 0x80, 0x83, 0x00, 0x00, 0xf9, 0xff, 0x00, 0x00,
0x80, 0xe9, 0x00, 0x00, 0x75, 0x30, 0x00, 0x00, 0xea, 0x60, 0x00, 0x00, 0x3a, 0x98, 0x00, 0x00, 0x17, 0x6f, 0x92,
0x5f, 0xc5, 0x46, 0x00, 0x00, 0x06, 0x1f, 0x49, 0x44, 0x41, 0x54, 0x78, 0xda, 0xec, 0x5d, 0xdb, 0x8e, 0xe4, 0x2a,
0x0c, 0x64, 0xa3, 0xf3, 0x10, 0x45, 0x49, 0x2b, 0xe2, 0xff, 0xbf, 0x11, 0x45, 0x09, 0x42, 0x79, 0x9b, 0xf3, 0x34,
0xda, 0xde, 0x08, 0x70, 0xd9, 0x18, 0x42, 0x66, 0x1a, 0x69, 0xb4, 0xdb, 0x37, 0x3a, 0x55, 0x2e, 0x97, 0x0d, 0xdd,
0x6a, 0xfe, 0x7c, 0x7d, 0x7d, 0x99, 0x86, 0x63, 0x01, 0x9f, 0x77, 0xb4, 0xba, 0xa0, 0x3f, 0x95, 0x09, 0x58, 0x14,
0xe6, 0x38, 0x9e, 0x46, 0x00, 0x02, 0xda, 0x26, 0xee, 0x77, 0xad, 0xc9, 0xd0, 0x24, 0x60, 0x11, 0x82, 0x36, 0x02,
0x32, 0x8e, 0xde, 0x08, 0x58, 0x98, 0xa0, 0x2d, 0x03, 0xb0, 0xab, 0x49, 0x82, 0x06, 0x01, 0x4b, 0x21, 0x70, 0x14,
0x74, 0x15, 0x22, 0x4a, 0x09, 0x40, 0xc1, 0x53, 0xf7, 0xa1, 0xd1, 0x77, 0xbd, 0x10, 0x80, 0x4a, 0xde, 0x0a, 0x14,
0xe0, 0x84, 0x6a, 0x38, 0x5a, 0x11, 0xa0, 0x01, 0x7e, 0x8d, 0xbc, 0x7e, 0x63, 0x12, 0xa1, 0x42, 0x82, 0x16, 0x01,
0x96, 0x41, 0xc4, 0x9a, 0x99, 0xbb, 0x39, 0x09, 0x5c, 0x02, 0x16, 0x66, 0xe4, 0x53, 0x51, 0x7f, 0x45, 0xe6, 0xd9,
0x41, 0x22, 0x9c, 0xa6, 0x31, 0x72, 0x08, 0xa8, 0x01, 0x7e, 0x36, 0xc6, 0x78, 0x90, 0x08, 0x0e, 0x09, 0x4d, 0x08,
0x48, 0x81, 0x4f, 0x49, 0xfe, 0x0a, 0x3c, 0x36, 0x7c, 0x6b, 0x12, 0x50, 0x02, 0x16, 0x41, 0xe4, 0x63, 0x51, 0x9f,
0x13, 0x24, 0x78, 0x06, 0x11, 0xaa, 0x24, 0x0c, 0xca, 0x2d, 0xae, 0x04, 0xfc, 0xf7, 0xed, 0xd8, 0xe3, 0xaf, 0x88,
0x92, 0x2c, 0x68, 0xbe, 0xd0, 0x18, 0x04, 0xaf, 0xb1, 0x05, 0xe0, 0xdf, 0x81, 0x4e, 0x97, 0xbf, 0xeb, 0xe3, 0x73,
0xc6, 0x30, 0x45, 0x60, 0xb5, 0x08, 0x40, 0xc0, 0xbf, 0x12, 0xe0, 0xcd, 0x05, 0xf0, 0xf4, 0x36, 0xc7, 0x14, 0x51,
0xc0, 0x95, 0x84, 0x95, 0x59, 0x82, 0x97, 0x52, 0x02, 0x16, 0x01, 0xf3, 0xaf, 0x4b, 0x34, 0xaf, 0x51, 0xbf, 0x02,
0x9e, 0x12, 0xff, 0xa7, 0x48, 0xb0, 0x77, 0x2a, 0x80, 0x92, 0x7e, 0xcc, 0xe5, 0x63, 0x20, 0x4d, 0x42, 0x01, 0x14,
0x09, 0xb9, 0xca, 0xc3, 0x52, 0xc1, 0x50, 0x18, 0x7d, 0x4b, 0x94, 0xba, 0x58, 0xbe, 0x5f, 0x41, 0x4f, 0x89, 0xdb,
0x29, 0x12, 0x90, 0x54, 0x68, 0xe2, 0x01, 0xa9, 0x31, 0x67, 0x22, 0x9b, 0x03, 0x9e, 0x52, 0xcb, 0x75, 0x4e, 0x24,
0x15, 0xac, 0x36, 0x01, 0x36, 0x23, 0xbb, 0xf7, 0xe8, 0xc7, 0x0c, 0xcf, 0x10, 0x60, 0x29, 0x52, 0x26, 0xa2, 0x3c,
0x16, 0xed, 0x56, 0x0d, 0xc2, 0xda, 0x9f, 0x32, 0x3e, 0x29, 0x78, 0x8e, 0xb2, 0xe6, 0x4c, 0x6f, 0xc0, 0xee, 0x0b,
0xb8, 0x29, 0x60, 0x41, 0xe3, 0x2b, 0x01, 0x3f, 0x31, 0x53, 0xa1, 0x48, 0x05, 0x03, 0x53, 0xfe, 0x68, 0xf4, 0x0d,
0xe0, 0x03, 0xc6, 0x18, 0x33, 0x0a, 0x48, 0xa0, 0x54, 0x50, 0x6c, 0x82, 0x4b, 0x85, 0xe8, 0xe7, 0xc0, 0x8f, 0x09,
0x22, 0x26, 0x66, 0xea, 0x89, 0xda, 0xe3, 0xd2, 0x2a, 0x50, 0x12, 0x7d, 0x54, 0x0d, 0x57, 0x52, 0x67, 0xe2, 0xfd,
0x6e, 0x2f, 0x83, 0x14, 0xe8, 0x31, 0x03, 0x76, 0x14, 0x92, 0xb7, 0x12, 0x4b, 0x72, 0x31, 0x01, 0x16, 0x94, 0xff,
0x4c, 0xd4, 0x73, 0x24, 0xca, 0x1c, 0x52, 0xa5, 0x66, 0xb8, 0x68, 0x2a, 0xe0, 0x55, 0x49, 0x3d, 0x94, 0x0a, 0x28,
0x33, 0x64, 0x99, 0xf8, 0x50, 0x58, 0xff, 0x73, 0xdd, 0x9b, 0x66, 0xf4, 0x29, 0xf0, 0xc8, 0xce, 0x14, 0x3b, 0x05,
0x90, 0x09, 0x38, 0x46, 0x74, 0x2a, 0x7a, 0xca, 0xa4, 0xa5, 0x46, 0x4e, 0x1f, 0x60, 0x13, 0x52, 0x9b, 0x19, 0xe6,
0x27, 0x4d, 0x83, 0x6a, 0x63, 0xa8, 0x94, 0xff, 0x1a, 0xf2, 0x47, 0x5f, 0xc3, 0xf5, 0x81, 0x25, 0x45, 0x00, 0x37,
0xff, 0x6b, 0x44, 0x9e, 0xe3, 0x31, 0x2a, 0x3e, 0xc0, 0x55, 0xc0, 0x5a, 0xe0, 0x01, 0xb5, 0x87, 0xa8, 0x1c, 0x0e,
0xcc, 0xfa, 0x2f, 0x6d, 0x7e, 0x6a, 0x37, 0x5b, 0x73, 0x4b, 0x0f, 0x78, 0x11, 0xf2, 0xd7, 0x24, 0x62, 0x14, 0x80,
0x5f, 0x6b, 0x11, 0xb0, 0x0a, 0xa2, 0x3f, 0x56, 0x8c, 0x3a, 0x55, 0x0e, 0x21, 0x15, 0x0f, 0x40, 0xfd, 0xb7, 0x8c,
0x1e, 0x60, 0x32, 0x0f, 0x1b, 0x43, 0xa6, 0x02, 0x58, 0x81, 0xfc, 0x6b, 0x44, 0x7f, 0x04, 0xab, 0xc1, 0x2c, 0x49,
0x83, 0x5a, 0xab, 0xc1, 0xb1, 0x93, 0xf9, 0x48, 0x35, 0x7f, 0x13, 0x70, 0x30, 0xf3, 0x5f, 0xb2, 0x01, 0xd2, 0xaa,
0x1a, 0xb0, 0x3e, 0x4a, 0x1b, 0x88, 0x26, 0xc8, 0x66, 0xea, 0xac, 0xd4, 0xf8, 0x90, 0xcf, 0x07, 0xa8, 0x79, 0xd5,
0x48, 0xff, 0x8f, 0xb9, 0x10, 0x2a, 0xdd, 0xf5, 0xa9, 0x65, 0x98, 0xdf, 0x73, 0xf9, 0x8b, 0x6a, 0x37, 0x29, 0x01,
0x5c, 0xf9, 0x6b, 0x01, 0xbd, 0x3e, 0x37, 0x44, 0x54, 0x70, 0xbe, 0x3d, 0x37, 0x64, 0x7a, 0x95, 0x5d, 0x62, 0x82,
0xb6, 0x30, 0x7a, 0x31, 0xf9, 0x87, 0x4a, 0xb9, 0x1f, 0x12, 0xd7, 0x32, 0x97, 0x6c, 0x88, 0xe4, 0xf2, 0x7f, 0x06,
0xca, 0x91, 0xb6, 0xd4, 0xa7, 0x0c, 0xc9, 0x31, 0x1f, 0x61, 0x77, 0x85, 0xdc, 0x32, 0x38, 0xdf, 0x98, 0xe7, 0xa5,
0xf3, 0x5b, 0x0d, 0x02, 0x24, 0x0d, 0x4b, 0x0d, 0x90, 0xd4, 0x7b, 0xcd, 0xc0, 0xea, 0x70, 0x41, 0x5a, 0xe1, 0x95,
0xb8, 0xa0, 0x1e, 0x5b, 0xdf, 0x99, 0xc0, 0x64, 0xb9, 0x0a, 0x78, 0x01, 0x51, 0x19, 0xcd, 0x43, 0xc7, 0x60, 0xb0,
0x9d, 0xa0, 0xbb, 0x73, 0x1f, 0x35, 0xc3, 0x89, 0xb9, 0x8a, 0x25, 0x37, 0x44, 0x7a, 0x5a, 0xed, 0x55, 0xa9, 0x36,
0x43, 0x06, 0xf4, 0x4a, 0xa8, 0x60, 0xea, 0x90, 0x24, 0xae, 0x11, 0x8a, 0xaa, 0x40, 0x4f, 0xf9, 0x3f, 0x82, 0xcd,
0x50, 0x76, 0x35, 0x78, 0x30, 0x0d, 0xb0, 0xf7, 0x31, 0x49, 0x53, 0x40, 0xcb, 0x00, 0xbb, 0x01, 0xa7, 0xd9, 0x08,
0x3d, 0x25, 0xff, 0xd9, 0xef, 0xcf, 0x59, 0x0c, 0x21, 0x1d, 0x59, 0xaf, 0x2a, 0x58, 0x35, 0x4c, 0x30, 0x74, 0x92,
0x06, 0xaa, 0xd7, 0x31, 0x34, 0xca, 0xbf, 0x3b, 0x15, 0xf0, 0xd2, 0x2e, 0x83, 0x3f, 0x6a, 0xfc, 0x74, 0x02, 0xe6,
0xdf, 0x4e, 0xc0, 0xaf, 0x57, 0x80, 0xff, 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};
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, 0x48, 0x59, 0x73, 0x00, 0x00, 0x0b,
0x13, 0x00, 0x00, 0x0b, 0x13, 0x01, 0x00, 0x9a, 0x9c, 0x18, 0x00,
0x00, 0x00, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x00, 0x00, 0x7a, 0x25,
0x00, 0x00, 0x80, 0x83, 0x00, 0x00, 0xf9, 0xff, 0x00, 0x00, 0x80,
0xe9, 0x00, 0x00, 0x75, 0x30, 0x00, 0x00, 0xea, 0x60, 0x00, 0x00,
0x3a, 0x98, 0x00, 0x00, 0x17, 0x6f, 0x92, 0x5f, 0xc5, 0x46, 0x00,
0x00, 0x06, 0x1f, 0x49, 0x44, 0x41, 0x54, 0x78, 0xda, 0xec, 0x5d,
0xdb, 0x8e, 0xe4, 0x2a, 0x0c, 0x64, 0xa3, 0xf3, 0x10, 0x45, 0x49,
0x2b, 0xe2, 0xff, 0xbf, 0x11, 0x45, 0x09, 0x42, 0x79, 0x9b, 0xf3,
0x34, 0xda, 0xde, 0x08, 0x70, 0xd9, 0x18, 0x42, 0x66, 0x1a, 0x69,
0xb4, 0xdb, 0x37, 0x3a, 0x55, 0x2e, 0x97, 0x0d, 0xdd, 0x6a, 0xfe,
0x7c, 0x7d, 0x7d, 0x99, 0x86, 0x63, 0x01, 0x9f, 0x77, 0xb4, 0xba,
0xa0, 0x3f, 0x95, 0x09, 0x58, 0x14, 0xe6, 0x38, 0x9e, 0x46, 0x00,
0x02, 0xda, 0x26, 0xee, 0x77, 0xad, 0xc9, 0xd0, 0x24, 0x60, 0x11,
0x82, 0x36, 0x02, 0x32, 0x8e, 0xde, 0x08, 0x58, 0x98, 0xa0, 0x2d,
0x03, 0xb0, 0xab, 0x49, 0x82, 0x06, 0x01, 0x4b, 0x21, 0x70, 0x14,
0x74, 0x15, 0x22, 0x4a, 0x09, 0x40, 0xc1, 0x53, 0xf7, 0xa1, 0xd1,
0x77, 0xbd, 0x10, 0x80, 0x4a, 0xde, 0x0a, 0x14, 0xe0, 0x84, 0x6a,
0x38, 0x5a, 0x11, 0xa0, 0x01, 0x7e, 0x8d, 0xbc, 0x7e, 0x63, 0x12,
0xa1, 0x42, 0x82, 0x16, 0x01, 0x96, 0x41, 0xc4, 0x9a, 0x99, 0xbb,
0x39, 0x09, 0x5c, 0x02, 0x16, 0x66, 0xe4, 0x53, 0x51, 0x7f, 0x45,
0xe6, 0xd9, 0x41, 0x22, 0x9c, 0xa6, 0x31, 0x72, 0x08, 0xa8, 0x01,
0x7e, 0x36, 0xc6, 0x78, 0x90, 0x08, 0x0e, 0x09, 0x4d, 0x08, 0x48,
0x81, 0x4f, 0x49, 0xfe, 0x0a, 0x3c, 0x36, 0x7c, 0x6b, 0x12, 0x50,
0x02, 0x16, 0x41, 0xe4, 0x63, 0x51, 0x9f, 0x13, 0x24, 0x78, 0x06,
0x11, 0xaa, 0x24, 0x0c, 0xca, 0x2d, 0xae, 0x04, 0xfc, 0xf7, 0xed,
0xd8, 0xe3, 0xaf, 0x88, 0x92, 0x2c, 0x68, 0xbe, 0xd0, 0x18, 0x04,
0xaf, 0xb1, 0x05, 0xe0, 0xdf, 0x81, 0x4e, 0x97, 0xbf, 0xeb, 0xe3,
0x73, 0xc6, 0x30, 0x45, 0x60, 0xb5, 0x08, 0x40, 0xc0, 0xbf, 0x12,
0xe0, 0xcd, 0x05, 0xf0, 0xf4, 0x36, 0xc7, 0x14, 0x51, 0xc0, 0x95,
0x84, 0x95, 0x59, 0x82, 0x97, 0x52, 0x02, 0x16, 0x01, 0xf3, 0xaf,
0x4b, 0x34, 0xaf, 0x51, 0xbf, 0x02, 0x9e, 0x12, 0xff, 0xa7, 0x48,
0xb0, 0x77, 0x2a, 0x80, 0x92, 0x7e, 0xcc, 0xe5, 0x63, 0x20, 0x4d,
0x42, 0x01, 0x14, 0x09, 0xb9, 0xca, 0xc3, 0x52, 0xc1, 0x50, 0x18,
0x7d, 0x4b, 0x94, 0xba, 0x58, 0xbe, 0x5f, 0x41, 0x4f, 0x89, 0xdb,
0x29, 0x12, 0x90, 0x54, 0x68, 0xe2, 0x01, 0xa9, 0x31, 0x67, 0x22,
0x9b, 0x03, 0x9e, 0x52, 0xcb, 0x75, 0x4e, 0x24, 0x15, 0xac, 0x36,
0x01, 0x36, 0x23, 0xbb, 0xf7, 0xe8, 0xc7, 0x0c, 0xcf, 0x10, 0x60,
0x29, 0x52, 0x26, 0xa2, 0x3c, 0x16, 0xed, 0x56, 0x0d, 0xc2, 0xda,
0x9f, 0x32, 0x3e, 0x29, 0x78, 0x8e, 0xb2, 0xe6, 0x4c, 0x6f, 0xc0,
0xee, 0x0b, 0xb8, 0x29, 0x60, 0x41, 0xe3, 0x2b, 0x01, 0x3f, 0x31,
0x53, 0xa1, 0x48, 0x05, 0x03, 0x53, 0xfe, 0x68, 0xf4, 0x0d, 0xe0,
0x03, 0xc6, 0x18, 0x33, 0x0a, 0x48, 0xa0, 0x54, 0x50, 0x6c, 0x82,
0x4b, 0x85, 0xe8, 0xe7, 0xc0, 0x8f, 0x09, 0x22, 0x26, 0x66, 0xea,
0x89, 0xda, 0xe3, 0xd2, 0x2a, 0x50, 0x12, 0x7d, 0x54, 0x0d, 0x57,
0x52, 0x67, 0xe2, 0xfd, 0x6e, 0x2f, 0x83, 0x14, 0xe8, 0x31, 0x03,
0x76, 0x14, 0x92, 0xb7, 0x12, 0x4b, 0x72, 0x31, 0x01, 0x16, 0x94,
0xff, 0x4c, 0xd4, 0x73, 0x24, 0xca, 0x1c, 0x52, 0xa5, 0x66, 0xb8,
0x68, 0x2a, 0xe0, 0x55, 0x49, 0x3d, 0x94, 0x0a, 0x28, 0x33, 0x64,
0x99, 0xf8, 0x50, 0x58, 0xff, 0x73, 0xdd, 0x9b, 0x66, 0xf4, 0x29,
0xf0, 0xc8, 0xce, 0x14, 0x3b, 0x05, 0x90, 0x09, 0x38, 0x46, 0x74,
0x2a, 0x7a, 0xca, 0xa4, 0xa5, 0x46, 0x4e, 0x1f, 0x60, 0x13, 0x52,
0x9b, 0x19, 0xe6, 0x27, 0x4d, 0x83, 0x6a, 0x63, 0xa8, 0x94, 0xff,
0x1a, 0xf2, 0x47, 0x5f, 0xc3, 0xf5, 0x81, 0x25, 0x45, 0x00, 0x37,
0xff, 0x6b, 0x44, 0x9e, 0xe3, 0x31, 0x2a, 0x3e, 0xc0, 0x55, 0xc0,
0x5a, 0xe0, 0x01, 0xb5, 0x87, 0xa8, 0x1c, 0x0e, 0xcc, 0xfa, 0x2f,
0x6d, 0x7e, 0x6a, 0x37, 0x5b, 0x73, 0x4b, 0x0f, 0x78, 0x11, 0xf2,
0xd7, 0x24, 0x62, 0x14, 0x80, 0x5f, 0x6b, 0x11, 0xb0, 0x0a, 0xa2,
0x3f, 0x56, 0x8c, 0x3a, 0x55, 0x0e, 0x21, 0x15, 0x0f, 0x40, 0xfd,
0xb7, 0x8c, 0x1e, 0x60, 0x32, 0x0f, 0x1b, 0x43, 0xa6, 0x02, 0x58,
0x81, 0xfc, 0x6b, 0x44, 0x7f, 0x04, 0xab, 0xc1, 0x2c, 0x49, 0x83,
0x5a, 0xab, 0xc1, 0xb1, 0x93, 0xf9, 0x48, 0x35, 0x7f, 0x13, 0x70,
0x30, 0xf3, 0x5f, 0xb2, 0x01, 0xd2, 0xaa, 0x1a, 0xb0, 0x3e, 0x4a,
0x1b, 0x88, 0x26, 0xc8, 0x66, 0xea, 0xac, 0xd4, 0xf8, 0x90, 0xcf,
0x07, 0xa8, 0x79, 0xd5, 0x48, 0xff, 0x8f, 0xb9, 0x10, 0x2a, 0xdd,
0xf5, 0xa9, 0x65, 0x98, 0xdf, 0x73, 0xf9, 0x8b, 0x6a, 0x37, 0x29,
0x01, 0x5c, 0xf9, 0x6b, 0x01, 0xbd, 0x3e, 0x37, 0x44, 0x54, 0x70,
0xbe, 0x3d, 0x37, 0x64, 0x7a, 0x95, 0x5d, 0x62, 0x82, 0xb6, 0x30,
0x7a, 0x31, 0xf9, 0x87, 0x4a, 0xb9, 0x1f, 0x12, 0xd7, 0x32, 0x97,
0x6c, 0x88, 0xe4, 0xf2, 0x7f, 0x06, 0xca, 0x91, 0xb6, 0xd4, 0xa7,
0x0c, 0xc9, 0x31, 0x1f, 0x61, 0x77, 0x85, 0xdc, 0x32, 0x38, 0xdf,
0x98, 0xe7, 0xa5, 0xf3, 0x5b, 0x0d, 0x02, 0x24, 0x0d, 0x4b, 0x0d,
0x90, 0xd4, 0x7b, 0xcd, 0xc0, 0xea, 0x70, 0x41, 0x5a, 0xe1, 0x95,
0xb8, 0xa0, 0x1e, 0x5b, 0xdf, 0x99, 0xc0, 0x64, 0xb9, 0x0a, 0x78,
0x01, 0x51, 0x19, 0xcd, 0x43, 0xc7, 0x60, 0xb0, 0x9d, 0xa0, 0xbb,
0x73, 0x1f, 0x35, 0xc3, 0x89, 0xb9, 0x8a, 0x25, 0x37, 0x44, 0x7a,
0x5a, 0xed, 0x55, 0xa9, 0x36, 0x43, 0x06, 0xf4, 0x4a, 0xa8, 0x60,
0xea, 0x90, 0x24, 0xae, 0x11, 0x8a, 0xaa, 0x40, 0x4f, 0xf9, 0x3f,
0x82, 0xcd, 0x50, 0x76, 0x35, 0x78, 0x30, 0x0d, 0xb0, 0xf7, 0x31,
0x49, 0x53, 0x40, 0xcb, 0x00, 0xbb, 0x01, 0xa7, 0xd9, 0x08, 0x3d,
0x25, 0xff, 0xd9, 0xef, 0xcf, 0x59, 0x0c, 0x21, 0x1d, 0x59, 0xaf,
0x2a, 0x58, 0x35, 0x4c, 0x30, 0x74, 0x92, 0x06, 0xaa, 0xd7, 0x31,
0x34, 0xca, 0xbf, 0x3b, 0x15, 0xf0, 0xd2, 0x2e, 0x83, 0x3f, 0x6a,
0xfc, 0x74, 0x02, 0xe6, 0xdf, 0x4e, 0xc0, 0xaf, 0x57, 0x80, 0xff,
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()
{
Events::processScriptsEvent += [this] {
if (!m_pNeonTexture)
{
m_pNeonTexture = Util::LoadTextureFromMemory((char *)neon_mask, sizeof(neon_mask));
}
};
Events::processScriptsEvent += [this]
{
if (!m_pNeonTexture)
{
m_pNeonTexture = Util::LoadTextureFromMemory((char*)neon_mask, sizeof(neon_mask));
}
};
Events::vehicleRenderEvent += [](CVehicle *pVeh) {
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 up = pVeh->TransformFromObjectSpace(CVector(0.0f, -Pos.y - data->m_fVal, 0.0f)) - center;
CVector right = pVeh->TransformFromObjectSpace(CVector(Pos.x + data->m_fVal, 0.0f, 0.0f)) - center;
CShadows::StoreShadowToBeRendered(5, m_pNeonTexture, &center, up.x, up.y, right.x, right.y, 180,
data->m_Color.r, data->m_Color.g, data->m_Color.b, 2.0f, false, 1.0f, 0,
true);
Events::vehicleRenderEvent += [](CVehicle* pVeh)
{
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 up = pVeh->TransformFromObjectSpace(CVector(0.0f, -Pos.y - data->m_fVal, 0.0f)) - center;
CVector right = pVeh->TransformFromObjectSpace(CVector(Pos.x + data->m_fVal, 0.0f, 0.0f)) - center;
CShadows::StoreShadowToBeRendered(5, m_pNeonTexture, &center, up.x, up.y, right.x, right.y, 180, data->m_Color.r,
data->m_Color.g, data->m_Color.b, 2.0f, false, 1.0f, 0, true);
if (data->m_bPulsing)
{
size_t delta = CTimer::m_snTimeInMilliseconds - CTimer::m_snPreviousTimeInMilliseconds;
if (data->m_bPulsing)
{
size_t delta = CTimer::m_snTimeInMilliseconds - CTimer::m_snPreviousTimeInMilliseconds;
if (data->m_fVal < 0.0f)
{
data->m_bIncrement = true;
}
if (data->m_fVal < 0.0f)
{
data->m_bIncrement = true;
}
if (data->m_fVal > 0.3f)
{
data->m_bIncrement = false;
}
if (data->m_fVal > 0.3f)
{
data->m_bIncrement = false;
}
if (data->m_bIncrement)
{
data->m_fVal += 0.0003f * delta;
}
else
{
data->m_fVal -= 0.0003f * delta;
}
}
}
};
if (data->m_bIncrement)
{
data->m_fVal += 0.0003f * delta;
}
else
{
data->m_fVal -= 0.0003f * delta;
}
}
}
};
}
Neon::~Neon()
{
if (m_pNeonTexture)
{
RwTextureDestroy(m_pNeonTexture);
m_pNeonTexture = nullptr;
}
if (m_pNeonTexture)
{
RwTextureDestroy(m_pNeonTexture);
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.g = green;
color.b = blue;
color.a = 255;
color.r = red;
color.g = green;
color.b = blue;
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
{
private:
class NeonData
{
public:
CRGBA m_Color;
bool m_bNeonInstalled;
float m_fVal;
bool m_bIncrement;
bool m_bPulsing;
class NeonData
{
public:
CRGBA m_Color;
bool m_bNeonInstalled;
float m_fVal;
bool m_bIncrement;
bool m_bPulsing;
NeonData(CVehicle *pVeh)
{
m_bNeonInstalled = false;
m_fVal = 0.0;
m_bIncrement = true;
}
};
NeonData(CVehicle* pVeh)
{
m_bNeonInstalled = false;
m_fVal = 0.0;
m_bIncrement = true;
}
};
static inline RwTexture *m_pNeonTexture = nullptr; // pointer to the neon mask texture
static inline VehicleExtendedData<NeonData> m_VehNeon;
static inline RwTexture* m_pNeonTexture = nullptr; // pointer to the neon mask texture
static inline VehicleExtendedData<NeonData> m_VehNeon;
public:
Neon();
~Neon();
static void InstallNeon(CVehicle *veh, int red, int green, int blue);
static bool IsNeonInstalled(CVehicle *veh);
static bool IsPulsingEnabled(CVehicle *veh);
static void SetPulsing(CVehicle *veh, bool state);
static void RemoveNeon(CVehicle *veh);
Neon();
~Neon();
static void InstallNeon(CVehicle* veh, int red, int green, int blue);
static bool IsNeonInstalled(CVehicle* veh);
static bool IsPulsingEnabled(CVehicle* veh);
static void SetPulsing(CVehicle* veh, bool state);
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
// SOFTWARE.
#include "pch.h"
#include "paint.h"
#include "NodeName.h"
#include "pch.h"
#include "util.h"
Paint::Paint()
{
Events::vehicleRenderEvent.before += [](CVehicle *pVeh) {
VehData &data = m_VehData.Get(pVeh);
Events::vehicleRenderEvent.before += [](CVehicle* pVeh)
{
VehData& data = m_VehData.Get(pVeh);
// reset custom color if color id changed
if (pVeh->m_nPrimaryColor != data.primary_color || pVeh->m_nSecondaryColor != data.secondary_color)
{
for (auto &it : data.materialProperties)
data.resetMaterialColor(it.first);
// reset custom color if color id changed
if (pVeh->m_nPrimaryColor != data.primary_color
|| pVeh->m_nSecondaryColor != data.secondary_color)
{
for (auto& it : data.materialProperties)
data.resetMaterialColor(it.first);
data.primary_color = pVeh->m_nPrimaryColor;
data.secondary_color = pVeh->m_nSecondaryColor;
}
data.primary_color = pVeh->m_nPrimaryColor;
data.secondary_color = pVeh->m_nSecondaryColor;
}
for (auto &it : data.materialProperties)
{
if (it.second._recolor)
{
it.second._originalColor = it.first->color;
it.first->color = it.second._color;
it.second._originalGeometryFlags = it.second._geometry->flags;
it.second._geometry->flags |= rpGEOMETRYMODULATEMATERIALCOLOR;
}
if (it.second._retexture)
{
auto tex = it.second._texture;
if (tex)
{
it.second._originalTexture = it.first->texture;
it.first->texture = tex;
}
else
{
it.second._retexture = false;
}
}
}
};
ThiscallEvent<AddressList<0x55332A, H_CALL>, PRIORITY_BEFORE, ArgPickN<CVehicle *, 0>, void(CVehicle *)>
vehicleResetAfterRender;
vehicleResetAfterRender += [](CVehicle *pVeh) {
for (auto &it : m_VehData.Get(pVeh).materialProperties)
{
if (it.second._recolor)
{
it.first->color = it.second._originalColor;
it.second._geometry->flags = it.second._originalGeometryFlags;
}
if (it.second._retexture)
{
it.first->texture = it.second._originalTexture;
}
}
};
for (auto& it : data.materialProperties)
{
if (it.second._recolor)
{
it.second._originalColor = it.first->color;
it.first->color = it.second._color;
it.second._originalGeometryFlags = it.second._geometry->flags;
it.second._geometry->flags |= rpGEOMETRYMODULATEMATERIALCOLOR;
}
if (it.second._retexture)
{
auto tex = it.second._texture;
if (tex)
{
it.second._originalTexture = it.first->texture;
it.first->texture = tex;
}
else
{
it.second._retexture = false;
}
}
}
};
ThiscallEvent<AddressList<0x55332A, H_CALL>, PRIORITY_BEFORE, ArgPickN<CVehicle*, 0>, void(CVehicle*)> vehicleResetAfterRender;
vehicleResetAfterRender += [](CVehicle* pVeh)
{
for (auto& it : m_VehData.Get(pVeh).materialProperties)
{
if (it.second._recolor)
{
it.first->color = it.second._originalColor;
it.second._geometry->flags = it.second._originalGeometryFlags;
}
if (it.second._retexture)
{
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) ||
(material->color.red == 0xFF && material->color.green == 0x00 && material->color.blue == 0xAF))
{
matProps._recolor = true;
matProps._color = color;
matProps._geometry = geometry;
}
if (!filter_mat
|| (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._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) ||
(material->color.red == 0xFF && material->color.green == 0x00 && material->color.blue == 0xAF))
{
matProps._retexture = true;
matProps._texture = texture;
}
if (!filter_mat
|| (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;
}
}
void Paint::VehData::resetMaterialColor(RpMaterial *material)
void Paint::VehData::resetMaterialColor(RpMaterial* material)
{
auto &matProps = materialProperties[material];
matProps._recolor = false;
matProps._color = {0, 0, 0, 0};
auto& matProps = materialProperties[material];
matProps._recolor = false;
matProps._color = {0, 0, 0, 0};
}
void Paint::VehData::resetMaterialTexture(RpMaterial *material)
void Paint::VehData::resetMaterialTexture(RpMaterial* material)
{
auto &matProps = materialProperties[material];
matProps._retexture = false;
matProps._texture = nullptr;
auto& matProps = materialProperties[material];
matProps._retexture = false;
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)
{
func(frame);
if (frame)
{
func(frame);
if (RwFrame *newFrame = frame->child)
NodeWrapperRecursive(newFrame, pVeh, func);
if (RwFrame *newFrame = frame->next)
NodeWrapperRecursive(newFrame, pVeh, func);
}
return;
if (RwFrame* newFrame = frame->child)
NodeWrapperRecursive(newFrame, pVeh, func);
if (RwFrame* newFrame = frame->next)
NodeWrapperRecursive(newFrame, pVeh, func);
}
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) {
const std::string name = GetFrameNodeName(frame);
NodeWrapperRecursive(frame, pVeh, [](RwFrame* 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()))
veh_nodes::names_vec.push_back(name);
});
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);
});
}
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) {
const std::string name = GetFrameNodeName(frame);
NodeWrapperRecursive(frame, pVeh, [&](RwFrame* frame)
{
const std::string name = GetFrameNodeName(frame);
struct ST
{
CRGBA _color;
bool _filter;
} st;
struct ST
{
CRGBA _color;
bool _filter;
} st;
st._color = color;
st._filter = filter_mat;
st._color = color;
st._filter = filter_mat;
if (node_name == "Default" || node_name == name)
{
RwFrameForAllObjects(
frame,
[](RwObject *object, void *data) -> RwObject * {
if (object->type == rpATOMIC)
{
RpAtomic *atomic = reinterpret_cast<RpAtomic *>(object);
if (node_name == "Default" || node_name == name)
{
RwFrameForAllObjects(frame, [](RwObject* object, void* data) -> RwObject*
{
if (object->type == rpATOMIC)
{
RpAtomic* atomic = reinterpret_cast<RpAtomic*>(object);
ST *st = reinterpret_cast<ST *>(data);
CRGBA *color = &st->_color;
bool filter_mat = st->_filter;
ST* st = reinterpret_cast<ST*>(data);
CRGBA* color = &st->_color;
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)
data.setMaterialColor(atomic->geometry->matList.materials[i], atomic->geometry,
{color->r, color->g, color->b, 255}, filter_mat);
}
return object;
},
&st);
}
});
for (int i = 0; i < atomic->geometry->matList.numMaterials; ++i)
data.setMaterialColor(atomic->geometry->matList.materials[i], atomic->geometry,
{color->r, color->g, color->b, 255}, filter_mat);
}
return object;
}, &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;
RwTexture *texture = nullptr;
RwFrame* frame = (RwFrame*)pVeh->m_pRwClump->object.parent;
RwTexture* texture = nullptr;
for (auto const &tex : m_TextureData.m_ImagesList)
{
if (tex.get()->m_FileName == texturename)
{
texture = tex.get()->m_pRwTexture;
break;
}
}
for (auto const& tex : m_TextureData.m_ImagesList)
{
if (tex.get()->m_FileName == texturename)
{
texture = tex.get()->m_pRwTexture;
break;
}
}
NodeWrapperRecursive(frame, pVeh, [&](RwFrame *frame) {
const std::string name = GetFrameNodeName(frame);
NodeWrapperRecursive(frame, pVeh, [&](RwFrame* frame)
{
const std::string name = GetFrameNodeName(frame);
struct ST
{
RwTexture *_tex;
bool _filter;
} st;
struct ST
{
RwTexture* _tex;
bool _filter;
} st;
st._tex = texture;
st._filter = filter_mat;
st._tex = texture;
st._filter = filter_mat;
if (node_name == "Default" || node_name == name)
{
RwFrameForAllObjects(
frame,
[](RwObject *object, void *data) -> RwObject * {
if (object->type == rpATOMIC)
{
RpAtomic *atomic = reinterpret_cast<RpAtomic *>(object);
if (node_name == "Default" || node_name == name)
{
RwFrameForAllObjects(frame, [](RwObject* object, void* data) -> RwObject*
{
if (object->type == rpATOMIC)
{
RpAtomic* atomic = reinterpret_cast<RpAtomic*>(object);
ST *st = reinterpret_cast<ST *>(data);
VehData &data = m_VehData.Get(FindPlayerPed()->m_pVehicle);
ST* st = reinterpret_cast<ST*>(data);
VehData& data = m_VehData.Get(FindPlayerPed()->m_pVehicle);
for (int i = 0; i < atomic->geometry->matList.numMaterials; ++i)
{
data.setMaterialTexture(atomic->geometry->matList.materials[i], st->_tex, st->_filter);
}
}
return object;
},
&st);
}
});
for (int i = 0; i < atomic->geometry->matList.numMaterials; ++i)
{
data.setMaterialTexture(atomic->geometry->matList.materials[i], st->_tex,
st->_filter);
}
}
return object;
}, &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) {
const std::string name = GetFrameNodeName(frame);
NodeWrapperRecursive(frame, pVeh, [&](RwFrame* frame)
{
const std::string name = GetFrameNodeName(frame);
if (node_name == "Default" || node_name == name)
{
RwFrameForAllObjects(
frame,
[](RwObject *object, void *data) -> RwObject * {
if (object->type == rpATOMIC)
{
RpAtomic *atomic = reinterpret_cast<RpAtomic *>(object);
VehData &data = m_VehData.Get(FindPlayerPed()->m_pVehicle);
if (node_name == "Default" || node_name == name)
{
RwFrameForAllObjects(frame, [](RwObject* object, void* data) -> RwObject*
{
if (object->type == rpATOMIC)
{
RpAtomic* atomic = reinterpret_cast<RpAtomic*>(object);
VehData& data = m_VehData.Get(FindPlayerPed()->m_pVehicle);
for (int i = 0; i < atomic->geometry->matList.numMaterials; ++i)
data.resetMaterialColor(atomic->geometry->matList.materials[i]);
}
return object;
},
nullptr);
}
});
for (int i = 0; i < atomic->geometry->matList.numMaterials; ++i)
data.resetMaterialColor(atomic->geometry->matList.materials[i]);
}
return object;
}, 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) {
const std::string name = GetFrameNodeName(frame);
NodeWrapperRecursive(frame, pVeh, [&](RwFrame* frame)
{
const std::string name = GetFrameNodeName(frame);
if (node_name == "Default" || node_name == name)
{
RwFrameForAllObjects(
frame,
[](RwObject *object, void *data) -> RwObject * {
if (object->type == rpATOMIC)
{
RpAtomic *atomic = reinterpret_cast<RpAtomic *>(object);
if (node_name == "Default" || node_name == name)
{
RwFrameForAllObjects(frame, [](RwObject* object, void* data) -> RwObject*
{
if (object->type == rpATOMIC)
{
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)
data.resetMaterialTexture(atomic->geometry->matList.materials[i]);
}
return object;
},
nullptr);
}
});
for (int i = 0; i < atomic->geometry->matList.numMaterials; ++i)
data.resetMaterialTexture(atomic->geometry->matList.materials[i]);
}
return object;
}, nullptr);
}
});
}

View File

@ -27,59 +27,64 @@
class Paint
{
private:
// store vehicle specific data
struct VehData
{
struct MaterialProperties
{
MaterialProperties()
: _color{0, 0, 0, 0}, _recolor(false), _retexture(false),
_geometry(nullptr), _originalColor{0, 0, 0, 0}, _originalTexture(nullptr), _originalGeometryFlags(0)
{
}
// store vehicle specific data
struct VehData
{
struct MaterialProperties
{
MaterialProperties() :
_color{0, 0, 0, 0},
_recolor(false),
_retexture(false),
_geometry(nullptr),
_originalColor{0, 0, 0, 0},
_originalTexture(nullptr),
_originalGeometryFlags(0)
{
}
RwRGBA _color;
RwTexture *_texture;
bool _recolor;
bool _retexture;
RpGeometry *_geometry;
RwRGBA _originalColor;
RwTexture *_originalTexture;
RwInt32 _originalGeometryFlags;
};
RwRGBA _color;
RwTexture* _texture;
bool _recolor;
bool _retexture;
RpGeometry* _geometry;
RwRGBA _originalColor;
RwTexture* _originalTexture;
RwInt32 _originalGeometryFlags;
};
// carcols color id
uchar primary_color = 0;
uchar secondary_color = 0;
std::unordered_map<RpMaterial *, MaterialProperties> materialProperties;
// carcols color id
uchar primary_color = 0;
uchar secondary_color = 0;
std::unordered_map<RpMaterial*, MaterialProperties> materialProperties;
VehData(CVehicle *veh)
{
primary_color = veh->m_nPrimaryColor;
secondary_color = veh->m_nSecondaryColor;
}
VehData(CVehicle* veh)
{
primary_color = veh->m_nPrimaryColor;
secondary_color = veh->m_nSecondaryColor;
}
void setMaterialColor(RpMaterial *material, RpGeometry *geometry, RwRGBA color, bool filter_mat = false);
void setMaterialTexture(RpMaterial *material, RwTexture *texture, bool filter_mat = false);
void resetMaterialColor(RpMaterial *material);
void resetMaterialTexture(RpMaterial *material);
};
static inline VehicleExtendedData<VehData> m_VehData;
void setMaterialColor(RpMaterial* material, RpGeometry* geometry, RwRGBA color, bool filter_mat = false);
void setMaterialTexture(RpMaterial* material, RwTexture* texture, bool filter_mat = false);
void resetMaterialColor(RpMaterial* material);
void resetMaterialTexture(RpMaterial* material);
};
static inline VehicleExtendedData<VehData> m_VehData;
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
{
static inline std::vector<std::string> names_vec{"Default"};
static inline std::string selected = "Default";
};
struct veh_nodes
{
static inline std::vector<std::string> names_vec{"Default"};
static inline std::string selected = "Default";
};
Paint();
static void UpdateNodeListRecursive(CVehicle *pVeh);
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 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 ResetNodeTexture(CVehicle *pVeh, std::string node_name);
Paint();
static void UpdateNodeListRecursive(CVehicle* pVeh);
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 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 ResetNodeTexture(CVehicle* pVeh, std::string node_name);
};

View File

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

View File

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

View File

@ -9,75 +9,63 @@ class Ped
{
private:
#ifdef GTASA
static inline bool m_bBigHead;
static inline bool m_bThinBody;
static inline CJson m_SpecialPedJson = CJson("ped special");
static inline ResourceStore m_PedData{"ped", eResourceType::TYPE_BOTH, ImVec2(65, 110)};
static inline bool m_bBigHead;
static inline bool m_bThinBody;
static inline CJson m_SpecialPedJson = CJson("ped special");
static inline ResourceStore m_PedData{"ped", eResourceType::TYPE_BOTH, ImVec2(65, 110)};
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"};
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"
};
#else // GTA3 & GTAVC
static inline ResourceStore m_PedData{"ped", eResourceType::TYPE_TEXT};
static inline ResourceStore m_PedData{"ped", eResourceType::TYPE_TEXT};
#endif
static inline bool m_bImagesLoaded;
static inline bool m_bExGangWarsInstalled;
static inline int m_nPedRemoveRadius = 5;
struct m_SpawnPed
{
static inline std::vector<CPed *> m_List;
static inline int m_nAccuracy = 50;
static inline int m_nPedHealth = 100;
static inline bool m_bPedMove;
static inline bool m_bPedBleed;
static inline int m_nSelectedPedType;
static inline int m_nWeaponId;
static inline std::string m_nWeaponName = "None";
static inline std::vector<std::string> m_PedTypeList = {
static inline bool m_bImagesLoaded;
static inline bool m_bExGangWarsInstalled;
static inline int m_nPedRemoveRadius = 5;
struct m_SpawnPed
{
static inline std::vector<CPed*> m_List;
static inline int m_nAccuracy = 50;
static inline int m_nPedHealth = 100;
static inline bool m_bPedMove;
static inline bool m_bPedBleed;
static inline int m_nSelectedPedType;
static inline int m_nWeaponId;
static inline std::string m_nWeaponName = "None";
static inline std::vector<std::string> m_PedTypeList =
{
#ifdef GTASA
"Civ Male",
"Civ Female",
"Cop",
"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"
"Civ Male", "Civ Female", "Cop", "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
"Civ Male", "Civ Female", "Cop (crash)", "Cubans", "Haitians", "Streetwannabe's", "Diaz' Gang",
"Security Guards", "Biker Gang", "Vercetti Gang", "Golfers", "Gang 9", "Emergency", "Fireman",
"Criminal", "Unused", "Prostitute", "Special"
"Civ Male", "Civ Female", "Cop (crash)", "Cubans", "Haitians", "Streetwannabe's", "Diaz' Gang",
"Security Guards", "Biker Gang", "Vercetti Gang", "Golfers", "Gang 9", "Emergency",
"Fireman", "Criminal", "Unused", "Prostitute", "Special"
#else // GTA3
"Civ Male", "Civ Female", "Cop", "Leones", "Triads", "Diablos", "Yakuza",
"Yardies", "Colombians", "Hoods", "unused", "unused", "Emergency", "Fireman",
"Criminal", "unused", "Prostitute", "Special"
"Civ Male", "Civ Female", "Cop", "Leones", "Triads", "Diablos", "Yakuza", "Yardies", "Colombians",
"Hoods", "unused", "unused", "Emergency", "Fireman", "Criminal", "unused", "Prostitute", "Special"
#endif
};
};
};
};
friend class Player;
friend class Player;
#ifdef GTASA
friend class Weapon;
friend class Weapon;
#endif
public:
Ped();
~Ped();
static void Draw();
Ped();
~Ped();
static void Draw();
#ifdef GTASA
static void SpawnPed(std::string &model);
static void BigHeadEffect(CPed *ped);
static void SpawnPed(std::string& model);
static void BigHeadEffect(CPed *ped);
#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
};

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -1,10 +1,12 @@
#include "pch.h"
#include "CFileLoader.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);
@ -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
Loading it directly here doesn't work
*/
Events::processScriptsEvent += [text, this]() {
Events::processScriptsEvent += [text, this]()
{
if (!m_bTexturesLoaded)
{
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";
RwTexDictionary *pRwTexDictionary = CFileLoader::LoadTexDictionary(fullPath.c_str());
std::string fullPath = PLUGIN_PATH((char*)"CheatMenu\\") + name + ".txd";
RwTexDictionary* pRwTexDictionary = CFileLoader::LoadTexDictionary(fullPath.c_str());
if (pRwTexDictionary)
{
RwLinkList *pRLL = (RwLinkList *)pRwTexDictionary->texturesInDict.link.next;
if (pRwTexDictionary)
{
RwLinkList *pRLL = (RwLinkList*)pRwTexDictionary->texturesInDict.link.next;
RwTexDictionary *pEndDic;
do
{
pEndDic = (RwTexDictionary *)pRLL->link.next;
RwTexture *pTex = (RwTexture *)&pRLL[-1];
pEndDic = (RwTexDictionary*)pRLL->link.next;
RwTexture *pTex = (RwTexture*)&pRLL[-1];
m_ImagesList.push_back(std::make_unique<TextureResource>());
m_ImagesList.back().get()->m_pRwTexture = pTex;
// Fetch IDirec9Texture9* from RwTexture*
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);
}
pRLL = (RwLinkList *)pEndDic;
} while (pEndDic != (RwTexDictionary *)&pRwTexDictionary->texturesInDict);
}
pRLL = (RwLinkList*)pEndDic;
}
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 "d3d9.h"
#include "json.h"
#include <rw/rwcore.h>
#include <string>
struct RwD3D9Raster
{
union {
IDirect3DTexture9 *texture;
IDirect3DSurface9 *surface;
};
unsigned char *palette;
unsigned char alpha;
unsigned char cubeTextureFlags; /* 0x01 IS_CUBEMAP_TEX */
unsigned char textureFlags; /* 0x10 IS_COMPRESSED */
unsigned char lockedLevel;
IDirect3DSurface9 *lockedSurface;
D3DLOCKED_RECT lockedRect;
D3DFORMAT format;
IDirect3DSwapChain9 *swapChain;
HWND *hwnd;
union
{
IDirect3DTexture9* texture;
IDirect3DSurface9* surface;
};
unsigned char* palette;
unsigned char alpha;
unsigned char cubeTextureFlags; /* 0x01 IS_CUBEMAP_TEX */
unsigned char textureFlags; /* 0x10 IS_COMPRESSED */
unsigned char lockedLevel;
IDirect3DSurface9* lockedSurface;
D3DLOCKED_RECT lockedRect;
D3DFORMAT format;
IDirect3DSwapChain9* swapChain;
HWND* hwnd;
};
struct RwRasterEx : public RwRaster
{
RwD3D9Raster *m_pRenderResource;
RwD3D9Raster *m_pRenderResource;
};
struct TextureResource
{
std::string m_FileName;
std::string m_CategoryName;
RwTexture *m_pRwTexture = nullptr;
void *m_pTexture = nullptr;
std::string m_FileName;
std::string m_CategoryName;
RwTexture *m_pRwTexture = nullptr;
void *m_pTexture = nullptr;
};
enum eResourceType
{
TYPE_IMAGE,
TYPE_TEXT,
TYPE_BOTH,
TYPE_IMAGE,
TYPE_TEXT,
TYPE_BOTH,
};
using TextureResourceList = std::vector<std::unique_ptr<TextureResource>>;
class ResourceStore
{
private:
void LoadTextureResource(std::string &&path);
void LoadTextureResource(std::string&& path);
public:
ImGuiTextFilter m_Filter = "";
std::vector<std::string> m_Categories = {"All"};
std::string m_Selected = "All";
std::unique_ptr<CJson> m_pJson;
TextureResourceList m_ImagesList;
ImVec2 m_ImageSize;
bool m_bTexturesLoaded = false;
ResourceStore(const char *text, eResourceType type = TYPE_IMAGE, ImVec2 imageSize = ImVec2(64, 64));
ImGuiTextFilter m_Filter = "";
std::vector<std::string> m_Categories = {"All"};
std::string m_Selected = "All";
std::unique_ptr<CJson> m_pJson;
TextureResourceList m_ImagesList;
ImVec2 m_ImageSize;
bool m_bTexturesLoaded = false;
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 "menu.h"
#include "pch.h"
#include "ui.h"
#include "util.h"
#ifdef GTASA
// 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()
{
uint cur_timer = CTimer::m_snTimeInMilliseconds;
static uint timer = cur_timer;
uint cur_timer = CTimer::m_snTimeInMilliseconds;
static uint timer = cur_timer;
// Update the radar list each 5 seconds
if (cur_timer - timer < 5000)
{
return;
}
// Update the radar list each 5 seconds
if (cur_timer - timer < 5000)
{
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
for (int i = 0; i != 175; ++i)
{
CVector pos = CRadar::ms_RadarTrace[i].m_vPosition;
uchar sprite = CRadar::ms_RadarTrace[i].m_nBlipSprite;
auto sprite_name = m_SpriteJson.m_Data[std::to_string(sprite)].get<std::string>();
std::string key_name = sprite_name + ", " + Util::GetLocationName(&pos);
// 175 is the max number of sprites, FLA can increase this limit, might need to update this
for (int i = 0; i != 175; ++i)
{
CVector pos = CRadar::ms_RadarTrace[i].m_vPosition;
uchar sprite = CRadar::ms_RadarTrace[i].m_nBlipSprite;
auto sprite_name = m_SpriteJson.m_Data[std::to_string(sprite)].get<std::string>();
std::string key_name = sprite_name + ", " + Util::GetLocationName(&pos);
m_tpData.m_pJson->m_Data["Radar"][key_name] =
"0, " + std::to_string(pos.x) + ", " + std::to_string(pos.y) + ", " + std::to_string(pos.z);
m_tpData.m_pJson->m_Data["Radar"][key_name] = "0, " + std::to_string(pos.x) + ", " + std::to_string(pos.y) + ", " +
std::to_string(pos.z);
/*
"Radar" : {
"key_name" : "0, x, y, z",
}
*/
}
/*
"Radar" : {
"key_name" : "0, x, y, z",
}
*/
}
}
#endif
Teleport::Teleport()
{
m_bQuickTeleport = gConfig.GetValue("quick_teleport", false);
m_bQuickTeleport = gConfig.GetValue("quick_teleport", false);
Events::processScriptsEvent += [] {
if ((m_Teleport::m_bEnabled == true) && ((CTimer::m_snTimeInMilliseconds - m_Teleport::m_nTimer) > 500))
{
CPlayerPed *player = FindPlayerPed();
Events::processScriptsEvent += []
{
if ((m_Teleport::m_bEnabled == true) && ((CTimer::m_snTimeInMilliseconds - m_Teleport::m_nTimer) > 500))
{
CPlayerPed* player = FindPlayerPed();
#ifdef GTASA
CEntity *player_entity = FindPlayerEntity(-1);
m_Teleport::m_fPos.z =
CWorld::FindGroundZFor3DCoord(m_Teleport::m_fPos.x, m_Teleport::m_fPos.y, m_Teleport::m_fPos.z + 100.0f,
nullptr, &player_entity) +
1.0f;
CEntity* player_entity = FindPlayerEntity(-1);
m_Teleport::m_fPos.z = CWorld::FindGroundZFor3DCoord(m_Teleport::m_fPos.x, m_Teleport::m_fPos.y,
m_Teleport::m_fPos.z + 100.0f, nullptr, &player_entity) + 1.0f;
#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 + 100.0f, nullptr) +
1.0f;
#endif
CVehicle *pVeh = player->m_pVehicle;
m_Teleport::m_fPos.z = CWorld::FindGroundZFor3DCoord(m_Teleport::m_fPos.x, m_Teleport::m_fPos.y,
m_Teleport::m_fPos.z + 100.0f, nullptr) + 1.0f;
#endif
CVehicle* pVeh = player->m_pVehicle;
if (pVeh && 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));
}
else
{
BY_GAME(player->Teleport(m_Teleport::m_fPos, false), player->Teleport(m_Teleport::m_fPos));
}
if (pVeh && BY_GAME(player->m_nPedFlags.bInVehicle, player->m_pVehicle, player->m_pVehicle))
{
BY_GAME(pVeh->Teleport(m_Teleport::m_fPos, false, false), pVeh->Teleport(m_Teleport::m_fPos));
}
else
{
BY_GAME(player->Teleport(m_Teleport::m_fPos, false, false), player->Teleport(m_Teleport::m_fPos));
}
m_Teleport::m_bEnabled = false;
Command<Commands::FREEZE_CHAR_POSITION_AND_DONT_LOAD_COLLISION>(CPools::GetPedRef(player), false);
Command<Commands::RESTORE_CAMERA_JUMPCUT>();
TheCamera.Fade(0, 1);
}
m_Teleport::m_bEnabled = false;
Command<Commands::FREEZE_CHAR_POSITION_AND_DONT_LOAD_COLLISION>(CPools::GetPedRef(player), false);
Command<Commands::RESTORE_CAMERA_JUMPCUT>();
TheCamera.Fade(0, 1);
}
if (m_bQuickTeleport)
{
if (quickTeleport.Pressed() && ((CTimer::m_snTimeInMilliseconds - m_nQuickTeleportTimer) > 500))
{
m_nQuickTeleportTimer = CTimer::m_snTimeInMilliseconds;
TeleportPlayer(true);
}
}
};
if (m_bQuickTeleport)
{
if (quickTeleport.Pressed()
&& ((CTimer::m_snTimeInMilliseconds - m_nQuickTeleportTimer) > 500))
{
m_nQuickTeleportTimer = CTimer::m_snTimeInMilliseconds;
TeleportPlayer(true);
}
}
};
}
void Teleport::TeleportPlayer(bool get_marker, CVector pos, int interior_id)
{
CPlayerPed *pPlayer = FindPlayerPed();
CVehicle *pVeh = pPlayer->m_pVehicle;
CPlayerPed* pPlayer = FindPlayerPed();
CVehicle* pVeh = pPlayer->m_pVehicle;
#ifdef GTASA
if (get_marker)
{
tRadarTrace targetBlip = CRadar::ms_RadarTrace[LOWORD(FrontEndMenuManager.m_nTargetBlipIndex)];
if (get_marker)
{
tRadarTrace targetBlip = CRadar::ms_RadarTrace[LOWORD(FrontEndMenuManager.m_nTargetBlipIndex)];
if (targetBlip.m_nBlipSprite != RADAR_SPRITE_WAYPOINT)
{
SetHelpMessage("Target blip not found. You need to place it on the map first.", false, false, false);
return;
}
CEntity *pPlayerEntity = FindPlayerEntity(-1);
pos = targetBlip.m_vPosition;
pos.z = CWorld::FindGroundZFor3DCoord(pos.x, pos.y, 1000, nullptr, &pPlayerEntity) + 50.f;
if (targetBlip.m_nBlipSprite != RADAR_SPRITE_WAYPOINT)
{
SetHelpMessage("Target blip not found. You need to place it on the map first.", false, false, false);
return;
}
CEntity* pPlayerEntity = FindPlayerEntity(-1);
pos = targetBlip.m_vPosition;
pos.z = CWorld::FindGroundZFor3DCoord(pos.x, pos.y, 1000, nullptr, &pPlayerEntity) + 50.f;
m_Teleport::m_fPos = pos;
m_Teleport::m_nTimer = CTimer::m_snTimeInMilliseconds;
m_Teleport::m_bEnabled = true;
TheCamera.Fade(0, 0);
Command<Commands::FREEZE_CHAR_POSITION_AND_DONT_LOAD_COLLISION>(CPools::GetPedRef(pPlayer), true);
}
m_Teleport::m_fPos = pos;
m_Teleport::m_nTimer = CTimer::m_snTimeInMilliseconds;
m_Teleport::m_bEnabled = true;
TheCamera.Fade(0, 0);
Command<Commands::FREEZE_CHAR_POSITION_AND_DONT_LOAD_COLLISION>(CPools::GetPedRef(pPlayer), true);
}
#endif
#ifdef GTA3
CStreaming::LoadScene(pos);
CStreaming::LoadScene(pos);
#else
CStreaming::LoadScene(&pos);
CStreaming::LoadSceneCollision(&pos);
CStreaming::LoadScene(&pos);
CStreaming::LoadSceneCollision(&pos);
#endif
CStreaming::LoadAllRequestedModels(false);
CStreaming::LoadAllRequestedModels(false);
#ifdef GTASA
if (pVeh && pPlayer->m_nPedFlags.bInVehicle)
{
pVeh->Teleport(pos, false);
if (pVeh && pPlayer->m_nPedFlags.bInVehicle)
{
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)
reinterpret_cast<CBike *>(pVeh)->PlaceOnRoadProperly();
else if (pVeh->m_nVehicleClass != VEHICLE_BOAT)
reinterpret_cast<CAutomobile *>(pVeh)->PlaceOnRoadProperly();
BY_GAME(pVeh->m_nAreaCode, pVeh->m_nInterior) = interior_id;
}
else
{
pPlayer->Teleport(pos, false);
}
BY_GAME(pVeh->m_nAreaCode, pVeh->m_nInterior) = interior_id;
}
else
{
pPlayer->Teleport(pos, false);
}
#else // GTA3 & GTAVC
if (pVeh && pPlayer->m_pVehicle)
{
if (pVeh && pPlayer->m_pVehicle)
{
#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
pVeh->Teleport(pos);
}
else
{
pPlayer->Teleport(pos);
}
pVeh->Teleport(pos);
}
else
{
pPlayer->Teleport(pos);
}
#endif
#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
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
{
int dimension = 0;
CVector pos;
sscanf(loc.c_str(), "%d,%f,%f,%f", &dimension, &pos.x, &pos.y, &pos.z);
TeleportPlayer(false, pos, dimension);
}
catch (...)
{
SetHelpMessage("Invalid location", false, false, false);
}
try
{
int dimension = 0;
CVector pos;
sscanf(loc.c_str(), "%d,%f,%f,%f", &dimension, &pos.x, &pos.y, &pos.z);
TeleportPlayer(false, pos, dimension);
}
catch (...)
{
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")
{
m_tpData.m_pJson->m_Data["Custom"].erase(key);
SetHelpMessage("Location removed", false, false, false);
m_tpData.m_pJson->WriteToDisk();
}
else
{
SetHelpMessage("You can only remove custom location", false, false, false);
}
if (category == "Custom")
{
m_tpData.m_pJson->m_Data["Custom"].erase(key);
SetHelpMessage("Location removed", false, false, false);
m_tpData.m_pJson->WriteToDisk();
}
else
{
SetHelpMessage("You can only remove custom location", false, false, false);
}
}
void Teleport::Draw()
{
if (ImGui::BeginTabBar("Teleport", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll))
{
ImGui::Spacing();
if (ImGui::BeginTabItem("Teleport"))
{
ImGui::Spacing();
if (ImGui::BeginChild("Teleport Child"))
{
ImGui::Columns(2, nullptr, false);
ImGui::Checkbox("Insert coordinates", &m_bInsertCoord);
ImGui::NextColumn();
if (ImGui::BeginTabBar("Teleport", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll))
{
ImGui::Spacing();
if (ImGui::BeginTabItem("Teleport"))
{
ImGui::Spacing();
if (ImGui::BeginChild("Teleport Child"))
{
ImGui::Columns(2, nullptr, false);
ImGui::Checkbox("Insert coordinates", &m_bInsertCoord);
ImGui::NextColumn();
#ifdef GTASA
if (Ui::CheckboxWithHint(
"Quick teleport", &m_bQuickTeleport,
std::string(std::string("Teleport to the location of your radar\ntarget blip using ") +
quickTeleport.GetNameString())
.c_str()))
{
gConfig.SetValue("quick_teleport", m_bQuickTeleport);
}
#endif
ImGui::Columns(1);
ImGui::Spacing();
if (Ui::CheckboxWithHint("Quick teleport", &m_bQuickTeleport,
std::string(std::string("Teleport to the location of your radar\ntarget blip using ")
+ quickTeleport.GetNameString()).c_str()))
{
gConfig.SetValue("quick_teleport", m_bQuickTeleport);
}
#endif
ImGui::Columns(1);
ImGui::Spacing();
if (m_bInsertCoord)
{
CVector pos = FindPlayerPed()->GetPosition();
if (m_bInsertCoord)
{
CVector pos = FindPlayerPed()->GetPosition();
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.z)))
.c_str());
}
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.z))).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)))
{
CVector pos{0, 0, 10};
if (ImGui::Button("Teleport to coord", Ui::GetSize(2)))
{
CVector pos{0, 0, 10};
try
{
sscanf(m_nInputBuffer, "%f,%f,%f", &pos.x, &pos.y, &pos.z);
pos.z += 1.0f;
TeleportPlayer(false, pos);
}
catch (...)
{
SetHelpMessage("Invalid coordinate", false, false, false);
}
}
ImGui::SameLine();
try
{
sscanf(m_nInputBuffer,"%f,%f,%f", &pos.x, &pos.y, &pos.z);
pos.z += 1.0f;
TeleportPlayer(false, pos);
}
catch (...)
{
SetHelpMessage("Invalid coordinate", false, false, false);
}
}
ImGui::SameLine();
#ifdef GTASA
if (ImGui::Button("Teleport to marker", Ui::GetSize(2)))
{
TeleportPlayer(true);
}
if (ImGui::Button("Teleport to marker", Ui::GetSize(2)))
{
TeleportPlayer(true);
}
#else
if (ImGui::Button("Teleport to map center", Ui::GetSize(2)))
{
TeleportPlayer(false, CVector(0, 0, 23));
}
if (ImGui::Button("Teleport to map center", Ui::GetSize(2)))
{
TeleportPlayer(false, CVector(0, 0, 23));
}
#endif
ImGui::EndChild();
}
ImGui::EndTabItem();
}
ImGui::EndChild();
}
ImGui::EndTabItem();
}
if (ImGui::BeginTabItem("Search"))
{
if (ImGui::BeginTabItem("Search"))
{
#ifdef GTASA
FetchRadarSpriteData();
FetchRadarSpriteData();
#endif
ImGui::Spacing();
Ui::DrawJSON(m_tpData, TeleportToLocation, RemoveTeleportEntry);
ImGui::EndTabItem();
}
ImGui::Spacing();
Ui::DrawJSON(m_tpData, TeleportToLocation,RemoveTeleportEntry);
ImGui::EndTabItem();
}
if (ImGui::BeginTabItem("Custom"))
{
ImGui::Spacing();
ImGui::InputTextWithHint("Location", "Groove Street", m_nLocationBuffer, IM_ARRAYSIZE(m_nInputBuffer));
ImGui::InputTextWithHint("Coordinates", "x, y, z", m_nInputBuffer, IM_ARRAYSIZE(m_nInputBuffer));
ImGui::Spacing();
if (ImGui::Button("Add location", Ui::GetSize()))
{
m_tpData.m_pJson->m_Data["Custom"][m_nLocationBuffer] = ("0, " + std::string(m_nInputBuffer));
if (ImGui::BeginTabItem("Custom"))
{
ImGui::Spacing();
ImGui::InputTextWithHint("Location", "Groove Street", m_nLocationBuffer, IM_ARRAYSIZE(m_nInputBuffer));
ImGui::InputTextWithHint("Coordinates", "x, y, z", m_nInputBuffer, IM_ARRAYSIZE(m_nInputBuffer));
ImGui::Spacing();
if (ImGui::Button("Add location", Ui::GetSize()))
{
m_tpData.m_pJson->m_Data["Custom"][m_nLocationBuffer] = ("0, " + std::string(m_nInputBuffer));
#ifdef GTASA
// Clear the Radar coordinates
m_tpData.m_pJson->m_Data.erase("Radar");
m_tpData.m_pJson->m_Data["Radar"] = {};
// Clear the Radar coordinates
m_tpData.m_pJson->m_Data.erase("Radar");
m_tpData.m_pJson->m_Data["Radar"] = {};
#endif
m_tpData.m_pJson->WriteToDisk();
}
ImGui::EndTabItem();
}
ImGui::EndTabBar();
}
m_tpData.m_pJson->WriteToDisk();
}
ImGui::EndTabItem();
}
ImGui::EndTabBar();
}
}

View File

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

View File

@ -1,49 +1,49 @@
#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
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_fPostFx2Blue = (uchar *)0x55F767;
uchar *m_fPostFx2Green = (uchar *)0x55F751;
@ -63,6 +63,49 @@ uchar *m_nHighLightMinIntensity = (uchar *)0x55F7A9;
uchar *m_fCloudAlpha = (uchar *)0x55F793;
#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_nAmbientBlGreen = (uchar *)0x861430;
uchar *m_nAmbientBlBlue = (uchar *)0x811740;
@ -86,4 +129,57 @@ uchar *m_nBottomCloudsBlue = (uchar *)0x7D9630;
uchar *m_nBlurRed = (uchar *)0x94B790;
uchar *m_nBlurGreen = (uchar *)0x8621A0;
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

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
{
public:
struct NamedMemory
{
std::string name;
int addr;
};
struct NamedMemory
{
std::string name;
int addr;
};
struct NamedValue
{
std::string name;
int value;
};
struct NamedValue
{
std::string name;
int value;
};
struct JsonPopUpData
{
std::function<void(std::string &, std::string &, std::string &)> function;
std::string key;
std::string rootKey;
std::string value;
};
struct JsonPopUpData
{
std::function<void(std::string&, std::string&, std::string&)> function;
std::string key;
std::string rootKey;
std::string value;
};
struct ImgPopUpData
{
std::function<void(std::string &)> function;
std::string value;
};
static inline std::string m_HeaderId;
static inline JsonPopUpData jsonPopup;
static inline ImgPopUpData imgPopup;
struct ImgPopUpData
{
std::function<void(std::string&)> function;
std::string value;
};
static inline std::string m_HeaderId;
static inline JsonPopUpData jsonPopup;
static inline ImgPopUpData imgPopup;
Ui() = delete;
Ui(Ui &) = delete;
static void CenterdText(const std::string &text);
static bool ColorButton(int color_id, std::vector<float> &color, ImVec2 size);
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);
Ui() = delete;
Ui(Ui&) = delete;
static void DrawJSON(ResourceStore &data,
std::function<void(std::string &, std::string &, std::string &)> func_left_click,
std::function<void(std::string &, std::string &, std::string &)> func_right_click);
static void DrawImages(ResourceStore &store, std::function<void(std::string &)> on_left_click,
std::function<void(std::string &)> on_right_click,
std::function<std::string(std::string &)> get_name_func,
std::function<bool(std::string &)> verify_func = nullptr,
const char **custom_names = nullptr, size_t length = 0);
static void CenterdText(const std::string& text);
static bool ColorButton(int color_id, std::vector<float>& color, ImVec2 size);
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);
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);
static void DrawJSON(ResourceStore& data,
std::function<void(std::string&, std::string&, std::string&)> func_left_click,
std::function<void(std::string&, std::string&, std::string&)> func_right_click);
static void DrawImages(ResourceStore &store, std::function<void(std::string&)> on_left_click,
std::function<void(std::string&)> on_right_click,
std::function<std::string(std::string&)> get_name_func,
std::function<bool(std::string&)> verify_func = nullptr,
const char** custom_names = nullptr, size_t length = 0);
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
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
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 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,
const char *custom_names[] = nullptr, size_t length = 0);
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 ListBoxCustomNames(const char* label, std::vector<std::string>& all_items, std::string& selected, const char* custom_names[] = nullptr, size_t length = 0);
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 RadioButtonAddress(const char* label, std::vector<NamedMemory>& named_mem);
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 ShowTooltip(const char *text);
static void ColorPickerAddress(const char* label, int base_addr, ImVec4&& default_color);
static void ShowTooltip(const char* text);
};
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))
{
int val = patch::Get<T>(address, false);
if (ImGui::CollapsingHeader(label))
{
int val = patch::Get<T>(address, false);
int items = 3;
int items = 3;
if (min == def)
items = 2;
if (min == def)
items = 2;
ImGui::Columns(items, nullptr, false);
ImGui::Text(("Min: " + std::to_string(min)).c_str());
ImGui::Columns(items, nullptr, false);
ImGui::Text(("Min: " + std::to_string(min)).c_str());
if (items == 3)
{
ImGui::NextColumn();
ImGui::Text(("Def: " + std::to_string(def)).c_str());
}
if (items == 3)
{
ImGui::NextColumn();
ImGui::Text(("Def: " + std::to_string(def)).c_str());
}
ImGui::NextColumn();
ImGui::Text(("Max: " + std::to_string(max)).c_str());
ImGui::Columns(1);
ImGui::NextColumn();
ImGui::Text(("Max: " + std::to_string(max)).c_str());
ImGui::Columns(1);
ImGui::Spacing();
ImGui::Spacing();
if (ImGui::InputInt(("Set value##" + std::string(label)).c_str(), &val))
patch::Set<T>(address, val, false);
if (ImGui::InputInt(("Set value##" + std::string(label)).c_str(), &val))
patch::Set<T>(address, val, false);
ImGui::Spacing();
ImGui::Spacing();
if (val < min)
val = min;
if (val < min)
val = min;
if (val > max)
val = max;
if (val > max)
val = max;
if (ImGui::Button(("Minimum##" + std::string(label)).c_str(), GetSize(items)))
patch::Set<T>(address, min, false);
if (ImGui::Button(("Minimum##" + std::string(label)).c_str(), GetSize(items)))
patch::Set<T>(address, min, false);
if (items == 3)
{
ImGui::SameLine();
if (items == 3)
{
ImGui::SameLine();
if (ImGui::Button(("Default##" + std::string(label)).c_str(), GetSize(3)))
patch::Set<T>(address, def, false);
}
if (ImGui::Button(("Default##" + std::string(label)).c_str(), GetSize(3)))
patch::Set<T>(address, def, false);
}
ImGui::SameLine();
ImGui::SameLine();
if (ImGui::Button(("Maximum##" + std::string(label)).c_str(), GetSize(items)))
patch::Set<T>(address, max, false);
if (ImGui::Button(("Maximum##" + std::string(label)).c_str(), GetSize(items)))
patch::Set<T>(address, max, false);
ImGui::Spacing();
ImGui::Separator();
}
ImGui::Spacing();
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))
{
int val = static_cast<int>(address);
if (ImGui::CollapsingHeader(label))
{
int val = static_cast<int>(address);
ImGui::Columns(3, nullptr, false);
ImGui::Text(("Min: " + std::to_string(min)).c_str());
ImGui::NextColumn();
ImGui::Text(("Def: " + std::to_string(def)).c_str());
ImGui::NextColumn();
ImGui::Text(("Max: " + std::to_string(max)).c_str());
ImGui::Columns(1);
ImGui::Columns(3, nullptr, false);
ImGui::Text(("Min: " + std::to_string(min)).c_str());
ImGui::NextColumn();
ImGui::Text(("Def: " + std::to_string(def)).c_str());
ImGui::NextColumn();
ImGui::Text(("Max: " + std::to_string(max)).c_str());
ImGui::Columns(1);
ImGui::Spacing();
ImGui::Spacing();
if (ImGui::InputInt(("Set value##" + std::string(label)).c_str(), &val))
address = static_cast<float>(val);
if (ImGui::InputInt(("Set value##" + std::string(label)).c_str(), &val))
address = static_cast<float>(val);
ImGui::Spacing();
ImGui::Spacing();
if (ImGui::Button(("Minimum##" + std::string(label)).c_str(), GetSize(3)))
address = static_cast<float>(min);
if (ImGui::Button(("Minimum##" + std::string(label)).c_str(), GetSize(3)))
address = static_cast<float>(min);
ImGui::SameLine();
ImGui::SameLine();
if (ImGui::Button(("Default##" + std::string(label)).c_str(), GetSize(3)))
address = static_cast<float>(def);
if (ImGui::Button(("Default##" + std::string(label)).c_str(), GetSize(3)))
address = static_cast<float>(def);
ImGui::SameLine();
ImGui::SameLine();
if (ImGui::Button(("Maximum##" + std::string(label)).c_str(), GetSize(3)))
address = static_cast<float>(max);
if (ImGui::Button(("Maximum##" + std::string(label)).c_str(), GetSize(3)))
address = static_cast<float>(max);
ImGui::Spacing();
ImGui::Separator();
}
ImGui::Spacing();
ImGui::Separator();
}
}

View File

@ -1,78 +1,76 @@
#include "updater.h"
#include "menuinfo.h"
#include "pch.h"
#include "updater.h"
#include "ui.h"
#include "menuinfo.h"
#include "util.h"
void Updater::CheckForUpdate()
{
const char *link = "https://api.github.com/repos/user-grinch/Cheat-Menu/tags";
char *path = PLUGIN_PATH((char *)"CheatMenu/json/versioninfo.json");
HRESULT res = URLDownloadToFile(NULL, link, path, 0, NULL);
const char* link = "https://api.github.com/repos/user-grinch/Cheat-Menu/tags";
char* path = PLUGIN_PATH((char*)"CheatMenu/json/versioninfo.json");
HRESULT res = URLDownloadToFile(NULL, link, path, 0, NULL);
if (res == E_OUTOFMEMORY || res == INET_E_DOWNLOAD_FAILURE)
{
SetHelpMessage("Failed to check for updates", false, false, false);
return;
}
if (res == E_OUTOFMEMORY || res == INET_E_DOWNLOAD_FAILURE)
{
SetHelpMessage("Failed to check for updates", false, false, false);
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 (verinfo.m_Data.empty())
{
m_LatestVersion = MENU_VERSION_NUMBER;
}
else
{
m_LatestVersion = verinfo.m_Data.items().begin().value()["name"].get<std::string>();
}
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;
}
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()
{
ImGui::Dummy(ImVec2(0, 20));
Ui::CenterdText("A new version of the mod is available.");
Ui::CenterdText(std::string("Current version: ") + MENU_VERSION);
Ui::CenterdText("Latest version: " + Updater::m_LatestVersion);
ImGui::Dummy(ImVec2(0, 10));
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.");
ImGui::Dummy(ImVec2(0, 10));
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.");
ImGui::Dummy(ImVec2(0, 20));
Ui::CenterdText("A new version of the mod is available.");
Ui::CenterdText(std::string("Current version: ") + MENU_VERSION);
Ui::CenterdText("Latest version: " + Updater::m_LatestVersion);
ImGui::Dummy(ImVec2(0, 10));
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.");
ImGui::Dummy(ImVec2(0, 10));
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.");
ImGui::Dummy(ImVec2(0, 5));
if (ImGui::Button("Discord server", ImVec2(Ui::GetSize(3))))
{
ShellExecute(NULL, "open", DISCORD_INVITE, NULL, NULL, SW_SHOWNORMAL);
}
ImGui::Dummy(ImVec2(0, 5));
if (ImGui::Button("Discord server", ImVec2(Ui::GetSize(3))))
{
ShellExecute(NULL, "open", DISCORD_INVITE, NULL, NULL, SW_SHOWNORMAL);
}
ImGui::SameLine();
ImGui::SameLine();
if (ImGui::Button("Download page", Ui::GetSize(3)))
{
ShellExecute(
NULL, "open",
std::string("https://github.com/user-grinch/Cheat-Menu/releases/tag/" + Updater::m_LatestVersion).c_str(),
NULL, NULL, SW_SHOWNORMAL);
}
if (ImGui::Button("Download page", Ui::GetSize(3)))
{
ShellExecute(NULL, "open", 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)))
{
Updater::m_State = UPDATER_IDLE;
}
if (ImGui::Button("Hide page", Ui::GetSize(3)))
{
Updater::m_State = UPDATER_IDLE;
}
}

View File

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

View File

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

View File

@ -1,6 +1,6 @@
#pragma once
#include "pdh.h"
#include "tchar.h"
#include "pdh.h"
static PDH_HQUERY cpuQuery;
static PDH_HCOUNTER cpuTotal;
@ -11,18 +11,19 @@ static HANDLE self;
class Util
{
public:
#ifdef GTASA
static void ClearCharTasksVehCheck(CPed *ped);
static int GetLargestGangInZone();
static RwTexture *LoadTextureFromMemory(char *data, unsigned int size);
static void ClearCharTasksVehCheck(CPed* ped);
static int GetLargestGangInZone();
static RwTexture* LoadTextureFromMemory(char* data, unsigned int size);
#endif
static CPed *GetClosestPed();
static CVehicle *GetClosestVehicle();
static std::string GetLocationName(CVector *pos);
static bool IsOnMission();
static bool IsOnCutscene();
static void RainbowValues(int &r, int &g, int &b, float speed);
static void GetCPUUsageInit();
static double GetCurrentCPUUsage();
static CPed* GetClosestPed();
static CVehicle* GetClosestVehicle();
static std::string GetLocationName(CVector* pos);
static bool IsOnMission();
static bool IsOnCutscene();
static void RainbowValues(int& r, int& g, int& b, float speed);
static void GetCPUUsageInit();
static double GetCurrentCPUUsage();
};

File diff suppressed because it is too large Load Diff

View File

@ -12,119 +12,98 @@ class Vehicle
#endif
{
private:
static inline bool m_bBikeFly;
static inline bool m_bDontFallBike;
static inline bool m_bVehHeavy;
static inline bool m_bVehWatertight;
static inline bool m_bNoDamage;
static inline int m_nDoorMenuButton;
static inline std::string m_DoorNames[6] = {
"Hood", "Boot", "Front left door", "Front right door", "Rear left door", "Rear right door"};
static inline int m_nVehRemoveRadius;
static inline bool m_bLockSpeed;
static inline float m_fLockSpeed;
static inline std::vector<std::vector<float>> m_CarcolsColorData;
struct m_Color
{
static inline bool m_bMatFilter = true;
static inline int m_nRadioButton = 1;
static inline float m_fColorPicker[3]{0, 0, 0};
};
static inline bool m_bBikeFly;
static inline bool m_bDontFallBike;
static inline bool m_bVehHeavy;
static inline bool m_bVehWatertight;
static inline bool m_bNoDamage;
static inline int m_nDoorMenuButton;
static inline std::string m_DoorNames[6] =
{ "Hood", "Boot", "Front left door", "Front right door", "Rear left door", "Rear right door" };
static inline int m_nVehRemoveRadius;
static inline bool m_bLockSpeed;
static inline float m_fLockSpeed;
static inline std::vector<std::vector<float>> m_CarcolsColorData;
struct m_Color
{
static inline bool m_bMatFilter = true;
static inline int m_nRadioButton = 1;
static inline float m_fColorPicker[3]{ 0, 0, 0 };
};
#ifdef GTASA
static inline bool m_bDisableColDetection;
static inline std::map<int, std::string> m_VehicleIDE;
struct m_Neon
{
static inline float m_fColorPicker[3]{0, 0, 0};
static inline bool m_bRainbowEffect;
static inline uint m_nRainbowTimer;
static inline bool m_bApplyOnTraffic;
static inline uint m_bTrafficTimer;
};
static inline ResourceStore m_TuneData{"components", eResourceType::TYPE_IMAGE, ImVec2(100, 80)};
#endif
static inline bool m_bDisableColDetection;
static inline std::map<int, std::string> m_VehicleIDE;
struct m_Neon
{
static inline float m_fColorPicker[3]{ 0, 0, 0 };
static inline bool m_bRainbowEffect;
static inline uint m_nRainbowTimer;
static inline bool m_bApplyOnTraffic;
static inline uint m_bTrafficTimer;
};
static inline ResourceStore m_TuneData { "components", eResourceType::TYPE_IMAGE, ImVec2(100, 80) };
#endif
struct m_Spawner
{
struct m_Spawner
{
#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
static inline ResourceStore m_VehData{"vehicle", eResourceType::TYPE_TEXT};
static inline ResourceStore m_VehData{"vehicle", eResourceType::TYPE_TEXT};
#endif
static inline bool m_bSpawnInside = true;
static inline bool m_bSpawnInAir = true;
static inline char m_nLicenseText[9];
};
struct m_UnlimitedNitro
{
static inline bool m_bEnabled;
static inline bool m_bCompAdded;
};
static inline bool m_bSpawnInside = true;
static inline bool m_bSpawnInAir = true;
static inline char m_nLicenseText[9];
};
struct m_UnlimitedNitro
{
static inline bool m_bEnabled;
static inline bool m_bCompAdded;
};
#ifdef GTASA
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",
"WHEEL_F_NARROW2", "WHEEL_F_NARROW", "WHEEL_F_WIDE", "WHEEL_F_WIDE2",
"WHEEL_R_NARROW2", "WHEEL_R_NARROW", "WHEEL_R_WIDE", "WHEEL_R_WIDE2",
"HYDRAULIC_GEOM", "HYDRAULIC_INST", "HYDRAULIC_NONE", "NOS_INST",
"OFFROAD_ABILITY", "OFFROAD_ABILITY2", "HALOGEN_LIGHTS", "PROC_REARWHEEL_1ST",
"USE_MAXSP_LIMIT", "LOW_RIDER", "STREET_RACER", "SWINGING_CHASSIS",
"Unused 1", "Unused 2", "Unused 3", "Unused 4"};
#ifdef GTASA
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",
"WHEEL_F_NARROW2", "WHEEL_F_NARROW", "WHEEL_F_WIDE", "WHEEL_F_WIDE2", "WHEEL_R_NARROW2", "WHEEL_R_NARROW",
"WHEEL_R_WIDE", "WHEEL_R_WIDE2",
"HYDRAULIC_GEOM", "HYDRAULIC_INST", "HYDRAULIC_NONE", "NOS_INST", "OFFROAD_ABILITY", "OFFROAD_ABILITY2",
"HALOGEN_LIGHTS", "PROC_REARWHEEL_1ST",
"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
{"IS_VAN",
"IS_BUS",
"IS_LOW",
"IS_BIG",
"REVERSE_BONNET",
"HANGING_BOOT",
"TAILGATE_BOOT",
"NOSWING_BOOT",
"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"};
static inline std::vector<std::string>(m_ModelFlagNames) = // 32 flags
{
"IS_VAN", "IS_BUS", "IS_LOW", "IS_BIG", "REVERSE_BONNET", "HANGING_BOOT", "TAILGATE_BOOT", "NOSWING_BOOT",
"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
private:
static void FixVehicle(CVehicle *pVeh);
static void FixVehicle(CVehicle *pVeh);
#ifdef GTASA
static void AddComponent(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 void GenerateHandlingDataFile(int phandling);
static void AddComponent(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 void GenerateHandlingDataFile(int phandling);
#endif
public:
#ifdef GTASA
static void SpawnVehicle(std::string &name);
static void SpawnVehicle(std::string& name);
#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
static std::string GetNameFromModel(int model);
static int GetModelFromName(const char *name);
static void Draw();
Vehicle();
static std::string GetNameFromModel(int model);
static int GetModelFromName(const char* name);
static void Draw();
Vehicle();
};

File diff suppressed because it is too large Load Diff

View File

@ -4,52 +4,48 @@
class Visual
{
private:
static inline bool m_bLockWeather;
static inline bool m_bLockWeather;
#ifdef GTASA
static inline bool m_bInvisibleWater;
static inline bool m_bNoWater;
static inline bool m_bDisableHydrant;
static inline bool m_bInvisibleWater;
static inline bool m_bNoWater;
static inline bool m_bDisableHydrant;
#endif
// Timecyc stuff
static inline int m_nTimecycHour = 8;
static inline std::vector<std::string> m_WeatherNames{"EXTRASUNNY LA", "SUNNY LA",
"EXTRASUNNY SMOG LA", "SUNNY SMOG LA",
"CLOUDY LA", "SUNNY SF",
"EXTRASUNNY SF", "CLOUDY SF",
"RAINY SF", "FOGGY SF",
"SUNNY VEGAS", "EXTRASUNNY VEGAS",
"CLOUDY VEGAS", "EXTRASUNNY COUNTRYSIDE",
"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);
// Timecyc stuff
static inline int m_nTimecycHour = 8;
static inline std::vector<std::string> m_WeatherNames
{
"EXTRASUNNY LA", "SUNNY LA", "EXTRASUNNY SMOG LA", "SUNNY SMOG LA", "CLOUDY LA", "SUNNY SF", "EXTRASUNNY SF",
"CLOUDY SF", "RAINY SF", "FOGGY SF",
"SUNNY VEGAS", "EXTRASUNNY VEGAS", "CLOUDY VEGAS", "EXTRASUNNY COUNTRYSIDE", "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);
public:
Visual();
static void Draw();
Visual();
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
// Compatable with 24h TimeCyc
T *arr = static_cast<T *>(patch::GetPointer(int(ptr)));
// Compatable with 24h TimeCyc
T* arr = static_cast<T*>(patch::GetPointer(int(ptr)));
#else // GTA3 & GTAVC
T *arr = static_cast<T *>(ptr);
T* arr = static_cast<T*>(ptr);
#endif
int a = arr[val];
int a = arr[val];
if (ImGui::SliderInt(label, &a, min, max))
arr[val] = static_cast<T>(a);
if (ImGui::SliderInt(label, &a, min, max))
arr[val] = static_cast<T>(a);
}

View File

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

View File

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

View File

@ -5,51 +5,52 @@ class Weapon
{
public:
#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_bRapidFire;
static inline bool m_bDualWeild;
static inline bool m_bMoveAim;
static inline bool m_bMoveFire;
static inline int m_nSelectedGang;
static inline bool m_bAutoAim;
static inline bool m_bRapidFire;
static inline bool m_bDualWeild;
static inline bool m_bMoveAim;
static inline bool m_bMoveFire;
static inline int m_nSelectedGang;
#else // GTA3 & GTAVC
static inline ResourceStore m_WeaponData{"weapon", eResourceType::TYPE_TEXT};
static inline bool m_bInfiniteAmmo;
static inline ResourceStore m_WeaponData{ "weapon", eResourceType::TYPE_TEXT };
static inline bool m_bInfiniteAmmo;
#endif
static inline bool m_bFastReload;
static inline bool m_bHugeDamage;
static inline bool m_bLongRange;
static inline int m_nAmmoCount = 99999;
static inline uchar m_nCurrentWeaponSlot = -1;
static inline int m_nSelectedWeapon;
static inline bool m_bFastReload;
static inline bool m_bHugeDamage;
static inline bool m_bLongRange;
static inline int m_nAmmoCount = 99999;
static inline uchar m_nCurrentWeaponSlot = -1;
static inline int m_nSelectedWeapon;
#ifdef GTASA
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_UNARMED, WEAPON_UNARMED}, // Vagos
{WEAPON_UNARMED, WEAPON_UNARMED, WEAPON_UNARMED}, // SF Rifa
{WEAPON_PISTOL, WEAPON_MICRO_UZI, WEAPON_UNARMED}, // Da Nang Boys
{WEAPON_DESERT_EAGLE, WEAPON_UNARMED, WEAPON_UNARMED}, // Mafia
{WEAPON_PISTOL, WEAPON_AK47, WEAPON_UNARMED}, // Triads
{WEAPON_PISTOL, WEAPON_MICRO_UZI, WEAPON_UNARMED}, // VLA
{WEAPON_UNARMED, WEAPON_UNARMED, WEAPON_UNARMED}, // Gang 9
{WEAPON_UNARMED, WEAPON_UNARMED, WEAPON_UNARMED}, // Gang 10
};
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_UNARMED, WEAPON_UNARMED}, // Vagos
{WEAPON_UNARMED, WEAPON_UNARMED, WEAPON_UNARMED}, // SF Rifa
{WEAPON_PISTOL, WEAPON_MICRO_UZI, WEAPON_UNARMED}, // Da Nang Boys
{WEAPON_DESERT_EAGLE, WEAPON_UNARMED, WEAPON_UNARMED}, // Mafia
{WEAPON_PISTOL, WEAPON_AK47, WEAPON_UNARMED}, // Triads
{WEAPON_PISTOL, WEAPON_MICRO_UZI, WEAPON_UNARMED}, // VLA
{WEAPON_UNARMED, WEAPON_UNARMED, WEAPON_UNARMED}, // Gang 9
{WEAPON_UNARMED, WEAPON_UNARMED, WEAPON_UNARMED}, // Gang 10
};
#endif
Weapon();
Weapon();
static void Draw();
static void Draw();
#ifdef GTASA
static void GiveWeaponToPlayer(std::string &weapon_type);
static void GiveWeaponToPlayer(std::string& weapon_type);
#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
#ifdef GTASA
static void SetGangWeapon(std::string &weapon_type);
static void SetGangWeapon(std::string& weapon_type);
#endif
};

View File

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