From 280da4d06e1afd36058b4091c6dbff1ed19200bd Mon Sep 17 00:00:00 2001 From: nullifiedcat Date: Fri, 21 Apr 2017 23:20:34 +0300 Subject: [PATCH] b1g playerlist --- src/EffectChams.cpp | 2 +- src/EffectGlow.cpp | 7 +- src/gui/guicommon.h | 15 +++ src/gui/ncc/ItemSublist.hpp | 2 + src/gui/ncc/Menu.hpp | 13 ++ src/gui/ncc/PlayerList.cpp | 51 ++++++++ src/gui/ncc/PlayerList.hpp | 18 ++- src/gui/ncc/PlayerListEntry.cpp | 223 ++++++++++++++++++++++++++++++++ src/gui/ncc/PlayerListEntry.hpp | 55 ++++++++ src/gui/ncc/Root.cpp | 3 + src/hacks/Chams.cpp | 202 ----------------------------- src/hacks/Chams.hpp | 19 --- src/hacks/ESP.cpp | 20 +-- src/hacks/hacklist.h | 1 - src/helpers.cpp | 3 +- src/helpers.h | 2 +- src/hooks/others.cpp | 1 + src/netvars.cpp | 1 + src/netvars.h | 1 + src/playerlist.cpp | 10 ++ src/playerlist.hpp | 2 + src/playerresource.cpp | 5 + src/playerresource.h | 1 + 23 files changed, 405 insertions(+), 252 deletions(-) create mode 100644 src/gui/guicommon.h create mode 100644 src/gui/ncc/PlayerListEntry.cpp delete mode 100644 src/hacks/Chams.cpp delete mode 100644 src/hacks/Chams.hpp diff --git a/src/EffectChams.cpp b/src/EffectChams.cpp index 21d86260..cd370102 100644 --- a/src/EffectChams.cpp +++ b/src/EffectChams.cpp @@ -115,7 +115,7 @@ bool EffectChams::ShouldRenderChams(IClientEntity* entity) { return true; case ENTITY_PLAYER: if (!players) return false; - if (!teammates && !ent->m_bEnemy) return false; + if (!teammates && !ent->m_bEnemy && playerlist::IsDefault(ent)) return false; if (CE_BYTE(ent, netvar.iLifeState) != LIFE_ALIVE) return false; return true; break; diff --git a/src/EffectGlow.cpp b/src/EffectGlow.cpp index 18a7d9a0..2899cf05 100644 --- a/src/EffectGlow.cpp +++ b/src/EffectGlow.cpp @@ -190,16 +190,11 @@ int EffectGlow::GlowColor(IClientEntity* entity) { } 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); } @@ -226,7 +221,7 @@ bool EffectGlow::ShouldRenderGlow(IClientEntity* entity) { return true; case ENTITY_PLAYER: if (!players) return false; - if (!teammates && !ent->m_bEnemy) return false; + if (!teammates && !ent->m_bEnemy && playerlist::IsDefault(ent)) return false; if (CE_BYTE(ent, netvar.iLifeState) != LIFE_ALIVE) return false; return true; break; diff --git a/src/gui/guicommon.h b/src/gui/guicommon.h new file mode 100644 index 00000000..81b81ac3 --- /dev/null +++ b/src/gui/guicommon.h @@ -0,0 +1,15 @@ +/* + * guicommon.h + * + * Created on: Apr 21, 2017 + * Author: nullifiedcat + */ + +#ifndef GUICOMMON_H_ +#define GUICOMMON_H_ + +#include "CBaseContainer.h" +#include "CBaseWidget.h" +#include "GUI.h" + +#endif /* GUICOMMON_H_ */ diff --git a/src/gui/ncc/ItemSublist.hpp b/src/gui/ncc/ItemSublist.hpp index 2a17c889..c2461178 100644 --- a/src/gui/ncc/ItemSublist.hpp +++ b/src/gui/ncc/ItemSublist.hpp @@ -15,6 +15,8 @@ class CatVar; namespace menu { namespace ncc { +class List; // ???? + class ItemSublist : public Item { public: ItemSublist(std::string title, List* list); diff --git a/src/gui/ncc/Menu.hpp b/src/gui/ncc/Menu.hpp index 2d7d842b..6973e2e5 100644 --- a/src/gui/ncc/Menu.hpp +++ b/src/gui/ncc/Menu.hpp @@ -10,13 +10,26 @@ #include "../../drawing.h" +#include "../guicommon.h" + #include "List.hpp" +#include "Item.hpp" +#include "ItemSublist.hpp" +#include "ItemTitle.hpp" +#include "ItemVariable.hpp" +#include "List.hpp" +#include "PlayerList.hpp" +#include "PlayerListEntry.hpp" +#include "Radar.hpp" +#include "Root.hpp" +#include "Tooltip.hpp" namespace menu { namespace ncc { class List; class Tooltip; +constexpr int font_item_height = 12; extern unsigned long font_title; // Verdana Bold 10px? extern unsigned long font_item; // Verdana 10px? extern Tooltip* tooltip; diff --git a/src/gui/ncc/PlayerList.cpp b/src/gui/ncc/PlayerList.cpp index 4455d986..4229ea1b 100644 --- a/src/gui/ncc/PlayerList.cpp +++ b/src/gui/ncc/PlayerList.cpp @@ -5,4 +5,55 @@ * Author: nullifiedcat */ +#include "Menu.hpp" +namespace menu { namespace ncc { + +PlayerList::PlayerList() : CBaseContainer() { + for (int i = 0; i <= 32; i++) { + AddChild(new PlayerListEntry(i)); + } +} + +void PlayerList::Draw(int x, int y) { + if (g_Settings.bInvalid) return; + const auto& size = GetSize(); + draw::DrawRect(x, y, size.first, size.second, colors::Create(0, 0, 0, 65)); + draw::OutlineRect(x, y, size.first, size.second, GUIColor()); + for (int i = 0; i < Props()->GetInt("vischildren"); i++) { + draw::DrawLine(x, y + i * 17, size_table_width(), 0, GUIColor()); + } + int accum = 0; + for (int i = 0; i < sizeof(size_table) / sizeof(int); i++) { + draw::DrawLine(x + accum, y, 0, size.second, GUIColor()); + accum += size_table[i] + 1; + } + CBaseContainer::Draw(x, y); +} + +void PlayerList::OnKeyPress(ButtonCode_t key, bool repeat) { + if (GetHoveredChild()) GetHoveredChild()->OnKeyPress(key, repeat); +} + +void PlayerList::Update() { + if (g_Settings.bInvalid) return; + if (IsPressed()) { + auto offset = GetOffset(); + offset.first += g_pGUI->mouse_dx; + offset.second += g_pGUI->mouse_dy; + SetOffset(offset.first, offset.second); + } + CBaseContainer::Update(); +} + +void PlayerList::MoveChildren() { + int visible = 0; + for (int i = 0; i < ChildCount(); i++) { + ChildByIndex(i)->SetOffset(0, 1 + visible * 17); + if (ChildByIndex(i)->IsVisible()) visible++; + } + SetSize(size_table_width(), visible * 17 + 1); + Props()->SetInt("vischildren", visible); +} + +}} diff --git a/src/gui/ncc/PlayerList.hpp b/src/gui/ncc/PlayerList.hpp index 723ba36f..af26d3a5 100644 --- a/src/gui/ncc/PlayerList.hpp +++ b/src/gui/ncc/PlayerList.hpp @@ -5,23 +5,33 @@ * Author: nullifiedcat */ -#ifndef PLAYERLIST_HPP_ -#define PLAYERLIST_HPP_ +#ifndef GUI_NCC_PLAYERLIST_HPP_ +#define GUI_NCC_PLAYERLIST_HPP_ #include "../CBaseContainer.h" namespace menu { namespace ncc { +constexpr int size_table[] = { 32, 32, 80, 160, 80, 80, 32, 32, 32 }; +constexpr int size_table_width() { + int accum = 1; + for (int i = 0; i < sizeof(size_table) / sizeof(int); i++) { + accum += (size_table[i] + 1); + } + return accum; +} + class PlayerList : public CBaseContainer { public: PlayerList(); - virtual void OnKeyPress(ButtonCode_t key, bool repeat) override; virtual void Draw(int x, int y) override; virtual void Update() override; + virtual void OnKeyPress(ButtonCode_t key, bool repeat) override; virtual void MoveChildren() override; + inline virtual void SortByZIndex() override {}; }; }} -#endif /* PLAYERLIST_HPP_ */ +#endif /* GUI_NCC_PLAYERLIST_HPP_ */ diff --git a/src/gui/ncc/PlayerListEntry.cpp b/src/gui/ncc/PlayerListEntry.cpp new file mode 100644 index 00000000..dca6dd66 --- /dev/null +++ b/src/gui/ncc/PlayerListEntry.cpp @@ -0,0 +1,223 @@ +/* + * PlayerListEntry.cpp + * + * Created on: Apr 21, 2017 + * Author: nullifiedcat + */ + +#include "PlayerListEntry.hpp" +#include "../../helpers.h" + +namespace menu { namespace ncc { + +using namespace entrysubs; + +void PlayerListEntry::Draw(int x, int y) { + CBaseContainer::Draw(x, y); +} + +void PlayerListEntry::Update() { + if (idx) { + SubBase* uid = dynamic_cast(ChildByIndex(1)); + SubBase* steamid = dynamic_cast(ChildByIndex(2)); + SubBase* name = dynamic_cast(ChildByIndex(3)); + SubBase* clazz = dynamic_cast(ChildByIndex(4)); + if (uid && steamid && name && clazz) { + player_info_s info; + bool success = g_IEngine->GetPlayerInfo(idx, &info); + if (success) { + uid->text = format(info.userID); + steamid->text = format(info.friendsID); + char safename[32]; + for (int i = 0, j = 0; i < 32; i++) { + if (info.name[i] == 0) { + safename[j] = 0; + break; + } + if (info.name[i] == '\n') continue; + safename[j++] = info.name[i]; + } + name->text = format(safename); + int iclazz = g_pPlayerResource->GetClass(ENTITY(idx)); + int team = g_pPlayerResource->GetTeam(idx); + clazz->color_bg = 0; + if (idx != g_IEngine->GetLocalPlayer()) { + if (team == TEAM_RED) { + clazz->color_bg = colors::red; + } else if (team == TEAM_BLU) { + clazz->color_bg = colors::blu; + } + } + if (iclazz && iclazz < 10) { + clazz->text = classes[iclazz - 1]; + } else { + clazz->text = "N/A"; + } + Show(); + } else { + uid->text = "N/A"; + steamid->text = "N/A"; + name->text = "N/A"; + clazz->text = "N/A"; + Hide(); + } + } else { + Hide(); + } + } + CBaseContainer::Update(); +} + +void PlayerListEntry::MoveChildren() { + int it = 1; + for (int i = 0; i < ChildCount() && i < (sizeof(size_table) / sizeof(int)); i++) { + IWidget* child = ChildByIndex(i); + child->SetOffset(it, 0); + child->SetSize(size_table[i], 16); + it += 1 + size_table[i]; + } + SetSize(it, 16); +} + +void PlayerListEntry::OnKeyPress(ButtonCode_t key, bool repeat) { + if (GetHoveredChild()) GetHoveredChild()->OnKeyPress(key, repeat); +} + +PlayerListEntry::PlayerListEntry(int eid) : CBaseContainer(), idx(eid) { + // If IDX == 0, this is a title. + if (!idx) { + AddChild(new SubTitle(*this, "EID")); + AddChild(new SubTitle(*this, "UID")); + AddChild(new SubTitle(*this, "SteamID")); + AddChild(new SubTitle(*this, "Name")); + AddChild(new SubTitle(*this, "Class")); + AddChild(new SubTitle(*this, "State")); + AddChild(new SubTitle(*this, "R")); + AddChild(new SubTitle(*this, "G")); + AddChild(new SubTitle(*this, "B")); + Show(); + } else { + Hide(); + SubBase* eid = new SubBase(*this); + eid->text = format(idx); + AddChild(eid); // EID + AddChild(new SubBase(*this)); // UID + AddChild(new SubBase(*this)); // SteamID + AddChild(new SubBase(*this)); // Name + AddChild(new SubBase(*this)); // Class + AddChild(new SubState(*this)); + AddChild(new SubColorComponent(*this, SubColorComponent::Component::R)); + AddChild(new SubColorComponent(*this, SubColorComponent::Component::G)); + AddChild(new SubColorComponent(*this, SubColorComponent::Component::B)); + } +} + +SubBase::SubBase(PlayerListEntry& base) : parent(base), CBaseWidget() {} + +void SubBase::Draw(int x, int y) { + if (color_bg) { + const auto& size = GetSize(); + draw::DrawRect(x, y, size.first, size.second, color_bg); + } + draw::String(menu::ncc::font_item, x + 2, y + 2, color_fg ? color_fg : colors::white, 2, text); +} + +SubTitle::SubTitle(PlayerListEntry& parent, const std::string& title) : SubBase(parent) { + text = title; +} + +void SubTitle::Draw(int x, int y) { + draw::String(menu::ncc::font_title, x + 2, y + 2, colors::white, 2, text); +} + +SubColorComponent::SubColorComponent(PlayerListEntry& parent, Component component) : SubBase(parent), component(component) {} + +void SubColorComponent::Update() { + player_info_s info; + bool success = g_IEngine->GetPlayerInfo(parent.idx, &info); + if (success) { + playerlist::userdata& data = playerlist::AccessData(info.friendsID); + color_bg = data.color; + } else { + color_bg = 0; + } + text = format((int)(reinterpret_cast(&color_bg)[static_cast(component)])); +} + +bool SubColorComponent::ConsumesKey(ButtonCode_t key) { + return key == MOUSE_WHEEL_DOWN || key == MOUSE_WHEEL_UP; +} +void SubColorComponent::OnKeyPress(ButtonCode_t key, bool repeat) { + player_info_s info; + bool success = g_IEngine->GetPlayerInfo(parent.idx, &info); + if (!success) return; + playerlist::userdata& data = playerlist::AccessData(info.friendsID); + int change = 0; + if (key == MOUSE_WHEEL_UP) { + if (g_IInputSystem->IsButtonDown(KEY_LSHIFT)) { + change = 50; + } else if (g_IInputSystem->IsButtonDown(KEY_LCONTROL)) { + change = 10; + } else { + change = 1; + } + } else if (key == MOUSE_WHEEL_DOWN) { + if (g_IInputSystem->IsButtonDown(KEY_LSHIFT)) { + change = -50; + } else if (g_IInputSystem->IsButtonDown(KEY_LCONTROL)) { + change = -10; + } else { + change = -1; + } + } + int result = _clamp(0, 255, (int)(reinterpret_cast(&data.color)[static_cast(component)]) + change); + (reinterpret_cast(&data.color)[static_cast(component)]) = (unsigned char)result; + if (!(data.color & 0x00FFFFFF)) { + data.color = 0; + } else { + data.color |= 0xFF000000; + } +} + +void SubState::Update() { + player_info_s info; + bool success = g_IEngine->GetPlayerInfo(parent.idx, &info); + if (!success) { + text = "N/A"; + return; + } + playerlist::userdata& data = playerlist::AccessData(info.friendsID); + if (parent.idx == g_IEngine->GetLocalPlayer()) { + text = "Local Player"; + return; + } + const int state = static_cast(data.state); + color_bg = playerlist::Color(info.friendsID); + if (state >= 0 && state <= static_cast(playerlist::k_EState::STATE_LAST)) { + text = playerlist::k_Names[state]; + } else { + text = "N/A"; + } +} + +bool SubState::ConsumesKey(ButtonCode_t key) { + return key == MOUSE_WHEEL_DOWN || key == MOUSE_WHEEL_UP; +} +void SubState::OnKeyPress(ButtonCode_t key, bool repeat) { + if (parent.idx == g_IEngine->GetLocalPlayer()) return; + player_info_s info; + bool success = g_IEngine->GetPlayerInfo(parent.idx, &info); + if (!success) return; + playerlist::userdata& data = playerlist::AccessData(info.friendsID); + int state = static_cast(data.state); + int change = 0; + if (key == MOUSE_WHEEL_UP) { + change = 1; + } else if (key == MOUSE_WHEEL_DOWN) { + change = -1; + } + int result = _clamp(0, static_cast(playerlist::k_EState::STATE_LAST), state + change); + data.state = static_cast(result); +} + +}} diff --git a/src/gui/ncc/PlayerListEntry.hpp b/src/gui/ncc/PlayerListEntry.hpp index 0c079bb5..a6ecd037 100644 --- a/src/gui/ncc/PlayerListEntry.hpp +++ b/src/gui/ncc/PlayerListEntry.hpp @@ -8,8 +8,63 @@ #ifndef PLAYERLISTENTRY_HPP_ #define PLAYERLISTENTRY_HPP_ +#include "Menu.hpp" +namespace menu { namespace ncc { +class PlayerListEntry : public CBaseContainer { +public: + PlayerListEntry(int eid); + inline virtual void SortByZIndex() override {}; + virtual void Draw(int x, int y) override; + virtual void MoveChildren() override; + virtual void Update() override; + virtual void OnKeyPress(ButtonCode_t key, bool repeat) override; +public: + const int idx; +}; +namespace entrysubs { + +class SubBase : public CBaseWidget { +public: + SubBase(PlayerListEntry&); + virtual void Draw(int x, int y) override; +public: + PlayerListEntry& parent; + int color_fg { 0 }; + int color_bg { 0 }; + std::string text { "" }; +}; +class SubTitle : public SubBase { +public: + SubTitle(PlayerListEntry& parent, const std::string& title); + virtual void Draw(int x, int y) override; +}; +class SubState : public SubBase { +public: + inline SubState(PlayerListEntry& parent) : SubBase(parent) {}; + virtual void Update() override; + virtual bool ConsumesKey(ButtonCode_t key) override; + virtual void OnKeyPress(ButtonCode_t key, bool repeat) override; +}; +class SubColorComponent : public SubBase { +public: + enum class Component { + R, + G, + B + }; + SubColorComponent(PlayerListEntry&, Component); + virtual void Update() override; + virtual bool ConsumesKey(ButtonCode_t key) override; + virtual void OnKeyPress(ButtonCode_t key, bool repeat) override; +public: + const Component component; +}; + +} + +}} #endif /* PLAYERLISTENTRY_HPP_ */ diff --git a/src/gui/ncc/Root.cpp b/src/gui/ncc/Root.cpp index 8901edb5..641df20f 100644 --- a/src/gui/ncc/Root.cpp +++ b/src/gui/ncc/Root.cpp @@ -36,6 +36,9 @@ void Root::Setup() { AddChild(new Radar()); menu::ncc::MainList().Show(); menu::ncc::MainList().SetOffset(draw::width / 2, draw::height / 2); + PlayerList* pl = new PlayerList(); + pl->SetOffset(200, 200); + AddChild(pl); } void Root::OnKeyPress(ButtonCode_t key, bool repeat) { diff --git a/src/hacks/Chams.cpp b/src/hacks/Chams.cpp deleted file mode 100644 index 87780b65..00000000 --- a/src/hacks/Chams.cpp +++ /dev/null @@ -1,202 +0,0 @@ -/* - * Chams.cpp - * - * Created on: Apr 15, 2017 - * Author: nullifiedcat - */ - -#include "../common.h" - -namespace hacks { namespace shared { namespace 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"); - -static bool init = false; - -CMaterialReference mat_unlit; -CMaterialReference mat_unlit_z; -CMaterialReference mat_lit; -CMaterialReference mat_lit_z; - -void Init() { - { - 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; -} - -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 (!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 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 (!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 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()) { - 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)) { - 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(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); - } - } 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(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); - } - - - } - } -}*/ - -}}} diff --git a/src/hacks/Chams.hpp b/src/hacks/Chams.hpp deleted file mode 100644 index 8e8cb9f5..00000000 --- a/src/hacks/Chams.hpp +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Chams.hpp - * - * Created on: Apr 15, 2017 - * Author: nullifiedcat - */ - -#ifndef HACKS_CHAMS_HPP_ -#define HACKS_CHAMS_HPP_ - -namespace hacks { namespace shared { namespace chams { - -//extern CatVar enable; - -//void DrawModelExecute(IVModelRender* _this, const DrawModelState_t& state, const ModelRenderInfo_t& info, matrix3x4_t* matrix); - -}}} - -#endif /* HACKS_CHAMS_HPP_ */ diff --git a/src/hacks/ESP.cpp b/src/hacks/ESP.cpp index d54884e1..c6cb2910 100644 --- a/src/hacks/ESP.cpp +++ b/src/hacks/ESP.cpp @@ -67,18 +67,6 @@ void AddEntityString(CachedEntity* entity, const std::string& string, int color) entity_data.string_count++; } -const std::string classes[] = { - "Scout", - "Sniper", - "Soldier", - "Demoman", - "Medic", - "Heavy", - "Pyro", - "Spy", - "Engineer" -}; - void CreateMove() { ResetEntityStrings(); int limit = HIGHEST_ENTITY; @@ -418,7 +406,7 @@ void ProcessEntity(CachedEntity* ent) { powerup_type power = GetPowerupOnPlayer(ent); // If target is enemy, always show powerups, if player is teammate, show powerups // only if bTeammatePowerup or bTeammates is true - if (legit && ent->m_iTeam != g_pLocalPlayer->team && playerlist::AccessData(ent).state != playerlist::k_EState::DEFAULT) { + if (legit && ent->m_iTeam != g_pLocalPlayer->team && playerlist::IsDefault(info.friendsID)) { if (IsPlayerInvisible(ent)) return; /*if (ent->m_lLastSeen > (unsigned)v_iLegitSeenTicks->GetInt()) { return; @@ -428,7 +416,7 @@ void ProcessEntity(CachedEntity* ent) { // FIXME Disabled powerup ESP. //AddEntityString(ent, format("HAS ", powerups[power])); } - if (ent->m_bEnemy || teammates || playerlist::AccessData(ent).state != playerlist::k_EState::DEFAULT) { + if (ent->m_bEnemy || teammates || !playerlist::IsDefault(info.friendsID)) { if (show_name) AddEntityString(ent, std::string(info.name)); if (show_class) { @@ -496,14 +484,14 @@ void ProcessEntityPT(CachedEntity* ent) { switch (ent->m_Type) { case ENTITY_PLAYER: { bool cloak = IsPlayerInvisible(ent); - if (legit && ent->m_iTeam != g_pLocalPlayer->team && playerlist::AccessData(ent).state == playerlist::k_EState::DEFAULT) { + if (legit && ent->m_iTeam != g_pLocalPlayer->team && playerlist::IsDefault(ent)) { if (cloak) return; /*if (ent->m_lLastSeen > v_iLegitSeenTicks->GetInt()) { return; }*/ } - if (!ent->m_bEnemy && !teammates && playerlist::AccessData(ent).state == playerlist::k_EState::DEFAULT) break; + if (!ent->m_bEnemy && !teammates && playerlist::IsDefault(ent)) break; if (!ent->m_bAlivePlayer) break; if (vischeck && !ent->IsVisible()) transparent = true; if (transparent) fg = colors::Transparent(fg); diff --git a/src/hacks/hacklist.h b/src/hacks/hacklist.h index d0d1ae9c..eac379f3 100644 --- a/src/hacks/hacklist.h +++ b/src/hacks/hacklist.h @@ -22,7 +22,6 @@ #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/helpers.cpp b/src/helpers.cpp index 67badbc4..cb6e82ba 100644 --- a/src/helpers.cpp +++ b/src/helpers.cpp @@ -872,8 +872,7 @@ const char* powerups[] = { "CRITS" }; -const char* tfclasses[] = { - "[NULL]", +const std::string classes[] = { "Scout", "Sniper", "Soldier", diff --git a/src/helpers.h b/src/helpers.h index 336fd53d..1ccb5a4e 100644 --- a/src/helpers.h +++ b/src/helpers.h @@ -132,7 +132,7 @@ std::string format(const Args&... args) { return stream.str(); } -extern const char* tfclasses[10]; +extern const std::string classes[10]; extern const char* powerups[POWERUP_COUNT]; #endif /* HELPERS_H_ */ diff --git a/src/hooks/others.cpp b/src/hooks/others.cpp index d0b9958e..68207496 100644 --- a/src/hooks/others.cpp +++ b/src/hooks/others.cpp @@ -295,6 +295,7 @@ void LevelInit_hook(void* thisptr, const char* newmap) { bool CanInspect_hook(IClientEntity*) { return true; } void LevelShutdown_hook(void* thisptr) { + playerlist::Save(); ((LevelShutdown_t*) hooks::hkClientMode->GetMethod(hooks::offLevelShutdown))(thisptr); g_Settings.bInvalid = true; hacks::shared::aimbot::Reset(); diff --git a/src/netvars.cpp b/src/netvars.cpp index cf6c1705..7f76373e 100644 --- a/src/netvars.cpp +++ b/src/netvars.cpp @@ -22,6 +22,7 @@ void NetVars::Init() { this->movetype = gNetvars.get_offset("DT_BaseEntity", "movetype"); this->m_Collision = gNetvars.get_offset("DT_BaseEntity", "m_Collision"); if (TF2) { + res_m_iTeam = gNetvars.get_offset("DT_TFPlayerResource", "baseclass", "m_iTeam"); m_angEyeAngles = gNetvars.get_offset("DT_TFPlayer", "tfnonlocaldata", "m_angEyeAngles[0]"); this->bGlowEnabled = gNetvars.get_offset("DT_TFPlayer", "m_bGlowEnabled"); this->iMaxBuffedHealth = gNetvars.get_offset("DT_TFPlayerResource", "m_iMaxBuffedHealth"); diff --git a/src/netvars.h b/src/netvars.h index 715f1e36..2b6ecca5 100644 --- a/src/netvars.h +++ b/src/netvars.h @@ -123,6 +123,7 @@ public: offset_t m_angEyeAngles; offset_t m_bReadyToBackstab; offset_t m_Collision; + offset_t res_m_iTeam; }; extern NetVars netvar; diff --git a/src/playerlist.cpp b/src/playerlist.cpp index 835d9c51..f3d11241 100644 --- a/src/playerlist.cpp +++ b/src/playerlist.cpp @@ -125,7 +125,17 @@ userdata& AccessData(CachedEntity* player) { if (CE_GOOD(player) && player->m_pPlayerInfo) return AccessData(player->m_pPlayerInfo->friendsID); return AccessData(0U); +} +bool IsDefault(unsigned steamid) { + const userdata& data = AccessData(steamid); + return data.state == k_EState::DEFAULT && !data.color; +} + +bool IsDefault(CachedEntity* entity) { + if (CE_GOOD(entity) && entity->m_pPlayerInfo) + return IsDefault(entity->m_pPlayerInfo->friendsID); + return true; } CatCommand pl_save("pl_save", "Save playerlist", Save); diff --git a/src/playerlist.hpp b/src/playerlist.hpp index 7fd49107..c792723f 100644 --- a/src/playerlist.hpp +++ b/src/playerlist.hpp @@ -47,6 +47,8 @@ int Color(unsigned steamid); int Color(CachedEntity* player); userdata& AccessData(unsigned steamid); userdata& AccessData(CachedEntity* player); +bool IsDefault(unsigned steamid); +bool IsDefault(CachedEntity* player); } diff --git a/src/playerresource.cpp b/src/playerresource.cpp index 694037f5..929dd8da 100644 --- a/src/playerresource.cpp +++ b/src/playerresource.cpp @@ -33,6 +33,11 @@ int TFPlayerResource::GetMaxBuffedHealth(CachedEntity* player) { return *(int*)((unsigned int)RAW_ENT(m_pEntity) + netvar.iMaxBuffedHealth + 4 * idx); } +int TFPlayerResource::GetTeam(int idx) { + if (idx >= 64 || idx < 0) return 0; + return *(int*)((unsigned int)RAW_ENT(m_pEntity) + netvar.res_m_iTeam + 4 * idx); +} + int TFPlayerResource::GetClass(CachedEntity* player) { if (CE_BAD(m_pEntity)) return 0; int idx = player->m_IDX; diff --git a/src/playerresource.h b/src/playerresource.h index d86859a3..91498bf0 100644 --- a/src/playerresource.h +++ b/src/playerresource.h @@ -16,6 +16,7 @@ public: int GetMaxHealth(CachedEntity* player); int GetMaxBuffedHealth(CachedEntity* player); int GetClass(CachedEntity* player); + int GetTeam(int idx); CachedEntity* m_pEntity; };