Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //N!tmod TDM Source Code - Sep. 5th 2010
- //This file contains main modifications that need to be done in Wolfenstein:Enemy Territory source code in order to implement N!tmod's TeamDeathMatch gametype.
- //Modifications such as adding cvars, sending TDM Score to clients or rendering the score on clients screen are not provided.
- //Credits go to N!tmod Dev Team. www.nitmod.com
- /*
- ***************************
- * bg_public.h *
- ***************************
- */
- // Add to gametype_t :
- GT_WOLF_TDM,
- /*
- ***************************
- * g_script_actions.c *
- ***************************
- */
- // G_ScriptAction_EndRound() - N!tmod gives 100 bonus points if the final objective is completed (remember that the map will not end as long as the score is not reached)
- // Add :
- if( g_gametype.integer == GT_WOLF_TDM ) {
- trap_GetConfigstring( CS_MULTI_MAPWINNER, cs, sizeof(cs) );
- winner = atoi( Info_ValueForKey( cs, "w" ) );
- if(winner == 1) {
- level.teamScores[TEAM_ALLIES] += 100;
- } else if(winner == 0) {
- level.teamScores[TEAM_AXIS] += 100;
- } return qtrue;
- }
- /*
- ***************************
- * g_main.c *
- ***************************
- */
- // CheckExitRules() - Check if a team has reached g_TDMScore.
- // Add :
- if ( g_gametype.integer == GT_WOLF_TDM ) {
- //Check team scores. The 1st team to reach the required score wins
- if ( level.teamScores[TEAM_AXIS] >= g_TDMScore.integer ) {
- trap_GetConfigstring( CS_MULTI_MAPWINNER, cs, sizeof(cs) );
- Info_SetValueForKey( cs, "w", "0" );
- trap_SetConfigstring( CS_MULTI_MAPWINNER, cs );
- LogExit( "TDM : Axis win this round\n" );
- trap_SendServerCommand( -1, "print \"^3TDM ^7: ^_Axis ^7win this round.\n\"");
- return;
- } else if (level.teamScores[TEAM_ALLIES] >= g_TDMScore.integer ) {
- trap_GetConfigstring( CS_MULTI_MAPWINNER, cs, sizeof(cs) );
- Info_SetValueForKey( cs, "w", "1" );
- trap_SetConfigstring( CS_MULTI_MAPWINNER, cs );
- LogExit( "TDM : Allies win this round\n" );
- trap_SendServerCommand( -1, "print \"^3TDM ^7: ^4Allies ^7win this round.\n\"");
- return;
- }
- }
- // Ignore Timelimit.
- // Modify :
- if ( level.gameManager && g_gametype.integer != GT_WOLF_TDM ) {
- G_Script_ScriptEvent( level.gameManager, "trigger", "timelimit_hit" );
- }
- if ( g_gametype.integer != GT_WOLF_TDM ){
- trap_SendServerCommand( -1, "print \"Timelimit hit.\n\"");
- LogExit( "Timelimit hit." );
- }
- //Send TeamScores to all the connected clients (except bots)
- void SendTeamScoreToAllClient( void )
- {
- int i;
- for(i=0; i<level.numConnectedClients;i++){
- gentity_t *ent = &g_entities[level.sortedClients[i]];
- if(!(ent->r.svFlags & SVF_BOT) && (ent->client->pers.connected == CON_CONNECTED)){
- G_SendTeamScore(ent);
- }
- }
- }
- /*
- ***************************
- * g_cmds.c *
- ***************************
- */
- //Send a small string that contains team scores for TDM.
- //This is sent to all clients as soon as a player dies during TDM, we are using this method instead of the stock ET method (where full scores are sent) to reduce BW usage and avoid lags on large servers.
- void G_SendTeamScore(gentity_t *ent)
- {
- trap_SendServerCommand(ent-g_entities, va( "tsc %d %d", level.teamScores[TEAM_AXIS], level.teamScores[TEAM_ALLIES]));
- }
- /*
- ***************************
- * cg_servercmds.c *
- ***************************
- */
- // CG_ServerCommand()
- // Add :
- if (!strcmp( cmd, "tsc" ) ) {
- CG_ParseTeamScore();
- return;
- }
- /*
- Parse Team Scores (used to be done by CG_ParseScore but in TDM gametype, we're sending a smaller string to clients)
- */
- void CG_ParseTeamScore( void )
- {
- cg.teamScores[0] = atoi( CG_Argv( 1 ) );
- cg.teamScores[1] = atoi( CG_Argv( 2 ) );
- }
- /*
- ***************************
- * g_combat.c *
- ***************************
- */
- // player_die() - Send updated teamscore to all clients during TDM as soon as a player dies.
- // Add :
- if(g_gametype.integer == GT_WOLF_TDM){
- SendTeamScoreToAllClient();
- }
- /*
- ***************************
- * cg_loadpanel.c *
- ***************************
- */
- // CG_LoadPanel_GameTypeName()
- // Add :
- case GT_WOLF_TDM:
- return "Team Death Match";
- // CG_LoadPanel_RenderCampaignPins()
- // Modify:
- if( cgs.gametype == GT_WOLF_STOPWATCH || cgs.gametype == GT_WOLF_LMS || cgs.gametype == GT_WOLF || cgs.gametype == GT_WOLF_MAPVOTE || cg_gameType.integer == GT_WOLF_TDM || cg_gameType.integer == GT_WOLF_DM ) {
- /*
- ***************************
- * cg_debriefing.c *
- ***************************
- */
- // CG_TeamDebriefing_CalcXP()
- // Modify:
- } else if( cg_gameType.integer == GT_WOLF ||
- cg_gameType.integer == GT_WOLF_STOPWATCH ||
- cg_gameType.integer == GT_WOLF_MAPVOTE ||
- cg_gameType.integer == GT_WOLF_TDM ) {
- for( j = 0; j < SK_NUM_SKILLS; j++ ) {
- if( skillindex != -1 && j != skillindex ) {
- continue;
- }
- cnt += team == TEAM_AXIS ? cgs.tdbAxisMapsXP[ j ][ 0 ] : cgs.tdbAlliedMapsXP[ j ][ 0 ];
- }
- }
- // CG_Debriefing_FindWinningTeamForPos()
- // Modify:
- } else if( cg_gameType.integer == GT_WOLF || cg_gameType.integer == GT_WOLF_LMS ||
- cg_gameType.integer == GT_WOLF_MAPVOTE || cg_gameType.integer == GT_WOLF_TDM ||cg_gameType.integer == GT_WOLF_DM ) {
- const char* s = CG_ConfigString( CS_MULTI_MAPWINNER );
- const char* buf = Info_ValueForKey( s, "w" );
- if( atoi( buf ) == -1 ) {
- } else if( atoi( buf ) ) {
- return TEAM_ALLIES;
- } else {
- return TEAM_AXIS;
- }
- }
- /*
- ***************************
- * cg_draw.c *
- ***************************
- */
- /*
- Print Team Scores AND Final TDM Score (Top Center of the screen)
- I know, this function sucks and needs to be reworked/rewritten...
- */
- void Nit_TDMScore_C( void ) {
- char *axis, *allies, *score;
- int a, b, c;
- if ( !CG_DrawScoreboard() ){
- axis = va("^_Axis ^7%d", cg.teamScores[0]);
- allies = va("%d ^4Allies", cg.teamScores[1]);
- a = CG_Text_Width_Ext(axis, 0.20f, 0, &cgs.media.limboFont2 );
- b = CG_Text_Width_Ext("|", 0.20f, 0, &cgs.media.limboFont2 );
- score = va("%i", cgs.tdmScore);
- c = CG_Text_Width_Ext(score, 0.20f, 0, &cgs.media.limboFont2 );
- CG_Text_Paint_Ext( SCREEN_WIDTH*.5 - a, 38, 0.20f, 0.20f, colorWhite, axis, 0, 0, ITEM_TEXTSTYLE_SHADOWED, &cgs.media.limboFont2 );
- CG_Text_Paint_Ext( SCREEN_WIDTH*.5, 38, 0.20f, 0.20f, colorWhite, "|", 0, 0, ITEM_TEXTSTYLE_SHADOWED, &cgs.media.limboFont2 );
- CG_Text_Paint_Ext( SCREEN_WIDTH*.5 + b, 38, 0.20f, 0.20f, colorWhite, allies, 0, 0, ITEM_TEXTSTYLE_SHADOWED, &cgs.media.limboFont2 );
- CG_Text_Paint_Ext( SCREEN_WIDTH*.5-15, 39, 0.20f, 0.20f, colorWhite, "______", 0, 0, ITEM_TEXTSTYLE_SHADOWED, &cgs.media.limboFont2 );
- CG_Text_Paint_Ext( SCREEN_WIDTH*.5-(c/2)+3, 49, 0.20f, 0.20f, colorWhite, score, 0, 0, ITEM_TEXTSTYLE_SHADOWED, &cgs.media.limboFont2 );
- }
- }
- /*
- Print Team Scores WITHOUT Final TDM Score (Right side of the screen, near lagometer etc...).
- */
- float Nit_TDMScore_R( float y, qboolean draw ){
- char *axis, *allies;
- int w, w2;
- if (draw)
- {
- axis = va("^_Axis ^7%d", cg.teamScores[0]);
- allies = va("^4Allies ^7%d", cg.teamScores[1]);
- w = CG_Text_Width_Ext( axis, 0.19f, 0, &cgs.media.limboFont1 );
- w2 = CG_Text_Width_Ext( allies, 0.19f, 0, &cgs.media.limboFont1 );
- CG_FillRect( UPPERRIGHT_X - w - 2, y, w + 5, 12 + 2, HUD_Background );
- CG_DrawRect_FixedBorder( UPPERRIGHT_X - w - 2, y, w + 5, 12 + 2, 1, HUD_Border );
- CG_Text_Paint_Ext( UPPERRIGHT_X - w, y + 11, 0.19f, 0.19f, HUD_Text, axis, 0, 0, 0, &cgs.media.limboFont1 );
- CG_FillRect( UPPERRIGHT_X - w2 - 2, y + 16, w2 + 5, 12 + 2, HUD_Background );
- CG_DrawRect_FixedBorder( UPPERRIGHT_X - w2 - 2, y + 16, w2 + 5, 12 + 2, 1, HUD_Border );
- CG_Text_Paint_Ext( UPPERRIGHT_X - w2, y + 27, 0.19f, 0.19f, HUD_Text, allies, 0, 0, 0, &cgs.media.limboFont1 );
- }
- return y + 28 + 4;
- }
- // CG_DrawUpperRight()
- // Add:
- if(cgs.gametype == GT_WOLF_TDM){
- if(cg_TDMScorePos.integer == 1){
- y = Nit_TDMScore_R(y, qtrue);
- } else {
- Nit_TDMScore_C();
- }
- }
- /*
- ***************************
- * cg_consolecmds.c *
- ***************************
- */
- /*
- /tdminfo client command.
- Prints useful informations about TeamDeathMatch Gametype.
- */
- void Nit_TDMInfo( void )
- {
- if(cgs.gametype == GT_WOLF_TDM){
- CG_Printf("^5> ^3Final TDM Score: ^7%d\n", cgs.tdmScore);
- CG_Printf("^5> ^3TDM Rules:\n");
- CG_Printf("- To win the match, your team has to reach the score. This score can be dynamic on some servers. The map will ^1NOT ^7end as long as the score is not reached.\n");
- CG_Printf("- Timelimit: If the timelimit is over, the map will ^1NOT ^7end.\n");
- CG_Printf("- Objective: If the final objective is completed, the map will ^1NOT ^7end. BUT the team will get ^2100 ^7Bonus Points!\n");
- CG_Printf("- XP: Every XP point counts in the score. XP will be saved if XPSave is configured on the server.\n");
- return;
- } else {
- CG_Printf("^5>> ^7N^1!^7tmod: ^1This server is NOT running Team Death Match gametype.\n");
- return;
- }
- }
- // static consoleCommand_t commands[]
- // Add:
- { "tdminfo", Nit_TDMInfo },
- //Don't forget to call bani_clearmapxp() and bani_storemapxp() for this gametype aswell.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement