asdadssdsds

This commit is contained in:
nullifiedcat 2016-10-30 16:08:04 +03:00
parent 0fba084e6a
commit 003cb11f1f
16 changed files with 488 additions and 138 deletions

View File

@ -62,6 +62,7 @@ Elf32_Shdr *getSectionHeader(void *module, const char *sectionName)
uintptr_t CSignature::dwFindPattern(uintptr_t dwAddress, uintptr_t dwLength, const char* szPattern)
{
logging::Info("Seaching for pattern from 0x%08x, len 0x%08x", dwAddress, dwLength);
const char* pat = szPattern;
uintptr_t firstMatch = NULL;
for (uintptr_t pCur = dwAddress; pCur < dwLength; pCur++)
@ -101,7 +102,7 @@ uintptr_t CSignature::GetClientSignature(char* chPattern)
// into memory, meaning that we cannot get the string table from the module.
static int fd = open(sharedobj::client->path, O_RDONLY);
static void *module = mmap(NULL, lseek(fd, 0, SEEK_END), PROT_READ, MAP_SHARED, fd, 0);
static link_map *moduleMap = (link_map *)GetModuleHandleSafe("./tf/bin/client.so");
static link_map *moduleMap = sharedobj::client->lmap;
//static void *module = (void *)moduleMap->l_addr;

View File

@ -20,14 +20,14 @@ 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(255, 64, 64, 255);
Color draw::blue(64, 64, 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", 19, 500, 0, 0, 0x200);
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);
}

View File

@ -24,6 +24,8 @@
#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"
@ -99,13 +101,6 @@ void hack::AddHack(IHack* hack) {
ICvar* g_pCVar = 0;
class CGlowObject {
public:
void* handle;
float r, g, b, a;
bool p1, p2;
int p3, p4;
};
void hack::Initialize() {
logging::Initialize();
@ -146,6 +141,8 @@ void hack::Initialize() {
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();

View File

@ -0,0 +1,21 @@
/*
* AntiAim.cpp
*
* Created on: Oct 26, 2016
* Author: nullifiedcat
*/
#include "AntiAim.h"
#include "../helpers.h"
void AntiAim::Create() {
this->v_bEnabled = CreateConVar("u_antiaim_enabled", "0", "Enable AntiAim");
}
bool AntiAim::CreateMove(void*, float, CUserCmd* cmd) {
if (!this->v_bEnabled->GetBool()) return true;
return false;
}
void AntiAim::Destroy() {}
void AntiAim::PaintTraverse(void*, unsigned int, bool, bool) {}

View File

@ -10,12 +10,15 @@
#include "IHack.h"
class ConVar;
class AntiAim : public IHack {
public:
void Create();
bool CreateMove(void*, float, CUserCmd*);
void Destroy();
void PaintTraverse(void*, unsigned int, bool, bool);
ConVar* v_bEnabled;
};
#endif /* ANTIAIM_H_ */

View File

@ -30,8 +30,6 @@ bool fix_silent;
int target_lock;
trace::FilterDefault* aim_filter;
void HAimbot::Create() {
this->v_bEnabled = CreateConVar("u_aimbot_enabled", "0", "Enables aimbot. EXPERIMENTAL AND TOTALLY NOT LEGIT");
this->v_iHitbox = CreateConVar("u_aimbot_hitbox", "0", "Hitbox");
@ -46,7 +44,6 @@ void HAimbot::Create() {
this->v_bCharge = CreateConVar("u_aimbot_charge", "1", "Autoshoot only with charge ready");
this->v_bEnabledAttacking = CreateConVar("u_aimbot_enable_attack_only", "0", "Aimbot only active with attack key held");
this->v_bStrictAttack = CreateConVar("u_aimbot_strict_attack", "0", "Not attacking unless target is locked");
aim_filter = new trace::FilterDefault();
fix_silent = false;
}
@ -114,29 +111,6 @@ bool HAimbot::CreateMove(void*, float, CUserCmd* cmd) {
void HAimbot::Destroy() {}
void HAimbot::PaintTraverse(void*, unsigned int, bool, bool) {}
bool HAimbot::IsVisible(IClientEntity* entity) {
//logging::Info("visible??");
trace_t aim_trace;
Ray_t ray;
IClientEntity* local = interfaces::entityList->GetClientEntity(interfaces::engineClient->GetLocalPlayer());
aim_filter->SetSelf(local);
Vector hit;
int ret = GetHitboxPosition(entity, v_iHitbox->GetInt(), hit);
if (ret) {
//logging::Info("ERROR %i", ret);
return false;
}
ray.Init(local->GetAbsOrigin() + GetEntityValue<Vector>(local, eoffsets.vViewOffset), hit);
interfaces::trace->TraceRay(ray, 0x4200400B, aim_filter, &aim_trace);
if (aim_trace.m_pEnt) {
//return (aim_trace.m_pEnt == (CBaseEntity*)(entity));
//return (aim_trace.m_pEnt == entity);
return ((IClientEntity*)aim_trace.m_pEnt) == entity;
}
//logging::Info("nO");
return false;
}
bool HAimbot::ShouldTarget(IClientEntity* entity) {
if (!entity) return false;
if (entity->IsDormant()) return false;
@ -163,51 +137,7 @@ bool HAimbot::ShouldTarget(IClientEntity* entity) {
}
int econd = GetEntityValue<int>(entity, eoffsets.iCond1);
if ((econd & cond_ex::vacc_bullet)) return false;
return this->IsVisible(entity);
}
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;
return IsEntityVisible(entity, v_iHitbox->GetInt());
}
void PredictPosition(Vector vec, IClientEntity* ent) {
@ -243,14 +173,14 @@ bool HAimbot::Aim(IClientEntity* entity, CUserCmd* cmd) {
cmd->buttons |= IN_ATTACK;
}
if (this->v_bSilent->GetBool()) {
FixMovement(*cmd, viewangles_old);
/*Vector vsilent(cmd->forwardmove, cmd->sidemove, cmd->upmove);
//FixMovement(*cmd, viewangles_old);
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;*/
cmd->sidemove = sin(yaw) * speed;
}
if (!this->v_bSilent->GetBool()) {
QAngle a;

View File

@ -19,7 +19,6 @@ public:
void Destroy();
bool CreateMove(void*, float, CUserCmd*);
void PaintTraverse(void*, unsigned int, bool, bool);
bool IsVisible(IClientEntity* entity);
bool ShouldTarget(IClientEntity* entity);
bool Aim(IClientEntity* entity, CUserCmd* cmd);
ConVar* v_bEnabled;

View File

@ -46,13 +46,12 @@ void HEsp::PaintTraverse(void*, unsigned int, bool, bool) {
void HEsp::Create() {
this->v_bEnabled = CreateConVar("u_esp_enabled", "1", "Enables ESP");
this->v_bBoxESP = CreateConVar("u_esp_box", "0", "Box ESP (NOT IMPLEMENTED)");
this->v_bEntityESP = CreateConVar("u_esp_entity", "0", "Entity ESP (dev)");
this->v_bTeammates = CreateConVar("u_esp_teammates", "0", "ESP own team");
this->v_bItemESP = CreateConVar("u_esp_item", "1", "Item ESP (powerups, health packs, etc)");
this->v_bTeammatePowerup = CreateConVar("u_esp_powerup_team", "1", "Show powerups on teammates if u_esp_teammates is 0");
this->v_bShowHead = CreateConVar("u_esp_head", "0", "Shows head (EXPERIMENTAL)");
this->v_bShowTargetScore = CreateConVar("u_esp_threat", "1", "Shows target score aka threat value");
this->v_bShowEntityID = CreateConVar("u_esp_entity_id", "0", "Shows EID");
//this->v_bModelInfo = CreateConVar("u_esp_model", "0", "ESP model info");
/*this->v_bEnabled = new ConVar("u_esp_enabled", "1");
this->v_bShowPacks = new ConVar("u_esp_showpacks", "1");
@ -60,6 +59,8 @@ void HEsp::Create() {
interfaces::cvar->RegisterConCommand(v_bShowPacks);*/
}
#define ESP_HEIGHT 14
void HEsp::ProcessEntity(IClientEntity* ent, int idx) {
if (!this->v_bEnabled->GetBool()) return;
if (!ent) return;
@ -80,6 +81,10 @@ void HEsp::ProcessEntity(IClientEntity* ent, int idx) {
// 89 tele 88 sentry 86 disp
int ClassID = ent->GetClientClass()->m_ClassID;
scr.y -= 32;
if (v_bShowEntityID->GetBool()) {
draw::DrawString(scr.x, scr.y, draw::white, true, "IDX %i CLASS %i", idx, ent->GetClientClass()->m_ClassID);
scr.y += ESP_HEIGHT;
}
switch (ClassID) {
case 1: {
if (!this->v_bItemESP->GetBool()) break;
@ -87,10 +92,10 @@ void HEsp::ProcessEntity(IClientEntity* ent, int idx) {
if (type == item_type::item_null) break;
if (type >= item_medkit_small && type <= item_medkit_large) {
draw::DrawString(scr.x, scr.y, draw::white, true, "%s HEALTH", packs[type - item_medkit_small]);
scr.y += 16;
scr.y += ESP_HEIGHT;
} else if (type >= item_ammo_small && type <= item_ammo_large) {
draw::DrawString(scr.x, scr.y, draw::white, true, "%s AMMO", packs[type - item_ammo_small]);
scr.y += 16;
scr.y += ESP_HEIGHT;
} else if (type >= item_mp_strength && type <= item_mp_crit) {
int skin = ent->GetSkin();
Color pickupColor;
@ -102,7 +107,7 @@ void HEsp::ProcessEntity(IClientEntity* ent, int idx) {
pickupColor = draw::yellow;
}
draw::DrawString(scr.x, scr.y, pickupColor, true, "%s PICKUP", powerups[type - item_mp_strength]);
scr.y += 16;
scr.y += ESP_HEIGHT;
}
} break;
case 241: {
@ -121,45 +126,29 @@ void HEsp::ProcessEntity(IClientEntity* ent, int idx) {
if (power >= 0 && (!teammate || this->v_bTeammatePowerup->GetBool() || this->v_bTeammates->GetBool())) {
Color clr = (team == 3 ? draw::blue : (team == 2 ? draw::red : draw::white));
draw::DrawString(scr.x, scr.y, clr, true, "HAS [%s]", powerups[power]);
scr.y += 16;
scr.y += ESP_HEIGHT;
}
if (teammate && !this->v_bTeammates->GetBool()) return;
if (v_bShowTargetScore->GetBool()) {
draw::DrawString(scr.x, scr.y, clr, true, "Threat: %i", GetScoreForEntity(ent));
scr.y += 16;
scr.y += ESP_HEIGHT;
}
if (v_bShowHead->GetBool()) {
Vector pos_head;
int ret = GetHitboxPosition(ent, hitbox::hb_head, pos_head);
if (ret) {
draw::DrawString(scr.x, scr.y, clr, true, "FAILED TO GET HEAD POSITION: %i", ret);
scr.y += 16;
} else {
//draw::DrawString(scr.x, scr.y, clr, true, "HEAD: %f %f %f", pos_head.x, pos_head.y, pos_head.z);
scr.y += 16;
Vector screen_head;
if (draw::WorldToScreen(pos_head, screen_head)) {
draw::DrawString(screen_head.x, screen_head.y, clr, true, "HEAD");
//draw::DrawString(screen_head.x, screen_head.y, 32, 32, clr);
}
}
}
draw::DrawString(scr.x, scr.y, clr, true, "%iu %s", (int)distance, info.name);
scr.y += 16;
draw::DrawString(scr.x, scr.y, clr, true, "%im %s", (int)(distance / 64 * 1.22f), info.name);
scr.y += ESP_HEIGHT;
if (pclass < 10 && pclass > 0)
draw::DrawString(scr.x, scr.y, clr, true, "%s - %i HP", classes[pclass - 1], health);
scr.y += 16;
scr.y += ESP_HEIGHT;
if (pcond & cond::cloaked) {
draw::DrawString(scr.x, scr.y, clr, true, "CLOAKED");
scr.y += 16;
scr.y += ESP_HEIGHT;
}
if (IsPlayerInvulnerable(ent)) {
draw::DrawString(scr.x, scr.y, clr, true, "INVULNERABLE");
scr.y += 16;
scr.y += ESP_HEIGHT;
}
if (IsPlayerCritBoosted(ent)) {
draw::DrawString(scr.x, scr.y, clr, true, "CRIT BOOSTED");
scr.y += 16;
scr.y += ESP_HEIGHT;
}
} break;
case 89:
@ -172,9 +161,9 @@ void HEsp::ProcessEntity(IClientEntity* ent, int idx) {
const char* name = (ClassID == 89 ? "Teleporter" : (ClassID == 88 ? "Sentry Gun" : "Dispenser"));
Color clr = ((team == 2) ? draw::red : (team == 3 ? draw::blue : draw::white));
draw::DrawString(scr.x, scr.y, clr, true, "LV %i %s HP %i", level, name, health);
scr.y += 16;
scr.y += ESP_HEIGHT;
draw::DrawString(scr.x, scr.y, clr, true, "%iu", (int)distance);
scr.y += 16;
scr.y += ESP_HEIGHT;
} break;
case 212: { /* Pipes and Stickies */
int team = GetEntityValue<int>(ent, eoffsets.iTeamNum);
@ -182,16 +171,16 @@ void HEsp::ProcessEntity(IClientEntity* ent, int idx) {
int type = GetEntityValue<int>(ent, eoffsets.iPipeType);
Color clr = ((team == 2) ? draw::red : (team == 3 ? draw::blue : draw::white));
draw::DrawString(scr.x, scr.y, clr, true, type ? "STICKY" : "PIPE", type);
scr.y += 16;
scr.y += ESP_HEIGHT;
draw::DrawString(scr.x, scr.y, clr, true, "%iu", (int)distance);
scr.y += 16;
scr.y += ESP_HEIGHT;
} break;
}
if (this->v_bEntityESP->GetBool()) {
draw::DrawString(scr.x, scr.y, draw::white, true, "%s [%i]", ent->GetClientClass()->GetName(), ent->GetClientClass()->m_ClassID);
scr.y += 16;
scr.y += ESP_HEIGHT;
draw::DrawString(scr.x, scr.y, draw::white, true, "%s %iu", GetModelPath(ent), (int)distance);
scr.y += 16;
scr.y += ESP_HEIGHT;
}
}

View File

@ -28,6 +28,7 @@ public:
ConVar* v_bTeammatePowerup;
ConVar* v_bShowHead;
ConVar* v_bShowTargetScore;
ConVar* v_bShowEntityID;
//ConVar* v_bModelInfo;
};

View File

@ -10,16 +10,95 @@
#include "../copypasted/CSignature.h"
#include "../logging.h"
#include "../entity.h"
#include "../helpers.h"
#include "../interfaces.h"
#include "../localplayer.h"
#include "../fixsdk.h"
#include <icliententity.h>
#include <Color.h>
#include <client_class.h>
#include <icliententitylist.h>
#include <cdll_int.h>
#include <tier1/convar.h>
#include <basehandle.h>
// -------------------------------------------------------------------------------------------------- //
template< class T >
class CHandle : public CBaseHandle
{
public:
CHandle();
CHandle( int iEntry, int iSerialNumber );
CHandle( const CBaseHandle &handle );
CHandle( T *pVal );
// The index should have come from a call to ToInt(). If it hasn't, you're in trouble.
static CHandle<T> FromIndex( int index );
T* Get() const;
void Set( const T* pVal );
operator T*();
operator T*() const;
bool operator !() const;
bool operator==( T *val ) const;
bool operator!=( T *val ) const;
const CBaseHandle& operator=( const T *val );
T* operator->() const;
};
struct GlowObjectDefinition_t
{
CHandle<CBaseEntity> m_hEntity;
Vector m_vGlowColor;
float m_flGlowAlpha;
bool m_bRenderWhenOccluded;
bool m_bRenderWhenUnoccluded;
int m_nSplitScreenSlot;
// Linked list of free slots
int m_nNextFreeSlot;
};
struct CGlowManager
{
CUtlVector<GlowObjectDefinition_t> m_GlowObjectDefinitions;
int RegisterGlowObject(CBaseEntity *pEntity, const Vector &vGlowColor, float flGlowAlpha, bool bRenderWhenOccluded, bool bRenderWhenUnoccluded, int nSplitScreenSlot);
};
template<typename T>
T GetFunction(void* obj, unsigned idx) {
const void** vtbl = *reinterpret_cast<const void***>((size_t*)obj);
return reinterpret_cast<T>(vtbl[idx]);
}
void UpdateGlowEffect(IClientEntity* entity);
void DestroyGlowEffect(IClientEntity* entity);
//void GetHealthColor(IClientEntity* entity, Color)
void ToggleEntityGlow(IClientEntity* entity, bool glow) {
if (!entity) return;
if (GetEntityValue<int>(entity, eoffsets.bGlowEnabled) == glow) return;
SetEntityValue<int>(entity, eoffsets.bGlowEnabled, (int)glow);
if (glow) UpdateGlowEffect(entity);
else DestroyGlowEffect(entity);
}
void UpdateGlowEffect(IClientEntity* entity) {
typedef void (*UpdateGlowEffect_t)(IClientEntity* entity);
//((UpdateGlowEffect_t)((*(uintptr_t*)entity)[0x35C / 4]))(entity);
GetFunction<UpdateGlowEffect_t>(entity, 0x35c / 4);
}
void DestroyGlowEffect(IClientEntity* entity) {
typedef void (*DestroyGlowEffect_t)(IClientEntity* entity);
GetFunction<DestroyGlowEffect_t>(entity, 0x360 / 4);
}
void SetEntityGlowColor(IClientEntity* entity, Color& color) {
@ -27,15 +106,49 @@ void SetEntityGlowColor(IClientEntity* entity, Color& color) {
}
void HGlow::Create() {
m_pGlowManager = **(CGlowManager***)(gSignatures.GetClientSignature("A1 ? ? ? ? C7 04 24 ? ? ? ? 89 44 24 04 E8 ? ? ? ? 8B 35 ? ? ? ? 89 C7 C1 E0 05 89 45 CC 01 C6 E9") + 8);
if (m_pGlowManager == 0) {
CGlowManager* g_pGlowManager = 0;
void CC_GlowSigSearch(const CCommand& args) {
logging::Info("Searching for %s", args.ArgS());
g_pGlowManager = *(CGlowManager**)(gSignatures.GetClientSignature((char*)args.ArgS()) + 8);
if (g_pGlowManager == 0) {
logging::Info("GlowManager sigsearch failed");
}
logging::Info("GlowManager: 0x%08f", m_pGlowManager);
logging::Info("GlowManager: 0x%08f", g_pGlowManager);
}
void HGlow::Create() {
cmd_scan = CreateConCommand("u_glow_scan", CC_GlowSigSearch, "Re-scans the memory for glow ptr");
v_bEnabled = CreateConVar("u_glow_enabled", "0", "Glow enabled. Experimental.");
v_bEnemyOnly = CreateConVar("u_glow_enemy", "1", "Only enemies will glow");
g_pGlowManager = *(CGlowManager**)(gSignatures.GetClientSignature("A1 ? ? ? ? C7 04 24 ? ? ? ? 89 44 24 04 E8 ? ? ? ? 8B 35 ? ? ? ? 89 C7 C1 E0 05 89 45 CC 01 C6 E9") + 8);
if (g_pGlowManager == 0) {
logging::Info("GlowManager sigsearch failed");
}
logging::Info("GlowManager: 0x%08f", g_pGlowManager);
}
bool HGlow::CreateMove(void*, float, CUserCmd*) {
if (!g_pGlowManager) return true;
if (!v_bEnabled->GetBool()) return true;
for (int i = 0; i < interfaces::entityList->GetHighestEntityIndex(); i++) {
IClientEntity* entity = interfaces::entityList->GetClientEntity(i);
if (i == interfaces::engineClient->GetLocalPlayer()) continue;
if (!entity) continue;
if (entity->GetClientClass()->m_ClassID != 241) continue;
if (entity->IsDormant()) {
ToggleEntityGlow(entity, false);
continue;
}
if (GetEntityValue<char>(entity, eoffsets.iLifeState)) {
ToggleEntityGlow(entity, false);
continue;
}
if (v_bEnemyOnly->GetBool()) {
if (GetEntityValue<int>(entity, eoffsets.iTeamNum) == g_pLocalPlayer->team) continue;
}
ToggleEntityGlow(entity, true);
}
return true;
}

View File

@ -13,16 +13,8 @@
#include "../fixsdk.h"
#include "basehandle.h"
class CGlowObject {
CBaseHandle handle;
float r, g, b, a;
unsigned char padding[0x20 - 0x14];
};
class CGlowManager {
public:
CGlowObject objects[1];
};
class ConVar;
class ConCommand;
class HGlow : public IHack {
public:
@ -30,7 +22,10 @@ public:
bool CreateMove(void*, float, CUserCmd*);
void Destroy();
void PaintTraverse(void*, unsigned int, bool, bool);
CGlowManager* m_pGlowManager;
ConVar* v_bEnabled;
ConVar* v_bEnemyOnly;
ConVar* v_bHealthColor;
ConCommand* cmd_scan;
};

186
uran/src/hacks/HPyroBot.cpp Normal file
View File

@ -0,0 +1,186 @@
/*
* HPyroBot.cpp
*
* Created on: Oct 30, 2016
* Author: nullifiedcat
*/
#include "HPyroBot.h"
#include "../interfaces.h"
#include "../entity.h"
#include "../helpers.h"
#include "../localplayer.h"
#include "../logging.h"
#include "../usercmd.h"
#include "../fixsdk.h"
#include <icliententity.h>
#include <icliententitylist.h>
#include <client_class.h>
#include <cdll_int.h>
unsigned long g_nTick = 0;
int g_nTargetID = 0;
//IClientEntity* eTarget;
bool bFollowingTeammate;
unsigned long nPilotSearch = 0;
void SetTarget(IClientEntity* ent) {
if (!ent) return;
g_nTargetID = ent->entindex();
}
IClientEntity* GetTarget() {
return interfaces::entityList->GetClientEntity(g_nTargetID);
}
void HPyroBot::ProcessEntity(IClientEntity* entity, bool enemy) {
IClientEntity* target = GetTarget();
if (!target) {
if (!enemy && v_iForceFollow->GetInt() != -1 && v_bForceFollowOnly->GetBool() && entity->entindex() != v_iForceFollow->GetInt()) return;
target = entity;
bFollowingTeammate = !enemy;
}
if (enemy) {
if (!bFollowingTeammate) {
if (DistToSqr(entity) <= DistToSqr(target)) {
target = entity;
}
} else {
target = entity;
}
bFollowingTeammate = false;
} else {
if (nPilotSearch < 100) return;
if (v_iForceFollow->GetInt() != -1) {
if (bFollowingTeammate && entity->entindex() == v_iForceFollow->GetInt()) {
target = entity;
} else {
return;
}
}
if (GetEntityValue<Vector>(entity, eoffsets.vVelocity).IsZero(1.0f)) return;
if (bFollowingTeammate && DistToSqr(entity) < DistToSqr(target)) {
target = entity;
}
}
SetTarget(target);
}
void AimAt(IClientEntity* entity, CUserCmd* cmd) {
Vector hit;
Vector angles;
if (GetHitboxPosition(entity, 4, hit)) return;
Vector tr = (hit - g_pLocalPlayer->v_Eye);
fVectorAngles(tr, angles);
fClampAngle(angles);
cmd->viewangles = angles;
QAngle a;
a.x = angles.x;
a.y = angles.y;
a.z = angles.z;
interfaces::engineClient->SetViewAngles(a);
}
bool HPyroBot::ShouldTarget(IClientEntity* ent) {
if (!ent || ent->IsDormant()) return false;
if (ent->GetClientClass()->m_ClassID != 241) return false;
if (GetEntityValue<char>(ent, eoffsets.iLifeState)) return false;
bool enemy = GetEntityValue<int>(ent, eoffsets.iTeamNum) != g_pLocalPlayer->team;
if (enemy) {
if (IsPlayerInvulnerable(ent)) return false;
}
if (DistToSqr(ent) > v_iMaxDistance->GetInt() * v_iMaxDistance->GetInt()) return false;
if (!IsEntityVisible(ent, 4)) return false;
return true;
}
void HPyroBot::Tick(CUserCmd* cmd) {
if (!g_pLocalPlayer->entity || g_pLocalPlayer->entity->IsDormant()) return;
if (g_pLocalPlayer->life_state) return;
IClientEntity* target = GetTarget();
IClientEntity* target_old = target;
if (!ShouldTarget(target)) {
SetTarget(0);
target = 0;
}
if (!target) {
nPilotSearch++;
/*if (nPilotSearch >= 100) {
interfaces::engineClient->ExecuteClientCmd("-forward");
interfaces::engineClient->ExecuteClientCmd("-attack");
}*/
} else {
nPilotSearch = 0;
interfaces::engineClient->ExecuteClientCmd("+forward");
}
if (g_nTick % 150 == 0 || !target) {
SetTarget(0);
for (int i = 0; i < 64 && i < interfaces::entityList->GetMaxEntities(); i++) {
IClientEntity* ent = interfaces::entityList->GetClientEntity(i);
if (!ShouldTarget(ent)) continue;
bool enemy = GetEntityValue<int>(ent, eoffsets.iTeamNum) != g_pLocalPlayer->team;
ProcessEntity(ent, enemy);
}
}
target = GetTarget();
if (!target) {
if (target_old != 0) {
logging::Info("Target lost!");
if (v_bChat->GetBool()) {
interfaces::engineClient->ServerCmd("say Target lost!");
}
}
return;
}
if (target != target_old) {
player_info_s info;
interfaces::engineClient->GetPlayerInfo(target->entindex(), &info);
logging::Info("Following %s", info.name);
if (v_bChat->GetBool()) {
char* cmd = new char[256];
if (bFollowingTeammate)
sprintf(cmd, "say Following: %s", info.name);
else
sprintf(cmd, "say Attacking: %s", info.name);
interfaces::engineClient->ServerCmd(cmd);
}
}
if (GetEntityValue<Vector>(g_pLocalPlayer->entity, eoffsets.vVelocity).IsZero(10.0f)) {
interfaces::engineClient->ExecuteClientCmd("+jump");
} else {
interfaces::engineClient->ExecuteClientCmd("-jump");
}
AimAt(target, cmd);
if (DistToSqr(target) < 200 * 200 && bFollowingTeammate) {
interfaces::engineClient->ExecuteClientCmd("-forward");
}
if (DistToSqr(target) < (v_iShootDistance->GetInt() * v_iShootDistance->GetInt()) && !bFollowingTeammate) {
interfaces::engineClient->ExecuteClientCmd("+attack");
} else {
interfaces::engineClient->ExecuteClientCmd("-attack");
}
}
bool HPyroBot::CreateMove(void*, float, CUserCmd* cmd) {
if (!v_bEnabled->GetBool()) return true;
Tick(cmd);
g_nTick++;
return true;
}
void HPyroBot::Create() {
logging::Info("Creating PyroBot");
v_bEnabled = CreateConVar("u_pyrobot_enabled", "0", "Enables WM1 bot");
v_iForceFollow = CreateConVar("u_pyrobot_force_follow", "-1", "Force follow a teammate");
v_bForceFollowOnly = CreateConVar("u_pyrobot_force_follow_only", "1", "only follow force");
v_iMaxDeltaY = CreateConVar("u_pyrobot_max_height", "450", "Max dY");
v_iMaxDistance = CreateConVar("u_pyrobot_aim_distance", "1300", "Distance");
v_iShootDistance = CreateConVar("u_pyrobot_shoot_distance", "800", "Shoot distance");
v_bChat = CreateConVar("u_pyrobot_chat", "0", "Enable chat");
}
void HPyroBot::Destroy() {}
void HPyroBot::PaintTraverse(void*, unsigned int, bool, bool) {}

34
uran/src/hacks/HPyroBot.h Normal file
View File

@ -0,0 +1,34 @@
/*
* HPyroBot.h
*
* Created on: Oct 30, 2016
* Author: nullifiedcat
*/
#ifndef HPYROBOT_H_
#define HPYROBOT_H_
#include "IHack.h"
class ConVar;
class IClientEntity;
class HPyroBot : public IHack {
public:
void Create();
bool CreateMove(void*, float, CUserCmd*);
void Destroy();
void PaintTraverse(void*, unsigned int, bool, bool);
void ProcessEntity(IClientEntity* entity, bool enemy);
void Tick(CUserCmd*);
bool ShouldTarget(IClientEntity* ent);
ConVar* v_bEnabled;
ConVar* v_iForceFollow;
ConVar* v_bForceFollowOnly;
ConVar* v_iMaxDistance;
ConVar* v_iShootDistance;
ConVar* v_iMaxDeltaY;
ConVar* v_bChat;
};
#endif /* HPYROBOT_H_ */

View File

@ -10,6 +10,8 @@
#include "entity.h"
#include "logging.h"
#include "usercmd.h"
#include "trace.h"
#include "localplayer.h"
#include "fixsdk.h"
#include <tier1/convar.h>
@ -17,6 +19,10 @@
#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);
@ -196,6 +202,7 @@ void VectorTransform (const float *in1, const matrix3x4_t& in2, float *out)
}
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);
@ -262,6 +269,76 @@ void FixMovement(CUserCmd& cmd, Vector& viewangles) {
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) {
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",

View File

@ -36,6 +36,10 @@ 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];

View File

@ -63,7 +63,7 @@ int GetScoreForEntity(IClientEntity* entity) {
total += 99;
}
if (distance != 0) {
int distance_factor = (4096 / distance) * 8;
int distance_factor = (4096 / distance) * 4;
total += distance_factor;
if (health != 0) {
int health_factor = (450 / health) * 4;