diff options
Diffstat (limited to 'source2-basehook/Source2SDK')
| -rw-r--r-- | source2-basehook/Source2SDK/CEngineClient.hpp | 54 | ||||
| -rw-r--r-- | source2-basehook/Source2SDK/CEngineVGUI.hpp | 13 | ||||
| -rw-r--r-- | source2-basehook/Source2SDK/CGlobalVarsBase.hpp | 18 | ||||
| -rw-r--r-- | source2-basehook/Source2SDK/CSource2Client.hpp | 41 | ||||
| -rw-r--r-- | source2-basehook/Source2SDK/CUserCmd.hpp | 50 | ||||
| -rw-r--r-- | source2-basehook/Source2SDK/ClientClass.hpp | 21 | ||||
| -rw-r--r-- | source2-basehook/Source2SDK/Color.hpp | 20 | ||||
| -rw-r--r-- | source2-basehook/Source2SDK/IClientModeShared.hpp | 9 | ||||
| -rw-r--r-- | source2-basehook/Source2SDK/ISurface.hpp | 171 | ||||
| -rw-r--r-- | source2-basehook/Source2SDK/QAngle.hpp | 338 | ||||
| -rw-r--r-- | source2-basehook/Source2SDK/SDK.cpp | 10 | ||||
| -rw-r--r-- | source2-basehook/Source2SDK/SDK.hpp | 17 | ||||
| -rw-r--r-- | source2-basehook/Source2SDK/Schema.hpp | 27 | ||||
| -rw-r--r-- | source2-basehook/Source2SDK/Vector.hpp | 252 |
14 files changed, 1041 insertions, 0 deletions
diff --git a/source2-basehook/Source2SDK/CEngineClient.hpp b/source2-basehook/Source2SDK/CEngineClient.hpp new file mode 100644 index 0000000..de556e9 --- /dev/null +++ b/source2-basehook/Source2SDK/CEngineClient.hpp @@ -0,0 +1,54 @@ +#pragma once + +class CEngineClient +{ +public: + virtual void Unknown1() = 0; + virtual void Unknown2() = 0; + virtual void Unknown3() = 0; + virtual void Unknown4() = 0; + virtual void Unknown5() = 0; + virtual void Unknown6() = 0; + virtual void Unknown7() = 0; + virtual void Unknown8() = 0; + virtual void Unknown9() = 0; + virtual void Unknown10() = 0; + virtual void Unknown11() = 0; + virtual void Unknown12() = 0; + virtual void Unknown13() = 0; + virtual void Unknown14() = 0; + virtual void Unknown15() = 0; + virtual void Unknown16() = 0; + virtual void Unknown17() = 0; + virtual void Unknown18() = 0; + virtual void Unknown19() = 0; + virtual void Unknown20(); + virtual void Unknown21() = 0; + virtual int GetLocalPlayer(int) = 0; + virtual void Unknown23() = 0; + virtual void Unknown24() = 0; + virtual void Unknown25() = 0; + virtual void Unknown26() = 0; + virtual int GetMaxClients(void) = 0; + virtual bool IsInGame(void) = 0; + virtual bool IsConnected(void) = 0; + virtual void Unknown31() = 0; + virtual void Unknown32() = 0; + virtual void Unknown33() = 0; + virtual void Unknown34() = 0; + virtual void Unknown35() = 0; + virtual void Unknown36() = 0; + virtual void Unknown37() = 0; + virtual void ClientCmd_Unrestricted(const char* szCmdString) = 0; + virtual void Unknown39() = 0; + + int GetLocalPlayer() + { + int Out = 0; + using oFn = int* (__thiscall*)(CEngineClient*, int&, int); + (CallVfunc<oFn>(this, 22))(this, Out, 0); + return Out; + } +}; + +extern CEngineClient* pEngine;
\ No newline at end of file diff --git a/source2-basehook/Source2SDK/CEngineVGUI.hpp b/source2-basehook/Source2SDK/CEngineVGUI.hpp new file mode 100644 index 0000000..937ae24 --- /dev/null +++ b/source2-basehook/Source2SDK/CEngineVGUI.hpp @@ -0,0 +1,13 @@ +#pragma once + +class IVPanel +{ +public: + const char* GetName(void* ptr, unsigned long long vguiPanel) + { + typedef const char* (__thiscall* OriginalFn)(void*, unsigned long long); + return CallVfunc<OriginalFn>(ptr, 50)(ptr, vguiPanel); + } +}; + +extern IVPanel* pPanel;
\ No newline at end of file diff --git a/source2-basehook/Source2SDK/CGlobalVarsBase.hpp b/source2-basehook/Source2SDK/CGlobalVarsBase.hpp new file mode 100644 index 0000000..ebdd799 --- /dev/null +++ b/source2-basehook/Source2SDK/CGlobalVarsBase.hpp @@ -0,0 +1,18 @@ +#pragma once + +class CGlobalVarsBase +{ +public: + float realtime; //0x0000 + int32_t framecount; //0x0004 + float absoluteframetime; //0x0008 + float curtime; //0x000C + float frameTime; //0x0010 + int32_t maxclients; //0x0014 + int32_t tickcount; //0x0018 + float interval_per_tick; //0x001C + float frametime2; //0x0020 + float interpolation_amount; //0x0024 +}; + +extern CGlobalVarsBase* pGlobals;
\ No newline at end of file diff --git a/source2-basehook/Source2SDK/CSource2Client.hpp b/source2-basehook/Source2SDK/CSource2Client.hpp new file mode 100644 index 0000000..e26764b --- /dev/null +++ b/source2-basehook/Source2SDK/CSource2Client.hpp @@ -0,0 +1,41 @@ +#pragma once +#include "ClientClass.hpp" + +class CSource2Client +{ +public: + virtual void Unknown1() = 0; + virtual void Disconnect(void) = 0; + virtual void Unknown3() = 0; + virtual void Unknown4() = 0; + virtual void Shutdown(void) = 0; + virtual void Unknown6() = 0; + virtual void Unknown7() = 0; + virtual void Unknown8() = 0; + virtual void Unknown9() = 0; + virtual void Unknown10() = 0; + virtual void Unknown11() = 0; + virtual void SetGlobals(void* CGlobalVarsBase) = 0; + virtual void Unknown13() = 0; + virtual void Unknown14() = 0; + virtual void Unknown15() = 0; + virtual void Unknown16() = 0; + virtual void Unknown17() = 0; + virtual void Unknown18() = 0; + virtual void Unknown19() = 0; + virtual void Unknown20() = 0; + virtual void Unknown21() = 0; + virtual void Unknown22() = 0; + virtual void Unknown23() = 0; + virtual void Unknown24() = 0; + virtual void Unknown25() = 0; + virtual void Unknown26() = 0; + virtual void Unknown27() = 0; + virtual ClientClass* GetAllClasses(void) = 0; + virtual void Unknown28() = 0; + virtual void Unknown29() = 0; + virtual void Unknown30() = 0; + virtual void HudUpdate(bool bActive) = 0; +}; + +extern CSource2Client* pClient;
\ No newline at end of file diff --git a/source2-basehook/Source2SDK/CUserCmd.hpp b/source2-basehook/Source2SDK/CUserCmd.hpp new file mode 100644 index 0000000..7c829dc --- /dev/null +++ b/source2-basehook/Source2SDK/CUserCmd.hpp @@ -0,0 +1,50 @@ +#pragma once +#include "Vector.hpp" +#include "QAngle.hpp" + +#define IN_ATTACK (1 << 0) +#define IN_JUMP (1 << 1) +#define IN_DUCK (1 << 2) +#define IN_FORWARD (1 << 3) +#define IN_BACK (1 << 4) +#define IN_USE (1 << 5) +#define IN_CANCEL (1 << 6) +#define IN_LEFT (1 << 7) +#define IN_RIGHT (1 << 8) +#define IN_MOVELEFT (1 << 9) +#define IN_MOVERIGHT (1 << 10) +#define IN_ATTACK2 (1 << 11) +#define IN_RUN (1 << 12) +#define IN_RELOAD (1 << 13) +#define IN_ALT1 (1 << 14) +#define IN_ALT2 (1 << 15) +#define IN_SCORE (1 << 16) // Used by client.dll for when scoreboard is held down +#define IN_SPEED (1 << 17) // Player is holding the speed key +#define IN_WALK (1 << 18) // Player holding walk key +#define IN_ZOOM (1 << 19) // Zoom key for HUD zoom +#define IN_WEAPON1 (1 << 20) // weapon defines these bits +#define IN_WEAPON2 (1 << 21) // weapon defines these bits +#define IN_BULLRUSH (1 << 22) +#define IN_GRENADE1 (1 << 23) // grenade 1 +#define IN_GRENADE2 (1 << 24) // grenade 2 +#define IN_ATTACK3 (1 << 25) + +class CUserCmd +{ +public: + virtual ~CUserCmd() {}; + int32_t command_number; //0x0008 + int32_t tick_count; //0x000C + QAngle viewangles; //0x0010 + Vector aimdirection; //0x001C + int32_t buttons; //0x0028 + int32_t unknown; + BYTE impulse; + int32_t weaponselect; //0x0034 + int32_t weaponsubtype; //0x0038 + int32_t random_seed; //0x003C + short mousedx; + short mousedy; +}; + +extern CUserCmd* pCmd;
\ No newline at end of file diff --git a/source2-basehook/Source2SDK/ClientClass.hpp b/source2-basehook/Source2SDK/ClientClass.hpp new file mode 100644 index 0000000..cf6806c --- /dev/null +++ b/source2-basehook/Source2SDK/ClientClass.hpp @@ -0,0 +1,21 @@ +#pragma once +#include "Schema.hpp" +//Greets to Praydog + +class ClientClass +{ +public: + char* m_pNetworkName; //0x0000 + char* m_pClassName; //0x0008 + ClientClass* m_pNext; //0x0010 + void* m_pCreateFn; //0x0018 + void* m_pCreateEventFn; //0x0020 + void* m_pDestroyFn; //0x0028 + char pad_0030[8]; //0x0030 + char* m_pLibNameAndClassName; //0x0038 + SchemaRecvTable* RecvTable; //0x0040 + char pad_0048[20]; //0x0048 + int m_ClassID; //0x005C + void* N00000046; //0x0060 + void* N00000047; //0x0068 +};
\ No newline at end of file diff --git a/source2-basehook/Source2SDK/Color.hpp b/source2-basehook/Source2SDK/Color.hpp new file mode 100644 index 0000000..d2513a7 --- /dev/null +++ b/source2-basehook/Source2SDK/Color.hpp @@ -0,0 +1,20 @@ +#pragma once + +class Color +{ +public: + Color(); + Color(BYTE r, BYTE g, BYTE b, BYTE a = 255) + { + this->r = r, + this->g = g, + this->b = b, + this->a = a; + } + BYTE r, g, b, a; + + BYTE& operator[](int i) + { + return *(BYTE*)((int)this + i); + } +}; diff --git a/source2-basehook/Source2SDK/IClientModeShared.hpp b/source2-basehook/Source2SDK/IClientModeShared.hpp new file mode 100644 index 0000000..f7dbca4 --- /dev/null +++ b/source2-basehook/Source2SDK/IClientModeShared.hpp @@ -0,0 +1,9 @@ +#pragma once + +class IClientModeShared +{ +public: + +}; + +extern IClientModeShared* pClientMode;
\ No newline at end of file diff --git a/source2-basehook/Source2SDK/ISurface.hpp b/source2-basehook/Source2SDK/ISurface.hpp new file mode 100644 index 0000000..2ad781b --- /dev/null +++ b/source2-basehook/Source2SDK/ISurface.hpp @@ -0,0 +1,171 @@ +#pragma once + +enum FontFlags_t +{ + FONTFLAG_NONE, + FONTFLAG_ITALIC = 0x001, + FONTFLAG_UNDERLINE = 0x002, + FONTFLAG_STRIKEOUT = 0x004, + FONTFLAG_SYMBOL = 0x008, + FONTFLAG_ANTIALIAS = 0x010, + FONTFLAG_GAUSSIANBLUR = 0x020, + FONTFLAG_ROTARY = 0x040, + FONTFLAG_DROPSHADOW = 0x080, + FONTFLAG_ADDITIVE = 0x100, + FONTFLAG_OUTLINE = 0x200, + FONTFLAG_CUSTOM = 0x400, + FONTFLAG_BITMAP = 0x800, +}; + +struct Vector2D +{ + Vector2D() {} + Vector2D(float x, float y) { this->x = x; this->y = y; } + float x; + float y; +}; + +struct Vertex_t +{ + Vertex_t() {} + Vertex_t(const Vector2D& pos, const Vector2D& coord = Vector2D(0, 0)) + { + m_Position = pos; + m_TexCoord = coord; + } + + void Init(const Vector2D& pos, const Vector2D& coord = Vector2D(0, 0)) + { + m_Position = pos; + m_TexCoord = coord; + } + + Vector2D m_Position; + Vector2D m_TexCoord; +}; + +class ISurface +{ +public: + unsigned long CreateFonts(void) + { + using OriginalFn = unsigned long(__thiscall*)(void*); + return CallVfunc< OriginalFn >(this, 51)(this); + } + + void SetFontGlyphSet(unsigned long& font, const char* WindowsFontName, int tall, int weight, int blur, int scanlines, int flags) + { + using OriginalFn = void(__thiscall*)(void*, unsigned long, const char*, int, int, int, int, int, int, int); + CallVfunc<OriginalFn>(this, 58)(this, font, WindowsFontName, tall, weight, blur, scanlines, flags, 0, 0); + } + + void GetTextSize(unsigned long font, const wchar_t* text, int& width, int& tall) + { + using OriginalFn = bool(__thiscall*)(void*, unsigned long, const wchar_t*, int&, int&); + CallVfunc<OriginalFn>(this, 66)(this, font, text, width, tall); + } +}; + +extern ISurface* pSurface; + +class IVGuiPaintSurface +{ +public: + void DrawColoredCircle(int centerx, int centery, float radius, int r, int g, int b, int a) + { + typedef void(__thiscall* OriginalFn)(void*, int, int, int, int, int, int, int); + CallVfunc< OriginalFn >(this, 7)(this, centerx, centery, radius, r, g, b, a); + } + + void DrawFilledRectFade(int x0, int y0, int x1, int y1, size_t alpha0, size_t alpha1, bool horizontal) + { + using OriginalFn = void(__thiscall*)(void*, int, int, int, int, size_t, size_t, bool); + CallVfunc<OriginalFn>(this, 9)(this, x0, y0, x1, y1, alpha0, alpha1, horizontal); + } + + void DrawOutlinedCircle(int x, int y, int radius, int segments) + { + typedef void(__thiscall* OriginalFn)(void*, int, int, int, int); + CallVfunc< OriginalFn >(this, 10)(this, x, y, radius, segments); + } + + void DrawSetTextFont(unsigned long font) + { + using OriginalFn = void(__thiscall*)(void*, unsigned long); + CallVfunc< OriginalFn >(this, 13)(this, font); + } + + void DrawSetColor(int r, int g, int b, int a) + { + using OriginalFn = void(__thiscall*)(void*, int, int, int, int); + CallVfunc<OriginalFn>(this, 17)(this, r, g, b, a); + } + + void DrawFilledRect(int x0, int y0, int x1, int y1) + { + using OriginalFn = void(__thiscall*)(void*, int, int, int, int); + CallVfunc< OriginalFn >(this, 19)(this, x0, y0, x1, y1); + } + + void DrawOutlinedRect(int x0, int y0, int x1, int y1) + { + using OriginalFn = void(__thiscall*)(void*, int, int, int, int); + CallVfunc< OriginalFn >(this, 21)(this, x0, y0, x1, y1); + } + + void DrawLine(int x0, int y0, int x1, int y1) + { + using OriginalFn = void(__thiscall*)(void*, int, int, int, int); + CallVfunc< OriginalFn >(this, 22)(this, x0, y0, x1, y1); + } + + void DrawSetTextColor(int r, int g, int b, int a) + { + using OriginalFn = void(__thiscall*)(void*, int, int, int, int); + CallVfunc< OriginalFn >(this, 25)(this, r, g, b, a); + } + + void DrawSetTextPos(int x, int y) + { + using OriginalFn = void(__thiscall*)(void*, int, int); + CallVfunc< OriginalFn >(this, 26)(this, x, y); + } + + void DrawPrintText(const wchar_t* text, int textLen) + { + using OriginalFn = void(__thiscall*)(void*, const wchar_t*, int); + CallVfunc< OriginalFn >(this, 27)(this, text, textLen); + } + + void DrawSetTexture(int id) + { + typedef void(__thiscall* OriginalFn)(void*, int); + CallVfunc< OriginalFn >(this, 33)(this, id); + } + + void DrawTexturedPolygon(int Count, Vertex_t* Vertices, bool bClipVertices = false) + { + typedef void(__thiscall* OriginalFn)(void*, int, Vertex_t*, bool); + return CallVfunc< OriginalFn >(this, 38)(this, Count, Vertices, bClipVertices); + } + + void GetTextSize(unsigned long font, const wchar_t* text, int& width, int& tall) + { + using OriginalFn = bool(__thiscall*)(void*, unsigned long, const wchar_t*, int&, int&); + CallVfunc< OriginalFn >(this, 57)(this, font, text, width, tall); + } + + int CreateNewTextureID(bool procedural = false) + { + typedef int(__thiscall* OriginalFn)(void*, bool); + return CallVfunc< OriginalFn >(this, 60)(this, procedural); + } + + void DrawSetTextureRGBA(int id, const unsigned char* rgba, int wide, int tall, int hw = 0, bool fr = true) + { + using OriginalFn = void(__thiscall*)(void*, int, const unsigned char*, int, int, int, bool); + CallVfunc< OriginalFn >(this, 64)(this, id, rgba, wide, tall, hw, fr); + } +}; + +extern IVGuiPaintSurface* pPaintSurface;
\ No newline at end of file diff --git a/source2-basehook/Source2SDK/QAngle.hpp b/source2-basehook/Source2SDK/QAngle.hpp new file mode 100644 index 0000000..a00e7bc --- /dev/null +++ b/source2-basehook/Source2SDK/QAngle.hpp @@ -0,0 +1,338 @@ +#pragma once + +class QAngle +{ +public: + float x, y, z; + + QAngle(void); + QAngle(float X, float Y, float Z); + QAngle(Vector A); + + void Init(float ix = 0.0f, float iy = 0.0f, float iz = 0.0f); + void Random(float minVal, float maxVal); + + bool IsValid() const; + void Invalidate(); + + bool IsZero() + { + CHECK_VALID(*this); + if (this->x == 0.f && this->y == 0.f && this->z == 0.f) + return true; + + return false; + } + + float operator[](int i) const; + float& operator[](int i); + + float* Base(); + float const* Base() const; + + bool operator==(const QAngle& v) const; + bool operator!=(const QAngle& v) const; + + QAngle& operator+=(const QAngle& v); + QAngle& operator-=(const QAngle& v); + QAngle& operator*=(float s); + QAngle& operator/=(float s); + + float Length() const; + float LengthSqr() const; + + QAngle& operator=(const QAngle& src); + + QAngle operator-(void) const; + + QAngle operator+(const QAngle& v) const; + QAngle operator-(const QAngle& v) const; + QAngle operator*(float fl) const; + QAngle operator/(float fl) const; + + QAngle Clamp(); + QAngle NormalizeNoClamp(); + QAngle Mod(float N); + + inline QAngle Normalize(); +}; + +//----------------------------------------------------------------------------- +// constructors +//----------------------------------------------------------------------------- +inline QAngle::QAngle(void) +{ +#ifdef _DEBUG +#ifdef VECTOR_PARANOIA + // Initialize to NAN to catch errors + x = y = z = float_NAN; +#endif +#endif +} + +inline QAngle::QAngle(float X, float Y, float Z) +{ + x = X; y = Y; z = Z; + CHECK_VALID(*this); +} + +inline QAngle::QAngle(Vector A) +{ + x = A.x; + y = A.y; + z = A.z; +} + +//----------------------------------------------------------------------------- +// initialization +//----------------------------------------------------------------------------- +inline void QAngle::Init(float ix, float iy, float iz) +{ + x = ix; y = iy; z = iz; + CHECK_VALID(*this); +} + +inline void QAngle::Random(float minVal, float maxVal) +{ + x = minVal + ((float)rand() / RAND_MAX) * (maxVal - minVal); + y = minVal + ((float)rand() / RAND_MAX) * (maxVal - minVal); + z = minVal + ((float)rand() / RAND_MAX) * (maxVal - minVal); + CHECK_VALID(*this); +} + +//----------------------------------------------------------------------------- +// IsValid? +//----------------------------------------------------------------------------- + +inline bool QAngle::IsValid() const +{ + return std::isfinite(x) && std::isfinite(y) && std::isfinite(z); +} + +//----------------------------------------------------------------------------- +// Invalidate +//----------------------------------------------------------------------------- + +inline void QAngle::Invalidate() +{ + //#ifdef _DEBUG + //#ifdef VECTOR_PARANOIA + x = y = z = std::numeric_limits<float>::infinity(); + //#endif + //#endif +} + +//----------------------------------------------------------------------------- +// assignment +//----------------------------------------------------------------------------- +inline QAngle& QAngle::operator=(const QAngle& vOther) +{ + CHECK_VALID(vOther); + x = vOther.x; y = vOther.y; z = vOther.z; + return *this; +} + +//----------------------------------------------------------------------------- +// comparison +//----------------------------------------------------------------------------- +inline bool QAngle::operator==(const QAngle& src) const +{ + CHECK_VALID(src); + CHECK_VALID(*this); + return (src.x == x) && (src.y == y) && (src.z == z); +} + +inline bool QAngle::operator!=(const QAngle& src) const +{ + CHECK_VALID(src); + CHECK_VALID(*this); + return (src.x != x) || (src.y != y) || (src.z != z); +} + +//----------------------------------------------------------------------------- +// standard math operations +//----------------------------------------------------------------------------- +inline QAngle& QAngle::operator+=(const QAngle& v) +{ + CHECK_VALID(*this); + CHECK_VALID(v); + x += v.x; y += v.y; z += v.z; + return *this; +} + +inline QAngle& QAngle::operator-=(const QAngle& v) +{ + CHECK_VALID(*this); + CHECK_VALID(v); + x -= v.x; y -= v.y; z -= v.z; + return *this; +} + +inline QAngle& QAngle::operator*=(float fl) +{ + x *= fl; + y *= fl; + z *= fl; + CHECK_VALID(*this); + return *this; +} + +inline QAngle& QAngle::operator/=(float fl) +{ + Assert(fl != 0.0f); + float oofl = 1.0f / fl; + x *= oofl; + y *= oofl; + z *= oofl; + CHECK_VALID(*this); + return *this; +} + +//----------------------------------------------------------------------------- +// Base address... +//----------------------------------------------------------------------------- +inline float* QAngle::Base() +{ + return (float*)this; +} + +inline float const* QAngle::Base() const +{ + return (float const*)this; +} + +//----------------------------------------------------------------------------- +// Array access +//----------------------------------------------------------------------------- +inline float& QAngle::operator[](int i) +{ + Assert((i >= 0) && (i < 3)); + return ((float*)this)[i]; +} + +inline float QAngle::operator[](int i) const +{ + Assert((i >= 0) && (i < 3)); + return ((float*)this)[i]; +} + +//----------------------------------------------------------------------------- +// length +//----------------------------------------------------------------------------- +inline float QAngle::Length() const +{ + CHECK_VALID(*this); + return (float)sqrt(LengthSqr()); +} + + +inline float QAngle::LengthSqr() const +{ + CHECK_VALID(*this); + return x * x + y * y; +} + +inline QAngle QAngle::operator-(void) const +{ + return QAngle(-x, -y, -z); +} + +inline QAngle QAngle::operator+(const QAngle& v) const +{ + QAngle res; + res.x = x + v.x; + res.y = y + v.y; + res.z = z + v.z; + return res; +} + +inline QAngle QAngle::operator-(const QAngle& v) const +{ + QAngle res; + res.x = x - v.x; + res.y = y - v.y; + res.z = z - v.z; + return res; +} + +inline QAngle QAngle::operator*(float fl) const +{ + QAngle res; + res.x = x * fl; + res.y = y * fl; + res.z = z * fl; + return res; +} + +inline QAngle QAngle::operator/(float fl) const +{ + QAngle res; + res.x = x / fl; + res.y = y / fl; + res.z = z / fl; + return res; +} + +inline QAngle QAngle::Clamp() +{ + CHECK_VALID(*this); + + if (this->x < -89.0f) + this->x = -89.0f; + + if (this->x > 89.0f) + this->x = 89.0f; + + while (this->y < -180.0f) + this->y += 360.0f; + + while (this->y > 180.0f) + this->y -= 360.0f; + + this->z = 0.0f; + + return *this; +} + +inline QAngle QAngle::NormalizeNoClamp() +{ + CHECK_VALID(*this); + + this->x -= floorf(this->x / 360.0f + 0.5f) * 360.0f; + + this->y -= floorf(this->y / 360.0f + 0.5f) * 360.0f; + + this->z -= floorf(this->z / 360.0f + 0.5f) * 360.0f; + + return *this; +} + +inline QAngle QAngle::Mod(float N) +{ + CHECK_VALID(*this); + this->x = fmod(x, N); + this->y = fmod(y, N); + this->z = fmod(z, N); + + return *this; +} + +inline QAngle QAngle::Normalize() +{ + CHECK_VALID(*this); + + QAngle vector; + float length = this->Length(); + + if (length != 0) + { + vector.x = x / length; + vector.y = y / length; + vector.z = z / length; + } + else + vector.x = vector.y = 0.0f; vector.z = 1.0f; + + return vector; +} + diff --git a/source2-basehook/Source2SDK/SDK.cpp b/source2-basehook/Source2SDK/SDK.cpp new file mode 100644 index 0000000..f5b54c9 --- /dev/null +++ b/source2-basehook/Source2SDK/SDK.cpp @@ -0,0 +1,10 @@ +#include "SDK.hpp" + +CSource2Client* pClient = nullptr; +IClientModeShared* pClientMode = nullptr; +CEngineClient* pEngine = nullptr; +CGlobalVarsBase* pGlobals = nullptr; +IVPanel* pPanel = nullptr; +ISurface* pSurface = nullptr; +IVGuiPaintSurface* pPaintSurface = nullptr; +CUserCmd* pCmd = nullptr; diff --git a/source2-basehook/Source2SDK/SDK.hpp b/source2-basehook/Source2SDK/SDK.hpp new file mode 100644 index 0000000..95a2889 --- /dev/null +++ b/source2-basehook/Source2SDK/SDK.hpp @@ -0,0 +1,17 @@ +#pragma once +#include "../Include.hpp" +#include "Color.hpp" +#include "Vector.hpp" +#include "QAngle.hpp" +#include "CSource2Client.hpp" +#include "IClientModeShared.hpp" +#include "CEngineClient.hpp" +#include "CEngineVGUI.hpp" +#include "CGlobalVarsBase.hpp" +#include "ClientClass.hpp" +#include "ISurface.hpp" +#include "CUserCmd.hpp" +#include "Schema.hpp" + + + diff --git a/source2-basehook/Source2SDK/Schema.hpp b/source2-basehook/Source2SDK/Schema.hpp new file mode 100644 index 0000000..3e74be6 --- /dev/null +++ b/source2-basehook/Source2SDK/Schema.hpp @@ -0,0 +1,27 @@ +#pragma once + +struct Netvar +{ + const char* NetvarName; + void* _pad[2]; + uint32_t Offset; + uint32_t something; + void* _pad2[10]; + const char* TypeName; + void* _pad3[5]; +}; + +struct NetvarWrapper +{ + Netvar* Netvar; + char pad[7]; +}Packed; + +struct SchemaRecvTable +{ + const char* varName; + void* _pad; + int32_t NumOfNetvars; + int32_t unknown; + NetvarWrapper* NetvarsArray; +};
\ No newline at end of file diff --git a/source2-basehook/Source2SDK/Vector.hpp b/source2-basehook/Source2SDK/Vector.hpp new file mode 100644 index 0000000..791e082 --- /dev/null +++ b/source2-basehook/Source2SDK/Vector.hpp @@ -0,0 +1,252 @@ +#pragma once +#define CHECK_VALID( _v ) 0 +#define Assert( _exp ) ((void)0) +#define M_PI 3.14159265358979323846f +#define M_RADPI 57.295779513082f +#define M_PI_F ((float)(M_PI)) +#define RAD2DEG( x ) ( (float)(x) * (float)(180.f / M_PI_F) ) +#define DEG2RAD( x ) ( (float)(x) * (float)(M_PI_F / 180.f) ) + +class Vector +{ +public: + + float x, y, z; + + Vector(void); + Vector(float x, float y, float z); + + float& operator[](int) const; + Vector& operator=(const Vector&); + + Vector& operator+=(const Vector&); + Vector& operator-=(const Vector&); + Vector& operator*=(const Vector&); + Vector& operator*=(const float&); + Vector& operator/=(const Vector&); + Vector& operator/=(const float&); + + Vector operator+(const Vector&) const; + Vector operator-(const Vector&) const; + Vector operator*(const Vector&) const; + Vector operator*(const float&) const; + Vector operator/(const Vector&) const; + Vector operator/(const float&) const; + + bool operator==(const Vector&) const; + bool operator!=(const Vector&) const; + + float DistTo(const Vector&) const; + + float Length() const; + float LengthSqr() const; + float Length2D() const; + float Length2DSqr() const; + + Vector Cross(const Vector&) const; + float Dot(const Vector&) const; + + float Normalize(); + void Init(float, float, float); + void Zero(); + bool IsZero(float); + + //new + void VectorClear(Vector&); + void VectorCopy(const Vector&, Vector&); +}; + +inline Vector::Vector() +{ + x = y = z = 0.f; +} + +inline void Vector::Zero() +{ + x = y = z = 0.0f; +} + +inline Vector::Vector(float _x, float _y, float _z) +{ + x = _x; + y = _y; + z = _z; +} + +inline float& Vector::operator[](int i) const +{ + return ((float*)this)[i]; +} + +inline Vector& Vector::operator=(const Vector& v) +{ + x = v.x; + y = v.y; + z = v.z; + + return *this; +} + +inline Vector& Vector::operator+=(const Vector& v) +{ + x += v.x; + y += v.y; + z += v.z; + + return *this; +} + +inline Vector& Vector::operator-=(const Vector& v) +{ + x -= v.x; + y -= v.y; + z -= v.z; + + return *this; +} + +inline Vector& Vector::operator*=(const Vector& v) +{ + x *= v.x; + y *= v.y; + z *= v.z; + + return *this; +} + +inline Vector& Vector::operator*=(const float& f) +{ + x *= f; + y *= f; + z *= f; + + return *this; +} + +inline Vector& Vector::operator/=(const Vector& v) +{ + x /= v.x; + y /= v.y; + z /= v.z; + + return *this; +} + +inline Vector& Vector::operator/=(const float& f) +{ + x /= f; + y /= f; + z /= f; + + return *this; +} + +inline Vector Vector::operator+(const Vector& v) const +{ + return Vector(x + v.x, y + v.y, z + v.z); +} + +inline Vector Vector::operator-(const Vector& v) const +{ + return Vector(x - v.x, y - v.y, z - v.z); +} + +inline Vector Vector::operator*(const Vector& v) const +{ + return Vector(x * v.x, y * v.y, z * v.z); +} + +inline Vector Vector::operator*(const float& f) const +{ + return Vector(x * f, y * f, z * f); +} + +inline Vector Vector::operator/(const Vector& v) const +{ + return Vector(x / (v.x), y / (v.y), z / (v.z)); +} + +inline Vector Vector::operator/(const float& f) const +{ + return Vector(x / (f), y / (f), z / (f)); +} + +inline bool Vector::operator==(const Vector& v) const +{ + return v.x == x && v.y == y && v.z == z; +} + +inline bool Vector::operator!=(const Vector& e) const +{ + return e.x != x || e.y != y || e.z != z; +} + +inline float Vector::DistTo(const Vector& v) const +{ + return (*this - v).Length(); +} + +inline float Vector::Length() const +{ + return sqrtf((x * x) + (y * y) + (z * z)); +} + +inline float Vector::LengthSqr() const +{ + return (x * x) + (y * y) + (z * z); +} + +inline float Vector::Length2D() const +{ + return sqrtf((x * x) + (y * y)); +} + +inline float Vector::Length2DSqr() const +{ + return (x * x) + (y * y); +} + +inline Vector Vector::Cross(const Vector& e) const +{ + return Vector((y * e.z) - (z * e.y), (z * e.x) - (x * e.z), (x * e.y) - (y * e.x)); +} + +inline float Vector::Dot(const Vector& e) const +{ + return (x * e.x) + (y * e.y) + (z * e.z); +} + +inline float Vector::Normalize() +{ + float l = Length(); + float m = 1.f / (l); + + *this *= m; + + return l; +} + +inline void Vector::Init(float ix = 0.0f, float iy = 0.0f, float iz = 0.0f) +{ + x = ix; y = iy; z = iz; +} + +inline void Vector::VectorClear(Vector& a) +{ + a.x = a.y = a.z = 0.0f; +} + +inline bool Vector::IsZero(float tolerance = 0.01f) +{ + return (x > -tolerance && x < tolerance && + y > -tolerance && y < tolerance && + z > -tolerance && z < tolerance); +} + +__forceinline void Vector::VectorCopy(const Vector& src, Vector& dst) +{ + dst.x = src.x; + dst.y = src.y; + dst.z = src.z; +} + |