#pragma once #include #include #include #include #include #include #include "core.h" #include "hook.h" #include "utils.h" #define STR_MERGE_IMPL(a, b) a##b #define STR_MERGE(a, b) STR_MERGE_IMPL(a, b) #define MAKE_PAD(size) STR_MERGE(_pad, __COUNTER__)[size] #define DEFINE_MEMBER_N(type, name, offset) struct {unsigned char MAKE_PAD(offset); type name;} #define DEFINE_MEMBER_0(type, name) struct {type name;} // Game structs struct Vector3 { float X, Y, Z; bool operator==(const Vector3& v) const { return Utils::are_same(X, v.X) && Utils::are_same(Y, v.Y) && Utils::are_same(Z, v.Z); } Vector3& operator+=(const Vector3& v) { X += v.X; Y += v.Y; Z += v.Z; return *this; } Vector3& operator-=(const Vector3& v) { X -= v.X; Y -= v.Y; Z -= v.Z; return *this; } Vector3 operator+(const Vector3& v) const { return { X + v.X, Y + v.Y, Z + v.Z }; } Vector3 operator-(const Vector3& v) const { return { X - v.X, Y - v.Y, Z - v.Z }; } Vector3 operator*(float scalar) const { return { X * scalar, Y * scalar, Z * scalar }; } Vector3 operator/(float scalar) const { return { X / scalar, Y / scalar, Z / scalar }; } Vector3 normalize() { float length = std::sqrt(X * X + Y * Y + Z * Z); return { X / length, Y / length, Z / length }; } Vector3 cross(const Vector3& v) const { return { Y * v.Z - Z * v.Y, Z * v.X - X * v.Z, X * v.Y - Y * v.X }; } bool isDefault() const { return Utils::are_same(X, 0.0f) && Utils::are_same(Y, 0.0f) && Utils::are_same(Z, 0.0f); } }; namespace EWeather { enum TYPE { Default = 0, Foggy = 1, Clear = 2, Overcast = 3, Cloudy = 4, Rainy = 5, Stormy = 6 }; } // Forward decl namespace Engine { class CBaseCamera { public: /*union { DEFINE_MEMBER_N(float, yaw, 0x48); DEFINE_MEMBER_N(float, X, 0x4C); DEFINE_MEMBER_N(float, pitch, 0x58); DEFINE_MEMBER_N(float, Y, 0x5C); DEFINE_MEMBER_N(float, Z, 0x6C); };*/ Vector3* GetForwardVector(Vector3* outForwardVec); Vector3* GetUpVector(Vector3* outUpVec); Vector3* GetLeftVector(Vector3* outLeftVec); Vector3* GetPosition(Vector3* outPos); }; class CoPhysicsProperty; class CRTTI; class CRTTIObject; // Inheritance classes class CRTTIField { public: DWORD64 Get_vec3(CRTTIObject* crtti, Vector3& out); }; class CRTTI { public: CRTTIField* FindField(char const* name); }; class CRTTIObject { public: CRTTIField* FindField(char const* name); }; class CRTTIManager { public: CRTTIManager* Get(); }; } namespace GamePH { extern const std::string GameVerToStr(DWORD64 version); extern const std::string GetCurrentGameVersionStr(); extern const DWORD64 GetCurrentGameVersion(); extern void ShowTPPModel(bool showTPPModel); extern bool ReloadJumps(); class PlayerVariables { public: static std::vector>> playerVars; static std::vector>> playerVarsDefault; static std::vector>> playerCustomVarsDefault; static bool gotPlayerVars; static void GetPlayerVars(); static void SortPlayerVars(); template static T GetPlayerVar(const std::string& playerVar) { static_assert(std::is_same::value || std::is_same::value || std::is_same::value, "Invalid type: value must be bool, float or string"); auto it = std::find_if(PlayerVariables::playerVars.begin(), PlayerVariables::playerVars.end(), [&playerVar](const auto& pair) { return pair.first == playerVar; }); if (it == PlayerVariables::playerVars.end()) { if (std::is_same::value) return {}; else if (std::is_same::value) return -404.0f; else return false; } return *reinterpret_cast(it->second.first); } template static void ChangePlayerVar(const std::string& playerVar, const T value) { static_assert(std::is_same::value || std::is_same::value || std::is_same::value, "Invalid type: value must be bool, float or string"); if (!gotPlayerVars) return; auto it = std::find_if(PlayerVariables::playerVars.begin(), PlayerVariables::playerVars.end(), [&playerVar](const auto& pair) { return pair.first == playerVar; }); if (it == PlayerVariables::playerVars.end()) return; if (std::is_same::value) { std::string valueStr = Utils::to_string(value); if (it->second.second == "float") { float* const varValue = reinterpret_cast(it->second.first); const float actualValue = std::stof(valueStr); *varValue = actualValue; *(varValue + 1) = actualValue; } else { bool* const varValue = reinterpret_cast(it->second.first); const bool actualValue = valueStr == "true"; *varValue = actualValue; *(varValue + 1) = actualValue; } } else { T* const varValue = reinterpret_cast(it->second.first); *varValue = value; *(varValue + 1) = value; } } template static void ManagePlayerVarOption(const std::string& playerVar, const T valueIfTrue, const T valueIfFalse, Option* option, const bool& usePreviousVal = true) { if (!gotPlayerVars) return; static T previousPlayerVarValue = GamePH::PlayerVariables::GetPlayerVar(playerVar); if (option->GetValue()) { if (!option->GetPrevValue()) previousPlayerVarValue = GamePH::PlayerVariables::GetPlayerVar(playerVar); GamePH::PlayerVariables::ChangePlayerVar(playerVar, valueIfTrue); option->SetPrevValue(true); } else if (option->GetPrevValue()) { option->SetPrevValue(false); GamePH::PlayerVariables::ChangePlayerVar(playerVar, usePreviousVal ? previousPlayerVarValue : valueIfFalse); } } static PlayerVariables* Get(); }; class PlayerState { public: union { DEFINE_MEMBER_N(PlayerVariables*, playerVars, 0x290); }; static PlayerState* Get(); }; class PlayerHealthModule { public: union { DEFINE_MEMBER_N(float, health, 0x2C); DEFINE_MEMBER_N(float, maxHealth, 0x3C); }; static PlayerHealthModule* pPlayerHealthModule; static PlayerHealthModule* Get(); }; class TPPCameraDI : public Engine::CBaseCamera { public: static TPPCameraDI* Get(); }; class CameraFPPDI : public Engine::CBaseCamera { public: union { DEFINE_MEMBER_N(Engine::CBaseCamera*, pCBaseCamera, 0x38); }; //static CameraFPPDI* Get(); }; class CoBaseCameraProxy { public: union { DEFINE_MEMBER_N(TPPCameraDI*, pTPPCameraDI, 0xD0); }; }; class FreeCamera : public Engine::CBaseCamera { public: union { DEFINE_MEMBER_N(CoBaseCameraProxy*, pCoBaseCameraProxy, 0x18); DEFINE_MEMBER_N(Engine::CBaseCamera*, pCBaseCamera, 0x38); DEFINE_MEMBER_N(bool, enableSpeedMultiplier1, 0x42); DEFINE_MEMBER_N(bool, enableSpeedMultiplier2, 0x43); DEFINE_MEMBER_N(float, speedMultiplier, 0x1CC); }; void AllowCameraMovement(int mode = 2); static FreeCamera* Get(); }; class DayNightCycle { public: union { DEFINE_MEMBER_N(float, time1, 0x10); DEFINE_MEMBER_N(float, time2, 0x20); DEFINE_MEMBER_N(float, time3, 0x5C); }; void SetDaytime(float time); static DayNightCycle* Get(); }; namespace TimeWeather { class CSystem { public: void SetForcedWeather(int weather); int GetCurrentWeather(); static CSystem* Get(); }; } class LevelDI { public: bool IsLoading(); bool IsLoaded(); LPVOID GetViewCamera(); float GetTimeDelta(); void SetViewCamera(LPVOID viewCam); float GetTimePlayed(); void ShowUIManager(bool enabled); float TimerGetSpeedUp(); void TimerSetSpeedUp(float timeScale); TimeWeather::CSystem* GetTimeWeatherSystem(); static LevelDI* Get(); }; class gen_TPPModel { public: union { DEFINE_MEMBER_N(bool, enableTPPModel1, 0x2CF9); DEFINE_MEMBER_N(bool, enableTPPModel2, 0x2CFA); }; static gen_TPPModel* Get(); }; class LocalClientDI { public: union { DEFINE_MEMBER_N(gen_TPPModel*, pgen_TPPModel, 0x90); }; static LocalClientDI* Get(); }; class SessionCooperativeDI { public: union { DEFINE_MEMBER_N(LocalClientDI*, pLocalClientDI, 0xE08); }; static SessionCooperativeDI* Get(); }; class GameDI_PH2 { public: static GameDI_PH2* Get(); }; class GameDI_PH { public: union { DEFINE_MEMBER_N(SessionCooperativeDI*, pSessionCooperativeDI, 0xF0); DEFINE_MEMBER_N(bool, blockPauseGameOnPlayerAfk, 0x830); }; float GetGameTimeDelta(); DWORD64 GetCurrentGameVersion(); void TogglePhotoMode(bool doNothing = false, bool setAsOptionalCamera = false); static GameDI_PH* Get(); }; class PlayerObjProperties { public: union { DEFINE_MEMBER_N(Engine::CoPhysicsProperty*, pCoPhysicsProperty, 0xF0); DEFINE_MEMBER_N(bool, isOutOfBounds, 0x2E80); DEFINE_MEMBER_N(float, outOfBoundsTimer, 0x2E84); }; static PlayerObjProperties* Get(); }; class LogicalPlayer : public Engine::CRTTIObject { public: static LogicalPlayer* Get(); }; } namespace Engine { class CVideoSettings { public: union { DEFINE_MEMBER_N(float, extraFOV, 0x7C); }; static CVideoSettings* Get(); }; class CGSObject2 { public: union { DEFINE_MEMBER_N(GamePH::LogicalPlayer*, pLogicalPlayer, 0x20); }; static CGSObject2* Get(); }; class CLevel2 { public: union { DEFINE_MEMBER_N(CGSObject2*, pCGSObject2, 0x28); }; static CLevel2* Get(); }; class CGSObject { public: union { DEFINE_MEMBER_N(CLevel2*, pCLevel2, 0x48); }; static CGSObject* Get(); }; class CLevel { public: union { DEFINE_MEMBER_N(GamePH::LevelDI*, pLevelDI, 0x20); DEFINE_MEMBER_N(CGSObject*, pCGSObject, 0x30); }; static CLevel* Get(); }; class CGame { public: union { DEFINE_MEMBER_N(GamePH::GameDI_PH*, pGameDI_PH, 0x8); DEFINE_MEMBER_N(CVideoSettings*, pCVideoSettings, 0x28); DEFINE_MEMBER_N(CLevel*, pCLevel, 0x380); }; static CGame* Get(); }; class CLobbySteam { public: union { DEFINE_MEMBER_N(CGame*, pCGame, 0xF8); }; static CLobbySteam* Get(); }; class CInput { public: DWORD64 BlockGameInput(); void UnlockGameInput(); static CInput* Get(); }; class CBulletPhysicsCharacter { public: union { DEFINE_MEMBER_N(Vector3, playerPos2, 0x8A0); DEFINE_MEMBER_N(Vector3, playerPos, 0x8B8); DEFINE_MEMBER_N(float, playerDownwardVelocity, 0xC38); }; static Vector3 posBeforeFreeze; void FreezeCharacter(); void MoveCharacter(const Vector3& pos); static CBulletPhysicsCharacter* Get(); }; class CoPhysicsProperty { public: union { DEFINE_MEMBER_N(CBulletPhysicsCharacter*, pCBulletPhysicsCharacter, 0x20); }; static CoPhysicsProperty* Get(); }; } #undef DEFINE_MEMBER_0 #undef DEFINE_MEMBER_N #undef MAKE_PAD #undef STR_MERGE #undef STR_MERGE_IMPL