From 6df1b84edce378fb55cc9e61cc1d5632c0d8098e Mon Sep 17 00:00:00 2001 From: PixelGM Date: Fri, 27 Aug 2021 18:58:23 +0700 Subject: [PATCH] Initial commit --- .gitattributes | 2 + README.md | 3 + aimbot.cpp | 272 ++++++++++++++++++ aimbot.h | 43 +++ baseentity.h | 433 ++++++++++++++++++++++++++++ bhop.h | 32 +++ cmove.h | 119 ++++++++ debugoverlay.h | 11 + dllmain.cpp | 45 +++ drawing.cpp | 110 +++++++ drawing.h | 26 ++ engineclient.h | 79 ++++++ enginetrace.h | 62 ++++ exploit.cpp | 9 + exploit.h | 6 + globalvars.h | 35 +++ hooking.hpp | 34 +++ hooks.h | 20 ++ include.h | 26 ++ interfaces.cpp | 43 +++ interfaces.h | 23 ++ l4d2hook.sln | 22 ++ l4d2hook.vcxproj | 108 +++++++ l4d2hook.vcxproj.filters | 52 ++++ l4d2hook.vcxproj.user | 4 + materials.h | 61 ++++ math.cpp | 130 +++++++++ math.h | 28 ++ md5hash.cpp | 192 +++++++++++++ md5hash.h | 17 ++ menu.cpp | 600 +++++++++++++++++++++++++++++++++++++++ menu.h | 172 +++++++++++ model.h | 60 ++++ modelsinfo.h | 67 +++++ mouse.cpp | 100 +++++++ mouse.h | 42 +++ netvars.cpp | 141 +++++++++ netvars.h | 24 ++ panel.h | 152 ++++++++++ panels.h | 17 ++ recvprop.h | 83 ++++++ sigs.cpp | 132 +++++++++ sigs.h | 17 ++ surface.h | 74 +++++ usercmd.h | 17 ++ variables.cpp | 95 +++++++ variables.h | 84 ++++++ vector.h | 218 ++++++++++++++ visuals.cpp | 402 ++++++++++++++++++++++++++ visuals.h | 15 + vmatrix.h | 44 +++ 51 files changed, 4603 insertions(+) create mode 100644 .gitattributes create mode 100644 README.md create mode 100644 aimbot.cpp create mode 100644 aimbot.h create mode 100644 baseentity.h create mode 100644 bhop.h create mode 100644 cmove.h create mode 100644 debugoverlay.h create mode 100644 dllmain.cpp create mode 100644 drawing.cpp create mode 100644 drawing.h create mode 100644 engineclient.h create mode 100644 enginetrace.h create mode 100644 exploit.cpp create mode 100644 exploit.h create mode 100644 globalvars.h create mode 100644 hooking.hpp create mode 100644 hooks.h create mode 100644 include.h create mode 100644 interfaces.cpp create mode 100644 interfaces.h create mode 100644 l4d2hook.sln create mode 100644 l4d2hook.vcxproj create mode 100644 l4d2hook.vcxproj.filters create mode 100644 l4d2hook.vcxproj.user create mode 100644 materials.h create mode 100644 math.cpp create mode 100644 math.h create mode 100644 md5hash.cpp create mode 100644 md5hash.h create mode 100644 menu.cpp create mode 100644 menu.h create mode 100644 model.h create mode 100644 modelsinfo.h create mode 100644 mouse.cpp create mode 100644 mouse.h create mode 100644 netvars.cpp create mode 100644 netvars.h create mode 100644 panel.h create mode 100644 panels.h create mode 100644 recvprop.h create mode 100644 sigs.cpp create mode 100644 sigs.h create mode 100644 surface.h create mode 100644 usercmd.h create mode 100644 variables.cpp create mode 100644 variables.h create mode 100644 vector.h create mode 100644 visuals.cpp create mode 100644 visuals.h create mode 100644 vmatrix.h diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..dfe0770 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Auto detect text files and perform LF normalization +* text=auto diff --git a/README.md b/README.md new file mode 100644 index 0000000..3fa7458 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# UwUHax + +Thx B0ruk for the base! \ No newline at end of file diff --git a/aimbot.cpp b/aimbot.cpp new file mode 100644 index 0000000..7ea1cad --- /dev/null +++ b/aimbot.cpp @@ -0,0 +1,272 @@ +#include "hooks.h" +#include "sigs.h" + +Aimbot g_Aimbot; + +bool shoot; +static int custom_delay = 0; + +int Aimbot::GetAimBone(CBaseEntity* e) +{ + int bone = 0; + + if (e) + { + studiohdr* hdr = pModel->GetStudiomodel(e->GetModel()); + if (hdr) + { + for (int i = 0; i < hdr->GetHitboxCount(0); i++) + { + mstudiobbox* box = hdr->pHitboxSet(0)->pHitbox(i); + if (box) + { + if (box->group == HITGROUP_HEAD) + { + bone = i; + } + } + } + } + } + + return bone; +} + +void Aimbot::triggerbot(CUserCmd *cmd, CBaseEntity* local) +{ + Vector ViewAngles = cmd->viewangles; + + Vector CrosshairForward; + Math::angleVectors(ViewAngles,CrosshairForward); + + CrosshairForward *= 8192.0f; + + Vector TraceSource = local->GetEyePosition(); + Vector TraceDestination = TraceSource + CrosshairForward; + + raytrace raytrace(TraceSource, TraceDestination); + traceclass Trace; + tracefitlers Skip = local; + + pEngineTrace->TraceRay(raytrace, &Skip, &Trace); + + if (!Trace.pent) + return; + + if (!Trace.pent->ValidEntity()) + return; + + if (Trace.pent->GetTeamNum() == TEAM_SURVIVOR) + return; + + bool didHit = false; + + if ((gCvars.trighead && Trace.hitgroup == HITGROUP_HEAD) + || (gCvars.triggerbody && Trace.hitgroup == HITGROUP_CHEST) + || (gCvars.triggerbody && Trace.hitgroup == HITGROUP_STOMACH) + || (gCvars.TRIGLIMB && Trace.hitgroup == HITGROUP_LEFTARM) + || (gCvars.TRIGLIMB && Trace.hitgroup == HITGROUP_RIGHTARM) + || (gCvars.TRIGLIMB && Trace.hitgroup == HITGROUP_LEFTLEG) + || (gCvars.TRIGLIMB && Trace.hitgroup == HITGROUP_RIGHTLEG)) + { + didHit = true; + } + + if (gCvars.trigerdelay >= 1) + { + if (custom_delay >= gCvars.trigerdelay / 30) + { + if (didHit) + { + custom_delay = 0; + shoot = true; + cmd->buttons |= IN_ATTACK; + } + } + else + { + custom_delay++; + } + } +} + + +bool Aimbot::GetHitboxpos(CBaseEntity* pLocal, CBaseEntity* Entitiy, Vector &vPos, int iHitBox, matrix3x4_t matrix[128]) +{ + Vector vMax; + Vector vMin; + + studiohdr* hdr = pModel->GetStudiomodel(Entitiy->GetModel()); + + if (!hdr) + return false; + + mstudiobbox* hitbox = hdr->pHitboxSet(0)->pHitbox(iHitBox); + + if (!hitbox) + return false; + + Math::VectorTransform(hitbox->bbmin, matrix[hitbox->bone], vMin); + Math::VectorTransform(hitbox->bbmax, matrix[hitbox->bone], vMax); + + if (vMin.IsZero() || vMax.IsZero()) + return false; + + vPos = (vMin + vMax) * 0.5; + + if (IsVisible(vEyePos, vPos, pLocal,Entitiy)) + return true; + + return false; +} + +bool Aimbot::IsVisible(Vector& vecStart, Vector& vecEnd, CBaseEntity* pLocal, CBaseEntity* target) +{ + if (!pLocal) + return false; + + if (!target) + return false; + + raytrace raytrace(vecStart, vecEnd); + traceclass trace; + tracefitlers Skip = pLocal; + + pEngineTrace->TraceRay(raytrace, &Skip, &trace); + + if (trace.pent == target || trace.fraction == 1.f) + return true; + + return false; +} + +void Aimbot::Main(CUserCmd* pUserCmd, CBaseEntity* pLocal) +{ + int iMyTeam = pLocal->GetTeamNum(); + + vEyePos = pLocal->GetEyePosition(); + + static Vector vClientViewAngles; + pEngine->GetViewAngles(vClientViewAngles); + + static Vector vAngle; + Math::angleVectors(vClientViewAngles, vAngle); + + Reset(); + + for (INT ax = 1; ax <= pEntList->GetHighestEntityIndex(); ax++) + { + CBaseEntity* entity = pEntList->GetClientEntity(ax); + + if (!entity || entity == pLocal || !entity->ValidEntity()) + continue; + + if (!entity->GetModel()) + continue; + + if (entity->GetTeamNum() == TEAM_SURVIVOR) + continue; + + if (entity->GetTeamNum() == TEAM_IDK) + continue; + + if (entity->IsDormant()) + continue; + + matrix3x4_t matrix[128]; + + if (!entity->SetupBones(matrix)) + continue; + + int aim = GetAimBone(entity); + + if (!GetHitboxpos(pLocal, entity, vTarget, aim, matrix)) + continue; + + float fCurrFOV = Math::GetFov(vEyePos, vTarget, vAngle); + + if (fCurrFOV > gCvars.AIMFOV) + continue; + + fCurrFOV = (Vector(vTarget - vEyePos).Length()); + + if (fBestTarget < fCurrFOV) + continue; + + fBestTarget = fCurrFOV; + + vFinal = vTarget; + + iTarget = ax; + } + + if (HasTarget()) + { + Math::CalcAngle(vEyePos, vFinal, pUserCmd->viewangles); + + if (gCvars.SMOOTHPITCH > 0 && gCvars.SMOOTHYAW > 0) + { + vClientViewAngles.x = Math::AngleNormalize(vClientViewAngles.x); + vClientViewAngles.y = Math::AngleNormalize(vClientViewAngles.y); + + Vector qDelta = pUserCmd->viewangles - vClientViewAngles; + + qDelta.x = Math::AngleNormalize(qDelta.x); + qDelta.y = Math::AngleNormalize(qDelta.y); + + pUserCmd->viewangles.x = vClientViewAngles.x + qDelta.x / (float)gCvars.SMOOTHPITCH; + pUserCmd->viewangles.y = vClientViewAngles.y + qDelta.y / (float)gCvars.SMOOTHYAW; + + pUserCmd->viewangles.x = Math::AngleNormalize(pUserCmd->viewangles.x); + pUserCmd->viewangles.y = Math::AngleNormalize(pUserCmd->viewangles.y); + } + + if (!gCvars.SILENTAIM) + { + pEngine->SetViewAngles(pUserCmd->viewangles); + } + + if (gCvars.AUTOFIRE) + { + pUserCmd->buttons |= IN_ATTACK; + } + } +} + +void Aimbot::FixMovement(CUserCmd* c, Vector &qOld) +{ + Vector vMove(c->forwardmove, c->sidemove, c->upmove); + float fSpeed = sqrt(vMove.x * vMove.x + vMove.y * vMove.y); + static Vector qMove; + Math::vectorAngles(vMove, qMove); + + float fYaw = DEG2RAD(c->viewangles.y - qOld.y + qMove.y); + + c->forwardmove = cos(fYaw) * fSpeed * 1; + c->sidemove = sin(fYaw) * fSpeed; +} + +void Aimbot::ApplyRecoil(CBaseEntity *plocal, Vector &angles, float factor) +{ + angles += plocal->GetPunchAngle() * factor; +} + +void Aimbot::ApplySpread(int sequence_number, CBaseEntity *plocal, Vector &angles, float factor) +{ + auto w = reinterpret_cast(pEntList->GetClientEntityFromHandle(plocal->GetActiveWeaponHandle())); + + if (!w) + return; + + int random_seed = MD5_PseudoRandom(sequence_number) & 0x7fffffff; + + static auto SharedRandomFloat = (float(*)(const char *, float, float, int))FindProlog(FindString(GetModuleHandle("client"), "SharedRandomFloat")); + static int &r_random_seed = **(int **)FindPattern((void *)SharedRandomFloat, 0x100, ((const pattern *)"\x01\x01\x00\x00\x00\xA1")); + + r_random_seed = random_seed; + + float spread = w->GetWeaponSpread(); + + angles.x += SharedRandomFloat("CTerrorGun::FireBullet HorizSpread", -spread, spread, 0) * factor; + angles.y += SharedRandomFloat("CTerrorGun::FireBullet VertSpread", -spread, spread, 0) * factor; +} \ No newline at end of file diff --git a/aimbot.h b/aimbot.h new file mode 100644 index 0000000..f0e91e5 --- /dev/null +++ b/aimbot.h @@ -0,0 +1,43 @@ + + +class Aimbot +{ +public: + void Main(CUserCmd* pUserCmd, CBaseEntity* pLocal); + + int GetAimBone(CBaseEntity* e); + + bool GetHitboxpos(CBaseEntity* pLocal, CBaseEntity* Entitiy, Vector &vPos, int iHitBox, matrix3x4_t matrix[128]); + + void ApplySpread(int sequence_number, CBaseEntity *plocal, Vector &angles, float factor); + + void FixMovement(CUserCmd* c, Vector &qOld); + + void ApplyRecoil(CBaseEntity *plocal, Vector &angles, float factor); + + bool IsVisible(Vector& vecStart, Vector& vecEnd, CBaseEntity* pLocal, CBaseEntity* target); + + void triggerbot(CUserCmd *cmd, CBaseEntity* local); + + void Reset() + { + iTarget = -1; + fBestTarget = 99999.9f; + vTarget.Zero(); + vFinal.Zero(); + } + + bool HasTarget() + { + return (iTarget != -1); + } + + int iTarget; + float fBestTarget; + Vector vTarget; + Vector vFinal; + Vector vEyePos; +}; + +extern Aimbot g_Aimbot; + diff --git a/baseentity.h b/baseentity.h new file mode 100644 index 0000000..06382ab --- /dev/null +++ b/baseentity.h @@ -0,0 +1,433 @@ + +#include "netvars.h" +#include "variables.h" + +enum classids +{ + Boomer = 0, + Charger = 99, + CTerrorPlayer = 232, + Hunter = 263, + Infected = 264, + Jockey = 265, + Smoker = 270, + Spitter = 272, + SurvivorBot = 275, + Tank = 276, + Witch = 277, +}; + +enum WeaponIDs +{ + WeaponCSBase = 0, + AssaultRifle = 5, + AutoShotgun = 4, + BaseBackpackItem = 0, + BoomerClaw = 41, + Chainsaw = 20, + ChargerClaw = 40, + ColaBottles = 28, + FireworkCrate = 29, + FirstAidKit = 12, + GasCan = 16, + Gnome = 27, + GrenadeLauncher = 21, + HunterClaw = 39, + Adrenaline = 23, + ItemAmmoPack = 22, + ItemDefibrillator = 24, + ItemUpgradePackExplosive = 31, + ItemUpgradePackIncendiary = 30, + VomitJar = 25, + JockeyClaw = 44, + Molotov = 13, + OxygenTank = 18, + PainPills = 15, + PipeBomb = 14, + Pistol = 1, + MagnumPistol = 32, + PropaneTank = 17, + PumpShotgun = 3, + AK47 = 26, + Desert = 9, + M60 = 37, + SG552 = 34, + Chrome = 8, + SPAS = 11, + MP5 = 33, + Silenced = 7, + SmokerClaw = 42, + SniperRifle = 6, + AWP = 35, + Military = 10, + Scout = 36, + SpitterClaw = 43, + SubMachinegun = 2, + TankClaw = 38, + TerrorMeleeWeapon = 19, + WeaponSpawn = 8, +}; + +enum TeamIndexes +{ + TEAM_UNASSIGNED, + TEAM_SPECTATOR, + TEAM_SURVIVOR, + TEAM_ZOMBY, + TEAM_IDK, +}; + +enum GROUP +{ + GROUP_INVALID = 0, + GROUP_TANK, + GROUP_BITCH, + GROUP_SPECIAL, + GROUP_INFECTED, + GROUP_PLAYER +}; + +#define pRenderables 0x4 +#define pNetworkables 0x8 + +struct CBaseEntity +{ + DWORD* GetModel() + { + PVOID pRenderable = (PVOID)(this + pRenderables); + typedef DWORD* (__thiscall* OriginalFn)(PVOID); + return getvfunc(pRenderable, 8)(pRenderable); + } + + int GetIndex() + { + PVOID pNetworkable = (PVOID)(this + pNetworkables); + typedef int(__thiscall* OriginalFn)(PVOID); + return getvfunc(pNetworkable, 8)(pNetworkable); + } + + bool SetupBones(void* mtx) + { + PVOID pRenderable = (PVOID)(this + pRenderables); + typedef bool(__thiscall* OriginalFn)(PVOID, void*, int, long, float); + return getvfunc(pRenderable, 13)(pRenderable, mtx, 128, 0x100, 0); + } + + bool IsDormant() + { + PVOID pNetworkable = (PVOID)(this + pNetworkables); + typedef bool(__thiscall* OriginalFn)(PVOID); + return getvfunc(pNetworkable, 7)(pNetworkable); + } + + const Vector& GetAbsOrigin() + { + typedef const Vector& (__thiscall *GetAbsOrg_t)(PVOID); + return getvfunc(this, 11)(this); + } + + ClientClass* GetClientClass() + { + PVOID pNetworkable = (PVOID)(this + pNetworkables); + typedef ClientClass* (__thiscall* OriginalFn)(PVOID); + return getvfunc(pNetworkable, 1)(pNetworkable); + } + + Vector GetMins() + { + static int iOffset = g_Netvarmanager.GetOffset("DT_BaseEntity", "m_vecMins"); + return *(Vector*)((uintptr_t)this + iOffset); + } + Vector GetMaxs() + { + static int iOffset = g_Netvarmanager.GetOffset("DT_BaseEntity", "m_vecMaxs"); + return *(Vector*)((uintptr_t)this + iOffset); + } + + unsigned short GetSolidFlags() + { + static int iOffset = g_Netvarmanager.GetOffset("DT_BaseEntity", "m_usSolidFlags"); + return *(unsigned short*)((uintptr_t)this + iOffset); + } + + unsigned char GetLifeState() + { + static int iOffset = g_Netvarmanager.GetOffset("DT_BasePlayer", "m_lifeState"); + return *(unsigned char*)((uintptr_t)this + iOffset); + } + + int GetHealth() + { + static int iOffset = g_Netvarmanager.GetOffset("DT_BasePlayer", "m_iHealth"); + return *(int*)((uintptr_t)this + iOffset); + } + + Vector GetVelocity() + { + static int iOffset = g_Netvarmanager.GetOffset("DT_BasePlayer", "m_vecVelocity[0]"); + return *(Vector*)((uintptr_t)this + iOffset); + } + + Vector GetVecViewOffset() + { + static int iOffset = g_Netvarmanager.GetOffset("DT_BasePlayer", "m_vecViewOffset[0]"); + return *(Vector*)((uintptr_t)this + iOffset); + } + + Vector GetEyePosition() + { + return GetAbsOrigin() + GetVecViewOffset(); + } + + int GetFlags() + { + static int iOffset = g_Netvarmanager.GetOffset("DT_BasePlayer", "m_fFlags"); + return *(int*)((uintptr_t)this + iOffset); + } + + bool IsAlive() + { + return (GetLifeState() == LIFE_ALIVE && GetHealth() > 0); + } + + int GetTeamNum() + { + static int iOffset = g_Netvarmanager.GetOffset("DT_BaseEntity", "m_iTeamNum"); + return *(int*)((uintptr_t)this + iOffset); + } + + Vector GetVecOrigin() + { + static int iOffset = g_Netvarmanager.GetOffset("DT_BaseEntity", "m_vecOrigin"); + return *(Vector*)((uintptr_t)this + iOffset); + } + + Vector GetPunchAngle() + { + static int iOffset = g_Netvarmanager.GetOffset("DT_BasePlayer", "m_vecPunchAngle"); + return *(Vector*)((DWORD)this + iOffset); + } + + int GetTickBase() + { + static int iOffset = g_Netvarmanager.GetOffset("DT_BasePlayer", "m_nTickBase"); + return *(int*)((uintptr_t)this + iOffset); + } + + HANDLE GetActiveWeaponHandle() + { + static int iOffset = g_Netvarmanager.GetOffset("DT_BaseCombatCharacter", "m_hActiveWeapon"); + return *(HANDLE*)((uintptr_t)this + iOffset); + } + + inline const std::uint32_t Sequence() + { + static int iOffset = g_Netvarmanager.GetOffset("DT_BaseAnimating", "m_nSequence"); + return *(std::uint32_t*)(reinterpret_cast(this) + iOffset); + } + + const GROUP GetGroup() + { + constexpr std::uint32_t m_Bitch = classids::Witch; + constexpr std::uint32_t m_Tanks = classids::Tank; + + constexpr std::uint32_t m_Special[] = + { + classids::Boomer, classids::Charger, classids::Smoker, + classids::Hunter, classids::Jockey, classids::Spitter + }; + + constexpr std::uint32_t m_Infected = classids::Infected; + constexpr std::uint32_t m_Player[] = { classids::CTerrorPlayer, classids::SurvivorBot }; + + std::uint32_t m_ClassID = this->GetClientClass()->GetClassID; + + if (m_ClassID == m_Infected) + return GROUP_INFECTED; + + if (m_ClassID == m_Bitch) + return GROUP_BITCH; + + if (m_ClassID == m_Tanks) + return GROUP_TANK; + + else if (std::find(std::begin(m_Special), std::end(m_Special), m_ClassID) != std::end(m_Special)) + return GROUP_SPECIAL; + + else if (std::find(std::begin(m_Player), std::end(m_Player), m_ClassID) != std::end(m_Player)) + return GROUP_PLAYER; + + return GROUP_INVALID; + } + + const bool ValidEntity() + { + if (this->IsDormant()) + return false; + + const auto nTeam = this->GetTeamNum(); + + if (nTeam != TEAM_SURVIVOR && nTeam != TEAM_ZOMBY) + return false; + + auto m_Group = this->GetGroup(); + auto m_Sequence = this->Sequence(); + auto m_SolidFlags = this->GetSolidFlags(); + + if (m_Group == GROUP_INVALID) + return false; + + if (m_Group == GROUP_TANK) + { + if (m_SolidFlags & 4) + return false; + + if (m_Sequence > 70) + return false; + } + + if (m_Group == GROUP_BITCH) + { + if (m_SolidFlags & 4) + return false; + + if (m_Sequence > 70) + return false; + } + + else if (m_Group == GROUP_SPECIAL) + { + if (m_SolidFlags & 4) + return false; + } + + else if (m_Group == GROUP_INFECTED) + { + if (m_SolidFlags & 4) + return false; + + if (m_Sequence > 305) + return false; + } + + return true; + } + + const bool ValidEntityIgnoreInfected() + { + if (this->IsDormant()) + return false; + + const auto nTeam = this->GetTeamNum(); + + if (nTeam != TEAM_SURVIVOR && nTeam != TEAM_ZOMBY) + return false; + + auto m_Group = this->GetGroup(); + auto m_Sequence = this->Sequence(); + auto m_SolidFlags = this->GetSolidFlags(); + + if (m_Group == GROUP_INVALID) + return false; + + if (m_Group == GROUP_TANK) + { + if (m_SolidFlags & 4) + return false; + + if (m_Sequence > 70) + return false; + } + + if (m_Group == GROUP_BITCH) + { + if (m_SolidFlags & 4) + return false; + + if (m_Sequence > 70) + return false; + } + + else if (m_Group == GROUP_SPECIAL) + { + if (m_SolidFlags & 4) + return false; + } + + else if (m_Group == GROUP_INFECTED) + { + if (gCvars.INGOREINFECTED) + return false; + + if (m_SolidFlags & 4) + return false; + + if (m_Sequence > 305) + return false; + } + + return true; + } +}; + +template +inline T ReadPtr(const void *base, int o) +{ + return *(T *)((char *)base + o); +} + +struct CBaseCombatWeapon +{ + float GetNextPrimaryAttack() + { + static int iOffset = g_Netvarmanager.GetOffset("DT_BaseCombatWeapon", "m_flNextPrimaryAttack"); + return *(float*)((uintptr_t)this + iOffset); + } + + HANDLE Owner() + { + static int iOffset = g_Netvarmanager.GetOffset("DT_BaseCombatWeapon", "m_hOwner"); + return *(HANDLE*)(reinterpret_cast(this) + iOffset); + } + + inline float GetWeaponSpread() + { + return ReadPtr(this, 3340); + } + + int GetWeaponID() + { + typedef int(__thiscall* oWeaponID)(PVOID); + return getvfunc< oWeaponID >(this, 383)(this); + } + + bool HasAmmo() + { + static int iOffset = g_Netvarmanager.GetOffset("DT_BaseCombatWeapon", "m_iClip1"); + return ((*(PINT)((DWORD)this + iOffset)) > 0); + } + + bool IsAimWep() + { + int iWpnID = GetWeaponID(); + + return (iWpnID == AssaultRifle + || iWpnID == AutoShotgun + || iWpnID == Pistol + || iWpnID == MagnumPistol + || iWpnID == PumpShotgun + || iWpnID == AK47 + || iWpnID == Desert + || iWpnID == M60 + || iWpnID == SG552 + || iWpnID == Chrome + || iWpnID == SPAS + || iWpnID == MP5 + || iWpnID == Silenced + || iWpnID == SniperRifle + || iWpnID == AWP + || iWpnID == Scout + || iWpnID == Military); + } +}; + diff --git a/bhop.h b/bhop.h new file mode 100644 index 0000000..2baa601 --- /dev/null +++ b/bhop.h @@ -0,0 +1,32 @@ +#pragma once + + +void RunBhop(CUserCmd* cmd, CBaseEntity* pLocal) +{ + static bool jumped_last_tick = false; + static bool should_fake_jump = false; + + if (!jumped_last_tick && should_fake_jump) + { + should_fake_jump = false; + cmd->buttons |= IN_JUMP; + } + else if (cmd->buttons & IN_JUMP) + { + if (pLocal->GetFlags() & FL_ONGROUND) + { + jumped_last_tick = true; + should_fake_jump = true; + } + else + { + cmd->buttons &= ~IN_JUMP; + jumped_last_tick = false; + } + } + else + { + jumped_last_tick = false; + should_fake_jump = false; + } +} \ No newline at end of file diff --git a/cmove.h b/cmove.h new file mode 100644 index 0000000..c7e319f --- /dev/null +++ b/cmove.h @@ -0,0 +1,119 @@ +#pragma once + +#include "bhop.h" + +void CreateMove(CUserCmd* cmd) +{ + CBaseEntity* pLocal = pEntList->GetClientEntity(pEngine->GetLocalPlayer()); + CBaseCombatWeapon* pWeapon = (CBaseCombatWeapon*)pEntList->GetClientEntityFromHandle(pLocal->GetActiveWeaponHandle()); + + if (pLocal && pWeapon && pLocal->IsAlive()) + { + if (gCvars.AUTOBH) + { + RunBhop(cmd, pLocal); + } + + if (gCvars.LAGFAST > 0 && GetAsyncKeyState(gCvars.LAGKEY)) + { + Sequence::RemoveConds(gCvars.LAGFAST); + } + + if (pWeapon->HasAmmo()) + { + Vector qOldAngle = cmd->viewangles; + + float fCurTime = pGlobalvars->interval_per_tick * (pLocal->GetTickBase() + 1); + float fNextPrimary = pWeapon->GetNextPrimaryAttack(); + + bool bCanFire = true; + + static bool bOldBullet; + + if ((fNextPrimary > fCurTime) || bOldBullet) + bCanFire = false; + + if (!(fNextPrimary > fCurTime)) + bOldBullet = false; + + if (pLocal->GetTeamNum() == TEAM_SURVIVOR) + { + if (GetAsyncKeyState(gCvars.triggerkey)) + { + g_Aimbot.triggerbot(cmd, pLocal); + } + + if (gCvars.ENABLEAIM && pWeapon->IsAimWep()) + { + if (gCvars.AIMONFIRE) + { + if ((cmd->buttons & IN_ATTACK)) + { + g_Aimbot.Main(cmd, pLocal); + } + } + else + { + if (bCanFire) + { + g_Aimbot.Main(cmd, pLocal); + } + } + } + + if (gCvars.NORECOIL) + { + g_Aimbot.ApplyRecoil(pLocal, cmd->viewangles, -1.0f); + } + + if (gCvars.NOSPREAD) + { + if ((cmd->buttons & IN_ATTACK)) + { + g_Aimbot.ApplySpread(cmd->command_number, pLocal, cmd->viewangles, -1.0f); + } + } + + g_Aimbot.FixMovement(cmd, qOldAngle); + } + } + } +} + +template inline T get_BP() +{ + __asm mov eax, ebp +} + +template inline T get_SI() +{ + __asm mov eax, esi +} + +using SetViewAngleFn = void(__stdcall*)(Vector &); +SetViewAngleFn org_SetViewAngles = nullptr; + +void __stdcall hooked_SetViewAngles(Vector &angles) +{ + CUserCmd* cmd = get_SI(); + unsigned* sequence_number = (*get_BP() + 2); + + org_SetViewAngles(angles); + + if (cmd && cmd->command_number == *sequence_number) + { + if (gCvars.SPEEDFAST > 0) + { + static int i = 0; + + if (gCvars.SPEEDFAST && GetAsyncKeyState(gCvars.SPEEDKEY) && i-- > 0) + *(****get_BP() + 1) -= 5; + else + i = gCvars.SPEEDFAST; + } + + CreateMove(cmd); + + *sequence_number = cmd->command_number; + } +} diff --git a/debugoverlay.h b/debugoverlay.h new file mode 100644 index 0000000..37b9745 --- /dev/null +++ b/debugoverlay.h @@ -0,0 +1,11 @@ + + +class CDebugOverlay +{ +public: + bool ScreenPosition(const Vector& vIn, Vector& vOut) + { + typedef bool(__thiscall* OriginalFn)(PVOID, const Vector&, Vector&); + return getvfunc(this, 12)(this, vIn, vOut); + } +}; \ No newline at end of file diff --git a/dllmain.cpp b/dllmain.cpp new file mode 100644 index 0000000..13c3e08 --- /dev/null +++ b/dllmain.cpp @@ -0,0 +1,45 @@ + + +#include "hooks.h" +#include "model.h" +#include "panel.h" +#include "cmove.h" +#include "hooking.hpp" + +vmt_hook* paint; +vmt_hook* engine; +vmt_hook* drawmodel; + +void InitThread() +{ + static bool once = false; + + if (!once) + { + InitialiseInterfaces(); + g_Netvarmanager.Init(); + + paint = new vmt_hook(pPanel); + painttraverse_original = paint->hook(41, hkPaintTraverse); + + engine = new vmt_hook(pEngine); + org_SetViewAngles = engine->hook(20, hooked_SetViewAngles); + + drawmodel = new vmt_hook(pModelRender); + draw_model_original = drawmodel->hook(19, hkDrawModelExecute); + + Draw::InitFonts(); + + once = true; + } +} + +int __stdcall DllMain(void*, int r, void*) +{ + if (r == 1) + { + InitThread(); + } + + return 1; +} diff --git a/drawing.cpp b/drawing.cpp new file mode 100644 index 0000000..8116049 --- /dev/null +++ b/drawing.cpp @@ -0,0 +1,110 @@ +#include "hooks.h" + +HFont Fonts::m_MenuFont; +HFont Fonts::m_ListItemFont; +HFont Fonts::m_WatermarkFont; +HFont Fonts::m_VelocityFont; + +VOID Draw::InitFonts() +{ + if (pSurface == NULL) + return; + + pSurface->SetFontGlyphSet(Fonts::m_MenuFont = pSurface->Create_Font(), "Visitor TT2 BRK", 15, 500, 0, 0, 0x200); + pSurface->SetFontGlyphSet(Fonts::m_ListItemFont = pSurface->Create_Font(), "Visitor TT2 BRK", 13, 500, 0, 0, 0x200); + pSurface->SetFontGlyphSet(Fonts::m_WatermarkFont = pSurface->Create_Font(), "Tahoma", 13, 700, 0, 0, 0x200); + pSurface->SetFontGlyphSet(Fonts::m_VelocityFont = pSurface->Create_Font(), "Tahoma", 24, 700, 0, 0, 0x200); +} + +#define clamp(val, min, max) (((val) > (max)) ? (max) : (((val) < (min)) ? (min) : (val))) +void Draw::DrawMonitorBar(int x, int y, int cur, const char* title) +{ + cur = clamp(cur, 0, 100); + + Draw::FillRGBA(x, y, 30, 160, (int)(cur*2.55), (255 - (int)(cur*2.55)), 0, 255); + Draw::FillRGBA(x, y, 30, 160 - (cur * 1.6), 0, 0, 0, 255); + Draw::DrawStringA(Fonts::m_ListItemFont, false, x, y + 169, 255, 255, 255, 255, title); +} + +void Draw::OutlinedRectangle(int x, int y, int w, int h, int r, int g, int b, int a) +{ + Draw::FillRGBA(x, y, w, 1, r, g, b, a); + Draw::FillRGBA(x, y, 1, h, r, g, b, a); + Draw::FillRGBA(x + w, y, 1, h + 1, r, g, b, a); + Draw::FillRGBA(x, y + h, w, 1, r, g, b, a); +} + +void Draw::DrawTexts(unsigned long font, int x, int y, int r, int g, int b, int a, const wchar_t * text) +{ + pSurface->DrawSetTextPos(x, y); + pSurface->DrawSetTextFont(font); + pSurface->DrawSetTextColor(r, g, b, a); + pSurface->DrawPrintText(text, wcslen(text)); +} + +void Draw::SoftOutlinedRectangle(int x, int y, int w, int h, int r, int g, int b, int a) +{ + Draw::FillRGBA(x + 2, y, w - 3, 1, r, g, b, a); + Draw::FillRGBA(x + 1, y + 1, 1, 1, r, g, b, a); + Draw::FillRGBA(x, y + 2, 1, h - 3, r, g, b, a); + Draw::FillRGBA(x + 1, y + h - 1, 1, 1, r, g, b, a); + Draw::FillRGBA(x + w, y + 2, 1, h - 3, r, g, b, a); + Draw::FillRGBA(x + w - 1, y + 1, 1, 1, r, g, b, a); + Draw::FillRGBA(x + 2, y + h, w - 3, 1, r, g, b, a); + Draw::FillRGBA(x + w - 1, y + h - 1, 1, 1, r, g, b, a); +} + +void Draw::FillRGBA(int x, int y, int w, int h, int r, int g, int b, int a) +{ + pSurface->DrawSetColor(r, g, b, a); + pSurface->DrawFilledRect(x, y, x + w, y + h); +} + +std::wstring Draw::stringToWide(const std::string& text) +{ + std::wstring wide(text.length(), L' '); + std::copy(text.begin(), text.end(), wide.begin()); + + return wide; +} + +int Draw::getWidht(unsigned long font, const char* input) +{ + INT iWide = 0; + INT iTall = 0; + INT iBufSize = MultiByteToWideChar(CP_UTF8, 0x0, input, -1, NULL, 0); + + wchar_t* pszUnicode = new wchar_t[iBufSize]; + + MultiByteToWideChar(CP_UTF8, 0x0, input, -1, pszUnicode, iBufSize); + + pSurface->GetTextSize(font, pszUnicode, iWide, iTall); + + delete[] pszUnicode; + + return iWide; +} + +void Draw::DrawStringA(unsigned long font, bool center, int x, int y, int r, int g, int b, int a, const char *input, ...) +{ + CHAR szBuffer[MAX_PATH]; + + if (!input) + return; + + vsprintf_s(szBuffer, input, (char*)&input + _INTSIZEOF(input)); + + if (center) + x -= getWidht(font, szBuffer) / 2; + + pSurface->DrawSetTextColor(r, g, b, a); + pSurface->DrawSetTextFont(font); + pSurface->DrawSetTextPos(x, y); + std::wstring wide = stringToWide(std::string(szBuffer)); + pSurface->DrawPrintText(wide.c_str(), wide.length()); +} + +bool Draw::WorldToScreen(const Vector &vOrigin, Vector &vScreen) +{ + return (pDebugOverlay->ScreenPosition(vOrigin, vScreen) != 1); +} diff --git a/drawing.h b/drawing.h new file mode 100644 index 0000000..30e6094 --- /dev/null +++ b/drawing.h @@ -0,0 +1,26 @@ +#pragma once + +typedef unsigned long HFont; + +namespace Fonts +{ + extern HFont m_MenuFont; + extern HFont m_ListItemFont; + extern HFont m_WatermarkFont; + extern HFont m_VelocityFont; +} + +namespace Draw +{ + VOID InitFonts(); + void FillRGBA(int x, int y, int w, int h, int r, int g, int b, int a); + bool WorldToScreen(const Vector &vOrigin, Vector &vScreen); + INT getWidht(unsigned long font, const char* input); + std::wstring stringToWide(const std::string& text); + VOID DrawStringA(unsigned long font, bool center, int x, int y, int r, int g, int b, int a, const char *input, ...); + void DrawTexts(unsigned long font, int x, int y, int r, int g, int b, int a, const wchar_t * text); + void DrawMonitorBar(int x, int y, int cur, const char * title); + void OutlinedRectangle(int x, int y, int w, int h, int r, int g, int b, int a); + void SoftOutlinedRectangle(int x, int y, int w, int h, int r, int g, int b, int a); +} + diff --git a/engineclient.h b/engineclient.h new file mode 100644 index 0000000..c4d374c --- /dev/null +++ b/engineclient.h @@ -0,0 +1,79 @@ +class INetChannel +{ +private: + __forceinline float GetLatency(int flow) + { + return getvfunc< float(__thiscall*)(decltype(this), int) >(this, 9)(this, flow); + } +}; + +class CEngineClient +{ +public: + void GetScreenSize(int& width, int& height) + { + typedef void(__thiscall* OriginalFn)(PVOID, int&, int&); + return getvfunc(this, 5)(this, width, height); + } + + int GetLocalPlayer(VOID) + { + typedef int(__thiscall* OriginalFn)(PVOID); + return getvfunc(this, 12)(this); + } + + void GetViewAngles(Vector& vAngles) + { + typedef void(__thiscall* OriginalFn)(PVOID, Vector&); + return getvfunc< OriginalFn >(this, 19)(this, vAngles); + } + + void SetViewAngles(Vector& vAngles) + { + typedef void(__thiscall* oSetViewAngles)(PVOID, Vector&); + return getvfunc< oSetViewAngles >(this, 20)(this, vAngles); + } + + int GetMaxClients() + { + typedef bool(__thiscall* oGetMaxClients)(PVOID); + return getvfunc< oGetMaxClients >(this, 21)(this); + } + + INetChannel* GetNetChannelInfo(void) + { + typedef INetChannel* (__thiscall* OriginalFn)(PVOID); + return getvfunc(this, 74)(this); + } +}; + +class CEntityList +{ +public: + CBaseEntity* GetClientEntity(int entnum) + { + typedef CBaseEntity* (__thiscall* OriginalFn)(PVOID, int); + return getvfunc(this, 3)(this, entnum); + } + CBaseEntity *GetClientEntityFromHandle(HANDLE hEnt) + { + typedef CBaseEntity* (__thiscall* OriginalFn)(PVOID, HANDLE); + return getvfunc(this, 4)(this, hEnt); + } + int GetHighestEntityIndex(void) + { + typedef int(__thiscall* OriginalFn)(PVOID); + return getvfunc(this, 8)(this); + } +}; + +class HLCLient +{ +public: + ClientClass* GetAllClasses(VOID) + { + typedef ClientClass* (__thiscall* OriginalFn)(PVOID); + return getvfunc(this, 7)(this); + } +}; + diff --git a/enginetrace.h b/enginetrace.h new file mode 100644 index 0000000..902a3a2 --- /dev/null +++ b/enginetrace.h @@ -0,0 +1,62 @@ + + +struct raytrace +{ + raytrace(const Vector& src, const Vector& dest) : start(src), delta(dest - src) { isSwept = delta.x || delta.y || delta.z; } + Vector start{ }; + float pad{ }; + Vector delta{ }; + byte pad2[40]{ }; + bool isRay{ true }; + bool isSwept{ }; +}; + + +struct tracefitlers +{ + tracefitlers(const CBaseEntity* entity) : skip{ entity } { } + virtual bool shouldHitEntity(CBaseEntity* entity, int) { return entity != skip; } + virtual int getTraceType() const { return 0; } + const void* skip; +}; + +struct traceclass +{ + Vector startpos; + Vector endpos; + + struct + { + Vector normal; + float distance; + char type; + char signbits; + short unused; + } + plane; + + float fraction; + int contents; + short dispflags; + bool allsolid; + bool startsolid; + float fractionleftsolid; + const char *name; + short surfaceprops; + short flags; + int hitgroup; + short physicsbone; + CBaseEntity *pent; + int hitbox; +}; + +class CEnginetrace +{ +public: + void TraceRay(const raytrace &ray, tracefitlers *pTraceFilter, traceclass *ptrace) + { + typedef void(__thiscall* OriginalFn)(PVOID, const raytrace &, int, tracefitlers *, traceclass *); + return getvfunc(this, 5)(this, ray, 0x46004003, pTraceFilter, ptrace); + } +}; + diff --git a/exploit.cpp b/exploit.cpp new file mode 100644 index 0000000..ee692d6 --- /dev/null +++ b/exploit.cpp @@ -0,0 +1,9 @@ +#include "hooks.h" + + +void Sequence::RemoveConds(int value) +{ + INetChannel* ch = (INetChannel*)pEngine->GetNetChannelInfo(); + int& m_nOutSequenceNr = *(int*)((unsigned)ch + 8); + m_nOutSequenceNr += value; +} diff --git a/exploit.h b/exploit.h new file mode 100644 index 0000000..0c5d021 --- /dev/null +++ b/exploit.h @@ -0,0 +1,6 @@ + + +namespace Sequence +{ + void RemoveConds(int value); +} diff --git a/globalvars.h b/globalvars.h new file mode 100644 index 0000000..4f2efbd --- /dev/null +++ b/globalvars.h @@ -0,0 +1,35 @@ + + + +class CGlobalVarsBase +{ +public: + float realtime; // 0x0000 + int framecount; // 0x0004 + float absoluteframetime; // 0x0008 + //float absoluteframe; // 0x000C + float curtime; // 0x0010 + float frametime; // 0x0014 + int maxClients; // 0x0018 + int tickcount; // 0x001C + float interval_per_tick; // 0x0020 + float interpolation_amount; // 0x0024 + int simTicksThisFrame; // 0x0028 + int network_protocol; // 0x002C + void* pSaveData; // 0x0030 + bool m_bClient; // 0x0031 + bool m_bRemoteClient; // 0x0032 +private: + int nTimestampNetworkingBase; + int nTimestampRandomizeWindow; +}; + +class IPlayerInfoManager +{ +public: + CGlobalVarsBase* GetGlobalVars() + { + typedef CGlobalVarsBase* (__thiscall* OriginalFn)(PVOID); + return getvfunc(this, 1)(this); + } +}; \ No newline at end of file diff --git a/hooking.hpp b/hooking.hpp new file mode 100644 index 0000000..b40b6a8 --- /dev/null +++ b/hooking.hpp @@ -0,0 +1,34 @@ + + +class vmt_hook +{ +public: + vmt_hook(void* classptr) + { + this->m_class_pointer = reinterpret_cast(classptr); + m_old_vmt = *m_class_pointer; + + size_t table_size = 0; + while (m_old_vmt[table_size]) + table_size++; + + m_new_vmt = new void*[table_size + 1]; + memcpy(&m_new_vmt[1], m_old_vmt, sizeof(void*) * table_size); + m_new_vmt[0] = m_old_vmt[-1]; + + *m_class_pointer = &m_new_vmt[1]; + } + + template + fn hook(size_t index, void* new_function) + { + if (new_function) + m_new_vmt[index + 1] = new_function; + return reinterpret_cast(m_old_vmt[index]); + } + +private: + void*** m_class_pointer = nullptr; + void** m_old_vmt = nullptr; + void** m_new_vmt = nullptr; +}; \ No newline at end of file diff --git a/hooks.h b/hooks.h new file mode 100644 index 0000000..04e3e6c --- /dev/null +++ b/hooks.h @@ -0,0 +1,20 @@ + + + + +#include +#include + +#include "vector.h" +#include "math.h" +#include "include.h" +#include "interfaces.h" +#include "drawing.h" +#include "aimbot.h" +#include "visuals.h" +#include "exploit.h" +#include "mouse.h" +#include "menu.h" +#include "variables.h" + + diff --git a/include.h b/include.h new file mode 100644 index 0000000..58cf6a8 --- /dev/null +++ b/include.h @@ -0,0 +1,26 @@ + + +template +t getvfunc(void* class_pointer, size_t index) +{ + return (*(t**)class_pointer)[index]; +} + +#define LIFE_ALIVE 0 +#define FL_ONGROUND (1<<0) +#define IN_ATTACK (1 << 0) +#define IN_JUMP (1 << 1) +#define IN_USE (1 << 5) + +#include "modelsinfo.h" +#include "debugoverlay.h" +#include "md5hash.h" +#include "recvprop.h" +#include "baseentity.h" +#include "engineclient.h" +#include "surface.h" +#include "materials.h" +#include "globalvars.h" +#include "panels.h" +#include "usercmd.h" +#include "enginetrace.h" \ No newline at end of file diff --git a/interfaces.cpp b/interfaces.cpp new file mode 100644 index 0000000..b889edd --- /dev/null +++ b/interfaces.cpp @@ -0,0 +1,43 @@ +#include "hooks.h" +#include "sigs.h" + + +void InitialiseInterfaces() +{ + auto EnginePointer = get_module_factory(GetModuleHandleW(L"engine.dll")); + auto ClientPointer = get_module_factory(GetModuleHandleW(L"client.dll")); + auto VGUISurfacePointer = get_module_factory(GetModuleHandleW(L"vguimatsurface.dll")); + auto VGUI2Pointer = get_module_factory(GetModuleHandleW(L"vgui2.dll")); + auto MaterialPointer = get_module_factory(GetModuleHandleW(L"materialsystem.dll")); + auto ServerPointer = get_module_factory(GetModuleHandleW(L"server.dll")); + + pInfoPlayer = (IPlayerInfoManager*)ServerPointer("PlayerInfoManager002", nullptr); + pClient = (HLCLient*)ClientPointer("VClient016", nullptr); + pEngine = (CEngineClient*)EnginePointer("VEngineClient013", nullptr); + pEntList = (CEntityList*)ClientPointer("VClientEntityList003", nullptr); + pModel = (CModelInfo*)EnginePointer("VModelInfoClient004", nullptr); + pModelRender = (IVModelRender*)EnginePointer("VEngineModel016", nullptr); + pMaterialSystem = (IMaterialSystem*)MaterialPointer("VMaterialSystem080", nullptr); + pPanel = (IPanel*)VGUI2Pointer("VGUI_Panel009", nullptr); + pSurface = (ISurface*)VGUISurfacePointer("VGUI_Surface031", nullptr); + pEngineTrace = (CEnginetrace*)EnginePointer("EngineTraceClient003", nullptr); + pDebugOverlay = (CDebugOverlay*)EnginePointer("VDebugOverlay003", nullptr); + + pClientMode = **(void***)(Findrekt("client.dll", "89 04 B5 ? ? ? ? E8") + 3); + pGlobalvars = pInfoPlayer->GetGlobalVars(); +} + +IPlayerInfoManager* pInfoPlayer; +CGlobalVarsBase* pGlobalvars; +void* pClientMode; +CDebugOverlay* pDebugOverlay; +CEngineClient* pEngine; +IPanel* pPanel; +CEntityList* pEntList; +ISurface* pSurface; +IMaterialSystem* pMaterialSystem; +IVModelRender* pModelRender; +CModelInfo* pModel; +HLCLient* pClient; +CEnginetrace* pEngineTrace; + diff --git a/interfaces.h b/interfaces.h new file mode 100644 index 0000000..46825ce --- /dev/null +++ b/interfaces.h @@ -0,0 +1,23 @@ + + +extern void InitialiseInterfaces(); + +extern IPlayerInfoManager* pInfoPlayer; +extern CGlobalVarsBase* pGlobalvars; +extern void* pClientMode; +extern CDebugOverlay* pDebugOverlay; +extern CEngineClient* pEngine; +extern IPanel* pPanel; +extern CEntityList* pEntList; +extern ISurface* pSurface; +extern IMaterialSystem* pMaterialSystem; +extern IVModelRender* pModelRender; +extern CModelInfo* pModel; +extern HLCLient* pClient; +extern CEnginetrace* pEngineTrace; + +typedef void* (*CreateInterfaceFn)(const char* pName, int* pReturnCode); +inline CreateInterfaceFn get_module_factory(HMODULE module) +{ + return reinterpret_cast(GetProcAddress(module, "CreateInterface")); +} \ No newline at end of file diff --git a/l4d2hook.sln b/l4d2hook.sln new file mode 100644 index 0000000..37f250f --- /dev/null +++ b/l4d2hook.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.1340 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "l4d2hook", "l4d2hook.vcxproj", "{B47833C2-CC00-4490-A751-A16553374E0E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B47833C2-CC00-4490-A751-A16553374E0E}.Release|x86.ActiveCfg = Release|Win32 + {B47833C2-CC00-4490-A751-A16553374E0E}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {8946D11E-242F-40AE-8EDC-714D57FCE5DC} + EndGlobalSection +EndGlobal diff --git a/l4d2hook.vcxproj b/l4d2hook.vcxproj new file mode 100644 index 0000000..28932af --- /dev/null +++ b/l4d2hook.vcxproj @@ -0,0 +1,108 @@ + + + + + Release + Win32 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 15.0 + {B47833C2-CC00-4490-A751-A16553374E0E} + Win32Proj + 10.0 + l4d2hook + + + + DynamicLibrary + false + v142 + true + MultiByte + + + + + + + + + + + + true + $(LibraryPath) + insomnia + $(IncludePath) + + + + WIN32;NDEBUG;_WINDOWS;_USRDLL;CSSBASE_EXPORTS;%(PreprocessorDefinitions) + MultiThreadedDLL + TurnOffAllWarnings + ProgramDatabase + false + stdcpp17 + + + MachineX86 + true + Windows + true + true + + + + + + \ No newline at end of file diff --git a/l4d2hook.vcxproj.filters b/l4d2hook.vcxproj.filters new file mode 100644 index 0000000..d995245 --- /dev/null +++ b/l4d2hook.vcxproj.filters @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/l4d2hook.vcxproj.user b/l4d2hook.vcxproj.user new file mode 100644 index 0000000..be25078 --- /dev/null +++ b/l4d2hook.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/materials.h b/materials.h new file mode 100644 index 0000000..2cb4e3d --- /dev/null +++ b/materials.h @@ -0,0 +1,61 @@ +#pragma once + + +struct ModelRenderInfo_t +{ + Vector origin; + Vector angles; + void* renderable; + const void *pModel; + const matrix3x4_t *pModelToWorld; + const matrix3x4_t *pLightingOffset; + const Vector* lightingOrigin; + int flags; + int entity_index; +}; + +enum MaterialVarFlag +{ + NO_DRAW = (1 << 2), + ZNEARER = (1 << 10), + NOCULL = (1 << 13), + NOFOG = (1 << 14), + IGNOREZ = (1 << 15), + HALFLAMBERT = (1 << 27) +}; + +class IMaterial +{ +public: + void ColorModulate(float r, float g, float b) + { + typedef void(__thiscall* ColorModulateFn)(void*, float, float, float); + getvfunc(this, 28)(this, r, g, b); + } + + void SetMaterialVarFlag(MaterialVarFlag flag, bool on) + { + typedef void(__thiscall* SetMaterialVarFlagFn)(void*, MaterialVarFlag, bool); + getvfunc(this, 29)(this, flag, on); + } +}; + +class IMaterialSystem +{ +public: + IMaterial *FindMaterial(char const* pMaterialName, const char *pTextureGroupName, bool complain = true, const char *pComplainPrefix = NULL) + { + typedef IMaterial*(__thiscall* OriginalFn)(PVOID, char const*, const char*, bool, const char*); + return getvfunc(this, 71)(this, pMaterialName, pTextureGroupName, complain, pComplainPrefix); + } +}; + +class IVModelRender +{ +public: + void ForcedMaterialOverride(IMaterial* mat) + { + typedef void(__thiscall *OriginalFn)(void*, IMaterial*, int); + return getvfunc(this, 1)(this, mat, 0); + } +}; diff --git a/math.cpp b/math.cpp new file mode 100644 index 0000000..a70c2d9 --- /dev/null +++ b/math.cpp @@ -0,0 +1,130 @@ +#include "hooks.h" + + +float Math::DotProduct(const float *v1, const float *v2) +{ + return v1[0] * v2[0] + v1[1] * v2[1] + v1[2] * v2[2]; +} + +float Math::sseSqrt(float x) +{ + float root = 0.0f; + + __asm + { + sqrtss xmm0, x + movss root, xmm0 + } + + return root; +} + +void Math::vectorAngles(Vector forward, Vector &angles) +{ + if (forward[1] == 0.0f && forward[0] == 0.0f) + { + angles[0] = (forward[2] > 0.0f) ? 270.0f : 90.0f; + angles[1] = 0.0f; + } + else + { + float len2d = sseSqrt(square(forward[0]) + square(forward[1])); + + angles[0] = RAD2DEG(atan2f(-forward[2], len2d)); + angles[1] = RAD2DEG(atan2f(forward[1], forward[0])); + + if (angles[0] < 0.0f) angles[0] += 360.0f; + if (angles[1] < 0.0f) angles[1] += 360.0f; + } + + angles[2] = 0.0f; +} + +VOID Math::VectorTransform(const Vector in1, const matrix3x4_t& in2, Vector& out) +{ + float buf[3]; + buf[0] = in1.x; + buf[1] = in1.y; + buf[2] = in1.z; + + out[0] = DotProduct(buf, in2[0]) + in2[0][3]; + out[1] = DotProduct(buf, in2[1]) + in2[1][3]; + out[2] = DotProduct(buf, in2[2]) + in2[2][3]; +} + +float Math::GetFov(Vector vLocalOrigin, Vector vPosition, Vector vForward) +{ + Vector vLocal; + + VectorSubtract(vPosition, vLocalOrigin, vLocal); + + vLocal.NormalizeInPlace(); + + float fValue = vForward.Dot(vLocal); + + if (fValue < -1.0f) + fValue = -1.0f; + + if (fValue > 1.0f) + fValue = 1.0f; + + return RAD2DEG(acos(fValue)); +} + +void Math::CalcAngle(Vector &vSource, Vector &vDestination, Vector &qAngle) +{ + Vector vDelta = vSource - vDestination; + + float fHyp = (vDelta.x * vDelta.x) + (vDelta.y * vDelta.y); + + float fRoot; + + __asm + { + sqrtss xmm0, fHyp + movss fRoot, xmm0 + } + + qAngle.x = RAD2DEG(atan(vDelta.z / fRoot)); + qAngle.y = RAD2DEG(atan(vDelta.y / vDelta.x)); + + if (vDelta.x >= 0.0f) + qAngle.y += 180.0f; + + qAngle.x = AngleNormalize(qAngle.x); + qAngle.y = AngleNormalize(qAngle.y); +} + +void sinCos(float radians, PFLOAT sine, PFLOAT cosine) +{ + __asm + { + fld dword ptr[radians] + fsincos + mov edx, dword ptr[cosine] + mov eax, dword ptr[sine] + fstp dword ptr[edx] + fstp dword ptr[eax] + } +} + +void Math::angleVectors(Vector angles, Vector &f) +{ + float sp, sy, sr, cp, cy, cr; + + sinCos(DEG2RAD(angles[0]), &sp, &cp); + sinCos(DEG2RAD(angles[1]), &sy, &cy); + sinCos(DEG2RAD(angles[2]), &sr, &cr); + + f[0] = cp * cy; + f[1] = cp * sy; + f[2] = -sp; +} + +float Math::AngleNormalize(float angle) +{ + while (angle < -180) angle += 360; + while (angle > 180) angle -= 360; + + return angle; +} diff --git a/math.h b/math.h new file mode 100644 index 0000000..d80f6ce --- /dev/null +++ b/math.h @@ -0,0 +1,28 @@ +#pragma once + +#include "vmatrix.h" + +#define PI 3.14159265358979323846f +#define DEG2RAD( x ) ( ( float )( x ) * ( float )( ( float )( PI ) / 180.0f ) ) +#define RAD2DEG( x ) ( ( float )( x ) * ( float )( 180.0f / ( float )( PI ) ) ) +#define square( x ) ( x * x ) + + +namespace Math +{ + float sseSqrt(float x); + + void vectorAngles(Vector forward, Vector &angles); + + float DotProduct(const float *v1, const float *v2); + + VOID VectorTransform(const Vector in1, const matrix3x4_t& in2, Vector& out); + + float GetFov(Vector vLocalOrigin, Vector vPosition, Vector vForward); + + void CalcAngle(Vector &vSource, Vector &vDestination, Vector &qAngle); + + void angleVectors(Vector angles, Vector &f); + + float AngleNormalize(float angle); +} diff --git a/md5hash.cpp b/md5hash.cpp new file mode 100644 index 0000000..2151fcc --- /dev/null +++ b/md5hash.cpp @@ -0,0 +1,192 @@ +#include "md5hash.h" + +#define F1(x, y, z) (z ^ (x & (y ^ z))) +#define F2(x, y, z) F1(z, x, y) +#define F3(x, y, z) (x ^ y ^ z) +#define F4(x, y, z) (y ^ (x | ~z)) + +#define MD5STEP(f, w, x, y, z, data, s) \ + ( w += f(x, y, z) + data, w = w<>(32-s), w += x ) + +static void MD5Transform(unsigned buf[4], unsigned const in[16]) +{ + register unsigned a, b, c, d; + + a = buf[0]; + b = buf[1]; + c = buf[2]; + d = buf[3]; + + MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7); + MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12); + MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17); + MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22); + MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7); + MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12); + MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17); + MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22); + MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7); + MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12); + MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17); + MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22); + MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7); + MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12); + MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17); + MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22); + + MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5); + MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9); + MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14); + MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20); + MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5); + MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9); + MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14); + MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20); + MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5); + MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9); + MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14); + MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20); + MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5); + MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9); + MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14); + MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20); + + MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4); + MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11); + MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16); + MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23); + MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4); + MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11); + MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16); + MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23); + MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4); + MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11); + MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16); + MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23); + MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4); + MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11); + MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16); + MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23); + + MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6); + MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10); + MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15); + MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21); + MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6); + MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10); + MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15); + MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21); + MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6); + MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10); + MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15); + MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21); + MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6); + MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10); + MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15); + MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21); + + buf[0] += a; + buf[1] += b; + buf[2] += c; + buf[3] += d; +} + +void MD5Init(MD5Context_t *ctx) +{ + ctx->buf[0] = 0x67452301; + ctx->buf[1] = 0xefcdab89; + ctx->buf[2] = 0x98badcfe; + ctx->buf[3] = 0x10325476; + + ctx->bits[0] = 0; + ctx->bits[1] = 0; +} + +void MD5Update(MD5Context_t *ctx, unsigned char const *buf, unsigned len) +{ + unsigned t; + + t = ctx->bits[0]; + if ((ctx->bits[0] = t + ((unsigned)len << 3)) < t) + ctx->bits[1]++; + ctx->bits[1] += len >> 29; + + t = (t >> 3) & 0x3f; + + if (t) + { + unsigned char *p = (unsigned char *)ctx->in + t; + + t = 64 - t; + if (len < t) + { + memcpy(p, buf, len); + return; + } + memcpy(p, buf, t); + //byteReverse(ctx->in, 16); + MD5Transform(ctx->buf, (unsigned *)ctx->in); + buf += t; + len -= t; + } + + while (len >= 64) + { + memcpy(ctx->in, buf, 64); + //byteReverse(ctx->in, 16); + MD5Transform(ctx->buf, (unsigned *)ctx->in); + buf += 64; + len -= 64; + } + + memcpy(ctx->in, buf, len); +} + +void MD5Final(unsigned char digest[MD5_DIGEST_LENGTH], MD5Context_t *ctx) +{ + unsigned count; + unsigned char *p; + + count = (ctx->bits[0] >> 3) & 0x3F; + + p = ctx->in + count; + *p++ = 0x80; + + count = 64 - 1 - count; + + if (count < 8) + { + memset(p, 0, count); + //byteReverse(ctx->in, 16); + MD5Transform(ctx->buf, (unsigned *)ctx->in); + + memset(ctx->in, 0, 56); + } + else + { + memset(p, 0, count - 8); + } + //byteReverse(ctx->in, 14); + + ((unsigned *)ctx->in)[14] = ctx->bits[0]; + ((unsigned *)ctx->in)[15] = ctx->bits[1]; + + MD5Transform(ctx->buf, (unsigned *)ctx->in); + //byteReverse((unsigned char *) ctx->buf, 4); + memcpy(digest, ctx->buf, MD5_DIGEST_LENGTH); + memset(ctx, 0, sizeof(ctx)); +} + +unsigned MD5_PseudoRandom(unsigned nSeed) +{ + MD5Context_t ctx; + unsigned char digest[MD5_DIGEST_LENGTH]; // The MD5 Hash + + memset(&ctx, 0, sizeof(ctx)); + + MD5Init(&ctx); + MD5Update(&ctx, (unsigned char*)&nSeed, sizeof(nSeed)); + MD5Final(digest, &ctx); + + return *(unsigned*)(digest + 6); // use 4 middle bytes for random value +} \ No newline at end of file diff --git a/md5hash.h b/md5hash.h new file mode 100644 index 0000000..362b985 --- /dev/null +++ b/md5hash.h @@ -0,0 +1,17 @@ +#pragma once +#include + +#define MD5_DIGEST_LENGTH 16 + +typedef struct +{ + unsigned buf[4]; + unsigned bits[2]; + unsigned char in[64]; +} MD5Context_t; + +void MD5Init(MD5Context_t *context); +void MD5Update(MD5Context_t *context, unsigned char const *buf, unsigned len); +void MD5Final(unsigned char digest[MD5_DIGEST_LENGTH], MD5Context_t *context); + +unsigned MD5_PseudoRandom(unsigned nSeed); \ No newline at end of file diff --git a/menu.cpp b/menu.cpp new file mode 100644 index 0000000..d430ee2 --- /dev/null +++ b/menu.cpp @@ -0,0 +1,600 @@ +#include "hooks.h" + + +cMenu g_Menu(400,200,290,253); + +bool bSliderFix[50]; + +int iSliderIndex = -1; +int iCurrSlider; + +DWORD dwWait; + +#define COLOR1 60, 60, 60, 255 +#define COLOR2 85, 85, 85, 255 +#define COLOR3 0, 0, 0, 255 +#define COLOR4 35, 35, 35, 255 +#define COLOR5 50, 50, 50, 255 +#define COLOR6 100, 100, 100, 255 +#define COLOR7 73, 73, 73, 255 +#define COLOR8 65, 65, 65, 255 + +#define COLOR9 (gCvars.espcolor[0]), (gCvars.espcolor[1]), (gCvars.espcolor[2]), 255 + +#define LISTITEM_TEXTCOLOR 255, 255, 255, 255 + +#define ELEMENT_SEPERATION 20 +#define CHECKBOX_SEPERATION_FROM_TEXT 100 +#define CHECKBOX_SIZE 13 + +#define DEFAULT_X_TO_ADD (70 + CHECKBOX_SIZE + 40) + +#define DROPDOWN_WIDTH 57 +#define DROPDOWN_HEIGHT 15 + +#define ADDER_SIZE 12 +#define ADDER_SEPERATE_FROM_BOXES 44 + +cMenu::cMenu(int x, int y, int w, int h) +{ + m_x = x; + m_y = y; + m_w = w; + m_h = h; +} + +char *fuckingkeynames[] = { "M2","F","Z","Q","V" }; +float fuckingkeyvalues[] = { 0x02,0x46,0x5A,0x51,0x56 }; + +void cMenu::InitMenuElements() +{ + static cMenuSection msAimbot; + static cMenuSection msAimbotSliders; + static cMenuSection radarslider; + static cMenuSection msEsp; + static cMenuSection msMisc; + static cMenuSection msRemovals; + static cMenuSection msskinss; + static cMenuSection hoodrich; + + int iRowTwo = DEFAULT_X_TO_ADD; + + int iUsualX = m_x + 10; + + iCurrSlider = 0; + + switch (GetTabIndex()) + { + case AIMTAB: + + msAimbot.ClearSection(); + msAimbotSliders.ClearSection(); + + msAimbot.Draw(iUsualX, m_y + 30, m_w - 22, 80); + + msAimbot.AddElement(ONOFF, -3, L" AIM ENABLE", &gCvars.ENABLEAIM); + msAimbot.AddElement(ONOFF, -3, L" AIM ON FIRE", &gCvars.AIMONFIRE); + msAimbot.AddElement(ONOFF, -3, L" SILENT AIM", &gCvars.SILENTAIM); + + msAimbot.RestartSection(); + + msAimbot.AddElement(ONOFF, iRowTwo, L" NORECOIL", &gCvars.NORECOIL); + msAimbot.AddElement(ONOFF, iRowTwo, L" NOSPREAD", &gCvars.NOSPREAD); + msAimbot.AddElement(ONOFF, iRowTwo, L" AUTOFIRE", &gCvars.AUTOFIRE); + + msAimbotSliders.Draw(iUsualX, m_y + 116, m_w - 22, 124); + + msAimbotSliders.SetSlider(iCurrSlider, true); + msAimbotSliders.AddElement(SLIDER, 0, L"TARGET SELECTION FOV", &gCvars.AIMFOV, 0, 180); + msAimbotSliders.SetSlider(iCurrSlider, true); + msAimbotSliders.AddElement(SLIDER, 0, L"SMOOTHNESS PITCH", &gCvars.SMOOTHPITCH, 0, 255); + msAimbotSliders.SetSlider(iCurrSlider, true); + msAimbotSliders.AddElement(SLIDER, 0, L"SMOOTHNESS YAW", &gCvars.SMOOTHYAW, 0, 255); + + break; + + case ESPTAB: + + msEsp.ClearSection(); + radarslider.ClearSection(); + + msEsp.Draw(iUsualX, m_y + 30, m_w - 22, 90); + + msEsp.AddElement(ONOFF, 0, L"ESP NAME", &gCvars.ESPNAME); + msEsp.AddElement(ONOFF, 0, L"ESP BOX", &gCvars.ESPBOX); + msEsp.AddElement(ONOFF, 0, L"ESP HEALTH", &gCvars.ESPHEALTH); + msEsp.AddElement(ONOFF, 0, L"IGNORE INFECTED", &gCvars.INGOREINFECTED); + msEsp.RestartSection(); + msEsp.AddElement(ONOFF, iRowTwo, L" CHAMS", &gCvars.CHAMS); + msEsp.AddElement(ONOFF, iRowTwo, L" CHAM XQZ", &gCvars.CHAMSXQZ); + msEsp.AddElement(ONOFF, iRowTwo, L" CHAM HAND", &gCvars.CHAMHAND); + + radarslider.Draw(iUsualX, m_y + 116, m_w - 22, 124); + + radarslider.SetSlider(iCurrSlider, true); + radarslider.AddElement(SLIDER, 0, L"RED", &gCvars.espcolor[0], 0, 255); + radarslider.SetSlider(iCurrSlider, true); + radarslider.AddElement(SLIDER, 0, L"GREEN", &gCvars.espcolor[1], 0, 255); + radarslider.SetSlider(iCurrSlider, true); + radarslider.AddElement(SLIDER, 0, L"BLUE", &gCvars.espcolor[2], 0, 255); + + break; + + case MISCTAB: + + msRemovals.ClearSection(); + msskinss.ClearSection(); + hoodrich.ClearSection(); + + hoodrich.Draw(iUsualX, m_y + 30, m_w - 22, 64); + hoodrich.SetValueNames(fuckingkeynames, fuckingkeyvalues, 5); + hoodrich.AddElement(ADDER, -20, L" SEQUENCE", &gCvars.LAGFAST, 0, 1000); + hoodrich.AddElement(DROPDOWN, -20, L" KEYBIND", &gCvars.LAGKEY); + hoodrich.RestartSection(); + hoodrich.SetValueNames(fuckingkeynames, fuckingkeyvalues, 5); + hoodrich.AddElement(ADDER, iRowTwo -14, L" OVERSPED", &gCvars.SPEEDFAST, 0, 10); + hoodrich.AddElement(DROPDOWN, iRowTwo -14, L" KEYBIND", &gCvars.SPEEDKEY); + + + msRemovals.Draw(iUsualX, m_y + 100, m_w - 175, 140); + msRemovals.AddElement(ONOFF, -17, L" BUNNYHOP", &gCvars.AUTOBH); + msRemovals.AddElement(ONOFF, -17, L" VELOCITY", &gCvars.velocity); + msRemovals.AddElement(ONOFF, -17, L" RADAR", &gCvars.radar); + msRemovals.AddElement(ONOFF, -17, L" WATERMARK", &gCvars.watermark); + msRemovals.AddElement(ONOFF, -17, L" NO VOMIT", &gCvars.NOVOMIT); + msRemovals.AddElement(ONOFF, -17, L" MONITOR", &gCvars.drawmonitor); + + msskinss.Draw(iUsualX + 120, m_y + 100, m_w - 142, 140); + + msskinss.AddElement(ONOFF, -9, L" TRIGGERBOT", &gCvars.trigenable); + msskinss.AddElement(ONOFF, -9, L" TRIG HEAD", &gCvars.trighead); + msskinss.AddElement(ONOFF, -9, L" TRIG BODY", &gCvars.triggerbody); + msskinss.AddElement(ONOFF, -9, L" TRIG LIMB", &gCvars.TRIGLIMB); + msskinss.SetValueNames(fuckingkeynames, fuckingkeyvalues, 5); + msskinss.AddElement(DROPDOWN, -10, L" KEY BIND", &gCvars.triggerkey); + msskinss.AddElement(ADDER, -10, L" DELAY", &gCvars.trigerdelay, 1, 150); + + hoodrich.PostSection(); + msskinss.PostSection(); + msRemovals.PostSection(); + break; + } +} + +int iNubLoop[] = {22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0}; + +void cMenu::DrawTab(int index, int &setindex, int x, int y, const char *pszTitle) +{ + static int iWidth = 90; + static int iHeight = 22; + + bool bOverTri = false; + + bool bOverBack = g_Mouse.IsOver(x + iHeight, y - iHeight, iWidth + 1 - iHeight, iHeight + 1); + + bool bSame = setindex == index; + + for (int ax = 0; ax <= iHeight; ax++) + { + if (g_Mouse.IsOver(x + ax, y - ax, 2, ax) || g_Mouse.IsOver(x + iWidth + ax, y - iHeight, 2, iNubLoop[ax])) + { + bOverTri = true; + break; + } + } + + for (int i = 0; i <= iHeight; i++) + { + if (bSame) + { + pSurface->DrawSetColor(COLOR7); + + pSurface->DrawLine(x + i, y, x + iHeight + i, y - iHeight); + pSurface->DrawLine(x + iWidth + iHeight - i, y - iHeight, x + iWidth - i, y); + + if (i == iHeight) + Draw::FillRGBA(x + iHeight, y - iHeight, iWidth - iHeight, iHeight + 1, COLOR7); + } + else + { + if (bOverBack || bOverTri) + pSurface->DrawSetColor(COLOR8); + else + pSurface->DrawSetColor(COLOR1); + + pSurface->DrawLine(x + i, y, x + iHeight + i, y - iHeight); + pSurface->DrawLine(x + iWidth + iHeight - i, y - iHeight, x + iWidth - i, y); + + if (g_Mouse.HasMouseOneJustBeenReleased() && (bOverBack || bOverTri)) + setindex = index; + + if (i == iHeight) + { + if (bOverBack || bOverTri) + Draw::FillRGBA(x + iHeight, y - iHeight, iWidth - iHeight, iHeight + 1, COLOR8); + else + Draw::FillRGBA(x + iHeight, y - iHeight, iWidth - iHeight, iHeight + 1, COLOR1); + } + } + } + + pSurface->DrawSetColor(COLOR2); + + pSurface->DrawLine(x, y, x + iHeight, y - iHeight); + pSurface->DrawLine(x + iHeight, y - iHeight, x + iWidth + iHeight + 1, y - iHeight); + pSurface->DrawLine(x + iWidth, y, x + iWidth + iHeight, y - iHeight); + pSurface->DrawLine(x, y, x + iWidth, y); + Draw::DrawStringA(Fonts::m_WatermarkFont, true, x + (iWidth + iHeight) * 0.5, y + 1 - iHeight, COLOR9, pszTitle); +} + +void cMenu::DrawMenu() +{ + Draw::FillRGBA(m_x + 22, m_y - 22, 80 * NUM_OF_TABS + 20, 23, COLOR4); + + pSurface->DrawSetColor(COLOR1); + + DrawTab(AIMTAB, iTabIndex, m_x, m_y, "AIM"); + DrawTab(ESPTAB, iTabIndex, m_x + 100, m_y, "VISUALS"); + DrawTab(MISCTAB, iTabIndex, m_x + 200, m_y, "MISC"); + + Draw::FillRGBA(m_x, m_y + 1, m_w, m_h, COLOR3); + Draw::FillRGBA(m_x + 1, m_y + 2, m_w - 2, m_h - 2, COLOR4); + Draw::FillRGBA(m_x + 6, m_y + 7, m_w - 12, m_h - 12, COLOR3); + Draw::FillRGBA(m_x + 7, m_y + 8, m_w - 14, m_h - 14, COLOR5); + Draw::FillRGBA(m_x + 5, m_y + 6, m_w - 10, 17, COLOR3); + Draw::FillRGBA(m_x + 5, m_y + 7, m_w - 10, 15, COLOR5); + + #define BUILDSTAMP ( L"BUILD DATE: " __DATE__ L" @ " __TIME__ ) + Draw::DrawTexts(Fonts::m_MenuFont, m_x + 15, m_y + 7, COLOR9, BUILDSTAMP); + + Draw::FillRGBA(m_x - 15, m_y + 95, 15, 55, COLOR3); + + if (g_Mouse.OneLeftClick(m_x - 14, m_y + 96, 14, 53)) //LOAD CFG + { + Config->Save(); + } + + if (g_Mouse.LeftClick(m_x - 14, m_y + 96, 14, 53)) + Draw::FillRGBA(m_x - 15, m_y + 95, 15, 55, COLOR9); + + Draw::FillRGBA(m_x - 14, m_y + 96, 14, 53, COLOR6); + Draw::DrawTexts(Fonts::m_MenuFont, m_x - 10, m_y + 95, COLOR9, L"S"); + Draw::DrawTexts(Fonts::m_MenuFont, m_x - 10, m_y + 107, COLOR9, L"A"); + Draw::DrawTexts(Fonts::m_MenuFont, m_x - 10, m_y + 119, COLOR9, L"V"); + Draw::DrawTexts(Fonts::m_MenuFont, m_x - 10, m_y + 131, COLOR9, L"E"); + + + Draw::FillRGBA(m_x + m_w, m_y + 95, 15, 55, COLOR3); + + if (g_Mouse.OneLeftClick(m_x + m_w, m_y + 96, 14, 53)) //SAVE CFG + { + Config->Load(); + } + + if (g_Mouse.LeftClick(m_x + m_w, m_y + 96, 15, 55)) + Draw::FillRGBA(m_x + m_w, m_y + 95, 15, 55, COLOR9); + + Draw::FillRGBA(m_x + m_w, m_y + 96, 14, 53, COLOR6); + + Draw::DrawTexts(Fonts::m_MenuFont, m_x + m_w + 3, m_y + 95, COLOR9, L"L"); + Draw::DrawTexts(Fonts::m_MenuFont, m_x + m_w + 3, m_y + 107, COLOR9, L"O"); + Draw::DrawTexts(Fonts::m_MenuFont, m_x + m_w + 3, m_y + 119, COLOR9, L"A"); + Draw::DrawTexts(Fonts::m_MenuFont, m_x + m_w + 3, m_y + 131, COLOR9, L"D"); + + InitMenuElements(); +} + +void cMenuSection::Draw(int x, int y, int w, int h) +{ + Draw::FillRGBA(x,y,10,1,COLOR2); + Draw::FillRGBA(x,y,1,h,COLOR2); + Draw::FillRGBA(x,y+h,w,1,COLOR2); + Draw::FillRGBA(x+w,y,1,h+1,COLOR2); + Draw::FillRGBA(x, y, w, 1, COLOR2); + + SetSectionPos(x,y); +} + +void cMenuSection::DrawAllDropDowns() +{ + int iNumOfDropDowns = vecDropDowns.size(); + + int iWhich = -1; + + for(int i2 = (iNumOfDropDowns - 1); i2 >= 0; i2--) + { + bool bIsActive = bActiveDropDown[i2]; + + if(bIsActive) + { + iWhich = i2; + + dwWait = GetTickCount() + 700; + break; + } + } + + for(int i = (iNumOfDropDowns - 1); i >= 0; i--) + { + int e_x = vecDropDowns[i].x; + int e_y = vecDropDowns[i].y; + int iCount = vecDropDowns[i].iCount; + + bool bIsActive = bActiveDropDown[i]; + + char **ppszNames = vecDropDowns[i].ppszNames; + float *fValues = vecDropDowns[i].fValues; + float *cvar = vecDropDowns[i].cvar; + + if(bIsActive) + { + int string_x = e_x + (DROPDOWN_WIDTH * 0.5); + + for(int ax = 0; ax < iCount; ax++) + { + if(g_Mouse.IsOver(e_x,e_y + (ax * DROPDOWN_HEIGHT),DROPDOWN_WIDTH,DROPDOWN_HEIGHT)) + { + if(!g_Menu.IsHandlingItem()) + g_Menu.AddMenuFlag(FL_DISABLEDRAG); + + Draw::FillRGBA(e_x + 1,e_y + 1 + (ax * DROPDOWN_HEIGHT),DROPDOWN_WIDTH - 1,DROPDOWN_HEIGHT - (ax == (iCount - 1) ? 1 : 0),COLOR5); + + if(g_Mouse.HasMouseOneJustBeenReleased()) + { + *cvar = fValues[ax]; + + bActiveDropDown[i] = false; + } + } + else + { + Draw::FillRGBA(e_x + 1,e_y + 1 + (ax * DROPDOWN_HEIGHT),DROPDOWN_WIDTH - 1,DROPDOWN_HEIGHT - (ax == (iCount - 1) ? 1 : 0),COLOR4); + + if(g_Mouse.HasMouseOneJustBeenReleased()) + { + bActiveDropDown[i] = false; + } + } + + if(ax == (iCount - 1)) + Draw::SoftOutlinedRectangle(e_x,e_y,DROPDOWN_WIDTH,(ax + 1) * DROPDOWN_HEIGHT,COLOR3); + + if(*cvar == fValues[ax]) + Draw::DrawStringA(Fonts::m_ListItemFont,true,string_x,e_y + (ax * DROPDOWN_HEIGHT),COLOR9,ppszNames[ax]); + else + Draw::DrawStringA(Fonts::m_ListItemFont,true,string_x,e_y + (ax * DROPDOWN_HEIGHT),LISTITEM_TEXTCOLOR,ppszNames[ax]); + } + } + else + { + if(g_Mouse.IsOver(e_x,e_y,DROPDOWN_WIDTH,DROPDOWN_HEIGHT)) + { + if(!g_Menu.IsHandlingItem()) + g_Menu.AddMenuFlag(FL_DISABLEDRAG); + + Draw::FillRGBA(e_x + 1,e_y + 1,DROPDOWN_WIDTH - 1,DROPDOWN_HEIGHT - 1,COLOR5); + + if(g_Mouse.HasMouseOneJustBeenReleased() && (dwWait < GetTickCount() || iWhich == -1)) + { + bActiveDropDown[i] = true; + } + } + else + Draw::FillRGBA(e_x + 1,e_y + 1,DROPDOWN_WIDTH - 1,DROPDOWN_HEIGHT - 1,COLOR4); + + Draw::SoftOutlinedRectangle(e_x,e_y,DROPDOWN_WIDTH,DROPDOWN_HEIGHT,COLOR3); + + int string_x = e_x + (DROPDOWN_WIDTH * 0.5); + int string_y = e_y; + + for(int ax = 0; ax < iCount; ax++) + { + if(*cvar == fValues[ax]) + { + Draw::DrawStringA(Fonts::m_ListItemFont,true,string_x,string_y,LISTITEM_TEXTCOLOR,ppszNames[ax]); + break; + } + } + } + } + + ClearAllElementSpecifics(); +} + +void cMenuSection::AddElement(int iType, int add_to_x, const wchar_t *pszElementName, float *cvar, float min, float max, float step) +{ + int e_x = s_x + 10 + add_to_x; + int e_y = s_y + 15 + (iSection * ELEMENT_SEPERATION); + + bool bDropDownActive = false; + + for (int i2 = 0; i2 < 50; i2++) + { + bDropDownActive = bActiveDropDown[i2]; + + if (bDropDownActive) + break; + } + + if (iType == ONOFF) + { + Draw::DrawTexts(Fonts::m_WatermarkFont, e_x, e_y, LISTITEM_TEXTCOLOR, pszElementName); + + e_x += CHECKBOX_SEPERATION_FROM_TEXT; + + if (g_Mouse.OneLeftClick(e_x - 3, e_y - 3, CHECKBOX_SIZE + 5, CHECKBOX_SIZE + 5) && !bDropDownActive) + *cvar = !*cvar; + + e_y += 1; + + Draw::FillRGBA(e_x, e_y, CHECKBOX_SIZE, CHECKBOX_SIZE, COLOR7); + + if (*cvar) + { + pSurface->DrawSetColor(COLOR4); + + pSurface->DrawLine(e_x + 2, e_y + 2, e_x + CHECKBOX_SIZE - 1, e_y + CHECKBOX_SIZE - 1); + pSurface->DrawLine(e_x + CHECKBOX_SIZE - 2, e_y + 2, e_x + 1, e_y + CHECKBOX_SIZE - 1); + } + + if (g_Mouse.IsOver(e_x, e_y, CHECKBOX_SIZE, CHECKBOX_SIZE)) + { + Draw::OutlinedRectangle(e_x, e_y, CHECKBOX_SIZE, CHECKBOX_SIZE, COLOR9); + + if (!g_Menu.IsHandlingItem()) + g_Menu.AddMenuFlag(FL_DISABLEDRAG); + } + else + Draw::OutlinedRectangle(e_x, e_y, CHECKBOX_SIZE, CHECKBOX_SIZE, COLOR4); + } + else if (iType == DROPDOWN) + { + Draw::DrawTexts(Fonts::m_WatermarkFont, e_x, e_y, LISTITEM_TEXTCOLOR, pszElementName); + + e_y += 1; + + DropDown_t ddNew; + + ddNew.x = e_x + CHECKBOX_SEPERATION_FROM_TEXT - 20; + ddNew.y = e_y - 2; + ddNew.fValues = fValueList; + ddNew.cvar = cvar; + ddNew.ppszNames = ppszValueNames; + ddNew.iCount = iValueCount; + + AddDropDownToDrawList(ddNew); + } + else if (iType == SLIDER) + { + float Scale = max / 245; + + bool bOver = false; + + + wchar_t szCopy[256]; + + wcscpy_s(szCopy, pszElementName); + swprintf_s(szCopy, L"%s %2.2f", pszElementName, *cvar); + + Draw::DrawTexts(Fonts::m_WatermarkFont, e_x, e_y - 7, LISTITEM_TEXTCOLOR, szCopy); + + + e_y += 8; + + Draw::FillRGBA(e_x + 3, e_y + 7, 240, 1, 115, 120, 123, 185); + + int mouse_x, mouse_y; + g_Mouse.GetMousePosition(mouse_x, mouse_y); + + if (mouse_x >= (e_x - 3) && mouse_x <= (e_x + fLength + 3) && mouse_y >= (e_y) && mouse_y <= (e_y + 10) && GetAsyncKeyState(VK_LBUTTON) && (iSliderIndex == -1) && dwWait < GetTickCount() && !bSliderFix[iCurrSlider]) + { + iSliderIndex = iCurrSlider; + bSliderFix[iCurrSlider] = true; + + if (!g_Menu.IsHandlingItem()) + g_Menu.AddMenuFlag(FL_DISABLEDRAG); + } + + if (mouse_x >= (e_x - 1000) && mouse_x <= (e_x + fLength + 1000) && mouse_y >= (e_y - 1000) && mouse_y <= (e_y + 1000) && GetAsyncKeyState(VK_LBUTTON) && !bDropDownActive) + { + if (bSliderFix[iCurrSlider]) + { + *cvar = min + (mouse_x - e_x) * Scale; + + bOver = true; + + if (!g_Menu.IsHandlingItem()) + g_Menu.AddMenuFlag(FL_DISABLEDRAG); + } + } + else if (bSliderFix[iCurrSlider]) + { + iSliderIndex = -1; + bSliderFix[iCurrSlider] = false; + } + + if (*cvar > max) + *cvar = max; + + if (*cvar < min) + *cvar = min; + + static int iSizeOf = 6; + + for (int nu = 0; nu <= iSizeOf; nu++) + { + Draw::FillRGBA(e_x + (*cvar / Scale) - iSizeOf + nu, e_y + iSizeOf - nu, (iSizeOf + 1) - nu, 1, COLOR4); + Draw::FillRGBA(e_x + (*cvar / Scale) - iSizeOf + nu, e_y + iSizeOf + nu, (iSizeOf + 1) - nu, 1, COLOR4); + + Draw::FillRGBA(e_x + (*cvar / Scale), e_y + iSizeOf - nu, (iSizeOf + 1) - nu, 1, COLOR4); + Draw::FillRGBA(e_x + (*cvar / Scale), e_y + iSizeOf + nu, (iSizeOf + 1) - nu, 1, COLOR4); + } + + if (g_Mouse.IsOver(e_x + (*cvar / Scale) - iSizeOf, e_y - 1, 10, 14) || bOver) + pSurface->DrawSetColor(COLOR9); + else + pSurface->DrawSetColor(COLOR6); + + pSurface->DrawLine(e_x + (*cvar / Scale) - (iSizeOf + 1), e_y + iSizeOf, e_x + (*cvar / Scale), e_y - 1); + pSurface->DrawLine(e_x + (*cvar / Scale), e_y - 1, e_x + (*cvar / Scale) + (iSizeOf + 1), e_y + iSizeOf); + pSurface->DrawLine(e_x + (*cvar / Scale) + (iSizeOf + 1), e_y + iSizeOf, e_x + (*cvar / Scale), e_y + (iSizeOf * 2 + 1)); + pSurface->DrawLine(e_x + (*cvar / Scale), e_y + (iSizeOf * 2 + 1), e_x + (*cvar / Scale) - (iSizeOf + 1), e_y + iSizeOf); + } + else if (iType == ADDER) + { + + Draw::DrawTexts(Fonts::m_WatermarkFont, e_x, e_y, LISTITEM_TEXTCOLOR, pszElementName); + + e_y += 1; + + e_x += (CHECKBOX_SEPERATION_FROM_TEXT - 20); + + Draw::FillRGBA(e_x, e_y, ADDER_SIZE, ADDER_SIZE, COLOR7); + + if (g_Mouse.IsOver(e_x, e_y, ADDER_SIZE, ADDER_SIZE)) + { + Draw::OutlinedRectangle(e_x, e_y, ADDER_SIZE, ADDER_SIZE, COLOR9); + + if (g_Mouse.HasMouseOneJustBeenReleased() && !bDropDownActive) + *cvar -= step; + + if (g_Mouse.IsMouseTwoBeingHeld() && !bDropDownActive) + *cvar -= 1; + } + else + Draw::OutlinedRectangle(e_x, e_y, ADDER_SIZE, ADDER_SIZE, COLOR4); + + Draw::DrawStringA(Fonts::m_ListItemFont, true, e_x + ADDER_SIZE * 0.5, e_y - 1, COLOR9, "<"); + + Draw::DrawStringA(Fonts::m_WatermarkFont, true, e_x - 6 + ADDER_SIZE + ADDER_SEPERATE_FROM_BOXES * 0.5, e_y - 2, LISTITEM_TEXTCOLOR, "%2.0f", *cvar); + + e_x += ADDER_SEPERATE_FROM_BOXES; + + Draw::FillRGBA(e_x, e_y, ADDER_SIZE, ADDER_SIZE, COLOR7); + + if (g_Mouse.IsOver(e_x, e_y, ADDER_SIZE, ADDER_SIZE)) + { + Draw::OutlinedRectangle(e_x, e_y, ADDER_SIZE, ADDER_SIZE, COLOR9); + + if (g_Mouse.HasMouseOneJustBeenReleased() && !bDropDownActive) + *cvar += step; + + if (g_Mouse.IsMouseTwoBeingHeld() && !bDropDownActive) + *cvar += 1; + } + else + Draw::OutlinedRectangle(e_x, e_y, ADDER_SIZE, ADDER_SIZE, COLOR4); + + + Draw::DrawStringA(Fonts::m_ListItemFont, true, e_x + ADDER_SIZE * 0.5, e_y - 1, COLOR9, ">"); + + //clamp but go to min,max instead of not allowing to increase/decrease + if (*cvar < min) + *cvar = max; + + if (*cvar > max) + *cvar = min; + } + + PostElement((iType == SLIDER ? 2 : 1)); +} \ No newline at end of file diff --git a/menu.h b/menu.h new file mode 100644 index 0000000..0826831 --- /dev/null +++ b/menu.h @@ -0,0 +1,172 @@ + + +#define NUM_OF_TABS 3 + +enum +{ + FL_DISABLEDRAG = (1 << 1) +}; + +enum +{ + AIMTAB, + ESPTAB, + MISCTAB +}; + +enum +{ + ONOFF, + DROPDOWN, + SLIDER, + ADDER +}; + +typedef struct DropDown_s +{ + int x, y; + int iCount; + + float *fValues; + float *cvar; + + char **ppszNames; +} DropDown_t; + +class cMenuSection +{ +public: + void Draw(int x, int y, int w, int h); + + void AddElement(int iType, int add_to_x, const wchar_t *pszElementName, float *cvar, float min = 0, float max = 1, float step = 1); + + void DrawAllDropDowns(); + + void PostSection() + { + DrawAllDropDowns(); + } + + void ClearSection() + { + vecDropDowns.clear(); + + RestartSection(); + } + + void RestartSection() + { + iSection = 0; + } + + void PostElement(int increment = 1) + { + iSection += increment; + } + + void SetSlider(int &iCurrentSlider, bool bColor = false, float fLen = 360.0f) + { + bColored = bColor; + + fLength = fLen; + + iCurrentSlider++; + } + + void SetSectionPos(int x, int y) + { + s_x = x; + s_y = y; + } + + void SetValueNames(char **szArrayArray, float *fArray, int iCount) + { + ppszValueNames = szArrayArray; + fValueList = fArray; + iValueCount = iCount; + } + + void ClearAllElementSpecifics() + { + SetValueNames(NULL,NULL,0); + } + +private: + void AddDropDownToDrawList(DropDown_t ddNew) + { + vecDropDowns.push_back(ddNew); + } + + int iSection; + int s_x, s_y; + + //dropdown specifics + //---------------------- + float *fValueList; + char **ppszValueNames; + int iValueCount; + bool bActiveDropDown[50]; + std::vector vecDropDowns; + //---------------------- + + //slider specifics + //---------------------- + bool bColored; + float fLength; +}; + +class cMenu +{ +public: + cMenu(int x, int y, int w, int h); + + void InitMenuElements(); + + void DrawMenu(); + + void SetMenuPos(int x, int y) + { + m_x = x; + m_y = y; + } + + void GetMenuPos(int &out_x, int &out_y) + { + out_x = m_x; + out_y = m_y; + } + + void GetMenuSize(int &out_w, int &out_h) + { + out_w = m_w; + out_h = m_h; + } + + bool IsHandlingItem() + { + return (iMenuFlags & FL_DISABLEDRAG); + } + + void AddMenuFlag(int iFlag) + { + iMenuFlags |= iFlag; + } + + void RemoveMenuFlag(int iFlag) + { + iMenuFlags &= ~iFlag; + } + + int GetTabIndex() + { + return iTabIndex; + } +private: + void DrawTab(int index, int &setindex, int x, int y, const char *pszTitle); + + int m_x, m_y, m_w, m_h; + int iMenuFlags; + int iTabIndex; +}; + +extern cMenu g_Menu; \ No newline at end of file diff --git a/model.h b/model.h new file mode 100644 index 0000000..c31d0a1 --- /dev/null +++ b/model.h @@ -0,0 +1,60 @@ + +void OverridematerialXQZ(IMaterial* mat, float r, float g, float b) +{ + mat->SetMaterialVarFlag(IGNOREZ, true); + mat->SetMaterialVarFlag(ZNEARER, true); + mat->SetMaterialVarFlag(NOCULL, true); + mat->SetMaterialVarFlag(NOFOG, true); + mat->SetMaterialVarFlag(HALFLAMBERT, true); + mat->ColorModulate(r / 255, g / 255, b / 255); + pModelRender->ForcedMaterialOverride(mat); +} + +void Overridematerial(IMaterial* mat, float r, float g, float b) +{ + mat->SetMaterialVarFlag(IGNOREZ, false); + mat->SetMaterialVarFlag(ZNEARER, true); + mat->SetMaterialVarFlag(NOCULL, true); + mat->SetMaterialVarFlag(NOFOG, true); + mat->SetMaterialVarFlag(HALFLAMBERT, true); + mat->ColorModulate(r / 255, g / 255, b / 255); + pModelRender->ForcedMaterialOverride(mat); +} + +typedef void(__thiscall *DrawModelExecuteFn)(IVModelRender*, void*, const ModelRenderInfo_t&, matrix3x4_t*); +DrawModelExecuteFn draw_model_original = nullptr; + +void __stdcall hkDrawModelExecute(void* state, const ModelRenderInfo_t &pInfo, matrix3x4_t *pCustomBoneToWorld) +{ + static IMaterial* material = pMaterialSystem->FindMaterial("debug/debugambientcube", "Model textures"); + static IMaterial* vomitboomer = pMaterialSystem->FindMaterial(("particle/screenspaceboomervomit"), "Particle textures"); + + if (pInfo.pModel && pInfo.entity_index && material && vomitboomer) + { + const char *pszModelName = pModel->GetModelName(pInfo.pModel); + CBaseEntity* pEntity = (CBaseEntity*)pEntList->GetClientEntity(pInfo.entity_index); + + vomitboomer->SetMaterialVarFlag(NO_DRAW, gCvars.NOVOMIT); + + if (gCvars.CHAMHAND && pszModelName && strstr(pszModelName, "models/weapons/arms/v_arms")) + { + Overridematerial(material, gCvars.espcolor[0], gCvars.espcolor[1], gCvars.espcolor[2]); + } + + if (gCvars.CHAMS && pEntity) + { + if (pEntity->GetTeamNum() == TEAM_ZOMBY && pEntity->GetGroup() && pEntity->ValidEntity()) + { + if (gCvars.CHAMSXQZ) + { + OverridematerialXQZ(material, gCvars.espcolor[1], gCvars.espcolor[2], gCvars.espcolor[0]); + draw_model_original(pModelRender, state, pInfo, pCustomBoneToWorld); + } + Overridematerial(material, gCvars.espcolor[0], gCvars.espcolor[1], gCvars.espcolor[2]); + } + } + } + + draw_model_original(pModelRender, state, pInfo, pCustomBoneToWorld); + pModelRender->ForcedMaterialOverride(nullptr); +} \ No newline at end of file diff --git a/modelsinfo.h b/modelsinfo.h new file mode 100644 index 0000000..ab13aa8 --- /dev/null +++ b/modelsinfo.h @@ -0,0 +1,67 @@ +#pragma once + +enum +{ + HITGROUP_GENERIC = 0, + HITGROUP_HEAD = 1, + HITGROUP_CHEST = 2, + HITGROUP_STOMACH = 3, + HITGROUP_LEFTARM = 4, + HITGROUP_RIGHTARM = 5, + HITGROUP_LEFTLEG = 6, + HITGROUP_RIGHTLEG = 7, + HITGROUP_GEAR = 10, +}; + +struct mstudiobbox +{ + int bone; + int group; + Vector bbmin; + Vector bbmax; + int szhitboxnameindex; + int unused[8]; +}; + +struct mstudiohitboxset +{ + int sznameindex; + inline char* const pszName(void) const { return ((char*)this) + sznameindex; } + int numhitboxes; + int hitboxindex; + inline mstudiobbox* pHitbox(int i) const { return (mstudiobbox*)(((BYTE*)this) + hitboxindex) + i; }; +}; + +struct studiohdr +{ + unsigned char pad[0xAC]; + int numhitboxsets; + int hitboxsetindex; + + mstudiohitboxset* pHitboxSet(int i) const + { + return (mstudiohitboxset*)(((BYTE*)this) + hitboxsetindex) + i; + }; + + inline int GetHitboxCount(int set) const + { + mstudiohitboxset const* s = pHitboxSet(set); + if (!s) + return 0; + return s->numhitboxes; + } +}; + +class CModelInfo +{ +public: + inline const char* GetModelName(const void* Model) + { + return getvfunc(this, 3)(this, Model); + } + studiohdr* GetStudiomodel(const DWORD *mod) + { + typedef studiohdr* (__thiscall* GetStudiomodelFn)(void*, const DWORD*); + return getvfunc< GetStudiomodelFn >(this, 30)(this, mod); + } +}; \ No newline at end of file diff --git a/mouse.cpp b/mouse.cpp new file mode 100644 index 0000000..fa3e3fa --- /dev/null +++ b/mouse.cpp @@ -0,0 +1,100 @@ +#include "hooks.h" + +cMouse g_Mouse; + +void cMouse::Drag(bool& bDrag, bool bCheck, bool bDragCheck,int& x, int& y, int& xdif, int& ydif) +{ + if(bCheck) + { + if(bDragCheck || (mouse1pressed && bDrag)) + { + if(!bDrag) + bDrag = true; + + if(xdif == -1 || ydif == -1) + { + xdif = mouse_x - x; + ydif = mouse_y - y; + } + + x += mouse_x - (xdif + x); + y += mouse_y - (ydif + y); + } + else + { + if(bDrag) + bDrag = false; + + xdif = -1; + ydif = -1; + } + } +} + +bool cMouse::LeftClick(int x,int y,int w,int h) +{ + return (mouse1pressed && IsOver(x,y,w,h)); +} + +bool cMouse::OneLeftClick(int x,int y,int w,int h) +{ + return (mouse1released && IsOver(x,y,w,h)); +} + +bool cMouse::IsOver(int x,int y,int w,int h) +{ + return (mouse_x > x && w+x > mouse_x && mouse_y > y && h+y > mouse_y); +} + +void cMouse::Update() +{ + int width, height; + pEngine->GetScreenSize(width, height); + + static auto window = FindWindowA(0, "Valve001"); + + tagPOINT tp; + GetCursorPos(&tp); + + LPPOINT pPoint = &tp; + ScreenToClient(window, pPoint); + + mouse_x = pPoint->x; + mouse_y = pPoint->y; + + if (mouse_x > width) + mouse_x = width; + + if (mouse_x < 0) + mouse_x = 0; + + if (mouse_y > height) + mouse_y = height; + + if (mouse_y < 0) + mouse_y = 0; + + if (GetAsyncKeyState(VK_LBUTTON)) + mouse1pressed = true; + else if (!GetAsyncKeyState(VK_LBUTTON)) + { + if (mouse1pressed) + mouse1released = true; + else + mouse1released = false; + + mouse1pressed = false; + } + + if (GetAsyncKeyState(VK_RBUTTON)) + mouse2pressed = true; + else if (!GetAsyncKeyState(VK_RBUTTON)) + { + if (mouse2pressed) + mouse2released = true; + else + mouse2released = false; + + mouse2pressed = false; + } +} \ No newline at end of file diff --git a/mouse.h b/mouse.h new file mode 100644 index 0000000..bfa72fe --- /dev/null +++ b/mouse.h @@ -0,0 +1,42 @@ +#define MAX_DRAG_OBJECTS 3 + +class cMouse +{ +public: + void Update(); + + bool LeftClick(int x,int y,int w,int h); + bool OneLeftClick(int x,int y,int w,int h); + bool IsOver(int x,int y,int w,int h); + + void Drag(bool& bDrag, bool bCheck, bool bDragCheck,int& x, int& y, int& xdif, int& ydif); + + void GetMousePosition(int &posx, int &posy) + { + posx = mouse_x; + posy = mouse_y; + } + + bool HasMouseOneJustBeenReleased() + { + return mouse1released; + } + + bool IsMouseTwoBeingHeld() + { + return mouse2pressed; + } + + bool bDragged[MAX_DRAG_OBJECTS]; + int iDiffX[MAX_DRAG_OBJECTS]; + int iDiffY[MAX_DRAG_OBJECTS]; + + int mouse_x, mouse_y; +private: + bool mouse1pressed; + bool mouse2pressed; + bool mouse2released; + bool mouse1released; +}; + +extern cMouse g_Mouse; diff --git a/netvars.cpp b/netvars.cpp new file mode 100644 index 0000000..b462cde --- /dev/null +++ b/netvars.cpp @@ -0,0 +1,141 @@ + +#include "hooks.h" + +Netvarmanager g_Netvarmanager; + +void Netvarmanager::Init(void) +{ + m_tables.clear(); + m_savedproxy.clear(); + + ClientClass *clientClass = pClient->GetAllClasses(); + + if (!clientClass) + { + return; + } + + while (clientClass) + { + RecvTable *recvTable = clientClass->GetTable; + + m_tables.push_back(recvTable); + + clientClass = clientClass->NextClass; + } +} + +Netvarmanager::~Netvarmanager(void) +{ + for (int i = 0; i < m_savedproxy.size(); i++) + { + RecvProp *recvProp = 0; + Get_Prop(m_savedproxy[i].szTableName, m_savedproxy[i].szPropName, &recvProp); + + if (!recvProp) + return; + + recvProp->m_ProxyFn = m_savedproxy[i].SavedProxy; + } +} + +int Netvarmanager::GetOffset(const char *tableName, const char *propName) +{ + int offset = Get_Prop(tableName, propName); + + if (!offset) + { + return 0; + } + + return offset; +} + + +int Netvarmanager::Get_Prop(const char *tableName, const char *propName, RecvProp **prop) +{ + RecvTable *recvTable = GetTable(tableName); + + if (!recvTable) + { + return 0; + } + + + int offset = Get_Prop(recvTable, propName, prop); + + if (!offset) + { + return 0; + } + + + return offset; +} + + +int Netvarmanager::Get_Prop(RecvTable *recvTable, const char *propName, RecvProp **prop) +{ + int extraOffset = 0; + + for (int i = 0; i < recvTable->m_nProps; ++i) + { + RecvProp *recvProp = &recvTable->m_pProps[i]; + + + RecvTable *child = recvProp->m_pDataTable; + + if (child + && (child->m_nProps > 0)) + { + int tmp = Get_Prop(child, propName, prop); + + if (tmp) + { + extraOffset += (recvProp->m_Offset + tmp); + } + } + + + if (_stricmp(recvProp->m_pVarName, propName)) + { + continue; + } + + + if (prop) + { + *prop = recvProp; + } + + return (recvProp->m_Offset + extraOffset); + } + + return extraOffset; +} + + +RecvTable *Netvarmanager::GetTable(const char *tableName) +{ + if (m_tables.empty()) + { + return 0; + } + + + for each (RecvTable *table in m_tables) + { + if (!table) + { + continue; + } + + + if (_stricmp(table->m_pNetTableName, tableName) == 0) + { + return table; + } + } + + return 0; +} diff --git a/netvars.h b/netvars.h new file mode 100644 index 0000000..37ded38 --- /dev/null +++ b/netvars.h @@ -0,0 +1,24 @@ +#pragma once + +typedef struct +{ + char szTableName[256]; + char szPropName[256]; + RecvVarProxyFn SavedProxy; +} Oldproxy_t; + +class Netvarmanager +{ +public: + ~Netvarmanager(void); + void Init(); + int GetOffset(const char *tableName, const char *propName); +private: + int Get_Prop(const char *tableName, const char *propName, RecvProp **prop = 0); + int Get_Prop(RecvTable *recvTable, const char *propName, RecvProp **prop = 0); + RecvTable *GetTable(const char *tableName); + std::vector m_tables; + std::vector m_savedproxy; +}; + +extern Netvarmanager g_Netvarmanager; diff --git a/panel.h b/panel.h new file mode 100644 index 0000000..9a4112e --- /dev/null +++ b/panel.h @@ -0,0 +1,152 @@ +#pragma once + +bool bMenu = false; + +using paint_traverse_t = void(__thiscall *)(void*, unsigned int, bool, bool); +paint_traverse_t painttraverse_original = nullptr; + +void __fastcall hkPaintTraverse(void* pPanels, int edx, unsigned int vguiPanel, bool forceRepaint, bool allowForce) +{ + painttraverse_original(pPanels, vguiPanel, forceRepaint, allowForce); + + CBaseEntity* pLocal = pEntList->GetClientEntity(pEngine->GetLocalPlayer()); + + if (!pLocal)//superior way of checking if we are ingame + { + static unsigned int FocusOverlayPanel = 0; + + static bool FoundPanel = false; + + if (!FoundPanel) + { + PCHAR szPanelName = (PCHAR)pPanel->GetName(vguiPanel); + if (strstr(szPanelName, "MainMenu")) + { + FocusOverlayPanel = vguiPanel; + + FoundPanel = true; + } + } + else if (FocusOverlayPanel == vguiPanel) + { + if (GetAsyncKeyState(VK_DELETE) & 1) + bMenu = !bMenu; + + if (gCvars.watermark) + { + Draw::DrawTexts(Fonts::m_MenuFont, 20, 20, 255, 255, 255, 255, L"INTERWEBZ"); + } + + if (bMenu) + { + g_Mouse.Update(); + + int copy_x, copy_y; + int copy_w, copy_h; + + g_Menu.GetMenuPos(copy_x, copy_y); + g_Menu.GetMenuSize(copy_w, copy_h); + + g_Menu.DrawMenu(); + + g_Mouse.Drag(g_Mouse.bDragged[0], + !g_Menu.IsHandlingItem(), + g_Mouse.LeftClick(copy_x, copy_y, copy_w, copy_h), copy_x, copy_y, g_Mouse.iDiffX[0], g_Mouse.iDiffY[0]); + + g_Menu.SetMenuPos(copy_x, copy_y); + + if (g_Menu.IsHandlingItem()) + g_Menu.RemoveMenuFlag(FL_DISABLEDRAG); + } + + if (!pLocal) + { + FoundPanel = false; + } + } + } + + if (pLocal)//WERE INGAME LOL + { + static unsigned int FocusOverlayPanel = 0; + + static bool FoundPanel = false; + + if (!FoundPanel) + { + PCHAR szPanelName = (PCHAR)pPanel->GetName(vguiPanel); + if (strstr(szPanelName, "FocusOverlayPanel")) + { + FocusOverlayPanel = vguiPanel; + + FoundPanel = true; + } + } + else if (FocusOverlayPanel == vguiPanel) + { + if (GetAsyncKeyState(VK_DELETE) & 1) + bMenu = !bMenu; + + int iScreenWidth, iScreenHeight; + pEngine->GetScreenSize(iScreenWidth, iScreenHeight); + + if (gCvars.ESPBOX || gCvars.ESPNAME || gCvars.ESPHEALTH) + { + ESP::draw(pLocal); + } + + if (gCvars.watermark) + { + Draw::DrawTexts(Fonts::m_MenuFont, 20, 20, 255, 255, 255, 255, L"INTERWEBZ"); + } + + if (gCvars.radar) + { + ESP::DrawRadarBack(iScreenWidth, iScreenHeight); + ESP::drawradar(iScreenWidth, iScreenHeight, pLocal); + } + + if (pLocal->IsAlive()) + { + if (gCvars.velocity) + { + ESP::drawvelocity(iScreenWidth, iScreenHeight, pLocal); + } + + if (gCvars.drawmonitor) + { + ESP::DrawMonitor(iScreenWidth, iScreenHeight, pLocal); + } + } + + pPanel->SetMouseInputEnabled(vguiPanel, bMenu); + + if (bMenu) + { + g_Mouse.Update(); + + int copy_x, copy_y; + int copy_w, copy_h; + + g_Menu.GetMenuPos(copy_x, copy_y); + g_Menu.GetMenuSize(copy_w, copy_h); + + g_Menu.DrawMenu(); + + g_Mouse.Drag(g_Mouse.bDragged[0], + !g_Menu.IsHandlingItem(), + g_Mouse.LeftClick(copy_x, copy_y, copy_w, copy_h), copy_x, copy_y, g_Mouse.iDiffX[0], g_Mouse.iDiffY[0]); + + g_Menu.SetMenuPos(copy_x, copy_y); + + if (g_Menu.IsHandlingItem()) + g_Menu.RemoveMenuFlag(FL_DISABLEDRAG); + } + + if (pLocal) + { + FoundPanel = false; + } + } + } +} diff --git a/panels.h b/panels.h new file mode 100644 index 0000000..ad3e5d9 --- /dev/null +++ b/panels.h @@ -0,0 +1,17 @@ + + + +class IPanel +{ +public: + void SetMouseInputEnabled(unsigned int iPanel, bool bState) + { + return (getvfunc(this, 32))(this, iPanel, bState); + } + + const char *GetName(unsigned int vguiPanel) + { + typedef const char* (__thiscall* OriginalFn)(PVOID, unsigned int); + return getvfunc(this, 36)(this, vguiPanel); + } +}; \ No newline at end of file diff --git a/recvprop.h b/recvprop.h new file mode 100644 index 0000000..b81ed78 --- /dev/null +++ b/recvprop.h @@ -0,0 +1,83 @@ +#pragma once + +#include + +struct RecvProp; + +class DVariant +{ +public: + union + { + float m_Float; + long m_Int; + char *m_pString; + void *m_pData; + float m_Vector[3]; + }; +}; + +namespace SourceEngine +{ + enum class SendPropType + { + DPT_Int = 0, + DPT_Float, + DPT_Vector, + DPT_VectorXY, // Only encodes the XY of a vector, ignores Z + DPT_String, + DPT_Array, // An array of the base types (can't be of datatables). + DPT_DataTable, + DPT_Int64, + DPT_NUMSendPropTypes + }; +}; + +class CRecvProxyData +{ +public: + const RecvProp *m_pRecvProp; + DVariant m_Value; + int m_iElement; + int m_ObjectID; +}; + +typedef void(*RecvVarProxyFn)(const CRecvProxyData *pData, void *pStruct, void *pOut); + +struct RecvTable +{ + RecvProp *m_pProps; + int m_nProps; + void *m_pDecoder; + char *m_pNetTableName; + bool m_bInitialized; + bool m_bInMainList; +}; + +struct RecvProp +{ + char *m_pVarName; + int m_RecvType; + int m_Flags; + int m_StringBufferSize; + bool m_bInsideArray; + const void *m_pExtraData; + RecvProp *m_pArrayProp; + void* m_ArrayLengthProxy; + void* m_ProxyFn; + void* m_DataTableProxyFn; + RecvTable *m_pDataTable; + int m_Offset; + int m_ElementStride; + int m_nElements; + const char *m_pParentArrayPropName; +}; + +struct ClientClass +{ + BYTE _chPadding[8]; + char * GetName; + RecvTable * GetTable; + ClientClass * NextClass; + int GetClassID; +}; diff --git a/sigs.cpp b/sigs.cpp new file mode 100644 index 0000000..467f071 --- /dev/null +++ b/sigs.cpp @@ -0,0 +1,132 @@ + +#include "sigs.h" + +DWORD Findrekt(std::string moduleName, std::string Mask) +{ + const char* pat = Mask.c_str(); + DWORD firstMatch = 0; + DWORD rangeStart = (DWORD)GetModuleHandleA(moduleName.c_str()); + MODULEINFO miModInfo; GetModuleInformation(GetCurrentProcess(), (HMODULE)rangeStart, &miModInfo, sizeof(MODULEINFO)); + DWORD rangeEnd = rangeStart + miModInfo.SizeOfImage; + for (DWORD pCur = rangeStart; pCur < rangeEnd; pCur++) + { + if (!*pat) + { + return firstMatch; + } + if (*(PBYTE)pat == '\?' || *(BYTE*)pCur == getByte(pat)) + { + if (!firstMatch) + { + firstMatch = pCur; + } + + if (!pat[2]) + { + return firstMatch; + } + + + if (*(PWORD)pat == '\?\?' || *(PBYTE)pat != '\?') + { + pat += 3; + } + else + { + pat += 2; //one ? + } + + } + else + { + pat = Mask.c_str(); + firstMatch = 0; + } + } + return NULL; +} + +bool streq(const char *s1, const char *s2) +{ + for (; *s1 == *s2; s1++, s2++) + { + if (*s1 == '\0') + return true; + } + + return false; +} + +void *FindString(void *ptr, const char *string) +{ + char *start; + char *str = nullptr; + + for (start = (char *)ptr; str == nullptr; start++) + { + if (streq(start, string)) + str = start; + } + + while (1) + { + if (*(char **)start == str) + return start; + + start--; + } + + return nullptr; +} + +void *FindPattern(void *start, unsigned int len, const pattern *data) +{ + const char *pattern = (char *)data + 5; + const char *q = (char *)start; + + for (int i = 0, mask = *(int *)((char *)data + 1); i < len; i++, q++) + { + const char *seq = pattern; + const char *mem = q; + + + register bool g = true; + + for (int x = 0; x < 32; x++) + { + if ((mask & (1 << x)) && (mem[x] != *seq++)) + { + g = false; + break; + } + } + + if (g) return (void *)(q + (int)*(unsigned char *)data); + } + + return nullptr; +} + +void *FindPattern(const char *l, const pattern *data) +{ + return FindPattern(GetModuleHandle(l), -1, data); +} + +void *FindProlog(void *ptr) +{ + unsigned char *ins = (unsigned char *)ptr; + + while (ins > 0) + { + if ((ins[0] & 0xf0) == 0x50 && + (ins[1] & 0xf0) == 0x80 && + (ins[2] & 0x0f) == 0x0c) + { + return ins; + } + + ins--; + } + + return nullptr; +} diff --git a/sigs.h b/sigs.h new file mode 100644 index 0000000..ee5d592 --- /dev/null +++ b/sigs.h @@ -0,0 +1,17 @@ +#pragma once + +#include +#include +#include + +#define INRANGE(x,a,b) (x >= a && x <= b) +#define getBits( x ) (INRANGE((x&(~0x20)),'A','F') ? ((x&(~0x20)) - 'A' + 0xa) : (INRANGE(x,'0','9') ? x - '0' : 0)) +#define getByte( x ) (getBits(x[0]) << 4 | getBits(x[1])) + +class pattern; + +DWORD Findrekt(std::string moduleName, std::string Mask); +void *FindString(void *, const char *); +void *FindProlog(void *); +void *FindPattern(void *, unsigned int, const pattern *); +void *FindPattern(const char *, const pattern *); \ No newline at end of file diff --git a/surface.h b/surface.h new file mode 100644 index 0000000..27ae2e6 --- /dev/null +++ b/surface.h @@ -0,0 +1,74 @@ + + +class ISurface +{ +public: + + void DrawSetColor(int r, int g, int b, int a) + { + typedef void(__thiscall* OriginalFn)(PVOID, int, int, int, int); + getvfunc(this, 11)(this, r, g, b, a); + } + + void DrawFilledRect(int x0, int y0, int x1, int y1) + { + typedef void(__thiscall* OriginalFn)(PVOID, int, int, int, int); + getvfunc(this, 12)(this, x0, y0, x1, y1); + } + + void DrawOutlinedRect(int x0, int y0, int x1, int y1) + { + typedef void(__thiscall* OriginalFn)(PVOID, int, int, int, int); + getvfunc(this, 14)(this, x0, y0, x1, y1); + } + + void DrawLine(int x0, int y0, int x1, int y1) + { + typedef void(__thiscall* OriginalFn)(PVOID, int, int, int, int); + getvfunc(this, 15)(this, x0, y0, x1, y1); + } + + void DrawSetTextFont(unsigned long font) + { + typedef void(__thiscall* OriginalFn)(PVOID, unsigned long); + getvfunc(this, 17)(this, font); + } + + void DrawSetTextColor(int r, int g, int b, int a) + { + typedef void(__thiscall* OriginalFn)(PVOID, int, int, int, int); + getvfunc(this, 19)(this, r, g, b, a); + } + + void DrawSetTextPos(int x, int y) + { + typedef void(__thiscall* OriginalFn)(PVOID, int, int); + getvfunc(this, 20)(this, x, y); + } + + void DrawPrintText(const wchar_t *text, int textLen) + { + typedef void(__thiscall* OriginalFn)(PVOID, const wchar_t *, int, int); + return getvfunc(this, 22)(this, text, textLen, 0); + } + + unsigned long Create_Font() + { + typedef unsigned int(__thiscall* OriginalFn)(PVOID); + return getvfunc(this, 63)(this); + } + + void SetFontGlyphSet(unsigned long &font, const char *windowsFontName, int tall, int weight, int blur, int scanlines, int flags) + { + typedef void(__thiscall* OriginalFn)(PVOID, unsigned long, const char*, int, int, int, int, int, int, int); + getvfunc(this, 64)(this, font, windowsFontName, tall, weight, blur, scanlines, flags, 0, 0); + } + + void GetTextSize(unsigned long font, const wchar_t *text, int &wide, int &tall) + { + typedef void(__thiscall* OriginalFn)(void*, unsigned long font, const wchar_t *text, int &wide, int &tall); + getvfunc(this, 72)(this, font, text, wide, tall); + } +}; + + diff --git a/usercmd.h b/usercmd.h new file mode 100644 index 0000000..60229aa --- /dev/null +++ b/usercmd.h @@ -0,0 +1,17 @@ + + + +class CUserCmd +{ +public: + virtual ~CUserCmd() {}; + std::int32_t command_number; + std::int32_t tick_count; + Vector viewangles; + float forwardmove; + float sidemove; + float upmove; + std::int32_t buttons; +}; + + diff --git a/variables.cpp b/variables.cpp new file mode 100644 index 0000000..f178383 --- /dev/null +++ b/variables.cpp @@ -0,0 +1,95 @@ +#include "variables.h" + +void CConfig::Setup() +{ + SetupValue(gCvars.flRadarPos_x, false, ("Config"), ("flRadarPos_x")); + SetupValue(gCvars.flRadarPos_y, false, ("Config"), ("flRadarPos_y")); + SetupValue(gCvars.SMOOTHYAW, false, ("Config"), ("SMOOTHYAW")); + SetupValue(gCvars.SMOOTHPITCH, false, ("Config"), ("SMOOTHPITCH")); + SetupValue(gCvars.ENABLEAIM, false, ("Config"), ("ENABLEAIM")); + SetupValue(gCvars.AIMONFIRE, false, ("Config"), ("AIMONFIRE")); + SetupValue(gCvars.AIMFOV, false, ("Config"), ("AIMFOV")); + SetupValue(gCvars.NORECOIL, false, ("Config"), ("NORECOIL")); + SetupValue(gCvars.NOSPREAD, false, ("Config"), ("NOSPREAD")); + SetupValue(gCvars.AUTOFIRE, false, ("Config"), ("AUTOFIRE")); + SetupValue(gCvars.SILENTAIM, false, ("Config"), ("SILENTAIM")); + SetupValue(gCvars.ESPBOX, false, ("Config"), ("ESPBOX")); + SetupValue(gCvars.ESPNAME, false, ("Config"), ("ESPNAME")); + SetupValue(gCvars.ESPHEALTH, false, ("Config"), ("ESPHEALTH")); + SetupValue(gCvars.INGOREINFECTED, false, ("Config"), ("INGOREINFECTED")); + SetupValue(gCvars.CHAMS, false, ("Config"), ("CHAMS")); + SetupValue(gCvars.CHAMSXQZ, false, ("Config"), ("CHAMSXQZ")); + SetupValue(gCvars.CHAMHAND, false, ("Config"), ("CHAMHAND")); + SetupValue(gCvars.AUTOBH, false, ("Config"), ("AUTOBH")); + SetupValue(gCvars.AUTOFIRE, false, ("Config"), ("AUTOFIRE")); + SetupValue(gCvars.SILENTAIM, false, ("Config"), ("SILENTAIM")); + SetupValue(gCvars.radar, false, ("Config"), ("radar")); + SetupValue(gCvars.watermark, false, ("Config"), ("watermark")); + SetupValue(gCvars.velocity, false, ("Config"), ("velocity")); + SetupValue(gCvars.SILENTAIM, false, ("Config"), ("SILENTAIM")); + SetupValue(gCvars.triggerkey, false, ("Config"), ("triggerkey")); + SetupValue(gCvars.trigenable, false, ("Config"), ("trigenable")); + SetupValue(gCvars.trighead, false, ("Config"), ("trighead")); + SetupValue(gCvars.triggerbody, false, ("Config"), ("triggerbody")); + SetupValue(gCvars.trigerdelay, false, ("Config"), ("trigerdelay")); + SetupValue(gCvars.TRIGLIMB, false, ("Config"), ("TRIGLIMB")); + SetupValue(gCvars.NOVOMIT, false, ("Config"), ("NOVOMIT")); + SetupValue(gCvars.espcolor[0], false, ("Config"), ("espcolor0")); + SetupValue(gCvars.espcolor[1], false, ("Config"), ("espcolor1")); + SetupValue(gCvars.espcolor[2], false, ("Config"), ("espcolor2")); + SetupValue(gCvars.SPEEDKEY, false, ("Config"), ("SPEEDKEY")); + SetupValue(gCvars.SPEEDFAST, false, ("Config"), ("SPEEDFAST")); + SetupValue(gCvars.LAGKEY, false, ("Config"), ("LAGKEY")); + SetupValue(gCvars.LAGFAST, false, ("Config"), ("LAGFAST")); + SetupValue(gCvars.drawmonitor, false, ("Config"), ("drawmonitor")); + SetupValue(gCvars.f1monitorpos_x, false, ("Config"), ("f1monitorpos_x")); + SetupValue(gCvars.f1monitorpos_y, false, ("Config"), ("f1monitorpos_y")); +} + +void CConfig::SetupValue(float &value, float def, std::string category, std::string name) +{ + value = def; + floats.push_back(new ConfigValue(category, name, &value)); +} + +void CConfig::Save() +{ + static TCHAR path[MAX_PATH]; + std::string folder, file; + + if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, path))) + { + folder = std::string(path) + ("\\l4d2hack\\"); + file = std::string(path) + ("\\l4d2hack\\config.ini"); + } + + CreateDirectory(folder.c_str(), NULL); + + for (auto value : floats) + WritePrivateProfileString(value->category.c_str(), value->name.c_str(), std::to_string(*value->value).c_str(), file.c_str()); +} + +void CConfig::Load() +{ + static TCHAR path[MAX_PATH]; + std::string folder, file; + + if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, path))) + { + folder = std::string(path) + ("\\l4d2hack\\"); + file = std::string(path) + ("\\l4d2hack\\config.ini"); + } + + CreateDirectory(folder.c_str(), NULL); + + char value_l[32] = { '\0' }; + + for (auto value : floats) + { + GetPrivateProfileString(value->category.c_str(), value->name.c_str(), "", value_l, 32, file.c_str()); + *value->value = (float)atof(value_l); + } +} + +CConfig* Config = new CConfig(); +CGlobalVariables gCvars; \ No newline at end of file diff --git a/variables.h b/variables.h new file mode 100644 index 0000000..f81657f --- /dev/null +++ b/variables.h @@ -0,0 +1,84 @@ +#pragma once + +#include +#include +#include + +template +class ConfigValue +{ +public: + ConfigValue(std::string category_, std::string name_, T* value_) + { + category = category_; + name = name_; + value = value_; + } + + std::string category, name; + T* value; +}; + +class CConfig +{ +protected: + std::vector*> floats; +private: + void SetupValue(float&, float, std::string, std::string); +public: + CConfig() + { + Setup(); + } + + void Setup(); + void Save(); + void Load(); +}; + +class CGlobalVariables +{ +public: + float SMOOTHYAW; + float SMOOTHPITCH; + float ENABLEAIM; + float AIMONFIRE; + float AIMFOV; + float NORECOIL; + float NOSPREAD; + float AUTOFIRE; + float SILENTAIM; + float ESPBOX; + float ESPNAME; + float ESPHEALTH; + float INGOREINFECTED; + float CHAMS; + float CHAMSXQZ; + float CHAMHAND; + float AUTOBH; + float iSavedRadarX; + float iSavedRadarY; + float flRadarPos_x = 120; + float flRadarPos_y = 120; + float radar; + float espcolor[3]; + float watermark; + float velocity; + float triggerkey; + float trigenable; + float trighead; + float triggerbody; + float trigerdelay; + float TRIGLIMB; + float NOVOMIT; + float SPEEDKEY; + float SPEEDFAST; + float LAGKEY; + float LAGFAST; + float drawmonitor; + float f1monitorpos_x = 400; + float f1monitorpos_y = 400; +}; + +extern CConfig* Config; +extern CGlobalVariables gCvars; diff --git a/vector.h b/vector.h new file mode 100644 index 0000000..5552490 --- /dev/null +++ b/vector.h @@ -0,0 +1,218 @@ +#pragma once + +class Vector +{ +public: + Vector(); + Vector(float x, float y, float z); + + Vector& operator +=(const Vector&); + Vector& operator -=(const Vector&); + Vector& operator *=(const float); + + float& operator [](int index); + + Vector operator+(const Vector& v) const; + Vector operator-(const Vector& v) const; + Vector operator*(float fl) const; + Vector& operator = (const Vector&); + + bool IsZero(float tolerance = FLT_EPSILON); + void Zero(); + float Length2D(); + float Length2DSqr(); + float Length(); + float Normalize(); + float NormalizeInPlace(); + float length_sqr(); + float Dot(const Vector&); + + float x; + float y; + float z; +}; + +inline bool Vector::IsZero(float tolerance) +{ + return (x > -tolerance && x < tolerance && y > -tolerance && y < tolerance && z > -tolerance && z < tolerance); +} + +inline Vector& Vector::operator += (const Vector &in) +{ + x += in.x; + y += in.y; + z += in.z; + + return *this; +} + +inline Vector& Vector::operator -= (const Vector &in) +{ + x -= in.x; + y -= in.y; + z -= in.z; + + return *this; +} + +inline Vector& Vector::operator *= (const float in) +{ + x *= in; + y *= in; + z *= in; + + return *this; +} + +inline float& Vector::operator [] (int index) +{ + return ((&x)[index]); +} + +inline Vector Vector::operator+(const Vector& v) const +{ + Vector res; + res.x = x + v.x; + res.y = y + v.y; + res.z = z + v.z; + return res; +} + +inline Vector Vector::operator-(const Vector& v) const +{ + Vector res; + res.x = x - v.x; + res.y = y - v.y; + res.z = z - v.z; + return res; +} + +inline Vector Vector::operator*(float fl) const +{ + Vector res; + res.x = x * fl; + res.y = y * fl; + res.z = z * fl; + return res; +} + + +inline Vector& Vector::operator = (const Vector &in) +{ + x = in.x; + y = in.y; + z = in.z; + + return *this; +} + +inline Vector::Vector() +{ + x = y = z = 0.f; +} + +inline void Vector::Zero() +{ + x = y = z = 0.f; +} + +inline Vector::Vector(float _x, float _y, float _z) +{ + x = _x; + y = _y; + z = _z; +} + +inline float Vector::Length2D() +{ + float root = 0.f; + float sqst = x * x + y * y; + + __asm + { + sqrtss xmm0, sqst + movss root, xmm0 + } + + return root; +} + +inline float Vector::Length2DSqr() +{ + return x * x + y * y; +} + +inline float Vector::Dot(const Vector &in) +{ + return (x * in.x + y * in.y + z * in.z); +} + +inline float Vector::length_sqr() +{ + return x * x + y * y + z * z; +} + +inline float Vector::Length() +{ + float root = 0.f; + float sqsr = x * x + y * y + z * z; + + __asm + { + sqrtss xmm0, sqsr + movss root, xmm0 + } + + return root; +} + +inline float Vector::Normalize() +{ + float flLength = Length(); + float flLengthNormal = 1.f / (FLT_EPSILON + flLength); + + x = x * flLengthNormal; + y = y * flLengthNormal; + z = z * flLengthNormal; + + return flLength; +} + +inline float Vector::NormalizeInPlace() +{ + return Normalize(); +} + +class VectorAligned : public Vector +{ +public: + VectorAligned() + { + x = y = z = 0; + } + + VectorAligned(const Vector &in) + { + x = in.x; + y = in.y; + z = in.z; + } + + float w; +}; + +FORCEINLINE void VectorSubtract(const Vector& a, const Vector& b, Vector& c) +{ + c.x = a.x - b.x; + c.y = a.y - b.y; + c.z = a.z - b.z; +} + +FORCEINLINE void VectorAdd(const Vector& a, const Vector& b, Vector& c) +{ + c.x = a.x + b.x; + c.y = a.y + b.y; + c.z = a.z + b.z; +} + + diff --git a/visuals.cpp b/visuals.cpp new file mode 100644 index 0000000..6fee725 --- /dev/null +++ b/visuals.cpp @@ -0,0 +1,402 @@ +#include "hooks.h" + +#define COLORESP (gCvars.espcolor[0]), (gCvars.espcolor[1]), (gCvars.espcolor[2]), 255 + +void ESP::DrawMonitor(int x, int y, CBaseEntity * entity) +{ + int sizex = 50; + int sizey = 100; + + if (g_Mouse.LeftClick(gCvars.f1monitorpos_x - (sizex / 2) - 6, gCvars.f1monitorpos_y - (sizey / 2) - 6, sizex * 2 + 12, sizey * 2 + 12)) + { + gCvars.f1monitorpos_x = g_Mouse.mouse_x; + gCvars.f1monitorpos_y = g_Mouse.mouse_y; + gCvars.f1monitorpos_x = gCvars.f1monitorpos_x; + gCvars.f1monitorpos_y = gCvars.f1monitorpos_y; + } + + int centerx = gCvars.f1monitorpos_x + (sizex / 2); + int centery = gCvars.f1monitorpos_y + (sizey / 2); + + Draw::FillRGBA(centerx - sizex - 6, centery - sizey - 20, 2 * sizex + 12, 2 * sizey + 26, 35, 35, 35, 255); + Draw::OutlinedRectangle(centerx - sizex - 6, centery - sizey - 20, 2 * sizex + 12, 2 * sizey + 26, 0, 0, 0, 254); + + Draw::DrawStringA(Fonts::m_MenuFont, false, centerx - sizex, centery - sizey - 19, 255, 255, 255, 255, "Monitor"); + Draw::FillRGBA(centerx - sizex, centery - sizey, 2 * sizex, 2 * sizey, 50, 50, 50, 255); + + Draw::OutlinedRectangle(centerx - sizex, centery - sizey, 2 * sizex, 2 * sizey, 0, 0, 0, 254); + + int iSpeed = 0; + float flPunch = 0.0f; + + Vector vSpeed = entity->GetVelocity(); + iSpeed = (int)vSpeed.Length2D(); + + Vector pAngle = entity->GetPunchAngle(); + float flModifier = pAngle.Normalize(); + + flModifier -= (10.0f + flModifier * 0.5f) * pGlobalvars->interval_per_tick; + pAngle *= flModifier; + flPunch = ((pAngle.x * 17.77777777777778) * 1.25); + + Draw::DrawMonitorBar(centerx - sizex + 9, centery - sizey + 12, (-flPunch), "Recoil"); + Draw::DrawMonitorBar(centerx - sizex + 59, centery - sizey + 12, (iSpeed * 0.2), "Speed"); +} + +RECT ESP::DynamicBox(CBaseEntity* pPlayer, bool& PVS, CBaseEntity* local) +{ + Vector trans = pPlayer->GetAbsOrigin(); + + Vector min; + Vector max; + + min = pPlayer->GetMins(); + max = pPlayer->GetMaxs(); + + Vector pointList[] = { + Vector(min.x, min.y, min.z), + Vector(min.x, max.y, min.z), + Vector(max.x, max.y, min.z), + Vector(max.x, min.y, min.z), + Vector(max.x, max.y, max.z), + Vector(min.x, max.y, max.z), + Vector(min.x, min.y, max.z), + Vector(max.x, min.y, max.z) + }; + + Vector Distance = pointList[0] - pointList[1]; + int dst = Distance.Length(); + dst /= 1.3f; + Vector angs; + Math::CalcAngle(trans, local->GetEyePosition(), angs); + + Vector all[8]; + angs.y += 45; + for (int i = 0; i < 4; i++) + { + Math::angleVectors(angs,all[i]); + all[i] *= dst; + all[i + 4] = all[i]; + all[i].z = max.z; + all[i + 4].z = min.z; + VectorAdd(all[i], trans, all[i]); + VectorAdd(all[i + 4], trans, all[i + 4]); + angs.y += 90; + } + + Vector flb, brt, blb, frt, frb, brb, blt, flt; + PVS = true; + + if (!Draw::WorldToScreen(all[3], flb)) + PVS = false; + if (!Draw::WorldToScreen(all[0], blb)) + PVS = false; + if (!Draw::WorldToScreen(all[2], frb)) + PVS = false; + if (!Draw::WorldToScreen(all[6], blt)) + PVS = false; + if (!Draw::WorldToScreen(all[5], brt)) + PVS = false; + if (!Draw::WorldToScreen(all[4], frt)) + PVS = false; + if (!Draw::WorldToScreen(all[1], brb)) + PVS = false; + if (!Draw::WorldToScreen(all[7], flt)) + PVS = false; + + Vector arr[] = { flb, brt, blb, frt, frb, brb, blt, flt }; + + float left = flb.x; + float top = flb.y; + float right = flb.x; + float bottom = flb.y; + + for (int i = 0; i < 8; i++) + { + if (left > arr[i].x) + left = arr[i].x; + if (top > arr[i].y) + top = arr[i].y; + if (right < arr[i].x) + right = arr[i].x; + if (bottom < arr[i].y) + bottom = arr[i].y; + } + RECT rect; + rect.left = left; + rect.bottom = bottom; + rect.right = right; + rect.top = top; + return rect; +} + + +void ESP::drawvelocity(int screenWidth, int screenHeight, CBaseEntity* local_player) +{ + Vector speed = local_player->GetVelocity(); + + int intspeed = round(speed.Length2D()); + + char vel[256]; + + sprintf_s(vel, "%d", intspeed); + + Draw::DrawStringA(Fonts::m_VelocityFont, true, screenWidth / 2, screenHeight - 100, COLORESP, vel); +} + +void ESP::drawradar(int screenwidght, int screenhight, CBaseEntity* local) +{ + for (int ax = 1; ax <= pEntList->GetHighestEntityIndex(); ax++) + { + CBaseEntity * pEntity = pEntList->GetClientEntity(ax); + + if (!pEntity || pEntity == local || pEntity->IsDormant()) + continue; + + if (!pEntity->GetModel()) + continue; + + if (pEntity->GetTeamNum() == TEAM_SURVIVOR) + continue; + + std::int32_t nClassID = pEntity->GetClientClass()->GetClassID; + + if (!pEntity->GetGroup() && !pEntity->ValidEntity()) + continue; + + static Vector vClientViewAngles; + + pEngine->GetViewAngles(vClientViewAngles); + + DrawRadarPoint(pEntity->GetAbsOrigin(), local->GetAbsOrigin(), vClientViewAngles); + } +} + +void ESP::DrawRadarBack(int screenwidght, int screenhight) +{ + bool bSave_Radar_Pos = true; + + int size = 110; + size -= 10; + + if (g_Mouse.LeftClick(gCvars.flRadarPos_x - (size / 2) - 6, gCvars.flRadarPos_y - (size / 2) - 6, size * 2 + 12, size * 2 + 12)) + { + if (!bSave_Radar_Pos) + { + gCvars.iSavedRadarX = g_Mouse.mouse_x - gCvars.flRadarPos_x; + gCvars.iSavedRadarY = g_Mouse.mouse_y - gCvars.flRadarPos_y; + bSave_Radar_Pos = true; + } + gCvars.flRadarPos_x = g_Mouse.mouse_x; + gCvars.flRadarPos_y = g_Mouse.mouse_y; + gCvars.flRadarPos_x = gCvars.flRadarPos_x - gCvars.iSavedRadarX; + gCvars.flRadarPos_y = gCvars.flRadarPos_y - gCvars.iSavedRadarY; + } + else + { + bSave_Radar_Pos = false; + } + + int centerx = gCvars.flRadarPos_x + (size / 2); + int centery = gCvars.flRadarPos_y + (size / 2); + + Draw::FillRGBA(centerx - size - 6, centery - size - 20, 2 * size + 12, 2 * size + 26, 35, 35, 35, 255); + Draw::OutlinedRectangle(centerx - size - 6, centery - size - 20, 2 * size + 12, 2 * size + 26, 0, 0, 0, 254); + + Draw::DrawStringA(Fonts::m_MenuFont, false, centerx - size, centery - size - 19, 255, 255, 255, 255, "Radar"); + Draw::FillRGBA(centerx - size, centery - size, 2 * size, 2 * size, 50, 50, 50, 255); + + Draw::OutlinedRectangle(centerx - size, centery - size, 2 * size, 2 * size, 0, 0, 0, 254); + Draw::FillRGBA(centerx, centery - size, 1, 2 * size, 0, 0, 0, 120); + Draw::FillRGBA(centerx - size, centery, 2 * size, 1, 0, 0, 0, 120); +} + +void ESP::DrawRadarPoint(Vector vecOriginx, Vector vecOriginy, Vector vAngle) +{ + int size = 110; + + int centerx = gCvars.flRadarPos_x + (size / 2); + int centery = gCvars.flRadarPos_y + (size / 2); + + float dx = vecOriginx.x - vecOriginy.x; + float dy = vecOriginx.y - vecOriginy.y; + float flAngle = vAngle.y; + float yaw = (flAngle)* (PI / 180.0); + float mainViewAngles_CosYaw = cos(yaw); + float mainViewAngles_SinYaw = sin(yaw); + float x = dy * (-mainViewAngles_CosYaw) + dx * mainViewAngles_SinYaw; + float y = dx * (-mainViewAngles_CosYaw) - dy * mainViewAngles_SinYaw; + float range = size * 30; + if (fabs(x) > range || fabs(y) > range) + { + if (y > x) + { + if (y > -x) { + x = range * x / y; + y = range; + } + else { + y = -range * y / x; + x = -range; + } + } + else { + if (y > -x) { + y = range * y / x; + x = range; + } + else { + x = -range * x / y; + y = -range; + } + } + } + int ScreenX = centerx + int(x / range * float(size)); + int ScreenY = centery + int(y / range * float(size)); + size -= 10; + int radar_menu_x = centerx; + int radar_menu_y = centery; + + if (ScreenX < radar_menu_x - size) + ScreenX = radar_menu_x - size + 1; + else if (ScreenX > radar_menu_x + size) + ScreenX = radar_menu_x + size - 3; + + if (ScreenY < radar_menu_y - size) + ScreenY = radar_menu_y - size + 2; + else if (ScreenY > radar_menu_y + size) + ScreenY = radar_menu_y + size - 4; + + Draw::FillRGBA(ScreenX - 1, ScreenY - 1, 4, 4, 255, 255, 255, 255); +} + +void ESP::draw(CBaseEntity* pLocal) +{ + Vector screen, worldpos; + + int iMyTeam = pLocal->GetTeamNum(); + + for (int i = 1; i <= pEntList->GetHighestEntityIndex(); i++) + { + CBaseEntity * pEntity = pEntList->GetClientEntity(i); + + if (!pEntity || pEntity == pLocal || pEntity->IsDormant()) + continue; + + if (!pEntity->GetModel()) + continue; + + int iTeamNum = pEntity->GetTeamNum(); + + if (iTeamNum == iMyTeam) + continue; + + //Draw Player Box ESP + if (pEntity->GetGroup() && pEntity->ValidEntityIgnoreInfected()) + { + DrawPlayer(pEntity, pLocal); + } + } +} + +void ESP::DrawBox(const RECT& rect) +{ + pSurface->DrawSetColor(COLORESP); + pSurface->DrawOutlinedRect(rect.left, rect.top, rect.right, rect.bottom); + pSurface->DrawSetColor(0,0,0,255); + pSurface->DrawOutlinedRect(rect.left - 1, rect.top - 1, rect.right + 1, rect.bottom + 1); + pSurface->DrawOutlinedRect(rect.left + 1, rect.top + 1, rect.right - 1, rect.bottom - 1); +} + + +void ESP::DrawPlayer(CBaseEntity * pEntity, CBaseEntity * local) +{ + bool PVS = false; + RECT rect = DynamicBox(pEntity, PVS, local); + + if (gCvars.ESPBOX) + { + DrawBox(rect); + } + + if (gCvars.ESPNAME || gCvars.ESPHEALTH) + { + int middle = ((rect.right - rect.left) / 2) + rect.left; + + char * szname{ pEntity->GetClientClass()->GetName }; + + int inthealth = pEntity->GetHealth(); + + char helfl[256]; + + sprintf_s(helfl, "(%d)", inthealth); + + if (local->GetTeamNum() == TEAM_SURVIVOR) + { + + if (pEntity->GetGroup() == GROUP_INFECTED) + { + if (gCvars.ESPNAME) + { + if (gCvars.INGOREINFECTED) + return; + + Draw::DrawStringA(Fonts::m_MenuFont, true, middle, rect.top - 15, 255, 255, 255, 255, "zombie"); + } + } + + if (pEntity->GetGroup() == GROUP_SPECIAL) + { + if (gCvars.ESPNAME) + { + Draw::DrawStringA(Fonts::m_MenuFont, true, middle, rect.top - 15, 255, 255, 255, 255, szname); + } + + if (gCvars.ESPHEALTH) + { + Draw::DrawStringA(Fonts::m_MenuFont, true, middle, rect.bottom + 1, 255, 255, 255, 255, helfl); + } + } + + if (pEntity->GetGroup() == GROUP_TANK) + { + if (gCvars.ESPNAME) + { + Draw::DrawStringA(Fonts::m_MenuFont, true, middle, rect.top - 15, 255, 255, 255, 255, "Tank"); + } + + if (gCvars.ESPHEALTH) + { + Draw::DrawStringA(Fonts::m_MenuFont, true, middle, rect.bottom + 1, 255, 255, 255, 255, helfl); + } + } + + if (pEntity->GetGroup() == GROUP_BITCH) + { + if (gCvars.ESPNAME) + { + Draw::DrawStringA(Fonts::m_MenuFont, true, middle, rect.top - 15, 255, 255, 255, 255, "Witch"); + } + } + } + + if (local->GetTeamNum() == TEAM_ZOMBY) + { + if (pEntity->GetGroup() == GROUP_PLAYER) + { + if (pEntity->GetTeamNum() == TEAM_SURVIVOR && pEntity->GetLifeState() == LIFE_ALIVE) + { + if (gCvars.ESPNAME) + { + Draw::DrawStringA(Fonts::m_MenuFont, true, middle, rect.top - 15, 255, 255, 255, 255, "Survivor"); + } + + if (gCvars.ESPHEALTH) + { + Draw::DrawStringA(Fonts::m_MenuFont, true, middle, rect.bottom + 1, 255, 255, 255, 255, helfl); + } + } + } + } + } +} \ No newline at end of file diff --git a/visuals.h b/visuals.h new file mode 100644 index 0000000..5b4b98e --- /dev/null +++ b/visuals.h @@ -0,0 +1,15 @@ + + +namespace ESP +{ + void DrawMonitor(int x, int y, CBaseEntity * entity); + RECT DynamicBox(CBaseEntity* pPlayer, bool& PVS, CBaseEntity* local); + void draw(CBaseEntity* local); + void DrawPlayer(CBaseEntity * pEntity,CBaseEntity * local); + void DrawBox(const RECT& rect); + void drawradar(int screenwidght, int screenheight, CBaseEntity* local); + void DrawRadarBack(int screenwidght, int screenheight); + void DrawRadarPoint(Vector vecOriginx, Vector vecOriginy, Vector vAngle); + void drawvelocity(int screenWidth, int screenHeight, CBaseEntity* local_player); +} + diff --git a/vmatrix.h b/vmatrix.h new file mode 100644 index 0000000..0d86150 --- /dev/null +++ b/vmatrix.h @@ -0,0 +1,44 @@ +#pragma once + +struct matrix3x4_t +{ + matrix3x4_t() {} + matrix3x4_t( + float m00, float m01, float m02, float m03, + float m10, float m11, float m12, float m13, + float m20, float m21, float m22, float m23) + { + m_flMatVal[0][0] = m00; m_flMatVal[0][1] = m01; m_flMatVal[0][2] = m02; m_flMatVal[0][3] = m03; + m_flMatVal[1][0] = m10; m_flMatVal[1][1] = m11; m_flMatVal[1][2] = m12; m_flMatVal[1][3] = m13; + m_flMatVal[2][0] = m20; m_flMatVal[2][1] = m21; m_flMatVal[2][2] = m22; m_flMatVal[2][3] = m23; + } + void Init(const Vector& xAxis, const Vector& yAxis, const Vector& zAxis, const Vector &vecOrigin) + { + m_flMatVal[0][0] = xAxis.x; m_flMatVal[0][1] = yAxis.x; m_flMatVal[0][2] = zAxis.x; m_flMatVal[0][3] = vecOrigin.x; + m_flMatVal[1][0] = xAxis.y; m_flMatVal[1][1] = yAxis.y; m_flMatVal[1][2] = zAxis.y; m_flMatVal[1][3] = vecOrigin.y; + m_flMatVal[2][0] = xAxis.z; m_flMatVal[2][1] = yAxis.z; m_flMatVal[2][2] = zAxis.z; m_flMatVal[2][3] = vecOrigin.z; + } + + matrix3x4_t(const Vector& xAxis, const Vector& yAxis, const Vector& zAxis, const Vector &vecOrigin) + { + Init(xAxis, yAxis, zAxis, vecOrigin); + } + float *operator[](int i) + { + return m_flMatVal[i]; + } + const float *operator[](int i) const + { + return m_flMatVal[i]; + } + float *Base() + { + return &m_flMatVal[0][0]; + } + const float *Base() const + { + return &m_flMatVal[0][0]; + } + + float m_flMatVal[3][4]; +};