1313#include " iclientmode.h"
1414#include " vgui/ILocalize.h"
1515#include " hl2mp_gamerules.h"
16+ #ifdef MAPBASE_MP
17+ #include " c_ai_basenpc.h"
18+ #endif
1619
1720// memdbgon must be the last include file in a .cpp file!!!
1821#include " tier0/memdbgon.h"
@@ -161,8 +164,12 @@ void CTargetID::Paint()
161164
162165 bShowPlayerName = true ;
163166 g_pVGuiLocalize->ConvertANSIToUnicode ( pPlayer->GetPlayerName (), wszPlayerName, sizeof (wszPlayerName) );
164-
167+
168+ #ifdef MAPBASE_MP
169+ if ( HL2MPRules ()->PlayerRelationship ( pLocalPlayer, pPlayer ) == GR_TEAMMATE )
170+ #else
165171 if ( HL2MPRules ()->IsTeamplay () == true && pPlayer->InSameTeam (pLocalPlayer) )
172+ #endif
166173 {
167174 printFormatString = " #Playerid_sameteam" ;
168175 bShowHealth = true ;
@@ -179,6 +186,52 @@ void CTargetID::Paint()
179186 wszHealthText[ ARRAYSIZE (wszHealthText)-1 ] = ' \0 ' ;
180187 }
181188 }
189+ #ifdef MAPBASE_MP
190+ else
191+ {
192+ extern ConVar sv_hl2mp_npc_target_id;
193+ if (sv_hl2mp_npc_target_id.GetBool ())
194+ {
195+ C_BaseEntity *pEnt = cl_entitylist->GetEnt ( iEntIndex );
196+ const char *pszPlayerName = pEnt->GetPlayerName ();
197+
198+ if (pszPlayerName && *pszPlayerName && (!pEnt->IsNPC () || !pEnt->MyNPCPointer ()->IsNeutralTo ( pLocalPlayer )))
199+ {
200+ c = GetColorForTargetTeam ( pEnt->GetTeamNumber () );
201+
202+ bShowPlayerName = true ;
203+
204+ wchar_t *pLocalized = g_pVGuiLocalize->Find ( pszPlayerName );
205+ if (pLocalized)
206+ {
207+ V_wcsncpy ( wszPlayerName, pLocalized, sizeof ( wszPlayerName ) );
208+ }
209+ else
210+ {
211+ g_pVGuiLocalize->ConvertANSIToUnicode ( pszPlayerName, wszPlayerName, sizeof ( wszPlayerName ) );
212+ }
213+
214+ if ( (HL2MPRules ()->IsTeamplay () == true && pEnt->InSameTeam (pLocalPlayer)) || (pEnt->IsNPC () && pEnt->MyNPCPointer ()->IsPlayerAlly (pLocalPlayer)) )
215+ {
216+ printFormatString = " #Playerid_sameteam" ;
217+ bShowHealth = true ;
218+ }
219+ else
220+ {
221+ printFormatString = " #Playerid_diffteam" ;
222+ }
223+
224+
225+ if ( bShowHealth )
226+ {
227+ // NPCs show their health directly
228+ _snwprintf ( wszHealthText, ARRAYSIZE (wszHealthText) - 1 , L" %i" , pEnt->GetHealth () );
229+ wszHealthText[ ARRAYSIZE (wszHealthText)-1 ] = ' \0 ' ;
230+ }
231+ }
232+ }
233+ }
234+ #endif
182235
183236 if ( printFormatString )
184237 {
0 commit comments