optimized FindNearestPlayer ()
support v6 waypoint file converted from v7
This commit is contained in:
parent
3042325f70
commit
83740aa129
2 changed files with 10 additions and 6 deletions
|
|
@ -680,7 +680,9 @@ bool Bot::DoWaypointNav (void)
|
|||
// pressing the jump button gives the illusion of the bot actual jmping.
|
||||
if (IsOnFloor () || IsOnLadder ())
|
||||
{
|
||||
pev->velocity = m_desiredVelocity + m_desiredVelocity * 0.15; // cheating i know, but something changed in recent cs updates...
|
||||
if (m_desiredVelocity != nullvec)
|
||||
pev->velocity = m_desiredVelocity + m_desiredVelocity * 0.15; // cheating i know, but something changed in recent cs updates...
|
||||
|
||||
pev->button |= IN_JUMP;
|
||||
|
||||
m_jumpFinished = true;
|
||||
|
|
|
|||
|
|
@ -1396,15 +1396,17 @@ bool FindNearestPlayer (void **pvHolder, edict_t *to, float searchDistance, bool
|
|||
// team, live status, search distance etc. if needBot is true, then pvHolder, will
|
||||
// be filled with bot pointer, else with edict pointer(!).
|
||||
|
||||
edict_t *ent = NULL, *survive = NULL; // pointer to temporaly & survive entity
|
||||
edict_t *survive = NULL; // pointer to temporaly & survive entity
|
||||
float nearestPlayer = 4096.0; // nearest player
|
||||
|
||||
while (!IsEntityNull (ent = FIND_ENTITY_IN_SPHERE (ent, to->v.origin, searchDistance)))
|
||||
for (int i = 0; i < GetMaxClients (); i++)
|
||||
{
|
||||
if (IsEntityNull (ent) || !IsValidPlayer (ent) || to == ent)
|
||||
continue; // skip invalid players
|
||||
edict_t *ent = g_clients[i].ent;
|
||||
|
||||
if ((sameTeam && GetTeam (ent) != GetTeam (to)) || (isAlive && !IsAlive (ent)) || (needBot && !IsValidBot (ent)) || (needDrawn && (ent->v.effects & EF_NODRAW)))
|
||||
if (!(g_clients[i].flags & CF_USED) || ent == to)
|
||||
continue;
|
||||
|
||||
if ((sameTeam && g_clients[i].team != GetTeam (to)) || (isAlive && !(g_clients[i].flags & CF_ALIVE)) || (needBot && !IsValidBot (ent)) || (needDrawn && (ent->v.effects & EF_NODRAW)))
|
||||
continue; // filter players with parameters
|
||||
|
||||
float distance = (ent->v.origin - to->v.origin).GetLengthSquared ();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue