Skip to content

Commit 303e632

Browse files
committed
Add support for NPC death notices and target IDs
1 parent f7186c0 commit 303e632

File tree

6 files changed

+398
-2
lines changed

6 files changed

+398
-2
lines changed

src/game/client/hl2mp/hl2mp_hud_target_id.cpp

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
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

Comments
 (0)