sticky!!!

This commit is contained in:
nullifiedcat 2016-12-02 21:01:15 +03:00
parent bc91c94b3e
commit 9920521559
6 changed files with 33 additions and 6 deletions

View File

@ -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() {

View File

@ -73,6 +73,7 @@ public:
offset_t flChargeBeginTime;
offset_t flLastFireTime;
offset_t hThrower;
};
// TODO globals

View File

@ -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());
}

View File

@ -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 <icliententitylist.h>
#include <icliententity.h>
@ -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<int>(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<int>(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<int>(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);

View File

@ -12,7 +12,7 @@
class IClientEntity;
class AutoSticky {
class AutoSticky : public IHack {
public:
DECLARE_HACK_METHODS();
AutoSticky();

View File

@ -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 {