From 992052155946a82a990137d19819e3fb002a842a Mon Sep 17 00:00:00 2001 From: nullifiedcat Date: Fri, 2 Dec 2016 21:01:15 +0300 Subject: [PATCH] sticky!!! --- uran/src/entity.cpp | 1 + uran/src/entity.h | 1 + uran/src/hack.cpp | 2 ++ uran/src/hacks/AutoSticky.cpp | 30 +++++++++++++++++++++++++----- uran/src/hacks/AutoSticky.h | 2 +- uran/src/hacks/IHack.h | 3 +++ 6 files changed, 33 insertions(+), 6 deletions(-) diff --git a/uran/src/entity.cpp b/uran/src/entity.cpp index c336c893..b57570ea 100644 --- a/uran/src/entity.cpp +++ b/uran/src/entity.cpp @@ -48,6 +48,7 @@ void EntityVariables::Init() { this->iItemDefinitionIndex = gNetvars.get_offset("DT_EconEntity", "m_AttributeManager", "m_Item", "m_iItemDefinitionIndex"); this->flChargeBeginTime = gNetvars.get_offset("DT_WeaponPipebombLauncher", "PipebombLauncherLocalData", "m_flChargeBeginTime"); this->flLastFireTime = gNetvars.get_offset("DT_TFWeaponBase", "LocalActiveTFWeaponData", "m_flLastFireTime"); + this->hThrower = gNetvars.get_offset("DT_BaseGrenade", "m_hThrower"); } void InitEntityOffsets() { diff --git a/uran/src/entity.h b/uran/src/entity.h index 1139c656..8254b642 100644 --- a/uran/src/entity.h +++ b/uran/src/entity.h @@ -73,6 +73,7 @@ public: offset_t flChargeBeginTime; offset_t flLastFireTime; + offset_t hThrower; }; // TODO globals diff --git a/uran/src/hack.cpp b/uran/src/hack.cpp index ec38c8d4..53101a24 100644 --- a/uran/src/hack.cpp +++ b/uran/src/hack.cpp @@ -38,6 +38,7 @@ #include "drawing.h" #include "hacks/Airstuck.h" #include "hacks/AutoStrafe.h" +#include "hacks/AutoSticky.h" #include "entity.h" #include "localplayer.h" #include "playerresource.h" @@ -186,6 +187,7 @@ void hack::InitHacks() { hack::AddHack(g_phBunnyhop = new HBunnyhop()); hack::AddHack(g_phEsp = new HEsp()); hack::AddHack(g_phTrigger = new HTrigger()); + hack::AddHack(g_phAutoSticky = new AutoSticky()); hack::AddHack(g_phAirstuck = new Airstuck()); } diff --git a/uran/src/hacks/AutoSticky.cpp b/uran/src/hacks/AutoSticky.cpp index d4714d49..cd16a898 100644 --- a/uran/src/hacks/AutoSticky.cpp +++ b/uran/src/hacks/AutoSticky.cpp @@ -11,6 +11,10 @@ #include "../interfaces.h" #include "../entitycache.h" #include "../helpers.h" +#include "../localplayer.h" +#include "../usercmd.h" +#include "../sdk/in_buttons.h" +#include "../logging.h" #include "../fixsdk.h" #include #include @@ -21,27 +25,41 @@ const char* AutoSticky::GetName() { // TODO scottish cyclops AutoSticky::AutoSticky() { + this->v_flDetonateDistance = CreateConVar("u_sticky_distance", "200", "Sticky detonation distance"); this->v_bBuildings = CreateConVar("u_sticky_buildings", "1", "Stickies detonate at enemies' buildings"); this->v_bEnabled = CreateConVar("u_sticky_enabled", "1", "Enable stickybot"); this->v_bScottish = CreateConVar("u_sticky_scottish", "0", "Enable stickybot scottish resistance compatability"); } bool AutoSticky::ShouldDetonate(IClientEntity* bomb) { + //logging::Info("Should detonate?"); for (int i = 0; i < gEntityCache.m_nMax; i++) { CachedEntity* ent = gEntityCache.GetEntity(i); - if (ent->m_iClassID != ClassID::CTFPlayer && !(this->v_bBuildings->GetBool() && IsBuilding(ent->m_pEntity))) return false; - if (ent->m_iTeam == GetEntityValue(bomb, eoffsets.iTeamNum)) return false; - if (ent->m_pEntity->GetAbsOrigin().DistToSqr(bomb->GetAbsOrigin())) return false; + if (ent->m_bNULL) continue; + if (ent->m_iClassID != ClassID::CTFPlayer && !(this->v_bBuildings->GetBool() && IsBuilding(ent->m_pEntity))) continue; + if (ent->m_iTeam == GetEntityValue(bomb, eoffsets.iTeamNum)) continue; + if (ent->m_pEntity->GetAbsOrigin().DistToSqr(bomb->GetAbsOrigin()) > this->v_flDetonateDistance->GetFloat() * this->v_flDetonateDistance->GetFloat()) continue; return true; } return false; } bool AutoSticky::CreateMove(void*, float, CUserCmd* cmd) { + if (!this->v_bEnabled->GetBool()) return true; for (int i = 0; i < gEntityCache.m_nMax; i++) { CachedEntity* ent = gEntityCache.GetEntity(i); - if (ent->m_iClassID != ClassID::CTFGrenadePipebombProjectile) return true; - + if (ent->m_bNULL) continue; + if (ent->m_iClassID != ClassID::CTFGrenadePipebombProjectile) continue; + if (g_pLocalPlayer->entity) { + IClientEntity* owner = interfaces::entityList->GetClientEntity(ent->Var(eoffsets.hThrower) & 0xFFF); + //logging::Info("Owner: 0x%08x", owner); + if (!owner) continue; + if (owner != g_pLocalPlayer->entity) continue; + } else continue; + if (ShouldDetonate(ent->m_pEntity)) { + //logging::Info("Detonate!"); + cmd->buttons |= IN_ATTACK2; + } } return true; } @@ -49,3 +67,5 @@ bool AutoSticky::CreateMove(void*, float, CUserCmd* cmd) { void AutoSticky::PaintTraverse(void*, unsigned int, bool, bool) { } + +DEFINE_HACK_SINGLETON(AutoSticky); diff --git a/uran/src/hacks/AutoSticky.h b/uran/src/hacks/AutoSticky.h index 8ac93d69..ce516116 100644 --- a/uran/src/hacks/AutoSticky.h +++ b/uran/src/hacks/AutoSticky.h @@ -12,7 +12,7 @@ class IClientEntity; -class AutoSticky { +class AutoSticky : public IHack { public: DECLARE_HACK_METHODS(); AutoSticky(); diff --git a/uran/src/hacks/IHack.h b/uran/src/hacks/IHack.h index 4950ae33..9743b146 100644 --- a/uran/src/hacks/IHack.h +++ b/uran/src/hacks/IHack.h @@ -21,6 +21,9 @@ typedef unsigned int uint32; void PaintTraverse(void*, unsigned int, bool, bool); #define DECLARE_HACK_SINGLETON(x) \ +extern x* g_ph##x; + +#define DEFINE_HACK_SINGLETON(x) \ x* g_ph##x = 0; class IHack {