Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames

UTGame.UTDeathmatch


00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
/**
 * Copyright 1998-2008 Epic Games, Inc. All Rights Reserved.
 */
class UTDeathmatch extends UTGame
	config(game);

function bool WantsPickups(UTBot B)
{
	return true;
}

/** return a value based on how much this pawn needs help */
function int GetHandicapNeed(Pawn Other)
{
	local float ScoreDiff;

	if ( Other.PlayerReplicationInfo == None )
	{
		return 0;
	}

	// base handicap on how far pawn is behind top scorer
	GameReplicationInfo.SortPRIArray();
	ScoreDiff = GameReplicationInfo.PriArray[0].Score - Other.PlayerReplicationInfo.Score;

	if ( ScoreDiff < 3 )
	{
		// ahead or close
		return 0;
	}
	return ScoreDiff/3;
}

function CheckSpiceOfLifeAchievement()
{
	local Mutator M;
	local int index;
	local int MutatorBitMask;
	local UTPlayerController PC;

	for (M=BaseMutator; M!=None; M=M.NextMutator)
	{
		if ( UTMutator_BigHead(M) != None)
			index = 0;
		else if ( UTMutator_FriendlyFire(M) != None)
			index = 1;
		else if ( UTMutator_Handicap(M) != None)
			index = 2;
		else if ( UTMutator_Instagib(M) != None)
			index = 3;
		else if ( UTMutator_LowGrav(M) != None)
			index = 4;
		else if ( UTMutator_NoOrbs(M) != None)
			index = 5;
		else if ( UTMutator_NoPowerups(M) != None)
			index = 6;
		else if ( UTMutator_NoTranslocator(M) != None)
			index = 7;
		else if ( UTMutator_Slomo(M) != None)
			index = 8;
		else if ( UTMutator_SlowTimeKills(M) != None)
			index = 9;
		else if ( UTMutator_SpeedFreak(M) != None)
			index = 10;
		else if ( UTMutator_SuperBerserk(M) != None)
			index = 11;
		else if ( UTMutator_WeaponReplacement(M) != None)
			index = 12;
		else if ( UTMutator_WeaponsRespawn(M) != None)
			index = 13;
		else if ( UTMutator_Survival(M) != None)
			index = 14;
		else
			index = -1;

		if (index != -1)
		{
			MutatorBitMask = MutatorBitMask | (1<<index);
		}
	}

	// Check Hero mutator without referencing UT3Gold content
	if ( UTGameReplicationInfo(WorldInfo.GRI).bHeroesAllowed )
	{
		//`log("SpiceOfLife : Hero enabled");
		MutatorBitMask = MutatorBitMask | (1<<15);
	}

	if (MutatorBitMask != 0)
	{
		foreach WorldInfo.AllControllers(class'UTPlayerController',PC)
		{
			//Spectators don't get any
			if (PC.PlayerReplicationInfo.bOnlySpectator)
			{
				continue;
			}

			PC.ClientUpdateSpiceOfLife(MutatorBitMask);
		}
	}
}

function UpdateOnlineAchievements()
{
	local UTPlayerController PC;

	foreach WorldInfo.AllControllers(class'UTPlayerController',PC)
	{
		//Spectators don't get any
		if (PC.PlayerReplicationInfo.bOnlySpectator)
		{
			continue;
		}

		if (PC.PlayerReplicationInfo == GameReplicationInfo.Winner || PC.PlayerReplicationInfo.Team == GameReplicationInfo.Winner)
		{
			PC.ClientUpdateAchievement(EUTA_RANKED_BloodSweatTears, 1);
		}
	}
}

function bool IsValidMutatorsForLikeTheBackOfMyHand()
{
	local Mutator M;

	for (M=BaseMutator; M!=None; M=M.NextMutator)
	{
		if ( UTMutator_Instagib(M) != None)
			return false;
		else if ( UTMutator_NoPowerups(M) != None)
			return false;
	}
	return true;
}

static function bool CheckLikeTheBackOfMyHandAchievement(UTPlayerController PC, INT index)
{
	local int Offset, BitIndex;
	local int TopMask, i, FullMask, Mask;
	local int MapIndex;
	local UTPlayerReplicationInfo UTPRI;
	local bool bAllPickups;

	if (UTBetrayalGame(PC.WorldInfo.Game) != None)
	{
		//Betrayal has no pickups, and doesn't count
		return false;
	}

    //Custom maps never count 
	MapIndex = ConvertMapNameToContext(PC.WorldInfo.GetMapName(true)); 
	if (MapIndex <= 0)
	{
		return false;
	}

	if (index < 0)
	{
		// -1 indicates no valid pickups on the map
		// so return true to catch maps with no pickups
		LogInternal("No pickups for map "$PC.WorldInfo.GetMapName()$" - Marking it completed for Like the Back of my Hand Achievement");
		PC.ClientIncrementLikeTheBackOfMyHand(MapIndex);
		return true;
	}

	//How many 32 bit integers do we need to represent the pickups
	Offset = index / 32;
	//How many bits in the last array
	BitIndex = index % 32;

	// build the mask(s)
	FullMask = 0xFFFFFFFF;

	//Even 0 means a bitmask of 0x1
	for (i = 0; i <= BitIndex; i++)
	{
		TopMask = TopMask | (1<<i);
	}

	// get the PRI
	if (UTPlayerReplicationInfo(PC.PlayerReplicationInfo) != None)
	{
		UTPRI = UTPlayerReplicationInfo(PC.PlayerReplicationInfo);

		if ( UTPRI.PickupFlags.Length == Offset+1)
		{
			bAllPickups=true;
			for (i=0; i <= Offset; i++)
			{
				if (i == Offset)
				{
					Mask = TopMask;
				}
				else
				{
					Mask = FullMask;
				}

				if ( (UTPRI.PickupFlags[i] & Mask) != Mask )
				{
					bAllPickups=false;
					break;
				}
			}

			if (bAllPickups==true)
			{
				LogInternal("You collected all the pickups for map "$PC.WorldInfo.GetMapName()$" - Marking it completed for Like the Back of my Hand Achievement");
				PC.ClientIncrementLikeTheBackOfMyHand(MapIndex);
			}
		}
	}

	return bAllPickups;
}

function CheckCampaignAchievements(int ChapterIndex, int Difficulty, bool Coop)
{
	local UTPlayerController PC;

	foreach WorldInfo.AllControllers(class'UTPlayerController', PC)
	{
		//Spectators don't get any
		if (PC.PlayerReplicationInfo != None && PC.PlayerReplicationInfo.bOnlySpectator)
		{
			continue;
		}

		switch (ChapterIndex)
		{
			// complete chapter 1
		case 1:
			PC.ClientUpdateAchievement(EUTA_CAMPAIGN_Chapter1);
			break;
			// complete chapter 2 - sign treaty
		case 2:
			PC.ClientUpdateAchievement(EUTA_CAMPAIGN_SignTreaty);
			if (Difficulty > 2)
			{
				PC.ClientUpdateAchievement(EUTA_CAMPAIGN_SignTreatyExpert);
			}
			break;
			// complete chapter 3 - liandri mainframe
		case 3:
			PC.ClientUpdateAchievement(EUTA_CAMPAIGN_LiandriMainframe);
			if (Difficulty > 2)
			{
				PC.ClientUpdateAchievement(EUTA_CAMPAIGN_LiandriMainframeExpert);
			}
			break;
			// complete chapter 4 - reach omincron
		case 4:
			PC.ClientUpdateAchievement(EUTA_CAMPAIGN_ReachOmicron);
			if (Difficulty > 2)
			{
				PC.ClientUpdateAchievement(EUTA_CAMPAIGN_ReachOmicronExpert);
			}
			break;
			// complete chapter 5 - defeat akasha - will this trigger?
		case 5:
			PC.ClientUpdateAchievement(EUTA_CAMPAIGN_DefeatAkasha);
			if (Difficulty > 2)
			{
				PC.ClientUpdateAchievement(EUTA_CAMPAIGN_DefeatAkashaExpert);
			}
			if (Coop)
			{
				PC.ClientUpdateAchievement(EUTA_COOP_CompleteCampaign);
			}
			break;
			// this needs to be valid for Coop games
		case 6:
			if (Coop)
			{
				PC.ClientUpdateAchievement(EUTA_COOP_Complete1,1);
				PC.ClientUpdateAchievement(EUTA_COOP_Complete10,1);
			}
			break;
		}
	}
}

function CheckMissionAchievements()
{
	local bool MissionResult;
	local UTProfileSettings Profile;
	local PlayerController PC;
	local bool bCoop;
	local int UnlockChapter;

	foreach LocalPlayerControllers(class'PlayerController', PC)
	{
		Profile = UTProfileSettings( PC.OnlinePlayerData.ProfileProvider.Profile);
		break;
	}

	// get the mission result
	MissionResult = GetSinglePlayerResult();

	// Is this a Coop game?
	if (WorldInfo.Game.GetNumPlayers() > 1)
	{
		bCoop = true;
	}
	else
	{
		bCoop = false;
	}

	// you always win mission 1
	if ( SinglePlayerMissionID == 1 )
	{
		MissionResult = true;
	}

	if ( MissionResult )
	{
		switch ( SinglePlayerMissionID )
		{
			case 1:
				UnlockChapter = 1;
				break;
			case 15:
			case 110:
			case 117:
			case 121:
			case 129:
			case 135:
			case 138:
				UnlockChapter = 2;
				break;
			case 24:
			case 52:
			case 55:
			case 56:
			case 61:
			case 70:
			case 71:
			case 76:
			case 81:
			case 91:
			case 101:
			case 105:
				UnlockChapter = 3;
				break;
			case 33:
				UnlockChapter = 4;
				break;
			case 41:
				UnlockChapter = 5;
				break;
			default:
				UnlockChapter = -1;
				break;
		}
		if (UnlockChapter != -1)
		{
			LogInternal("Unlock Chapter "$UnlockChapter);
			CheckCampaignAchievements(UnlockChapter, Profile.GetCampaignSkillLevel(), bCoop);
		}
	}

	if ( MissionResult && bCoop == true )
	{
		CheckCampaignAchievements(6,0,bCoop);
	}
}

function CheckAchievements()
{
	local int GameScore;
	local UTPlayerController PC;
	local int MixItUpType;
	local bool CheckLikeTheBackOfMyHand;

	if (SinglePlayerMissionID > INDEX_None)
	{
		CheckMissionAchievements();
	}

	CheckLikeTheBackOfMyHand = IsValidMutatorsForLikeTheBackOfMyHand();

	if (bUsingArbitration)
	{
		// it's a ranked game
		MixItUpType = 3;
	}
	else
	{
		if (WorldInfo.NetMode == NM_Standalone)
		{
			// it's an instant action game
			MixItUpType = 1;
		}
		else
		{
			// it'a a multiplayer game
			MixItUpType = 2;
		}
	}

	// Iterate through the playercontroller list
	foreach WorldInfo.AllControllers(class'UTPlayerController',PC)
	{
		//Spectators don't get any
		if (PC.PlayerReplicationInfo.bOnlySpectator)
		{
			continue;
		}

		//These achievements aren't allowed in campaign
		if (SinglePlayerMissionID == INDEX_None)
		{
			// only increment the mix it up for ranked games if they won, do the other ones regardless
			if ((MixItUpType < 3) || (MixItUpType == 3 && (PC.PlayerReplicationInfo == GameReplicationInfo.Winner || PC.PlayerReplicationInfo.Team == GameReplicationInfo.Winner)) )
			{
				// there has to be a better way to get the game type
				if (UTGreedGame(WorldInfo.Game) != None)
					PC.ClientIncrementMixItUp(7, MixItUpType);
				else if (UTBetrayalGame(WorldInfo.Game) != None)
					PC.ClientIncrementMixItUp(6, MixItUpType);
				else if (UTDuelGame(WorldInfo.Game) != None)
					PC.ClientIncrementMixItUp(5, MixItUpType);
				else if (UTOnslaughtGame(WorldInfo.Game) != None)
					PC.ClientIncrementMixItUp(4, MixItUpType);
				else if (UTVehicleCTFGame(WorldInfo.Game) != None)
					PC.ClientIncrementMixItUp(3, MixItUpType);
				else if (UTCTFGame(WorldInfo.Game) != None)
					PC.ClientIncrementMixItUp(2, MixItUpType);
				else if (UTTeamGame(WorldInfo.Game) != None)
					PC.ClientIncrementMixItUp(1, MixItUpType);
				else if (UTDeathmatch(WorldInfo.Game) != None)
					PC.ClientIncrementMixItUp(0, MixItUpType);
			}

			// increment the around the world achievement
			if (WorldInfo.NetMode != NM_Standalone && (PC.PlayerReplicationInfo == GameReplicationInfo.Winner || PC.PlayerReplicationInfo.Team == GameReplicationInfo.Winner))
			{
				//`log("Update the Around the World achievement");
				// TODO:ACH - get map index, these need to have the same order/value as the map contexts on the Xbox
				PC.ClientIncrementAroundTheWorld(ConvertMapNameToContext(WorldInfo.GetMapName(true)));
			}

			// check the untouchable achievement
			if (WorldInfo.NetMode == NM_Standalone)
			{
				if (PC.PlayerReplicationInfo.Kills >= 20 && PC.PlayerReplicationInfo.Deaths == 0 && GetBotSkillLevel() == 7)
				{
					PC.ClientUpdateAchievement(EUTA_IA_Untouchable, 1);
				}
			}
		}

		if (CheckLikeTheBackOfMyHand)
		{
			CheckLikeTheBackOfMyHandAchievement(PC, UTGame(WorldInfo.Game).NextPickupIndex-1);
		}
	}

	if (BaseMutator != None)
	{
		CheckSpiceOfLifeAchievement();
	}

	// bah, check for the only non-team game achievement, the rest are in UTTeamGame
	if (IsMPOrHardBotsGame() && WorldInfo.Game.Class.Name == 'UTDeathmatch')
	{
		GameScore = UTPlayerReplicationInfo(GameReplicationInfo.Winner).Score;

		if ( GameScore >= 20 )
		{
			foreach WorldInfo.AllControllers(class'UTPlayerController',PC)
			{
				//Spectators don't get any
				if (PC.PlayerReplicationInfo.bOnlySpectator)
				{
					continue;
				}

				PC.ClientUpdateAchievement(EUTA_GAME_PaintTownRed,1);
			}
		}
	}

	if (SinglePlayerMissionID == INDEX_NONE && WorldInfo.NetMode != NM_Standalone && !GameSettings.bIsLanMatch && (bUsingArbitration || !class'WorldInfo'.static.IsConsoleBuild(CONSOLE_Xbox360)))
	{
		UpdateOnlineAchievements();
	}
}

/**
 * Writes out the stats for the game type
 */
function WriteOnlineStats()
{
	local UTLeaderboardWriteDM Stats;
	local UTPlayerController PC;
	local UTPlayerReplicationInfo PRI;
	local UniqueNetId ZeroUniqueId;
	local int NumInactives;
	local bool bIsPureGame;
	local int i;
	local float TimeInGame;

	//Figure out all the achievements
	CheckAchievements();

	if ((SinglePlayerMissionID > INDEX_None) || (WorldInfo.NetMode == NM_Standalone))
	{
		//We don't record single player stats
		return;
	}

	// Only calc this if the subsystem can write stats
	if (OnlineSub != None && OnlineSub.StatsInterface != None)
	{
		//Epic content + No bots => Pure
		bIsPureGame = IsPureGame() && !bPlayersVsBots;

		// Iterate through the playercontroller list updating the stats
		foreach WorldInfo.AllControllers(class'UTPlayerController',PC)
		{
			PRI = UTPlayerReplicationInfo(PC.PlayerReplicationInfo);

			// Don't record stats for bots (bots have a zero unique net id)
			// don't record for spectators either (@warning: assumes active players can't become spectators)
			if (PRI != None && !PRI.bOnlySpectator && (PRI.UniqueId != ZeroUniqueId))
			{
				TimeInGame = float(WorldInfo.GRI.ElapsedTime - PRI.StartTime);
				//Game has lasted more than 10 seconds, you've been in at least 30 secs of it or 90% of the elapsed time
				if (WorldInfo.GRI.ElapsedTime > 10 && (TimeInGame >= Min(30.0f, float(WorldInfo.GRI.ElapsedTime) * 0.9f)))
				{
					LogInternal("Writing out stats for player"@PRI.PlayerName);
					//Write out all relevant stats
					Stats = UTLeaderboardWriteDM(new OnlineStatsWriteClass);
					Stats.CopyAndWriteAllStats(PC.PlayerReplicationInfo.UniqueId, PRI, bIsPureGame, OnlineSub.StatsInterface);
				}
			}
			else
			{
				LogInternal("Player"@PRI.PlayerName@"did not have a valid UniqueID, stats not written");
			}
		}

		//Write out stats of players who left the game
		NumInactives = InactivePRIArray.length;
		for (i=0; i<NumInactives; i++)
		{
			PRI = UTPlayerReplicationInfo(InactivePRIArray[i]);
			if (PRI != None && (PRI.UniqueId != ZeroUniqueId))
			{
				LogInternal("Writing out stats for inactive player"@PRI.PlayerName);
				//Write out all relevant stats
				Stats = UTLeaderboardWriteDM(new OnlineStatsWriteClass);
				Stats.CopyAndWriteAllStats(PRI.UniqueId, PRI, bIsPureGame, OnlineSub.StatsInterface);
			}
			else
			{
				LogInternal("Inactive player"@PRI.PlayerName@"did not have a valid UniqueID, stats not written");
			}
		}
	}
}

defaultproperties
{
   bScoreDeaths=True
   bIgnoreTeamForVoiceChat=True
   Acronym="DM"
   Description="Free-for-all kill or be killed.  The player with the most frags wins."
   DefaultEnemyRosterClass="UTGame.UTDMRoster"
   MapPrefixes(0)="DM"
   EndOfMatchRulesTemplateStr_Scoring="First to make `g frags wins"
   EndOfMatchRulesTemplateStr_ScoringSingle="First to frag wins"
   EndOfMatchRulesTemplateStr_Time="most frags in `t mins. wins"
   GameName="DeathMatch"
   OnlineStatsWriteClass=Class'UTGame.UTLeaderboardWriteDM'
   OnlineGameSettingsClass=Class'UTGame.UTGameSettingsDM'
   Name="Default__UTDeathmatch"
   ObjectArchetype=UTGame'UTGame.Default__UTGame'
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: tr 31-1-2018 17:18:36.000 - Creation time: sk 18-3-2018 10:01:19.523 - Created with UnCodeX