Far chams
This commit is contained in:
parent
a902813db3
commit
b573edc1d8
185
src/EffectChams.cpp
Normal file
185
src/EffectChams.cpp
Normal file
@ -0,0 +1,185 @@
|
|||||||
|
/*
|
||||||
|
* EffectChams.cpp
|
||||||
|
*
|
||||||
|
* Created on: Apr 16, 2017
|
||||||
|
* Author: nullifiedcat
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
#include "EffectChams.hpp"
|
||||||
|
|
||||||
|
//static CatVar chams_experimental(CV_SWITCH, "chams_effect", "0", "Experimental Chams");
|
||||||
|
|
||||||
|
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");
|
||||||
|
|
||||||
|
void EffectChams::Init() {
|
||||||
|
logging::Info("Init EffectChams...");
|
||||||
|
{
|
||||||
|
KeyValues* kv = new KeyValues("UnlitGeneric");
|
||||||
|
kv->SetString("$basetexture", "vgui/white_additive");
|
||||||
|
kv->SetInt("$ignorez", 0);
|
||||||
|
mat_unlit.Init("__cathook_echams_unlit", kv);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
KeyValues* kv = new KeyValues("UnlitGeneric");
|
||||||
|
kv->SetString("$basetexture", "vgui/white_additive");
|
||||||
|
kv->SetInt("$ignorez", 1);
|
||||||
|
mat_unlit_z.Init("__cathook_echams_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_echams_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_echams_lit_z", kv);
|
||||||
|
}
|
||||||
|
logging::Info("Init done!");
|
||||||
|
init = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EffectChams::BeginRenderChams() {
|
||||||
|
drawing = true;
|
||||||
|
CMatRenderContextPtr ptr(vfunc<IMatRenderContext*(*)(IMaterialSystemFixed*)>(g_IMaterialSystem, 100, 0)(g_IMaterialSystem));
|
||||||
|
g_IVRenderView->SetBlend(1.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EffectChams::EndRenderChams() {
|
||||||
|
drawing = false;
|
||||||
|
CMatRenderContextPtr ptr(vfunc<IMatRenderContext*(*)(IMaterialSystemFixed*)>(g_IMaterialSystem, 100, 0)(g_IMaterialSystem));
|
||||||
|
g_IVModelRender->ForcedMaterialOverride(nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
int EffectChams::ChamsColor(IClientEntity* entity) {
|
||||||
|
CachedEntity* ent = ENTITY(entity->entindex());
|
||||||
|
if (CE_BAD(ent)) return colors::white;
|
||||||
|
if (vfunc<bool(*)(IClientEntity*)>(entity, 0xBE, 0)(entity)) {
|
||||||
|
IClientEntity* owner = vfunc<IClientEntity*(*)(IClientEntity*)>(entity, 0x1C3, 0)(entity);
|
||||||
|
if (owner) {
|
||||||
|
return ChamsColor(owner);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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 (!players) return 0;
|
||||||
|
if (!ent->m_bEnemy && !teammates) return 0;
|
||||||
|
if (health) {
|
||||||
|
return colors::Health(ent->m_iHealth, ent->m_iMaxHealth);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return colors::EntityF(ent);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EffectChams::ShouldRenderChams(IClientEntity* entity) {
|
||||||
|
if (!enable) return false;
|
||||||
|
if (entity->entindex() < 0) return false;
|
||||||
|
CachedEntity* ent = ENTITY(entity->entindex());
|
||||||
|
if (CE_BAD(ent)) return false;
|
||||||
|
if (weapons && vfunc<bool(*)(IClientEntity*)>(entity, 0xBE, 0)(entity)) {
|
||||||
|
IClientEntity* owner = vfunc<IClientEntity*(*)(IClientEntity*)>(entity, 0x1C3, 0)(entity);
|
||||||
|
if (owner) {
|
||||||
|
return ShouldRenderChams(owner);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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 (!players) return false;
|
||||||
|
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 EffectChams::RenderChams(int idx) {
|
||||||
|
CMatRenderContextPtr ptr(g_IMaterialSystem->GetRenderContext());
|
||||||
|
IClientEntity* entity = g_IEntityList->GetClientEntity(idx);
|
||||||
|
if (entity && !entity->IsDormant()) {
|
||||||
|
if (ShouldRenderChams(entity)) {
|
||||||
|
int color = ChamsColor(entity);
|
||||||
|
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);
|
||||||
|
ptr->DepthRange(0.0f, 0.01f);
|
||||||
|
g_IVRenderView->SetColorModulation(color_1);
|
||||||
|
g_IVModelRender->ForcedMaterialOverride(flat ? mat_unlit_z : mat_lit_z);
|
||||||
|
entity->DrawModel(1);
|
||||||
|
//((DrawModelExecute_t)(hooks::hkIVModelRender->GetMethod(hooks::offDrawModelExecute)))(_this, state, info, matrix);
|
||||||
|
mat_unlit->AlphaModulate(1.0f);
|
||||||
|
g_IVRenderView->SetColorModulation(color_2);
|
||||||
|
ptr->DepthRange(0.0f, 1.0f);
|
||||||
|
g_IVModelRender->ForcedMaterialOverride(flat ? mat_unlit : mat_lit);
|
||||||
|
entity->DrawModel(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void EffectChams::Render(int x, int y, int w, int h) {
|
||||||
|
if (!init) Init();
|
||||||
|
if (g_IEngine->IsTakingScreenshot() && clean_screenshots) return;
|
||||||
|
if (!enable) return;
|
||||||
|
CMatRenderContextPtr ptr(g_IMaterialSystem->GetRenderContext());
|
||||||
|
|
||||||
|
BeginRenderChams();
|
||||||
|
for (int i = 1; i < HIGHEST_ENTITY; i++) {
|
||||||
|
IClientEntity* ent = g_IEntityList->GetClientEntity(i);
|
||||||
|
if (ent && !ent->IsDormant()) {
|
||||||
|
RenderChams(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EndRenderChams();
|
||||||
|
}
|
||||||
|
|
||||||
|
EffectChams g_EffectChams;
|
||||||
|
CScreenSpaceEffectRegistration* g_pEffectChams = nullptr;
|
44
src/EffectChams.hpp
Normal file
44
src/EffectChams.hpp
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* EffectChams.hpp
|
||||||
|
*
|
||||||
|
* Created on: Apr 16, 2017
|
||||||
|
* Author: nullifiedcat
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EFFECTCHAMS_HPP_
|
||||||
|
#define EFFECTCHAMS_HPP_
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
|
class EffectChams : public IScreenSpaceEffect {
|
||||||
|
public:
|
||||||
|
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; };
|
||||||
|
|
||||||
|
int ChamsColor(IClientEntity* entity);
|
||||||
|
bool ShouldRenderChams(IClientEntity* entity);
|
||||||
|
void RenderChams(int idx);
|
||||||
|
void BeginRenderChams();
|
||||||
|
void EndRenderChams();
|
||||||
|
public:
|
||||||
|
bool init { false };
|
||||||
|
bool drawing { false };
|
||||||
|
bool enabled;
|
||||||
|
float orig_modulation[3];
|
||||||
|
CMaterialReference mat_unlit;
|
||||||
|
CMaterialReference mat_unlit_z;
|
||||||
|
CMaterialReference mat_lit;
|
||||||
|
CMaterialReference mat_lit_z;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern EffectChams g_EffectChams;
|
||||||
|
extern CScreenSpaceEffectRegistration* g_pEffectChams;
|
||||||
|
|
||||||
|
#endif /* EFFECTCHAMS_HPP_ */
|
@ -50,6 +50,7 @@
|
|||||||
#include "itemtypes.h"
|
#include "itemtypes.h"
|
||||||
#include "chatstack.h"
|
#include "chatstack.h"
|
||||||
#include "textfile.h"
|
#include "textfile.h"
|
||||||
|
#include "EffectChams.hpp"
|
||||||
#include "ipc.h"
|
#include "ipc.h"
|
||||||
#include "gui/GUI.h"
|
#include "gui/GUI.h"
|
||||||
#include "hooks/hookedmethods.h"
|
#include "hooks/hookedmethods.h"
|
||||||
|
@ -183,6 +183,9 @@ void hack::Initialize() {
|
|||||||
hack::command_stack().push("cat_spam_reload");
|
hack::command_stack().push("cat_spam_reload");
|
||||||
logging::Info("Hooked!");
|
logging::Info("Hooked!");
|
||||||
playerlist::Load();
|
playerlist::Load();
|
||||||
|
g_pEffectChams = new CScreenSpaceEffectRegistration("_cathook_chams", &g_EffectChams);
|
||||||
|
g_pScreenSpaceEffects->EnableScreenSpaceEffect("_cathook_chams");
|
||||||
|
g_EffectChams.Init();
|
||||||
//g_pEffectGlow = new CScreenSpaceEffectRegistration("_cathook_glow", &g_EffectGlow);
|
//g_pEffectGlow = new CScreenSpaceEffectRegistration("_cathook_glow", &g_EffectGlow);
|
||||||
//for (CScreenSpaceEffectRegistration* reg = *g_ppScreenSpaceRegistrationHead; reg; reg = reg->m_pNext) {
|
//for (CScreenSpaceEffectRegistration* reg = *g_ppScreenSpaceRegistrationHead; reg; reg = reg->m_pNext) {
|
||||||
// logging::Info("%s", reg->m_pEffectName);
|
// logging::Info("%s", reg->m_pEffectName);
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
namespace hacks { namespace shared { namespace chams {
|
namespace hacks { namespace shared { namespace chams {
|
||||||
|
|
||||||
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 flat(CV_SWITCH, "chams_flat", "0", "Flat");
|
||||||
static CatVar health(CV_SWITCH, "chams_health", "0", "Health");
|
static CatVar health(CV_SWITCH, "chams_health", "0", "Health");
|
||||||
static CatVar teammates(CV_SWITCH, "chams_teammates", "0", "Teammates");
|
static CatVar teammates(CV_SWITCH, "chams_teammates", "0", "Teammates");
|
||||||
@ -192,11 +192,11 @@ void DrawModelExecute(IVModelRender* _this, const DrawModelState_t& state, const
|
|||||||
mat_unlit->AlphaModulate(1.0f);
|
mat_unlit->AlphaModulate(1.0f);
|
||||||
g_IVRenderView->SetColorModulation(color_2);
|
g_IVRenderView->SetColorModulation(color_2);
|
||||||
g_IVModelRender->ForcedMaterialOverride(flat ? mat_unlit : mat_lit);
|
g_IVModelRender->ForcedMaterialOverride(flat ? mat_unlit : mat_lit);
|
||||||
}*/
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
}}}
|
}}}
|
||||||
|
@ -10,9 +10,9 @@
|
|||||||
|
|
||||||
namespace hacks { namespace shared { namespace chams {
|
namespace hacks { namespace shared { namespace chams {
|
||||||
|
|
||||||
extern CatVar enable;
|
//extern CatVar enable;
|
||||||
|
|
||||||
void DrawModelExecute(IVModelRender* _this, const DrawModelState_t& state, const ModelRenderInfo_t& info, matrix3x4_t* matrix);
|
//void DrawModelExecute(IVModelRender* _this, const DrawModelState_t& state, const ModelRenderInfo_t& info, matrix3x4_t* matrix);
|
||||||
|
|
||||||
}}}
|
}}}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ void DrawModelExecute_hook(IVModelRender* _this, const DrawModelState_t& state,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
if (!(no_arms || no_hats || hacks::shared::chams::enable) || (clean_screenshots && g_IEngine->IsTakingScreenshot())) {
|
if (!(no_arms || no_hats || (clean_screenshots && g_IEngine->IsTakingScreenshot()))) {
|
||||||
((DrawModelExecute_t)(hooks::hkIVModelRender->GetMethod(hooks::offDrawModelExecute)))(_this, state, info, matrix);
|
((DrawModelExecute_t)(hooks::hkIVModelRender->GetMethod(hooks::offDrawModelExecute)))(_this, state, info, matrix);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -55,12 +55,15 @@ void DrawModelExecute_hook(IVModelRender* _this, const DrawModelState_t& state,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float mod_old[3] { 0.0f };
|
IClientUnknown* unk = info.pRenderable->GetIClientUnknown();
|
||||||
g_IVRenderView->GetColorModulation(mod_old);
|
if (unk) {
|
||||||
hacks::shared::chams::DrawModelExecute(_this, state, info, matrix);
|
IClientEntity* ent = unk->GetIClientEntity();
|
||||||
|
if (ent && !g_EffectChams.drawing && g_EffectChams.ShouldRenderChams(ent)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
((DrawModelExecute_t)(hooks::hkIVModelRender->GetMethod(hooks::offDrawModelExecute)))(_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) {
|
bool CanPacket_hook(void* thisptr) {
|
||||||
|
@ -53,6 +53,7 @@
|
|||||||
#include <engine/ivdebugoverlay.h>
|
#include <engine/ivdebugoverlay.h>
|
||||||
|
|
||||||
#include "sdk/in_buttons.h"
|
#include "sdk/in_buttons.h"
|
||||||
|
#include "sdk/imaterialsystemfixed.h"
|
||||||
#include "sdk/ScreenSpaceEffects.h"
|
#include "sdk/ScreenSpaceEffects.h"
|
||||||
#include "sdk/iinput.h"
|
#include "sdk/iinput.h"
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user