Improve Freecam, increase special ped type from 1 -> 10

This commit is contained in:
Grinch_ 2021-10-09 17:36:25 +06:00
parent 8cc4a0513c
commit be57a02a2e
6 changed files with 51 additions and 34 deletions

View File

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

View File

@ -212,15 +212,21 @@ void SetPlayerMission(std::string& rootkey, std::string& name, std::string& id)
player->SetWantedLevel(0); player->SetWantedLevel(0);
Command<Commands::LOAD_AND_LAUNCH_MISSION_INTERNAL>(std::stoi(id)); Command<Commands::LOAD_AND_LAUNCH_MISSION_INTERNAL>(std::stoi(id));
} }
else SetHelpMessage("Can't start mission now", false, false, false); else
{
SetHelpMessage("Can't start mission now", false, false, false);
}
} }
#ifdef GTASA #ifdef GTASA
void Game::FreeCam() void Game::FreeCam()
{ {
int deltaSpeed = m_Freecam::m_fSpeed * (CTimer::m_snTimeInMillisecondsNonClipped - int delta = (CTimer::m_snTimeInMillisecondsNonClipped -
CTimer::m_snPreviousTimeInMillisecondsNonClipped); CTimer::m_snPreviousTimeInMillisecondsNonClipped);
int ratio = 1 / (1 + (delta * m_Freecam::m_nMul));
int speed = m_Freecam::m_nMul + m_Freecam::m_nMul * ratio * delta;
if (!m_Freecam::m_bInitDone) if (!m_Freecam::m_bInitDone)
{ {
CPlayerPed* player = FindPlayerPed(-1); CPlayerPed* player = FindPlayerPed(-1);
@ -285,48 +291,48 @@ void Game::FreeCam()
if (KeyPressed(VK_RCONTROL)) if (KeyPressed(VK_RCONTROL))
{ {
deltaSpeed /= 2; speed /= 2;
} }
if (KeyPressed(VK_RSHIFT)) if (KeyPressed(VK_RSHIFT))
{ {
deltaSpeed *= 2; speed *= 2;
} }
if (KeyPressed(VK_KEY_I) || KeyPressed(VK_KEY_K)) if (KeyPressed(VK_KEY_I) || KeyPressed(VK_KEY_K))
{ {
if (KeyPressed(VK_KEY_K)) if (KeyPressed(VK_KEY_K))
{ {
deltaSpeed *= -1; speed *= -1;
} }
float angle; float angle;
Command<Commands::GET_CHAR_HEADING>(m_Freecam::m_nPed, &angle); Command<Commands::GET_CHAR_HEADING>(m_Freecam::m_nPed, &angle);
pos.x += deltaSpeed * cos(angle * 3.14159f / 180.0f); pos.x += speed * cos(angle * 3.14159f / 180.0f);
pos.y += deltaSpeed * sin(angle * 3.14159f / 180.0f); pos.y += speed * sin(angle * 3.14159f / 180.0f);
pos.z += deltaSpeed * 2 * sin(m_Freecam::m_fTotalMouse.y / 3 * 3.14159f / 180.0f); pos.z += speed * 2 * sin(m_Freecam::m_fTotalMouse.y / 3 * 3.14159f / 180.0f);
} }
if (KeyPressed(VK_KEY_J) || KeyPressed(VK_KEY_L)) if (KeyPressed(VK_KEY_J) || KeyPressed(VK_KEY_L))
{ {
if (KeyPressed(VK_KEY_J)) if (KeyPressed(VK_KEY_J))
{ {
deltaSpeed *= -1; speed *= -1;
} }
float angle; float angle;
Command<Commands::GET_CHAR_HEADING>(m_Freecam::m_nPed, &angle); Command<Commands::GET_CHAR_HEADING>(m_Freecam::m_nPed, &angle);
angle -= 90; angle -= 90;
pos.x += deltaSpeed * cos(angle * 3.14159f / 180.0f); pos.x += speed * cos(angle * 3.14159f / 180.0f);
pos.y += deltaSpeed * sin(angle * 3.14159f / 180.0f); pos.y += speed * sin(angle * 3.14159f / 180.0f);
} }
if (CPad::NewMouseControllerState.wheelUp) if (CPad::NewMouseControllerState.wheelUp)
{ {
if (m_Freecam::m_fFOV > 10.0f) if (m_Freecam::m_fFOV > 10.0f)
{ {
m_Freecam::m_fFOV -= 2.0f * deltaSpeed; m_Freecam::m_fFOV -= 2.0f * speed;
} }
TheCamera.LerpFOV(TheCamera.FindCamFOV(), m_Freecam::m_fFOV, 250, true); TheCamera.LerpFOV(TheCamera.FindCamFOV(), m_Freecam::m_fFOV, 250, true);
@ -337,7 +343,7 @@ void Game::FreeCam()
{ {
if (m_Freecam::m_fFOV < 115.0f) if (m_Freecam::m_fFOV < 115.0f)
{ {
m_Freecam::m_fFOV += 2.0f * deltaSpeed; m_Freecam::m_fFOV += 2.0f * speed;
} }
TheCamera.LerpFOV(TheCamera.FindCamFOV(), m_Freecam::m_fFOV, 250, true); TheCamera.LerpFOV(TheCamera.FindCamFOV(), m_Freecam::m_fFOV, 250, true);
@ -543,7 +549,7 @@ Lowers armour, health, stamina etc."))
ImGui::Spacing(); ImGui::Spacing();
ImGui::SliderFloat("Field of view", &m_Freecam::m_fFOV, 5.0f, 120.0f); ImGui::SliderFloat("Field of view", &m_Freecam::m_fFOV, 5.0f, 120.0f);
ImGui::SliderFloat("Movement Speed", &m_Freecam::m_fSpeed, 0.0f, 0.5f); ImGui::SliderInt("Movement Speed", &m_Freecam::m_nMul, 1, 10);
ImGui::Spacing(); ImGui::Spacing();
ImGui::TextWrapped("Press Enter to teleport player to camera location"); ImGui::TextWrapped("Press Enter to teleport player to camera location");
ImGui::Spacing(); ImGui::Spacing();

View File

@ -34,7 +34,7 @@ public:
struct m_Freecam struct m_Freecam
{ {
static inline bool m_bEnabled; static inline bool m_bEnabled;
static inline float m_fSpeed = 0.08f; static inline int m_nMul = 1;
static inline float m_fFOV = 60.0f; static inline float m_fFOV = 60.0f;
static inline bool m_bInitDone; static inline bool m_bInitDone;
static inline CPed* m_pPed; static inline CPed* m_pPed;

View File

@ -2,5 +2,5 @@
#define MENU_NAME "Cheat Menu" #define MENU_NAME "Cheat Menu"
#define MENU_VERSION_NUMBER "3.0" #define MENU_VERSION_NUMBER "3.0"
#define MENU_VERSION MENU_VERSION_NUMBER"-beta" #define MENU_VERSION MENU_VERSION_NUMBER"-beta"
#define BUILD_NUMBER "20211002" #define BUILD_NUMBER "20211009"
#define MENU_TITLE MENU_NAME " v" MENU_VERSION "(" BUILD_NUMBER ")" #define MENU_TITLE MENU_NAME " v" MENU_VERSION "(" BUILD_NUMBER ")"

View File

@ -81,6 +81,7 @@ void Ped::SpawnPed(std::string& cat, std::string& name, std::string& model)
CPed* ped; CPed* ped;
int hplayer; int hplayer;
static size_t currentSlot = 1;
#ifdef GTASA #ifdef GTASA
if (m_SpecialPedJson.m_Data.contains(model)) if (m_SpecialPedJson.m_Data.contains(model))
@ -91,18 +92,22 @@ void Ped::SpawnPed(std::string& cat, std::string& name, std::string& model)
else else
name = model; name = model;
CStreaming::RequestSpecialChar(1, name.c_str(), PRIORITY_REQUEST); CStreaming::RequestSpecialChar(currentSlot, name.c_str(), PRIORITY_REQUEST);
CStreaming::LoadAllRequestedModels(true); CStreaming::LoadAllRequestedModels(true);
Command<Commands::CREATE_CHAR>(m_SpawnPed::m_nSelectedPedType + 4, 291, pos.x, pos.y, pos.z + 1, &hplayer); Command<Commands::CREATE_CHAR>(m_SpawnPed::m_nSelectedPedType + 4, 290 + currentSlot, pos.x, pos.y, pos.z + 1, &hplayer);
CStreaming::SetSpecialCharIsDeletable(291); CStreaming::SetSpecialCharIsDeletable(290 + currentSlot);
// SA has 10 slots
++currentSlot;
if (currentSlot > 10)
{
currentSlot = 1;
}
} }
#elif GTAVC #elif GTAVC
if (cat == "Special") // Special model if (cat == "Special") // Special model
{ {
static size_t currentSlot = 1;
Command<Commands::LOAD_SPECIAL_CHARACTER>(currentSlot, model.c_str()); Command<Commands::LOAD_SPECIAL_CHARACTER>(currentSlot, model.c_str());
Command<Commands::LOAD_ALL_MODELS_NOW>(); Command<Commands::LOAD_ALL_MODELS_NOW>();
@ -197,15 +202,20 @@ void Ped::Draw()
if (ImGui::Button("Start gang war", ImVec2(Ui::GetSize(2)))) if (ImGui::Button("Start gang war", ImVec2(Ui::GetSize(2))))
{ {
if (Util::GetLargestGangInZone() == 1) if (Util::GetLargestGangInZone() == 1)
{
CGangWars::StartDefensiveGangWar(); CGangWars::StartDefensiveGangWar();
}
else else
{
CGangWars::StartOffensiveGangWar(); CGangWars::StartOffensiveGangWar();
}
CGangWars::bGangWarsActive = true; CGangWars::bGangWarsActive = true;
} }
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::Button("End gang war", ImVec2(Ui::GetSize(2)))) if (ImGui::Button("End gang war", ImVec2(Ui::GetSize(2))))
{
CGangWars::EndGangWar(true); CGangWars::EndGangWar(true);
}
ImGui::Dummy(ImVec2(0, 20)); ImGui::Dummy(ImVec2(0, 20));
ImGui::TextWrapped("Gang zone density:"); ImGui::TextWrapped("Gang zone density:");
@ -236,8 +246,10 @@ void Ped::Draw()
ImGui::TextWrapped("You'll need ExGangWars plugin to display some turf colors"); ImGui::TextWrapped("You'll need ExGangWars plugin to display some turf colors");
ImGui::Spacing(); ImGui::Spacing();
if (ImGui::Button("Download ExGangWars", Ui::GetSize(1))) if (ImGui::Button("Download ExGangWars", Ui::GetSize(1)))
{
ShellExecute(NULL, "open", "https://gtaforums.com/topic/682194-extended-gang-wars/", NULL, NULL, ShellExecute(NULL, "open", "https://gtaforums.com/topic/682194-extended-gang-wars/", NULL, NULL,
SW_SHOWNORMAL); SW_SHOWNORMAL);
}
} }
ImGui::Spacing(); ImGui::Spacing();

View File

@ -280,7 +280,6 @@ int Vehicle::GetRandomTrainIdForModel(int model)
void WarpPlayerIntoVehicle(CVehicle *pVeh, int seatId) void WarpPlayerIntoVehicle(CVehicle *pVeh, int seatId)
{ {
CPlayerPed *pPlayer = FindPlayerPed(); CPlayerPed *pPlayer = FindPlayerPed();
pPlayer->m_bInVehicle = true; pPlayer->m_bInVehicle = true;
pPlayer->m_pVehicle = pVeh; pPlayer->m_pVehicle = pVeh;
pPlayer->RegisterReference((CEntity**)&pPlayer->m_pVehicle); pPlayer->RegisterReference((CEntity**)&pPlayer->m_pVehicle);
@ -288,6 +287,8 @@ void WarpPlayerIntoVehicle(CVehicle *pVeh, int seatId)
pPlayer->RegisterReference((CEntity**)&pPlayer->m_pObjectiveVehicle); pPlayer->RegisterReference((CEntity**)&pPlayer->m_pObjectiveVehicle);
pPlayer->m_dwAction = ePedAction::Driving; pPlayer->m_dwAction = ePedAction::Driving;
pPlayer->m_dwObjective = OBJECTIVE_NO_OBJ; pPlayer->m_dwObjective = OBJECTIVE_NO_OBJ;
patch::Set<BYTE>(0x7838CD, 1); // player got in car flag
Call<0x41D370>(pVeh); // CCarCtrl::RegisterVehicleOfInterest
if (pVeh->m_passengers[seatId]) if (pVeh->m_passengers[seatId])
{ {
@ -296,9 +297,7 @@ void WarpPlayerIntoVehicle(CVehicle *pVeh, int seatId)
pVeh->m_passengers[seatId] = pPlayer; pVeh->m_passengers[seatId] = pPlayer;
pVeh->RegisterReference((CEntity**)&pVeh->m_passengers[seatId]); pVeh->RegisterReference((CEntity**)&pVeh->m_passengers[seatId]);
patch::Set<BYTE>(0x7838CD, 1); // player got in car flag // Set player position
Call<0x41D370>(pVeh); // CCarCtrl::RegisterVehicleOfInterest
CWorld::Remove(pPlayer); CWorld::Remove(pPlayer);
pPlayer->m_placement.pos.x = pVeh->m_placement.pos.x; pPlayer->m_placement.pos.x = pVeh->m_placement.pos.x;
pPlayer->m_placement.pos.y = pVeh->m_placement.pos.y; pPlayer->m_placement.pos.y = pVeh->m_placement.pos.y;