diff --git a/resource/CheatMenuSA/misc.txd b/resource/CheatMenuSA/misc.txd index 5e508f5..e056ebd 100644 Binary files a/resource/CheatMenuSA/misc.txd and b/resource/CheatMenuSA/misc.txd differ diff --git a/src/animation.cpp b/src/animation.cpp index fddcafe..0f35348 100644 --- a/src/animation.cpp +++ b/src/animation.cpp @@ -9,9 +9,7 @@ #include #include "eAnimations.h" #include - #elif GTAVC - #include "../depend/kiero/minhook/MinHook.h" #include #include @@ -22,9 +20,18 @@ #ifdef GTASA #include "overlay.h" +void Cutscene::Init() +{ + static CdeclEvent , PRIORITY_AFTER, ArgPickNone, void()> skipCutsceneEvent; + skipCutsceneEvent += []() + { + Stop(); + }; +} + void Cutscene::Play(std::string& rootKey, std::string& cutsceneId, std::string& interior) { - if (Util::IsOnCutscene()) + if (CCutsceneMgr::ms_running) { Util::SetMessage(TEXT("Animation.CutsceneRunning")); return; @@ -33,11 +40,10 @@ void Cutscene::Play(std::string& rootKey, std::string& cutsceneId, std::string& CPlayerPed* pPlayer = FindPlayerPed(); if (pPlayer) { - m_SceneName = cutsceneId; m_pLastVeh = pPlayer->m_nPedFlags.bInVehicle ? pPlayer->m_pVehicle : nullptr; m_nVehSeat = -1; - if (m_pLastVeh->m_pDriver != pPlayer) + if (m_pLastVeh && m_pLastVeh->m_pDriver != pPlayer) { for (size_t i = 0; i != 8; ++i) { @@ -48,10 +54,44 @@ void Cutscene::Play(std::string& rootKey, std::string& cutsceneId, std::string& } } } - Command(cutsceneId.c_str()); + CCutsceneMgr::LoadCutsceneData(cutsceneId.c_str()); + CCutsceneMgr::Update(); + m_nInterior = pPlayer->m_nAreaCode; pPlayer->m_nAreaCode = std::stoi(interior); Command(pPlayer->m_nAreaCode); + Cutscene::m_bRunning = true; + CCutsceneMgr::StartCutscene(); + } +} + +void Cutscene::Stop() +{ + if (Cutscene::m_bRunning) + { + CPlayerPed *pPlayer = FindPlayerPed(); + int hPlayer = CPools::GetPedRef(pPlayer); + + CCutsceneMgr::DeleteCutsceneData(); + Cutscene::m_bRunning = false; + pPlayer->m_nAreaCode = Cutscene::m_nInterior; + Cutscene::m_nInterior = 0; + Command(pPlayer->m_nAreaCode); + + // handle vehicle + if (Cutscene::m_pLastVeh) + { + int hVeh = CPools::GetVehicleRef(Cutscene::m_pLastVeh); + if (Cutscene::m_nVehSeat == -1) + { + Command(hPlayer, hVeh); + } + else + { + Command(hPlayer, hVeh, Cutscene::m_nVehSeat); + } + } + TheCamera.Fade(0, 1); } } @@ -64,10 +104,25 @@ void Particle::Play(std::string& cat, std::string& name, std::string& particle) int handle; Command(particle.c_str(), pos.x, pos.y, pos.z, 1, &handle); Command(handle); - m_nParticleList.push_back(handle); + m_nList.push_back(handle); } } +void Particle::RemoveAll() +{ + for (int& p : Particle::m_nList) + { + Command(p); + } + Particle::m_nList.clear(); +} + +void Particle::RemoveLatest() +{ + Command(Particle::m_nList.back()); // stop if anything is running + Particle::m_nList.pop_back(); +} + #elif GTAVC // Thanks to codenulls(https://github.com/codenulls/) @@ -178,14 +233,14 @@ void _PlayAnim(RpClump* pClump, int animGroup, int animID, float blend, bool loo void Animation::Play(std::string& cat, std::string& anim, std::string& ifp) { - CPed *pPed = m_PedAnim ? m_pTarget : FindPlayerPed(); + CPed *pPed = m_bPedAnim ? m_pTarget : FindPlayerPed(); if (!pPed) { return; } #ifdef GTASA - int hped = CPools::GetPedRef(pPed); + int hPed = CPools::GetPedRef(pPed); if (ifp != "PED") { @@ -193,14 +248,14 @@ void Animation::Play(std::string& cat, std::string& anim, std::string& ifp) Command(); } - Command(hped); + Command(hPed); if (m_bSecondary) { - Command(hped, anim.c_str(), ifp.c_str(), 4.0, m_Loop, 0, 0, 0, -1); + Command(hPed, anim.c_str(), ifp.c_str(), 4.0, m_Loop, 0, 0, 0, -1); } else { - Command(hped, anim.c_str(), ifp.c_str(), 4.0, m_Loop, 0, 0, 0, -1); + Command(hPed, anim.c_str(), ifp.c_str(), 4.0, m_Loop, 0, 0, 0, -1); } if (ifp != "PED") @@ -218,32 +273,10 @@ void Animation::Play(std::string& cat, std::string& anim, std::string& ifp) void Animation::Init() { #ifdef GTASA + Cutscene::Init(); Events::processScriptsEvent += [] { CPlayerPed* pPlayer = FindPlayerPed(); - if (Cutscene::m_bRunning) - { - if (Command()) - { - if (!pPlayer) - { - return; - } - - pPlayer->m_nAreaCode = Cutscene::m_nInterior; - Command(pPlayer->m_nAreaCode); - Cutscene::m_nInterior = 0; - TheCamera.Fade(0, 1); - } - } - else - { - if (Cutscene::m_SceneName != "" && Command()) - { - Command(); - Cutscene::m_bRunning = true; - } - } if (pPlayer && pPlayer->m_pPlayerTargettedPed) { @@ -277,8 +310,6 @@ void Animation::ShowPage() CPlayerPed* pPlayer = FindPlayerPed(); int hPlayer = CPools::GetPedRef(pPlayer); - ImGui::Spacing(); - if (ImGui::BeginTabItem(TEXT("Animation.AnimationTab"))) { ImGui::Spacing(); @@ -300,12 +331,12 @@ void Animation::ShowPage() Widget::Checkbox(TEXT("Animation.SecondaryCheckbox"), &m_bSecondary, TEXT("Animation.SecondaryCheckboxText")); ImGui::NextColumn(); #ifdef GTASA - Widget::Checkbox(TEXT("Animation.PedAnim"), &m_PedAnim, TEXT("Animation.PedAnimText")); + Widget::Checkbox(TEXT("Animation.PedAnim"), &m_bPedAnim, TEXT("Animation.PedAnimText")); #endif ImGui::Columns(1); ImGui::Spacing(); - if (m_PedAnim && !m_pTarget) + if (m_bPedAnim && !m_pTarget) { ImGui::TextWrapped(TEXT("Animation.NoTarget")); } @@ -343,15 +374,14 @@ void Animation::ShowPage() ImGui::Spacing(); Widget::Checkbox(TEXT("Menu.ShowPedTasks"), &Overlay::m_bPedTasks); ImGui::Spacing(); - CPlayerPed* player = FindPlayerPed(); - if (player) + if (pPlayer) { ImGui::BeginChild("TasksList"); ImGui::Text(TEXT("Animation.PrimaryTasks")); ImGui::Separator(); for (size_t i = 0; i != TASK_PRIMARY_MAX; ++i) { - CTask *pTask = player->m_pIntelligence->m_TaskMgr.m_aPrimaryTasks[i]; + CTask *pTask = pPlayer->m_pIntelligence->m_TaskMgr.m_aPrimaryTasks[i]; if (pTask) { const char *name = taskNames[pTask->GetId()]; @@ -369,7 +399,7 @@ void Animation::ShowPage() ImGui::Separator(); for (size_t i = 0; i != TASK_SECONDARY_MAX; ++i) { - CTask *pTask = player->m_pIntelligence->m_TaskMgr.m_aSecondaryTasks[i]; + CTask *pTask = pPlayer->m_pIntelligence->m_TaskMgr.m_aSecondaryTasks[i]; if (pTask) { const char *name = taskNames[pTask->GetId()]; @@ -389,28 +419,7 @@ void Animation::ShowPage() ImGui::Spacing(); if (ImGui::Button(TEXT("Animation.StopCutscene"), Widget::CalcSize())) { - if (Cutscene::m_bRunning) - { - CPlayerPed* player = FindPlayerPed(); - int hPlayer = CPools::GetPedRef(player); - int hVeh = CPools::GetVehicleRef(Cutscene::m_pLastVeh); - Command(); - Cutscene::m_bRunning = false; - Cutscene::m_SceneName = ""; - player->m_nAreaCode = Cutscene::m_nInterior; - Command(player->m_nAreaCode); - - if (Cutscene::m_nVehSeat == -1) - { - Command(hPlayer, hVeh); - } - else - { - Command(hPlayer, hVeh, Cutscene::m_nVehSeat); - } - Cutscene::m_nInterior = 0; - TheCamera.Fade(0, 1); - } + Cutscene::Stop(); } ImGui::Spacing(); @@ -427,17 +436,12 @@ void Animation::ShowPage() ImGui::Spacing(); if (ImGui::Button(TEXT("Animation.RemoveAll"), Widget::CalcSize(2))) { - for (int& p : Particle::m_nParticleList) - { - Command(p); - } - Particle::m_nParticleList.clear(); + Particle::RemoveAll(); } ImGui::SameLine(); if (ImGui::Button(TEXT("Animation.RemoveLatest"), Widget::CalcSize(2))) { - Command(Particle::m_nParticleList.back()); // stop if anything is running - Particle::m_nParticleList.pop_back(); + Particle::RemoveLatest(); } ImGui::Spacing(); if (Widget::CheckboxBits(TEXT("Animation.InvisiblePlayer"), pPlayer->m_nPedFlags.bDontRender)) diff --git a/src/animation.h b/src/animation.h index e10ee6d..fe3961a 100644 --- a/src/animation.h +++ b/src/animation.h @@ -2,48 +2,85 @@ #include "pch.h" #ifdef GTASA +/* + Cutscene Player Class for SA + Plays mission cutscenes +*/ class Cutscene { -public: - static inline ResourceStore m_Data{ "cutscenes", eResourceType::TYPE_TEXT }; - static inline std::string m_SceneName; - static inline int m_nInterior; // player interior backup - static inline bool m_bRunning; - static inline CVehicle *m_pLastVeh; - static inline int m_nVehSeat; +private: + static inline bool m_bRunning; // is cutscene currently running - static void Play(std::string& rootKey, std::string& cutsceneId, std::string& interior); + // backup data + static inline int m_nInterior; // interior player was in + static inline CVehicle *m_pLastVeh; // vehicle player was in + static inline int m_nVehSeat; // seat id of player vehicle + +public: + static inline ResourceStore m_Data{ "cutscenes", eResourceType::TYPE_TEXT }; // names + + Cutscene() = delete; + Cutscene(const Cutscene&) = delete; + + // Initializes hooks, vars etc. + static void Init(); + + // Plays a cutscene + static void Play(std::string& cat, std::string& key, std::string& val); + + // Stops a running cutscene + static void Stop(); }; +/* + Particle Player Class for SA + Spawns particles in the world +*/ class Particle { -public: - static inline ResourceStore m_Data{ "particles", eResourceType::TYPE_TEXT }; - static inline std::vector m_nParticleList; +private: + static inline std::vector m_nList; - static void Play(std::string& rootKey, std::string& particle, std::string& dummy); +public: + static inline ResourceStore m_Data{ "particles", eResourceType::TYPE_TEXT }; // names + + Particle() = delete; + Particle(const Particle&) = delete; + + // Plays a particle + static void Play(std::string& cat, std::string& key, std::string& val); + + // Removes all spawned particles + static void RemoveAll(); + + // Removes the most recent spawned particle + static void RemoveLatest(); }; #endif +/* + Animation Player Class + Plays animatins on player & peds +*/ class Animation { private: static inline ResourceStore m_AnimData{ "animations", eResourceType::TYPE_TEXT }; - static inline bool m_Loop; // loop animation - static inline bool m_bSecondary; // play animation as secondary - static inline bool m_PedAnim; - static inline CPed *m_pTarget = nullptr; + static inline bool m_Loop; // keep playing animation in a loop + static inline bool m_bSecondary; // play animation alongside another + static inline bool m_bPedAnim; // play the animation on a target ped + static inline CPed *m_pTarget = nullptr; // target ped pointer - static void Play(std::string& rootKey, std::string& anim, std::string& ifp); - -#ifdef GTASA - static void DrawPedTasks(); -#endif + // Plays a particular animation + static void Play(std::string& cat, std::string& key, std::string& val); public: Animation() = delete; Animation(const Animation&) = delete; + // Initializes hooks & stuff static void Init(); + + // Displays animation menu page static void ShowPage(); }; \ No newline at end of file diff --git a/src/defines.h b/src/defines.h index 7c4f259..2b41d94 100644 --- a/src/defines.h +++ b/src/defines.h @@ -9,7 +9,7 @@ #define MENU_NAME "Cheat Menu" #define MENU_VERSION_NUMBER "3.3" #define MENU_VERSION MENU_VERSION_NUMBER"-beta" -#define BUILD_NUMBER "20220721" +#define BUILD_NUMBER "20220805" #define MENU_TITLE MENU_NAME " v" MENU_VERSION #ifdef GTASA diff --git a/src/overlay.cpp b/src/overlay.cpp index 53545f8..bfe4029 100644 --- a/src/overlay.cpp +++ b/src/overlay.cpp @@ -11,8 +11,6 @@ void Overlay::Init() { - // TODO: use structs - // Load config data m_bCoord = gConfig.Get("Overlay.ShowCoordinates", false); m_bCpuUsage = gConfig.Get("Overlay.ShowCPUUsage", false); m_bFPS = gConfig.Get("Overlay.ShowFPS", false);