whoops forgot to switch to master

This commit is contained in:
nullifiedcat 2017-04-13 10:52:24 +03:00
parent c8859092fe
commit da6faad337
5 changed files with 131 additions and 35 deletions

View File

@ -11,13 +11,59 @@
static CatEnum glow_color_scheme_enum({"ESP", "HEALTH"});
static CatVar glow_color_scheme(glow_color_scheme_enum, "glow_color_scheme", "1", "Colors", "Doesn't need a description");
// Doesn't work - has to be registered manually.
//static CatVar glow_ammo_boxes(CV_SWITCH, "glow_ammo_boxes", "0", "Ammo");
//static CatVar glow_health_packs(CV_SWITCH, "glow_health_packs", "0", "Health");
static CatVar glow_ammo_boxes(CV_SWITCH, "glow_ammo_boxes", "0", "Ammo");
static CatVar glow_health_packs(CV_SWITCH, "glow_health_packs", "0", "Health");
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");
int CGlowObjectManager::EnableGlow(IClientEntity* entity, int color) {
int idx = GlowHandle(entity);
if (idx != -1) {
logging::Info("[WARNING] Glow handle exists!!!");
return idx;
}
if (m_nFirstFreeSlot == END_OF_FREE_LIST) {
idx = m_GlowObjectDefinitions.AddToTail();
} else {
idx = m_nFirstFreeSlot;
m_nFirstFreeSlot = m_GlowObjectDefinitions[idx].m_nNextFreeSlot;
}
g_CathookManagedGlowObjects.insert(idx);
GlowObjectDefinition_t& def = m_GlowObjectDefinitions[idx];
def.m_bRenderWhenOccluded = true;
def.m_bRenderWhenUnoccluded = true;
def.m_flGlowAlpha = 1.0f;
def.m_hEntity = CBaseHandle();
def.m_hEntity.Set(entity);
unsigned char _b = (color >> 16) & 0xFF;
unsigned char _g = (color >> 8) & 0xFF;
unsigned char _r = (color) & 0xFF;
def.m_vGlowColor = Vector((float)_r / 255.0f, (float)_g / 255.0f, (float)_b / 255.0f);
def.m_nNextFreeSlot = ENTRY_IN_USE;
def.m_nSplitScreenSlot = -1;
return idx;
}
void CGlowObjectManager::DisableGlow(int idx) {
const auto& it = g_CathookManagedGlowObjects.find(idx);
if (it == g_CathookManagedGlowObjects.end()) {
return;
}
g_CathookManagedGlowObjects.erase(it);
m_GlowObjectDefinitions[idx].m_nNextFreeSlot = m_nFirstFreeSlot;
m_GlowObjectDefinitions[idx].m_hEntity = NULL;
m_nFirstFreeSlot = idx;
}
int CGlowObjectManager::GlowHandle(IClientEntity* entity) const {
for (int i = 0; i < m_GlowObjectDefinitions.Count(); i++) {
if (m_GlowObjectDefinitions[i].m_nNextFreeSlot == ENTRY_IN_USE && (m_GlowObjectDefinitions[i].m_hEntity.m_Index & 0xFFF) == entity->entindex()) return i;
}
return -1;
}
int GetEntityGlowColor(int idx) {
if (idx < 0 || idx > g_IEntityList->GetHighestEntityIndex()) return colors::white;
CachedEntity* ent = ENTITY(idx);
@ -59,7 +105,7 @@ bool ShouldEntityGlow(int idx) {
return true;
}
break;
/*case ENTITY_GENERIC:
case ENTITY_GENERIC:
switch (ent->m_ItemType) {
case ITEM_HEALTH_LARGE:
case ITEM_HEALTH_MEDIUM:
@ -70,9 +116,11 @@ bool ShouldEntityGlow(int idx) {
case ITEM_AMMO_SMALL:
return glow_ammo_boxes;
}
break;*/
break;
}
return false;
}
std::set<int> g_CathookManagedGlowObjects {};
CGlowObjectManager* g_GlowObjectManager = 0;

View File

@ -11,13 +11,12 @@
#define END_OF_FREE_LIST -1
#define ENTRY_IN_USE -2
#include "fixsdk.h"
#include <tier1/utlvector.h>
#include <mathlib/vector.h>
#include <basehandle.h>
#include "common.h"
//template<typename T> class CUtlVector;
extern std::set<int> g_CathookManagedGlowObjects;
struct GlowObjectDefinition_t {
CBaseHandle m_hEntity;
Vector m_vGlowColor;
@ -30,6 +29,9 @@ struct GlowObjectDefinition_t {
class CGlowObjectManager {
public:
int EnableGlow(IClientEntity* entity, int color);
void DisableGlow(int idx);
int GlowHandle(IClientEntity* entity) const;
CUtlVector<GlowObjectDefinition_t> m_GlowObjectDefinitions;
int m_nFirstFreeSlot;
};

View File

@ -157,6 +157,8 @@ List& MainList() {
"Glow Menu"
"glow_enabled"
"glow_color_scheme"
"glow_health_packs"
"glow_ammo_boxes"
"glow_teammates"
"glow_teammate_buildings"
"glow_buildings"
@ -179,6 +181,8 @@ List& MainList() {
"esp_3d_box_health"
"esp_3d_box_expand"
"esp_3d_box_smoothing"
"esp_3d_box_expand_size"
"esp_3d_box_healthbar"
]
"esp_legit"
"esp_health_num"

View File

@ -107,9 +107,12 @@ static CatEnum esp_box_text_position_enum({"TOP RIGHT", "BOTTOM RIGHT", "CENTER"
static CatVar esp_box_text_position(esp_box_text_position_enum, "esp_box_text_position", "0", "Text position", "Defines text position");
static CatVar esp_3d_box_health(CV_SWITCH, "esp_3d_box_health", "1", "3D box health color");
static CatVar esp_3d_box_thick(CV_SWITCH, "esp_3d_box_thick", "1", "Thick 3D box");
static CatVar esp_3d_box_expand_rate(CV_FLOAT, "esp_3d_box_expand_size", "10", "3D Box Expand Size", "Expand 3D box by X units", 50.0f);
static CatVar esp_3d_box_expand(CV_SWITCH, "esp_3d_box_expand", "1", "Expand 3D box");
static CatEnum esp_3d_box_smoothing_enum({"None", "Origin offset", "Bone update (NOT IMPL)"});
static CatVar esp_3d_box_smoothing(esp_3d_box_smoothing_enum, "esp_3d_box_smoothing", "1", "3D box smoothing", "3D box smoothing method");
static CatVar esp_3d_box_nodraw(CV_SWITCH, "esp_3d_box_nodraw", "0", "Invisible 3D box", "Don't draw 3d box");
static CatVar esp_3d_box_healthbar(CV_SWITCH, "esp_3d_box_healthbar", "1", "Health bar");
void Draw3DBox(CachedEntity* ent, int clr, bool healthbar, int health, int healthmax) {
Vector mins, maxs;
@ -125,18 +128,23 @@ void Draw3DBox(CachedEntity* ent, int clr, bool healthbar, int health, int healt
if (!set || hb->max.z > maxs.z) maxs.z = hb->max.z;
set = true;
}
// Expand it a bit
// This is weird, smoothing only makes it worse on local servers
if ((int)esp_3d_box_smoothing == 1) {
mins += (RAW_ENT(ent)->GetAbsOrigin() - ent->m_vecOrigin);
maxs += (RAW_ENT(ent)->GetAbsOrigin() - ent->m_vecOrigin);
}
static const Vector expand_vector(8.5, 8.5, 8.5);
//static const Vector expand_vector(8.5, 8.5, 8.5);
if (esp_3d_box_expand) {
maxs += expand_vector;
mins -= expand_vector;
const float& exp = (float)esp_3d_box_expand_rate;
maxs.x += exp;
maxs.y += exp;
maxs.z += exp;
mins.x -= exp;
mins.y -= exp;
mins.z -= exp;
}
Vector points_r[8];
@ -192,14 +200,21 @@ void Draw3DBox(CachedEntity* ent, int clr, bool healthbar, int health, int healt
if (esp_3d_box_health) clr = colors::Health(health, healthmax);
bool cloak = ent->m_iClassID == g_pClassID->C_Player && IsPlayerInvisible(ent);
if (cloak) clr = colors::Transparent(clr, 0.2);
for (int i = 0; i < 12; i++) {
const Vector& p1 = points[indices[i][0]];
const Vector& p2 = points[indices[i][1]];
draw::DrawLine(p1.x, p1.y, p2.x - p1.x, p2.y - p1.y, clr);
if (esp_3d_box_thick) {
draw::DrawLine(p1.x + 1, p1.y, p2.x - p1.x, p2.y - p1.y, clr);
draw::DrawLine(p1.x, p1.y + 1, p2.x - p1.x, p2.y - p1.y, clr);
draw::DrawLine(p1.x + 1, p1.y + 1, p2.x - p1.x, p2.y - p1.y, clr);
if (esp_3d_box_healthbar) {
draw::OutlineRect(min_x - 6, min_y, 6, max_y - min_y, colors::black);
int hbh = (max_y - min_y - 2) * min((float)health / (float)healthmax, 1.0f);
draw::DrawRect(min_x - 5, max_y - 1 - hbh, 4, hbh, colors::Health(health, healthmax));
}
if (!esp_3d_box_nodraw) {
for (int i = 0; i < 12; i++) {
const Vector& p1 = points[indices[i][0]];
const Vector& p2 = points[indices[i][1]];
draw::DrawLine(p1.x, p1.y, p2.x - p1.x, p2.y - p1.y, clr);
if (esp_3d_box_thick) {
draw::DrawLine(p1.x + 1, p1.y, p2.x - p1.x, p2.y - p1.y, clr);
draw::DrawLine(p1.x, p1.y + 1, p2.x - p1.x, p2.y - p1.y, clr);
draw::DrawLine(p1.x + 1, p1.y + 1, p2.x - p1.x, p2.y - p1.y, clr);
}
}
}
}

View File

@ -116,26 +116,53 @@ void FrameStageNotify_hook(void* thisptr, int stage) {
unsigned char _b = (color >> 16) & 0xFF;
unsigned char _g = (color >> 8) & 0xFF;
unsigned char _r = (color) & 0xFF;
glowobject.m_vGlowColor = Vector((float)_r / 255.0f, (float)_g / 255.0f, (float)_b / 255.0f);
glowobject.m_vGlowColor.x = (float)_r / 255.0f;
glowobject.m_vGlowColor.y = (float)_g / 255.0f;
glowobject.m_vGlowColor.z = (float)_b / 255.0f;
}
}
for (int i = 1; i < g_IEntityList->GetHighestEntityIndex(); i++) {
IClientEntity* entity = g_IEntityList->GetClientEntity(i);
if (!entity || i == g_IEngine->GetLocalPlayer() || entity->IsDormant())
continue;
int clazz = entity->GetClientClass()->m_ClassID;
bool old_byte = NET_BYTE(entity, 0xDA1);
bool new_byte = (glow_enabled && !entity->IsDormant() && ShouldEntityGlow(i));
if (CanEntityEvenGlow(i)) NET_BYTE(entity, 0xDA1) = new_byte;
if (old_byte != new_byte && clazz == g_pClassID->CTFPlayer) {
if (new_byte) {
vfunc<void(*)(IClientEntity*)>(entity, 290, 0)(entity);
} else {
vfunc<void(*)(IClientEntity*)>(entity, 291, 0)(entity);
// Remove glow from dead entities
for (int i = 0; i < g_GlowObjectManager->m_GlowObjectDefinitions.Count(); i++) {
if (g_GlowObjectManager->m_GlowObjectDefinitions[i].m_nNextFreeSlot != ENTRY_IN_USE) continue;
IClientEntity* ent = (IClientEntity*)g_IEntityList->GetClientEntityFromHandle(g_GlowObjectManager->m_GlowObjectDefinitions[i].m_hEntity);
if (ent && ent->IsDormant()) {
g_GlowObjectManager->DisableGlow(i);
} else if (ent && ent->GetClientClass()->m_ClassID == g_pClassID->C_Player) {
if (NET_BYTE(ent, netvar.iLifeState) != LIFE_ALIVE) {
g_GlowObjectManager->DisableGlow(i);
}
}
}
if (glow_enabled) {
for (int i = 1; i < g_IEntityList->GetHighestEntityIndex(); i++) {
IClientEntity* entity = g_IEntityList->GetClientEntity(i);
if (!entity || i == g_IEngine->GetLocalPlayer() || entity->IsDormant())
continue;
if (!CanEntityEvenGlow(i)) continue;
int clazz = entity->GetClientClass()->m_ClassID;
int current_handle = g_GlowObjectManager->GlowHandle(entity);
bool shouldglow = ShouldEntityGlow(i);
if (current_handle != -1) {
if (!shouldglow) {
g_GlowObjectManager->DisableGlow(current_handle);
}
} else {
if (shouldglow) {
g_GlowObjectManager->EnableGlow(entity, colors::white);
}
}
/*bool old_byte = NET_BYTE(entity, 0xDA1);
bool new_byte = (glow_enabled && ShouldEntityGlow(i));
if (CanEntityEvenGlow(i)) NET_BYTE(entity, 0xDA1) = new_byte;
if (old_byte != new_byte && clazz == g_pClassID->CTFPlayer) {
if (new_byte) {
vfunc<void(*)(IClientEntity*)>(entity, 290, 0)(entity);
} else {
vfunc<void(*)(IClientEntity*)>(entity, 291, 0)(entity);
}
}*/
}
}
SVDBG("FSN %i", __LINE__);
if (force_thirdperson && !g_pLocalPlayer->life_state && CE_GOOD(g_pLocalPlayer->entity)) {