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

UTGame.UTMissionSelectionGame


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
00584
00585
00586
00587
00588
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604
00605
00606
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639
00640
00641
00642
00643
00644
00645
00646
00647
00648
00649
00650
00651
00652
00653
00654
00655
00656
00657
00658
00659
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670
00671
00672
00673
00674
00675
00676
00677
00678
00679
00680
00681
00682
00683
00684
00685
00686
00687
00688
00689
00690
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701
00702
00703
00704
00705
00706
00707
00708
00709
00710
00711
00712
00713
00714
00715
00716
00717
00718
00719
00720
00721
00722
00723
00724
00725
00726
00727
00728
00729
00730
00731
00732
00733
00734
00735
00736
00737
00738
00739
00740
00741
00742
00743
00744
00745
00746
00747
00748
00749
00750
00751
00752
00753
00754
00755
00756
00757
00758
00759
00760
00761
00762
00763
00764
00765
00766
00767
00768
00769
00770
00771
00772
00773
00774
00775
00776
00777
00778
00779
00780
00781
00782
00783
00784
00785
00786
00787
00788
00789
00790
00791
00792
00793
00794
00795
00796
00797
00798
00799
00800
00801
00802
00803
00804
00805
00806
00807
00808
00809
00810
00811
00812
00813
00814
00815
00816
00817
00818
00819
00820
00821
00822
00823
00824
00825
00826
00827
00828
00829
00830
00831
00832
00833
00834
00835
00836
00837
00838
00839
00840
00841
00842
00843
00844
00845
00846
00847
00848
00849
00850
00851
00852
00853
00854
00855
00856
00857
00858
00859
00860
00861
00862
00863
00864
00865
00866
00867
00868
00869
00870
00871
00872
00873
00874
00875
00876
00877
00878
00879
00880
00881
00882
00883
00884
00885
00886
00887
00888
00889
00890
00891
00892
00893
00894
00895
00896
00897
00898
00899
00900
00901
00902
00903
00904
00905
00906
00907
00908
00909
/**
 * Copyright 1998-2008 Epic Games, Inc. All Rights Reserved.
 */

class UTMissionSelectionGame extends UTEntryGame
	dependson(UTMissionInfo, UTSeqObj_SPMission);

enum ESinglePlayerMissionResult
{
	ESPMR_None,
	ESPMR_Win,
	ESPMR_Loss
};

var ESinglePlayerMissionResult LastMissionResult;
var string NextMissionURL;
var bool bNextMissionTeamGame;

var UTPlayerController HostPlayer;

var array<string> IronGuardPool;
var array<string> IronGuardEnhancedPool;
var array<string> LiandriPool;
var array<string> LiandriEnhancedPool;

/** This holds the set of bots that have been played from a card **/
var array<string> CardCharacters;

/** This is the set of characters that should always be custom characters **/
var array<string> CharactersThatShouldAlwaysBeCustomCharacters;

/**
 * Figure out if the last match was won or lost
 */
event InitGame( string Options, out string ErrorMessage )
{
	local string InOpt;

	MaxPlayers = GetIntOption(Options, "MaxPlayers", 4);

	GameDifficulty = FMax(0,GetIntOption(Options, "Difficulty", GameDifficulty));

	BroadcastHandler = Spawn(BroadcastHandlerClass);
	if (WorldInfo.NetMode == NM_ListenServer || WorldInfo.NetMode == NM_DedicatedServer )
	{
		AccessControl = Spawn(AccessControlClass);
	}

	InOpt = ParseOption( Options, "SPResult");
	if ( InOpt != "" )
	{
		LastMissionResult = bool(InOpt) ? ESPMR_Win : ESPMR_Loss;
	}
	else
	{
		LastMissionResult = ESPMR_None;
	}

	InOpt = ParseOption(Options,"SPI");
	if ( InOpt != "" )
	{
		SinglePlayerMissionID = int(InOpt);
	}
	else
	{
		SinglePlayerMissionID = INDEX_NONE;
	}

	// Cache a pointer to the online subsystem
	OnlineSub = class'GameEngine'.static.GetOnlineSubsystem();
	if (OnlineSub != None)
	{
		// And grab one for the game interface since it will be used often
		GameInterface = OnlineSub.GameInterface;
	}
}

function InitGameReplicationInfo()
{
	Super.InitGameReplicationInfo();

	UTGameReplicationInfo(GameReplicationInfo).bStoryMode = true;
}

/**
 * A new player has joined the server.  Figure out if that player
 * is the host.
 */
event PostLogin( PlayerController NewPlayer )
{
	Super.PostLogin(NewPlayer);
	ManageLogin(NewPlayer);
}

/**
 * A new player has returned to the server via Seamless travel.  We need
 * to determine if they are the host and setup the PRI accordingly
 */
event HandleSeamlessTravelPlayer(out Controller C)
{
	Super.HandleSeamlessTravelPlayer(C);
	if ( PlayerController(C) != none )
	{
		ManageLogin( PlayerController(C) );
	}
	else if ( UTBot(C) != none )
	{
		KillBot( UTBot(C) );
	}
}


function ManageLogin(PlayerController NewPlayer)
{
	local UTMissionSelectionPRI PRI;
	local UTMissionGRI MGRI;

	MGRI= UTMissionGRI(GameReplicationInfo);
	PRI = UTMissionSelectionPRI(NewPlayer.PlayerReplicationInfo);

	if ( MGRI.HostPRI == None && PRI != None && LocalPlayer(NewPlayer.Player) != none )
	{
		PRI.bIsHost = true;
		MGRI.HostPRI = PRI;

		HostPlayer = UTPlayerController(NewPlayer);

		// Yeah - We have a host, initialize the Mission System.

		InitializeMissionSystem(MGRI, NewPlayer);
	}
}

function byte PickTeam(byte num, Controller C)
{
	if (PlayerController(C) != None)
	{
		return 0;
	}
	else
	{
		return Super.PickTeam(num, C);
	}
}

/**
 * Find the current Mission and look to see if we have a forced path.  If we do, server travel
 */
function InitializeMissionSystem(UTMissionGRI MGRI,PlayerController Host)
{
	local UTProfileSettings Profile;
	local int CMID;
	local int CMResult;
	local UTSeqObj_SPMission PreviousMissionObj, MissionObj;
	local int i, NoChildren;
	local EMissionCondition Condition;
	local EMissionInformation Mission;
	local bool bNeedsProfileSaved, bForceSaveProfile;
	local string work;
	local name Card;

//	`log("[SinglePlayer] InitializeMission:"@SinglePlayerMissionID@LastMissionResult);

	if ( Host == none )
	{
		LogInternal("Error: Attempted to Check for Forced Transitions without a host.  This should never happen.");
		return;
	}

	// Save the status to the profile

	Profile = UTProfileSettings( Host.OnlinePlayerData.ProfileProvider.Profile);

	// You always win the first mission
	if (SinglePlayerMissionID == 1)
	{
		LastMissionResult = ESPMR_Win;
	}

	if ( LastMissionResult != ESPMR_Win )	// Rising Sun always continues....
	{
		// Is there a game in progress

		if ( Profile.bGameInProgress() )
		{

//			`log("[SinglePlayer] Reloading last mission");

			Profile.GetCurrentMissionData(CMID, CMResult);
			SinglePlayerMissionID = CMID;
			LastMissionResult = ESinglePlayerMissionResult(CMResult);
		}
		else
		{
//			`log("[SinglePlayer] New Mission");
			SinglePlayerMissionID = 0;
			LastMissionResult = ESPMR_None;
		}

	}
	else	// Continuing this session
	{

		Card = UTGameUISceneClient(class'UIRoot'.static.GetSceneClient()).LastModifierCardUsed;
		if (Card != '')
		{

			// If we have a modifier card in play, clear it here
			HostPlayer.UseModifierCard(Card);
		}

		CMResult = INT(LastMissionResult);
		Profile.SetCurrentMissionData( SinglePlayerMissionID, CMResult);
		bNeedsProfileSaved = true;
		CMID = SinglePlayerMissionID;

//		`log("[SinglePlayer] Continuing to next mission");


	}

	// Look at all of the available missions for the last mission and fill out the GRI's array.
	// Also, check for CutSequences and Automatic Transitions here

	PreviousMissionObj = MGRI.GetMissionObj(CMID);

	if ( PreviousMissionObj != none )
	{
		// Mark the mission's as being visited

		if ( MGRI.GetMission(PreviousMissionObj.MissionID, Mission) )
		{
			Profile.BoneHasBeenVisited(Mission.GlobeBoneName);
			bNeedsProfileSaved = true;

			// If this was any of the containment maps, flag it

		    if ( InStr(Mission.Map,"Containment") > INDEX_None || PreviousMissionObj.MissionID == 33 || PreviousMissionObj.MissionID == 143)
	        {
	        	Profile.AddPersistentKey(ESPKey_DarkWalkerUnlock);
	        	Profile.AddPersistentKey(ESPKey_CanStealNecris);
				bForceSaveProfile = true;
	        }
		}

		// If we aren't a cutsequence or the first mission, we need to save the profile for the the mission progress
		if (bForceSaveProfile || (!PreviousMissionObj.bCutSequence && PreviousMissionObj.MissionID != 0) )
		{
			Profile.BoneHasBeenVisited(Mission.GlobeBoneName);
			bNeedsProfileSaved = true;
		}
		else
		{	// Otherwise don't save the profile
			bNeedsProfileSaved = false;
		}


		// We have to subtract 1 from UnlockChapterIndex because Jim used 1-X instead of 0-X.
		// This is also done in Profile.UnlockChapter

		// Look to see if we need to unlock a chapter
		if ( LastMissionResult == ESPMR_Win && PreviousMissionObj.bUnlockChapterWhenCompleted )
		{
			Profile.UnlockChapter(PreviousMissionObj.UnlockChapterIndex);
			work = Localize("Campaign","Chapter"$PreviousMissionObj.UnlockChapterIndex-1$"Unlock","UTGameUI");
			class'UTUIScene'.static.ShowOnlineToast(Work);
			bNeedsProfileSaved = true;
		}


		// Look to see if we should be clearing the cards
		if ( PreviousMissionObj.bClearCards )
		{
			Profile.ClearModifierCards();
			bNeedsProfileSaved = true;
		}

		NoChildren = PreviousMissionObj.NumChildren();
		for (i = 0; i < NoChildren; i++)
		{
			MissionObj = PreviousMissionObj.GetChild(i,Condition);

			if ( CheckMission(Profile, LastMissionResult, Condition) )
			{

				// Check to see if we should auto-forward

				if ( MGRI.GetMission(MissionObj.MissionID, Mission) )
				{
					if ( MissionObj.bCutSequence )
					{
						HandleCutSequence(Mission, MissionObj);

						if (bNeedsProfileSaved)
						{
							SaveProfile(Host);
						}

						return;
					}

					if ( MissionObj.bAutomaticTransition )
					{

						if (Mission.MissionID == 149)
						{
							ShowCredits();
						}
						else
						{
							HandleForcedTravel(Mission.MissionID);

							if (bNeedsProfileSaved)
							{
								SaveProfile(Host);
							}
						}

						return;
					}
					// Add to the Available Missions List
					MGRI.AddAvailableMission(Mission);
				}

			}
		}
	}

	MGRI.LastMissionResult = LastMissionResult;
	MGRI.LastMissionID = SinglePlayerMissionID;
	MGRI.HostChapterMask = Profile.GetChapterMask();

	// Open up the selection menu
	MGRI.ChangeMenuState(EMS_Selection);

	// Tell everyone which mission to select
	MGRI.ChangeMission(MGRI.AvailMissionList[0].MissionID);

	if (bNeedsProfileSaved)
	{
		SaveProfile(Host);
	}

	Profile.GetBoneMask(MGRI.BoneMask.A, MGRI.BoneMask.B);
	MGRI.ReplicatedEvent('BoneMask');


}

function SaveProfile(PlayerController TargetPC)
{
	UTPlayerController(TargetPC).SaveProfile();
}

/**
 * Checks to see if a mission can be added to the mission list
 *
 * @param Profile		The profile we are using
 * @param Result		The result of the last match
 * @param Condition 	The conditions to check against
 *
 * @returns true if this mission is good to go
 */
function bool CheckMission(UTProfileSettings Profile, ESinglePlayerMissionResult Result, EMissionCondition Condition)
{
	local int i;
	// Quick Win/Lost Short Circuit
	if ( (Condition.MissionResult == EMResult_Won && Result != ESPMR_Win) ||
		(Condition.MissionResult == EMResult_Lost && Result != ESPMR_Loss) )
	{
		return false;
	}

	// Check for any required persistent keys
	for (i=0;i<Condition.RequiredPersistentKeys.Length;i++)
	{
		if ( !Profile.HasPersistentKey(Condition.RequiredPersistentKeys[i]) )
		{
			return false;
		}
	}

	// Check to see if we are restricted by a persistent key
	for (i=0;i<Condition.RequiredPersistentKeys.Length;i++)
	{
		if ( Profile.HasPersistentKey(Condition.RestrictedPersistentKeys[i]) )
		{
			return false;
		}
	}

	// This mission is ok

	return true;
}


/**
 * Travel to a cut sequence
 */

function HandleCutSequence(EMissionInformation Mission, UTSeqObj_SPMission MissionObj)
{
	local string URL;
	local UTMissionGRI MissionGRI;

	MissionGRI = UTMissionGRI(GameReplicationInfo);

	if ( MissionObj.bIsBinkSequence )
	{
//		`log("[SinglePlayer] Executing a BINK cut sequence ("$Mission.Map$")");

		MissionGRI.CurrentMissionID = Mission.MissionID;
		MissionGRI.PlayBinkMission = Mission.MissionID;
		MissionGRI.ReplicatedEvent('PlayBinkMission');	// Fake replication on listen server hosts
		MissionGRI.OnBinkMovieFinished = BinkMovieFinished;
	}
	else
	{
//		`log("[SinglePlayer] Executing a in-game cut sequence @"@WorldInfo.TimeSeconds);
		URL = Mission.Map $ Mission.URL $ "?SPI="$Mission.MissionID;
		WorldInfo.ServerTravel(URL);
	}
}

function BinkMovieFinished()
{
	local UTMissionGRI MissionGRI;

//	`log("[SinglePlayer] Bink movie finished @"@WorldInfo.TimeSeconds@"continuing Re-initializing Mission System");

	MissionGRI = UTMissionGRI(GameReplicationInfo);
	MissionGRI.PlayBinkMission = -1;
	LastMissionResult = ESPMR_WIN;
	SinglePlayerMissionID = MissionGRI.CurrentMissionID;
	InitializeMissionSystem(MissionGRI, HostPlayer);
}

/**
 * Create the URL and travel to a given mission.
 */
function HandleForcedTravel(int MissionID)
{
	local EMissionInformation Mission;
	UTMissionGRI(GameReplicationInfo).CurrentMissionID = MissionID;
	UTMissionGRI(GameReplicationInfo).GetCurrentMission(Mission);
//	`log("[SinglePlayer] Force Travel to :"@MissionId@Mission.MissionId@Mission.Map);
	AcceptMission();
}




function BriefMission()
{
	local UTMissionGRI MGRI;
	MGRI = UTMissionGRI(GameReplicationInfo);
	MGRI.ChangeMenuState(EMS_Brief);
}

/**
 * The host has accepted a mission.  Signal the clients to travel and wait for
 * them to sync up.
 */

function AcceptMission()
{
	local UTMissionGRI MGRI;
	local string URL, GameType;
	local EMissionInformation Mission;
	local int i;
	local UTPlayerController PC;
	local UTProfileSettings Profile;
	local UTBot B;

	// Log any bots still hanging around
	foreach WorldInfo.AllControllers(class'UTBot', B)
	{
		WarnInternal("BOT STILL AROUND!" @ B.PlayerReplicationInfo.PlayerName @ B);
		//@hack: pretty sure the right fix is to prevent Logout() from adding a bot to replace an exiting human
		//	when we haven't accepted the mission yet, but this is a safer fix at this point
		B.Destroy();
	}

	MGRI = UTMissionGRI(GameReplicationInfo);
	if ( MGRI != none && MGRI.GetCurrentMission(Mission) )
	{

		UTGameUISceneClient(class'UIRoot'.static.GetSceneClient()).MissionText = " DEBUG Prev. MissionID: "$SinglePlayerMissionID$" \n DEBUG MissionID: "$Mission.MissionID$" \n\ "$Mission.BriefingText;

		GameType = ParseOption(Mission.URL, "game");
		// default to Team DM if no gametype specified for DM maps
		if (GameType == "" && Left(Mission.Map, 3) ~= "DM-")
		{
			Mission.URL $= "?game=UTGame.UTTeamGame";
			bNextMissionTeamGame = true;
		}
		else
		{
			//@hack: we can't load the game class on console, so assume deathmatch is the only FFA type
			bNextMissionTeamGame = !(GameType ~= "utgame.utdeathmatch");
		}

		Profile = UTProfileSettings( HostPlayer.OnlinePlayerData.ProfileProvider.Profile );

		// Always read the skill level from the profile....
		GameDifficulty = Profile.GetCampaignSkillLevel() * 2;

		URL = Mission.Map $ Mission.URL $ "?SPI="$Mission.MissionID$"?PlayersMustBeReady=1?Difficulty="$GameDifficulty$"?MaxPlayers="$MaxPlayers;
		if (InStr(Caps(URL), "?TIMELIMIT=") == INDEX_NONE)
		{
			URL $= "?TimeLimit=20";
		}

		if ( Profile == none  || !Profile.HasPersistentKey(ESPKey_CanStealNecris) )
		{
			URL $= "?NecrisLocked=1";
		}

		if (HostPlayer != None)
		{

			if ( Mission.MissionID == 149 )	// We won, clear out the mission data in the profile.
			{
				Profile.SetCurrentMissionData(INDEX_None, INDEX_None);
			}


			if (MGRI.GameModifierCard != '')
			{
				ProcessModifierCard(MGRI.GameModifierCard, Profile, URL, Mission);
			}

			// Clear Any Must use cards
			for (i=0;i<class'UTGameModifierCard'.default.Deck.Length; i++)
			{
				if (class'UTGameModifierCard'.default.Deck[i].bMustUse)
				{
					HostPlayer.UseModifierCard(class'UTGameModifierCard'.default.Deck[i].Tag);
				}
			}
		}

		// we need to call this twice so we first add all of the characters that must have customized meshes and then with everyone else
		AddBotsFromMissionData( Mission, TRUE );
		AddBotsFromMissionData( Mission, FALSE );

		// make sure all the humans are on the correct team
		foreach WorldInfo.AllControllers(class'UTPlayerController', PC)
		{
			SetTeam(PC, bNextMissionTeamGame ? Teams[0] : None, false);
		}

		NextMissionURL = URL;
		MGRI.ChangeMenuState(EMS_Launch);
		GotoState('SyncClients');
	}
	else
	{
		LogInternal("Warning: The Single Play game could not accept a mission.");
	}
}

/** This will look down the list of chars that should always be custom and then return true of the passed in string is in that list **/
function bool IsACharacterThatShouldAlwaysBeCustom( string CharName )
{
	local bool Retval;
	local int i;

	for( i = 0; i < CharactersThatShouldAlwaysBeCustomCharacters.length; ++i )
	{
		if( CharactersThatShouldAlwaysBeCustomCharacters[i] == CharName )
		{
			Retval = TRUE;
			break;
		}
	}

	return Retval;
}

/**
 * This function is called when we are adding a character to the game.  It is meant to be called twice.  The first time
 * with bAddOnlyCustomizedCharacters being TRUE so all of the characters that we want customized will actually be that way.
 * And then with bAddOnlyCustomizedCharacters FALSE so we add all of the other characters into the world.
 *
 * The mission data has a number of ways in which it organizes that data so we need to do two passes over that data in order
 * to make certain that we get the most optimal set of customized characters.
 *
 * NOTE: this will just order the list with the "important to be customized" first.  Machine settings could make it such that
 * only a subset actually get customized characters or that all of them do!
 *
 **/
function AddBotsFromMissionData( EMissionInformation Mission, bool bAddOnlyCustomizedCharacters )
{
	local int i;
	local UTBot B;

	// add any card characters first as they are important!
	for (i = 0; i < CardCharacters.length; i++)
	{
		if( IsACharacterThatShouldAlwaysBeCustom( CardCharacters[i] ) == bAddOnlyCustomizedCharacters )
		{
			SinglePlayerAddBot(CardCharacters[i], true, 0);
		}
	}

	// spawn the bots in advance, so the custom mesh construction takes place while traveling
	for (i = 0; i < Mission.RequiredTeammates.length; i++)
	{
		if( IsACharacterThatShouldAlwaysBeCustom( Mission.RequiredTeammates[i] ) == bAddOnlyCustomizedCharacters )
		{
			SinglePlayerAddBot(Mission.RequiredTeammates[i], true, 0);
		}
	}

	for (i = 0; i < Mission.RequiredOpponents.length; i++)
	{
		if( IsACharacterThatShouldAlwaysBeCustom( Mission.RequiredOpponents[i] ) == bAddOnlyCustomizedCharacters )
		{
			SinglePlayerAddBot(Mission.RequiredOpponents[i], true, 1);
		}
	}

	for (i = 0; i < Mission.PrecachedTeammates.length; i++)
	{
		if( IsACharacterThatShouldAlwaysBeCustom( Mission.PrecachedTeammates[i] ) == bAddOnlyCustomizedCharacters )
		{
			B = SinglePlayerAddBot(Mission.PrecachedTeammates[i], true, 0);
			if (B != None)
			{
				UTPlayerReplicationInfo(B.PlayerReplicationInfo).bPrecachedBot = true;
			}
		}
	}

	for (i = 0; i < Mission.PrecachedOpponents.length; i++)
	{
		if( IsACharacterThatShouldAlwaysBeCustom( Mission.PrecachedOpponents[i] ) == bAddOnlyCustomizedCharacters )
		{
			B = SinglePlayerAddBot(Mission.PrecachedOpponents[i], true, 1);
			if (B != None)
			{
				UTPlayerReplicationInfo(B.PlayerReplicationInfo).bPrecachedBot = true;
			}
		}
	}
}


function ProcessModifierCard(name GameModifierCard, UTProfileSettings Profile, out string URL, out EMissionInformation Mission)
{
	local int i,j,r, OldNum, RemoveCount;
	local array<string> Pool;

	URL = URL$Class'UTGameModifierCard'.static.GetURL(GameModifierCard);

	CardCharacters.Length = 0; // reset the CardCharacters

	if ( GameModifierCard == 'IronGuard' )
	{
		if ( Profile.HasPersistentKey( class'UTGameModifierCard'.static.GetAltKey(GameModifierCard)) )
		{
			i = CardCharacters.Length;
			CardCharacters.Length = i + 2;

			CardCharacters[i] = "Lauren";
			j = Rand(IronGuardEnhancedPool.Length);
			CardCharacters[i+1] = IronGuardEnhancedPool[j];
		}
		else
		{
			i = CardCharacters.Length;
			CardCharacters.Length = i + 2;
			for (j=0;j<2;j++)
			{
				r = Rand(IronGuardPool.Length);
				CardCharacters[i+j] = IronGuardPool[r];
				IronGuardPool.Remove(r,1);
			}
		}
	}
	else if ( GameModifierCard == 'Liandri' )
	{
		Pool = Profile.HasPersistentKey(class'UTGameModifierCard'.static.GetAltKey(GameModifierCard)) ? LiandriEnhancedPool : LiandriPool;

		// first, try to pick random characters and only choose those not already in the mission
		i = CardCharacters.Length;
		CardCharacters.Length = i + 2;
		while (i < CardCharacters.length && Pool.length > 0)
		{
			r = Rand(Pool.length);
			if (Mission.RequiredOpponents.Find(Pool[r]) == INDEX_NONE && Mission.PrecachedOpponents.Find(Pool[r]) == INDEX_NONE)
			{
				CardCharacters[i] = Pool[r];
				i++;
			}
			Pool.Remove(r, 1);
		}

		if (i < CardCharacters.length)
		{
			// now just pick in order and don't care about duplicates
			Pool = Profile.HasPersistentKey(class'UTGameModifierCard'.static.GetAltKey(GameModifierCard)) ? LiandriEnhancedPool : LiandriPool;
			for (r = 0; r < Pool.length && i < CardCharacters.length; r++)
			{
				if (CardCharacters.Find(Pool[r]) == INDEX_NONE)
				{
					CardCharacters[i] = Pool[r];
					i++;
				}
			}
		}
	}
	else if (GameModifierCard == 'TacticalDiversion')
	{
		if ( Mission.RequiredOpponents.length <= Mission.RequiredTeammates.length + 1 )
			RemoveCount = Min(1, Mission.RequiredOpponents.length - 1);
		else
		RemoveCount = Min(2, Mission.RequiredOpponents.length - 1);
		if (RemoveCount > 0)
		{
			Mission.RequiredOpponents.Remove(Mission.RequiredOpponents.length - RemoveCount, RemoveCount);
		}
		else
		{
			RemoveCount = 0;
		}
		// also update the URL's number of players
		i = InStr(Caps(URL), "?NUMPLAY=");
		if (i != INDEX_NONE)
		{
			// we have to strip out the mapname for GetIntOption() to work
			OldNum = GetIntOption(Right(URL, Len(URL) - InStr(URL, "?")), "numplay", 0);

			URL = Left(URL, i) $ "?numplay=" $ (OldNum - RemoveCount) $ Right(URL, Len(URL) - i - 9 - ((OldNum >= 10) ? 2 : 1));
			if (RemoveCount < 2)
			{
				URL $= "?diverted=" $ (2 - RemoveCount);
			}
		}
	}


	UTGameUISceneClient(class'UIRoot'.static.GetSceneClient()).LastModifierCardUsed = GameModifierCard;
}


function UTTeamInfo GetBotTeam(optional int TeamBots, optional bool bUseTeamIndex, optional int TeamIndex)
{
	if (bNextMissionTeamGame)
	{
		return Super.GetBotTeam(TeamBots, bUseTeamIndex, TeamIndex);
	}
	else
	{
		EnemyRosterName = "UTGame.UTDMRoster";
		return Super(UTGame).GetBotTeam(TeamBots, bUseTeamIndex, TeamIndex);
	}
}

function UTBot AddBot(optional string BotName, optional bool bUseTeamIndex, optional int TeamIndex)
{
	local UTBot B;

	B = Super.AddBot(BotName, bUseTeamIndex, TeamIndex);
	if (B != None)
	{
		B.GotoState('RoundEnded');
	}

	return B;
}

/**
 * We need to give clients time to bring the briefing menu up and become ready to travel.  We do
 * this by pausing here and waiting for bReadyToPlay to be set for each player
 */
state SyncClients
{
	// Check ready status 4x a second
	function BeginState(name PrevStateName)
	{
		Super.BeginState(PrevStateName);
		SetTimer(0.25, true);
		SetTimer(5.0, false, 'GiveUpWaiting');
	}

	// Look at the PRI list and see if anyone still isn't ready.
	function Timer()
	{
		local int i;
		local bool bReadyToGo;
		local PlayerReplicationInfo PRI;

		bReadyToGo = true;
		for (i=0;i<GameReplicationInfo.PRIArray.Length;i++)
		{
			PRI = GameReplicationInfo.PRIArray[i];
			if ( !PRI.bOnlySpectator && !PRI.bReadyToPlay && !PRI.bBot)
			{
				bReadyToGo = false;
			}
		}

		if (bReadyToGo)
		{
			ClearTimer();
			ClearTimer('GiveUpWaiting');
			WorldInfo.ServerTravel(NextMissionURL,true);
		}
	}

	function GiveUpWaiting()
	{
		ClearTimer();
		WorldInfo.ServerTravel(NextMissionURL, true);
	}
}

function SetModifierCard(name Card)
{
	UTMissionGRI(GameReplicationInfo).SetModifierCard(Card);
}

function bool TooManyBots(Controller botToRemove)
{
	return false;
}

function bool NeedPlayers()
{
	return false;
}

auto State PendingMatch
{
	function bool MatchIsInProgress()
	{
		return false;
	}

	/**
	 * Tells all of the currently connected clients to register with arbitration.
	 * The clients will call back to the server once they have done so, which
	 * will tell this state to see if it is time for the server to register with
	 * arbitration.
	 */
	function StartMatch()
	{
		return;
	}
}

function ShowCredits()
{
	WorldInfo.ServerTravel("UTCin-UT3Credits",true);
}

defaultproperties
{
   IronGuardPool(0)="Cain"
   IronGuardPool(1)="Blackjack"
   IronGuardPool(2)="Johnson"
   IronGuardPool(3)="Kregore"
   IronGuardPool(4)="Talan"
   IronGuardEnhancedPool(0)="Barktooth"
   IronGuardEnhancedPool(1)="Harlin"
   IronGuardEnhancedPool(2)="Slain"
   IronGuardEnhancedPool(3)="Blain"
   LiandriPool(0)="Torque"
   LiandriPool(1)="Syntax"
   LiandriPool(2)="Raptor"
   LiandriPool(3)="Mihr"
   LiandriEnhancedPool(0)="Matrix"
   LiandriEnhancedPool(1)="Aspect"
   LiandriEnhancedPool(2)="Cathode"
   LiandriEnhancedPool(3)="Enigma"
   CharactersThatShouldAlwaysBeCustomCharacters(0)="Reaper"
   CharactersThatShouldAlwaysBeCustomCharacters(1)="Jester"
   CharactersThatShouldAlwaysBeCustomCharacters(2)="Othello"
   CharactersThatShouldAlwaysBeCustomCharacters(3)="Bishop"
   CharactersThatShouldAlwaysBeCustomCharacters(4)="Lauren"
   CharactersThatShouldAlwaysBeCustomCharacters(5)="Akasha"
   CharactersThatShouldAlwaysBeCustomCharacters(6)="Loque"
   CharactersThatShouldAlwaysBeCustomCharacters(7)="Matrix"
   CharactersThatShouldAlwaysBeCustomCharacters(8)="Scythe"
   CharactersThatShouldAlwaysBeCustomCharacters(9)="Alanna"
   CharactersThatShouldAlwaysBeCustomCharacters(10)="Arachne"
   CharactersThatShouldAlwaysBeCustomCharacters(11)="Ariel"
   CharactersThatShouldAlwaysBeCustomCharacters(12)="Avalon"
   CharactersThatShouldAlwaysBeCustomCharacters(13)="Cassidy"
   CharactersThatShouldAlwaysBeCustomCharacters(14)="Desiree"
   CharactersThatShouldAlwaysBeCustomCharacters(15)="Freylis"
   CharactersThatShouldAlwaysBeCustomCharacters(16)="Kai"
   CharactersThatShouldAlwaysBeCustomCharacters(17)="Kira"
   CharactersThatShouldAlwaysBeCustomCharacters(18)="Malise"
   CharactersThatShouldAlwaysBeCustomCharacters(19)="Metridia"
   CharactersThatShouldAlwaysBeCustomCharacters(20)="Raven"
   CharactersThatShouldAlwaysBeCustomCharacters(21)="Visse"
   ConsolePlayerControllerClass=Class'UTGame.UTMissionPlayerController'
   HUDType=None
   PlayerControllerClass=Class'UTGame.UTMissionPlayerController'
   PlayerReplicationInfoClass=Class'UTGame.UTMissionSelectionPRI'
   GameReplicationInfoClass=Class'UTGame.UTMissionGRI'
   Name="Default__UTMissionSelectionGame"
   ObjectArchetype=UTEntryGame'UTGame.Default__UTEntryGame'
}

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