From b5cc76fe85b0c969f1d73367ac7a1c8954d9b4df Mon Sep 17 00:00:00 2001 From: rei-2 <174158077+rei-2@users.noreply.github.com> Date: Mon, 24 Mar 2025 23:20:41 -0400 Subject: [PATCH] fixes --- .../Aimbot/AimbotHitscan/AimbotHitscan.cpp | 42 +++++++++----- .../AimbotProjectile/AimbotProjectile.cpp | 2 +- Amalgam/src/Features/ImGui/Menu/Components.h | 47 ++++++++-------- Amalgam/src/Features/ImGui/Menu/Menu.cpp | 56 ++++++++++--------- Amalgam/src/Features/Misc/Misc.cpp | 48 ++++++++-------- Amalgam/src/Features/Misc/Misc.h | 7 ++- .../MovementSimulation/MovementSimulation.cpp | 14 ++--- Amalgam/src/Features/Visuals/Radar/Radar.cpp | 4 +- Amalgam/src/Features/Visuals/Visuals.cpp | 22 +++++--- Amalgam/src/Hooks/CNetChannel_SendNetMsg.cpp | 16 +++--- Amalgam/src/SDK/Definitions/Types.h | 4 +- Amalgam/src/SDK/Helpers/Particles/Particles.h | 12 ++-- Amalgam/src/SDK/SDK.cpp | 47 +++++++--------- Amalgam/src/SDK/SDK.h | 6 +- Amalgam/src/SDK/Vars.h | 3 +- 15 files changed, 173 insertions(+), 157 deletions(-) diff --git a/Amalgam/src/Features/Aimbot/AimbotHitscan/AimbotHitscan.cpp b/Amalgam/src/Features/Aimbot/AimbotHitscan/AimbotHitscan.cpp index d7aed649..11e49032 100644 --- a/Amalgam/src/Features/Aimbot/AimbotHitscan/AimbotHitscan.cpp +++ b/Amalgam/src/Features/Aimbot/AimbotHitscan/AimbotHitscan.cpp @@ -335,12 +335,14 @@ int CAimbotHitscan::CanHit(Target_t& tTarget, CTFPlayer* pLocal, CTFWeaponBase* auto RayToOBB = [&](const Vec3& vOrigin, const Vec3& vDirection, const Vec3& vMins, const Vec3& vMaxs, const matrix3x4& mMatrix, float flScale = 1.f) -> bool { + /* switch (Vars::Aimbot::General::AimType.Value) { case Vars::Aimbot::General::AimTypeEnum::Smooth: case Vars::Aimbot::General::AimTypeEnum::Assistive: return Math::RayToOBB(vOrigin, vDirection, vMins, vMaxs, mMatrix, flScale); } + */ return true; }; @@ -379,6 +381,11 @@ int CAimbotHitscan::CanHit(Target_t& tTarget, CTFPlayer* pLocal, CTFWeaponBase* float flBoneScale = std::max(Vars::Aimbot::Hitscan::BoneSizeMinimumScale.Value, Vars::Aimbot::Hitscan::PointScale.Value / 100.f); float flBoneSubtract = Vars::Aimbot::Hitscan::BoneSizeSubtract.Value; + auto pGameRules = I::TFGameRules(); + auto pViewVectors = pGameRules ? pGameRules->GetViewVectors() : nullptr; + Vec3 vHullMins = (pViewVectors ? pViewVectors->m_vHullMin : Vec3(-24, -24, 0)) * flModelScale; + Vec3 vHullMaxs = (pViewVectors ? pViewVectors->m_vHullMax : Vec3(24, 24, 82)) * flModelScale; + Vec3 vAngle; Math::MatrixAngles(aBones[pBox->bone], vAngle); Vec3 vMins = pBox->bbmin; Vec3 vMaxs = pBox->bbmax; @@ -418,6 +425,8 @@ int CAimbotHitscan::CanHit(Target_t& tTarget, CTFPlayer* pLocal, CTFWeaponBase* } } + auto pCollideable = tTarget.m_pEntity->GetCollideable(); + const matrix3x4& transform = pCollideable ? pCollideable->CollisionToWorldTransform() : tTarget.m_pEntity->RenderableToWorldTransform(); for (auto& vPoint : vPoints) { Vec3 vOrigin = {}; Math::VectorTransform(vPoint, aBones[pBox->bone], vOrigin); vOrigin += vOffset; @@ -437,22 +446,26 @@ int CAimbotHitscan::CanHit(Target_t& tTarget, CTFPlayer* pLocal, CTFWeaponBase* auto vAngles = Aim(G::CurrentUserCmd->viewangles, Math::CalcAngle(pLocal->GetShootPos(), vOrigin)); Vec3 vForward; Math::AngleVectors(vAngles, &vForward); - // for the time being, no vischecks against other hitboxes - Vec3 vCheckMins = (vMins + flBoneSubtract / flModelScale) * flBoneScale, vCheckMaxs = (vMaxs - flBoneSubtract / flModelScale) * flBoneScale; - if (RayToOBB(vEyePos, vForward, vCheckMins, vCheckMaxs, aBones[pBox->bone], flModelScale)) + // not perfect but it will do for now + if (Math::RayToOBB(vEyePos, vForward, vHullMins, vHullMaxs, transform)) { - flPreferredRecord = tRecord.m_flSimTime; + // for the time being, no vischecks against other hitboxes + Vec3 vCheckMins = (vMins + flBoneSubtract / flModelScale) * flBoneScale, vCheckMaxs = (vMaxs - flBoneSubtract / flModelScale) * flBoneScale; + if (RayToOBB(vEyePos, vForward, vCheckMins, vCheckMaxs, aBones[pBox->bone], flModelScale)) + { + flPreferredRecord = tRecord.m_flSimTime; - tTarget.m_vAngleTo = vAngles; - tTarget.m_tRecord = tRecord; - tTarget.m_vPos = vOrigin; - tTarget.m_nAimedHitbox = iHitbox; - tTarget.m_bBacktrack = true; - return true; + tTarget.m_vAngleTo = vAngles; + tTarget.m_tRecord = tRecord; + tTarget.m_vPos = vOrigin; + tTarget.m_nAimedHitbox = iHitbox; + tTarget.m_bBacktrack = true; + return true; + } + else if (iReturn == 2 ? vAngles.DeltaAngle(G::CurrentUserCmd->viewangles).Length2D() < tTarget.m_vAngleTo.DeltaAngle(G::CurrentUserCmd->viewangles).Length2D() : true) + tTarget.m_vAngleTo = vAngles; + iReturn = 2; } - else if (iReturn == 2 ? vAngles.DeltaAngle(G::CurrentUserCmd->viewangles).Length2D() < tTarget.m_vAngleTo.DeltaAngle(G::CurrentUserCmd->viewangles).Length2D() : true) - tTarget.m_vAngleTo = vAngles; - iReturn = 2; } } } @@ -492,7 +505,8 @@ int CAimbotHitscan::CanHit(Target_t& tTarget, CTFPlayer* pLocal, CTFWeaponBase* } } - const matrix3x4& transform = tTarget.m_pEntity->RenderableToWorldTransform(); + auto pCollideable = tTarget.m_pEntity->GetCollideable(); + const matrix3x4& transform = pCollideable ? pCollideable->CollisionToWorldTransform() : tTarget.m_pEntity->RenderableToWorldTransform(); for (auto& vPoint : vPoints) { Vec3 vOrigin = tTarget.m_pEntity->GetCenter() + vPoint; diff --git a/Amalgam/src/Features/Aimbot/AimbotProjectile/AimbotProjectile.cpp b/Amalgam/src/Features/Aimbot/AimbotProjectile/AimbotProjectile.cpp index 2309eb02..db92dad7 100644 --- a/Amalgam/src/Features/Aimbot/AimbotProjectile/AimbotProjectile.cpp +++ b/Amalgam/src/Features/Aimbot/AimbotProjectile/AimbotProjectile.cpp @@ -1697,7 +1697,7 @@ void CAimbotProjectile::Run(CTFPlayer* pLocal, CTFWeaponBase* pWeapon, CUserCmd* flAmount = flMortar ? Math::RemapValClamped(flCharge, -flMortar, 0.f, 0.f, 1.f) : 0.f; } - if (pWeapon->GetWeaponID() == TF_WEAPON_PIPEBOMBLAUNCHER && Vars::Aimbot::Projectile::AutoRelease.Value && flAmount > Vars::Aimbot::Projectile::AutoRelease.Value / 100) + if (pWeapon->GetWeaponID() == TF_WEAPON_PIPEBOMBLAUNCHER && G::Buttons & IN_ATTACK && Vars::Aimbot::Projectile::AutoRelease.Value && flAmount > Vars::Aimbot::Projectile::AutoRelease.Value / 100) pCmd->buttons &= ~IN_ATTACK; else if (G::CanPrimaryAttack && Vars::Aimbot::Projectile::Modifiers.Value & Vars::Aimbot::Projectile::ModifiersEnum::CancelCharge) { diff --git a/Amalgam/src/Features/ImGui/Menu/Components.h b/Amalgam/src/Features/ImGui/Menu/Components.h index a6fe73b0..e6b60ec7 100644 --- a/Amalgam/src/Features/ImGui/Menu/Components.h +++ b/Amalgam/src/Features/ImGui/Menu/Components.h @@ -1310,11 +1310,9 @@ namespace ImGui } std::string sPreview = ""; - if (iFlags & FDropdown_Multi && !*pVar) - sPreview = "None"; - else + if (!(iFlags & FDropdown_Multi) || *pVar) { - int i = 0; for (auto& iValue : vValues) + size_t i = 0; for (auto& iValue : vValues) { while (FNV1A::Hash32(vEntries[i]) == FNV1A::Hash32Const("##Divider")) i++; @@ -1325,8 +1323,13 @@ namespace ImGui sPreview = std::format("{}##", StripDoubleHash(vEntries[i]).c_str()); i++; } - sPreview.pop_back(); sPreview.pop_back(); + if (sPreview.length() > 1) + { + sPreview.pop_back(); sPreview.pop_back(); + } } + if (sPreview.empty()) + sPreview = "None"; PushStyleVar(ImGuiStyleVar_FramePadding, { 0.f, H::Draw.Scale(13.5f) }); float flSizeX = GetWindowWidth(); @@ -2014,8 +2017,6 @@ namespace ImGui } inline void FKeybind(const char* sLabel, int& iOutput, int iFlags = FKeybind_None, ImVec2 vSize = { 0, 30 }, int iSizeOffset = 0, bool* pHovered = nullptr) { - static bool bCanceled = false; - ImGuiID uId = GetID(sLabel); PushID(sLabel); @@ -2023,13 +2024,14 @@ namespace ImGui { F::Menu.m_bInKeybind = true; - //FButton("...", flags | FButton_NoUpper, sizeOffset); - FButton(std::format("{}: ...", sLabel).c_str(), iFlags | FButton_NoUpper, vSize, iSizeOffset); - bool bHovered = IsItemHovered(); + bool bHovered = false; + FButton(std::format("{}: ...", sLabel).c_str(), iFlags | FButton_NoUpper, vSize, iSizeOffset, &bHovered); + if (pHovered) + *pHovered = bHovered; - if (bHovered && IsMouseClicked(ImGuiMouseButton_Left)) + if (bHovered && IsMouseReleased(ImGuiMouseButton_Left)) { - bCanceled = true; + SDK::Output("ClearActiveID"); ClearActiveID(); } else @@ -2046,13 +2048,10 @@ namespace ImGui } } - if (iKeyPressed) + if (iKeyPressed && (iKeyPressed != VK_LBUTTON || !bHovered)) { switch (iKeyPressed) { - case VK_LBUTTON: - iOutput = bHovered ? iOutput : iKeyPressed; - break; case VK_ESCAPE: if (iFlags & FKeybind_AllowNone) { @@ -2064,18 +2063,18 @@ namespace ImGui if (iFlags & FKeybind_AllowMenu || iKeyPressed != Vars::Menu::MenuPrimaryKey.Value && iKeyPressed != Vars::Menu::MenuSecondaryKey.Value) iOutput = iKeyPressed; } + SDK::Output("ClearActiveID"); ClearActiveID(); } + + GetCurrentContext()->ActiveIdAllowOverlap = true; } - - GetCurrentContext()->ActiveIdAllowOverlap = true; } - //else if (FButton(VK2STR(output).c_str(), flags | FButton_NoUpper) && !bCanceled) - else if (FButton(std::format("{}: {}", sLabel, VK2STR(iOutput)).c_str(), iFlags | FButton_NoUpper, vSize, iSizeOffset) && !bCanceled) + else if (FButton(std::format("{}: {}", sLabel, VK2STR(iOutput)).c_str(), iFlags | FButton_NoUpper, vSize, iSizeOffset, pHovered)) + { + SDK::Output("SetActiveID"); SetActiveID(uId, GetCurrentWindow()); - - if (bCanceled && !IsMouseDown(ImGuiMouseButton_Left) && !IsMouseReleased(ImGuiMouseButton_Left)) - bCanceled = false; + } PopID(); } @@ -2442,7 +2441,7 @@ namespace ImGui } bLastHovered = bLastHovered || bHovered; - if (tBind.m_iType == 0) + if (tBind.m_iType == BindEnum::Key) { FKeybind("Key", tBind.m_iKey, FKeybind_None, { 0, 30 }, 0, &bHovered); bLastHovered = bLastHovered || bHovered; diff --git a/Amalgam/src/Features/ImGui/Menu/Menu.cpp b/Amalgam/src/Features/ImGui/Menu/Menu.cpp index c08c766c..fa027887 100644 --- a/Amalgam/src/Features/ImGui/Menu/Menu.cpp +++ b/Amalgam/src/Features/ImGui/Menu/Menu.cpp @@ -16,19 +16,13 @@ void CMenu::DrawMenu() { using namespace ImGui; - ImVec2 vMainWindowPos = {}; - ImVec2 vMainWindowSize = {}; - SetNextWindowSize({ 750, 500 }, ImGuiCond_FirstUseEver); PushStyleVar(ImGuiStyleVar_WindowMinSize, { H::Draw.Scale(750), H::Draw.Scale(500) }); PushStyleVar(ImGuiStyleVar_ChildRounding, H::Draw.Scale(3)); if (Begin("Main", nullptr, ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoBackground)) { - auto vWindowPos = vMainWindowPos = GetWindowPos(); - auto vWindowSize = vMainWindowSize = GetWindowSize(); - - vWindowPos = GetWindowPos(); - vWindowSize = GetWindowSize(); + ImVec2 vWindowPos = GetWindowPos(); + ImVec2 vWindowSize = GetWindowSize(); PushClipRect({ 0, 0 }, { ImGui::GetIO().DisplaySize.x, ImGui::GetIO().DisplaySize.y }, false); RenderTwoToneBackground(H::Draw.Scale(140), F::Render.Background0, F::Render.Background1, F::Render.Background2, 0.f, false); @@ -39,7 +33,10 @@ void CMenu::DrawMenu() float flOffset = 0.f; Bind_t tBind; - if (F::Binds.GetBind(CurrentBind, &tBind)) // bind + if (!F::Binds.GetBind(CurrentBind, &tBind)) + CurrentBind = DEFAULT_BIND; + + if (CurrentBind != DEFAULT_BIND) // bind { flOffset = H::Draw.Scale(60); pDrawList->AddRectFilled({ vDrawPos.x, vDrawPos.y + H::Draw.Scale(59) }, { vDrawPos.x + H::Draw.Scale(139), vDrawPos.y + H::Draw.Scale(60) }, F::Render.Background2); @@ -856,7 +853,8 @@ void CMenu::MenuVisuals(int iTab) { if (Section("Debug", true)) { - FToggle("Thirdperson scales", Vars::Visuals::ThirdPerson::Scale); + FToggle("Thirdperson scales", Vars::Visuals::ThirdPerson::Scale, FToggle_Left); + FToggle("Thirdperson collides", Vars::Visuals::ThirdPerson::Collide, FToggle_Right); } EndSection(); } if (Section("Out of FOV arrows", true)) @@ -969,10 +967,18 @@ void CMenu::MenuVisuals(int iTab) FSDropdown("Chat info prefix", Vars::Menu::CheatPrefix, {}, FDropdown_Right); FKeybind("Primary key", Vars::Menu::MenuPrimaryKey.Map[DEFAULT_BIND], FButton_Left | FKeybind_AllowMenu); FKeybind("Secondary key", Vars::Menu::MenuSecondaryKey.Map[DEFAULT_BIND], FButton_Right | FButton_SameLine | FKeybind_AllowMenu); - if (Vars::Menu::MenuPrimaryKey.Map[DEFAULT_BIND] == VK_LBUTTON) - Vars::Menu::MenuPrimaryKey.Map[DEFAULT_BIND] = VK_INSERT; - if (Vars::Menu::MenuSecondaryKey.Map[DEFAULT_BIND] == VK_LBUTTON) - Vars::Menu::MenuSecondaryKey.Map[DEFAULT_BIND] = VK_F3; + switch (Vars::Menu::MenuPrimaryKey.Map[DEFAULT_BIND]) + { + case VK_LBUTTON: + case VK_RBUTTON: + Vars::Menu::MenuPrimaryKey.Map[DEFAULT_BIND] = Vars::Menu::MenuPrimaryKey.Default; + } + switch (Vars::Menu::MenuSecondaryKey.Map[DEFAULT_BIND]) + { + case VK_LBUTTON: + case VK_RBUTTON: + Vars::Menu::MenuSecondaryKey.Map[DEFAULT_BIND] = Vars::Menu::MenuSecondaryKey.Default; + } } EndSection(); /* Column 2 */ @@ -1788,14 +1794,14 @@ void CMenu::MenuSettings(int iTab) std::lock_guard lock(F::PlayerUtils.m_mutex); const auto& playerCache = F::PlayerUtils.m_vPlayerCache; - auto getTeamColor = [](int team, bool alive) + auto getTeamColor = [&](int team, bool alive) { switch (team) { - case 3: return Color_t(50, 75, 100, alive ? 255 : 127); - case 2: return Color_t(125, 50, 50, alive ? 255 : 127); + case 3: return Color_t(100, 150, 200, alive ? 255 : 127).Lerp(Vars::Menu::Theme::Background.Value, 0.5f, false); + case 2: return Color_t(200, 100, 100, alive ? 255 : 127).Lerp(Vars::Menu::Theme::Background.Value, 0.5f, false); } - return Color_t(100, 100, 100, 255); + return Color_t(127, 127, 127, 255).Lerp(Vars::Menu::Theme::Background.Value, 0.5f, false); }; auto drawPlayer = [getTeamColor](const ListPlayer& player, int x, int y) { @@ -2237,14 +2243,12 @@ void CMenu::MenuSettings(int iTab) bool bClicked = false, bDelete = false; - ImColor imColor = ColorToVec(_tTag.Color); - imColor.Value.x /= 3; imColor.Value.y /= 3; imColor.Value.z /= 3; - ImVec2 vOriginalPos = { !_tTag.Label ? GetStyle().WindowPadding.x : GetWindowWidth() * 2 / 3 + GetStyle().WindowPadding.x / 2, H::Draw.Scale(96 + 36 * y) }; // background float flWidth = GetWindowWidth() * (_tTag.Label ? 1.f / 3 : 2.f / 3) - GetStyle().WindowPadding.x * 1.5f; float flHeight = H::Draw.Scale(28); + ImColor imColor = ColorToVec(_tTag.Color.Lerp(Vars::Menu::Theme::Background.Value, 0.5f, false)); ImVec2 vDrawPos = GetDrawPos() + vOriginalPos; GetWindowDrawList()->AddRectFilled(vDrawPos, { vDrawPos.x + flWidth, vDrawPos.y + flHeight }, imColor, H::Draw.Scale(3)); @@ -2581,11 +2585,6 @@ void CMenu::DrawBinds() if (m_bIsOpen ? false : I::EngineVGui->IsGameUIVisible() || I::MatSystemSurface->IsCursorVisible() && !I::EngineClient->IsPlayingDemo()) return; - static DragBox_t old = { -2147483648, -2147483648 }; - DragBox_t info = m_bIsOpen ? FGet(Vars::Menu::BindsDisplay, true) : Vars::Menu::BindsDisplay.Value; - if (info != old) - SetNextWindowPos({ float(info.x), float(info.y) }, ImGuiCond_Always); - std::vector> vInfo; std::function getBinds = [&](int iParent) { @@ -2653,6 +2652,11 @@ void CMenu::DrawBinds() if (vInfo.empty()) return; + static DragBox_t old = { -2147483648, -2147483648 }; + DragBox_t info = m_bIsOpen ? FGet(Vars::Menu::BindsDisplay, true) : Vars::Menu::BindsDisplay.Value; + if (info != old) + SetNextWindowPos({ float(info.x), float(info.y) }, ImGuiCond_Always); + float flNameWidth = 0, flInfoWidth = 0, flStateWidth = 0; PushFont(F::Render.FontSmall); for (auto& [_, sName, sInfo, sState, iBind, tBind] : vInfo) diff --git a/Amalgam/src/Features/Misc/Misc.cpp b/Amalgam/src/Features/Misc/Misc.cpp index 7066f2c7..67a02e0f 100644 --- a/Amalgam/src/Features/Misc/Misc.cpp +++ b/Amalgam/src/Features/Misc/Misc.cpp @@ -145,49 +145,42 @@ void CMisc::AutoStrafe(CTFPlayer* pLocal, CUserCmd* pCmd) void CMisc::AutoPeek(CTFPlayer* pLocal, CUserCmd* pCmd) { - static bool bPosPlaced = false; static bool bReturning = false; - if (Vars::CL_Move::AutoPeek.Value) { - const Vec3 localPos = pLocal->GetAbsOrigin(); + const Vec3 vLocalPos = pLocal->m_vecOrigin(); - // We just started peeking. Save the return position! - if (!bPosPlaced) + if (G::Attacking && m_bPeekPlaced) + bReturning = true; + if (!bReturning && !pLocal->m_hGroundEntity()) + m_bPeekPlaced = false; + + if (!m_bPeekPlaced) { - if (pLocal->m_hGroundEntity()) - { - vPeekReturnPos = localPos; - bPosPlaced = true; - } + m_vPeekReturnPos = vLocalPos; + m_bPeekPlaced = true; } else { static Timer tTimer = {}; if (tTimer.Run(0.7f)) - H::Particles.DispatchParticleEffect("ping_circle", vPeekReturnPos, {}); + H::Particles.DispatchParticleEffect("ping_circle", m_vPeekReturnPos, {}); } - // We've just attacked. Let's return! - if (G::LastUserCmd->buttons & IN_ATTACK || G::Attacking) - bReturning = true; - if (bReturning) { - if (localPos.DistTo(vPeekReturnPos) < 7.f) + if (vLocalPos.DistTo(m_vPeekReturnPos) < 8.f) { bReturning = false; return; } - SDK::WalkTo(pCmd, pLocal, vPeekReturnPos); + SDK::WalkTo(pCmd, pLocal, m_vPeekReturnPos); + pCmd->buttons &= ~IN_JUMP; } } else - { - bPosPlaced = bReturning = false; - vPeekReturnPos = Vec3(); - } + m_bPeekPlaced = bReturning = false; } void CMisc::MovementLock(CTFPlayer* pLocal, CUserCmd* pCmd) @@ -304,15 +297,15 @@ void CMisc::PingReducer() const int iMaxUpdateRate = sv_maxupdaterate ? sv_maxupdaterate->GetInt() : 66; const int iTarget = Vars::Misc::Exploits::PingReducer.Value ? Vars::Misc::Exploits::PingTarget.Value : iCmdRate; - if (iWishCmdrate != iTarget) + if (m_iWishCmdrate != iTarget) { - NET_SetConVar cmd("cl_cmdrate", std::to_string(iWishCmdrate = iTarget).c_str()); + NET_SetConVar cmd("cl_cmdrate", std::to_string(m_iWishCmdrate = iTarget).c_str()); pNetChan->SendNetMsg(cmd); } - if (iWishUpdaterate != iMaxUpdateRate) + if (m_iWishUpdaterate != iMaxUpdateRate) { - NET_SetConVar cmd("cl_updaterate", std::to_string(iWishUpdaterate = iMaxUpdateRate).c_str()); + NET_SetConVar cmd("cl_updaterate", std::to_string(m_iWishUpdaterate = iMaxUpdateRate).c_str()); pNetChan->SendNetMsg(cmd); } } @@ -463,13 +456,16 @@ void CMisc::Event(IGameEvent* pEvent, uint32_t uHash) case FNV1A::Hash32Const("client_disconnect"): case FNV1A::Hash32Const("client_beginconnect"): case FNV1A::Hash32Const("game_newmap"): - iWishCmdrate = iWishUpdaterate = -1; + m_iWishCmdrate = m_iWishUpdaterate = -1; F::Backtrack.m_flWishInterp = -1.f; [[fallthrough]]; case FNV1A::Hash32Const("teamplay_round_start"): G::LineStorage.clear(); G::BoxStorage.clear(); G::PathStorage.clear(); + break; + case FNV1A::Hash32Const("player_spawn"): + m_bPeekPlaced = false; } } diff --git a/Amalgam/src/Features/Misc/Misc.h b/Amalgam/src/Features/Misc/Misc.h index 534da41a..fd281020 100644 --- a/Amalgam/src/Features/Misc/Misc.h +++ b/Amalgam/src/Features/Misc/Misc.h @@ -21,7 +21,8 @@ class CMisc void EdgeJump(CTFPlayer* pLocal, CUserCmd* pCmd, bool bPost = false); - Vec3 vPeekReturnPos = {}; + bool m_bPeekPlaced = false; + Vec3 m_vPeekReturnPos = {}; //bool bSteamCleared = false; public: @@ -35,8 +36,8 @@ public: void LockAchievements(); bool SteamRPC(); - int iWishCmdrate = -1; - int iWishUpdaterate = -1; + int m_iWishCmdrate = -1; + int m_iWishUpdaterate = -1; }; ADD_FEATURE(CMisc, Misc) diff --git a/Amalgam/src/Features/Simulation/MovementSimulation/MovementSimulation.cpp b/Amalgam/src/Features/Simulation/MovementSimulation/MovementSimulation.cpp index 43864a09..b5e1365a 100644 --- a/Amalgam/src/Features/Simulation/MovementSimulation/MovementSimulation.cpp +++ b/Amalgam/src/Features/Simulation/MovementSimulation/MovementSimulation.cpp @@ -685,20 +685,20 @@ bool CMovementSimulation::SetDuck(PlayerStorage& playerStorage, bool bDuck) // t if (!playerStorage.m_pPlayer->IsOnGround()) { - Vec3 vHullMin = (pViewVectors ? pViewVectors->m_vHullMin : Vec3(-24, -24, 0)) * flScale; - Vec3 vHullMax = (pViewVectors ? pViewVectors->m_vHullMax : Vec3(24, 24, 82)) * flScale; - Vec3 vDuckHullMin = (pViewVectors ? pViewVectors->m_vDuckHullMin : Vec3(-24, -24, 0)) * flScale; - Vec3 vDuckHullMax = (pViewVectors ? pViewVectors->m_vDuckHullMax : Vec3(24, 24, 62)) * flScale; + Vec3 vHullMins = (pViewVectors ? pViewVectors->m_vHullMin : Vec3(-24, -24, 0)) * flScale; + Vec3 vHullMaxs = (pViewVectors ? pViewVectors->m_vHullMax : Vec3(24, 24, 82)) * flScale; + Vec3 vDuckHullMins = (pViewVectors ? pViewVectors->m_vDuckHullMin : Vec3(-24, -24, 0)) * flScale; + Vec3 vDuckHullMaxs = (pViewVectors ? pViewVectors->m_vDuckHullMax : Vec3(24, 24, 62)) * flScale; if (bDuck) - playerStorage.m_MoveData.m_vecAbsOrigin += (vHullMax - vHullMin) - (vDuckHullMax - vDuckHullMin); + playerStorage.m_MoveData.m_vecAbsOrigin += (vHullMaxs - vHullMins) - (vDuckHullMaxs - vDuckHullMins); else { - Vec3 vOrigin = playerStorage.m_MoveData.m_vecAbsOrigin - ((vHullMax - vHullMin) - (vDuckHullMax - vDuckHullMin)); + Vec3 vOrigin = playerStorage.m_MoveData.m_vecAbsOrigin - ((vHullMaxs - vHullMins) - (vDuckHullMaxs - vDuckHullMins)); CGameTrace trace = {}; CTraceFilterWorldAndPropsOnly filter = {}; - SDK::TraceHull(vOrigin, vOrigin, vHullMin, vHullMax, playerStorage.m_pPlayer->SolidMask(), &filter, &trace); + SDK::TraceHull(vOrigin, vOrigin, vHullMins, vHullMaxs, playerStorage.m_pPlayer->SolidMask(), &filter, &trace); if (trace.DidHit()) return false; diff --git a/Amalgam/src/Features/Visuals/Radar/Radar.cpp b/Amalgam/src/Features/Visuals/Radar/Radar.cpp index fa4a1c8b..8925a3bb 100644 --- a/Amalgam/src/Features/Visuals/Radar/Radar.cpp +++ b/Amalgam/src/Features/Visuals/Radar/Radar.cpp @@ -65,8 +65,8 @@ void CRadar::DrawBackground() break; } case Vars::Radar::Main::StyleEnum::Rectangle: - H::Draw.FillRect(info.x, info.y, info.w, info.w, tColorBackground); - H::Draw.LineRect(info.x, info.y, info.w, info.w, tColorAccent); + H::Draw.FillRoundRect(info.x, info.y, info.w, info.w, H::Draw.Scale(3), tColorBackground); + H::Draw.LineRoundRect(info.x, info.y, info.w, info.w, H::Draw.Scale(3), tColorAccent); } H::Draw.Line(info.x + info.w / 2, info.y, info.x + info.w / 2, info.y + info.w - 1, tColorAccent); diff --git a/Amalgam/src/Features/Visuals/Visuals.cpp b/Amalgam/src/Features/Visuals/Visuals.cpp index 33b7fef9..1b1b6128 100644 --- a/Amalgam/src/Features/Visuals/Visuals.cpp +++ b/Amalgam/src/Features/Visuals/Visuals.cpp @@ -814,15 +814,23 @@ void CVisuals::ThirdPerson(CTFPlayer* pLocal, CViewSetup* pView) vOffset += vRight * Vars::Visuals::ThirdPerson::Right.Value * flScale; vOffset += vUp * Vars::Visuals::ThirdPerson::Up.Value * flScale; vOffset -= vForward * Vars::Visuals::ThirdPerson::Distance.Value * flScale; - float flHull = 9.f * flScale; - Vec3 vMins = { -flHull, -flHull, -flHull }, vMaxs = { flHull, flHull, flHull }; - Vec3 vDiff = pView->origin - pLocal->GetEyePosition(); - CGameTrace trace = {}; - CTraceFilterWorldAndPropsOnly filter = {}; - SDK::TraceHull(pView->origin - vDiff, pView->origin + vOffset - vDiff, vMins, vMaxs, MASK_SOLID, &filter, &trace); + Vec3 vOrigin = pLocal->GetEyePosition(); //pView->origin + Vec3 vStart = vOrigin; + Vec3 vEnd = vOrigin + vOffset; - pView->origin += vOffset * trace.fraction - vDiff; + if (Vars::Visuals::ThirdPerson::Collide.Value) + { + float flHull = 9.f * flScale; + Vec3 vMins = { -flHull, -flHull, -flHull }, vMaxs = { flHull, flHull, flHull }; + + CGameTrace trace = {}; + CTraceFilterWorldAndPropsOnly filter = {}; + SDK::TraceHull(vStart, vEnd, vMins, vMaxs, MASK_SOLID, &filter, &trace); + vEnd = trace.endpos; + } + + pView->origin = vEnd; } } diff --git a/Amalgam/src/Hooks/CNetChannel_SendNetMsg.cpp b/Amalgam/src/Hooks/CNetChannel_SendNetMsg.cpp index 44134bf8..8380a9a6 100644 --- a/Amalgam/src/Hooks/CNetChannel_SendNetMsg.cpp +++ b/Amalgam/src/Hooks/CNetChannel_SendNetMsg.cpp @@ -36,8 +36,8 @@ MAKE_HOOK(CNetChannel_SendNetMsg, S::CNetChannel_SendNetMsg(), bool, } catch (...) {}; } break; case FNV1A::Hash32Const("cl_cmdrate"): - if (F::Misc.iWishCmdrate != -1) - strncpy_s(localCvar->Value, std::to_string(F::Misc.iWishCmdrate).c_str(), MAX_OSPATH); + if (F::Misc.m_iWishCmdrate != -1) + strncpy_s(localCvar->Value, std::to_string(F::Misc.m_iWishCmdrate).c_str(), MAX_OSPATH); if (Vars::Misc::Game::AntiCheatCompatibility.Value) { try { int iValue = std::stof(localCvar->Value); @@ -45,8 +45,8 @@ MAKE_HOOK(CNetChannel_SendNetMsg, S::CNetChannel_SendNetMsg(), bool, } catch (...) {}; } break; case FNV1A::Hash32Const("cl_updaterate"): - if (F::Misc.iWishUpdaterate != -1) - strncpy_s(localCvar->Value, std::to_string(F::Misc.iWishUpdaterate).c_str(), MAX_OSPATH); + if (F::Misc.m_iWishUpdaterate != -1) + strncpy_s(localCvar->Value, std::to_string(F::Misc.m_iWishUpdaterate).c_str(), MAX_OSPATH); break; case FNV1A::Hash32Const("cl_interp_ratio"): case FNV1A::Hash32Const("cl_interpolate"): @@ -102,14 +102,14 @@ MAKE_HOOK(CNetChannel_SendNetMsg, S::CNetChannel_SendNetMsg(), bool, sValue = "1"; break; case FNV1A::Hash32Const("cl_cmdrate"): - if (F::Misc.iWishCmdrate != -1) - sValue = std::to_string(F::Misc.iWishCmdrate); + if (F::Misc.m_iWishCmdrate != -1) + sValue = std::to_string(F::Misc.m_iWishCmdrate); else sValue = pConVar->GetString(); break; case FNV1A::Hash32Const("cl_updaterate"): - if (F::Misc.iWishUpdaterate != -1) - sValue = std::to_string(F::Misc.iWishUpdaterate); + if (F::Misc.m_iWishUpdaterate != -1) + sValue = std::to_string(F::Misc.m_iWishUpdaterate); else sValue = pConVar->GetString(); break; diff --git a/Amalgam/src/SDK/Definitions/Types.h b/Amalgam/src/SDK/Definitions/Types.h index 52a183af..b2966ad5 100644 --- a/Amalgam/src/SDK/Definitions/Types.h +++ b/Amalgam/src/SDK/Definitions/Types.h @@ -652,14 +652,14 @@ struct Color_t return std::format("\x8{:02X}{:02X}{:02X}{:02X}", r, g, b, a); } - Color_t Lerp(Color_t to, float t) const + Color_t Lerp(Color_t to, float t, bool bAlpha = true) const { //a + (b - a) * t return { byte(r + (to.r - r) * t), byte(g + (to.g - g) * t), byte(b + (to.b - b) * t), - byte(a + (to.a - a) * t), + byte(bAlpha ? a + (to.a - a) * t : a), }; } }; diff --git a/Amalgam/src/SDK/Helpers/Particles/Particles.h b/Amalgam/src/SDK/Helpers/Particles/Particles.h index 20a58dbc..f96fecec 100644 --- a/Amalgam/src/SDK/Helpers/Particles/Particles.h +++ b/Amalgam/src/SDK/Helpers/Particles/Particles.h @@ -73,22 +73,20 @@ public: inline void DispatchParticleEffect(int iEffectIndex, const Vec3& vecOrigin, const Vec3& vecStart, const Vec3& vecAngles, CBaseEntity* pEntity = nullptr) { - CEffectData data{}; + CEffectData data = {}; data.m_nHitBox = iEffectIndex; data.m_vOrigin = vecOrigin; data.m_vStart = vecStart; data.m_vAngles = vecAngles; - - if (pEntity) { + data.m_bCustomColors = true; + if (pEntity) + { data.m_nEntIndex = pEntity->entindex(); data.m_fFlags |= (1 << 0); data.m_nDamageType = 2; } - else { + else data.m_nEntIndex = 0; - } - - data.m_bCustomColors = true; DispatchEffect("ParticleEffect", data); } diff --git a/Amalgam/src/SDK/SDK.cpp b/Amalgam/src/SDK/SDK.cpp index 79ff8cb4..cffffcfb 100644 --- a/Amalgam/src/SDK/SDK.cpp +++ b/Amalgam/src/SDK/SDK.cpp @@ -619,42 +619,37 @@ bool SDK::StopMovement(CTFPlayer* pLocal, CUserCmd* pCmd) } } -Vec3 SDK::ComputeMove(const CUserCmd* pCmd, CTFPlayer* pLocal, Vec3& a, Vec3& b) +Vec3 SDK::ComputeMove(const CUserCmd* pCmd, CTFPlayer* pLocal, Vec3& vFrom, Vec3& vTo) { - const Vec3 diff = (b - a); - if (diff.Length() == 0.f) - return { 0.f, 0.f, 0.f }; + const Vec3 vDiff = vTo - vFrom; + if (!vDiff.Length()) + return {}; - const float x = diff.x; - const float y = diff.y; - const Vec3 vSilent(x, y, 0); - Vec3 ang; - Math::VectorAngles(vSilent, ang); - const float yaw = DEG2RAD(ang.y - pCmd->viewangles.y); - const float pitch = DEG2RAD(ang.x - pCmd->viewangles.x); - Vec3 move = { cos(yaw) * 450.f, -sin(yaw) * 450.f, -cos(pitch) * 450.f }; + Vec3 vSilent = { vDiff.x, vDiff.y, 0 }; + Vec3 vAngle; Math::VectorAngles(vSilent, vAngle); + const float flYaw = DEG2RAD(vAngle.y - pCmd->viewangles.y); + const float flPitch = DEG2RAD(vAngle.x - pCmd->viewangles.x); - // Only apply upmove in water - if (!(I::EngineTrace->GetPointContents(pLocal->GetEyePosition()) & CONTENTS_WATER)) - move.z = pCmd->upmove; - return move; + Vec3 vMove = { cos(flYaw) * 450.f, -sin(flYaw) * 450.f, -cos(flPitch) * 450.f }; + if (!(I::EngineTrace->GetPointContents(pLocal->GetShootPos()) & CONTENTS_WATER)) // only apply upmove in water + vMove.z = pCmd->upmove; + + return vMove; } -void SDK::WalkTo(CUserCmd* pCmd, CTFPlayer* pLocal, Vec3& a, Vec3& b, float scale) +void SDK::WalkTo(CUserCmd* pCmd, CTFPlayer* pLocal, Vec3& vFrom, Vec3& vTo, float flScale) { - // Calculate how to get to a vector - const auto result = ComputeMove(pCmd, pLocal, a, b); + const auto vResult = ComputeMove(pCmd, pLocal, vFrom, vTo); - // Push our move to usercmd - pCmd->forwardmove = result.x * scale; - pCmd->sidemove = result.y * scale; - pCmd->upmove = result.z * scale; + pCmd->forwardmove = vResult.x * flScale; + pCmd->sidemove = vResult.y * flScale; + pCmd->upmove = vResult.z * flScale; } -void SDK::WalkTo(CUserCmd* pCmd, CTFPlayer* pLocal, Vec3& pDestination) +void SDK::WalkTo(CUserCmd* pCmd, CTFPlayer* pLocal, Vec3& vTo, float flScale) { - Vec3 localPos = pLocal->m_vecOrigin(); - WalkTo(pCmd, pLocal, localPos, pDestination, 1.f); + Vec3 vLocalPos = pLocal->m_vecOrigin(); + WalkTo(pCmd, pLocal, vLocalPos, vTo, flScale); } diff --git a/Amalgam/src/SDK/SDK.h b/Amalgam/src/SDK/SDK.h index 8cc553c8..4de648da 100644 --- a/Amalgam/src/SDK/SDK.h +++ b/Amalgam/src/SDK/SDK.h @@ -108,9 +108,9 @@ namespace SDK void FixMovement(CUserCmd* pCmd, const Vec3& vTargetAngle); bool StopMovement(CTFPlayer* pLocal, CUserCmd* pCmd); - Vec3 ComputeMove(const CUserCmd* pCmd, CTFPlayer* pLocal, Vec3& a, Vec3& b); - void WalkTo(CUserCmd* pCmd, CTFPlayer* pLocal, Vec3& a, Vec3& b, float scale); - void WalkTo(CUserCmd* pCmd, CTFPlayer* pLocal, Vec3& pDestination); + Vec3 ComputeMove(const CUserCmd* pCmd, CTFPlayer* pLocal, Vec3& vFrom, Vec3& vTo); + void WalkTo(CUserCmd* pCmd, CTFPlayer* pLocal, Vec3& vFrom, Vec3& vTo, float flScale = 1.f); + void WalkTo(CUserCmd* pCmd, CTFPlayer* pLocal, Vec3& vTo, float flScale = 1.f); void GetProjectileFireSetup(CTFPlayer* pPlayer, const Vec3& vAngIn, Vec3 vOffset, Vec3& vPosOut, Vec3& vAngOut, bool bPipes = false, bool bInterp = false); void GetProjectileFireSetupAirblast(CTFPlayer* pPlayer, const Vec3& vAngIn, Vec3 vPosIn, Vec3& vAngOut, bool bInterp = false); diff --git a/Amalgam/src/SDK/Vars.h b/Amalgam/src/SDK/Vars.h index e7fd7137..8a6a8900 100644 --- a/Amalgam/src/SDK/Vars.h +++ b/Amalgam/src/SDK/Vars.h @@ -141,7 +141,7 @@ namespace Vars SUBNAMESPACE_BEGIN(Hitscan) CVarEnum(Hitboxes, 0b000111, NONE, Head = 1 << 0, Body = 1 << 1, Pelvis = 1 << 2, Arms = 1 << 3, Legs = 1 << 4, BodyaimIfLethal = 1 << 5) - CVarEnum(Modifiers, 0b01000000, NONE, Tapfire = 1 << 0, WaitForHeadshot = 1 << 1, WaitForCharge = 1 << 2, ScopedOnly = 1 << 3, AutoScope = 1 << 4, AutoRev = 1 << 5, ExtinguishTeam = 1 << 6) + CVarEnum(Modifiers, 0b0100000, NONE, Tapfire = 1 << 0, WaitForHeadshot = 1 << 1, WaitForCharge = 1 << 2, ScopedOnly = 1 << 3, AutoScope = 1 << 4, AutoRev = 1 << 5, ExtinguishTeam = 1 << 6) CVar(PointScale, 0.f) CVar(TapFireDist, 1000.f) @@ -600,6 +600,7 @@ namespace Vars CVar(Up, 0.f, VISUAL) CVar(Crosshair, false, VISUAL) CVar(Scale, true, DEBUGVAR) + CVar(Collide, true, DEBUGVAR) SUBNAMESPACE_END(ThirdPerson) SUBNAMESPACE_BEGIN(FOVArrows)