OMAN I AM NOT GOOD WITH COMPUTERS PLZ TO HELP
This commit is contained in:
parent
f4f47df3a7
commit
d02db0cdb4
@ -5,12 +5,13 @@
|
||||
* Author: nullifiedcat
|
||||
*/
|
||||
|
||||
#ifdef IPC_ENABLED
|
||||
|
||||
#include "FollowBot.h"
|
||||
|
||||
#include "../common.h"
|
||||
|
||||
#ifdef IPC_ENABLED
|
||||
|
||||
namespace hacks { namespace shared { namespace followbot {
|
||||
|
||||
unsigned follow_steamid { 0 };
|
||||
|
142
src/hacks/SkinChanger.cpp
Normal file
142
src/hacks/SkinChanger.cpp
Normal file
@ -0,0 +1,142 @@
|
||||
/*
|
||||
* SkinChanger.cpp
|
||||
*
|
||||
* Created on: May 4, 2017
|
||||
* Author: nullifiedcat
|
||||
*/
|
||||
|
||||
#include "SkinChanger.hpp"
|
||||
|
||||
namespace hacks { namespace tf2 { namespace skinchanger {
|
||||
|
||||
CAttribute::CAttribute(uint16_t iAttributeDefinitionIndex, float flValue) {
|
||||
data.defidx = iAttributeDefinitionIndex;
|
||||
data.value = flValue;
|
||||
}
|
||||
|
||||
void CAttributeList::RemoveAttribute(int index) {
|
||||
for (int i = 0; i < m_Attributes.Count(); i++) {
|
||||
const auto& a = m_Attributes[i];
|
||||
if (a.data.defidx == index) {
|
||||
m_Attributes.Remove(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CAttributeList::SetAttribute(int index, float value) {
|
||||
// Let's check if attribute exists already. We don't want dupes.
|
||||
for (int i = 0; i < m_Attributes.Count(); i++) {
|
||||
auto& a = m_Attributes[i];
|
||||
if (a.data.defidx == index) {
|
||||
a.data.value = value;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_Attributes.Count() > 14)
|
||||
return;
|
||||
|
||||
m_Attributes.AddToTail(CAttribute { index, value });
|
||||
}
|
||||
|
||||
static CatVar enabled(CV_SWITCH, "skinchanger", "0", "Skin Changer");
|
||||
static CatCommand set_attr("skinchanger_set", "Set Attribute", [](const CCommand& args) {
|
||||
unsigned attrid = strtoul(args.Arg(1), nullptr, 10);
|
||||
unsigned attrv = strtoul(args.Arg(2), nullptr, 10);
|
||||
GetModifier(LOCAL_W->m_IDX).Set(attrid, attrv);
|
||||
InvalidateCookies();
|
||||
});
|
||||
|
||||
void FrameStageNotify(int stage) {
|
||||
if (!enabled) return;
|
||||
CachedEntity* weapon = LOCAL_W;
|
||||
if (CE_BAD(weapon)) return;
|
||||
if (!GetCookie(weapon->m_IDX).Check()) {
|
||||
logging::Info("Cookie bad for %i", weapon->m_IDX); // FIXME DEBUG LOGS!
|
||||
GetModifier(CE_INT(weapon, netvar.iItemDefinitionIndex)).Apply(weapon->m_IDX);
|
||||
GetCookie(weapon->m_IDX).Update(weapon->m_IDX);
|
||||
}
|
||||
}
|
||||
|
||||
void PaintTraverse() {
|
||||
if (!enabled) return;
|
||||
// Debug info?
|
||||
}
|
||||
|
||||
void def_attribute_modifier::Set(int id, float value) {
|
||||
for (auto& i : modifiers) {
|
||||
if (i.defidx == id) {
|
||||
i.value = value;
|
||||
return;
|
||||
}
|
||||
}
|
||||
attribute_s& attr = modifiers.at(modifiers.size());
|
||||
attr.defidx = id;
|
||||
attr.value = value;
|
||||
}
|
||||
|
||||
void InvalidateCookies() {
|
||||
logging::Info("All cookies invalidated!"); // FIXME DEBUG LOGS!
|
||||
for (auto& cookie : cookie_map) {
|
||||
cookie.second.valid = false;
|
||||
}
|
||||
}
|
||||
|
||||
patched_weapon_cookie::patched_weapon_cookie(int entity) {
|
||||
Update(entity);
|
||||
}
|
||||
|
||||
void patched_weapon_cookie::Update(int entity) {
|
||||
IClientEntity* ent = g_IEntityList->GetClientEntity(entity);
|
||||
if (!ent || ent->IsDormant()) return;
|
||||
logging::Info("Updating cookie for %i", entity); // FIXME DEBUG LOGS!
|
||||
eidx = entity;
|
||||
defidx = NET_INT(ent, netvar.iItemDefinitionIndex);
|
||||
eclass = ent->GetClientClass()->m_ClassID;
|
||||
valid = true;
|
||||
}
|
||||
|
||||
bool patched_weapon_cookie::Check() {
|
||||
if (!valid) return false;
|
||||
IClientEntity* ent = g_IEntityList->GetClientEntity(eidx);
|
||||
if (!ent || ent->IsDormant()) return false;
|
||||
if (eclass != ent->GetClientClass()->m_ClassID) return false;
|
||||
if (defidx != NET_INT(ent, netvar.iItemDefinitionIndex)) return false;
|
||||
}
|
||||
|
||||
void def_attribute_modifier::Apply(int entity) {
|
||||
IClientEntity* ent = g_IEntityList->GetClientEntity(entity);
|
||||
if (!ent || ent->IsDormant()) return;
|
||||
CAttributeList* list = NET_VAR(ent, netvar.AttributeList, CAttributeList*);
|
||||
logging::Info("Applying modifiers for %i", entity);
|
||||
for (const auto& mod : modifiers) {
|
||||
if (mod.defidx) {
|
||||
logging::Info("Setting %i to %.2f", mod.defidx, mod.value); // FIXME DEBUG LOGS!
|
||||
list->SetAttribute(mod.defidx, mod.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def_attribute_modifier& GetModifier(int idx) {
|
||||
try {
|
||||
return modifier_map.at(idx);
|
||||
} catch (std::out_of_range& oor) {
|
||||
modifier_map.emplace(idx, def_attribute_modifier{});
|
||||
return modifier_map.at(idx);
|
||||
}
|
||||
}
|
||||
|
||||
patched_weapon_cookie& GetCookie(int idx) {
|
||||
try {
|
||||
return cookie_map.at(idx);
|
||||
} catch (std::out_of_range& oor) {
|
||||
cookie_map.emplace(idx, patched_weapon_cookie{idx});
|
||||
return cookie_map.at(idx);
|
||||
}
|
||||
}
|
||||
|
||||
std::unordered_map<int, def_attribute_modifier> modifier_map {};
|
||||
std::unordered_map<int, patched_weapon_cookie> cookie_map {};
|
||||
|
||||
}}}
|
87
src/hacks/SkinChanger.hpp
Normal file
87
src/hacks/SkinChanger.hpp
Normal file
@ -0,0 +1,87 @@
|
||||
/*
|
||||
* SkinChanger.hpp
|
||||
*
|
||||
* Created on: May 4, 2017
|
||||
* Author: nullifiedcat
|
||||
*/
|
||||
|
||||
#ifndef HACKS_SKINCHANGER_HPP_
|
||||
#define HACKS_SKINCHANGER_HPP_
|
||||
|
||||
#include "../common.h"
|
||||
|
||||
namespace hacks { namespace tf2 { namespace skinchanger {
|
||||
|
||||
// TOTALLY NOT A PASTE.
|
||||
// Seriously tho, it's modified at least.
|
||||
// Credits: blackfire62
|
||||
|
||||
struct attribute_s {
|
||||
uint16_t defidx;
|
||||
float value;
|
||||
};
|
||||
|
||||
class CAttribute {
|
||||
public:
|
||||
CAttribute(uint16_t iAttributeDefinitionIndex, float flValue);
|
||||
public:
|
||||
uint32_t pad00;
|
||||
attribute_s data;
|
||||
uint32_t pad01;
|
||||
};
|
||||
|
||||
class CAttributeList {
|
||||
public:
|
||||
void SetAttribute(int index, float value);
|
||||
void RemoveAttribute(int index);
|
||||
public:
|
||||
uint32_t pad00;
|
||||
CUtlVector<CAttribute, CUtlMemory<CAttribute>> m_Attributes;
|
||||
};
|
||||
|
||||
enum class Attributes {
|
||||
loot_rarity = 2022,
|
||||
is_australium_item = 2027,
|
||||
item_style_override = 542,
|
||||
sheen = 2014,
|
||||
killstreak_tier = 2025
|
||||
};
|
||||
|
||||
enum class UnusualEffects {
|
||||
HOT = 701,
|
||||
ISOTOPE,
|
||||
COOL,
|
||||
ENERGY_ORB
|
||||
};
|
||||
|
||||
struct patched_weapon_cookie {
|
||||
patched_weapon_cookie(int entity);
|
||||
void Update(int entity);
|
||||
bool Check();
|
||||
public:
|
||||
int eidx { 0 };
|
||||
int defidx { 0 };
|
||||
int eclass { 0 };
|
||||
bool valid { false };
|
||||
};
|
||||
|
||||
struct def_attribute_modifier {
|
||||
void Apply(int entity);
|
||||
void Set(int id, float value);
|
||||
int defidx { 0 };
|
||||
std::array<attribute_s, 15> modifiers { attribute_s{ 0, 0 } };
|
||||
};
|
||||
|
||||
extern std::unordered_map<int, def_attribute_modifier> modifier_map;
|
||||
extern std::unordered_map<int, patched_weapon_cookie> cookie_map;
|
||||
|
||||
def_attribute_modifier& GetModifier(int idx);
|
||||
patched_weapon_cookie& GetCookie(int idx);
|
||||
|
||||
void InvalidateCookies();
|
||||
void FrameStageNotify(int stage);
|
||||
void PaintTraverse();
|
||||
|
||||
}}}
|
||||
|
||||
#endif /* HACKS_SKINCHANGER_HPP_ */
|
@ -24,6 +24,7 @@
|
||||
#include "Trigger.h"
|
||||
#include "KillSay.h"
|
||||
#include "UberSpam.hpp"
|
||||
#include "SkinChanger.hpp"
|
||||
#include "Achievement.h"
|
||||
#include "Spam.h"
|
||||
#include "Noisemaker.h"
|
||||
|
@ -157,6 +157,7 @@ void PaintTraverse_hook(void* _this, unsigned int vp, bool fr, bool ar) {
|
||||
SAFE_CALL(hacks::shared::esp::Draw());
|
||||
if (TF) SAFE_CALL(hacks::tf::spyalert::Draw());
|
||||
if (TF) SAFE_CALL(hacks::tf::radar::Draw());
|
||||
if (TF2) SAFE_CALL(hacks::tf2::skinchanger::PaintTraverse());
|
||||
}
|
||||
|
||||
|
||||
|
@ -179,6 +179,7 @@ void FrameStageNotify_hook(void* _this, int stage) {
|
||||
SEGV_BEGIN;
|
||||
if (!g_IEngine->IsInGame()) g_Settings.bInvalid = true;
|
||||
// TODO hack FSN hook
|
||||
hacks::tf2::skinchanger::FrameStageNotify(stage);
|
||||
if (resolver && cathook && !g_Settings.bInvalid && stage == FRAME_NET_UPDATE_POSTDATAUPDATE_START) {
|
||||
for (int i = 1; i < 32 && i < HIGHEST_ENTITY; i++) {
|
||||
if (i == g_IEngine->GetLocalPlayer()) continue;
|
||||
|
@ -5,13 +5,14 @@
|
||||
* Author: nullifiedcat
|
||||
*/
|
||||
|
||||
#ifdef IPC_ENABLED
|
||||
|
||||
#include "ipc.h"
|
||||
|
||||
#include "common.h"
|
||||
#include "hack.h"
|
||||
|
||||
#ifdef IPC_ENABLED
|
||||
|
||||
namespace ipc {
|
||||
|
||||
std::atomic<bool> thread_running(false);
|
||||
|
Reference in New Issue
Block a user