Fix building hitboxes and slight aimbot code improvements

This commit is contained in:
TotallyNotElite 2019-05-31 10:39:35 +02:00
parent 57d75db1ef
commit be5b48bf5f
2 changed files with 8 additions and 35 deletions

View File

@ -70,7 +70,7 @@ static settings::Float fovcircle_opacity{ "aimbot.fov-circle.opacity", "0.7" };
int GetSentry() int GetSentry()
{ {
for (int i = 0; i < HIGHEST_ENTITY; i++) for (int i = 1; i < HIGHEST_ENTITY; i++)
{ {
CachedEntity *ent = ENTITY(i); CachedEntity *ent = ENTITY(i);
if (CE_BAD(ent)) if (CE_BAD(ent))
@ -149,7 +149,7 @@ static void CreateMove()
// Refresh projectile info // Refresh projectile info
if (projectileAimbotRequired) if (projectileAimbotRequired)
{ {
projectile_mode = (GetProjectileData(g_pLocalPlayer->weapon(), cur_proj_speed, cur_proj_grav)); projectile_mode = GetProjectileData(g_pLocalPlayer->weapon(), cur_proj_speed, cur_proj_grav);
if (!projectile_mode) if (!projectile_mode)
return; return;
if (proj_speed) if (proj_speed)
@ -378,7 +378,7 @@ CachedEntity *RetrieveBestTarget(bool aimkey_state, bool Backtracking)
CachedEntity *ent; CachedEntity *ent;
CachedEntity *target_highest_ent = 0; CachedEntity *target_highest_ent = 0;
target_highest_score = -256; target_highest_score = -256;
for (int i = 0; i < HIGHEST_ENTITY; i++) for (int i = 1; i < HIGHEST_ENTITY; i++)
{ {
ent = ENTITY(i); ent = ENTITY(i);
if (CE_BAD(ent)) if (CE_BAD(ent))
@ -732,8 +732,6 @@ bool IsTargetStateGood(CachedEntity *entity)
// Target not valid // Target not valid
return false; return false;
} }
// An impossible error so just return false
return false;
} }
// A function to aim at a specific entitiy // A function to aim at a specific entitiy
@ -1061,7 +1059,7 @@ int BestHitbox(CachedEntity *target)
// 18 health is a good number to use as thats the usual minimum // 18 health is a good number to use as thats the usual minimum
// damage it can do with a bodyshot, but damage could // damage it can do with a bodyshot, but damage could
// potentially be higher // potentially be higher
if (target->m_iHealth() <= 18 || IsPlayerCritBoosted(g_pLocalPlayer->entity)) if (target->m_iHealth() <= 18 || IsPlayerCritBoosted(g_pLocalPlayer->entity) || target->m_flDistance() > 1200)
headonly = false; headonly = false;
// Rocket launcher // Rocket launcher
} }

View File

@ -937,35 +937,10 @@ bool VisCheckEntFromEntVector(Vector startVector, CachedEntity *startEnt, Cached
Vector GetBuildingPosition(CachedEntity *ent) Vector GetBuildingPosition(CachedEntity *ent)
{ {
if (ent->hitboxes.GetHitbox(1)) // Get the collideable origin of ent and get min and max of collideable
return ent->hitboxes.GetHitbox(1)->center; // OBBMins and OBBMaxs are offsets from origin
if (ent->hitboxes.GetHitbox(0)) auto raw = RAW_ENT(ent);
return ent->hitboxes.GetHitbox(0)->center; return (raw->GetCollideable()->OBBMins() + raw->GetCollideable()->OBBMaxs()) / 2 + raw->GetCollideable()->GetCollisionOrigin();
Vector res;
res = ent->m_vecOrigin();
int classid = ent->m_iClassID();
if (classid == CL_CLASS(CObjectDispenser))
res.z += 30;
if (classid == CL_CLASS(CObjectTeleporter))
res.z += 8;
if (classid == CL_CLASS(CObjectSentrygun))
{
if (CE_BYTE(ent, netvar.m_bMiniBuilding))
res.z += 10.0f;
switch (CE_INT(ent, netvar.iUpgradeLevel))
{
case 1:
res.z += 30;
break;
case 2:
res.z += 50;
break;
case 3:
res.z += 60;
break;
}
}
return res;
} }
bool IsBuildingVisible(CachedEntity *ent) bool IsBuildingVisible(CachedEntity *ent)