From bc91c94b3e9867d4c0f20a3831b27595a96b9fa5 Mon Sep 17 00:00:00 2001 From: nullifiedcat Date: Fri, 2 Dec 2016 20:42:06 +0300 Subject: [PATCH] auto sticky!!! --- uran/src/hacks/AutoSticky.cpp | 51 +++++++++++++++++++++++++++++++++++ uran/src/hacks/AutoSticky.h | 28 +++++++++++++++++++ uran/src/hacks/IHack.h | 3 +++ 3 files changed, 82 insertions(+) create mode 100644 uran/src/hacks/AutoSticky.cpp create mode 100644 uran/src/hacks/AutoSticky.h diff --git a/uran/src/hacks/AutoSticky.cpp b/uran/src/hacks/AutoSticky.cpp new file mode 100644 index 00000000..d4714d49 --- /dev/null +++ b/uran/src/hacks/AutoSticky.cpp @@ -0,0 +1,51 @@ +/* + * AutoSticky.cpp + * + * Created on: Dec 2, 2016 + * Author: nullifiedcat + */ + +#include "AutoSticky.h" + +#include "../entity.h" +#include "../interfaces.h" +#include "../entitycache.h" +#include "../helpers.h" +#include "../fixsdk.h" +#include +#include + +const char* AutoSticky::GetName() { + return "AUTO-STICKY"; +} + +// TODO scottish cyclops +AutoSticky::AutoSticky() { + 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) { + 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; + return true; + } + return false; +} + +bool AutoSticky::CreateMove(void*, float, CUserCmd* cmd) { + for (int i = 0; i < gEntityCache.m_nMax; i++) { + CachedEntity* ent = gEntityCache.GetEntity(i); + if (ent->m_iClassID != ClassID::CTFGrenadePipebombProjectile) return true; + + } + return true; +} + +void AutoSticky::PaintTraverse(void*, unsigned int, bool, bool) { + +} diff --git a/uran/src/hacks/AutoSticky.h b/uran/src/hacks/AutoSticky.h new file mode 100644 index 00000000..8ac93d69 --- /dev/null +++ b/uran/src/hacks/AutoSticky.h @@ -0,0 +1,28 @@ +/* + * AutoSticky.h + * + * Created on: Dec 2, 2016 + * Author: nullifiedcat + */ + +#ifndef HACKS_AUTOSTICKY_H_ +#define HACKS_AUTOSTICKY_H_ + +#include "IHack.h" + +class IClientEntity; + +class AutoSticky { +public: + DECLARE_HACK_METHODS(); + AutoSticky(); + bool ShouldDetonate(IClientEntity* bomb); + ConVar* v_bEnabled; + ConVar* v_bBuildings; + ConVar* v_bScottish; + ConVar* v_flDetonateDistance; +}; + +DECLARE_HACK_SINGLETON(AutoSticky); + +#endif /* HACKS_AUTOSTICKY_H_ */ diff --git a/uran/src/hacks/IHack.h b/uran/src/hacks/IHack.h index d28a8242..4950ae33 100644 --- a/uran/src/hacks/IHack.h +++ b/uran/src/hacks/IHack.h @@ -20,6 +20,9 @@ typedef unsigned int uint32; bool CreateMove(void*, float, CUserCmd*); \ void PaintTraverse(void*, unsigned int, bool, bool); +#define DECLARE_HACK_SINGLETON(x) \ +x* g_ph##x = 0; + class IHack { public: inline virtual ~IHack() {};