Add TopDownCamera class
This commit is contained in:
parent
376673dce6
commit
216630d4c1
@ -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"
|
||||
|
79
src/custom/topdowncam_sa.cpp
Normal file
79
src/custom/topdowncam_sa.cpp
Normal file
@ -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<eScriptCommands::COMMAND_SET_PLAYER_DRUNKENNESS> (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<eScriptCommands::COMMAND_SET_FIXED_CAMERA_POSITION> (
|
||||
outColPoint.m_vecPoint.x, outColPoint.m_vecPoint.y,
|
||||
outColPoint.m_vecPoint.z, 0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
Command<eScriptCommands::COMMAND_SET_FIXED_CAMERA_POSITION> (
|
||||
cameraPos.x, cameraPos.y, cameraPos.z, 0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
Command<eScriptCommands::COMMAND_POINT_CAMERA_AT_POINT> (pos.x, pos.y,
|
||||
pos.z, 2);
|
||||
|
||||
TheCamera.m_fGenerationDistMultiplier = 10.0f;
|
||||
TheCamera.m_fLODDistMultiplier = 10.0f;
|
||||
}
|
23
src/custom/topdowncam_sa.h
Normal file
23
src/custom/topdowncam_sa.h
Normal file
@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
#include "interface/icheat.hpp"
|
||||
|
||||
/*
|
||||
TopDown for SA
|
||||
Activates/Disactivates cheats randomly
|
||||
*/
|
||||
class TopDownCamera : public ICheat<TopDownCamera>
|
||||
{
|
||||
private:
|
||||
|
||||
friend ICheat;
|
||||
TopDownCamera();
|
||||
TopDownCamera(const TopDownCamera&);
|
||||
|
||||
public:
|
||||
int m_nZoom = 40;
|
||||
|
||||
// Process cheat each frame
|
||||
void Process();
|
||||
};
|
||||
|
||||
extern TopDownCamera& TopDownCam;
|
@ -5,14 +5,13 @@
|
||||
#include "utils/util.h"
|
||||
|
||||
#ifdef GTASA
|
||||
#include "custom/freecam_sa.h"
|
||||
#include "custom/randomcheats_sa.h"
|
||||
#include <CMessages.h>
|
||||
#include <CSprite2d.h>
|
||||
#include <CAERadioTrackManager.h>
|
||||
#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<Commands::RESTORE_CAMERA_JUMPCUT>();
|
||||
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")))
|
||||
{
|
||||
|
@ -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<eScriptCommands::COMMAND_SET_PLAYER_DRUNKENNESS> (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<eScriptCommands::COMMAND_SET_FIXED_CAMERA_POSITION> (
|
||||
outColPoint.m_vecPoint.x, outColPoint.m_vecPoint.y,
|
||||
outColPoint.m_vecPoint.z, 0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
Command<eScriptCommands::COMMAND_SET_FIXED_CAMERA_POSITION> (
|
||||
cameraPos.x, cameraPos.y, cameraPos.z, 0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
Command<eScriptCommands::COMMAND_POINT_CAMERA_AT_POINT> (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<eScriptCommands::COMMAND_SET_PLAYER_DRUNKENNESS> (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<Commands::RESTORE_CAMERA_JUMPCUT>();
|
||||
}
|
||||
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")))
|
||||
{
|
||||
|
@ -30,15 +30,6 @@ private:
|
||||
static inline std::vector<std::string> 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
|
||||
|
@ -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<float>(TEXT("Visual.RadarPosX"), 0x68FD2C, -999, 40, 999);
|
||||
float diff = *(float*)0x68FD2C - prevVal;
|
||||
float prevVal = posX;
|
||||
Widget::EditAddr<float>(TEXT("Visual.RadarPosX"), (uint)&posX, -999, 40, 999);
|
||||
float diff = posX - prevVal;
|
||||
discLeft += diff;
|
||||
discRight += diff;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user