diff --git a/cathook/src/entity.cpp b/cathook/src/entity.cpp index 398f1a81..2cc1bd2a 100644 --- a/cathook/src/entity.cpp +++ b/cathook/src/entity.cpp @@ -59,6 +59,8 @@ void EntityVariables::Init() { this->nForceTauntCam = gNetvars.get_offset("DT_TFPlayer", "m_nForceTauntCam"); this->iFOV = gNetvars.get_offset("DT_BasePlayer", "m_iFOV"); this->iDefaultFOV = gNetvars.get_offset("DT_BasePlayer", "m_iDefaultFOV"); + this->Rocket_bCritical = gNetvars.get_offset("DT_TFBaseRocket", "m_bCritical"); + this->Grenade_bCritical = gNetvars.get_offset("DT_TFWeaponBaseGrenadeProj", "m_bCritical"); } void InitEntityOffsets() { diff --git a/cathook/src/entity.h b/cathook/src/entity.h index 77851166..46b8481e 100644 --- a/cathook/src/entity.h +++ b/cathook/src/entity.h @@ -82,6 +82,8 @@ public: offset_t Rocket_iDeflected; offset_t Grenade_iDeflected; + offset_t Rocket_bCritical; + offset_t Grenade_bCritical; offset_t bDistributed; diff --git a/cathook/src/entitycache.cpp b/cathook/src/entitycache.cpp index 716dd55a..a95dcd03 100644 --- a/cathook/src/entitycache.cpp +++ b/cathook/src/entitycache.cpp @@ -45,6 +45,13 @@ void CachedEntity::Update(int idx) { m_flDistance = (g_pLocalPlayer->entity->GetAbsOrigin().DistTo(m_pEntity->GetAbsOrigin())); } m_bAlivePlayer = false; + if (IsProjectile(m_pEntity)) { + m_bCritProjectile = IsProjectileCrit(m_pEntity); + m_bIsVisible = IsEntityVisible(m_pEntity, -1); + m_iTeam = Var(netvar.iTeamNum); + m_bEnemy = (m_iTeam != g_pLocalPlayer->team); + } + if (m_iClassID == ClassID::CTFPlayer) { m_bAlivePlayer = !(m_bNULL || m_bDormant || GetEntityValue(m_pEntity, netvar.iLifeState)); m_iTeam = Var(netvar.iTeamNum); // TODO diff --git a/cathook/src/entitycache.h b/cathook/src/entitycache.h index 44f5afd2..cfc03aa2 100644 --- a/cathook/src/entitycache.h +++ b/cathook/src/entitycache.h @@ -35,6 +35,8 @@ public: int m_iClassID; float m_flDistance; + bool m_bCritProjectile; + int m_iTeam; bool m_bAlivePlayer; bool m_bEnemy; diff --git a/cathook/src/hacks/AutoReflect.cpp b/cathook/src/hacks/AutoReflect.cpp index 476d449f..0eb9ce9f 100644 --- a/cathook/src/hacks/AutoReflect.cpp +++ b/cathook/src/hacks/AutoReflect.cpp @@ -33,13 +33,13 @@ bool AutoReflect::ShouldReflect(IClientEntity* ent) { case ClassID::CTFProjectile_Cleaver: case ClassID::CTFProjectile_Jar: case ClassID::CTFProjectile_JarMilk: { - int deflected = GetEntityValue(ent, netvar.Rocket_iDeflected); + int deflected = GetEntityValue(ent, netvar.Grenade_iDeflected); if (deflected) return false; if (GetEntityValue(ent, netvar.iTeamNum) == g_pLocalPlayer->team) return false; return true; } break; case ClassID::CTFGrenadePipebombProjectile: { - int deflected = GetEntityValue(ent, netvar.Rocket_iDeflected); + int deflected = GetEntityValue(ent, netvar.Grenade_iDeflected); if (deflected) return false; if (GetEntityValue(ent, netvar.iTeamNum) == g_pLocalPlayer->team) return false; if (GetEntityValue(ent, netvar.iPipeType) == 1) { diff --git a/cathook/src/hacks/ESP.cpp b/cathook/src/hacks/ESP.cpp index ed4175b2..e9d2e23f 100644 --- a/cathook/src/hacks/ESP.cpp +++ b/cathook/src/hacks/ESP.cpp @@ -57,6 +57,12 @@ ESP::ESP() { v_bShowHealthNumbers = CreateConVar(CON_PREFIX "esp_health_num", "1", "Health in numbers"); v_bShowMoney = CreateConVar(CON_PREFIX "esp_money", "1", "MvM money"); v_bShowRedMoney = CreateConVar(CON_PREFIX "esp_money_red", "1", "Red MvM money"); + this->v_iShowRockets = CreateConVar(CON_PREFIX "esp_proj_rockets", "1", "Rockets"); + this->v_iShowArrows = CreateConVar(CON_PREFIX "esp_proj_arrows", "1", "Arrows"); + this->v_iShowStickies = CreateConVar(CON_PREFIX "esp_proj_stickies", "1", "Stickies"); + this->v_iShowPipes = CreateConVar(CON_PREFIX "esp_proj_pipes", "1", "Pipes"); + this->v_bOnlyEnemyProjectiles = CreateConVar(CON_PREFIX "esp_proj_enemy", "Only enemy projectiles", "0"); + this->v_bProjectileESP = CreateConVar(CON_PREFIX "esp_proj", "1", "Projectile ESP"); } #define ESP_HEIGHT 14 @@ -154,6 +160,48 @@ void ESP::ProcessEntity(CachedEntity* ent) { } switch (ent->m_iClassID) { + case ClassID::CTFProjectile_Rocket: + case ClassID::CTFProjectile_SentryRocket: { + if (!v_bProjectileESP->GetBool() || !v_iShowRockets->GetBool()) break; + if (v_iShowRockets->GetInt() == 2 && !ent->m_bCritProjectile) break; + if (!ent->m_bEnemy) { + if (!v_bTeammates->GetBool() || v_bOnlyEnemyProjectiles->GetBool()) break; + } + ent->AddESPString(color, bgclr, "[ ==> ]"); + if (this->v_bShowDistance) { + ent->AddESPString(color, bgclr, "%im", (int)(ent->m_flDistance / 64 * 1.22f)); + } + } break; + case ClassID::CTFGrenadePipebombProjectile: { + if (!v_bProjectileESP->GetBool()) break; + if (!ent->m_bEnemy) { + if (!v_bTeammates->GetBool() || v_bOnlyEnemyProjectiles->GetBool()) break; + } + switch (ent->Var(netvar.iPipeType)) { + case 0: + if (!v_iShowPipes->GetBool()) break; + if (v_iShowPipes->GetInt() == 2 && !ent->m_bCritProjectile) break; + ent->AddESPString(color, bgclr, "[ (PP) ]"); + case 1: + if (!v_iShowStickies->GetBool()) break; + if (v_iShowStickies->GetInt() == 2 && !ent->m_bCritProjectile) break; + ent->AddESPString(color, bgclr, "[ {*} ]"); + } + if (this->v_bShowDistance) { + ent->AddESPString(color, bgclr, "%im", (int)(ent->m_flDistance / 64 * 1.22f)); + } + } break; + case ClassID::CTFProjectile_Arrow: { + if (!v_bProjectileESP->GetBool() || !v_iShowArrows->GetBool()) break; + if (v_iShowArrows->GetInt() == 2 && !ent->m_bCritProjectile) break; + if (!ent->m_bEnemy) { + if (!v_bTeammates->GetBool() || v_bOnlyEnemyProjectiles->GetBool()) break; + } + ent->AddESPString(color, bgclr, "[ >>---> ]"); + if (this->v_bShowDistance) { + ent->AddESPString(color, bgclr, "%im", (int)(ent->m_flDistance / 64 * 1.22f)); + } + } break; case ClassID::CTFTankBoss: { if (!this->v_bShowTank->GetBool()) break; ent->AddESPString(color, bgclr, "Tank"); diff --git a/cathook/src/hacks/ESP.h b/cathook/src/hacks/ESP.h index 561c961e..24694bc8 100644 --- a/cathook/src/hacks/ESP.h +++ b/cathook/src/hacks/ESP.h @@ -44,6 +44,15 @@ public: ConVar* v_bLegit; ConVar* v_bShowHealthNumbers; ConVar* v_iLegitSeenTicks; + + ConVar* v_iShowRockets; + ConVar* v_iShowArrows; + ConVar* v_iShowPipes; + ConVar* v_iShowStickies; + + ConVar* v_bOnlyEnemyProjectiles; + ConVar* v_bProjectileESP; + //ConVar* v_bModelInfo; }; diff --git a/cathook/src/helpers.cpp b/cathook/src/helpers.cpp index 6aaddda9..866b7790 100644 --- a/cathook/src/helpers.cpp +++ b/cathook/src/helpers.cpp @@ -315,10 +315,14 @@ bool IsEntityVisible(IClientEntity* entity, int hb) { IClientEntity* local = interfaces::entityList->GetClientEntity(interfaces::engineClient->GetLocalPlayer()); trace_filter->SetSelf(local); Vector hit; - int ret = GetHitboxPosition(entity, hb, hit); - if (ret) { - //logging::Info("Couldn't get hitbox position: %i", hb); - return false; + if (hb == -1) { + hit = entity->GetAbsOrigin(); + } else { + int ret = GetHitboxPosition(entity, hb, hit); + if (ret) { + //logging::Info("Couldn't get hitbox position: %i", hb); + return false; + } } ray.Init(local->GetAbsOrigin() + GetEntityValue(local, netvar.vViewOffset), hit); interfaces::trace->TraceRay(ray, 0x4200400B, trace_filter, &trace_visible); @@ -438,6 +442,43 @@ bool IsMeleeWeapon(IClientEntity* ent) { return false; } +bool IsProjectile(IClientEntity* ent) { + if (!ent) return false; + switch (ent->GetClientClass()->m_ClassID) { + case ClassID::CTFProjectile_Arrow: + case ClassID::CTFProjectile_Flare: + case ClassID::CTFProjectile_HealingBolt: + case ClassID::CTFProjectile_Rocket: + case ClassID::CTFProjectile_SentryRocket: + case ClassID::CTFProjectile_EnergyBall: + case ClassID::CTFProjectile_Cleaver: + case ClassID::CTFProjectile_Jar: + case ClassID::CTFProjectile_JarMilk: + case ClassID::CTFGrenadePipebombProjectile: + return true; + } + return false; +} + +bool IsProjectileCrit(IClientEntity* ent) { + if (!ent) return false; + switch (ent->GetClientClass()->m_ClassID) { + case ClassID::CTFProjectile_Arrow: + case ClassID::CTFProjectile_Flare: + case ClassID::CTFProjectile_HealingBolt: + case ClassID::CTFProjectile_Rocket: + case ClassID::CTFProjectile_SentryRocket: + case ClassID::CTFProjectile_EnergyBall: + return GetEntityValue(ent, netvar.Rocket_bCritical); + case ClassID::CTFProjectile_Cleaver: + case ClassID::CTFProjectile_Jar: + case ClassID::CTFProjectile_JarMilk: + case ClassID::CTFGrenadePipebombProjectile: + return GetEntityValue(ent, netvar.Grenade_bCritical); + } + return false; +} + weaponmode GetWeaponMode(IClientEntity* player) { if (!player) return weapon_invalid; int weapon_handle = GetEntityValue(player, netvar.hActiveWeapon); diff --git a/cathook/src/helpers.h b/cathook/src/helpers.h index 0c077af3..976011fa 100644 --- a/cathook/src/helpers.h +++ b/cathook/src/helpers.h @@ -73,6 +73,8 @@ void AimAt(Vector origin, Vector target, CUserCmd* cmd); void AimAtHitbox(IClientEntity* ent, int hitbox, CUserCmd* cmd); bool IsMeleeWeapon(IClientEntity* ent); +bool IsProjectile(IClientEntity* ent); +bool IsProjectileCrit(IClientEntity* ent); QAngle VectorToQAngle(Vector in); Vector QAngleToVector(QAngle in);