Improved freecam & bug fixes
This commit is contained in:
parent
f0e6698481
commit
079ddb7d34
170
src/Game.cpp
170
src/Game.cpp
@ -3,6 +3,7 @@
|
||||
#include "Menu.h"
|
||||
#include "Ui.h"
|
||||
#include "Util.h"
|
||||
#include "CIplStore.h"
|
||||
|
||||
ImGuiTextFilter Game::filter = "";
|
||||
std::vector<std::string> Game::search_categories;
|
||||
@ -22,11 +23,15 @@ int Game::random_cheats::enable_wait_time = 10;
|
||||
uint Game::random_cheats::timer = 0;
|
||||
std::string Game::random_cheats::enabled_cheats[92][2];
|
||||
|
||||
bool Game::airbreak::init_done = false;
|
||||
bool Game::airbreak::enable = false;
|
||||
float Game::airbreak::speed = 0.08f;
|
||||
float Game::airbreak::tmouseX = 0;
|
||||
float Game::airbreak::tmouseY = 0;
|
||||
bool Game::freecam::init_done = false;
|
||||
bool Game::freecam::enable = false;
|
||||
float Game::freecam::speed = 0.08f;
|
||||
float Game::freecam::tmouseX = 0;
|
||||
float Game::freecam::tmouseY = 0;
|
||||
float Game::freecam::mouseX = 0;
|
||||
float Game::freecam::mouseY = 0;
|
||||
int Game::freecam::hped = -1;
|
||||
CPed *Game::freecam::ped = nullptr;
|
||||
|
||||
bool Game::disable_cheats = false;
|
||||
bool Game::disable_replay = false;
|
||||
@ -161,17 +166,17 @@ Game::Game()
|
||||
}
|
||||
}
|
||||
|
||||
if (Ui::HotKeyPressed(Menu::hotkeys::airbreak))
|
||||
if (Ui::HotKeyPressed(Menu::hotkeys::freecam))
|
||||
{
|
||||
if (airbreak::enable)
|
||||
if (freecam::enable)
|
||||
{
|
||||
airbreak::enable = false;
|
||||
ClearAirbreakStuff();
|
||||
freecam::enable = false;
|
||||
ClearFreecamStuff();
|
||||
}
|
||||
else airbreak::enable = true;
|
||||
else freecam::enable = true;
|
||||
}
|
||||
if (airbreak::enable)
|
||||
AirbreakMode(player,hplayer);
|
||||
if (freecam::enable)
|
||||
FreeCam();
|
||||
};
|
||||
}
|
||||
|
||||
@ -195,89 +200,104 @@ void SetPlayerMission(std::string& rootkey, std::string& name, std::string& id)
|
||||
|
||||
}
|
||||
|
||||
void Game::AirbreakMode(CPlayerPed* player, int hplayer)
|
||||
void Game::FreeCam()
|
||||
{
|
||||
CVector pos = player->GetPosition();
|
||||
uint delta_speed = airbreak::speed * (CTimer::m_snTimeInMillisecondsNonClipped - CTimer::m_snPreviousTimeInMillisecondsNonClipped);
|
||||
uint delta_speed = freecam::speed * (CTimer::m_snTimeInMillisecondsNonClipped - CTimer::m_snPreviousTimeInMillisecondsNonClipped);
|
||||
|
||||
if (!airbreak::init_done)
|
||||
if (!freecam::init_done)
|
||||
{
|
||||
CPlayerPed *player = FindPlayerPed(-1);
|
||||
Command<Commands::SET_EVERYONE_IGNORE_PLAYER>(0, true);
|
||||
Command<Commands::FREEZE_CHAR_POSITION_AND_DONT_LOAD_COLLISION>(hplayer,true);
|
||||
Command<Commands::SET_CHAR_COLLISION>(hplayer, false);
|
||||
Command<Commands::SET_LOAD_COLLISION_FOR_CHAR_FLAG>(hplayer, false);
|
||||
player->m_nPedFlags.bDontRender = true;
|
||||
|
||||
CHud::bScriptDontDisplayRadar = true;
|
||||
CHud::m_Wants_To_Draw_Hud = false;
|
||||
CVector player_pos = player->GetPosition();
|
||||
CPad::GetPad(0)->DisablePlayerControls = true;
|
||||
|
||||
airbreak::tmouseX = TheCamera.GetHeading() + (90.0f * 3.1416f / 180.0f);
|
||||
airbreak::tmouseY = 0;
|
||||
airbreak::init_done = true;
|
||||
Command<Commands::CREATE_RANDOM_CHAR>(player_pos.x,player_pos.y,player_pos.z, &freecam::hped);
|
||||
freecam::ped = CPools::GetPed(freecam::hped);
|
||||
freecam::ped->m_bIsVisible = false;
|
||||
|
||||
Command<Commands::FREEZE_CHAR_POSITION_AND_DONT_LOAD_COLLISION>(freecam::hped,true);
|
||||
Command<Commands::SET_CHAR_COLLISION>(freecam::hped, false);
|
||||
Command<Commands::SET_LOAD_COLLISION_FOR_CHAR_FLAG>(freecam::hped, false);
|
||||
|
||||
freecam::tmouseX = player->GetHeading();
|
||||
freecam::tmouseY = 0;
|
||||
|
||||
freecam::init_done = true;
|
||||
player_pos.z -= 20;
|
||||
freecam::ped->SetPosn(player_pos);
|
||||
}
|
||||
CVector pos = freecam::ped->GetPosition();
|
||||
|
||||
float mul = 1.0f;
|
||||
Command<Commands::GET_PC_MOUSE_MOVEMENT>(&freecam::mouseX, &freecam::mouseY);
|
||||
freecam::tmouseX = freecam::tmouseX - freecam::mouseX/250;
|
||||
freecam::tmouseY = freecam::tmouseY + freecam::mouseY/3;
|
||||
|
||||
airbreak::tmouseX -= (CPad::NewMouseControllerState.X / 6.0f);
|
||||
airbreak::tmouseY += (CPad::NewMouseControllerState.Y / 3.0f);
|
||||
if (freecam::tmouseY > 150)
|
||||
freecam::tmouseY = 150;
|
||||
|
||||
airbreak::tmouseY = (airbreak::tmouseY > 17.1887f) ? 17.1887f : airbreak::tmouseY;
|
||||
airbreak::tmouseY = (airbreak::tmouseY < -17.1887f) ? -17.1887f : airbreak::tmouseY;
|
||||
|
||||
TheCamera.m_fOrientation = airbreak::tmouseY * (3.1416 / 180);
|
||||
CHud::SetMessage((char*)std::to_string(TheCamera.m_fOrientation).c_str());
|
||||
if (freecam::tmouseY < -150)
|
||||
freecam::tmouseY = -150;
|
||||
|
||||
if (KeyPressed(VK_RETURN))
|
||||
{
|
||||
CPlayerPed *player = FindPlayerPed(-1);
|
||||
CVector pos = freecam::ped->GetPosition();
|
||||
CEntity* player_entity = FindPlayerEntity(-1);
|
||||
pos.z = CWorld::FindGroundZFor3DCoord(pos.x, pos.y, 1000, 0, &player_entity) + 0.5f;
|
||||
Command<Commands::SET_CHAR_COORDINATES>(CPools::GetPedRef(player),pos.x,pos.y,pos.z);
|
||||
}
|
||||
|
||||
if (KeyPressed(VK_RCONTROL))
|
||||
mul /= 2;
|
||||
delta_speed /= 2;
|
||||
|
||||
if (KeyPressed(VK_RSHIFT))
|
||||
mul *= 2;
|
||||
delta_speed *= 2;
|
||||
|
||||
if (KeyPressed(VK_KEY_I) || KeyPressed(VK_KEY_K))
|
||||
{
|
||||
if (KeyPressed(VK_KEY_K))
|
||||
mul *= -1;
|
||||
delta_speed *= -1;
|
||||
|
||||
float angle = TheCamera.GetHeading() + (90.0f * 3.1416f / 180.0f);
|
||||
|
||||
pos.x += delta_speed * cos(angle) * mul;
|
||||
pos.y += delta_speed * sin(angle) * mul;
|
||||
pos.z += delta_speed * sin(TheCamera.m_fOrientation*2) * mul;
|
||||
float angle;
|
||||
Command<Commands::GET_CHAR_HEADING>(freecam::hped,&angle);
|
||||
|
||||
pos.x += delta_speed * cos(angle * 3.14159f/180.0f);
|
||||
pos.y += delta_speed * sin(angle * 3.14159f/180.0f);
|
||||
pos.z += delta_speed* 2 * sin(freecam::tmouseY/3* 3.14159f/180.0f);
|
||||
}
|
||||
|
||||
if (KeyPressed(VK_KEY_J) || KeyPressed(VK_KEY_L))
|
||||
{
|
||||
if (KeyPressed(VK_KEY_J))
|
||||
mul *= -1;
|
||||
delta_speed *= -1;
|
||||
|
||||
float angle = TheCamera.GetHeading() + (3.1416f / 180.0f);
|
||||
float angle;
|
||||
Command<Commands::GET_CHAR_HEADING>(freecam::hped,&angle);
|
||||
angle -= 90.0f;
|
||||
|
||||
pos.x += delta_speed * cos(angle) * mul;
|
||||
pos.y += delta_speed * sin(angle) * mul;
|
||||
pos.x += delta_speed * cos(angle * 3.14159f/180.0f);
|
||||
pos.y += delta_speed * sin(angle * 3.14159f/180.0f);
|
||||
}
|
||||
|
||||
player->SetPosn(pos);
|
||||
freecam::ped->SetHeading(freecam::tmouseX);
|
||||
Command<Commands::ATTACH_CAMERA_TO_CHAR>(freecam::hped,0.0,0.0,20.0,90.0,180,freecam::tmouseY,0.0,2);
|
||||
freecam::ped->SetPosn(pos);
|
||||
CIplStore::AddIplsNeededAtPosn(pos);
|
||||
}
|
||||
|
||||
void Game::ClearAirbreakStuff()
|
||||
void Game::ClearFreecamStuff()
|
||||
{
|
||||
CPlayerPed *player = FindPlayerPed();
|
||||
uint hplayer = CPools::GetPedRef(player);
|
||||
|
||||
airbreak::init_done = false;
|
||||
freecam::init_done = false;
|
||||
Command<Commands::SET_EVERYONE_IGNORE_PLAYER>(0, false);
|
||||
Command<Commands::FREEZE_CHAR_POSITION_AND_DONT_LOAD_COLLISION>(hplayer, false);
|
||||
Command<Commands::SET_CHAR_COLLISION>(hplayer, true);
|
||||
Command<Commands::SET_LOAD_COLLISION_FOR_CHAR_FLAG>(hplayer, true);
|
||||
player->m_nPedFlags.bDontRender = false;
|
||||
|
||||
CHud::bScriptDontDisplayRadar = false;
|
||||
CHud::m_Wants_To_Draw_Hud = true;
|
||||
CPad::GetPad(0)->DisablePlayerControls = false;
|
||||
|
||||
Command<Commands::DELETE_CHAR>(freecam::hped);
|
||||
freecam::ped = nullptr;
|
||||
|
||||
CVector pos = player->GetPosition();
|
||||
CEntity* player_entity = FindPlayerEntity(-1);
|
||||
pos.z = CWorld::FindGroundZFor3DCoord(pos.x, pos.y, 1000, 0, &player_entity) + 0.5f;
|
||||
player->SetPosn(pos);
|
||||
Command<Commands::RESTORE_CAMERA_JUMPCUT>();
|
||||
}
|
||||
|
||||
@ -362,21 +382,6 @@ of LS without completing missions"))
|
||||
}
|
||||
if (ImGui::BeginTabItem("Menus"))
|
||||
{
|
||||
if (ImGui::CollapsingHeader("Airbreak mode"))
|
||||
{
|
||||
if (Ui::CheckboxWithHint("Enable", &airbreak::enable, "Forward: I\tBackward: K\
|
||||
\nLeft: J\t\t Right: L\n\nSlower: RCtrl\tFaster: RShift"))
|
||||
{
|
||||
if (!airbreak::enable)
|
||||
ClearAirbreakStuff();
|
||||
}
|
||||
ImGui::Spacing();
|
||||
|
||||
ImGui::SliderFloat("Movement Speed", &airbreak::speed, 0.0, 0.5);
|
||||
|
||||
ImGui::Spacing();
|
||||
ImGui::Separator();
|
||||
}
|
||||
if (ImGui::CollapsingHeader("Current day"))
|
||||
{
|
||||
int day = CClock::CurrentDay-1;
|
||||
@ -387,6 +392,23 @@ of LS without completing missions"))
|
||||
}
|
||||
Ui::EditAddress<int>("Days passed", 0xB79038, 0, 9999);
|
||||
Ui::EditReference("FPS limit", RsGlobal.frameLimit, 1, 30, 60);
|
||||
if (ImGui::CollapsingHeader("Free cam"))
|
||||
{
|
||||
if (Ui::CheckboxWithHint("Enable", &freecam::enable, "Forward: I\tBackward: K\
|
||||
\nLeft: J\t\t Right: L\n\nSlower: RCtrl\tFaster: RShift"))
|
||||
{
|
||||
if (!freecam::enable)
|
||||
ClearFreecamStuff();
|
||||
}
|
||||
ImGui::Spacing();
|
||||
|
||||
ImGui::SliderFloat("Movement Speed", &freecam::speed, 0.0, 0.5);
|
||||
|
||||
ImGui::Spacing();
|
||||
ImGui::TextWrapped("Press Enter to teleport player to camera location");
|
||||
ImGui::Spacing();
|
||||
ImGui::Separator();
|
||||
}
|
||||
Ui::EditReference("Game speed", CTimer::ms_fTimeScale,1, 1, 10);
|
||||
Ui::EditFloat("Gravity", 0x863984, -1.0f, 0.008f, 1.0f);
|
||||
|
||||
|
11
src/Game.h
11
src/Game.h
@ -19,12 +19,14 @@ public:
|
||||
static std::string enabled_cheats[92][2];
|
||||
};
|
||||
|
||||
struct airbreak
|
||||
struct freecam
|
||||
{
|
||||
static bool enable;
|
||||
static float speed;
|
||||
static bool init_done;
|
||||
static float tmouseX, tmouseY;
|
||||
static CPed *ped;
|
||||
static int hped;
|
||||
static float mouseX, mouseY, tmouseX, tmouseY;
|
||||
};
|
||||
|
||||
static bool disable_cheats;
|
||||
@ -52,8 +54,7 @@ public:
|
||||
Game();
|
||||
~Game();
|
||||
static void Main();
|
||||
static void AirbreakMode(CPlayerPed* player, int hplayer);
|
||||
static void CameraMode();
|
||||
static void ClearAirbreakStuff();
|
||||
static void FreeCam();
|
||||
static void ClearFreecamStuff();
|
||||
};
|
||||
|
||||
|
12
src/Menu.cpp
12
src/Menu.cpp
@ -19,7 +19,7 @@ float Menu::overlay::posX = NULL;
|
||||
float Menu::overlay::posY = NULL;
|
||||
|
||||
HotKeyData Menu::hotkeys::aim_skin_changer{};
|
||||
HotKeyData Menu::hotkeys::airbreak{};
|
||||
HotKeyData Menu::hotkeys::freecam{};
|
||||
HotKeyData Menu::hotkeys::command_window{};
|
||||
HotKeyData Menu::hotkeys::flip_veh{};
|
||||
HotKeyData Menu::hotkeys::fix_veh{};
|
||||
@ -52,8 +52,8 @@ Menu::Menu()
|
||||
hotkeys::aim_skin_changer.key1 = config.GetValue("hotkey.aim_skin_changer.key1", VK_RETURN);
|
||||
hotkeys::aim_skin_changer.key2 = config.GetValue("hotkey.aim_skin_changer.key2", VK_RETURN);
|
||||
|
||||
hotkeys::airbreak.key1 = config.GetValue("hotkey.airbreak.key1", VK_LMENU);
|
||||
hotkeys::airbreak.key2 = config.GetValue("hotkey.airbreak.key2", VK_KEY_A);
|
||||
hotkeys::freecam.key1 = config.GetValue("hotkey.freecam.key1", VK_LMENU);
|
||||
hotkeys::freecam.key2 = config.GetValue("hotkey.freecam.key2", VK_KEY_A);
|
||||
|
||||
hotkeys::quick_ss.key1 = config.GetValue("hotkey.quick_screenshot.key1", VK_LCONTROL);
|
||||
hotkeys::quick_ss.key2 = config.GetValue("hotkey.quick_screenshot.key2", VK_KEY_S);
|
||||
@ -351,10 +351,10 @@ void Menu::Main()
|
||||
config.SetValue("hotkey.aim_skin_changer.key1", hotkeys::aim_skin_changer.key1);
|
||||
config.SetValue("hotkey.aim_skin_changer.key2", hotkeys::aim_skin_changer.key2);
|
||||
}
|
||||
if (Ui::HotKey("Airbreak mode", hotkeys::airbreak))
|
||||
if (Ui::HotKey("Freecam", hotkeys::freecam))
|
||||
{
|
||||
config.SetValue("hotkey.airbreak.key1", hotkeys::airbreak.key1);
|
||||
config.SetValue("hotkey.airbreak.key2", hotkeys::airbreak.key2);
|
||||
config.SetValue("hotkey.freecam.key1", hotkeys::freecam.key1);
|
||||
config.SetValue("hotkey.freecam.key2", hotkeys::freecam.key2);
|
||||
}
|
||||
if (Ui::HotKey("Take quick screenshot", hotkeys::quick_ss))
|
||||
{
|
||||
|
@ -20,7 +20,7 @@ public:
|
||||
struct hotkeys
|
||||
{
|
||||
static HotKeyData aim_skin_changer;
|
||||
static HotKeyData airbreak;
|
||||
static HotKeyData freecam;
|
||||
static HotKeyData command_window;
|
||||
static HotKeyData fix_veh;
|
||||
static HotKeyData flip_veh;
|
||||
|
6
src/Ui.h
6
src/Ui.h
@ -107,6 +107,12 @@ void Ui::EditAddress(const char *label, const int address, const int min, const
|
||||
|
||||
ImGui::Spacing();
|
||||
|
||||
if (val < min)
|
||||
val = min;
|
||||
|
||||
if (val > max)
|
||||
val = max;
|
||||
|
||||
if (ImGui::Button(("Minimum##" + std::string(label)).c_str(), Ui::GetSize(items)))
|
||||
patch::Set<T>(address, min, false);
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "Ui.h"
|
||||
#include "Util.h"
|
||||
#include "Game.h"
|
||||
#include "CHudColours.h"
|
||||
|
||||
bool Visual::lock_weather = false;
|
||||
int Visual::weather_type_backup = 0;
|
||||
@ -14,6 +15,15 @@ std::vector<std::string> Visual::weather_names{
|
||||
"EXTRASUNNY DESERT","SUNNY DESERT","SANDSTORM DESERT","UNDERWATER","EXTRACOLOURS 1","EXTRACOLOURS 2"
|
||||
};
|
||||
|
||||
// Let's just use our own variables
|
||||
static float radar_posX;
|
||||
static float radar_posY;
|
||||
static float radar_width = 76.0f;
|
||||
static float radar_height = 104.0f;
|
||||
static CHudColour health_bar;
|
||||
//static CHudColour armour_bar;
|
||||
static bool init_patches = false;
|
||||
|
||||
Visual::Visual()
|
||||
{
|
||||
Events::initGameEvent += []
|
||||
@ -208,24 +218,62 @@ void Visual::Main()
|
||||
}
|
||||
if (ImGui::BeginTabItem("Menus"))
|
||||
{
|
||||
Ui::ColorPickerAddress("Health bar + debt color", 0xBAB22C, ImVec4(180,25,29,255));
|
||||
|
||||
if (!init_patches)
|
||||
{
|
||||
// read those values from game
|
||||
health_bar = HudColour.m_aColours[0];
|
||||
//armour_bar = HudColour.m_aColours[4];
|
||||
|
||||
radar_posX = *(float*)*(int*)0x5834D4;
|
||||
radar_posY = *(float*)*(int*)0x583500;
|
||||
radar_height = *(float*)*(int*)0x5834F6;
|
||||
radar_width = *(float*)*(int*)0x5834C2;
|
||||
|
||||
// patch radar stuff oof
|
||||
patch::SetPointer(0x5834D4, &radar_posX);
|
||||
patch::SetPointer(0x583500, &radar_posY);
|
||||
patch::SetPointer(0x5834F6, &radar_height);
|
||||
patch::SetPointer(0x5834C2, &radar_width);
|
||||
|
||||
patch::SetPointer(0x58A79B, &radar_posX);
|
||||
patch::SetPointer(0x58A7C7, &radar_posY);
|
||||
patch::SetPointer(0x58A801, &radar_height);
|
||||
patch::SetPointer(0x58A7E9, &radar_width);
|
||||
patch::SetPointer(0x58A836, &radar_posX);
|
||||
patch::SetPointer(0x58A868, &radar_posY);
|
||||
patch::SetPointer(0x58A8AB, &radar_height);
|
||||
patch::SetPointer(0x58A840, &radar_width);
|
||||
patch::SetPointer(0x58A8E9, &radar_posX);
|
||||
patch::SetPointer(0x58A913, &radar_posY);
|
||||
patch::SetPointer(0x58A921, &radar_height);
|
||||
patch::SetPointer(0x58A943, &radar_width);
|
||||
patch::SetPointer(0x58A98A, &radar_posX);
|
||||
patch::SetPointer(0x58A9C7, &radar_posY);
|
||||
patch::SetPointer(0x58A9D5, &radar_height);
|
||||
patch::SetPointer(0x58A99D, &radar_width);
|
||||
|
||||
patch::SetPointer(0x589331, &health_bar);
|
||||
//patch::SetPointer(0x5890FC,&armour_bar);
|
||||
init = true;
|
||||
}
|
||||
|
||||
Ui::ColorPickerAddress("Armour bar", *(int*)0x5890FC, ImVec4(180,25,29,255));
|
||||
Ui::ColorPickerAddress("Health bar", *(int*)0x589331, ImVec4(180,25,29,255));
|
||||
Ui::ColorPickerAddress("Main menu title border color", 0xBAB240, ImVec4(0,0,0,255));
|
||||
Ui::ColorPickerAddress("Money color", 0xBAB230, ImVec4(54,104,44,255));
|
||||
static std::vector<Ui::NamedValue> font_outline{{ "No outline", 0 }, { "Thin outline" ,1 }, { "Default outline" ,2 }};
|
||||
Ui::EditRadioButtonAddressEx("Money font outline", 0x58F58D, font_outline);
|
||||
static std::vector<Ui::NamedValue> style{ { "Style 1", 1 }, { "Style 2" ,2 }, { "Default style" ,3 }};
|
||||
Ui::EditRadioButtonAddressEx("Money font style", 0x58F57F, style);
|
||||
Ui::EditAddress<float>("Radar Height", 0x866B74, 0, 76, 999);
|
||||
Ui::EditAddress<float>("Radar Width", 0x866B78, 0, 94, 999);
|
||||
Ui::EditAddress<float>("Radar X position", 0x858A10, -999, 40, 999);
|
||||
Ui::EditAddress<float>("Radar Y position", 0x866B70, -999, 104, 999);
|
||||
Ui::EditAddress<float>("Radar Height", *(int*)0x5834F6, 0, 76, 999);
|
||||
Ui::EditAddress<float>("Radar Width", *(int*)0x5834C2, 0, 94, 999);
|
||||
Ui::EditAddress<float>("Radar X position", *(int*)0x5834D4, -999, 40, 999);
|
||||
Ui::EditAddress<float>("Radar Y position", *(int*)0x583500, -999, 104, 999);
|
||||
Ui::EditAddress<int>("Radar zoom", 0xA444A3, 0, 0, 170);
|
||||
Ui::ColorPickerAddress("Radio station color", 0xBAB24C, ImVec4(150,150,150,255));
|
||||
Ui::ColorPickerAddress("Styled text color", 0xBAB258, ImVec4(226,192,99,255));
|
||||
Ui::ColorPickerAddress("Text color", 0xBAB234, ImVec4(50,60,127,255));
|
||||
static std::vector<Ui::NamedValue> star_border{ { "No border", 0 }, { "Default" ,1 }, { "Bold border" ,2 }};
|
||||
Ui::EditRadioButtonAddressEx("Wanted star border", 0x58DD41, star_border);
|
||||
Ui::ColorPickerAddress("Wanted star color + some text", 0xBAB244, ImVec4(144,98,16,255));
|
||||
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user