This commit is contained in:
BenCat07 2018-02-12 18:25:28 +01:00 committed by GitHub
parent b81aec3238
commit 32290c257b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -45,16 +45,16 @@ void CreateMove()
CachedEntity *pEnt = ENTITY(i); CachedEntity *pEnt = ENTITY(i);
if (!CE_GOOD(pEnt)) if (!CE_GOOD(pEnt))
continue; continue;
if (!pEnt->m_bAlivePlayer) if (pEnt->m_Type != ENTITY_PLAYER)
continue; continue;
if (!pEnt->m_Type == ENTITY_PLAYER) if (!pEnt->m_bAlivePlayer)
continue; continue;
if (pEnt == LOCAL_E) if (pEnt == LOCAL_E)
continue; continue;
if (LOCAL_E->m_iTeam == pEnt->m_iTeam) if (LOCAL_E->m_iTeam == pEnt->m_iTeam)
continue; continue;
scr = 4096.0f - pEnt->m_vecOrigin.DistTo(LOCAL_E->m_vecOrigin); scr = 4096.0f - pEnt->m_vecOrigin.DistTo(LOCAL_E->m_vecOrigin);
if (scr > scr_best) if ((scr > scr_best) && ent->m_flDistance < (int) 100.0f)
{ {
scr_best = scr; scr_best = scr;
ent = pEnt; ent = pEnt;
@ -65,16 +65,36 @@ void CreateMove()
return; return;
if (!CE_GOOD(ent)) if (!CE_GOOD(ent))
return; return;
float ent_eye = CE_FLOAT(ent, netvar.m_angEyeAngles + 4);
float min = CE_FLOAT(LOCAL_E, netvar.m_angEyeAngles + 4) - 50.0f; Vector vecVictimForward;
float max = CE_FLOAT(LOCAL_E, netvar.m_angEyeAngles + 4) + 50.0f; vecVictimForward.x = CE_FLOAT(ent, netvar.angEyeAngles);
if (ent_eye >= min && ent_eye <= max) vecVictimForward.y = CE_FLOAT(ent, netvar.angEyeAngles + 4);
{ vecVictimForward.z = 0.0f;
if (LOCAL_E->m_vecOrigin.DistTo(ent->m_vecOrigin) <= 100) vecVictimForward.NormalizeInPlace();
g_pUserCmd->buttons |= IN_ATTACK;
} // Get a vector from my origin to my targets origin
Vector vecToTarget;
vecToTarget = GetWorldSpaceCenter(ent) - GetWorldSpaceCenter(LOCAL_E);
vecToTarget.z = 0.0f;
vecToTarget.NormalizeInPlace();
float flDot = DotProduct(vecVictimForward, vecToTarget);
if (flDot > -0.1)
g_pUserCmd->buttons |= IN_ATTACK;
} }
} }
// pPaste, thanks to F1ssi0N
const Vector GetWorldSpaceCenter(CachedEntity *ent)
{
Vector vMin, vMax;
RAW_ENT(ent)->GetRenderBounds(vMin, vMax);
Vector vWorldSpaceCenter = RAW_ENT(ent)->GetAbsOrigin();
vWorldSpaceCenter.z += (vMin.z + vMax.z) / 2;
return vWorldSpaceCenter;
}
} }
} }
} }