diff --git a/resource/common/locale/English.toml b/resource/common/locale/English.toml index 9c21e82..d8bb28e 100644 --- a/resource/common/locale/English.toml +++ b/resource/common/locale/English.toml @@ -186,7 +186,7 @@ OpenCMDUsing = "Open or close command window using %s" OpenMenuKey = "Open/ close cheat menu" Overlay = "Overlay" Patreon = "Patreon" -PatreonText = "If you like my work, consider supporting :)" +PatreonText = "If you like my work, consider donating :)" Position = "Position" Remove = "Remove" Favourites = "Add to favourites" diff --git a/src/custom/topdowncam_sa.cpp b/src/custom/topdowncam_sa.cpp new file mode 100644 index 0000000..5203a86 --- /dev/null +++ b/src/custom/topdowncam_sa.cpp @@ -0,0 +1,79 @@ +#include "pch.h" +#include "topdowncam_sa.h" + +TopDownCamera& TopDownCam = *TopDownCamera::Get(); + +TopDownCamera::TopDownCamera() +{ + Events::processScriptsEvent += [this]() + { + if (m_bEnabled) + { + Process(); + } + }; +} + +/* + Taken from gta chaos mod by Lordmau5 + https://github.com/gta-chaos-mod/Trilogy-ASI-Script +*/ +void TopDownCamera::Process() +{ + CPlayerPed *player = FindPlayerPed(); + CVector pos = player->GetPosition (); + float curOffset = m_nZoom; + + // drunk effect causes issues + Command (0, 0); + + CVehicle *vehicle = FindPlayerVehicle(-1, false); + + // TODO: implement smooth transition + if (vehicle) + { + float speed = vehicle->m_vecMoveSpeed.Magnitude(); + if (speed > 1.2f) + { + speed = 1.2f; + } + if (speed * 40.0f > 40.0f) + { + speed = 40.0f; + } + + if (speed < 0.0f) + { + speed = 0.0f; + } + curOffset += speed; + } + + CVector playerOffset = CVector (pos.x, pos.y, pos.z + 2.0f); + CVector cameraPos = CVector (playerOffset.x, playerOffset.y, playerOffset.z + curOffset); + + CColPoint outColPoint; + CEntity * outEntity; + + // TODO: Which variable? X, Y or Z for the look direction? + + if (CWorld::ProcessLineOfSight (playerOffset, cameraPos, outColPoint, + outEntity, true, true, true, true, true, + true, true, true)) + { + Command ( + outColPoint.m_vecPoint.x, outColPoint.m_vecPoint.y, + outColPoint.m_vecPoint.z, 0.0f, 0.0f, 0.0f); + } + else + { + Command ( + cameraPos.x, cameraPos.y, cameraPos.z, 0.0f, 0.0f, 0.0f); + } + + Command (pos.x, pos.y, + pos.z, 2); + + TheCamera.m_fGenerationDistMultiplier = 10.0f; + TheCamera.m_fLODDistMultiplier = 10.0f; +} diff --git a/src/custom/topdowncam_sa.h b/src/custom/topdowncam_sa.h new file mode 100644 index 0000000..5b4fb41 --- /dev/null +++ b/src/custom/topdowncam_sa.h @@ -0,0 +1,23 @@ +#pragma once +#include "interface/icheat.hpp" + +/* + TopDown for SA + Activates/Disactivates cheats randomly +*/ +class TopDownCamera : public ICheat +{ +private: + + friend ICheat; + TopDownCamera(); + TopDownCamera(const TopDownCamera&); + +public: + int m_nZoom = 40; + + // Process cheat each frame + void Process(); +}; + +extern TopDownCamera& TopDownCam; \ No newline at end of file diff --git a/src/pages/game.cpp b/src/pages/game.cpp index 2722c39..9018c34 100644 --- a/src/pages/game.cpp +++ b/src/pages/game.cpp @@ -5,14 +5,13 @@ #include "utils/util.h" #ifdef GTASA -#include "custom/freecam_sa.h" -#include "custom/randomcheats_sa.h" #include #include #include -#endif +#include "custom/freecam_sa.h" +#include "custom/randomcheats_sa.h" +#include "custom/topdowncam_sa.h" -#ifdef GTASA static bool bSaveGameFlag = false; #endif @@ -490,6 +489,19 @@ void Game::ShowPage() {TEXT("Game.Beach"), 0x969159}, {TEXT("Game.Country"), 0x96917D}, {TEXT("Game.FunHouse"), 0x969176}, {TEXT("Game.Ninja"), 0x96915C} }; Widget::EditRadioBtnAddr(TEXT("Game.Themes"), themes); + if (ImGui::CollapsingHeader(TEXT("Player.TopDownCamera"))) + { + bool state = TopDownCam.GetState(); + if (ImGui::Checkbox(TEXT("Window.Enabled"), &state)) + { + Command(); + TopDownCam.Toggle(); + } + ImGui::Spacing(); + ImGui::SliderInt(TEXT("Player.CameraZoom"), &TopDownCam.m_nZoom, 20, 60); + ImGui::Spacing(); + ImGui::Separator(); + } #endif if (ImGui::CollapsingHeader(TEXT("Game.Weather"))) { diff --git a/src/pages/player.cpp b/src/pages/player.cpp index a0e0684..1e884dc 100644 --- a/src/pages/player.cpp +++ b/src/pages/player.cpp @@ -7,6 +7,7 @@ #ifdef GTASA #include "ped.h" +#include "custom/topdowncam_sa.h" static inline const char* clothNameList[18] = { @@ -25,71 +26,6 @@ static inline void PlayerModelBrokenFix() Call<0x5A81E0>(0, pPlayer->m_pPlayerData->m_pPedClothesDesc, 0xBC1C78, false); } } - -/* - Taken from gta chaos mod by Lordmau5 - https://github.com/gta-chaos-mod/Trilogy-ASI-Script -*/ -void Player::TopDownCamera::Process() -{ - CPlayerPed *player = FindPlayerPed (); - CVector pos = player->GetPosition (); - float curOffset = m_fOffset; - - // drunk effect causes issues - Command (0, 0); - - CVehicle *vehicle = FindPlayerVehicle(-1, false); - - // TODO: implement smooth transition - if (vehicle) - { - float speed = vehicle->m_vecMoveSpeed.Magnitude(); - if (speed > 1.2f) - { - speed = 1.2f; - } - if (speed * 40.0f > 40.0f) - { - speed = 40.0f; - } - - if (speed < 0.0f) - { - speed = 0.0f; - } - curOffset += speed; - } - - CVector playerOffset = CVector (pos.x, pos.y, pos.z + 2.0f); - CVector cameraPos - = CVector (playerOffset.x, playerOffset.y, playerOffset.z + curOffset); - - CColPoint outColPoint; - CEntity * outEntity; - - // TODO: Which variable? X, Y or Z for the look direction? - - if (CWorld::ProcessLineOfSight (playerOffset, cameraPos, outColPoint, - outEntity, true, true, true, true, true, - true, true, true)) - { - Command ( - outColPoint.m_vecPoint.x, outColPoint.m_vecPoint.y, - outColPoint.m_vecPoint.z, 0.0f, 0.0f, 0.0f); - } - else - { - Command ( - cameraPos.x, cameraPos.y, cameraPos.z, 0.0f, 0.0f, 0.0f); - } - - Command (pos.x, pos.y, - pos.z, 2); - - TheCamera.m_fGenerationDistMultiplier = 10.0f; - TheCamera.m_fLODDistMultiplier = 10.0f; -} #endif void Player::Init() @@ -232,16 +168,11 @@ void Player::Init() } #ifdef GTASA - if (m_bDrunkEffect && !TopDownCamera::m_bEnabled) + if (m_bDrunkEffect && !TopDownCam.GetState()) { Command (0, 100); } - if (TopDownCamera::m_bEnabled) - { - TopDownCamera::Process(); - } - if (m_bAimSkinChanger && aimSkinChanger.Pressed()) { CPed* targetPed = player->m_pPlayerTargettedPed; @@ -436,7 +367,7 @@ void Player::ShowPage() #ifdef GTASA Widget::CheckboxAddr(TEXT("Player.BountyYourself"), 0x96913F); - ImGui::BeginDisabled(TopDownCamera::m_bEnabled); + ImGui::BeginDisabled(TopDownCam.GetState()); if (Widget::Checkbox(TEXT("Player.DrunkEffect"), &m_bDrunkEffect)) { if (!m_bDrunkEffect) @@ -782,17 +713,6 @@ void Player::ShowPage() Widget::EditStat(TEXT("Player.Muscle"), STAT_MUSCLE); Widget::EditStat(TEXT("Player.Respect"), STAT_RESPECT); Widget::EditStat(TEXT("Player.Stamina"), STAT_STAMINA); - if (ImGui::CollapsingHeader(TEXT("Player.TopDownCamera"))) - { - if (ImGui::Checkbox(TEXT("Window.Enabled"), &TopDownCamera::m_bEnabled)) - { - Command(); - } - ImGui::Spacing(); - ImGui::SliderFloat(TEXT("Player.CameraZoom"), &TopDownCamera::m_fOffset, 20.0f, 60.0f); - ImGui::Spacing(); - ImGui::Separator(); - } #endif if (ImGui::CollapsingHeader(TEXT("Player.WantedLevel"))) { diff --git a/src/pages/player.h b/src/pages/player.h index 170bdc1..acbd6e6 100644 --- a/src/pages/player.h +++ b/src/pages/player.h @@ -30,15 +30,6 @@ private: static inline std::vector m_List; }; - struct TopDownCamera - { - public: - static inline bool m_bEnabled = false; - static inline float m_fOffset = 40.0f; - - static void Process(); - }; - static void ChangePlayerModel(std::string& model); static void ChangePlayerCloth(std::string& model); #else diff --git a/src/pages/visual.cpp b/src/pages/visual.cpp index 8d7b503..aa0d540 100644 --- a/src/pages/visual.cpp +++ b/src/pages/visual.cpp @@ -920,14 +920,15 @@ void Visual::ShowPage() #elif GTAVC static float discLeft = *(float*)0x55A956; static float discRight = *(float*)*(int*)0x55A9AE; + static float &posX = *(float*)0x68FD2C; patch::SetPointer(0x55A9AE, &discRight); patch::SetPointer(0x55AAE7, &discRight); patch::SetFloat(0x55A956, discLeft); patch::SetFloat(0x55AA94, discLeft); - float prevVal = *(float*)0x68FD2C; - Widget::EditAddr(TEXT("Visual.RadarPosX"), 0x68FD2C, -999, 40, 999); - float diff = *(float*)0x68FD2C - prevVal; + float prevVal = posX; + Widget::EditAddr(TEXT("Visual.RadarPosX"), (uint)&posX, -999, 40, 999); + float diff = posX - prevVal; discLeft += diff; discRight += diff;