-
Автор темы
- #1
Пример на исходнике Undefeated!!!
Итак, что нам надо сделать:
1) Сам хук
2) Отрисовка чамсов
Начинаем:
1) "Хукаем" Scene-End
Код:
typedef void(__fastcall *iSceneEnd)(void*, void*);
iSceneEnd oSceneEnd;
if (Interfaces.g_pRenderView)
{
VMTRenderView.bInitialize(reinterpret_cast< DWORD** >(Interfaces.g_pRenderView));
oSceneEnd = reinterpret_cast< iSceneEnd >(VMTRenderView.dwHookMethod(reinterpret_cast< DWORD >(&Hooked_SceneEnd), 9));
}
2)Создаём вызов хука:
Код:
void __fastcall Hooked_SceneEnd(void* thisptr, void* edx)
{
Hacks.oSceneEnd(thisptr, edx);
}
3) Теперь отрисовываем:
Код:
DrawModel:
int draw_model(int flags, uint8_t alpha) {
using fn = int(__thiscall*)(void*, int, uint8_t);
return getvfunc< fn >(GetClientRenderable(), 9)(GetClientRenderable(), flags, alpha);
}
Сам рендер:
void __fastcall Hooked_SceneEnd(void* thisptr, void* edx)
{
for (int i = 1; i < Interfaces.pGlobalVars->maxClients; ++i) {
auto ent = Interfaces.pEntList->GetClientEntity(i);
if (Vars.Visuals.Chams.Enable)
{
if (ent && ent->isValidPlayer()) {
if (ent->GetTeam() == Hacks.LocalPlayer->GetTeam() && !Vars.Visuals.Chams.Team)
continue;
IMaterial* TexVis = Create_Material(false, true, false);
IMaterial* TexXQZ = Create_Material(true, true, false);
IMaterial* FlatVis = Create_Material(false, false, false);
IMaterial* FlatXQZ = Create_Material(true, false, false);
IMaterial* WireVis = Create_Material(false, false, true);
IMaterial* WireXQZ = Create_Material(true, false, true);
TexVis->ColorModulate(Vars.Visuals.Col.ChamsVisible[0], Vars.Visuals.Col.ChamsVisible[1], Vars.Visuals.Col.ChamsVisible[2]);
TexXQZ->ColorModulate(Vars.Visuals.Col.ChamsInvisible[0], Vars.Visuals.Col.ChamsInvisible[1], Vars.Visuals.Col.ChamsInvisible[2]);
FlatVis->ColorModulate(Vars.Visuals.Col.ChamsVisible[0], Vars.Visuals.Col.ChamsVisible[1], Vars.Visuals.Col.ChamsVisible[2]);
FlatXQZ->ColorModulate(Vars.Visuals.Col.ChamsInvisible[0], Vars.Visuals.Col.ChamsInvisible[1], Vars.Visuals.Col.ChamsInvisible[2]);
WireVis->ColorModulate(Vars.Visuals.Col.ChamsVisible[0], Vars.Visuals.Col.ChamsVisible[1], Vars.Visuals.Col.ChamsVisible[2]);
WireXQZ->ColorModulate(Vars.Visuals.Col.ChamsInvisible[0], Vars.Visuals.Col.ChamsInvisible[1], Vars.Visuals.Col.ChamsInvisible[2]);
if (Vars.Visuals.Chams.Type == 0) {
if (!Vars.Visuals.Chams.XQZ)
{
Interfaces.g_pModelRender->ForcedMaterialOverride(TexXQZ);
ent->draw_model(0x1/*STUDIO_RENDER*/, 255);
Interfaces.g_pModelRender->ForcedMaterialOverride(nullptr);
}
Interfaces.g_pModelRender->ForcedMaterialOverride(TexVis);
ent->draw_model(0x1/*STUDIO_RENDER*/, 255);
Interfaces.g_pModelRender->ForcedMaterialOverride(nullptr);
}
if (Vars.Visuals.Chams.Type == 1) {
if (!Vars.Visuals.Chams.XQZ)
{
Interfaces.g_pModelRender->ForcedMaterialOverride(FlatXQZ);
ent->draw_model(0x1/*STUDIO_RENDER*/, 255);
Interfaces.g_pModelRender->ForcedMaterialOverride(nullptr);
}
Interfaces.g_pModelRender->ForcedMaterialOverride(FlatVis);
ent->draw_model(0x1/*STUDIO_RENDER*/, 255);
Interfaces.g_pModelRender->ForcedMaterialOverride(nullptr);
}
if (Vars.Visuals.Chams.Type == 2) {
if (!Vars.Visuals.Chams.XQZ)
{
Interfaces.g_pModelRender->ForcedMaterialOverride(WireXQZ);
ent->draw_model(0x1/*STUDIO_RENDER*/, 255);
Interfaces.g_pModelRender->ForcedMaterialOverride(nullptr);
}
Interfaces.g_pModelRender->ForcedMaterialOverride(WireVis);
ent->draw_model(0x1/*STUDIO_RENDER*/, 255);
Interfaces.g_pModelRender->ForcedMaterialOverride(nullptr);
}
}
}
}
if (Vars.Visuals.Chams.FakeAngle && Hacks.LocalPlayer->isAlive())
{
IMaterial* mat = Create_Material(false, true, false);
if (mat)
{
Hacks.LocalPlayer->SetAngle(Vector(0, lineFakeAngle, 0));
Interfaces.g_pRenderView->SetColorModulation(Vars.Visuals.Col.FakeChams);
Interfaces.g_pModelRender->ForcedMaterialOverride(mat);
Hacks.LocalPlayer->draw_model(0x1, 255);
Interfaces.g_pModelRender->ForcedMaterialOverride(nullptr);
Vector OrigAng;
OrigAng = Hacks.LocalPlayer->GetEyeAngles();
Hacks.LocalPlayer->SetAngle(OrigAng);
}
}
Hacks.oSceneEnd(thisptr, edx);
}