diff --git a/source/navigate.cpp b/source/navigate.cpp index b390933..dda56de 100644 --- a/source/navigate.cpp +++ b/source/navigate.cpp @@ -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; diff --git a/source/support.cpp b/source/support.cpp index e50f40a..4244ea1 100644 --- a/source/support.cpp +++ b/source/support.cpp @@ -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 ();