This commit is contained in:
main-thing 2025-12-16 01:19:52 -08:00 committed by GitHub
commit 53697b227c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 45 additions and 14 deletions

View File

@ -660,6 +660,7 @@ void CHudBaseDeathNotice::FireGameEvent( IGameEvent *event )
const char *pszMsgKey = NULL;
int iEventType = event->GetInt( "eventtype" );
const char *pszMsgText = event->GetString( "msg", "");
bool bIsMvM = TFGameRules() && TFGameRules()->IsMannVsMachineMode();
if ( bIsMvM )
@ -678,22 +679,41 @@ void CHudBaseDeathNotice::FireGameEvent( IGameEvent *event )
switch ( iEventType )
{
case TF_FLAGEVENT_PICKUP:
pszMsgKey = bIsHalloween2014 ? "#Msg_PickedUpFlagHalloween2014" : "#Msg_PickedUpFlag";
break;
case TF_FLAGEVENT_CAPTURE:
pszMsgKey = bIsHalloween2014 ? "#Msg_CapturedFlagHalloween2014" : "#Msg_CapturedFlag";
break;
case TF_FLAGEVENT_DEFEND:
if ( bIsMvM )
if ( Q_strlen(pszMsgText) <= 0 )
{
pszMsgKey = "#Msg_DefendedBomb";
pszMsgKey = bIsHalloween2014 ? "#Msg_PickedUpFlagHalloween2014" : "#Msg_PickedUpFlag";
}
else
{
pszMsgKey = bIsHalloween2014 ? "#Msg_DefendedFlagHalloween2014" : "#Msg_DefendedFlag";
pszMsgKey = pszMsgText;
}
break;
case TF_FLAGEVENT_CAPTURE:
if ( Q_strlen(pszMsgText) <= 0 )
{
pszMsgKey = bIsHalloween2014 ? "#Msg_CapturedFlagHalloween2014" : "#Msg_CapturedFlag";
}
else
{
pszMsgKey = pszMsgText;
}
break;
case TF_FLAGEVENT_DEFEND:
if ( Q_strlen(pszMsgText) <= 0 )
{
if (bIsMvM)
{
pszMsgKey = "#Msg_DefendedBomb";
}
else
{
pszMsgKey = bIsHalloween2014 ? "#Msg_DefendedFlagHalloween2014" : "#Msg_DefendedFlag";
}
}
else
{
pszMsgKey = pszMsgText;
}
break;
// Add this when we can get localization for it
@ -708,6 +728,7 @@ void CHudBaseDeathNotice::FireGameEvent( IGameEvent *event )
}
wchar_t *pwzEventText = g_pVGuiLocalize->Find( pszMsgKey );
wchar_t pwzEventTextNonLocalized[256] = L"";
Assert( pwzEventText );
if ( pwzEventText )
{
@ -715,7 +736,8 @@ void CHudBaseDeathNotice::FireGameEvent( IGameEvent *event )
}
else
{
V_memset( m_DeathNotices[iMsg].wzInfoText, 0, sizeof( m_DeathNotices[iMsg].wzInfoText ) );
g_pVGuiLocalize->ConvertANSIToUnicode( pszMsgKey, pwzEventTextNonLocalized, sizeof(pwzEventTextNonLocalized) );
V_wcsncpy( m_DeathNotices[iMsg].wzInfoText, pwzEventTextNonLocalized, sizeof( m_DeathNotices[iMsg].wzInfoText ) );
}
int iPlayerIndex = event->GetInt( "player" );

View File

@ -12335,6 +12335,7 @@ void CTFPlayer::Event_Killed( const CTakeDamageInfo &info )
event->SetInt( "carrier", entindex() );
event->SetInt( "priority", 8 );
event->SetInt( "team", pCaptureFlag->GetTeamNumber() );
event->SetString( "msg", STRING( pCaptureFlag->m_iszDefendName ) );
gameeventmanager->FireEvent( event );
}
CTF_GameStats.Event_PlayerDefendedPoint( pPlayerAttacker );

View File

@ -186,6 +186,9 @@ BEGIN_DATADESC( CCaptureFlag )
DEFINE_KEYFIELD( m_iszPaperEffect, FIELD_STRING, "flag_paper" ),
DEFINE_KEYFIELD( m_iszTrailEffect, FIELD_STRING, "flag_trail" ),
DEFINE_KEYFIELD( m_iszTags, FIELD_STRING, "tags" ),
DEFINE_KEYFIELD( m_iszCaptureName, FIELD_STRING, "text_captured" ),
DEFINE_KEYFIELD( m_iszPickupName, FIELD_STRING, "text_pickup" ),
DEFINE_KEYFIELD( m_iszDefendName, FIELD_STRING, "text_defend" ),
// Inputs.
DEFINE_INPUTFUNC( FIELD_VOID, "Enable", InputEnable ),
@ -942,6 +945,7 @@ void CCaptureFlag::ResetMessage( void )
event->SetInt( "eventtype", TF_FLAGEVENT_RETURNED );
event->SetInt( "priority", 8 );
event->SetInt( "team", GetTeamNumber() );
event->SetString( "msg", STRING( m_iszDefendName ) );
gameeventmanager->FireEvent( event );
}
@ -1430,6 +1434,7 @@ void CCaptureFlag::PickUp( CTFPlayer *pPlayer, bool bInvisible )
event->SetInt( "priority", 8 );
event->SetInt( "home", ( nOldFlagStatus == TF_FLAGINFO_HOME ) ? 1 : 0 );
event->SetInt( "team", GetTeamNumber() );
event->SetString( "msg", STRING( m_iszPickupName ) );
gameeventmanager->FireEvent( event );
}
@ -1731,6 +1736,7 @@ void CCaptureFlag::Capture( CTFPlayer *pPlayer, int nCapturePoint )
event->SetInt( "eventtype", TF_FLAGEVENT_CAPTURE );
event->SetInt( "priority", 9 );
event->SetInt( "team", GetTeamNumber() );
event->SetString( "msg", STRING( m_iszCaptureName ) );
gameeventmanager->FireEvent( event );
}
@ -2861,6 +2867,7 @@ void CCaptureFlag::AddPointValue( int nPoints )
{
pEvent->SetInt( "player", m_hPrevOwner && m_hPrevOwner->IsPlayer() ? ToBasePlayer( m_hPrevOwner )->entindex() : -1 );
pEvent->SetInt( "eventtype", TF_FLAGEVENT_PICKUP );
pEvent->SetString( "msg", STRING( m_iszPickupName ) );
gameeventmanager->FireEvent( pEvent );
}
}

View File

@ -332,7 +332,9 @@ public:
void GetHudIcon( int nTeam, char *pchName, int nBuffSize );
const char *GetPaperEffect( void );
void GetTrailEffect( int nTeam, char *pchName, int nBuffSize );
string_t m_iszCaptureName;
string_t m_iszPickupName;
string_t m_iszDefendName;
int GetPointValue() const { return m_nPointValue.Get(); }
private:
@ -349,7 +351,6 @@ private:
#endif
bool IsGlowEnabled( void ){ return m_bGlowEnabled; }
private:
CNetworkVar( bool, m_bDisabled ); // Enabled/Disabled?