jhjhjgjhjgh

This commit is contained in:
nullifiedcat 2016-11-05 13:44:54 +03:00
parent 416850b6f7
commit 04f7d4e6b5
27 changed files with 0 additions and 1833 deletions

View File

@ -1,125 +0,0 @@
/*
* CDumper.h
*
* Created on: Oct 5, 2016
* Author: nullifiedcat
*/
#ifndef CDUMPER_H_
#define CDUMPER_H_
#include <cstring>
#include <fstream>
#include "logging.h"
#include "fixsdk.h"
#include <dt_common.h>
#include <client_class.h>
class CDumper
{
std::fstream m_file;
char* TypeToString(SendPropType type)
{
//logging::Info("inside...");
char* ret = "UNKNOWN";
//logging::Info("oh my");
//logging::Info("ret.. %s", ret);
if (type == 0) {
ret = "INT";
} else if (type == 1) {
ret = "FLOAT";
} else if (type == 2) {
ret = "VECTOR3";
} else if (type == 3) {
ret = "VECTOR2";
} else if (type == 4) {
ret = "STRING";
} else if (type == 5) {
ret = "ARRAY";
} else if (type == 6) {
ret = "TABLE";
}
//logging::Info("returning %s", ret);
return ret;
}
public:
CDumper()
{
//logging::Info("opening file...");
m_file.open("/tmp/netdump.txt", std::ios::out | std::ios::trunc);
//logging::Info("file: %i", m_file.good());
}
~CDumper()
{
m_file.close();
}
void SaveDump()
{
logging::Info("Dumping..");
ClientClass *pList = interfaces::baseClient->GetAllClasses();
//logging::Info("iterating...");
while(pList)
{
DumpTable(pList->m_pRecvTable, 0);
pList = pList->m_pNext;
}
m_file.close();
}
void DumpTable(RecvTable *pTable, int iLevel)
{
if(!pTable)
return;
//logging::Info("dumping table.. %s", pTable->GetName());
for(int j = 0; j < iLevel; j++)
m_file << " ";
m_file << pTable->GetName() << std::endl;
iLevel += 2;
for(int i = 0; i < pTable->GetNumProps(); ++i)
{
//logging::Info("dumping prop.. %i out of %i..", i, pTable->GetNumProps());
RecvProp *pProp = pTable->GetProp(i);
//logging::Info("it has name %s", pProp->GetName());
if(!pProp)
continue;
if(isdigit(pProp->GetName()[0]))
continue;
if(pProp->GetDataTable())
{
DumpTable(pProp->GetDataTable(), iLevel + 1);
}
for(int j = 0; j < iLevel; j++)
m_file << " ";
int offset = pProp->GetOffset();
//logging::Info("offset %i", offset);
SendPropType type = pProp->GetType();
//logging::Info("type.. %i", type);
char* typestr = TypeToString(type);
//logging::Info("back from tts");
//logging::Info("type str %s", typestr);
m_file << pProp->GetName() << " : 0x" << std::hex << offset << " [" << typestr << "]" << std::endl;
}
if(iLevel == 2)
m_file << std::endl;
}
};
#endif /* CDUMPER_H_ */

View File

@ -1,80 +0,0 @@
/*
* drawing.cpp
*
* Created on: Oct 5, 2016
* Author: nullifiedcat
*/
#include "drawing.h"
#include "interfaces.h"
#include "fixsdk.h"
#include <vgui/ISurface.h>
#include <Color.h>
#include <cdll_int.h>
#include <mathlib/vmatrix.h>
// TODO globals
unsigned long draw::font_handle = 0;
unsigned long draw::panel_top = 0;
unsigned long draw::font_handle_large = 0;
int draw::width = 0;
int draw::height = 0;
Color draw::white(255, 255, 255, 255);
Color draw::red(184, 56, 59, 255);
Color draw::blue(88, 133, 162, 255);
Color draw::yellow(255, 255, 0, 255);
void draw::Initialize() {
draw::font_handle = interfaces::surface->CreateFont();
draw::font_handle_large = interfaces::surface->CreateFont();
interfaces::surface->SetFontGlyphSet(draw::font_handle, "Tahoma", 15, 500, 0, 0, 0x010 | 0x200);
interfaces::surface->SetFontGlyphSet(draw::font_handle_large, "Tahoma", 32, 500, 0, 0, 0x200);
}
void draw::DrawString(unsigned long font, int x, int y, Color color, const wchar_t* text) {
interfaces::surface->DrawSetTextPos(x, y);
interfaces::surface->DrawSetTextColor(color);
interfaces::surface->DrawSetTextFont(draw::font_handle);
interfaces::surface->DrawPrintText(text, wcslen(text));
}
void draw::DrawString(int x, int y, Color color, bool center, const char* text, ...) {
va_list list;
char buffer[1024] = { '\0' };
wchar_t string[1024] = { '\0' };
va_start(list, text);
vsprintf(buffer, text, list);
va_end(list);
swprintf(string, 1024, L"%s", buffer);
if (center) {
int l, h;
draw::GetStringLength(string, l, h);
x -= (l / 2);
}
draw::DrawString(draw::font_handle, x, y, color, string);
}
bool draw::WorldToScreen(Vector& origin, Vector& screen) {
VMatrix wts = interfaces::engineClient->WorldToScreenMatrix();
screen.z = 0;
float w = wts[3][0] * origin[0] + wts[3][1] * origin[1] + wts[3][2] * origin[2] + wts[3][3];
if (w > 0.001) {
float odw = 1.0f / w;
screen.x = (draw::width / 2) + (0.5 * ((wts[0][0] * origin[0] + wts[0][1] * origin[1] + wts[0][2] * origin[2] + wts[0][3]) * odw) * draw::width + 0.5);
screen.y = (draw::height / 2) - (0.5 * ((wts[1][0] * origin[0] + wts[1][1] * origin[1] + wts[1][2] * origin[2] + wts[1][3]) * odw) * draw::height + 0.5);
return true;
}
return false;
}
void draw::OutlineRect(int x, int y, int w, int h, Color color) {
interfaces::surface->DrawSetColor(color);
interfaces::surface->DrawOutlinedRect(x, y, x + w, y + h);
}
void draw::GetStringLength(wchar_t* string, int& length, int& height) {
//wchar_t buf[1024] = {'\0'};
//mbstowcs(buf, string, strlen(string));
interfaces::surface->GetTextSize(draw::font_handle, string, length, height);
}

View File

@ -1,35 +0,0 @@
/*
* drawing.h
*
* Created on: Oct 5, 2016
* Author: nullifiedcat
*/
#ifndef DRAWING_H_
#define DRAWING_H_
class Color;
class Vector;
namespace draw {
extern unsigned long font_handle;
extern unsigned long font_handle_large;
extern unsigned long panel_top;
extern int width;
extern int height;
extern Color white;
extern Color blue;
extern Color red;
extern Color yellow;
void Initialize();
void DrawString(unsigned long font, int x, int y, Color color, const wchar_t* text);
void DrawString(int x, int y, Color color, bool center, const char* text, ...);
bool WorldToScreen(Vector &origin, Vector &screen);
void OutlineRect(int x, int y, int w, int h, Color color);
void GetStringLength(wchar_t* string, int& length, int& height);
}
#endif /* DRAWING_H_ */

View File

@ -1,38 +0,0 @@
/*
a * entity.cpp
*
* Created on: Oct 6, 2016
* Author: nullifiedcat
*/
#include "entity.h"
#include "copypasted/Netvar.h"
#include "logging.h"
// TODO globals
EntityVariables eoffsets;
void EntityVariables::Init() {
this->iCond = gNetvars.get_offset("DT_TFPlayer", "m_Shared", "m_nPlayerCond");
this->iFlags = gNetvars.get_offset("DT_BasePlayer", "m_fFlags");
this->iHealth = gNetvars.get_offset("DT_BasePlayer", "m_iHealth");
this->iLifeState = gNetvars.get_offset("DT_BasePlayer", "m_lifeState");
this->iTeamNum = gNetvars.get_offset("DT_BaseEntity", "m_iTeamNum");
this->iClass = gNetvars.get_offset("DT_TFPlayer", "m_PlayerClass", "m_iClass");
this->vViewOffset = gNetvars.get_offset("DT_BasePlayer", "localdata", "m_vecViewOffset[0]");
this->hActiveWeapon = gNetvars.get_offset("DT_BaseCombatCharacter", "m_hActiveWeapon");
this->flChargedDamage = gNetvars.get_offset("DT_TFSniperRifle", "SniperRifleLocalData", "m_flChargedDamage");
this->iUpgradeLevel = gNetvars.get_offset("DT_BaseObject", "m_iUpgradeLevel");
this->iPipeType = gNetvars.get_offset("DT_TFProjectile_Pipebomb", "m_iType");
this->iBuildingHealth = gNetvars.get_offset("DT_BaseObject", "m_iHealth");
this->iCond1 = gNetvars.get_offset("DT_TFPlayer", "m_Shared", "m_nPlayerCondEx");
this->iCond2 = gNetvars.get_offset("DT_TFPlayer", "m_Shared", "m_nPlayerCondEx2");
this->iCond3 = gNetvars.get_offset("DT_TFPlayer", "m_Shared", "m_nPlayerCondEx3");
this->iHitboxSet = gNetvars.get_offset("DT_BaseAnimating", "m_nHitboxSet");
this->vVelocity = gNetvars.get_offset("DT_BasePlayer", "localdata", "m_vecVelocity[0]");
this->bGlowEnabled = gNetvars.get_offset("DT_TFPlayer", "m_bGlowEnabled");
}
void InitEntityOffsets() {
eoffsets.Init();
}

View File

@ -1,60 +0,0 @@
/*
* entity.h
*
* Created on: Oct 6, 2016
* Author: nullifiedcat
*/
#ifndef ENTITY_H_
#define ENTITY_H_
#include "logging.h"
class IClientEntity;
// TODO globals
typedef unsigned int offset_t;
template<typename T>
inline T GetEntityValue(IClientEntity* ent, unsigned int offset) {
int null = 0;
if (ent == 0) return *(reinterpret_cast<T*>(&null));
//logging::Info("GetEntityValue 0x%08x, 0x%08x", ent, offset);
return *(reinterpret_cast<T*>((unsigned int)ent + offset));
}
template<typename T>
void SetEntityValue(IClientEntity* ent, unsigned int offset, T value) {
*(reinterpret_cast<T*>((unsigned int)ent + offset)) = value;
}
void InitEntityOffsets();
class EntityVariables {
public:
void Init();
offset_t iTeamNum;
offset_t iFlags;
offset_t iHealth;
offset_t iLifeState;
offset_t iCond;
offset_t iCond1;
offset_t iCond2;
offset_t iCond3;
offset_t iClass;
offset_t vViewOffset;
offset_t hActiveWeapon;
offset_t flChargedDamage;
offset_t iUpgradeLevel;
offset_t iPipeType;
offset_t iBuildingHealth;
offset_t iHitboxSet;
offset_t vVelocity;
offset_t bGlowEnabled;
offset_t iGlowIndex;
};
// TODO globals
extern EntityVariables eoffsets;
#endif /* ENTITY_H_ */

View File

@ -1,52 +0,0 @@
/*
* entry.cpp
*
* Created on: Oct 3, 2016
* Author: nullifiedcat
*/
#include <pthread.h>
#include <string>
#include "hack.h"
#include "fixsdk.h"
#include <tier1/convar.h>
// TODO globals
pthread_mutex_t mutex_quit;
pthread_t thread_main;
bool IsStopping(pthread_mutex_t* mutex_quit_l) {
if (!pthread_mutex_trylock(mutex_quit_l)) {
pthread_mutex_unlock(mutex_quit_l);
return true;
} else {
return false;
}
return true;
}
void* MainThread(void* arg) {
pthread_mutex_t* mutex_quit_l = (pthread_mutex_t*) arg;
hack::Initialize();
while (!IsStopping(mutex_quit_l)) {
hack::Think();
}
hack::Shutdown();
return 0;
}
void __attribute__((constructor)) attach() {
std::string test_str = "test";
pthread_mutex_init(&mutex_quit, 0);
pthread_mutex_lock(&mutex_quit);
pthread_create(&thread_main, 0, MainThread, &mutex_quit);
}
void __attribute__((destructor)) detach() {
pthread_mutex_unlock(&mutex_quit);
pthread_join(thread_main, 0);
}

View File

@ -1,167 +0,0 @@
/*
* enums.h
*
* Created on: Oct 7, 2016
* Author: nullifiedcat
*/
#ifndef ENUMS_H_
#define ENUMS_H_
enum cond {
zoomed = (1 << 1),
cloaked = (1 << 4),
uber = (1 << 5),
taunting = (1 << 7),
uber_expiration = (1 << 8),
kritzkrieg = (1 << 11),
dead_ringer = (1 << 13),
bonk = (1 << 14),
stunned = (1 << 15),
buff_banner = (1 << 16),
mini_crit = (1 << 19),
on_fire = (1 << 22),
jarate = (1 << 24),
backup = (1 << 26),
milk = (1 << 27),
quickfix_uber = (1 << 28),
concheror = (1 << 29),
marked = (1 << 30)
};
enum cond_ex {
halloween_crit = (1 << 1),
canteen_crit = (1 << 2),
hype = (1 << 4),
first_blood_crit = (1 << 5),
winning_crit = (1 << 6),
intelligence_crit = (1 << 7),
on_kill_crit = (1 << 8),
phlog_crit = (1 << 12),
phlog_uber = (1 << 13),
gru_marked = (1 << 16),
hidden_uber = (1 << 19),
canteen_uber = (1 << 20),
misc_crit = (1 << 24),
misc_uber = (1 << 25),
vacc_bullet = (1 << 26),
vacc_blast = (1 << 27),
vacc_fire = (1 << 28),
vacc_pbullet = (1 << 29),
vacc_pblast = (1 << 30),
vacc_pfire = (1 << 31)
};
enum cond_ex2 {
cloak_spell = (1 << 0),
cloak_spell_fading = (1 << 2),
immunity_bullet = (1 << 3),
immunity_blast = (1 << 4),
immunity_fire = (1 << 5),
buddha = (1 << 6),
minify_spell = (1 << 8),
healing_spell = (1 << 9),
minify_spell_size = (1 << 11),
base_jumping = (1 << 16),
rocket_jumping = (1 << 17),
powerup_generic = (1 << 25),
powerup_strength = (1 << 26),
powerup_haste = (1 << 27),
powerup_regen = (1 << 28),
powerup_resistance = (1 << 29),
powerup_vampire = (1 << 30),
powerup_reflect = (1 << 31)
};
enum cond_ex3 {
powerup_precision = (1 << 0),
powerup_agility = (1 << 1),
grappling = (1 << 2),
powerup_knockout = (1 << 7),
powerup_revenge = (1 << 8),
powerup_crit = (1 << 9),
powerup_king = (1 << 13),
powerup_plague = (1 << 14),
powerup_supernova = (1 << 15),
airblasted = (1 << 19)
};
enum powerup_type {
not_powerup = -1,
strength,
resistance,
vampire,
reflect,
haste,
regeneration,
precision,
agility,
knockout,
king,
plague,
supernova,
crits,
POWERUP_COUNT
};
enum powerup_owner {
neutral = 0,
red = 1,
blue = 2
};
enum item_type {
item_null = -1,
item_medkit_small,
item_medkit_medium,
item_medkit_large,
item_ammo_small,
item_ammo_medium,
item_ammo_large,
item_mp_strength,
item_mp_resistance,
item_mp_vampire,
item_mp_reflect,
item_mp_haste,
item_mp_regeneration,
item_mp_precision,
item_mp_agility,
item_mp_knockout,
item_mp_king,
item_mp_plague,
item_mp_supernova,
item_mp_crit,
item_mp_uber, /* this exists for some reason */
item_mp_warlock, /* never seen that powerup, but the model exists */
item_mp_thorns /* and this one */
};
enum pack_type {
not_pack = -1,
small,
medium,
large,
PACK_COUNT
};
enum entities {
E_PLAYER = 241
};
enum tf_class {
tf_scout = 1,
tf_sniper,
tf_soldier,
tf_demoman,
tf_medic,
tf_heavy,
tf_pyro,
tf_spy,
tf_engineer
};
enum hitbox {
hb_head = 0
};
#endif /* ENUMS_H_ */

View File

@ -1,17 +0,0 @@
/*
* stdheader.h
*
* Created on: Oct 3, 2016
* Author: nullifiedcat
*/
#ifndef FIXSDK_H_
#define FIXSDK_H_
#define LINUX 1
#define _LINUX 1
#define POSIX 1
#define GNUC 1
#undef min
#endif /* FIXSDK_H_ */

View File

@ -1,170 +0,0 @@
/*
* hack.cpp
*
* Created on: Oct 3, 2016
* Author: nullifiedcat
*/
#include "hack.h"
#include <fstream>
#include <iostream>
#include <cstring>
#include <unistd.h>
#include <link.h>
#include <unordered_map>
#include <cstring>
#include <memory>
#include "interfaces.h"
#include "sharedobj.h"
#include "logging.h"
#include "hooks.h"
#include "hacks/IHack.h"
#include "hacks/HBunnyhop.h"
#include "hacks/HTrigger.h"
#include "hacks/HEsp.h"
#include "hacks/HGlow.h"
#include "hacks/HPyroBot.h"
#include "hacks/HAimbot.h"
#include "usercmd.h"
#include "drawing.h"
#include "entity.h"
#include "localplayer.h"
#include <csignal>
#include "fixsdk.h"
#include <tier1/convar.h>
#include <igameevents.h>
#include <icliententitylist.h>
#include <cdll_int.h>
#include <engine/IEngineTrace.h>
#include <icliententity.h>
#include <cmodel.h>
#include <client_class.h>
#include <vgui/ISurface.h>
#include <vgui/IPanel.h>
#include <convar.h>
#include <icvar.h>
#include "copypasted/CSignature.h"
#include "copypasted/Netvar.h"
#include "CDumper.h"
#include "hacks/HSaySpecial.h"
/*
* Credits to josh33901 aka F1ssi0N for butifel F1Public and Darkstorm 2015 Linux
*/
typedef void(PaintTraverse_t)(void*, unsigned int, bool, bool);
typedef bool(CreateMove_t)(void*, float, CUserCmd*);
void hack::Hk_PaintTraverse(void* p, unsigned int vp, bool fr, bool ar) {
((PaintTraverse_t*)hooks::hkPaintTraverse->GetMethod(hooks::offPaintTraverse))(p, vp, fr, ar);
if (!draw::width || !draw::height) {
interfaces::engineClient->GetScreenSize(draw::width, draw::height);
}
if (!draw::panel_top) {
const char* name = interfaces::panel->GetName(vp);
if (strlen(name) > 4) {
if (name[0] == 'M' && name[3] == 'S') {
draw::panel_top = vp;
logging::Info("Got top panel: %i", vp);
}
}
}
if (draw::panel_top == vp) {
for (IHack* i_hack : hack::hacks) {
i_hack->PaintTraverse(p, vp, fr, ar);
}
}
}
bool hack::Hk_CreateMove(void* thisptr, float inputSample, CUserCmd* cmd) {
((CreateMove_t*)hooks::hkCreateMove->GetMethod(hooks::offCreateMove))(thisptr, inputSample, cmd);
g_pLocalPlayer->Update();
bool ret = true;
for (IHack* i_hack : hack::hacks) {
if (!i_hack->CreateMove(thisptr, inputSample, cmd)) {
ret = false;
}
}
return ret;
}
// TODO globals
std::vector<IHack*> hack::hacks;
void hack::AddHack(IHack* hack) {
hack->Create();
hack::hacks.push_back(hack);
}
// TODO globals
ICvar* g_pCVar = 0;
void hack::Initialize() {
logging::Initialize();
std::string test = "";
logging::Info("Build: " __DATE__ " " __TIME__);
logging::Info("Loading shared objects...");
sharedobj::LoadAllSharedObjects();
/* TODO */
//logging::Info("TRYIN' SHIT");
//CGlowObject* gom = (CGlowObject*)((uintptr_t)sharedobj::client->lmap->l_addr + 0x01FC6260);
//logging::Info("MANAGER?? 0x%08f", gom);
logging::Info("Creating interfaces...");
interfaces::CreateInterfaces();
logging::Info("Interfaces created!");
logging::Info("Hooking PaintTraverse...");
hooks::hkPaintTraverse = new hooks::VMTHook();
hooks::hkPaintTraverse->Init(interfaces::panel, 0);
hooks::hkPaintTraverse->HookMethod((void*)&hack::Hk_PaintTraverse, hooks::offPaintTraverse);
hooks::hkPaintTraverse->Apply();
logging::Info("Hooking CreateMove...");
hooks::hkCreateMove = new hooks::VMTHook();
uintptr_t* clientMode = 0;
while(!(clientMode = **(uintptr_t***)((uintptr_t)((*(void***)interfaces::baseClient)[10]) + 1))) {
sleep(1);
}
g_pLocalPlayer = new LocalPlayer();
hooks::hkCreateMove->Init((void*)clientMode, 0);
hooks::hkCreateMove->HookMethod((void*)&hack::Hk_CreateMove, hooks::offCreateMove);
hooks::hkCreateMove->Apply();
logging::Info("Hooked!");
logging::Info("Initializing surface...");
draw::Initialize();
logging::Info("testing string...");
logging::Info("Adding hacks...");
SetCVarInterface(interfaces::cvar);
hack::AddHack(new HSaySpecial());
hack::AddHack(new HBunnyhop());
hack::AddHack(new HTrigger());
hack::AddHack(new HEsp());
hack::AddHack(new HAimbot());
hack::AddHack(new HGlow());
hack::AddHack(new HPyroBot());
ConVar_Register();
logging::Info("Initializing NetVar tree...");
gNetvars.init();
logging::Info("Initializing entity offsets...");
InitEntityOffsets();
logging::Info("Init done!");
}
void hack::Think() {
// Main code goes here...
usleep(1000);
}
void hack::Shutdown() {
logging::Info("Shutting down...");
logging::Shutdown();
ConVar_Unregister();
hooks::hkPaintTraverse->Kill();
hooks::hkCreateMove->Kill();
for (IHack* i_hack : hack::hacks) {
i_hack->Destroy();
}
}

View File

@ -1,31 +0,0 @@
/*
* hack.h
*
* Created on: Oct 3, 2016
* Author: nullifiedcat
*/
#ifndef HACK_H_
#define HACK_H_
#include <vector>
class IHack;
class CUserCmd;
namespace hack {
extern std::vector<IHack*> hacks;
void Hk_PaintTraverse(void*, unsigned int, bool, bool);
bool Hk_CreateMove(void*, float, CUserCmd*);
void AddHack(IHack* hack);
void Initialize();
void Think();
void Shutdown();
}
#endif /* HACK_H_ */

View File

@ -1,363 +0,0 @@
/*
* helpers.cpp
*
* Created on: Oct 8, 2016
* Author: nullifiedcat
*/
#include "helpers.h"
#include "interfaces.h"
#include "entity.h"
#include "logging.h"
#include "usercmd.h"
#include "trace.h"
#include "localplayer.h"
#include "fixsdk.h"
#include <tier1/convar.h>
#include <engine/ivmodelinfo.h>
#include <icliententity.h>
#include <cmodel.h>
#include <studio.h>
#include <gametrace.h>
#include <icliententitylist.h>
#include <cdll_int.h>
#include <engine/IEngineTrace.h>
bool IsPlayerInvulnerable(IClientEntity* player) {
int cond1 = GetEntityValue<int>(player, eoffsets.iCond);
int cond2 = GetEntityValue<int>(player, eoffsets.iCond1);
int uber_mask_1 = (cond::uber | cond::uber_expiration | cond::bonk);
int uber_mask_2 = (cond_ex::hidden_uber | cond_ex::canteen_uber | cond_ex::misc_uber | cond_ex::phlog_uber);
if ((cond1 & uber_mask_1) || (cond2 & uber_mask_2)) return true;
return false;
}
bool IsPlayerCritBoosted(IClientEntity* player) {
int cond1 = GetEntityValue<int>(player, eoffsets.iCond);
int cond2 = GetEntityValue<int>(player, eoffsets.iCond1);
int cond4 = GetEntityValue<int>(player, eoffsets.iCond3);
int crit_mask_1 = (cond::kritzkrieg);
int crit_mask_2 = (cond_ex::halloween_crit | cond_ex::canteen_crit | cond_ex::first_blood_crit | cond_ex::winning_crit |
cond_ex::intelligence_crit | cond_ex::on_kill_crit | cond_ex::phlog_crit | cond_ex::misc_crit);
int crit_mask_4 = (cond_ex3::powerup_crit);
if ((cond1 & crit_mask_1) || (cond2 & crit_mask_2) || (cond4 & crit_mask_4)) return true;
return false;
}
ConVar* CreateConVar(const char* name, const char* value, const char* help) {
ConVar* ret = new ConVar(name, value, 0, help);
interfaces::cvar->RegisterConCommand(ret);
return ret;
}
ConCommand* CreateConCommand(const char* name, FnCommandCallback_t callback, const char* help) {
ConCommand* ret = new ConCommand(name, callback, help);
interfaces::cvar->RegisterConCommand(ret);
return ret;
}
const char* GetModelPath(IClientEntity* entity) {
if (!entity) return "NULL";
const model_t* model = entity->GetModel();
return interfaces::model->GetModelName(model);
}
/* Takes CBaseAnimating entity as input */
item_type GetItemType(IClientEntity* entity) {
if (entity == 0) return item_type::item_null;
const char* path = GetModelPath(entity); /* SDK function */
size_t length = strlen(path);
/* Default/Festive medkits */
if (length >= 29 && path[16] == 'k') {
if (path[20] == 's') return item_type::item_medkit_small;
if (path[20] == 'm') return item_type::item_medkit_medium;
if (path[20] == 'l') return item_type::item_medkit_large;
}
/* Sandwich/Steak */
if (length >= 22 && path[13] == 'p' && path[14] == 'l') {
return item_type::item_medkit_medium;
}
/* Medieval meat */
if (length == 39 && path[31] == 'm' && path[29] == 'l') {
return item_type::item_medkit_medium;
}
/* Halloween medkits */
if (length >= 49 && path[33] == 'm' && path[36] == 'k') {
if (path[20] == 's') return item_type::item_medkit_small;
if (path[40] == 'm') return item_type::item_medkit_medium;
if (path[40] == 'l') return item_type::item_medkit_large;
}
/* Ammo packs */
if (length >= 31 && path[14] == 'm' && path[15] == 'm') {
if (path[22] == 's') return item_type::item_ammo_small;
if (path[22] == 'm') return item_type::item_ammo_medium;
if (path[22] == 'l') return item_type::item_ammo_large;
}
/* Powerups */
if (length >= 38 && path[20] == 'p' && path[24] == 'w') {
if (path[30] == 'h') return item_type::item_mp_haste;
if (path[30] == 'v') return item_type::item_mp_vampire;
if (path[30] == 'u') return item_type::item_mp_uber;
if (path[32] == 'e') return item_type::item_mp_precision;
if (path[30] == 'w') return item_type::item_mp_warlock;
if (path[32] == 'r') return item_type::item_mp_strength;
if (path[32] == 'g') return item_type::item_mp_regeneration;
if (path[37] == 'v') return item_type::item_mp_supernova;
/* looks like resistance.mdl is unused and replaced with defense.mdl? idk */
if (path[37] == 'n') return item_type::item_mp_resistance;
if (path[34] == 'k') return item_type::item_mp_knockout;
/* actually this one is 'defense' but it's used for resistance powerup */
if (path[35] == 's') return item_type::item_mp_resistance;
if (path[30] == 'c') return item_type::item_mp_crit;
if (path[30] == 'a') return item_type::item_mp_agility;
if (path[31] == 'i') return item_type::item_mp_king;
if (path[33] == 'g') return item_type::item_mp_plague;
if (path[36] == 't') return item_type::item_mp_reflect;
if (path[30] == 't') return item_type::item_mp_thorns;
}
return item_type::item_null;
}
pack_type GetHealthPackType(IClientEntity* ent) {
if (!ent) return pack_type::not_pack;
const char* name = GetModelPath(ent);
// models/items/medkit_SIZE.mdl
if (strlen(name) >= 20 && name[13] == 'm' && name[16] == 'k') {
if (name[20] == 's') return pack_type::small;
if (name[20] == 'm') return pack_type::medium;
if (name[20] == 'l') return pack_type::large;
}
// models/props_halloween/halloween_medkit_SIZE.mdl
if (strlen(name) >= 42 && name[33] == 'm' && name[36] == 'k') {
if (name[40] == 's') return pack_type::small;
if (name[40] == 'm') return pack_type::medium;
if (name[40] == 'l') return pack_type::large;
}
// models/items/plate
if (strlen(name) >= 18 && name[13] == 'p' && name[17] == 'e') {
return pack_type::medium;
}
return pack_type::not_pack;
// TODO add halloween packs n' stuff
}
pack_type GetAmmoPackType(IClientEntity* ent) {
if (!ent) return pack_type::not_pack;
const char* name = GetModelPath(ent);
if (strlen(name) < 30) return pack_type::not_pack;
return pack_type::not_pack;
}
/* Strength [30]=='s' */
powerup_type GetPowerupType(IClientEntity* ent) {
if (!ent) return powerup_type::not_powerup;
const char* name = GetModelPath(ent);
if (strlen(name) < 35) return powerup_type::not_powerup;
if (name[27] != 'u' || name[22] != 'p') return powerup_type::not_powerup;
if (name[30] == 's' && name[31] == 't') return powerup_type::strength;
if (name[30] == 'd' && name[32] == 'f') return powerup_type::resistance;
if (name[30] == 'v') return powerup_type::vampire;
if (name[30] == 'r' && name[32] == 'f') return powerup_type::reflect;
if (name[30] == 'h') return powerup_type::haste;
if (name[30] == 'r' && name[32] == 'g') return powerup_type::regeneration;
if (name[30] == 'p' && name[31] == 'r') return powerup_type::precision;
if (name[30] == 'a') return powerup_type::agility;
if (name[30] == 'k' && name[31] == 'n') return powerup_type::knockout;
if (name[30] == 'k' && name[31] == 'i') return powerup_type::king;
if (name[30] == 'p' && name[31] == 'l') return powerup_type::plague;
if (name[30] == 's' && name[31] == 'u') return powerup_type::supernova;
return powerup_type::not_powerup;
}
powerup_type GetPowerupOnPlayer(IClientEntity* player) {
if (!player) return powerup_type::not_powerup;
uint32_t cond2 = GetEntityValue<uint32_t>(player, eoffsets.iCond2);
uint32_t cond3 = GetEntityValue<uint32_t>(player, eoffsets.iCond3);
//if (!(cond2 & cond_ex2::powerup_generic)) return powerup_type::not_powerup;
if (cond2 & cond_ex2::powerup_strength) return powerup_type::strength;
if (cond2 & cond_ex2::powerup_haste) return powerup_type::haste;
if (cond2 & cond_ex2::powerup_regen) return powerup_type::regeneration;
if (cond2 & cond_ex2::powerup_resistance) return powerup_type::resistance;
if (cond2 & cond_ex2::powerup_vampire) return powerup_type::vampire;
if (cond2 & cond_ex2::powerup_reflect) return powerup_type::reflect;
if (cond3 & cond_ex3::powerup_precision) return powerup_type::precision;
if (cond3 & cond_ex3::powerup_agility) return powerup_type::agility;
if (cond3 & cond_ex3::powerup_knockout) return powerup_type::knockout;
if (cond3 & cond_ex3::powerup_king) return powerup_type::king;
if (cond3 & cond_ex3::powerup_plague) return powerup_type::plague;
if (cond3 & cond_ex3::powerup_supernova) return powerup_type::supernova;
return powerup_type::not_powerup;
}
void VectorTransform (const float *in1, const matrix3x4_t& in2, float *out)
{
out[0] = (in1[0] * in2[0][0] + in1[1] * in2[0][1] + in1[2] * in2[0][2]) + in2[0][3];
out[1] = (in1[0] * in2[1][0] + in1[1] * in2[1][1] + in1[2] * in2[1][2]) + in2[1][3];
out[2] = (in1[0] * in2[2][0] + in1[1] * in2[2][1] + in1[2] * in2[2][2]) + in2[2][3];
}
int GetHitboxPosition(IClientEntity* entity, int hb, Vector& out) {
if (!entity) return 1;
if (entity->IsDormant()) return 1;
const model_t* model = entity->GetModel();
studiohdr_t* shdr = interfaces::model->GetStudiomodel(model);
if (!shdr) return 2;
// TODO rewrite
mstudiohitboxset_t* set = shdr->pHitboxSet(GetEntityValue<int>(entity, eoffsets.iHitboxSet));
if (!set) return 4;
mstudiobbox_t* box = set->pHitbox(hb);
if (!box) return 5;
matrix3x4_t bones[128];
if (!entity->SetupBones(bones, 128, 0x100, 0)) return 3;
Vector min, max;
if (box->bone < 0 || box->bone >= 128) return 6;
VectorTransform(box->bbmin, bones[box->bone], min);
VectorTransform(box->bbmax, bones[box->bone], max);
out = (min + max) / 2;
return 0;
}
void VectorAngles(Vector &forward, Vector &angles) {
float tmp, yaw, pitch;
if(forward[1] == 0 && forward[0] == 0)
{
yaw = 0;
if(forward[2] > 0)
pitch = 270;
else
pitch = 90;
}
else
{
yaw = (atan2(forward[1], forward[0]) * 180 / PI);
if(yaw < 0)
yaw += 360;
tmp = sqrt((forward[0] * forward[0] + forward[1] * forward[1]));
pitch = (atan2(-forward[2], tmp) * 180 / PI);
if(pitch < 0)
pitch += 360;
}
angles[0] = pitch;
angles[1] = yaw;
angles[2] = 0;
}
void FixMovement(CUserCmd& cmd, Vector& viewangles) {
Vector movement(cmd.forwardmove, cmd.sidemove, cmd.upmove);
float speed = sqrt(movement.x * movement.x + movement.y * movement.y);
Vector ang;
VectorAngles(movement, ang);
float yaw = DEG2RAD(ang.y - viewangles.y + cmd.viewangles.y);
cmd.forwardmove = cos(yaw) * speed;
cmd.sidemove = sin(yaw) * speed;
/*Vector vsilent(cmd->forwardmove, cmd->sidemove, cmd->upmove);
float speed = sqrt(vsilent.x * vsilent.x + vsilent.y * vsilent.y);
Vector ang;
VectorAngles(vsilent, ang);
float yaw = deg2rad(ang.y - viewangles_old.y + cmd->viewangles.y);
cmd->forwardmove = cos(yaw) * speed;
cmd->sidemove = sin(yaw) * speed;*/
}
trace::FilterDefault* trace_filter;
bool IsEntityVisible(IClientEntity* entity, int hb) {
if (!trace_filter) {
trace_filter = new trace::FilterDefault();
}
trace_t trace_visible;
Ray_t ray;
IClientEntity* local = interfaces::entityList->GetClientEntity(interfaces::engineClient->GetLocalPlayer());
trace_filter->SetSelf(local);
Vector hit;
int ret = GetHitboxPosition(entity, hb, hit);
if (ret) {
logging::Info("Couldn't get hitbox position: %i", hb);
return false;
}
ray.Init(local->GetAbsOrigin() + GetEntityValue<Vector>(local, eoffsets.vViewOffset), hit);
interfaces::trace->TraceRay(ray, 0x4200400B, trace_filter, &trace_visible);
if (trace_visible.m_pEnt) {
return ((IClientEntity*)trace_visible.m_pEnt) == entity;
}
return false;
}
void fVectorAngles(Vector &forward, Vector &angles) {
float tmp, yaw, pitch;
if(forward[1] == 0 && forward[0] == 0)
{
yaw = 0;
if(forward[2] > 0)
pitch = 270;
else
pitch = 90;
}
else
{
yaw = (atan2(forward[1], forward[0]) * 180 / PI);
if(yaw < 0)
yaw += 360;
tmp = sqrt((forward[0] * forward[0] + forward[1] * forward[1]));
pitch = (atan2(-forward[2], tmp) * 180 / PI);
if(pitch < 0)
pitch += 360;
}
angles[0] = pitch;
angles[1] = yaw;
angles[2] = 0;
}
void fClampAngle(Vector& qaAng) {
while(qaAng[0] > 89)
qaAng[0] -= 180;
while(qaAng[0] < -89)
qaAng[0] += 180;
while(qaAng[1] > 180)
qaAng[1] -= 360;
while(qaAng[1] < -180)
qaAng[1] += 360;
qaAng.z = 0;
}
float DistToSqr(IClientEntity* entity) {
return g_pLocalPlayer->v_Origin.DistToSqr(entity->GetAbsOrigin());
}
const char* powerups[] = {
"STRENGTH",
"RESISTANCE",
"VAMPIRE",
"REFLECT",
"HASTE",
"REGENERATION",
"PRECISION",
"AGILITY",
"KNOCKOUT",
"KING",
"PLAGUE",
"SUPERNOVA",
"CRITS"
};
const char* packs[] = {
"+",
"++",
"+++"
};

View File

@ -1,47 +0,0 @@
/*
* helpers.h
*
* Created on: Oct 8, 2016
* Author: nullifiedcat
*/
#ifndef HELPERS_H_
#define HELPERS_H_
class IClientEntity;
class ConVar;
class ConCommand;
class CUserCmd;
class Vector;
#define PI 3.14159265358979323846f
#define DEG2RAD(x) x * (PI / 180.0f)
#include "enums.h"
#include "fixsdk.h"
#include <tier1/convar.h>
bool IsPlayerCritBoosted(IClientEntity* player);
bool IsPlayerInvulnerable(IClientEntity* player);
//bool SpyIsVisible(IClientEntity* spy);
ConVar* CreateConVar(const char* name, const char* value, const char* help);
ConCommand* CreateConCommand(const char* name, FnCommandCallback_t callback, const char* help);
pack_type GetHealthPackType(IClientEntity* ent);
pack_type GetAmmoPackType(IClientEntity* ent);
powerup_type GetPowerupType(IClientEntity* ent);
powerup_type GetPowerupOnPlayer(IClientEntity* player);
item_type GetItemType(IClientEntity* entity);
const char* GetModelPath(IClientEntity* entity);
int GetHitboxPosition(IClientEntity* entity, int hb, Vector& out);
void FixMovement(CUserCmd& cmd, Vector& viewangles);
void VectorAngles(Vector &forward, Vector &angles);
bool IsEntityVisible(IClientEntity* entity, int hb);
float DistToSqr(IClientEntity* entity);
void fClampAngle(Vector& qaAng);
void fVectorAngles(Vector &forward, Vector &angles);
extern const char* powerups[POWERUP_COUNT];
extern const char* packs[PACK_COUNT];
#endif /* HELPERS_H_ */

View File

@ -1,66 +0,0 @@
/*
* hooks.cpp
*
* Created on: Oct 4, 2016
* Author: nullifiedcat
*/
#include "hooks.h"
#include "logging.h"
#include <stdlib.h>
unsigned int hooks::offCreateMove = 22;
unsigned int hooks::offPaintTraverse = 42;
unsigned int hooks::CountMethods(void** vmt) {
unsigned int i = -1;
do ++i; while (vmt[i]);
return i;
}
void**& hooks::GetVMT(void* inst, unsigned int offset) {
// I'm not quite sure what happens here...
// inst is the pointer to class
// (char*) inst + offset is the pointer to vmt
// so it casts vmt pointer to void*** and returns its value..?
return *reinterpret_cast<void***>((char*)inst + offset);
}
void hooks::VMTHook::Init(void* inst, unsigned int offset) {
logging::Info("Initializing VMTHook at 0x%08x", inst);
vmt = &GetVMT(inst, offset);
oldvmt = *vmt;
unsigned int cnt = CountMethods(oldvmt);
logging::Info("found %i methods...", cnt);
void **arr = array = (void**)malloc((cnt + 4) * sizeof(void*));
arr[0] = this;
arr[1] = (void* )GUARD;
(arr + 3)[cnt] = 0;
unsigned int i = -1;
do arr[i + 3] = oldvmt[i]; while (++i < cnt);
}
void hooks::VMTHook::Kill() {
*vmt = oldvmt;
vmt = 0;
free(array);
array = 0;
}
void hooks::VMTHook::HookMethod(void* func, unsigned int idx) {
array[idx + 3] = func;
}
void* hooks::VMTHook::GetMethod(unsigned int idx) const {
return oldvmt[idx];
}
void hooks::VMTHook::Apply() {
*vmt = array + 3;
}
hooks::VMTHook* hooks::hkCreateMove = 0;
hooks::VMTHook* hooks::hkPaintTraverse = 0;

View File

@ -1,41 +0,0 @@
/*
* hooks.h
*
* Created on: Oct 4, 2016
* Author: nullifiedcat
*/
#ifndef HOOKS_H_
#define HOOKS_H_
namespace hooks {
// Parts of copypasted code
// Credits: Casual_Hacker
unsigned int CountMethods(void** vmt);
void**& GetVMT(void* inst, unsigned int offset);
class VMTHook {
public:
enum { GUARD = 0xD34DC477 };
void Init(void* inst, unsigned int offset);
void Kill();
void HookMethod(void* func, unsigned int idx);
void* GetMethod(unsigned int idx) const;
void Apply();
protected:
void ***vmt;
void **oldvmt;
void **array;
};
extern VMTHook* hkPaintTraverse;
extern VMTHook* hkCreateMove;
extern unsigned int offPaintTraverse;
extern unsigned int offCreateMove;
}
#endif /* HOOKS_H_ */

View File

@ -1,44 +0,0 @@
/*
* interfaces.cpp
*
* Created on: Oct 3, 2016
* Author: nullifiedcat
*/
#include "interfaces.h"
#include "sharedobj.h"
#include "logging.h"
#include <ISteamClient017.h>
//class ISteamFriends002;
ISteamClient017* interfaces::steamClient = 0;
ISteamFriends002* interfaces::steamFriends = 0;
IVEngineClient013* interfaces::engineClient = 0;
vgui::ISurface* interfaces::surface = 0;
vgui::IPanel* interfaces::panel = 0;
IClientEntityList* interfaces::entityList = 0;
ICenterPrint* interfaces::centerPrint = 0;
IGameEventManager2* interfaces::eventManager = 0;
IBaseClientDLL* interfaces::baseClient = 0;
IEngineTrace* interfaces::trace = 0;
IVModelInfoClient* interfaces::model = 0;
//ICvar* interfaces::cvar = 0;
void interfaces::CreateInterfaces() {
interfaces::centerPrint = reinterpret_cast<ICenterPrint*>(sharedobj::client->fptr("VCENTERPRINT002", nullptr));
interfaces::cvar = reinterpret_cast<ICvar*>(sharedobj::vstdlib->CreateInterface("VEngineCvar004"));
interfaces::engineClient = reinterpret_cast<IVEngineClient013*>(sharedobj::engine->CreateInterface("VEngineClient013"));
interfaces::entityList = reinterpret_cast<IClientEntityList*>(sharedobj::client->CreateInterface("VClientEntityList003"));
interfaces::panel = reinterpret_cast<vgui::IPanel*>(sharedobj::vgui2->CreateInterface("VGUI_Panel009"));
interfaces::steamClient = reinterpret_cast<ISteamClient017*>(sharedobj::steamclient->CreateInterface("SteamClient017"));
interfaces::surface = reinterpret_cast<vgui::ISurface*>(sharedobj::vguimatsurface->CreateInterface("VGUI_Surface030"));
interfaces::eventManager = reinterpret_cast<IGameEventManager2*>(sharedobj::engine->CreateInterface("GAMEEVENTSMANAGER002"));
interfaces::baseClient = reinterpret_cast<IBaseClientDLL*>(sharedobj::client->CreateInterface("VClient017"));
interfaces::trace = reinterpret_cast<IEngineTrace*>(sharedobj::engine->CreateInterface("EngineTraceClient003"));
interfaces::model = reinterpret_cast<IVModelInfoClient*>(sharedobj::engine->CreateInterface("VModelInfoClient006"));
HSteamPipe sp = interfaces::steamClient->CreateSteamPipe();
HSteamUser su = interfaces::steamClient->ConnectToGlobalUser(sp);
interfaces::steamFriends = reinterpret_cast<ISteamFriends002*>(interfaces::steamClient->GetISteamFriends(su, sp, "SteamFriends002"));
}

View File

@ -1,47 +0,0 @@
/*
* interfaces.h
*
* Created on: Oct 3, 2016
* Author: nullifiedcat
*/
#ifndef INTERFACES_H_
#define INTERFACES_H_
namespace vgui {
class ISurface;
class IPanel;
}
class ISteamClient017;
class ISteamFriends002;
class IVEngineClient013;
class IClientEntityList;
class ICenterPrint;
class ICvar;
class IGameEventManager2;
class IBaseClientDLL;
class ClientModeShared;
class IEngineTrace;
class IVModelInfoClient;
namespace interfaces {
extern ISteamClient017* steamClient;
extern ISteamFriends002* steamFriends;
extern IVEngineClient013* engineClient;
extern vgui::ISurface* surface;
extern vgui::IPanel* panel;
extern IClientEntityList* entityList;
extern ICenterPrint* centerPrint;
extern ICvar* cvar;
extern IGameEventManager2* eventManager;
extern IBaseClientDLL* baseClient;
extern IEngineTrace* trace;
extern IVModelInfoClient* model;
void CreateInterfaces();
}
#endif /* INTERFACES_H_ */

View File

@ -1,28 +0,0 @@
/*
* localplayer.cpp
*
* Created on: Oct 15, 2016
* Author: nullifiedcat
*/
#include "localplayer.h"
#include "interfaces.h"
#include "entity.h"
#include "fixsdk.h"
#include <cdll_int.h>
#include <icliententitylist.h>
#include <mathlib/vector.h>
#include <icliententity.h>
void LocalPlayer::Update() {
entity_idx = interfaces::engineClient->GetLocalPlayer();
entity = interfaces::entityList->GetClientEntity(entity_idx);
team = GetEntityValue<int>(entity, eoffsets.iTeamNum);
life_state = GetEntityValue<char>(entity, eoffsets.iLifeState);
v_ViewOffset = GetEntityValue<Vector>(entity, eoffsets.vViewOffset);
v_Origin = entity->GetAbsOrigin();
v_Eye = v_Origin + v_ViewOffset;
}
LocalPlayer* g_pLocalPlayer = 0;

View File

@ -1,38 +0,0 @@
/*
* localplayer.h
*
* Created on: Oct 15, 2016
* Author: nullifiedcat
*/
#ifndef LOCALPLAYER_H_
#define LOCALPLAYER_H_
#include "fixsdk.h"
#include <mathlib/vector.h>
class IClientEntity;
class LocalPlayer {
public:
void Update();
int team;
int health;
int flags;
char life_state;
int clazz;
int cond_0;
int cond_1;
int cond_2;
int cond_3;
Vector v_ViewOffset;
Vector v_Origin;
Vector v_Eye;
int entity_idx;
IClientEntity* entity;
IClientEntity* weapon;
};
extern LocalPlayer* g_pLocalPlayer;
#endif /* LOCALPLAYER_H_ */

View File

@ -1,47 +0,0 @@
/*
* logging.cpp
*
* Created on: Oct 3, 2016
* Author: nullifiedcat
*/
#include "logging.h"
#include <stdarg.h>
#include <string.h>
#include "fixsdk.h"
#include <icvar.h>
namespace interfaces {
ICvar* cvar;
}
FILE* logging::handle = 0;
void logging::Initialize() {
logging::handle = fopen("/tmp/uran.log", "w");
}
void logging::Info(const char* fmt, ...) {
if (logging::handle == 0) return;
char buffer[1024];
va_list list;
va_start(list, fmt);
vsprintf(buffer, fmt, list);
va_end(list);
size_t length = strlen(buffer);
char* result = new char[length + 9];
sprintf(result, "[Hack] %s\n", buffer);
fprintf(logging::handle, "%s", result);
fflush(logging::handle);
if (interfaces::cvar) {
interfaces::cvar->ConsolePrintf("%s", result);
}
delete result;
}
void logging::Shutdown() {
fclose(logging::handle);
logging::handle = 0;
}

View File

@ -1,25 +0,0 @@
/*
* logging.h
*
* Created on: Oct 3, 2016
* Author: nullifiedcat
*/
#ifndef LOGGING_H_
#define LOGGING_H_
#include <stdio.h>
typedef void(fn_Msg_t)(const char* msg, va_list);
namespace logging {
extern FILE* handle;
void Initialize();
void Shutdown();
void Info(const char* fmt, ...);
}
#endif /* LOGGING_H_ */

View File

@ -1,73 +0,0 @@
/*
* sharedobj.cpp
*
* Created on: Oct 3, 2016
* Author: nullifiedcat
*/
#include "sharedobj.h"
#include "logging.h"
#include <unistd.h>
#include <link.h>
#include <dlfcn.h>
#include <libgen.h>
#define STEAM_BASEDIR "/home/nullifiedcat/.local/share/Steam/"
namespace logging {
void Info(const char* fmt, ...);
}
sharedobj::SharedObject* sharedobj::steamclient = 0;
sharedobj::SharedObject* sharedobj::client = 0;
sharedobj::SharedObject* sharedobj::engine = 0;
sharedobj::SharedObject* sharedobj::vguimatsurface = 0;
sharedobj::SharedObject* sharedobj::vgui2 = 0;
sharedobj::SharedObject* sharedobj::vstdlib = 0;
sharedobj::SharedObject* sharedobj::tier0 = 0;
sharedobj::SharedObject::SharedObject(const char* path, bool factory) {
this->path = path;
while (!(lmap = (link_map*)dlopen(path, RTLD_NOLOAD))) {
sleep(1);
if (0 != dlerror()) {
logging::Info("DLERROR: %s", dlerror());
}
}
logging::Info("Shared object %s loaded at 0x%08x", basename(lmap->l_name), lmap->l_addr);
if (factory) {
fptr = reinterpret_cast<fn_CreateInterface_t>(dlsym(lmap, "CreateInterface"));
if (!this->fptr) {
logging::Info("Failed to create interface factory for %s", basename(lmap->l_name));
}
}
}
int* sharedobj::SharedObject::Pointer(int offset) {
if (this->lmap) {
return (int*)((int) this->lmap->l_addr + offset);
} else {
return 0;
}
}
void* sharedobj::SharedObject::CreateInterface(const char* name) {
int result;
void* interface = (void*)(fptr(name, &result));
if (result) {
logging::Info("Interface creation failed: %s from %s", name, basename(lmap->l_name));
}
return interface;
}
void sharedobj::LoadAllSharedObjects() {
sharedobj::client = new SharedObject(STEAM_BASEDIR "steamapps/common/Team Fortress 2/tf/bin/client.so", true);
sharedobj::engine = new SharedObject(STEAM_BASEDIR "steamapps/common/Team Fortress 2/bin/engine.so", true);
sharedobj::steamclient = new SharedObject(STEAM_BASEDIR "linux32/steamclient.so", true);
sharedobj::tier0 = new SharedObject(STEAM_BASEDIR "steamapps/common/Team Fortress 2/bin/libtier0.so", false);
sharedobj::vgui2 = new SharedObject(STEAM_BASEDIR "steamapps/common/Team Fortress 2/bin/vgui2.so", true);
sharedobj::vguimatsurface = new SharedObject(STEAM_BASEDIR "steamapps/common/Team Fortress 2/bin/vguimatsurface.so", true);
sharedobj::vstdlib = new SharedObject(STEAM_BASEDIR "steamapps/common/Team Fortress 2/bin/libvstdlib.so", true);
}

View File

@ -1,38 +0,0 @@
/*
* sharedobj.h
*
* Created on: Oct 3, 2016
* Author: nullifiedcat
*/
#ifndef SHAREDOBJ_H_
#define SHAREDOBJ_H_
struct link_map;
typedef void *(*fn_CreateInterface_t)(const char*, int*);
namespace sharedobj {
class SharedObject {
public:
SharedObject(const char* path, bool factory);
int* Pointer(int offset);
void* CreateInterface(const char* name);
fn_CreateInterface_t fptr;
const char* path;
link_map* lmap;
};
extern SharedObject* steamclient;
extern SharedObject* client;
extern SharedObject* engine;
extern SharedObject* vguimatsurface;
extern SharedObject* vgui2;
extern SharedObject* vstdlib;
extern SharedObject* tier0;
void LoadAllSharedObjects();
}
#endif /* SHAREDOBJ_H_ */

View File

@ -1,77 +0,0 @@
/*
* targethelper.cpp
*
* Created on: Oct 16, 2016
* Author: nullifiedcat
*/
#include "enums.h"
#include "entity.h"
#include "localplayer.h"
#include "helpers.h"
#include "fixsdk.h"
#include <icliententity.h>
/*
* Targeting priorities:
* passive bullet vacc medic
* zoomed snipers ALWAYS
* medics
* snipers
* spies
*/
/* Assuming given entity is a valid target range 0 to 100 */
int GetScoreForEntity(IClientEntity* entity) {
int clazz = GetEntityValue<int>(entity, eoffsets.iClass);
int health = GetEntityValue<int>(entity, eoffsets.iHealth);
float distance = (g_pLocalPlayer->v_Origin - entity->GetAbsOrigin()).Length();
bool zoomed = (GetEntityValue<int>(entity, eoffsets.iCond) & cond::zoomed);
int condx = (GetEntityValue<int>(entity, eoffsets.iCond1));
int condx2 = (GetEntityValue<int>(entity, eoffsets.iCond2));
bool pbullet = (condx & cond_ex::vacc_pbullet);
bool special = false;
bool kritz = IsPlayerCritBoosted(entity);
int total = 0;
switch(clazz) {
case tf_sniper:
total += 25;
if (zoomed) {
total += 50;
}
special = true;
break;
case tf_medic:
total += 50;
if (pbullet) return 100;
break;
case tf_spy:
total += 20;
if (distance < 400) total += 60;
special = true;
break;
case tf_soldier:
if (condx2 & cond_ex2::rocket_jumping) total += 30;
break;
}
if (!special) {
if (pbullet) {
total += 50;
}
if (kritz) {
total += 99;
}
if (distance != 0) {
int distance_factor = (4096 / distance) * 4;
total += distance_factor;
if (health != 0) {
int health_factor = (450 / health) * 4;
if (health_factor > 30) health_factor = 30;
total += health_factor;
}
}
}
if (total > 99) total = 99;
return total;
}

View File

@ -1,13 +0,0 @@
/*
* targethelper.h
*
* Created on: Oct 15, 2016
* Author: nullifiedcat
*/
#ifndef TARGETHELPER_H_
#define TARGETHELPER_H_
int GetScoreForEntity(IClientEntity* entity);
#endif /* TARGETHELPER_H_ */

View File

@ -1,45 +0,0 @@
/*
* trace.cpp
*
* Created on: Oct 10, 2016
* Author: nullifiedcat
*/
#include "trace.h"
#include <cstdint>
#include "fixsdk.h"
#include <client_class.h>
#include <icliententity.h>
trace::FilterDefault::FilterDefault() {
m_pSelf = nullptr;
}
trace::FilterDefault::~FilterDefault() {};
void trace::FilterDefault::SetSelf(IClientEntity* self) {
m_pSelf = self;
}
bool trace::FilterDefault::ShouldHitEntity(IHandleEntity* handle, int mask) {
IClientEntity* entity = (IClientEntity*) handle;
ClientClass* clazz = entity->GetClientClass();
/* Ignore invisible entities that we don't wanna hit */
switch(clazz->m_ClassID) {
// TODO magic numbers: invisible entity ids
case 64:
case 225:
case 55:
return false;
}
/* Do not hit yourself. Idiot. */
if (entity == m_pSelf) return false;
return true;
}
TraceType_t trace::FilterDefault::GetTraceType() const {
return TRACE_EVERYTHING;
}

View File

@ -1,31 +0,0 @@
/*
* trace.h
*
* Created on: Oct 10, 2016
* Author: nullifiedcat
*/
#ifndef TRACE_H_
#define TRACE_H_
#include "fixsdk.h"
#include <engine/IEngineTrace.h>
class IClientEntity;
namespace trace {
class FilterDefault : public ITraceFilter {
public:
IClientEntity* m_pSelf;
public:
virtual ~FilterDefault();
FilterDefault();
virtual bool ShouldHitEntity(IHandleEntity* entity, int mask);
void SetSelf(IClientEntity* self);
virtual TraceType_t GetTraceType() const;
};
}
#endif /* TRACE_H_ */

View File

@ -1,35 +0,0 @@
/*
* usercmd.h
*
* Created on: Oct 5, 2016
* Author: nullifiedcat
*/
#ifndef USERCMD_H_
#define USERCMD_H_
#include <stdint.h>
#include "fixsdk.h"
#include <mathlib/vector.h>
class CUserCmd {
public:
virtual ~CUserCmd() {};
int command_number;
int tick_count;
Vector viewangles;
float forwardmove;
float sidemove;
float upmove;
int buttons;
uint8_t impulse;
int weaponselect;
int weaponsubtype;
int random_seed;
short mousedx;
short mousedy;
bool hasbeenpredicted;
};
#endif /* USERCMD_H_ */