Add auto charge/demoknight support

This commit is contained in:
TotallyNotElite 2021-01-28 13:51:23 +01:00 committed by TotallyNotElite
parent 3b57ca33c1
commit 19da6f98d4
8 changed files with 67 additions and 16 deletions

View File

@ -1,4 +1,4 @@
/*
/*
* entity.h
*
* Created on: Oct 6, 2016
@ -169,7 +169,8 @@ public:
offset_t res_bAlive;
offset_t m_nChargeResistType;
offset_t m_hHealingTarget;
offset_t m_flChargeLevel;
offset_t m_flChargeLevel; // Medigun
offset_t m_flChargeMeter; // Demoman Shield
offset_t m_rgflCoordinateFrame;
offset_t m_bFeignDeathReady;

View File

@ -12,7 +12,6 @@
namespace hacks::shared::catbot
{
extern Timer timer_votekicks;
bool should_ignore_player(CachedEntity *player);
void update();
void init();
void level_init();

View File

@ -27,5 +27,12 @@ public:
typedef Vector &(*fn_t)(IClientEntity *);
return vfunc<fn_t>(self, offsets::PlatformOffset(196, offsets::undefined, 196), 0)(self);
}
inline static IClientEntity *GetEquippedDemoShield(IClientEntity *self)
{
static auto signature = gSignatures.GetClientSignature("55 89 E5 57 56 53 83 EC 2C 8B 45 ? 8B 98 ? ? ? ? 85 DB 7E");
typedef IClientEntity *(*GetEquippedDemoShield_t)(IClientEntity *);
static GetEquippedDemoShield_t GetEquippedDemoShield_fn = GetEquippedDemoShield_t(signature);
return GetEquippedDemoShield_fn(self);
}
};
} // namespace re

View File

@ -59,6 +59,7 @@ void NetVars::Init()
this->m_nChargeResistType = gNetvars.get_offset("DT_WeaponMedigun", "m_nChargeResistType");
this->m_hHealingTarget = gNetvars.get_offset("DT_WeaponMedigun", "m_hHealingTarget");
this->m_flChargeLevel = gNetvars.get_offset("DT_WeaponMedigun", "NonLocalTFWeaponMedigunData", "m_flChargeLevel");
this->m_flChargeMeter = gNetvars.get_offset("DT_TFPlayer", "m_Shared", "m_flChargeMeter");
this->m_bFeignDeathReady = gNetvars.get_offset("DT_TFPlayer", "m_Shared", "m_bFeignDeathReady");
this->m_bCarryingObject = gNetvars.get_offset("DT_TFPlayer", "m_Shared", "m_bCarryingObject");
this->m_hCarriedObject = gNetvars.get_offset("DT_TFPlayer", "m_Shared", "m_hCarriedObject");

View File

@ -681,8 +681,6 @@ bool IsTargetStateGood(CachedEntity *entity)
// Some global checks
if (!player_tools::shouldTarget(entity))
return false;
if (hacks::shared::catbot::should_ignore_player(entity))
return false;
// Invulnerable players, ex: uber, bonk
if (IsPlayerInvulnerable(entity))
return false;

View File

@ -541,14 +541,6 @@ static Timer waiting_for_quit_timer{};
static std::vector<unsigned> ipc_blacklist{};
bool should_ignore_player(CachedEntity *player)
{
if (CE_INVALID(player))
return false;
return playerlist::IsFriend(player);
}
#if ENABLE_IPC
void update_ipc_data(ipc::user_data_s &data)
{
@ -643,7 +635,7 @@ void smart_crouch()
for (int i = 0; i <= g_IEngine->GetMaxClients(); i++)
{
auto ent = ENTITY(i);
if (CE_BAD(ent) || ent->m_Type() != ENTITY_PLAYER || ent->m_iTeam() == LOCAL_E->m_iTeam() || !(ent->hitboxes.GetHitbox(0)) || !(ent->m_bAlivePlayer()) || !player_tools::shouldTarget(ent) || should_ignore_player(ent))
if (CE_BAD(ent) || ent->m_Type() != ENTITY_PLAYER || ent->m_iTeam() == LOCAL_E->m_iTeam() || !(ent->hitboxes.GetHitbox(0)) || !(ent->m_bAlivePlayer()) || !player_tools::shouldTarget(ent))
continue;
bool failedvis = false;
for (int j = 0; j < 18; j++)

View File

@ -688,6 +688,24 @@ static CatCommand dump_vars_by_name("debug_dump_netvars_name", "Dump netvars of
DumpRecvTable(ent, clz->m_pRecvTable, 0, ft, 0);
}
});
static CatCommand debug_print_weaponid("debug_weaponid", "Print the weapon IDs of all currently equiped weapons", [](const CCommand &) {
// Invalid player
if (CE_BAD(LOCAL_E))
return;
int *hWeapons = &CE_INT(LOCAL_E, netvar.hMyWeapons);
// Go through the handle array and search for the item
for (int i = 0; hWeapons[i]; i++)
{
if (IDX_BAD(HandleToIDX(hWeapons[i])))
continue;
// Get the weapon
CachedEntity *weapon = ENTITY(HandleToIDX(hWeapons[i]));
// Print weaponid
logging::Info("weapon %i: %i", i, re::C_TFWeaponBase::GetWeaponID(RAW_ENT(weapon)));
}
});
#if ENABLE_VISUALS && !ENFORCE_STREAM_SAFETY
// This makes us able to see enemy class and status in scoreboard and player panel
static std::unique_ptr<BytePatch> patch_playerpanel;

View File

@ -617,10 +617,45 @@ bool meleeAttack(int slot, std::pair<CachedEntity *, float> &nearest)
if (navparser::NavEngine::current_priority > prio_melee)
return false;
static Timer melee_cooldown{};
auto raw_local = RAW_ENT(LOCAL_E);
// We are charging, let the charge aimbot do it's job
if (HasCondition<TFCond_Charging>(LOCAL_E))
{
navparser::NavEngine::cancelPath();
return true;
}
static Timer melee_cooldown{};
bool isVisible;
{
Ray_t ray;
trace_t trace;
trace::filter_default.SetSelf(raw_local);
auto hb = nearest.first->hitboxes.GetHitbox(spine_3);
if (hb)
{
ray.Init(g_pLocalPlayer->v_Origin + Vector{ 0, 0, 20 }, hb->center, raw_local->GetCollideable()->OBBMins(), raw_local->GetCollideable()->OBBMaxs());
g_ITrace->TraceRay(ray, MASK_PLAYERSOLID, &trace::filter_default, &trace);
isVisible = (IClientEntity *) trace.m_pEnt == RAW_ENT(nearest.first);
}
else
isVisible = false;
}
// TODO: FIXME We make no effort to determine if the charge aimbot is actually on or not
if (re::C_BasePlayer::GetEquippedDemoShield(raw_local) && re::CTFPlayerShared::GetChargeMeter(re::CTFPlayerShared::GetPlayerShared(raw_local)) == 100.0f && nearest.second < 1.5f * 750 - 100 && isVisible)
{
// Charge
current_user_cmd->buttons |= IN_ATTACK2;
AimAt(g_pLocalPlayer->v_Eye, nearest.first->m_vecOrigin(), current_user_cmd);
navparser::NavEngine::cancelPath();
return true;
}
// If we are close enough, don't even bother with using the navparser to get there
if (nearest.second < 200 && nearest.first->IsVisible())
else if (nearest.second < 200 && isVisible)
{
WalkTo(nearest.first->m_vecOrigin());
navparser::NavEngine::cancelPath();