cl_dll/hl2mp/hud_deathnotice.cpp
891011121314
#include "hudelement.h"
#include "hud_macros.h"
#include "c_playerresource.h"
#include "clientmode_hl2mpnormal.h"
#include
#include
#include
891011121314
#include "hudelement.h"
#include "hud_macros.h"
#include "c_playerresource.h"
#include "clientmode_ff.h"
#include
#include
#include
161718192021
#include
#include "c_baseplayer.h"
#include "c_team.h"
// memdbgon must be the last include file in a .cpp file!!!
16171819202122
#include
#include "c_baseplayer.h"
#include "c_team.h"
#include "ff_gamerules.h"
// memdbgon must be the last include file in a .cpp file!!!
110111112113114115116
//-----------------------------------------------------------------------------
void CHudDeathNotice::Init( void )
{
gameeventmanager->AddListener(this, "player_death", false );
}
//-----------------------------------------------------------------------------
111112113114115116117118119
//-----------------------------------------------------------------------------
void CHudDeathNotice::Init( void )
{
gameeventmanager->AddListener(this, "player_death", false );
gameeventmanager->AddListener( this, "dispenser_killed", false );
gameeventmanager->AddListener( this, "sentrygun_killed", false );
}
//-----------------------------------------------------------------------------
146147148149150151152
if ( !m_iconD_skull )
return;
int yStart = GetClientModeHL2MPNormal()->GetDeathMessageStartHeight();
surface()->DrawSetTextFont( m_hTextFont );
surface()->DrawSetTextColor( GameResources()->GetTeamColor( 0 ) );
149150151152153154155
if ( !m_iconD_skull )
return;
int yStart = GetClientModeFFNormal()->GetDeathMessageStartHeight();
surface()->DrawSetTextFont( m_hTextFont );
surface()->DrawSetTextColor( GameResources()->GetTeamColor( 0 ) );
197198199200201202203
int x;
if ( m_bRightJustify )
{
x = GetWide() - len - iconWide;
}
else
{
200201202203204205206
int x;
if ( m_bRightJustify )
{
x = GetWide() - len - iconWide - 5; // |-- Mirv: 10 extra px gap between elements
}
else
{
204205206207208209
x = 0;
}
// Only draw killers name if it wasn't a suicide
if ( !m_DeathNotices[i].iSuicide )
{
207208209210211212213214215216217218219
x = 0;
}
// --> Mirv: Shove over a bit
y += 16;
x -= 28;
int offset = iconTall / 4;
// <--
// Only draw killers name if it wasn't a suicide
if ( !m_DeathNotices[i].iSuicide )
{
219220221222223224225226227228229230231232
surface()->DrawSetTextFont( m_hTextFont );
surface()->DrawUnicodeString( killer );
surface()->DrawGetTextPos( x, y );
}
Color iconColor( 255, 80, 0, 255 );
// Draw death weapon
//If we're using a font char, this will ignore iconTall and iconWide
icon->DrawSelf( x, y, iconWide, iconTall, iconColor );
x += iconWide;
SetColorForNoticePlayer( iVictimTeam );
229230231232233234235236237238239240241242243244245246247248249
surface()->DrawSetTextFont( m_hTextFont );
surface()->DrawUnicodeString( killer );
surface()->DrawGetTextPos( x, y );
x += 5; // |-- Mirv: 5px gap
}
Color iconColor( 255, 80, 0, 255 );
Color iconTeamKillColor(0, 185, 0 , 250);
// Don't include self kills when determining if teamkill
//bool bTeamKill = (iKillerTeam == iVictimTeam && m_DeathNotices[i].Killer.iEntIndex != m_DeathNotices[i].Victim.iEntIndex);
bool bTeamKill = ( ( FFGameRules()->IsTeam1AlliedToTeam2( iKillerTeam, iVictimTeam ) == GR_TEAMMATE ) && ( m_DeathNotices[i].Killer.iEntIndex != m_DeathNotices[i].Victim.iEntIndex ) );
// Draw death weapon
//If we're using a font char, this will ignore iconTall and iconWide
icon->DrawSelf( x, y - offset, iconWide, iconTall, bTeamKill ? iconTeamKillColor : iconColor );
x += iconWide + 5; // |-- Mirv: 5px gap
SetColorForNoticePlayer( iVictimTeam );
272273274275276277
int victim = engine->GetPlayerForUserID( event->GetInt("userid") );
const char *killedwith = event->GetString( "weapon" );
char fullkilledwith[128];
if ( killedwith && *killedwith )
{
289290291292293294295296297
int victim = engine->GetPlayerForUserID( event->GetInt("userid") );
const char *killedwith = event->GetString( "weapon" );
// Stuffs for handling buildable deaths
bool bBuildableKilled = false;
char fullkilledwith[128];
if ( killedwith && *killedwith )
{
294295296297298299300301302303304
const char *killer_name = g_PR->GetPlayerName( killer );
const char *victim_name = g_PR->GetPlayerName( victim );
if ( !killer_name )
killer_name = "";
if ( !victim_name )
victim_name = "";
// Make a new death notice
DeathNoticeItem deathMsg;
deathMsg.Killer.iEntIndex = killer;
314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
const char *killer_name = g_PR->GetPlayerName( killer );
const char *victim_name = g_PR->GetPlayerName( victim );
//bool bTeamKill = (g_PR->GetTeam(killer) == g_PR->GetTeam(victim));
bool bTeamKill = ( ( FFGameRules()->IsTeam1AlliedToTeam2( g_PR->GetTeam( killer ), g_PR->GetTeam( victim ) ) == GR_TEAMMATE ) && ( killer != victim ) );
if ( !killer_name )
killer_name = "";
if ( !victim_name )
victim_name = "";
// Buildable stuff
char pszVictimMod[ MAX_PLAYER_NAME_LENGTH + 24 ];
if( !Q_strcmp( event->GetName(), "dispenser_killed" ) )
{
bBuildableKilled = true;
Q_snprintf( pszVictimMod, sizeof( pszVictimMod ), "%s's Dispenser", victim_name );
victim_name = const_cast< char * >( pszVictimMod );
}
else if( !Q_strcmp( event->GetName(), "sentrygun_killed" ) )
{
bBuildableKilled = true;
Q_snprintf( pszVictimMod, sizeof( pszVictimMod ), "%s's Sentrygun", victim_name );
victim_name = const_cast< char * >( pszVictimMod );
}
// Make a new death notice
DeathNoticeItem deathMsg;
deathMsg.Killer.iEntIndex = killer;
306307308309310311312313314315316317
Q_strncpy( deathMsg.Killer.szName, killer_name, MAX_PLAYER_NAME_LENGTH );
Q_strncpy( deathMsg.Victim.szName, victim_name, MAX_PLAYER_NAME_LENGTH );
deathMsg.flDisplayTime = gpGlobals->curtime + hud_deathnotice_time.GetFloat();
deathMsg.iSuicide = ( !killer || killer == victim );
// Try and find the death identifier in the icon list
deathMsg.iconDeath = gHUD.GetIcon( fullkilledwith );
if ( !deathMsg.iconDeath || deathMsg.iSuicide )
{
// Can't find it, so use the default skull & crossbones icon
deathMsg.iconDeath = m_iconD_skull;
344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
Q_strncpy( deathMsg.Killer.szName, killer_name, MAX_PLAYER_NAME_LENGTH );
Q_strncpy( deathMsg.Victim.szName, victim_name, MAX_PLAYER_NAME_LENGTH );
deathMsg.flDisplayTime = gpGlobals->curtime + hud_deathnotice_time.GetFloat();
deathMsg.iSuicide = ( !killer || ( ( killer == victim ) && ( !bBuildableKilled ) ) );
// 0000336: If we have a Detpack...
// NOTE: may need these changes for the SG and Dispenser in order for the death status icons to work right
if (Q_stricmp(killedwith, "Detpack") == 0)
{
deathMsg.iconDeath = gHUD.GetIcon("death_weapon_deploydetpack");
}
// 0001292: If we have a Dispenser
else if (Q_stricmp(killedwith, "Dispenser") == 0)
{
deathMsg.iconDeath = gHUD.GetIcon("death_weapon_deploydispenser");
}
// 0001292: If we have a Sentrygun
else if (Q_stricmp(killedwith, "Sentrygun") == 0)
{
deathMsg.iconDeath = gHUD.GetIcon("death_weapon_deploysentrygun");
}
else
{
// Try and find the death identifier in the icon list
deathMsg.iconDeath = gHUD.GetIcon( fullkilledwith );
}
// Show weapon if it was a suicide too
if ( !deathMsg.iconDeath /*|| deathMsg.iSuicide*/ )
{
// Can't find it, so use the default skull & crossbones icon
deathMsg.iconDeath = m_iconD_skull;
336337338339340341342
}
else
{
Q_snprintf( sDeathMsg, sizeof( sDeathMsg ), "%s killed %s", deathMsg.Killer.szName, deathMsg.Victim.szName );
if ( fullkilledwith && *fullkilledwith && (*fullkilledwith > 13 ) )
{
394395396397398399400
}
else
{
Q_snprintf( sDeathMsg, sizeof( sDeathMsg ), "%s %skilled %s", deathMsg.Killer.szName, bTeamKill ? "team" : "", deathMsg.Victim.szName );
if ( fullkilledwith && *fullkilledwith && (*fullkilledwith > 13 ) )
{