b1g playerlist

This commit is contained in:
nullifiedcat 2017-04-21 23:20:34 +03:00
parent ae0fcb087a
commit 280da4d06e
23 changed files with 405 additions and 252 deletions

View File

@ -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;

View File

@ -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;

15
src/gui/guicommon.h Normal file
View File

@ -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_ */

View File

@ -15,6 +15,8 @@ class CatVar;
namespace menu { namespace ncc {
class List; // ????
class ItemSublist : public Item {
public:
ItemSublist(std::string title, List* list);

View File

@ -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;

View File

@ -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);
}
}}

View File

@ -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_ */

View File

@ -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<SubBase*>(ChildByIndex(1));
SubBase* steamid = dynamic_cast<SubBase*>(ChildByIndex(2));
SubBase* name = dynamic_cast<SubBase*>(ChildByIndex(3));
SubBase* clazz = dynamic_cast<SubBase*>(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<unsigned char*>(&color_bg)[static_cast<int>(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<unsigned char*>(&data.color)[static_cast<int>(component)]) + change);
(reinterpret_cast<unsigned char*>(&data.color)[static_cast<int>(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<int>(data.state);
color_bg = playerlist::Color(info.friendsID);
if (state >= 0 && state <= static_cast<int>(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<int>(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<int>(playerlist::k_EState::STATE_LAST), state + change);
data.state = static_cast<playerlist::k_EState>(result);
}
}}

View File

@ -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_ */

View File

@ -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) {

View File

@ -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<bool(*)(IClientEntity*)>(entity, 0xBE, 0)(entity)) {
IClientEntity* owner = vfunc<IClientEntity*(*)(IClientEntity*)>(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<bool(*)(IClientEntity*)>(entity, 0xBE, 0)(entity)) {
IClientEntity* owner = vfunc<IClientEntity*(*)(IClientEntity*)>(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<bool(*)(IClientEntity*)>(entity, 0xBE, 0)(entity)) {
IClientEntity* owner = vfunc<IClientEntity*(*)(IClientEntity*)>(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);
}
}
}
}*/
}}}

View File

@ -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_ */

View File

@ -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);

View File

@ -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"

View File

@ -872,8 +872,7 @@ const char* powerups[] = {
"CRITS"
};
const char* tfclasses[] = {
"[NULL]",
const std::string classes[] = {
"Scout",
"Sniper",
"Soldier",

View File

@ -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_ */

View File

@ -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();

View File

@ -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");

View File

@ -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;

View File

@ -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);

View File

@ -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);
}

View File

@ -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;

View File

@ -16,6 +16,7 @@ public:
int GetMaxHealth(CachedEntity* player);
int GetMaxBuffedHealth(CachedEntity* player);
int GetClass(CachedEntity* player);
int GetTeam(int idx);
CachedEntity* m_pEntity;
};