Skip to content

Commit

Permalink
Added some changes by @RileyKun, Made some tiny visual changes
Browse files Browse the repository at this point in the history
I didn't include all the changes by @RileyKun as they broke alt-tab functionality for me

Co-Authored-By: Riley <[email protected]>
  • Loading branch information
Viceroyy and RileyKun committed Jul 25, 2024
1 parent 6453a0f commit 1dd4a17
Show file tree
Hide file tree
Showing 14 changed files with 102 additions and 117 deletions.
76 changes: 53 additions & 23 deletions Amalgam/src/Core/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,43 @@
// File.close();
//}

void CCore::Load()
__forceinline bool CheckRenderIsCompatible()
{
// Check the DirectX version
// Check for if we are running in DXVK mode.
if (GetModuleHandleA("dxvk_d3d9.dll"))
{
MessageBoxA(nullptr, "You are running with graphics options that Amalgam does not support.\n"
"Please remove -vulkan from your launch options and reinject.", "Error", MB_ICONERROR);
U::Core.bUnload = true;
return false;
}

// Check for if we are running in DirectX 8.
auto cvDXLevel = I::CVar->FindVar("mat_dxlevel");
auto iLevel = cvDXLevel->GetInt();
if (iLevel < 90)
{
std::string fmt = std::format("You are running with graphics options that Amalgam does not support.\nPlease remove -dxlevel {} from your launch options and reinject.\0", iLevel);
MessageBox(nullptr, fmt.c_str(), "Error", MB_ICONERROR);
U::Core.bUnload = true;
return false;
}

return true;
}

void CCore::Load()
{
U::Signatures.Initialize();
U::Interfaces.Initialize();
//DumpTables();
U::Hooks.Initialize();

U::ConVars.Initialize();

if (!CheckRenderIsCompatible())
return;

U::Hooks.Initialize();
F::Materials.LoadMaterials();
F::Commands.Initialize();

Expand All @@ -93,31 +121,33 @@ void CCore::Load()

void CCore::Unload()
{
G::Unload = true;
if (!bUnload)
{
G::Unload = true;

F::EventListener.Destroy();
U::Hooks.Unload();
U::ConVars.Unload();
F::Materials.UnloadMaterials();
F::EventListener.Destroy();
U::Hooks.Unload();
U::ConVars.Unload();
F::Materials.UnloadMaterials();

F::Visuals.RestoreWorldModulation();
Vars::Visuals::World::SkyboxChanger.Value = "Off"; // hooks won't run, remove here
if (I::Input->CAM_IsThirdPerson())
{
auto pLocal = H::Entities.GetLocal();
if (pLocal)
F::Visuals.RestoreWorldModulation();
Vars::Visuals::World::SkyboxChanger.Value = "Off"; // hooks won't run, remove here
if (I::Input->CAM_IsThirdPerson())
{
I::Input->CAM_ToFirstPerson();
pLocal->ThirdPersonSwitch();
auto pLocal = H::Entities.GetLocal();
if (pLocal)
{
I::Input->CAM_ToFirstPerson();
pLocal->ThirdPersonSwitch();
}
}
}
if (auto cl_wpn_sway_interp = U::ConVars.FindVar("cl_wpn_sway_interp"))
cl_wpn_sway_interp->SetValue(0.f);
if (auto cl_wpn_sway_scale = U::ConVars.FindVar("cl_wpn_sway_scale"))
cl_wpn_sway_scale->SetValue(0.f);

Sleep(250);
if (auto cl_wpn_sway_interp = U::ConVars.FindVar("cl_wpn_sway_interp"))
cl_wpn_sway_interp->SetValue(0.f);
if (auto cl_wpn_sway_scale = U::ConVars.FindVar("cl_wpn_sway_scale"))
cl_wpn_sway_scale->SetValue(0.f);

Sleep(250);
}
SDK::Output("Amalgam", "Unloaded", { 175, 150, 255, 255 });
}

Expand Down
2 changes: 1 addition & 1 deletion Amalgam/src/DllMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
SetUnhandledExceptionFilter(Minidump::ExceptionFilter);
#endif

DisableThreadLibraryCalls(hinstDLL);
//DisableThreadLibraryCalls(hinstDLL);
if (const auto hMainThread = CreateThread(nullptr, 0, MainThread, hinstDLL, 0, nullptr))
CloseHandle(hMainThread);
}
Expand Down
1 change: 0 additions & 1 deletion Amalgam/src/Features/ImGui/Render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ void CRender::Render(IDirect3DDevice9* pDevice)
LoadColors();
PushFont(FontRegular);

F::Visuals.DrawTickbaseBars();
F::Menu.Render();

PopFont();
Expand Down
2 changes: 1 addition & 1 deletion Amalgam/src/Features/Misc/Misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ void CMisc::PingReducer()
if (cl_cmdrate == nullptr || netChannel == nullptr) { return; }

static Timer updateRateTimer{};
if (updateRateTimer.Run(500))
if (updateRateTimer.Run(250))
{
if (Vars::Misc::Exploits::PingReducer.Value)
{
Expand Down
2 changes: 1 addition & 1 deletion Amalgam/src/Features/Visuals/ESP/ESP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ void CESP::DrawBuildings(CTFPlayer* pLocal)
// Building level
if (Vars::ESP::Building.Value & 1 << 6 && !bIsMini)
{
H::Draw.String(fFont, x + w + 4, y + rOffset, { 254, 202, 87, 255 }, ALIGN_TOPLEFT, L"LEVEL %d", pBuilding->m_iUpgradeLevel());
H::Draw.String(fFont, x + w + 4, y + rOffset, { 254, 202, 87, 255 }, ALIGN_TOPLEFT, L"%d", pBuilding->m_iUpgradeLevel());
rOffset += fFont.m_nTall;
}

Expand Down
39 changes: 5 additions & 34 deletions Amalgam/src/Features/Visuals/SpectatorList/SpectatorList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@ bool CSpectatorList::GetSpectators(CTFPlayer* pLocal)
{
case OBS_MODE_DEATHCAM: { szMode = L"Deathcam"; break; }
case OBS_MODE_FREEZECAM: { szMode = L"Freezecam"; break; }
case OBS_MODE_FIXED: { szMode = L"Fixed"; break; }
case OBS_MODE_FIRSTPERSON: { szMode = L"1st"; break; }
case OBS_MODE_FIRSTPERSON: { szMode = L"1st"; break; }
case OBS_MODE_THIRDPERSON: { szMode = L"3rd"; break; }
case OBS_MODE_ROAMING: { szMode = L"Roaming"; break; }
default: { continue; }
}

Expand Down Expand Up @@ -75,7 +73,6 @@ void CSpectatorList::Run(CTFPlayer* pLocal)
EAlign align = ALIGN_TOP;
if (x <= (100 + 50 * Vars::Menu::DPI.Value))
{
// iconOffset = 36;
x -= 42 * Vars::Menu::DPI.Value;
align = ALIGN_TOPLEFT;
}
Expand All @@ -84,11 +81,6 @@ void CSpectatorList::Run(CTFPlayer* pLocal)
x += 42 * Vars::Menu::DPI.Value;
align = ALIGN_TOPRIGHT;
}
//else
// iconOffset = 16;

//if (!Vars::Menu::SpectatorAvatars.Value)
// iconOffset = 0;

const auto& fFont = H::Fonts.GetFont(FONT_INDICATORS);

Expand All @@ -97,37 +89,16 @@ void CSpectatorList::Run(CTFPlayer* pLocal)
{
y += fFont.m_nTall + 3;

/*
if (Vars::Visuals::SpectatorAvatars.Value)
{
int w, h;
I::MatSystemSurface->GetTextSize(H::Fonts.GetFont(FONT_INDICATORS).dwFont,
(Spectator.Name + Spectator.Mode + std::to_wstring(Spectator.RespawnIn) + std::wstring{L" - (respawn s)"}).c_str(), w, h);
switch (align)
{
case ALIGN_DEFAULT: w = 0; break;
case ALIGN_CENTERHORIZONTAL: w /= 2; break;
}
PlayerInfo_t pi{};
if (!I::EngineClient->GetPlayerInfo(Spectator.Index, &pi))
continue;
H::Draw.Avatar(x - w - (36 - iconOffset), y, 24, 24, pi.friendsID);
// center - half the width of the string
y += 6;
}
*/

Color_t color = Vars::Menu::Theme::Active.Value;
if (Spectator.Mode == std::wstring{L"1st"})
color = { 255, 200, 127, 255 };
if (Spectator.RespawnTimeIncreased)
color = SDK::WarningColor();
if (Spectator.IsFriend)
color = { 200, 255, 200, 255 };
H::Draw.String(fFont, x + iconOffset, y, color, align,
L"%ls - %ls (respawn %ds)", Spectator.Name.data(), Spectator.Mode.data(), Spectator.RespawnIn);
if (Spectator.Team == pLocal->m_iTeamNum())
H::Draw.String(fFont, x + iconOffset, y, color, align, L"%ls - %ls (respawn %ds)", Spectator.Name.data(), Spectator.Mode.data(), Spectator.RespawnIn);
else
H::Draw.String(fFont, x + iconOffset, y, Vars::Menu::Theme::Accent.Value, align, L"%ls - %ls", Spectator.Name.data(), Spectator.Mode.data());
}
}
1 change: 0 additions & 1 deletion Amalgam/src/Features/Visuals/SpectatorList/SpectatorList.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class CSpectatorList
std::unordered_map<int, float> RespawnCache;

public:
int SpecListX = 30, SpecListY = 100;
bool GetSpectators(CTFPlayer* pLocal);
void Run(CTFPlayer* pLocal);
};
Expand Down
34 changes: 0 additions & 34 deletions Amalgam/src/Features/Visuals/Visuals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,40 +58,6 @@ void CVisuals::DrawTickbaseText(CTFPlayer* pLocal)
H::Draw.EndClipping();
}
}
void CVisuals::DrawTickbaseBars()
{
/* get rid of me
if (!(Vars::Menu::Indicators.Value & (1 << 0)) || I::EngineVGui->IsGameUIVisible())
return;
auto pLocal = I::ClientEntityList->GetClientEntity(I::EngineClient->GetLocalPlayer());
if (!pLocal || !pLocal->As<CTFPlayer>()->IsAlive())
return;
const int iTicks = std::clamp(G::ShiftedTicks + G::ChokeAmount, 0, G::MaxShift);
const DragBox_t dtPos = Vars::Menu::TicksDisplay.Value;
const auto& fFont = H::Fonts.GetFont(FONT_INDICATORS);
const float ratioCurrent = (float)iTicks / (float)G::MaxShift;
float sizeX = 100 * Vars::Menu::DPI.Value, sizeY = 12 * Vars::Menu::DPI.Value, posY = dtPos.y + 5 + fFont.m_nTall;
ImGui::GetBackgroundDrawList()->AddRectFilled(
ImVec2(dtPos.x - sizeX / 2, posY), ImVec2(dtPos.x + sizeX / 2, posY + sizeY),
F::Render.Background, 10
);
if (iTicks && ratioCurrent)
{
sizeX = 96 * Vars::Menu::DPI.Value, sizeY = 8 * Vars::Menu::DPI.Value; posY = posY + 2 * Vars::Menu::DPI.Value;
ImGui::GetBackgroundDrawList()->PushClipRect(ImVec2(dtPos.x - sizeX / 2, posY), ImVec2(dtPos.x - sizeX / 2 + sizeX * ratioCurrent + 1, posY + sizeY), true);
ImGui::GetBackgroundDrawList()->AddRectFilled(
ImVec2(dtPos.x - sizeX / 2, posY), ImVec2(dtPos.x + sizeX / 2, posY + sizeY),
ImColor(Vars::Menu::Theme::Accent.Value.r, Vars::Menu::Theme::Accent.Value.g, Vars::Menu::Theme::Accent.Value.b, Vars::Menu::Theme::Accent.Value.a), 10
);
ImGui::GetBackgroundDrawList()->PopClipRect();
}
*/
}

void CVisuals::DrawOnScreenPing(CTFPlayer* pLocal)
{
Expand Down
1 change: 0 additions & 1 deletion Amalgam/src/Features/Visuals/Visuals.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class CVisuals
public:
void DrawAimbotFOV(CTFPlayer* pLocal);
void DrawTickbaseText(CTFPlayer* pLocal);
void DrawTickbaseBars();
void DrawOnScreenPing(CTFPlayer* pLocal);
void DrawOnScreenConditions(CTFPlayer* pLocal);
void DrawSeedPrediction(CTFPlayer* pLocal);
Expand Down
3 changes: 2 additions & 1 deletion Amalgam/src/Hooks/CTFRagdoll_CreateTFRagdoll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ MAKE_HOOK(CTFRagdoll_CreateTFRagdoll, S::CTFRagdoll_CreateTFRagdoll(), void, __f
if (!Vars::Visuals::Ragdolls::Enabled.Value)
return CALL_ORIGINAL(ecx);

if (auto pEntity = static_cast<CBaseAnimating*>(ecx))
auto pEntity = static_cast<CBaseAnimating*>(ecx);
if (pEntity)
{
if (Vars::Visuals::Ragdolls::EnemyOnly.Value)
{
Expand Down
14 changes: 5 additions & 9 deletions Amalgam/src/Hooks/ModelRender_DrawModelExecute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,12 @@ MAKE_HOOK(ModelRender_DrawModelExecute, U::Memory.GetVFunc(I::ModelRender, 19),

if (Vars::Visuals::Removals::Cosmetics.Value && pInfo.pModel)
{
auto pEntity = I::ClientEntityList->GetClientEntity(pInfo.entity_index)->As<CTFPlayer>();
if (pEntity && pEntity != H::Entities.GetLocal())
const char* name = I::ModelInfoClient->GetModelName(pInfo.pModel);
if (name)
{
const char* name = I::ModelInfoClient->GetModelName(pInfo.pModel);
if (name)
{
std::string sname = name;
if (sname.find("player/items") != std::string::npos)
return;
}
std::string sname = name;
if (sname.find("player/items") != std::string::npos)
return;
}
}

Expand Down
14 changes: 12 additions & 2 deletions Amalgam/src/Hooks/StudioRender_SetAlphaModulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,18 @@
MAKE_HOOK(StudioRender_SetAlphaModulation, U::Memory.GetVFunc(I::StudioRender, 28), void, __fastcall,
void* ecx, float flAlpha)
{
if (Vars::Visuals::World::Modulations.Value & (1 << 2) && G::DrawingProps && !(Vars::Visuals::UI::CleanScreenshots.Value && I::EngineClient->IsTakingScreenshot()))
return CALL_ORIGINAL(ecx, float(Vars::Colors::PropModulation.Value.a) / 255.f * flAlpha);
if (Vars::Visuals::World::Modulations.Value & (1 << 2) &&
G::DrawingProps && !(Vars::Visuals::UI::CleanScreenshots.Value && I::EngineClient->IsTakingScreenshot()))
{
// TODO: make these static?
auto PropVal = Vars::Colors::PropModulation.Value.a;
auto flHookAlpha = flAlpha;

if (PropVal || flHookAlpha)
{
auto flVal = PropVal / 255.f * flHookAlpha;
return CALL_ORIGINAL(ecx, flVal);
}
}
CALL_ORIGINAL(ecx, flAlpha);
}
25 changes: 19 additions & 6 deletions Amalgam/src/Hooks/StudioRender_SetColorModulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,26 @@ MAKE_HOOK(StudioRender_SetColorModulation, U::Memory.GetVFunc(I::StudioRender, 2
{
if (Vars::Visuals::World::Modulations.Value & (1 << 2) && G::DrawingProps && !(Vars::Visuals::UI::CleanScreenshots.Value && I::EngineClient->IsTakingScreenshot()))
{
const float flCustomBlend[3] = {
float(Vars::Colors::PropModulation.Value.r) / 255.f,
float(Vars::Colors::PropModulation.Value.g) / 255.f,
float(Vars::Colors::PropModulation.Value.b) / 255.f
};
// TODO: make these static?
auto Red = Vars::Colors::PropModulation.Value.r;
auto Green = Vars::Colors::PropModulation.Value.g;
auto Blue = Vars::Colors::PropModulation.Value.b;

return CALL_ORIGINAL(ecx, flCustomBlend);
// Assert the values to make sure they aren't 0, we're dividing here.
if (Red || Green || Blue)
{
float flRed = Red / 255.f;
float flGreen = Green / 255.f;
float flBlue = Blue / 255.f;

const float flBlend[3] = {
flRed,
flGreen,
flBlue
};

return CALL_ORIGINAL(ecx, flBlend);
}
}

CALL_ORIGINAL(ecx, pColor);
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ With a few more features here and there, notable changes include;
- Fast stop that utilizes counter strafing
- Capture flag esp/chams/glow and return timer
- Teleporter recharge timer
- Pickup timer that works
- Healthpack/Ammopack respawn timer that works
- Hurt teammates chams when playing as medic
- PS2/Low graphic models toggle
- PS2/Low graphic models and flat textures toggle
- Ping reducer with a target ping
- Live font changer
- Force enabled game fixes and pure bypass because why would you ever not want those
- And possibly more

Expand Down

0 comments on commit 1dd4a17

Please sign in to comment.