Beispiel #1
0
static void DrawTeamScores( int x, int y )
{
	if (( GAMEMODE_GetCurrentFlags() & GMF_PLAYERSONTEAMS ) == 0 )
		return;

	int numteams = TEAM_GetNumAvailableTeams();
	FString text;

	// [TP] Common case
	if ( numteams == 2 )
	{
		int scores[2] = { GetScoreForTeam( 0 ), GetScoreForTeam( 1 ) };
		int leadingTeam = !!( scores[1] > scores[0] );
		int losingTeam = 1 - leadingTeam;

		text.Format ("\\c%c%d\\cC - \\c%c%d",
			V_GetColorChar( TEAM_GetTextColor( leadingTeam )), scores[leadingTeam],
			V_GetColorChar( TEAM_GetTextColor( losingTeam )), scores[losingTeam] );
	}
	else
	{
		int teams[MAX_TEAMS] = { 0, 1, 2, 3 };
		std::sort( teams, teams + countof( teams ), TeamScoreSorter );

		for ( int i = 0; i < numteams; ++i )
		{
			if ( i > 0 )
				text += "\\cC - ";

			text += "\\c";
			text += V_GetColorChar( TEAM_GetTextColor( teams[i] ));
			text.AppendFormat( "%d", GetScoreForTeam( teams[i] ));
		}
	}

	V_ColorizeString( text );
	screen->DrawText( HudFont, CR_UNTRANSLATED, x, y + 17, text.GetChars(),
		DTA_KeepRatio, true,
		DTA_VirtualWidth, hudwidth,
		DTA_VirtualHeight, hudheight,
		DTA_Alpha, 0xc000, TAG_DONE );
}
Beispiel #2
0
//*****************************************************************************
//
void LASTMANSTANDING_DoWinSequence( ULONG ulWinner )
{
	ULONG	ulIdx;

	// Put the game state in the win sequence state.
	if (( NETWORK_GetState( ) != NETSTATE_CLIENT ) &&
		( CLIENTDEMO_IsPlaying( ) == false ))
	{
		LASTMANSTANDING_SetState( LMSS_WINSEQUENCE );
	}

	// Tell clients to do the win sequence.
	if ( NETWORK_GetState( ) == NETSTATE_SERVER )
		SERVERCOMMANDS_DoGameModeWinSequence( ulWinner );

	if ( NETWORK_GetState( ) != NETSTATE_SERVER )
	{
		char				szString[64];
		DHUDMessageFadeOut	*pMsg;

		if ( teamlms )
		{
			if ( ulWinner == teams.Size( ) )
				sprintf( szString, "\\cdDraw Game!" );
			else
				sprintf( szString, "\\c%c%s Wins!", V_GetColorChar( TEAM_GetTextColor( ulWinner ) ), TEAM_GetName( ulWinner ));
		}
		else if ( ulWinner == MAXPLAYERS )
			sprintf( szString, "\\cdDRAW GAME!" );
		else
			sprintf( szString, "%s \\c-WINS!", players[ulWinner].userinfo.netname );
		V_ColorizeString( szString );

		// Display "%s WINS!" HUD message.
		pMsg = new DHUDMessageFadeOut( BigFont, szString,
			160.4f,
			75.0f,
			320,
			200,
			CR_RED,
			3.0f,
			2.0f );

		StatusBar->AttachMessage( pMsg, MAKE_ID('C','N','T','R') );

		szString[0] = 0;
		pMsg = new DHUDMessageFadeOut( SmallFont, szString,
			0.0f,
			0.0f,
			0,
			0,
			CR_RED,
			3.0f,
			2.0f );

		StatusBar->AttachMessage( pMsg, MAKE_ID('F','R','A','G') );

		pMsg = new DHUDMessageFadeOut( SmallFont, szString,
			0.0f,
			0.0f,
			0,
			0,
			CR_RED,
			3.0f,
			2.0f );

		StatusBar->AttachMessage( pMsg, MAKE_ID('P','L','A','C') );
	}

	// Award a victory or perfect medal to the winner.
	if (( lastmanstanding ) &&
		( NETWORK_GetState( ) != NETSTATE_CLIENT ) &&
		( CLIENTDEMO_IsPlaying( ) == false ))
	{
		LONG	lMedal;

		// If the winner has full health, give him a "Perfect!".
		if ( players[ulWinner].health == deh.MegasphereHealth )
			lMedal = MEDAL_PERFECT;
		else
			lMedal = MEDAL_VICTORY;

		// Give the player the medal.
		MEDAL_GiveMedal( ulWinner, lMedal );
		if ( NETWORK_GetState( ) == NETSTATE_SERVER )
			SERVERCOMMANDS_GivePlayerMedal( ulWinner, lMedal );
	}

	for ( ulIdx = 0; ulIdx < MAXPLAYERS; ulIdx++ )
	{
		if (( playeringame[ulIdx] ) && ( players[ulIdx].pSkullBot ))
			players[ulIdx].pSkullBot->PostEvent( BOTEVENT_LMS_WINSEQUENCE );
	}
}
Beispiel #3
0
//*****************************************************************************
//
void CHAT_PrintChatString( ULONG ulPlayer, ULONG ulMode, const char *pszString )
{
	ULONG		ulChatLevel = 0;
	FString		OutString;
	FString		ChatString;

	// [RC] Are we ignoring this player?
	if (( ulPlayer != MAXPLAYERS ) && players[ulPlayer].bIgnoreChat )
		return;

	// If ulPlayer == MAXPLAYERS, it is the server talking.
	if ( ulPlayer == MAXPLAYERS )
	{
		// Special support for "/me" commands.
		ulChatLevel = PRINT_HIGH;
		if ( strnicmp( "/me", pszString, 3 ) == 0 )
		{
			pszString += 3;
			OutString = "* <server>";
		}
		else
			OutString = "<server>: ";
	}
	else if ( ulMode == CHATMODE_GLOBAL )
	{
		ulChatLevel = PRINT_CHAT;

		// Special support for "/me" commands.
		if ( strnicmp( "/me", pszString, 3 ) == 0 )
		{
			ulChatLevel = PRINT_HIGH;
			pszString += 3;
			OutString.AppendFormat( "* %s\\cc", players[ulPlayer].userinfo.netname );
		}
		else
		{
			OutString.AppendFormat( "%s" TEXTCOLOR_CHAT ": ", players[ulPlayer].userinfo.netname );
		}
	}
	else if ( ulMode == CHATMODE_TEAM )
	{
		ulChatLevel = PRINT_TEAMCHAT;
		if ( PLAYER_IsTrueSpectator ( &players[consoleplayer] ) )
			OutString += "<SPEC> ";
		else
		{
			OutString = "\\c";
			OutString += V_GetColorChar( TEAM_GetTextColor( players[consoleplayer].ulTeam ));
			OutString += "<TEAM> ";
		}

		// Special support for "/me" commands.
		if ( strnicmp( "/me", pszString, 3 ) == 0 )
		{
			ulChatLevel = PRINT_HIGH;
			pszString += 3;
			OutString.AppendFormat( "\\cc* %s\\cc", players[ulPlayer].userinfo.netname );
		}
		else
		{
			OutString.AppendFormat( "\\cd%s" TEXTCOLOR_TEAMCHAT ": ", players[ulPlayer].userinfo.netname );
		}
	}

	ChatString = pszString;

	// [RC] Remove linebreaks and other escape codes from chat.
	ChatString.Substitute("\\", "\\\\");

	// [RC] ...but allow chat colors.
	ChatString.Substitute("\\\\c", "\\c");

	// [BB] Remove invalid color codes, those can confuse the printing and create new lines.
	V_RemoveInvalidColorCodes( ChatString );

	// [RC] ...if the user wants them.
	if ( con_colorinmessages == 2)
		V_RemoveColorCodes( ChatString );

	// [BB] Remove any kind of trailing crap.
	V_RemoveTrailingCrapFromFString ( ChatString );

	// [BB] If the chat string is empty now, it only contained crap and is ignored.
	if ( ChatString.IsEmpty() )
		return;

	OutString += ChatString;

	Printf( ulChatLevel, "%s\n", OutString.GetChars() );

	// [BB] If the user doesn't want to see the messages, they shouldn't make a sound.
	if ( show_messages )
	{
		// [RC] User can choose the chat sound.
		if ( chat_sound == 1 ) // Default
			S_Sound( CHAN_VOICE | CHAN_UI, gameinfo.chatSound, 1, ATTN_NONE );
		else if ( chat_sound == 2 ) // Doom 1
			S_Sound( CHAN_VOICE | CHAN_UI, "misc/chat2", 1, ATTN_NONE );
		else if ( chat_sound == 3 ) // Doom 2
			S_Sound( CHAN_VOICE | CHAN_UI, "misc/chat", 1, ATTN_NONE );
	}

	BOTCMD_SetLastChatString( pszString );
	BOTCMD_SetLastChatPlayer( players[ulPlayer].userinfo.netname );

	{
		ULONG	ulIdx;

		for ( ulIdx = 0; ulIdx < MAXPLAYERS; ulIdx++ )
		{
			if ( playeringame[ulIdx] == false )
				continue;

			// Don't tell the bot someone talked if it was it who talked.
			if ( ulIdx == ulPlayer )
				continue;

			// If this is a bot, tell it a player said something.
			if ( players[ulIdx].pSkullBot )
				players[ulIdx].pSkullBot->PostEvent( BOTEVENT_PLAYER_SAY );
		}
	}
}