From e9c8395e01fb5619dee5920f0ac825d1dc15dafa Mon Sep 17 00:00:00 2001 From: nullifiedcat Date: Wed, 12 Apr 2017 14:57:56 +0300 Subject: [PATCH 1/8] useless --- src/entitycache.cpp | 1 - src/hack.cpp | 5 +++++ src/hooks.cpp | 1 + src/hooks.h | 2 ++ src/hooks/hookedmethods.h | 10 +++------- src/hooks/others.cpp | 13 +++++++++++++ src/interfaces.cpp | 2 ++ src/interfaces.h | 2 ++ 8 files changed, 28 insertions(+), 8 deletions(-) diff --git a/src/entitycache.cpp b/src/entitycache.cpp index 2e6a58a7..c874613c 100644 --- a/src/entitycache.cpp +++ b/src/entitycache.cpp @@ -38,7 +38,6 @@ void EntityCache::Invalidate() { void CachedEntity::Update(int idx) { SEGV_BEGIN - m_IDX = idx; if (!RAW_ENT(this)) return; #if PROXY_ENTITY != true diff --git a/src/hack.cpp b/src/hack.cpp index 1cc2879c..9ec81785 100644 --- a/src/hack.cpp +++ b/src/hack.cpp @@ -171,6 +171,10 @@ void hack::Initialize() { hooks::hkInput->Init((void*)g_IInput, 0); hooks::hkInput->HookMethod((void*)GetUserCmd_hook, hooks::offGetUserCmd); hooks::hkInput->Apply(); + hooks::hkIVModelRender = new hooks::VMTHook(); + hooks::hkIVModelRender->Init(g_IVModelRender, 0); + hooks::hkIVModelRender->HookMethod((void*)DrawModelExecute_hook, hooks::offDrawModelExecute); + hooks::hkIVModelRender->Apply(); if (TF2) g_GlowObjectManager = *reinterpret_cast(gSignatures.GetClientSignature("C1 E0 05 03 05") + 5); InitStrings(); hacks::shared::killsay::Init(); @@ -195,6 +199,7 @@ void hack::Shutdown() { if (hooks::hkNetChannel) hooks::hkNetChannel->Kill(); if (hooks::hkStudioRender) hooks::hkStudioRender->Kill(); if (hooks::hkInput) hooks::hkInput->Kill(); + if (hooks::hkIVModelRender) hooks::hkIVModelRender->Kill(); //if (hooks::hkCTFPlayer) hooks::hkCTFPlayer->Kill(); logging::Info("Unregistering convars.."); ConVar_Unregister(); diff --git a/src/hooks.cpp b/src/hooks.cpp index 84b9c165..142cae49 100644 --- a/src/hooks.cpp +++ b/src/hooks.cpp @@ -81,3 +81,4 @@ hooks::VMTHook* hooks::hkNetChannel = 0; hooks::VMTHook* hooks::hkClientDLL = 0; hooks::VMTHook* hooks::hkMatSurface = 0; hooks::VMTHook* hooks::hkStudioRender = 0; +hooks::VMTHook* hooks::hkIVModelRender = nullptr; diff --git a/src/hooks.h b/src/hooks.h index d74fab37..3f4a8a89 100644 --- a/src/hooks.h +++ b/src/hooks.h @@ -40,9 +40,11 @@ extern VMTHook* hkClientDLL; extern VMTHook* hkMatSurface; extern VMTHook* hkStudioRender; extern VMTHook* hkInput; +extern VMTHook* hkIVModelRender; constexpr unsigned int offGetUserCmd = 8; constexpr unsigned int offShouldDraw = 136; +constexpr unsigned int offDrawModelExecute = 19; extern unsigned int offHandleInputEvent; extern unsigned int offPaintTraverse; extern unsigned int offCreateMove; diff --git a/src/hooks/hookedmethods.h b/src/hooks/hookedmethods.h index 3f04bb6e..9a43891a 100644 --- a/src/hooks/hookedmethods.h +++ b/src/hooks/hookedmethods.h @@ -8,13 +8,7 @@ #ifndef HOOKEDMETHODS_H_ #define HOOKEDMETHODS_H_ -class IStudioRender; -class CUserCmd; -class INetMessage; -class bf_read; -class CViewSetup; -class IClientEntity; -class IInput; +#include "../common.h" typedef bool(CreateMove_t)(void*, float, CUserCmd*); typedef void(PaintTraverse_t)(void*, unsigned int, bool, bool); @@ -29,6 +23,7 @@ typedef void(LevelInit_t)(void*, const char*); typedef void(LevelShutdown_t)(void*); typedef void(BeginFrame_t)(IStudioRender*); typedef bool(*CanInspect_t)(IClientEntity*); +typedef void(*DrawModelExecute_t)(IVModelRender*, const DrawModelState_t&, const ModelRenderInfo_t&, matrix3x4_t*); typedef CUserCmd*(GetUserCmd_t)(IInput*, int); //typedef void(*CInput__CreateMove_t)(void*, int, float, bool); //void CInput__CreateMove_hook(void*, int sequence_number, float input_sample_frametime, bool active); @@ -36,6 +31,7 @@ bool CanInspect_hook(IClientEntity*); const unsigned int offCanInspect = 512; void BeginFrame_hook(IStudioRender*); CUserCmd* GetUserCmd_hook(IInput*, int); +void DrawModelExecute_hook(IVModelRender* _this, const DrawModelState_t& state, const ModelRenderInfo_t& info, matrix3x4_t* matrix); #include "CreateMove.h" #include "PaintTraverse.h" diff --git a/src/hooks/others.cpp b/src/hooks/others.cpp index 4494258a..545b1607 100644 --- a/src/hooks/others.cpp +++ b/src/hooks/others.cpp @@ -10,6 +10,19 @@ #include "../hack.h" #include "hookedmethods.h" +void DrawModelExecute_hook(IVModelRender* _this, const DrawModelState_t& state, const ModelRenderInfo_t& info, matrix3x4_t* matrix) { + IClientUnknown* unknown = info.pRenderable->GetIClientUnknown(); + if (unknown) { + IClientEntity* entity = unknown->GetIClientEntity(); + if (entity && entity->entindex() != -1) { + if (entity->GetClientClass() == g_pClassID->C_Player) { + //CMatRenderContextPtr ptr(); + } + } + } + ((DrawModelExecute_t)(hooks::hkIVModelRender->GetMethod(hooks::offDrawModelExecute)))(_this, state, info, matrix); +} + bool CanPacket_hook(void* thisptr) { SEGV_BEGIN; return send_packets && ((CanPacket_t*)hooks::hkNetChannel->GetMethod(hooks::offCanPacket))(thisptr); diff --git a/src/interfaces.cpp b/src/interfaces.cpp index 5b08cebb..87b7ff2f 100644 --- a/src/interfaces.cpp +++ b/src/interfaces.cpp @@ -21,6 +21,7 @@ //class ISteamFriends002; +IVModelRender* g_IVModelRender = nullptr; ISteamClient* g_ISteamClient = nullptr; ISteamFriends* g_ISteamFriends = nullptr; IVEngineClient013* g_IEngine = nullptr; @@ -83,6 +84,7 @@ void CreateInterfaces() { g_IVDebugOverlay = BruteforceInterface("VDebugOverlay", sharedobj::engine); HSteamPipe sp = g_ISteamClient->CreateSteamPipe(); HSteamUser su = g_ISteamClient->ConnectToGlobalUser(sp); + g_IVModelRender = BruteforceInterface("VEngineModel", sharedobj::engine, 16); g_ISteamFriends = g_ISteamClient->GetISteamFriends(su, sp, "SteamFriends002"); g_GlobalVars = **(reinterpret_cast((uintptr_t)11 + gSignatures.GetClientSignature("55 89 E5 83 EC ? 8B 45 08 8B 15 ? ? ? ? F3 0F 10"))); g_IPrediction = BruteforceInterface("VClientPrediction", sharedobj::client); diff --git a/src/interfaces.h b/src/interfaces.h index 18ab9bfb..5e270b7c 100644 --- a/src/interfaces.h +++ b/src/interfaces.h @@ -42,7 +42,9 @@ class IAchievementMgr; class ISteamUserStats; class IStudioRender; class IVDebugOverlay; +class IVModelRender; +extern IVModelRender* g_IVModelRender; extern ISteamClient* g_ISteamClient; extern ISteamFriends* g_ISteamFriends; extern IVEngineClient013* g_IEngine; From 3e8ea7cf5546d9fa14ff584ee49987fa93dfea03 Mon Sep 17 00:00:00 2001 From: nullifiedcat Date: Thu, 13 Apr 2017 14:46:45 +0300 Subject: [PATCH 2/8] working "glow" screen space effect dummy --- src/EffectGlow.cpp | 30 ++++++++++++ src/EffectGlow.hpp | 32 +++++++++++++ src/common.h | 1 + src/hack.cpp | 6 +++ src/hooks/others.cpp | 2 +- src/interfaces.cpp | 5 ++ src/sdk.h | 1 + src/sdk/ScreenSpaceEffects.h | 92 ++++++++++++++++++++++++++++++++++++ 8 files changed, 168 insertions(+), 1 deletion(-) create mode 100644 src/EffectGlow.cpp create mode 100644 src/EffectGlow.hpp create mode 100644 src/sdk/ScreenSpaceEffects.h diff --git a/src/EffectGlow.cpp b/src/EffectGlow.cpp new file mode 100644 index 00000000..67bf1c8f --- /dev/null +++ b/src/EffectGlow.cpp @@ -0,0 +1,30 @@ +/* + * EffectGlow.cpp + * + * Created on: Apr 13, 2017 + * Author: nullifiedcat + */ + +#include "common.h" +#include "EffectGlow.hpp" + +// FIXME move to sdk +CScreenSpaceEffectRegistration *CScreenSpaceEffectRegistration::s_pHead = NULL; +IScreenSpaceEffectManager* g_pScreenSpaceEffects = nullptr; +CScreenSpaceEffectRegistration** g_ppScreenSpaceRegistrationHead = nullptr; +CScreenSpaceEffectRegistration::CScreenSpaceEffectRegistration( const char *pName, IScreenSpaceEffect *pEffect ) +{ + logging::Info("Creating new effect '%s', head: 0x%08x", pName, *g_ppScreenSpaceRegistrationHead); + m_pEffectName = pName; + m_pEffect = pEffect; + m_pNext = *g_ppScreenSpaceRegistrationHead; + *g_ppScreenSpaceRegistrationHead = this; + logging::Info("New head: 0x%08x", *g_ppScreenSpaceRegistrationHead); +} + +void EffectGlow::Render(int x, int y, int w, int h) { + +} + +EffectGlow g_EffectGlow; +CScreenSpaceEffectRegistration* g_pEffectGlow = nullptr; diff --git a/src/EffectGlow.hpp b/src/EffectGlow.hpp new file mode 100644 index 00000000..5e7c7693 --- /dev/null +++ b/src/EffectGlow.hpp @@ -0,0 +1,32 @@ +/* + * EffectGlow.hpp + * + * Created on: Apr 13, 2017 + * Author: nullifiedcat + */ + +#ifndef EFFECTGLOW_HPP_ +#define EFFECTGLOW_HPP_ + +#include "common.h" + +class EffectGlow : public IScreenSpaceEffect { +public: + inline virtual void Init( ) {}; + inline virtual void Shutdown( ) {}; + + inline virtual void SetParameters( KeyValues *params ) {}; + + virtual void Render( int x, int y, int w, int h ); + + inline virtual void Enable( bool bEnable ) { enabled = bEnable; }; + inline virtual bool IsEnabled( ) { return enabled; }; + +public: + bool enabled; +}; + +extern EffectGlow g_EffectGlow; +extern CScreenSpaceEffectRegistration* g_pEffectGlow; + +#endif /* EFFECTGLOW_HPP_ */ diff --git a/src/common.h b/src/common.h index 01c67257..459871dd 100644 --- a/src/common.h +++ b/src/common.h @@ -33,6 +33,7 @@ #include "helpers.h" #include "playerlist.hpp" #include "interfaces.h" +#include "EffectGlow.hpp" #include "localplayer.h" #include "logging.h" #include "playerresource.h" diff --git a/src/hack.cpp b/src/hack.cpp index 7c31a990..9b1b2a07 100644 --- a/src/hack.cpp +++ b/src/hack.cpp @@ -183,6 +183,12 @@ void hack::Initialize() { hack::command_stack().push("cat_spam_reload"); logging::Info("Hooked!"); playerlist::Load(); + g_pEffectGlow = new CScreenSpaceEffectRegistration("_cathook_glow", &g_EffectGlow); + for (CScreenSpaceEffectRegistration* reg = *g_ppScreenSpaceRegistrationHead; reg; reg = reg->m_pNext) { + logging::Info("%s", reg->m_pEffectName); + } + g_pScreenSpaceEffects->EnableScreenSpaceEffect("_cathook_glow"); + logging::Info("SSE enabled.."); } void hack::Think() { diff --git a/src/hooks/others.cpp b/src/hooks/others.cpp index 57005ec7..ae85aec9 100644 --- a/src/hooks/others.cpp +++ b/src/hooks/others.cpp @@ -15,7 +15,7 @@ void DrawModelExecute_hook(IVModelRender* _this, const DrawModelState_t& state, if (unknown) { IClientEntity* entity = unknown->GetIClientEntity(); if (entity && entity->entindex() != -1) { - if (entity->GetClientClass() == g_pClassID->C_Player) { + if (entity->GetClientClass()->m_ClassID == g_pClassID->C_Player) { //CMatRenderContextPtr ptr(); } } diff --git a/src/interfaces.cpp b/src/interfaces.cpp index abf84f2b..4e0ed9ce 100644 --- a/src/interfaces.cpp +++ b/src/interfaces.cpp @@ -89,6 +89,11 @@ void CreateInterfaces() { g_GlobalVars = **(reinterpret_cast((uintptr_t)11 + gSignatures.GetClientSignature("55 89 E5 83 EC ? 8B 45 08 8B 15 ? ? ? ? F3 0F 10"))); g_IPrediction = BruteforceInterface("VClientPrediction", sharedobj::client); g_IGameMovement = BruteforceInterface("GameMovement", sharedobj::client); + if (TF2) { + // FIXME static pointer + g_pScreenSpaceEffects = *(IScreenSpaceEffectManager**)sharedobj::client->Pointer(0x01F73E74); + g_ppScreenSpaceRegistrationHead = (CScreenSpaceEffectRegistration**)sharedobj::client->Pointer(0x02018E30); + } if (TF2) g_IInput = **(reinterpret_cast((uintptr_t)1 + gSignatures.GetClientSignature("A1 ? ? ? ? C6 05 ? ? ? ? 01 8B 10 89 04 24 FF 92 B4 00 00 00 A1 ? ? ? ? 8B 10"))); else if (TF2C) g_IInput = **(reinterpret_cast((uintptr_t)1 + gSignatures.GetClientSignature("A1 ? ? ? ? C6 05 ? ? ? ? 01 8B 10 89 04 24 FF 92 A8 00 00 00 A1 ? ? ? ? 8B 10"))); else if (HL2DM) g_IInput = **(reinterpret_cast((uintptr_t)1 + gSignatures.GetClientSignature("A1 ? ? ? ? 8B 10 89 04 24 FF 52 78 A1 ? ? ? ? 8B 10"))); diff --git a/src/sdk.h b/src/sdk.h index fa17f4c5..40e2f1bf 100644 --- a/src/sdk.h +++ b/src/sdk.h @@ -50,6 +50,7 @@ #include #include "sdk/in_buttons.h" +#include "sdk/ScreenSpaceEffects.h" #include "sdk/iinput.h" #endif /* SDK_H_ */ diff --git a/src/sdk/ScreenSpaceEffects.h b/src/sdk/ScreenSpaceEffects.h new file mode 100644 index 00000000..8a729739 --- /dev/null +++ b/src/sdk/ScreenSpaceEffects.h @@ -0,0 +1,92 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +// +//=====================================================================================// + +#ifndef SCREENSPACEEFFECTS_H +#define SCREENSPACEEFFECTS_H + +#ifdef _WIN32 +#pragma once +#endif + +class KeyValues; + + +//------------------------------------------------------------------------------ +// Simple base class for screen space post-processing effects +//------------------------------------------------------------------------------ +class IScreenSpaceEffect +{ +public: + + virtual void Init( ) = 0; + virtual void Shutdown( ) = 0; + + virtual void SetParameters( KeyValues *params ) = 0; + + virtual void Render( int x, int y, int w, int h ) = 0; + + virtual void Enable( bool bEnable ) = 0; + virtual bool IsEnabled( ) = 0; +}; + + +//------------------------------------------------------------------------------ +// Interface class for managing screen space post-processing effects +//------------------------------------------------------------------------------ +class IScreenSpaceEffectManager +{ +public: + + virtual void InitScreenSpaceEffects( ) = 0; + virtual void ShutdownScreenSpaceEffects( ) = 0; + + virtual IScreenSpaceEffect *GetScreenSpaceEffect( const char *pEffectName ) = 0; + + virtual void SetScreenSpaceEffectParams( const char *pEffectName, KeyValues *params ) = 0; + virtual void SetScreenSpaceEffectParams( IScreenSpaceEffect *pEffect, KeyValues *params ) = 0; + + virtual void EnableScreenSpaceEffect( const char *pEffectName ) = 0; + virtual void EnableScreenSpaceEffect( IScreenSpaceEffect *pEffect ) = 0; + + virtual void DisableScreenSpaceEffect( const char *pEffectName ) = 0; + virtual void DisableScreenSpaceEffect( IScreenSpaceEffect *pEffect ) = 0; + + virtual void DisableAllScreenSpaceEffects( ) = 0; + + virtual void RenderEffects( int x, int y, int w, int h ) = 0; +}; + +extern IScreenSpaceEffectManager *g_pScreenSpaceEffects; + + +//------------------------------------------------------------------------------------- +// Registration class for adding screen space effects to the IScreenSpaceEffectManager +//------------------------------------------------------------------------------------- +class CScreenSpaceEffectRegistration +{ +public: + CScreenSpaceEffectRegistration( const char *pName, IScreenSpaceEffect *pEffect ); + + const char *m_pEffectName; + IScreenSpaceEffect *m_pEffect; + + CScreenSpaceEffectRegistration *m_pNext; + + // NEVER USE - CATHOOK + static CScreenSpaceEffectRegistration *s_pHead; +}; + +// CATHOOK +extern CScreenSpaceEffectRegistration** g_ppScreenSpaceRegistrationHead; + +#define ADD_SCREENSPACE_EFFECT( CEffect, pEffectName ) CEffect pEffectName##_effect; \ + CScreenSpaceEffectRegistration pEffectName##_reg( #pEffectName, &pEffectName##_effect ); + + + +#endif From de33a1469898aac7a74943a00746a34d4d309bab Mon Sep 17 00:00:00 2001 From: nullifiedcat Date: Thu, 13 Apr 2017 14:50:17 +0300 Subject: [PATCH 3/8] materialsystem, renderview, model interfaces.. --- src/interfaces.cpp | 6 ++++++ src/interfaces.h | 6 ++++++ src/sharedobj.cpp | 2 ++ src/sharedobj.h | 1 + 4 files changed, 15 insertions(+) diff --git a/src/interfaces.cpp b/src/interfaces.cpp index 4e0ed9ce..7cf8dcb0 100644 --- a/src/interfaces.cpp +++ b/src/interfaces.cpp @@ -45,6 +45,9 @@ IAchievementMgr* g_IAchievementMgr = nullptr; ISteamUserStats* g_ISteamUserStats = nullptr; IStudioRender* g_IStudioRender = nullptr; IVDebugOverlay* g_IVDebugOverlay = nullptr; +IVModelRender* g_IVModelRender = nullptr; +IMaterialSystem* g_IMaterialSystem = nullptr; +IVRenderView* g_IVRenderView = nullptr; template T* BruteforceInterface(std::string name, sharedobj::SharedObject* object, int start) { @@ -89,6 +92,9 @@ void CreateInterfaces() { g_GlobalVars = **(reinterpret_cast((uintptr_t)11 + gSignatures.GetClientSignature("55 89 E5 83 EC ? 8B 45 08 8B 15 ? ? ? ? F3 0F 10"))); g_IPrediction = BruteforceInterface("VClientPrediction", sharedobj::client); g_IGameMovement = BruteforceInterface("GameMovement", sharedobj::client); + g_IVRenderView = BruteforceInterface("VEngineRenderView", sharedobj::engine); + g_IMaterialSystem = BruteforceInterface("VMaterialSystem", sharedobj::materialsystem, 81); + g_IVModelRender = BruteforceInterface("VEngineModel", sharedobj::engine); if (TF2) { // FIXME static pointer g_pScreenSpaceEffects = *(IScreenSpaceEffectManager**)sharedobj::client->Pointer(0x01F73E74); diff --git a/src/interfaces.h b/src/interfaces.h index 5e270b7c..bd96ae45 100644 --- a/src/interfaces.h +++ b/src/interfaces.h @@ -43,6 +43,9 @@ class ISteamUserStats; class IStudioRender; class IVDebugOverlay; class IVModelRender; +class IVModelRender; +class IVRenderView; +class IMaterialSystem; extern IVModelRender* g_IVModelRender; extern ISteamClient* g_ISteamClient; @@ -68,6 +71,9 @@ extern IAchievementMgr* g_IAchievementMgr; extern ISteamUserStats* g_ISteamUserStats; extern IStudioRender* g_IStudioRender; extern IVDebugOverlay* g_IVDebugOverlay; +extern IMaterialSystem* g_IMaterialSystem; +extern IVModelRender* g_IVModelRender; +extern IVRenderView* g_IVRenderView; template T* BruteforceInterface(std::string name, sharedobj::SharedObject* object, int start = 0); diff --git a/src/sharedobj.cpp b/src/sharedobj.cpp index ea493b03..2a5d11fe 100644 --- a/src/sharedobj.cpp +++ b/src/sharedobj.cpp @@ -77,6 +77,7 @@ sharedobj::SharedObject* sharedobj::vstdlib = 0; sharedobj::SharedObject* sharedobj::tier0 = 0; sharedobj::SharedObject* sharedobj::inputsystem = 0; sharedobj::SharedObject* sharedobj::studiorender = 0; +sharedobj::SharedObject* sharedobj::materialsystem = 0; sharedobj::SharedObject::SharedObject(const std::string& name, bool factory) { while (!(this->path = path_from_proc_maps(name))) { @@ -132,5 +133,6 @@ void sharedobj::LoadAllSharedObjects() { sharedobj::vstdlib = new SharedObject("libvstdlib.so", true); sharedobj::inputsystem = new SharedObject("inputsystem.so", true); sharedobj::studiorender = new SharedObject("studiorender.so", true); + sharedobj::materialsystem = new SharedObject("materialsystem.so", true); } diff --git a/src/sharedobj.h b/src/sharedobj.h index 32e4eaa1..1681f96d 100644 --- a/src/sharedobj.h +++ b/src/sharedobj.h @@ -39,6 +39,7 @@ extern SharedObject* vstdlib; extern SharedObject* tier0; extern SharedObject* inputsystem; extern SharedObject* studiorender; +extern SharedObject* materialsystem; void LoadAllSharedObjects(); From 6397d9a8394446880e1465902868a2591df323fd Mon Sep 17 00:00:00 2001 From: nullifiedcat Date: Thu, 13 Apr 2017 16:53:03 +0300 Subject: [PATCH 4/8] reee nothing works --- src/EffectGlow.cpp | 55 ++++++- src/hack.cpp | 8 +- src/interfaces.cpp | 4 +- src/interfaces.h | 1 - src/sdk.h | 2 + src/sdk/MaterialSystemUtil.cpp | 255 +++++++++++++++++++++++++++++++++ 6 files changed, 316 insertions(+), 9 deletions(-) create mode 100644 src/sdk/MaterialSystemUtil.cpp diff --git a/src/EffectGlow.cpp b/src/EffectGlow.cpp index 67bf1c8f..0195cf3e 100644 --- a/src/EffectGlow.cpp +++ b/src/EffectGlow.cpp @@ -8,6 +8,8 @@ #include "common.h" #include "EffectGlow.hpp" +IMaterialSystem* materials = nullptr; + // FIXME move to sdk CScreenSpaceEffectRegistration *CScreenSpaceEffectRegistration::s_pHead = NULL; IScreenSpaceEffectManager* g_pScreenSpaceEffects = nullptr; @@ -22,8 +24,59 @@ CScreenSpaceEffectRegistration::CScreenSpaceEffectRegistration( const char *pNam logging::Info("New head: 0x%08x", *g_ppScreenSpaceRegistrationHead); } -void EffectGlow::Render(int x, int y, int w, int h) { +static CTextureReference tr_cathook_rt; +/*IMaterial* GetRenderTarget() { + if (!tr_cathook_rt) { + tr_cathook_rt.InitRenderTarget(256, 256, RT_SIZE_FULL_FRAME_BUFFER, IMAGE_FORMAT_ARGB8888, MATERIAL_RT_DEPTH_NONE, false, "cathook_rt"); + } + return tr_cathook_rt.; +}*/ + +IMaterial* GetGlowMaterial() { + return vfunc(g_IMaterialSystem, 73)(g_IMaterialSystem, "dev/glow_color", TEXTURE_GROUP_OTHER, true, 0); + /*static IMaterial* material = nullptr; + if (!material) { + KeyValues* kv = new KeyValues("UnlitGeneric"); + kv->SetString("$basetexture", "_rt_FullFrameFB"); + kv->SetInt("$ignorez", 1); + material = g_IMaterialSystem->CreateMaterial("cathook/glow", kv); + } + return material;*/ +} + +void EffectGlow::Render(int x, int y, int w, int h) { + if (!materials) materials = g_IMaterialSystem; + CMatRenderContextPtr ptr(vfunc(g_IMaterialSystem, 100, 0)(g_IMaterialSystem)); + //ITexture* rt_original = ptr->GetRenderTarget(); + ITexture *pRtFullFrame = NULL; + pRtFullFrame = vfunc(g_IMaterialSystem, 81)(g_IMaterialSystem, "_rt_FullFrameFB", TEXTURE_GROUP_RENDER_TARGET, 1, 0);//materials->FindTexture( "_rt_FullFrameFB", TEXTURE_GROUP_RENDER_TARGET ); + logging::Info("%s", pRtFullFrame->GetName()); + ptr->SetRenderTarget(pRtFullFrame); + ptr->Viewport(0, 0, 1920, 1080); + ptr->PushRenderTargetAndViewport(); + Vector orig_modulation; + g_IVRenderView->GetColorModulation(orig_modulation.Base()); + Vector red(1.0f, 0.1f, 0.1f); + g_IVRenderView->SetColorModulation(red.Base()); + g_IStudioRender->ForcedMaterialOverride(GetGlowMaterial()); + g_IVRenderView->SetBlend(1.0f); + for (int i = 1; i < 8; i++) { + IClientEntity* ent = g_IEntityList->GetClientEntity(i); + if (!ent->IsDormant() && NET_BYTE(ent, netvar.iLifeState) == LIFE_ALIVE) { + logging::Info("Drawing %d", i); + ent->DrawModel(1); + } + } + logging::Info("Setting modulation"); + g_IVRenderView->SetColorModulation(orig_modulation.Base()); + logging::Info("z"); + logging::Info("%i", g_IStudioRender->GetNumAmbientLightSamples()); + g_IStudioRender->ForcedMaterialOverride(0); + logging::Info("x"); + ptr->PopRenderTargetAndViewport(); + logging::Info("Done...?"); + //ptr->SetRenderTarget(rt_original); } EffectGlow g_EffectGlow; diff --git a/src/hack.cpp b/src/hack.cpp index 9b1b2a07..9756c094 100644 --- a/src/hack.cpp +++ b/src/hack.cpp @@ -171,10 +171,10 @@ void hack::Initialize() { hooks::hkInput->Init((void*)g_IInput, 0); hooks::hkInput->HookMethod((void*)GetUserCmd_hook, hooks::offGetUserCmd); hooks::hkInput->Apply(); - hooks::hkIVModelRender = new hooks::VMTHook(); - hooks::hkIVModelRender->Init(g_IVModelRender, 0); - hooks::hkIVModelRender->HookMethod((void*)DrawModelExecute_hook, hooks::offDrawModelExecute); - hooks::hkIVModelRender->Apply(); + //hooks::hkIVModelRender = new hooks::VMTHook(); + //hooks::hkIVModelRender->Init(g_IVModelRender, 0); + //hooks::hkIVModelRender->HookMethod((void*)DrawModelExecute_hook, hooks::offDrawModelExecute); + //hooks::hkIVModelRender->Apply(); if (TF2) g_GlowObjectManager = *reinterpret_cast(gSignatures.GetClientSignature("C1 E0 05 03 05") + 5); InitStrings(); hacks::shared::killsay::Init(); diff --git a/src/interfaces.cpp b/src/interfaces.cpp index 7cf8dcb0..49fbc821 100644 --- a/src/interfaces.cpp +++ b/src/interfaces.cpp @@ -45,7 +45,6 @@ IAchievementMgr* g_IAchievementMgr = nullptr; ISteamUserStats* g_ISteamUserStats = nullptr; IStudioRender* g_IStudioRender = nullptr; IVDebugOverlay* g_IVDebugOverlay = nullptr; -IVModelRender* g_IVModelRender = nullptr; IMaterialSystem* g_IMaterialSystem = nullptr; IVRenderView* g_IVRenderView = nullptr; @@ -94,9 +93,8 @@ void CreateInterfaces() { g_IGameMovement = BruteforceInterface("GameMovement", sharedobj::client); g_IVRenderView = BruteforceInterface("VEngineRenderView", sharedobj::engine); g_IMaterialSystem = BruteforceInterface("VMaterialSystem", sharedobj::materialsystem, 81); - g_IVModelRender = BruteforceInterface("VEngineModel", sharedobj::engine); if (TF2) { - // FIXME static pointer + // FIXME static offset FIXME FIXME FIXME FIXME IMPORTANT! g_pScreenSpaceEffects = *(IScreenSpaceEffectManager**)sharedobj::client->Pointer(0x01F73E74); g_ppScreenSpaceRegistrationHead = (CScreenSpaceEffectRegistration**)sharedobj::client->Pointer(0x02018E30); } diff --git a/src/interfaces.h b/src/interfaces.h index bd96ae45..03451722 100644 --- a/src/interfaces.h +++ b/src/interfaces.h @@ -47,7 +47,6 @@ class IVModelRender; class IVRenderView; class IMaterialSystem; -extern IVModelRender* g_IVModelRender; extern ISteamClient* g_ISteamClient; extern ISteamFriends* g_ISteamFriends; extern IVEngineClient013* g_IEngine; diff --git a/src/sdk.h b/src/sdk.h index 40e2f1bf..6e0f2215 100644 --- a/src/sdk.h +++ b/src/sdk.h @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -30,6 +31,7 @@ #include #include #include +#include #include #include #include diff --git a/src/sdk/MaterialSystemUtil.cpp b/src/sdk/MaterialSystemUtil.cpp new file mode 100644 index 00000000..ba63f007 --- /dev/null +++ b/src/sdk/MaterialSystemUtil.cpp @@ -0,0 +1,255 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $Workfile: $ +// $NoKeywords: $ +//===========================================================================// + +#include "materialsystem/MaterialSystemUtil.h" +#include "materialsystem/imaterial.h" +#include "materialsystem/itexture.h" +#include "materialsystem/imaterialsystem.h" +#include "tier1/KeyValues.h" + +// memdbgon must be the last include file in a .cpp file!!! +#include "tier0/memdbgon.h" + +//----------------------------------------------------------------------------- +// Little utility class to deal with material references +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// constructor, destructor +//----------------------------------------------------------------------------- +CMaterialReference::CMaterialReference( char const* pMaterialName, const char *pTextureGroupName, bool bComplain ) : m_pMaterial( 0 ) +{ + if ( pMaterialName ) + { + Assert( pTextureGroupName ); + Init( pMaterialName, pTextureGroupName, bComplain ); + } +} + +CMaterialReference::~CMaterialReference() +{ + Shutdown(); +} + +//----------------------------------------------------------------------------- +// Attach to a material +//----------------------------------------------------------------------------- +void CMaterialReference::Init( char const* pMaterialName, const char *pTextureGroupName, bool bComplain ) +{ + IMaterial *pMaterial = materials->FindMaterial( pMaterialName, pTextureGroupName, bComplain); + if( IsErrorMaterial( pMaterial ) ) + { + if (IsOSX()) + { + printf("\n ##### CMaterialReference::Init got error material for %s in tex group %s", pMaterialName, pTextureGroupName ); + } + } + + Assert( pMaterial ); + Init( pMaterial ); +} + +void CMaterialReference::Init( const char *pMaterialName, KeyValues *pVMTKeyValues ) +{ + // CreateMaterial has a refcount of 1 + Shutdown(); + m_pMaterial = materials->CreateMaterial( pMaterialName, pVMTKeyValues ); +} + +void CMaterialReference::Init( const char *pMaterialName, const char *pTextureGroupName, KeyValues *pVMTKeyValues ) +{ + IMaterial *pMaterial = materials->FindProceduralMaterial( pMaterialName, pTextureGroupName, pVMTKeyValues ); + Assert( pMaterial ); + Init( pMaterial ); +} + +void CMaterialReference::Init( IMaterial* pMaterial ) +{ + if ( m_pMaterial != pMaterial ) + { + Shutdown(); + m_pMaterial = pMaterial; + if ( m_pMaterial ) + { + m_pMaterial->IncrementReferenceCount(); + } + } +} + +void CMaterialReference::Init( CMaterialReference& ref ) +{ + if ( m_pMaterial != ref.m_pMaterial ) + { + Shutdown(); + m_pMaterial = ref.m_pMaterial; + if (m_pMaterial) + { + m_pMaterial->IncrementReferenceCount(); + } + } +} + +//----------------------------------------------------------------------------- +// Detach from a material +//----------------------------------------------------------------------------- +void CMaterialReference::Shutdown( ) +{ + if ( m_pMaterial && materials ) + { + m_pMaterial->DecrementReferenceCount(); + m_pMaterial = NULL; + } +} + + +//----------------------------------------------------------------------------- +// Little utility class to deal with texture references +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// constructor, destructor +//----------------------------------------------------------------------------- +CTextureReference::CTextureReference( ) : m_pTexture(NULL) +{ +} + +CTextureReference::CTextureReference( const CTextureReference &ref ) +{ + m_pTexture = ref.m_pTexture; + if ( m_pTexture ) + { + m_pTexture->IncrementReferenceCount(); + } +} + +void CTextureReference::operator=( CTextureReference &ref ) +{ + m_pTexture = ref.m_pTexture; + if ( m_pTexture ) + { + m_pTexture->IncrementReferenceCount(); + } +} + +CTextureReference::~CTextureReference( ) +{ + Shutdown(); +} + +//----------------------------------------------------------------------------- +// Attach to a texture +//----------------------------------------------------------------------------- +void CTextureReference::Init( char const* pTextureName, const char *pTextureGroupName, bool bComplain ) +{ + Shutdown(); + m_pTexture = materials->FindTexture( pTextureName, pTextureGroupName, bComplain ); + if ( m_pTexture ) + { + m_pTexture->IncrementReferenceCount(); + } +} + +void CTextureReference::Init( ITexture* pTexture ) +{ + Shutdown(); + + m_pTexture = pTexture; + if (m_pTexture) + { + m_pTexture->IncrementReferenceCount(); + } +} + +void CTextureReference::InitProceduralTexture( const char *pTextureName, const char *pTextureGroupName, int w, int h, ImageFormat fmt, int nFlags ) +{ + Shutdown(); + + m_pTexture = materials->CreateProceduralTexture( pTextureName, pTextureGroupName, w, h, fmt, nFlags ); + + // NOTE: The texture reference is already incremented internally above! + /* + if ( m_pTexture ) + { + m_pTexture->IncrementReferenceCount(); + } + */ +} + +void CTextureReference::InitRenderTarget( int w, int h, RenderTargetSizeMode_t sizeMode, ImageFormat fmt, MaterialRenderTargetDepth_t depth, bool bHDR, char *pStrOptionalName /* = NULL */ ) +{ + Shutdown(); + + int textureFlags = TEXTUREFLAGS_CLAMPS | TEXTUREFLAGS_CLAMPT; + if ( depth == MATERIAL_RT_DEPTH_ONLY ) + textureFlags |= TEXTUREFLAGS_POINTSAMPLE; + + int renderTargetFlags = bHDR ? CREATERENDERTARGETFLAGS_HDR : 0; + + // NOTE: Refcount returned by CreateRenderTargetTexture is 1 + m_pTexture = materials->CreateNamedRenderTargetTextureEx( pStrOptionalName, w, h, sizeMode, fmt, + depth, textureFlags, renderTargetFlags ); + + Assert( m_pTexture ); +} + +//----------------------------------------------------------------------------- +// Detach from a texture +//----------------------------------------------------------------------------- +void CTextureReference::Shutdown( bool bDeleteIfUnReferenced ) +{ + if ( m_pTexture && materials ) + { + m_pTexture->DecrementReferenceCount(); + if ( bDeleteIfUnReferenced ) + { + m_pTexture->DeleteIfUnreferenced(); + } + m_pTexture = NULL; + } +} + +//----------------------------------------------------------------------------- +// Builds ONLY the system ram render target. Used when caller is explicitly managing. +// The paired EDRAM surface can be built in an alternate format. +//----------------------------------------------------------------------------- +#if defined( _X360 ) +void CTextureReference::InitRenderTargetTexture( int w, int h, RenderTargetSizeMode_t sizeMode, ImageFormat fmt, MaterialRenderTargetDepth_t depth, bool bHDR, char *pStrOptionalName ) +{ + // other variants not implemented yet + Assert( depth == MATERIAL_RT_DEPTH_NONE || depth == MATERIAL_RT_DEPTH_SHARED ); + Assert( !bHDR ); + + int renderTargetFlags = CREATERENDERTARGETFLAGS_NOEDRAM; + + m_pTexture = materials->CreateNamedRenderTargetTextureEx( + pStrOptionalName, + w, + h, + sizeMode, + fmt, + depth, + TEXTUREFLAGS_CLAMPS | TEXTUREFLAGS_CLAMPT, + renderTargetFlags ); + Assert( m_pTexture ); +} +#endif + +//----------------------------------------------------------------------------- +// Builds ONLY the EDRAM render target surface. Used when caller is explicitly managing. +// The paired system memory texture can be built in an alternate format. +//----------------------------------------------------------------------------- +#if defined( _X360 ) +void CTextureReference::InitRenderTargetSurface( int width, int height, ImageFormat fmt, bool bSameAsTexture ) +{ + // texture has to be created first + Assert( m_pTexture && m_pTexture->IsRenderTarget() ); + + m_pTexture->CreateRenderTargetSurface( width, height, fmt, bSameAsTexture ); +} +#endif + From 84341c6291bc5c08f93ab8609d8b3ddd79fd718c Mon Sep 17 00:00:00 2001 From: nullifiedcat Date: Sat, 15 Apr 2017 18:10:15 +0300 Subject: [PATCH 5/8] shit wont work --- src/EffectGlow.cpp | 170 ++++++++++++++++++++++++++------- src/EffectGlow.hpp | 15 ++- src/hack.cpp | 1 + src/interfaces.cpp | 4 +- src/sdk.h | 1 + src/sdk/MaterialSystemUtil.cpp | 6 +- 6 files changed, 157 insertions(+), 40 deletions(-) diff --git a/src/EffectGlow.cpp b/src/EffectGlow.cpp index 0195cf3e..aa581b07 100644 --- a/src/EffectGlow.cpp +++ b/src/EffectGlow.cpp @@ -24,8 +24,6 @@ CScreenSpaceEffectRegistration::CScreenSpaceEffectRegistration( const char *pNam logging::Info("New head: 0x%08x", *g_ppScreenSpaceRegistrationHead); } -static CTextureReference tr_cathook_rt; - /*IMaterial* GetRenderTarget() { if (!tr_cathook_rt) { tr_cathook_rt.InitRenderTarget(256, 256, RT_SIZE_FULL_FRAME_BUFFER, IMAGE_FORMAT_ARGB8888, MATERIAL_RT_DEPTH_NONE, false, "cathook_rt"); @@ -35,48 +33,148 @@ static CTextureReference tr_cathook_rt; IMaterial* GetGlowMaterial() { return vfunc(g_IMaterialSystem, 73)(g_IMaterialSystem, "dev/glow_color", TEXTURE_GROUP_OTHER, true, 0); - /*static IMaterial* material = nullptr; - if (!material) { - KeyValues* kv = new KeyValues("UnlitGeneric"); - kv->SetString("$basetexture", "_rt_FullFrameFB"); - kv->SetInt("$ignorez", 1); - material = g_IMaterialSystem->CreateMaterial("cathook/glow", kv); - } - return material;*/ +} + +static CatVar glow_experimental(CV_SWITCH, "glow_experimental", "0", "Experimental Glow"); + +void EffectGlow::Init() { + logging::Info("Init EffectGlow..."); + if (!materials) materials = g_IMaterialSystem; + logging::Info("materials: 0x%08x", materials); + rt_A.InitRenderTarget(1920/2, 1080/2, RT_SIZE_DEFAULT, IMAGE_FORMAT_RGBA8888, MATERIAL_RT_DEPTH_SEPARATE, false, "__cathook_glow_rta"); + rt_B.InitRenderTarget(1920/2, 1080/2, RT_SIZE_DEFAULT, IMAGE_FORMAT_RGBA8888, MATERIAL_RT_DEPTH_SEPARATE, false, "__cathook_glow_rtb"); + logging::Info("Textures init!"); + //rt_B.InitRenderTarget(256, 256, RT_SIZE_FULL_FRAME_BUFFER, IMAGE_FORMAT_ARGB8888, MATERIAL_RT_DEPTH_NONE, false, "__cathook_glow_rtB"); + KeyValues *kv2 = new KeyValues( "VertexLitGeneric" ); + kv2->SetString( "$basetexture", "vgui/white" ); + kv2->SetInt( "$selfillum", 1 ); + kv2->SetString( "$selfillummask", "vgui/white" ); + kv2->SetInt( "$vertexalpha", 1 ); + kv2->SetInt( "$model", 1 ); + glow_material.Init( "__cathook_glow_mat_color", TEXTURE_GROUP_CLIENT_EFFECTS, kv2 ); + glow_material->Refresh(); + KeyValues* kv = new KeyValues("UnlitGeneric"); + kv->SetString("$basetexture", "_rt_FullFrameFB"); + kv->SetInt("$additive", 1); + result_material.Init("__cathook_glow_mat", TEXTURE_GROUP_CLIENT_EFFECTS, kv); + result_material->Refresh(); + logging::Info("Material init!"); + //dev_glow_color.Init(vfunc(g_IMaterialSystem, 73)(g_IMaterialSystem, "dev/glow_color", TEXTURE_GROUP_OTHER, true, 0)); + dev_bloomdadd.Init(vfunc(g_IMaterialSystem, 73)(g_IMaterialSystem, "dev/bloomadd", TEXTURE_GROUP_OTHER, true, 0)); + dev_blurfilterx.Init(vfunc(g_IMaterialSystem, 73)(g_IMaterialSystem, "dev/blurfilterx", TEXTURE_GROUP_OTHER, true, 0)); + dev_blurfiltery.Init(vfunc(g_IMaterialSystem, 73)(g_IMaterialSystem, "dev/blurfiltery", TEXTURE_GROUP_OTHER, true, 0)); + dev_halo_add_to_screen.Init(vfunc(g_IMaterialSystem, 73)(g_IMaterialSystem, "dev/halo_add_to_screen", TEXTURE_GROUP_OTHER, true, 0)); + + logging::Info("Init done!"); + init = true; +} + +void EffectGlow::BeginRenderGlow() { + CMatRenderContextPtr ptr(vfunc(g_IMaterialSystem, 100, 0)(g_IMaterialSystem)); + ptr->PushRenderTargetAndViewport(rt_A); + g_IVModelRender->SuppressEngineLighting(true); + g_IVRenderView->GetColorModulation(orig_modulation); + static Vector red(1.0f, 0.1f, 0.1f); + g_IVRenderView->SetColorModulation(red.Base()); + g_IStudioRender->ForcedMaterialOverride(glow_material); + g_IVRenderView->SetBlend(1.0f); +} + +void EffectGlow::EndRenderGlow() { + CMatRenderContextPtr ptr(vfunc(g_IMaterialSystem, 100, 0)(g_IMaterialSystem)); + g_IVRenderView->SetColorModulation(orig_modulation); + g_IStudioRender->ForcedMaterialOverride(nullptr); + g_IVModelRender->SuppressEngineLighting(false); + ptr->PopRenderTargetAndViewport(); +} + +void EffectGlow::RenderGlow(int idx) { + CMatRenderContextPtr ptr(vfunc(g_IMaterialSystem, 100, 0)(g_IMaterialSystem)); + ptr->PushRenderTargetAndViewport( rt_A ); + + g_IVModelRender->SuppressEngineLighting( true ); + + // Set the glow tint since selfillum trumps color modulation + IMaterialVar *var = glow_material->FindVar( "$selfillumtint", NULL, false ); + static float color[4] = { 1.0f, 0.0f, 0.0f, 1.0f }; + var->SetVecValue( color, 4 ); // Fixed compilation error + var = glow_material->FindVar( "$alpha", NULL, false ); + var->SetFloatValue( color[3] ); // Fixed compilation error + + g_IVModelRender->ForcedMaterialOverride( glow_material ); + IClientEntity* ent = g_IEntityList->GetClientEntity(idx); + if (ent) ent->DrawModel(1); + g_IVModelRender->ForcedMaterialOverride( NULL ); + + g_IVModelRender->SuppressEngineLighting( false ); + + ptr->PopRenderTargetAndViewport(); + + + /*IClientEntity* ent = g_IEntityList->GetClientEntity(idx); + if (ent) { + ent->DrawModel(1); + }*/ } void EffectGlow::Render(int x, int y, int w, int h) { - if (!materials) materials = g_IMaterialSystem; + if (!init) Init(); + if (!glow_experimental) return; CMatRenderContextPtr ptr(vfunc(g_IMaterialSystem, 100, 0)(g_IMaterialSystem)); - //ITexture* rt_original = ptr->GetRenderTarget(); - ITexture *pRtFullFrame = NULL; - pRtFullFrame = vfunc(g_IMaterialSystem, 81)(g_IMaterialSystem, "_rt_FullFrameFB", TEXTURE_GROUP_RENDER_TARGET, 1, 0);//materials->FindTexture( "_rt_FullFrameFB", TEXTURE_GROUP_RENDER_TARGET ); - logging::Info("%s", pRtFullFrame->GetName()); - ptr->SetRenderTarget(pRtFullFrame); - ptr->Viewport(0, 0, 1920, 1080); - ptr->PushRenderTargetAndViewport(); - Vector orig_modulation; - g_IVRenderView->GetColorModulation(orig_modulation.Base()); - Vector red(1.0f, 0.1f, 0.1f); - g_IVRenderView->SetColorModulation(red.Base()); - g_IStudioRender->ForcedMaterialOverride(GetGlowMaterial()); - g_IVRenderView->SetBlend(1.0f); - for (int i = 1; i < 8; i++) { + + //ptr->Viewport(x, y, w, h); + + ITexture* rt = ptr->GetRenderTarget(); + + IMaterialVar* var; + var = dev_blurfilterx->FindVar("$basetexture", nullptr); + var->SetTextureValue(rt_A); + var = dev_blurfiltery->FindVar("$basetexture", nullptr); + var->SetTextureValue(rt_B); + var = result_material->FindVar("$basetexture", nullptr); + var->SetTextureValue(rt_A); + //var = dev_blurfilterx->FindVar("$bloomamount", nullptr); + //var->SetFloatValue(10); + var = dev_blurfiltery->FindVar("$bloomamount", nullptr); + var->SetFloatValue(10); + + ptr->ClearColor4ub(0, 0, 0, 255); + ptr->PushRenderTargetAndViewport(rt_A); + ptr->ClearBuffers(true, true); + ptr->PopRenderTargetAndViewport(); + ptr->PushRenderTargetAndViewport(rt_B); + ptr->ClearBuffers(true, true); + ptr->PopRenderTargetAndViewport(); + + ptr->ClearStencilBufferRectangle( 0, 0, 1920, 1080, 0 ); + + BeginRenderGlow(); + for (int i = 1; i < 32; i++) { IClientEntity* ent = g_IEntityList->GetClientEntity(i); - if (!ent->IsDormant() && NET_BYTE(ent, netvar.iLifeState) == LIFE_ALIVE) { - logging::Info("Drawing %d", i); - ent->DrawModel(1); + if (ent && !ent->IsDormant() && NET_BYTE(ent, netvar.iLifeState) == LIFE_ALIVE) { + //BeginRenderGlow(); + RenderGlow(i); + //EndRenderGlow(); } } - logging::Info("Setting modulation"); - g_IVRenderView->SetColorModulation(orig_modulation.Base()); - logging::Info("z"); - logging::Info("%i", g_IStudioRender->GetNumAmbientLightSamples()); - g_IStudioRender->ForcedMaterialOverride(0); - logging::Info("x"); + + ptr->PushRenderTargetAndViewport( rt_B ); + ptr->Viewport(x, y, w, h); + ptr->DrawScreenSpaceQuad( dev_blurfilterx ); ptr->PopRenderTargetAndViewport(); - logging::Info("Done...?"); - //ptr->SetRenderTarget(rt_original); + + ptr->PushRenderTargetAndViewport( rt_A ); + ptr->Viewport(x, y, w, h); + ptr->DrawScreenSpaceQuad( dev_blurfiltery ); + ptr->PopRenderTargetAndViewport(); + + ptr->SetRenderTarget(rt); + ptr->Viewport(x, y, w, h); + + ptr->DrawScreenSpaceQuad(result_material); + var = result_material->FindVar("$basetexture", nullptr); + //var->SetTextureValue(rt_B); + //ptr->DrawScreenSpaceQuad(result_material); } EffectGlow g_EffectGlow; diff --git a/src/EffectGlow.hpp b/src/EffectGlow.hpp index 5e7c7693..f76b3da7 100644 --- a/src/EffectGlow.hpp +++ b/src/EffectGlow.hpp @@ -12,7 +12,7 @@ class EffectGlow : public IScreenSpaceEffect { public: - inline virtual void Init( ) {}; + virtual void Init( ); inline virtual void Shutdown( ) {}; inline virtual void SetParameters( KeyValues *params ) {}; @@ -22,8 +22,21 @@ public: inline virtual void Enable( bool bEnable ) { enabled = bEnable; }; inline virtual bool IsEnabled( ) { return enabled; }; + void RenderGlow(int idx); + void BeginRenderGlow(); + void EndRenderGlow(); public: + bool init { false }; bool enabled; + float orig_modulation[3]; + CTextureReference rt_A; + CTextureReference rt_B; + CMaterialReference result_material; + CMaterialReference glow_material; + CMaterialReference dev_bloomdadd; + CMaterialReference dev_halo_add_to_screen; + CMaterialReference dev_blurfilterx; + CMaterialReference dev_blurfiltery; }; extern EffectGlow g_EffectGlow; diff --git a/src/hack.cpp b/src/hack.cpp index 9756c094..88ba85e2 100644 --- a/src/hack.cpp +++ b/src/hack.cpp @@ -188,6 +188,7 @@ void hack::Initialize() { logging::Info("%s", reg->m_pEffectName); } g_pScreenSpaceEffects->EnableScreenSpaceEffect("_cathook_glow"); + //g_EffectGlow.Init(); logging::Info("SSE enabled.."); } diff --git a/src/interfaces.cpp b/src/interfaces.cpp index 49fbc821..afa9cdbd 100644 --- a/src/interfaces.cpp +++ b/src/interfaces.cpp @@ -95,8 +95,8 @@ void CreateInterfaces() { g_IMaterialSystem = BruteforceInterface("VMaterialSystem", sharedobj::materialsystem, 81); if (TF2) { // FIXME static offset FIXME FIXME FIXME FIXME IMPORTANT! - g_pScreenSpaceEffects = *(IScreenSpaceEffectManager**)sharedobj::client->Pointer(0x01F73E74); - g_ppScreenSpaceRegistrationHead = (CScreenSpaceEffectRegistration**)sharedobj::client->Pointer(0x02018E30); + g_pScreenSpaceEffects = **(IScreenSpaceEffectManager***)(gSignatures.GetClientSignature("F3 0F 10 83 40 05 00 00 C7 44 24 04 ? ? ? ? 89 34 24 F3 0F 11 44 24 08 E8 ? ? ? ? A1 ? ? ? ? 8B 10 89 04 24 89 74 24 08 C7 44 24 04 ? ? ? ? FF 52 0C A1 ? ? ? ? 8B 10 C7 44 24 04 ? ? ? ? 89 04 24 FF 52 14") + 31); + g_ppScreenSpaceRegistrationHead = *(CScreenSpaceEffectRegistration***)(gSignatures.GetClientSignature("55 89 E5 53 83 EC 14 8B 1D ? ? ? ? 85 DB 74 25 8D B4 26 00 00 00 00 8B 43 04 85 C0 74 10") + 9); } if (TF2) g_IInput = **(reinterpret_cast((uintptr_t)1 + gSignatures.GetClientSignature("A1 ? ? ? ? C6 05 ? ? ? ? 01 8B 10 89 04 24 FF 92 B4 00 00 00 A1 ? ? ? ? 8B 10"))); else if (TF2C) g_IInput = **(reinterpret_cast((uintptr_t)1 + gSignatures.GetClientSignature("A1 ? ? ? ? C6 05 ? ? ? ? 01 8B 10 89 04 24 FF 92 A8 00 00 00 A1 ? ? ? ? 8B 10"))); diff --git a/src/sdk.h b/src/sdk.h index 6e0f2215..818d257e 100644 --- a/src/sdk.h +++ b/src/sdk.h @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include diff --git a/src/sdk/MaterialSystemUtil.cpp b/src/sdk/MaterialSystemUtil.cpp index ba63f007..dff8b1e5 100644 --- a/src/sdk/MaterialSystemUtil.cpp +++ b/src/sdk/MaterialSystemUtil.cpp @@ -12,6 +12,8 @@ #include "materialsystem/imaterialsystem.h" #include "tier1/KeyValues.h" +#include "../vfunc.h" + // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" @@ -191,7 +193,9 @@ void CTextureReference::InitRenderTarget( int w, int h, RenderTargetSizeMode_t s int renderTargetFlags = bHDR ? CREATERENDERTARGETFLAGS_HDR : 0; // NOTE: Refcount returned by CreateRenderTargetTexture is 1 - m_pTexture = materials->CreateNamedRenderTargetTextureEx( pStrOptionalName, w, h, sizeMode, fmt, + //m_pTexture = vfunc(materials, 87, 0)(materials, pStrOptionalName, w, h, sizeMode, fmt, + // depth, textureFlags, renderTargetFlags); + m_pTexture = materials->CreateNamedRenderTargetTextureEx( pStrOptionalName, w, h, sizeMode, fmt, depth, textureFlags, renderTargetFlags ); Assert( m_pTexture ); From afb0e977bdb457abbb318de0760443e0fb8a47e5 Mon Sep 17 00:00:00 2001 From: nullifiedcat Date: Sat, 15 Apr 2017 22:56:48 +0300 Subject: [PATCH 6/8] working no hats, no arms, chams --- src/common.h | 1 + src/hack.cpp | 18 ++++---- src/hacks/Chams.cpp | 103 +++++++++++++++++++++++++++++++++++++++++++ src/hacks/Chams.hpp | 17 +++++++ src/hacks/hacklist.h | 1 + src/hooks/others.cpp | 37 +++++++++++++++- 6 files changed, 167 insertions(+), 10 deletions(-) create mode 100644 src/hacks/Chams.cpp create mode 100644 src/hacks/Chams.hpp diff --git a/src/common.h b/src/common.h index d44764e0..6e9a9e6b 100644 --- a/src/common.h +++ b/src/common.h @@ -51,6 +51,7 @@ #include "textfile.h" #include "ipc.h" #include "gui/GUI.h" +#include "hooks/hookedmethods.h" #include "classid.h" #include "crits.h" diff --git a/src/hack.cpp b/src/hack.cpp index 88ba85e2..a42f1e6e 100644 --- a/src/hack.cpp +++ b/src/hack.cpp @@ -171,10 +171,10 @@ void hack::Initialize() { hooks::hkInput->Init((void*)g_IInput, 0); hooks::hkInput->HookMethod((void*)GetUserCmd_hook, hooks::offGetUserCmd); hooks::hkInput->Apply(); - //hooks::hkIVModelRender = new hooks::VMTHook(); - //hooks::hkIVModelRender->Init(g_IVModelRender, 0); - //hooks::hkIVModelRender->HookMethod((void*)DrawModelExecute_hook, hooks::offDrawModelExecute); - //hooks::hkIVModelRender->Apply(); + hooks::hkIVModelRender = new hooks::VMTHook(); + hooks::hkIVModelRender->Init(g_IVModelRender, 0); + hooks::hkIVModelRender->HookMethod((void*)DrawModelExecute_hook, hooks::offDrawModelExecute); + hooks::hkIVModelRender->Apply(); if (TF2) g_GlowObjectManager = *reinterpret_cast(gSignatures.GetClientSignature("C1 E0 05 03 05") + 5); InitStrings(); hacks::shared::killsay::Init(); @@ -183,11 +183,11 @@ void hack::Initialize() { hack::command_stack().push("cat_spam_reload"); logging::Info("Hooked!"); playerlist::Load(); - g_pEffectGlow = new CScreenSpaceEffectRegistration("_cathook_glow", &g_EffectGlow); - for (CScreenSpaceEffectRegistration* reg = *g_ppScreenSpaceRegistrationHead; reg; reg = reg->m_pNext) { - logging::Info("%s", reg->m_pEffectName); - } - g_pScreenSpaceEffects->EnableScreenSpaceEffect("_cathook_glow"); + //g_pEffectGlow = new CScreenSpaceEffectRegistration("_cathook_glow", &g_EffectGlow); + //for (CScreenSpaceEffectRegistration* reg = *g_ppScreenSpaceRegistrationHead; reg; reg = reg->m_pNext) { + // logging::Info("%s", reg->m_pEffectName); + //} + //g_pScreenSpaceEffects->EnableScreenSpaceEffect("_cathook_glow"); //g_EffectGlow.Init(); logging::Info("SSE enabled.."); } diff --git a/src/hacks/Chams.cpp b/src/hacks/Chams.cpp new file mode 100644 index 00000000..2be8ddcd --- /dev/null +++ b/src/hacks/Chams.cpp @@ -0,0 +1,103 @@ +/* + * Chams.cpp + * + * Created on: Apr 15, 2017 + * Author: nullifiedcat + */ + +#include "../common.h" + +namespace hacks { namespace shared { namespace chams { + +static CatVar enable(CV_SWITCH, "chams_enable", "0", "Enable"); + +static bool init = false; + +CMaterialReference mat_unlit; +CMaterialReference mat_unlit_z; +CMaterialReference mat_lit; +CMaterialReference mat_lit_z; + +void Init() { + if (!materials) materials = g_IMaterialSystem; + { + KeyValues* kv = new KeyValues("UnlitGeneric"); + kv->SetString("$basetexture", "vgui/white_additive"); + kv->SetInt("$ignorez", 0); + mat_unlit.Init("__cathook_chams_unlit", kv); + } + { + KeyValues* kv = new KeyValues("UnlitGeneric"); + kv->SetString("$basetexture", "vgui/white_additive"); + kv->SetInt("$ignorez", 1); + mat_unlit_z.Init("__cathook_chams_unlit_z", kv); + } + { + KeyValues* kv = new KeyValues("VertexLitGeneric"); + kv->SetString("$basetexture", "vgui/white_additive"); + kv->SetInt("$ignorez", 0); + kv->SetInt("$halflambert", 1); + mat_lit.Init("__cathook_chams_lit", kv); + } + { + KeyValues* kv = new KeyValues("VertexLitGeneric"); + kv->SetString("$basetexture", "vgui/white_additive"); + kv->SetInt("$ignorez", 1); + kv->SetInt("$halflambert", 1); + mat_lit_z.Init("__cathook_chams_lit_z", kv); + } + init = true; +} + +void DrawModelExecute(IVModelRender* _this, const DrawModelState_t& state, const ModelRenderInfo_t& info, matrix3x4_t* matrix) { + if (!enable) return; + if (!init) { + Init(); + } + //std::string name(g_IModelInfo->GetModelName(info.pModel)); + IClientUnknown* unknown = info.pRenderable->GetIClientUnknown(); + if (unknown) { + IClientEntity* entity = unknown->GetIClientEntity(); + //logging::Info("entity: 0x%08x", entity); + if (entity && !entity->IsDormant()) { + //logging::Info("lit player"); + // IsBaseCombatWeapon + if (vfunc(entity, 0xBE, 0)(entity)) { + IClientEntity* owner = vfunc(entity, 0x1C3, 0)(entity); + if (owner) { + int color = colors::EntityF(ENTITY(owner->entindex())); + unsigned char _b = (color >> 16) & 0xFF; + unsigned char _g = (color >> 8) & 0xFF; + unsigned char _r = (color) & 0xFF; + float color_1[] = { (float)_r / 255.0f, (float)_g / 255.0f, (float)_b / 255.0f }; + float color_2[] = { color_1[0] * 0.6f, color_1[1] * 0.6f, color_1[2] * 0.6f }; + mat_unlit_z->AlphaModulate(1.0f); + g_IVRenderView->SetColorModulation(color_1); + g_IVModelRender->ForcedMaterialOverride(mat_lit_z); + ((DrawModelExecute_t)(hooks::hkIVModelRender->GetMethod(hooks::offDrawModelExecute)))(_this, state, info, matrix); + mat_unlit->AlphaModulate(1.0f); + g_IVRenderView->SetColorModulation(color_2); + g_IVModelRender->ForcedMaterialOverride(mat_lit); + } + } else if (entity->GetClientClass()->m_ClassID == g_pClassID->C_Player) { + int color = colors::EntityF(ENTITY(entity->entindex())); + unsigned char _b = (color >> 16) & 0xFF; + unsigned char _g = (color >> 8) & 0xFF; + unsigned char _r = (color) & 0xFF; + float color_1[] = { (float)_r / 255.0f, (float)_g / 255.0f, (float)_b / 255.0f }; + float color_2[] = { color_1[0] * 0.6f, color_1[1] * 0.6f, color_1[2] * 0.6f }; + mat_unlit_z->AlphaModulate(1.0f); + g_IVRenderView->SetColorModulation(color_1); + g_IVModelRender->ForcedMaterialOverride(mat_lit_z); + ((DrawModelExecute_t)(hooks::hkIVModelRender->GetMethod(hooks::offDrawModelExecute)))(_this, state, info, matrix); + mat_unlit->AlphaModulate(1.0f); + g_IVRenderView->SetColorModulation(color_2); + g_IVModelRender->ForcedMaterialOverride(mat_lit); + } + + + } + } +} + +}}} diff --git a/src/hacks/Chams.hpp b/src/hacks/Chams.hpp new file mode 100644 index 00000000..93e8bfef --- /dev/null +++ b/src/hacks/Chams.hpp @@ -0,0 +1,17 @@ +/* + * Chams.hpp + * + * Created on: Apr 15, 2017 + * Author: nullifiedcat + */ + +#ifndef HACKS_CHAMS_HPP_ +#define HACKS_CHAMS_HPP_ + +namespace hacks { namespace shared { namespace chams { + +void DrawModelExecute(IVModelRender* _this, const DrawModelState_t& state, const ModelRenderInfo_t& info, matrix3x4_t* matrix); + +}}} + +#endif /* HACKS_CHAMS_HPP_ */ diff --git a/src/hacks/hacklist.h b/src/hacks/hacklist.h index 56ebafd8..b1540dd5 100644 --- a/src/hacks/hacklist.h +++ b/src/hacks/hacklist.h @@ -23,6 +23,7 @@ #include "Misc.h" #include "SpyAlert.h" #include "Trigger.h" +#include "Chams.hpp" #include "KillSay.h" #include "Achievement.h" #include "Spam.h" diff --git a/src/hooks/others.cpp b/src/hooks/others.cpp index 9cdd8518..85a7cc53 100644 --- a/src/hooks/others.cpp +++ b/src/hooks/others.cpp @@ -10,8 +10,24 @@ #include "../hack.h" #include "hookedmethods.h" +static CatVar no_invisibility(CV_SWITCH, "no_invis", "0", "Remove Invisibility", "Useful with chams!"); + +int C_TFPlayer__DrawModel_hook(IClientEntity* _this, int flags) { + float old_invis = *(float*)((uintptr_t)_this + 79u); + if (no_invisibility) { + if (old_invis < 1.0f) { + *(float*)((uintptr_t)_this + 79u) = 0.5f; + } + } + + *(float*)((uintptr_t)_this + 79u) = old_invis; +} + +static CatVar no_arms(CV_SWITCH, "no_arms", "0", "No Arms"); +static CatVar no_hats(CV_SWITCH, "no_hats", "0", "No Hats"); + void DrawModelExecute_hook(IVModelRender* _this, const DrawModelState_t& state, const ModelRenderInfo_t& info, matrix3x4_t* matrix) { - IClientUnknown* unknown = info.pRenderable->GetIClientUnknown(); + /*IClientUnknown* unknown = info.pRenderable->GetIClientUnknown(); if (unknown) { IClientEntity* entity = unknown->GetIClientEntity(); if (entity && entity->entindex() != -1) { @@ -19,8 +35,27 @@ void DrawModelExecute_hook(IVModelRender* _this, const DrawModelState_t& state, //CMatRenderContextPtr ptr(); } } + }*/ + if (no_arms || no_hats) { + if (info.pModel) { + const char* name = g_IModelInfo->GetModelName(info.pModel); + if (name) { + std::string sname(name); + if (no_arms && sname.find("arms") != std::string::npos) { + return; + } else if (no_hats && sname.find("player/items") != std::string::npos) { + return; + } + } + } } + + float mod_old[3] { 0.0f }; + g_IVRenderView->GetColorModulation(mod_old); + hacks::shared::chams::DrawModelExecute(_this, state, info, matrix); ((DrawModelExecute_t)(hooks::hkIVModelRender->GetMethod(hooks::offDrawModelExecute)))(_this, state, info, matrix); + g_IVModelRender->ForcedMaterialOverride(nullptr); + g_IVRenderView->SetColorModulation(mod_old); } bool CanPacket_hook(void* thisptr) { From 842784ce642725c19526e6e49b0a5af162502ab3 Mon Sep 17 00:00:00 2001 From: nullifiedcat Date: Sun, 16 Apr 2017 00:02:37 +0300 Subject: [PATCH 7/8] cham options and stuff --- src/entitycache.cpp | 3 +- src/hacks/Chams.cpp | 110 +++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 106 insertions(+), 7 deletions(-) diff --git a/src/entitycache.cpp b/src/entitycache.cpp index 3c36e8ef..4e0e47a6 100644 --- a/src/entitycache.cpp +++ b/src/entitycache.cpp @@ -210,7 +210,8 @@ EntityCache::~EntityCache() { void EntityCache::Update() { m_nMax = g_IEntityList->GetHighestEntityIndex(); - for (int i = 0; i < m_nMax && i < MAX_ENTITIES; i++) { + // idk that can break something i guess + for (int i = 0; i <= m_nMax && i < MAX_ENTITIES; i++) { m_pArray[i].Update(i); } } diff --git a/src/hacks/Chams.cpp b/src/hacks/Chams.cpp index 2be8ddcd..16ba8bea 100644 --- a/src/hacks/Chams.cpp +++ b/src/hacks/Chams.cpp @@ -10,6 +10,16 @@ namespace hacks { namespace shared { namespace chams { static CatVar enable(CV_SWITCH, "chams_enable", "0", "Enable"); +static CatVar flat(CV_SWITCH, "chams_flat", "0", "Flat"); +static CatVar health(CV_SWITCH, "chams_health", "0", "Health"); +static CatVar teammates(CV_SWITCH, "chams_teammates", "0", "Teammates"); +static CatVar players(CV_SWITCH, "chams_players", "1", "Players"); +static CatVar medkits(CV_SWITCH, "chams_medkits", "0", "Medkits"); +static CatVar ammobox(CV_SWITCH, "chams_ammo", "0", "Ammoboxes"); +static CatVar buildings(CV_SWITCH, "chams_buildings", "0", "Buildings"); +static CatVar stickies(CV_SWITCH, "chams_stickies", "0", "Stickies"); +static CatVar teammate_buildings(CV_SWITCH, "chams_teammate_buildings", "0", "Teammate Buildings"); +static CatVar weapons(CV_SWITCH, "chams_weapons", "1", "Weapons"); static bool init = false; @@ -49,6 +59,79 @@ void Init() { init = true; } +int GetChamColor(int idx) { + if (idx < 0 || idx > g_IEntityList->GetHighestEntityIndex()) return colors::white; + CachedEntity* ent = ENTITY(idx); + if (CE_BAD(ent)) return colors::white; + IClientEntity* entity = RAW_ENT(ent); + if (vfunc(entity, 0xBE, 0)(entity)) { + IClientEntity* owner = vfunc(entity, 0x1C3, 0)(entity); + if (owner) { + return GetChamColor(owner->entindex()); + } + } + switch (ent->m_Type) { + case ENTITY_BUILDING: + if (!ent->m_bEnemy && !(teammates || teammate_buildings)) { + return 0; + } + if (health) { + return colors::Health(ent->m_iHealth, ent->m_iMaxHealth); + } + break; + case ENTITY_PLAYER: + if (!ent->m_bEnemy && !teammates) return 0; + if (health) { + return colors::Health(ent->m_iHealth, ent->m_iMaxHealth); + } + break; + } + return colors::EntityF(ent); +} + +bool ShouldCham(int idx) { + if (idx < 0 || idx > HIGHEST_ENTITY) return false; + CachedEntity* ent = ENTITY(idx); + if (CE_BAD(ent)) return false; + IClientEntity* entity = RAW_ENT(ent); + if (weapons && vfunc(entity, 0xBE, 0)(entity)) { + IClientEntity* owner = vfunc(entity, 0x1C3, 0)(entity); + if (owner) { + return ShouldCham(owner->entindex()); + } + } + switch (ent->m_Type) { + case ENTITY_BUILDING: + if (!buildings) return false; + if (!ent->m_bEnemy && !(teammate_buildings || teammates)) return false; + return true; + case ENTITY_PLAYER: + if (!teammates && !ent->m_bEnemy) return false; + if (CE_BYTE(ent, netvar.iLifeState) != LIFE_ALIVE) return false; + return true; + break; + case ENTITY_PROJECTILE: + if (!ent->m_bEnemy) return false; + if (stickies && ent->m_iClassID == g_pClassID->CTFGrenadePipebombProjectile) { + return true; + } + break; + case ENTITY_GENERIC: + switch (ent->m_ItemType) { + case ITEM_HEALTH_LARGE: + case ITEM_HEALTH_MEDIUM: + case ITEM_HEALTH_SMALL: + return medkits; + case ITEM_AMMO_LARGE: + case ITEM_AMMO_MEDIUM: + case ITEM_AMMO_SMALL: + return ammobox; + } + break; + } + return false; +} + void DrawModelExecute(IVModelRender* _this, const DrawModelState_t& state, const ModelRenderInfo_t& info, matrix3x4_t* matrix) { if (!enable) return; if (!init) { @@ -60,9 +143,24 @@ void DrawModelExecute(IVModelRender* _this, const DrawModelState_t& state, const IClientEntity* entity = unknown->GetIClientEntity(); //logging::Info("entity: 0x%08x", entity); if (entity && !entity->IsDormant()) { + if (ShouldCham(entity->entindex())) { + int color = GetChamColor(entity->entindex()); + unsigned char _b = (color >> 16) & 0xFF; + unsigned char _g = (color >> 8) & 0xFF; + unsigned char _r = (color) & 0xFF; + float color_1[] = { (float)_r / 255.0f, (float)_g / 255.0f, (float)_b / 255.0f }; + float color_2[] = { color_1[0] * 0.6f, color_1[1] * 0.6f, color_1[2] * 0.6f }; + mat_unlit_z->AlphaModulate(1.0f); + g_IVRenderView->SetColorModulation(color_1); + g_IVModelRender->ForcedMaterialOverride(flat ? mat_unlit_z : mat_lit_z); + ((DrawModelExecute_t)(hooks::hkIVModelRender->GetMethod(hooks::offDrawModelExecute)))(_this, state, info, matrix); + mat_unlit->AlphaModulate(1.0f); + g_IVRenderView->SetColorModulation(color_2); + g_IVModelRender->ForcedMaterialOverride(flat ? mat_unlit : mat_lit); + } //logging::Info("lit player"); // IsBaseCombatWeapon - if (vfunc(entity, 0xBE, 0)(entity)) { + /*if (vfunc(entity, 0xBE, 0)(entity)) { IClientEntity* owner = vfunc(entity, 0x1C3, 0)(entity); if (owner) { int color = colors::EntityF(ENTITY(owner->entindex())); @@ -73,11 +171,11 @@ void DrawModelExecute(IVModelRender* _this, const DrawModelState_t& state, const float color_2[] = { color_1[0] * 0.6f, color_1[1] * 0.6f, color_1[2] * 0.6f }; mat_unlit_z->AlphaModulate(1.0f); g_IVRenderView->SetColorModulation(color_1); - g_IVModelRender->ForcedMaterialOverride(mat_lit_z); + g_IVModelRender->ForcedMaterialOverride(flat ? mat_unlit_z : mat_lit_z); ((DrawModelExecute_t)(hooks::hkIVModelRender->GetMethod(hooks::offDrawModelExecute)))(_this, state, info, matrix); mat_unlit->AlphaModulate(1.0f); g_IVRenderView->SetColorModulation(color_2); - g_IVModelRender->ForcedMaterialOverride(mat_lit); + g_IVModelRender->ForcedMaterialOverride(flat ? mat_unlit : mat_lit); } } else if (entity->GetClientClass()->m_ClassID == g_pClassID->C_Player) { int color = colors::EntityF(ENTITY(entity->entindex())); @@ -88,12 +186,12 @@ void DrawModelExecute(IVModelRender* _this, const DrawModelState_t& state, const float color_2[] = { color_1[0] * 0.6f, color_1[1] * 0.6f, color_1[2] * 0.6f }; mat_unlit_z->AlphaModulate(1.0f); g_IVRenderView->SetColorModulation(color_1); - g_IVModelRender->ForcedMaterialOverride(mat_lit_z); + g_IVModelRender->ForcedMaterialOverride(flat ? mat_unlit_z : mat_lit_z); ((DrawModelExecute_t)(hooks::hkIVModelRender->GetMethod(hooks::offDrawModelExecute)))(_this, state, info, matrix); mat_unlit->AlphaModulate(1.0f); g_IVRenderView->SetColorModulation(color_2); - g_IVModelRender->ForcedMaterialOverride(mat_lit); - } + g_IVModelRender->ForcedMaterialOverride(flat ? mat_unlit : mat_lit); + }*/ } From f8021fa33969baf84cb7ebcce85d0c02eaa70d93 Mon Sep 17 00:00:00 2001 From: nullifiedcat Date: Sun, 16 Apr 2017 00:08:25 +0300 Subject: [PATCH 8/8] seems pretty stable /shrug --- src/glowobjects.cpp | 3 +++ src/gui/ncc/Menu.cpp | 16 ++++++++++++++++ src/hacks/Chams.cpp | 4 +++- src/hacks/Chams.hpp | 2 ++ src/hooks/others.cpp | 5 +++++ 5 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/glowobjects.cpp b/src/glowobjects.cpp index 5e6e80d2..1fa793f0 100644 --- a/src/glowobjects.cpp +++ b/src/glowobjects.cpp @@ -17,6 +17,7 @@ static CatVar glow_teammates(CV_SWITCH, "glow_teammates", "0", "Teammates"); static CatVar glow_teammate_buildings(CV_SWITCH, "glow_teammate_buildings", "0", "Teammate buildings"); static CatVar glow_buildings(CV_SWITCH, "glow_buildings", "1", "Buildings"); static CatVar glow_stickies(CV_SWITCH, "glow_stickies", "0", "Stickies"); +static CatVar glow_players(CV_SWITCH, "glow_players", "1", "Players"); int CGlowObjectManager::EnableGlow(IClientEntity* entity, int color) { int idx = GlowHandle(entity); @@ -78,6 +79,7 @@ int GetEntityGlowColor(int idx) { } break; case ENTITY_PLAYER: + if (!glow_players) return 0; if (!ent->m_bEnemy && !glow_teammates) return 0; if ((int)glow_color_scheme == 1) { return colors::Health(ent->m_iHealth, ent->m_iMaxHealth); @@ -103,6 +105,7 @@ bool ShouldEntityGlow(int idx) { if (!ent->m_bEnemy && !(glow_teammate_buildings || glow_teammates)) return false; return true; case ENTITY_PLAYER: + if (!glow_players) return false; if (!glow_teammates && !ent->m_bEnemy) return false; if (CE_BYTE(ent, netvar.iLifeState) != LIFE_ALIVE) return false; return true; diff --git a/src/gui/ncc/Menu.cpp b/src/gui/ncc/Menu.cpp index fa7029b0..0dde425a 100644 --- a/src/gui/ncc/Menu.cpp +++ b/src/gui/ncc/Menu.cpp @@ -155,9 +155,25 @@ List& MainList() { ] ] +"Chams" [ + "Chams Menu" + "chams_enable" + "chams_health" + "chams_players" + "chams_teammates" + "chams_buildings" + "chams_teammate_buildings" + "chams_flat" + "chams_weapons" + "chams_medkits" + "chams_ammo" + "chams_stickies" +] + "Glow" [ "Glow Menu" "glow_enabled" + "glow_players" "glow_color_scheme" "glow_health_packs" "glow_ammo_boxes" diff --git a/src/hacks/Chams.cpp b/src/hacks/Chams.cpp index 16ba8bea..e6f24248 100644 --- a/src/hacks/Chams.cpp +++ b/src/hacks/Chams.cpp @@ -9,7 +9,7 @@ namespace hacks { namespace shared { namespace chams { -static CatVar enable(CV_SWITCH, "chams_enable", "0", "Enable"); +CatVar enable(CV_SWITCH, "chams_enable", "0", "Enable"); static CatVar flat(CV_SWITCH, "chams_flat", "0", "Flat"); static CatVar health(CV_SWITCH, "chams_health", "0", "Health"); static CatVar teammates(CV_SWITCH, "chams_teammates", "0", "Teammates"); @@ -80,6 +80,7 @@ int GetChamColor(int idx) { } break; case ENTITY_PLAYER: + if (!players) return 0; if (!ent->m_bEnemy && !teammates) return 0; if (health) { return colors::Health(ent->m_iHealth, ent->m_iMaxHealth); @@ -106,6 +107,7 @@ bool ShouldCham(int idx) { if (!ent->m_bEnemy && !(teammate_buildings || teammates)) return false; return true; case ENTITY_PLAYER: + if (!players) return false; if (!teammates && !ent->m_bEnemy) return false; if (CE_BYTE(ent, netvar.iLifeState) != LIFE_ALIVE) return false; return true; diff --git a/src/hacks/Chams.hpp b/src/hacks/Chams.hpp index 93e8bfef..1d9862ce 100644 --- a/src/hacks/Chams.hpp +++ b/src/hacks/Chams.hpp @@ -10,6 +10,8 @@ namespace hacks { namespace shared { namespace chams { +extern CatVar enable; + void DrawModelExecute(IVModelRender* _this, const DrawModelState_t& state, const ModelRenderInfo_t& info, matrix3x4_t* matrix); }}} diff --git a/src/hooks/others.cpp b/src/hooks/others.cpp index 85a7cc53..0ffd2874 100644 --- a/src/hooks/others.cpp +++ b/src/hooks/others.cpp @@ -36,6 +36,11 @@ void DrawModelExecute_hook(IVModelRender* _this, const DrawModelState_t& state, } } }*/ + if (!(no_arms || no_hats || hacks::shared::chams::enable)) { + ((DrawModelExecute_t)(hooks::hkIVModelRender->GetMethod(hooks::offDrawModelExecute)))(_this, state, info, matrix); + return; + } + if (no_arms || no_hats) { if (info.pModel) { const char* name = g_IModelInfo->GetModelName(info.pModel);