Get Farthest Player ID Instead of the Closest

This following code grabs the closestplayers id

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
int ClosestID = -1;
int how_ClosestID = m_pClient->m_Tuning[g_Config.m_ClDummy].m_HookLength;
int my_x = m_pClient->m_Snap.m_pLocalCharacter->m_X;
int my_y = m_pClient->m_Snap.m_pLocalCharacter->m_Y;
int LocalID = m_pClient->m_Snap.m_LocalClientID;
vec2 WallPos;

template<typename T>
inline T distance(const vector2_base<T> a, const vector2_base<T> &b)
{
	return length(a-b);
}

for (int i = 0; i < MAX_CLIENTS; i++)
{
	if (LocalID != i) // Skip our ClientID
	{
	    vec2 MyPos = m_pClient->m_aClients[LocalID].m_Predicted.m_Pos + m_pClient->m_aClients[LocalID].m_Predicted.m_Vel; 
	    CCharacterCore Player = m_pClient->m_aClients[i].m_Predicted; 
	    vec2 EnemyPos = m_pClient->m_aClients[i].m_Predicted.m_Pos + m_pClient->m_aClients[i].m_Predicted.m_Vel; 

	    int dist = distance(vec2(my_x, my_y), vec2(EnemyPos.x, EnemyPos.y)); 

	    if (how_ClosestID > dist)
	    {
		ClosestID = i; // Saving the ClosestPlayer's ID
		how_ClosestID = dist;
	    }
        }
}
                                  // THIS IS A 2D GAME BY THE WAY 


What im trying to achieve at the moment is to grab the Farthest playersID
Last edited on
im thinking about doing something like this
 
 if (how_ClosestID < dist + somenumber ill test out)
Last edited on
Topic archived. No new replies allowed.