mirror of
https://github.com/EricPlayZ/EGameTools.git
synced 2025-07-18 17:37:53 +08:00
- Fixed Free Camera orientation resetting back to player orientation after pausing and unpausing the game
- Added Vec4, changed Mtx34 structure to reflect the game's structure
This commit is contained in:
@ -61,6 +61,7 @@
|
||||
<ClCompile Include="src\Utils\Time.cpp" />
|
||||
<ClCompile Include="src\Utils\Values.cpp" />
|
||||
<ClCompile Include="src\Vec3.cpp" />
|
||||
<ClCompile Include="src\Vec4.cpp" />
|
||||
<ClCompile Include="SteamAPI.cpp" />
|
||||
<ClCompile Include="WinMemory.cpp" />
|
||||
</ItemGroup>
|
||||
@ -121,6 +122,7 @@
|
||||
<ClInclude Include="include\EGSDK\Utils\Values.h" />
|
||||
<ClInclude Include="include\EGSDK\Utils\WinMemory.h" />
|
||||
<ClInclude Include="include\EGSDK\Vec3.h" />
|
||||
<ClInclude Include="include\EGSDK\Vec4.h" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
|
@ -157,6 +157,9 @@
|
||||
<ClCompile Include="src\Mtx34.cpp">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\Vec4.cpp">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="include">
|
||||
@ -374,5 +377,8 @@
|
||||
<ClInclude Include="include\EGSDK\Mtx34.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\EGSDK\Vec4.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -8,7 +8,6 @@ namespace EGSDK::Engine {
|
||||
public:
|
||||
union {
|
||||
DynamicField(CBulletPhysicsCharacter, Vec3, playerPos);
|
||||
DynamicField(CBulletPhysicsCharacter, Vec3, playerPos2);
|
||||
DynamicField(CBulletPhysicsCharacter, float, playerDownwardVelocity);
|
||||
};
|
||||
|
||||
|
@ -3,11 +3,6 @@
|
||||
#include <EGSDK\Mtx34.h>
|
||||
|
||||
namespace EGSDK::Engine {
|
||||
struct EGameSDK_API CameraMtx {
|
||||
Mtx34 mtx1;
|
||||
Mtx34 mtx2;
|
||||
};
|
||||
|
||||
class EGameSDK_API IBaseCamera {
|
||||
public:
|
||||
float GetFOV();
|
||||
@ -15,11 +10,14 @@ namespace EGSDK::Engine {
|
||||
Vec3* GetUpVector(Vec3* outUpVec);
|
||||
Vec3* GetLeftVector(Vec3* outLeftVec);
|
||||
Vec3* GetPosition(Vec3* outPos);
|
||||
CameraMtx* GetViewMatrix();
|
||||
Mtx34* GetViewMatrix();
|
||||
Mtx34* GetInvCameraMatrix();
|
||||
|
||||
void Rotate(float angle, const Vec3* axis);
|
||||
void SetFOV(float fov);
|
||||
void SetPosition(const Vec3* pos);
|
||||
void SetCameraMatrix(const CameraMtx* mtx);
|
||||
void SetCameraMatrix(const Mtx34* mtx);
|
||||
void SetInvCameraMatrix(const Mtx34* mtx);
|
||||
|
||||
static bool isSetFOVCalledByEGSDK;
|
||||
};
|
||||
|
@ -1,16 +1,16 @@
|
||||
#pragma once
|
||||
#include <EGSDK\Vec3.h>
|
||||
#include <EGSDK\Vec4.h>
|
||||
#include <EGSDK\Exports.h>
|
||||
|
||||
namespace EGSDK {
|
||||
struct EGameSDK_API Mtx34 {
|
||||
Vec3 XAxis;
|
||||
Vec3 YAxis;
|
||||
Vec3 ZAxis;
|
||||
Vec3 Position;
|
||||
struct EGameSDK_API alignas(16) Mtx34 {
|
||||
Vec4 Row1;
|
||||
Vec4 Row2;
|
||||
Vec4 Row3;
|
||||
|
||||
Mtx34();
|
||||
Mtx34(const Vec3& xAxis, const Vec3& yAxis, const Vec3& zAxis, const Vec3& position);
|
||||
Mtx34(const Vec4& row1, const Vec4& row2, const Vec4& row3);
|
||||
|
||||
bool operator==(const Mtx34& m) const;
|
||||
Mtx34& operator+=(const Mtx34& m);
|
||||
@ -19,12 +19,14 @@ namespace EGSDK {
|
||||
Mtx34 operator-(const Mtx34& m) const;
|
||||
Mtx34 operator*(const Mtx34& scalar) const;
|
||||
Mtx34 operator/(const Mtx34& scalar) const;
|
||||
Mtx34 operator*(const Vec3& scalar) const;
|
||||
Mtx34 operator/(const Vec3& scalar) const;
|
||||
Mtx34 operator*(const Vec4& scalar) const;
|
||||
Mtx34 operator/(const Vec4& scalar) const;
|
||||
|
||||
Vec3 TransformPosition(const Vec3& v) const;
|
||||
void Normalize();
|
||||
Vec3 GetXAxis() const;
|
||||
Vec3 GetYAxis() const;
|
||||
Vec3 GetZAxis() const;
|
||||
Vec3 GetPosition() const;
|
||||
|
||||
Mtx34 TransposeRotation() const;
|
||||
Mtx34 normalize();
|
||||
};
|
||||
}
|
@ -20,8 +20,9 @@ namespace EGSDK {
|
||||
Vec3 operator*(float scalar) const;
|
||||
Vec3 operator/(float scalar) const;
|
||||
|
||||
Vec3 normalize();
|
||||
Vec3 normalize() const;
|
||||
Vec3 cross(const Vec3& v) const;
|
||||
float dot(const Vec3& v) const;
|
||||
Vec3 round();
|
||||
Vec3 round(int decimals);
|
||||
|
||||
|
30
EGameSDK/include/EGSDK/Vec4.h
Normal file
30
EGameSDK/include/EGSDK/Vec4.h
Normal file
@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
#include <EGSDK\Exports.h>
|
||||
|
||||
namespace EGSDK {
|
||||
struct EGameSDK_API Vec4 {
|
||||
float X;
|
||||
float Y;
|
||||
float Z;
|
||||
float W;
|
||||
|
||||
Vec4();
|
||||
Vec4(float x, float y, float z, float w);
|
||||
|
||||
bool operator==(const Vec4& v) const;
|
||||
Vec4& operator+=(const Vec4& v);
|
||||
Vec4& operator-=(const Vec4& v);
|
||||
Vec4 operator+(const Vec4& v) const;
|
||||
Vec4 operator-(const Vec4& v) const;
|
||||
Vec4 operator*(const Vec4& scalar) const;
|
||||
Vec4 operator/(const Vec4& scalar) const;
|
||||
Vec4 operator*(float scalar) const;
|
||||
Vec4 operator/(float scalar) const;
|
||||
|
||||
Vec4 normalize() const;
|
||||
Vec4 round();
|
||||
Vec4 round(int decimals);
|
||||
|
||||
bool isDefault() const;
|
||||
};
|
||||
}
|
@ -12,7 +12,7 @@ namespace EGSDK::Engine {
|
||||
void CBulletPhysicsCharacter::MoveCharacter(const Vec3& pos) {
|
||||
playerDownwardVelocity = 0.0f;
|
||||
playerPos = pos;
|
||||
playerPos2 = pos;
|
||||
//playerPos2 = pos;
|
||||
}
|
||||
|
||||
static CBulletPhysicsCharacter* GetOffset_CBulletPhysicsCharacter() {
|
||||
|
@ -20,10 +20,16 @@ namespace EGSDK::Engine {
|
||||
Vec3* IBaseCamera::GetPosition(Vec3* outPos) {
|
||||
return Utils::Memory::SafeCallFunction<Vec3*>("engine_x64_rwdi.dll", "?GetPosition@IBaseCamera@@UEBA?BVvec3@@XZ", nullptr, this, outPos);
|
||||
}
|
||||
CameraMtx* IBaseCamera::GetViewMatrix() {
|
||||
return Utils::Memory::SafeCallFunction<CameraMtx*>("engine_x64_rwdi.dll", "?GetViewMatrix@IBaseCamera@@QEAAAEBVmtx34@@XZ", nullptr, this);
|
||||
Mtx34* IBaseCamera::GetViewMatrix() {
|
||||
return Utils::Memory::SafeCallFunction<Mtx34*>("engine_x64_rwdi.dll", "?GetViewMatrix@IBaseCamera@@QEAAAEBVmtx34@@XZ", nullptr, this);
|
||||
}
|
||||
Mtx34* IBaseCamera::GetInvCameraMatrix() {
|
||||
return Utils::Memory::SafeCallFunction<Mtx34*>("engine_x64_rwdi.dll", "?GetInvCameraMatrix@IBaseCamera@@QEAAAEBVmtx34@@XZ", nullptr, this);
|
||||
}
|
||||
|
||||
void IBaseCamera::Rotate(float angle, const Vec3* axis) {
|
||||
Utils::Memory::SafeCallFunctionVoid("engine_x64_rwdi.dll", "?Rotate@IBaseCamera@@QEAAXMAEBVvec3@@@Z", this, angle, axis);
|
||||
}
|
||||
void IBaseCamera::SetFOV(float fov) {
|
||||
isSetFOVCalledByEGSDK = true;
|
||||
Utils::Memory::SafeCallFunctionVoid("engine_x64_rwdi.dll", "?SetFOV@IBaseCamera@@QEAAXM@Z", this, fov);
|
||||
@ -32,7 +38,10 @@ namespace EGSDK::Engine {
|
||||
void IBaseCamera::SetPosition(const Vec3* pos) {
|
||||
Utils::Memory::SafeCallFunctionVoid("engine_x64_rwdi.dll", "?SetPosition@IBaseCamera@@QEAAXAEBVvec3@@@Z", this, pos);
|
||||
}
|
||||
void IBaseCamera::SetCameraMatrix(const CameraMtx* mtx) {
|
||||
void IBaseCamera::SetCameraMatrix(const Mtx34* mtx) {
|
||||
Utils::Memory::SafeCallFunctionVoid("engine_x64_rwdi.dll", "?SetCameraMatrix@IBaseCamera@@QEAAXAEBVmtx34@@@Z", this, mtx);
|
||||
}
|
||||
void IBaseCamera::SetInvCameraMatrix(const Mtx34* mtx) {
|
||||
Utils::Memory::SafeCallFunctionVoid("engine_x64_rwdi.dll", "?SetInvCameraMatrix@IBaseCamera@@QEAAXAEBVmtx34@@@Z", this, mtx);
|
||||
}
|
||||
}
|
@ -1,64 +1,57 @@
|
||||
#include <EGSDK\Mtx34.h>
|
||||
|
||||
namespace EGSDK {
|
||||
Mtx34::Mtx34() : XAxis(1.0f, 0.0f, 0.0f), YAxis(0.0f, 1.0f, 0.0f), ZAxis(0.0f, 0.0f, 1.0f), Position(0.0f, 0.0f, 0.0f) {}
|
||||
Mtx34::Mtx34(const Vec3& XAxis, const Vec3& YAxis, const Vec3& ZAxis, const Vec3& Pos) : XAxis(XAxis), YAxis(YAxis), ZAxis(ZAxis), Position(Pos) {}
|
||||
Mtx34::Mtx34() : Row1(1.0f, 0.0f, 0.0f, 0.0f), Row2(0.0f, 1.0f, 0.0f, 0.0f), Row3(0.0f, 0.0f, 1.0f, 0.0f) {}
|
||||
Mtx34::Mtx34(const Vec4& row1, const Vec4& row2, const Vec4& row3) : Row1(row1), Row2(row2), Row3(row3) {}
|
||||
|
||||
bool Mtx34::operator==(const Mtx34& m) const {
|
||||
return XAxis == m.XAxis && YAxis == m.YAxis && ZAxis == m.ZAxis && Position == m.Position;
|
||||
return Row1 == m.Row1 && Row2 == m.Row2 && Row3 == m.Row3;
|
||||
}
|
||||
Mtx34& Mtx34::operator+=(const Mtx34& m) {
|
||||
XAxis += m.XAxis;
|
||||
YAxis += m.YAxis;
|
||||
ZAxis += m.ZAxis;
|
||||
Position += m.Position;
|
||||
Row1 += m.Row1;
|
||||
Row2 += m.Row2;
|
||||
Row3 += m.Row3;
|
||||
return *this;
|
||||
}
|
||||
Mtx34& Mtx34::operator-=(const Mtx34& m) {
|
||||
XAxis -= m.XAxis;
|
||||
YAxis -= m.YAxis;
|
||||
ZAxis -= m.ZAxis;
|
||||
Position -= m.Position;
|
||||
Row1 -= m.Row1;
|
||||
Row2 -= m.Row2;
|
||||
Row3 -= m.Row3;
|
||||
return *this;
|
||||
}
|
||||
Mtx34 Mtx34::operator+(const Mtx34& m) const {
|
||||
return { XAxis + m.XAxis, YAxis + m.YAxis, ZAxis + m.ZAxis, Position + m.Position };
|
||||
return { Row1 + m.Row1, Row2 + m.Row2, Row3 + m.Row3 };
|
||||
}
|
||||
Mtx34 Mtx34::operator-(const Mtx34& m) const {
|
||||
return { XAxis - m.XAxis, YAxis - m.YAxis, ZAxis - m.ZAxis, Position - m.Position };
|
||||
return { Row1 - m.Row1, Row2 - m.Row2, Row3 - m.Row3 };
|
||||
}
|
||||
Mtx34 Mtx34::operator*(const Mtx34& scalar) const {
|
||||
return { XAxis * scalar.XAxis, YAxis * scalar.YAxis, ZAxis * scalar.ZAxis, Position * scalar.Position };
|
||||
return { Row1 * scalar.Row1, Row2 * scalar.Row2, Row3 * scalar.Row3 };
|
||||
}
|
||||
Mtx34 Mtx34::operator/(const Mtx34& scalar) const {
|
||||
return { XAxis / scalar.XAxis, YAxis / scalar.YAxis, ZAxis / scalar.ZAxis, Position / scalar.Position };
|
||||
return { Row1 / scalar.Row1, Row2 / scalar.Row2, Row3 / scalar.Row3 };
|
||||
}
|
||||
Mtx34 Mtx34::operator*(const Vec3& scalar) const {
|
||||
return { XAxis * scalar, YAxis * scalar, ZAxis * scalar, Position * scalar };
|
||||
Mtx34 Mtx34::operator*(const Vec4& scalar) const {
|
||||
return { Row1 * scalar, Row2 * scalar, Row3 * scalar };
|
||||
}
|
||||
Mtx34 Mtx34::operator/(const Vec3& scalar) const {
|
||||
return { XAxis / scalar, YAxis / scalar, ZAxis / scalar, Position / scalar };
|
||||
Mtx34 Mtx34::operator/(const Vec4& scalar) const {
|
||||
return { Row1 / scalar, Row2 / scalar, Row3 / scalar };
|
||||
}
|
||||
|
||||
Vec3 Mtx34::TransformPosition(const Vec3& v) const {
|
||||
return {
|
||||
XAxis.X * v.X + YAxis.X * v.Y + ZAxis.X * v.Z + Position.X,
|
||||
XAxis.Y * v.X + YAxis.Y * v.Y + ZAxis.Y * v.Z + Position.Y,
|
||||
XAxis.Z * v.X + YAxis.Z * v.Y + ZAxis.Z * v.Z + Position.Z
|
||||
};
|
||||
}
|
||||
void Mtx34::Normalize() {
|
||||
XAxis = XAxis.normalize();
|
||||
YAxis = YAxis.normalize();
|
||||
ZAxis = ZAxis.normalize();
|
||||
}
|
||||
Vec3 Mtx34::GetXAxis() const {
|
||||
return Vec3(Row1.X, Row2.X, Row3.X);
|
||||
}
|
||||
Vec3 Mtx34::GetYAxis() const {
|
||||
return Vec3(Row1.Y, Row2.Y, Row3.Y);
|
||||
}
|
||||
Vec3 Mtx34::GetZAxis() const {
|
||||
return Vec3(Row1.Z, Row2.Z, Row3.Z);
|
||||
}
|
||||
Vec3 Mtx34::GetPosition() const {
|
||||
return Vec3(Row1.W, Row2.W, Row3.W);
|
||||
}
|
||||
|
||||
Mtx34 Mtx34::TransposeRotation() const {
|
||||
return Mtx34(
|
||||
Vec3(XAxis.X, YAxis.X, ZAxis.X),
|
||||
Vec3(XAxis.Y, YAxis.Y, ZAxis.Y),
|
||||
Vec3(XAxis.Z, YAxis.Z, ZAxis.Z),
|
||||
Position
|
||||
);
|
||||
Mtx34 Mtx34::normalize() {
|
||||
return { Row1.normalize(), Row2.normalize(), Row3.normalize() };
|
||||
}
|
||||
}
|
@ -41,7 +41,10 @@ namespace EGSDK {
|
||||
return { X / scalar, Y / scalar, Z / scalar };
|
||||
}
|
||||
|
||||
Vec3 Vec3::normalize() {
|
||||
Vec3 Vec3::normalize() const {
|
||||
if (isDefault())
|
||||
return *this;
|
||||
|
||||
float length = std::sqrt(X * X + Y * Y + Z * Z);
|
||||
return { X / length, Y / length, Z / length };
|
||||
}
|
||||
@ -52,6 +55,9 @@ namespace EGSDK {
|
||||
X * v.Y - Y * v.X
|
||||
};
|
||||
}
|
||||
float Vec3::dot(const Vec3& v) const {
|
||||
return (X * v.X) + (Y * v.Y) + (Z * v.Z);
|
||||
}
|
||||
Vec3 Vec3::round() {
|
||||
return { std::roundf(X), std::roundf(Y), std::roundf(Z) };
|
||||
}
|
||||
|
61
EGameSDK/src/Vec4.cpp
Normal file
61
EGameSDK/src/Vec4.cpp
Normal file
@ -0,0 +1,61 @@
|
||||
#define _USE_MATH_DEFINES
|
||||
#include <cmath>
|
||||
#include <EGSDK\Vec4.h>
|
||||
#include <EGSDK\Utils\Values.h>
|
||||
|
||||
namespace EGSDK {
|
||||
Vec4::Vec4() : X(0.0f), Y(0.0f), Z(0.0f), W(0.0f) {}
|
||||
Vec4::Vec4(float x, float y, float z, float w) : X(x), Y(y), Z(z), W(w) {}
|
||||
|
||||
bool Vec4::operator==(const Vec4& v) const {
|
||||
return Utils::Values::are_samef(X, v.X) && Utils::Values::are_samef(Y, v.Y) && Utils::Values::are_samef(Z, v.Z) && Utils::Values::are_samef(W, v.W);
|
||||
}
|
||||
Vec4& Vec4::operator+=(const Vec4& v) {
|
||||
X += v.X;
|
||||
Y += v.Y;
|
||||
Z += v.Z;
|
||||
W += v.W;
|
||||
return *this;
|
||||
}
|
||||
Vec4& Vec4::operator-=(const Vec4& v) {
|
||||
X -= v.X;
|
||||
Y -= v.Y;
|
||||
Z -= v.Z;
|
||||
W -= v.W;
|
||||
return *this;
|
||||
}
|
||||
Vec4 Vec4::operator+(const Vec4& v) const {
|
||||
return { X + v.X, Y + v.Y, Z + v.Z, W + v.W };
|
||||
}
|
||||
Vec4 Vec4::operator-(const Vec4& v) const {
|
||||
return { X - v.X, Y - v.Y, Z - v.Z, W - v.W };
|
||||
}
|
||||
Vec4 Vec4::operator*(const Vec4& scalar) const {
|
||||
return { X * scalar.X, Y * scalar.Y, Z * scalar.Z, W * scalar.W };
|
||||
}
|
||||
Vec4 Vec4::operator/(const Vec4& scalar) const {
|
||||
return { X / scalar.X, Y / scalar.Y, Z / scalar.Z, W / scalar.W };
|
||||
}
|
||||
Vec4 Vec4::operator*(float scalar) const {
|
||||
return { X * scalar, Y * scalar, Z * scalar, W * scalar };
|
||||
}
|
||||
Vec4 Vec4::operator/(float scalar) const {
|
||||
return { X / scalar, Y / scalar, Z / scalar, W / scalar };
|
||||
}
|
||||
|
||||
Vec4 Vec4::normalize() const {
|
||||
float length = std::sqrt(X * X + Y * Y + Z * Z + W * W);
|
||||
return { X / length, Y / length, Z / length, W / length };
|
||||
}
|
||||
Vec4 Vec4::round() {
|
||||
return { std::roundf(X), std::roundf(Y), std::roundf(Z), std::roundf(W) };
|
||||
}
|
||||
Vec4 Vec4::round(int decimals) {
|
||||
float power = std::powf(10.0f, static_cast<float>(decimals));
|
||||
return { std::roundf(X * power) / power, std::roundf(Y * power) / power, std::roundf(Z * power) / power, std::roundf(W * power) / power };
|
||||
}
|
||||
|
||||
bool Vec4::isDefault() const {
|
||||
return Utils::Values::are_samef(X, 0.0f) && Utils::Values::are_samef(Y, 0.0f) && Utils::Values::are_samef(Z, 0.0f) && Utils::Values::are_samef(W, 0.0f);
|
||||
}
|
||||
}
|
@ -170,12 +170,14 @@ I have some things planned for the next updates, but time will decide when I'll
|
||||
|
||||
- Changed DirectX 11 and DirectX 12 hooks to be more reliable and less likely to crash the game
|
||||
- Fixed time and weather changing taking a long time to apply (now it is instant!)
|
||||
- Fixed random classes not getting detected properly, resulting in NULL values in the Debug tab, which was caused by unreliable class vftable scanning which can now be disabled through the "Disable Vftable Scanning" in the Debug tab in case of class detection issues
|
||||
|
||||
- Fixed game progression not working properly if you modify Player Variables related to game progression, because game and mod Player Variables interfere with each other
|
||||
- Fixed ownership of Player Variables managed by EGameTools, removing conflict in managing Player Variables between different modules (e.g. Player and World) and any bugs associated with this issue
|
||||
- Fixed conflict between ImGui state and Player Variables list, causing the game to crash when changing Player Variables
|
||||
- Fixed random crashes related to Player Variables (if you still experience crashes at startup, please open a bug report)
|
||||
- Fixed Free Camera orientation resetting back to player orientation after pausing and unpausing the game
|
||||
- Fixed FOV slider not affecting Third Person Camera
|
||||
- Fixed random classes not getting detected properly, resulting in NULL values in the Debug tab, which was caused by unreliable class vftable scanning which can now be disabled through the "Disable Vftable Scanning" in the Debug tab in case of class detection issues
|
||||
- Fixed not all options in the mod menu being disabled whilst the game is starting up)" }
|
||||
};
|
||||
}
|
@ -6,8 +6,6 @@
|
||||
|
||||
namespace EGT::Engine {
|
||||
namespace Hooks {
|
||||
extern bool switchedFreeCamByGamePause;
|
||||
extern EGSDK::Vec3 freeCamPosBeforeGamePause;
|
||||
extern int mountDataPaksRanWith8Count;
|
||||
|
||||
extern EGSDK::Utils::Hook::MHook<void*, DWORD64(*)(DWORD64, DWORD, DWORD), DWORD64, DWORD, DWORD> FsOpenHook;
|
||||
|
@ -1,3 +1,5 @@
|
||||
#define _USE_MATH_DEFINES
|
||||
#include <cmath>
|
||||
#include <filesystem>
|
||||
#include <EGSDK\Utils\Time.h>
|
||||
#include <EGSDK\Utils\WinMemory.h>
|
||||
@ -5,6 +7,7 @@
|
||||
#include <EGSDK\Engine\RendererCVars.h>
|
||||
#include <EGSDK\Engine\CBaseCamera.h>
|
||||
#include <EGSDK\Engine\Engine_Misc.h>
|
||||
#include <EGSDK\GamePH\FreeCamera.h>
|
||||
#include <EGSDK\Offsets.h>
|
||||
#include <EGT\Engine\Engine_Hooks.h>
|
||||
#include <EGT\Menu\Camera.h>
|
||||
@ -13,27 +16,42 @@
|
||||
namespace EGT::Engine {
|
||||
namespace Hooks {
|
||||
#pragma region MoveCameraFromForwardUpPos
|
||||
bool switchedFreeCamByGamePause = false;
|
||||
EGSDK::Vec3 freeCamPosBeforeGamePause{};
|
||||
static bool switchedFreeCamByGamePause = false;
|
||||
static EGSDK::Vec3 freeCamPosBeforeGamePause{};
|
||||
static EGSDK::Vec3 freeCamTargetDirBeforeGamePause{};
|
||||
static EGSDK::Vec3 freeCamUpDirBeforeGamePause{};
|
||||
|
||||
static EGSDK::Utils::Hook::MHook<void*, void(*)(void*, float*, float*, EGSDK::Vec3*), void*, float*, float*, EGSDK::Vec3*> MoveCameraFromForwardUpPosHook{ "MoveCameraFromForwardUpPos", &EGSDK::OffsetManager::Get_MoveCameraFromForwardUpPos, [](void* pCBaseCamera, float* a3, float* a4, EGSDK::Vec3* pos) -> void {
|
||||
static EGSDK::Utils::Hook::MHook<void*, void(*)(void*, EGSDK::Vec3*, EGSDK::Vec3*, EGSDK::Vec3*), void*, EGSDK::Vec3*, EGSDK::Vec3*, EGSDK::Vec3*> MoveCameraFromForwardUpPosHook{ "MoveCameraFromForwardUpPos", &EGSDK::OffsetManager::Get_MoveCameraFromForwardUpPos, [](void* pCBaseCamera, EGSDK::Vec3* targetDirection, EGSDK::Vec3* upDirection, EGSDK::Vec3* pos) -> void {
|
||||
auto iLevel = EGSDK::GamePH::LevelDI::Get();
|
||||
if (!iLevel || !iLevel->IsLoaded() || iLevel->IsTimerFrozen())
|
||||
return MoveCameraFromForwardUpPosHook.ExecuteCallbacksWithOriginal(pCBaseCamera, a3, a4, pos);
|
||||
if (!pos)
|
||||
return;
|
||||
|
||||
if (Menu::Camera::freeCam.GetValue() && switchedFreeCamByGamePause) {
|
||||
switchedFreeCamByGamePause = false;
|
||||
*pos = freeCamPosBeforeGamePause;
|
||||
return MoveCameraFromForwardUpPosHook.ExecuteCallbacksWithOriginal(pCBaseCamera, a3, a4, pos);
|
||||
if (!iLevel || !iLevel->IsLoaded())
|
||||
return MoveCameraFromForwardUpPosHook.ExecuteCallbacksWithOriginal(pCBaseCamera, targetDirection, upDirection, pos);
|
||||
if (iLevel->IsTimerFrozen()) {
|
||||
switchedFreeCamByGamePause = Menu::Camera::freeCam.GetValue() && iLevel->IsTimerFrozen();
|
||||
return MoveCameraFromForwardUpPosHook.ExecuteCallbacksWithOriginal(pCBaseCamera, targetDirection, upDirection, pos);
|
||||
}
|
||||
if ((!Menu::Camera::thirdPersonCamera.GetValue() && Menu::Camera::cameraOffset.isDefault()) || Menu::Camera::photoMode.GetValue() || Menu::Camera::freeCam.GetValue())
|
||||
return MoveCameraFromForwardUpPosHook.ExecuteCallbacksWithOriginal(pCBaseCamera, a3, a4, pos);
|
||||
if (!targetDirection || !upDirection || !pos)
|
||||
return;
|
||||
|
||||
auto viewCam = static_cast<EGSDK::Engine::CBaseCamera*>(iLevel->GetViewCamera());
|
||||
if (!viewCam)
|
||||
return MoveCameraFromForwardUpPosHook.ExecuteCallbacksWithOriginal(pCBaseCamera, a3, a4, pos);
|
||||
return MoveCameraFromForwardUpPosHook.ExecuteCallbacksWithOriginal(pCBaseCamera, targetDirection, upDirection, pos);
|
||||
|
||||
if (Menu::Camera::freeCam.GetValue() && viewCam == EGSDK::GamePH::FreeCamera::Get()) {
|
||||
if (switchedFreeCamByGamePause) {
|
||||
switchedFreeCamByGamePause = false;
|
||||
*pos = freeCamPosBeforeGamePause;
|
||||
*targetDirection = freeCamTargetDirBeforeGamePause;
|
||||
*upDirection = freeCamUpDirBeforeGamePause;
|
||||
} else {
|
||||
freeCamPosBeforeGamePause = *pos;
|
||||
freeCamTargetDirBeforeGamePause = *targetDirection;
|
||||
freeCamUpDirBeforeGamePause = *upDirection;
|
||||
}
|
||||
return MoveCameraFromForwardUpPosHook.ExecuteCallbacksWithOriginal(pCBaseCamera, targetDirection, upDirection, pos);
|
||||
}
|
||||
|
||||
if ((!Menu::Camera::thirdPersonCamera.GetValue() && Menu::Camera::cameraOffset.isDefault()) || Menu::Camera::photoMode.GetValue() || Menu::Camera::freeCam.GetValue())
|
||||
return MoveCameraFromForwardUpPosHook.ExecuteCallbacksWithOriginal(pCBaseCamera, targetDirection, upDirection, pos);
|
||||
|
||||
EGSDK::Vec3 forwardVec, upVec, leftVec = {};
|
||||
viewCam->GetForwardVector(&forwardVec);
|
||||
@ -57,7 +75,7 @@ namespace EGT::Engine {
|
||||
}
|
||||
|
||||
*pos = newCamPos;
|
||||
MoveCameraFromForwardUpPosHook.ExecuteCallbacksWithOriginal(pCBaseCamera, a3, a4, pos);
|
||||
MoveCameraFromForwardUpPosHook.ExecuteCallbacksWithOriginal(pCBaseCamera, targetDirection, upDirection, pos);
|
||||
} };
|
||||
#pragma endregion
|
||||
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include <EGSDK\GamePH\PlayerDI_PH.h>
|
||||
#include <EGSDK\GamePH\GamePH_Misc.h>
|
||||
#include <EGSDK\Offsets.h>
|
||||
#include <EGT\Engine\Engine_Hooks.h>
|
||||
#include <EGT\Menu\Camera.h>
|
||||
#include <EGT\Menu\Menu.h>
|
||||
|
||||
@ -195,8 +194,6 @@ namespace EGT::Menu {
|
||||
pFreeCam->speedMultiplier *= 2.0f;
|
||||
else if (ImGui::IsKeyDown(ImGuiKey_LeftAlt))
|
||||
pFreeCam->speedMultiplier /= 2.0f;
|
||||
|
||||
pFreeCam->GetPosition(&EGT::Engine::Hooks::freeCamPosBeforeGamePause);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -207,8 +204,6 @@ namespace EGT::Menu {
|
||||
pGameDI_PH->TogglePhotoMode();
|
||||
pFreeCam->AllowCameraMovement(2);
|
||||
} else {
|
||||
Engine::Hooks::switchedFreeCamByGamePause = freeCam.GetValue() && iLevel->IsTimerFrozen();
|
||||
|
||||
if (prevFreeCam) {
|
||||
pFreeCam->enableSpeedMultiplier1 = prevEnableSpeedMultiplier;
|
||||
pFreeCam->speedMultiplier = prevSpeedMultiplier;
|
||||
|
Reference in New Issue
Block a user