added class

This commit is contained in:
nullifiedcat 2017-01-19 19:17:30 +03:00
parent 1371277468
commit 578942a8c5
8 changed files with 35 additions and 3 deletions

View File

@ -7,6 +7,7 @@ SteamID DRM
FIX crash
FIX conds
Player List
dominatesay assistsay worldsay
DS esp slow
MAX -> MIN priority

View File

@ -14,6 +14,19 @@ DEFINE_HACK_SINGLETON(KillSay);
const char* KillSay::GetName() { return "KILLSAY"; }
const char* tf_classes_killsay[] = {
"class",
"scout",
"sniper",
"soldier",
"demoman",
"medic",
"heavy",
"pyro",
"spy",
"engineer"
};
void KillSayEventListener::FireGameEvent(IGameEvent* event) {
if (!g_phKillSay->v_bEnabled->GetBool()) return;
SEGV_BEGIN;
@ -34,6 +47,9 @@ const char* KillSay::ComposeKillSay(IGameEvent* event) {
player_info_s info;
interfaces::engineClient->GetPlayerInfo(interfaces::engineClient->GetPlayerForUserID(vid), &info);
ReplaceString(msg, "%name%", info.name);
CachedEntity* ent = ENTITY(interfaces::engineClient->GetPlayerForUserID(vid));
int clz = g_pPlayerResource->GetClass(ent);
ReplaceString(msg, "%class%", (char*)tf_classes_killsay[clz]);
return msg;
}
@ -77,7 +93,7 @@ void KillSay::LoadFile() {
void KillSay::PushStack(const char* text) {
if (m_nStackTop == KILLSAY_STACK_SIZE - 1) return;
strncpy(m_Stack[++m_nStackTop].data, text, 255);
logging::Info("Pushed, new stacktop: %i", m_nStackTop);
//logging::Info("Pushed, new stacktop: %i", m_nStackTop);
}
char256* KillSay::PopStack() {

View File

@ -26,7 +26,11 @@ void BeginConVars() {
}
void EndConVars() {
if (hConVarsFile) fclose(hConVarsFile);
if (hConVarsFile) {
fprintf(hConVarsFile, "exec cat_autoexec");
fprintf(hConVarsFile, "cat_killsay_reload");
fclose(hConVarsFile);
}
ConVar_Register();
}

View File

@ -27,8 +27,9 @@ void PaintTraverse_hook(void* p, unsigned int vp, bool fr, bool ar) {
static bool autoexec_done = false;
if (!autoexec_done) {
interfaces::engineClient->ExecuteClientCmd("exec cat_autoexec");
interfaces::engineClient->ExecuteClientCmd("cat_killsay_reload");
autoexec_done = true;
}
autoexec_done = true;
#if NO_IPC != true
if (g_phFollowBot->v_bEnabled->GetBool()) {
ipc_client_seg* seg_g = g_phFollowBot->m_pIPC->GetClientSegment(0);

View File

@ -62,6 +62,7 @@ void NetVars::Init() {
this->Rocket_bCritical = gNetvars.get_offset("DT_TFProjectile_Rocket", "m_bCritical");
this->Grenade_bCritical = gNetvars.get_offset("DT_TFWeaponBaseGrenadeProj", "m_bCritical");
this->_condition_bits = gNetvars.get_offset("DT_TFPlayer", "m_Shared", "m_ConditionList", "_condition_bits");
this->iPlayerClass = gNetvars.get_offset("DT_TFPlayerResource", "m_iPlayerClass");
}
void InitNetVars() {

View File

@ -107,6 +107,7 @@ public:
offset_t iDefaultFOV;
offset_t iFOV;
offset_t _condition_bits;
offset_t iPlayerClass;
};
extern NetVars netvar;

View File

@ -31,5 +31,12 @@ int TFPlayerResource::GetMaxBuffedHealth(CachedEntity* player) {
return *(int*)((unsigned int)RAW_ENT(m_pEntity) + netvar.iMaxBuffedHealth + 4 * idx);
}
int TFPlayerResource::GetClass(CachedEntity* player) {
if (CE_BAD(m_pEntity)) return 0;
int idx = player->m_IDX;
if (idx >= 64 || idx < 0) return 0;
return *(int*)((unsigned int)RAW_ENT(m_pEntity) + netvar.iPlayerClass + 4 * idx);
}
TFPlayerResource* g_pPlayerResource = 0;

View File

@ -15,6 +15,7 @@ public:
void Update();
int GetMaxHealth(CachedEntity* player);
int GetMaxBuffedHealth(CachedEntity* player);
int GetClass(CachedEntity* player);
CachedEntity* m_pEntity;
};