Botpack
Class TrainingCTF

source: e:\games\UnrealTournament\Botpack\Classes\TrainingCTF.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Info
         |
         +--Engine.GameInfo
            |
            +--Botpack.TournamentGameInfo
               |
               +--Botpack.DeathMatchPlus
                  |
                  +--Botpack.TeamGamePlus
                     |
                     +--Botpack.CTFGame
                        |
                        +--Botpack.TrainingCTF
Direct Known Subclasses:None

class TrainingCTF
extends Botpack.CTFGame

//============================================================================= // TrainingCTF. //=============================================================================
Variables
 string CTF[27]
 EventIndex, SoundIndex
 PlayerPawn Trainee
 string TutMessage[30]
 bool bOldAutoTaunt
 bool bPause

States
ServerTravel, FreeRunning2, FreeRunning1

Function Summary
 void CTFTutEvent0()
 void CTFTutEvent1()
 void CTFTutEvent10()
 void CTFTutEvent11()
 void CTFTutEvent12()
 void CTFTutEvent13()
 void CTFTutEvent14()
 void CTFTutEvent15()
 void CTFTutEvent16()
 void CTFTutEvent17()
 void CTFTutEvent2()
 void CTFTutEvent3()
 void CTFTutEvent4()
 void CTFTutEvent5()
 void CTFTutEvent6()
 void CTFTutEvent7()
 void CTFTutEvent8()
 void CTFTutEvent9()
 void InitRatedGame(LadderInventory LadderObj, PlayerPawn LadderPlayer)
 void Timer()
 void TutorialSound(string NewSound)


State ServerTravel Function Summary
 void BeginState()
 void Timer()


State FreeRunning2 Function Summary
 void EndGame(string Reason)
 bool SuccessfulGame()
 void CTFTutEvent24()
 void CTFTutEvent23()
 void CTFTutEvent22()
 void CTFTutEvent21()
 void CTFTutEvent20()
 void Tick(float DeltaTime)


State FreeRunning1 Function Summary
 void CTFTutEvent19()
 void CTFTutEvent18()
 void Tick(float DeltaTime)



Source Code


00001	//=============================================================================
00002	// TrainingCTF.
00003	//=============================================================================
00004	class TrainingCTF extends CTFGame;
00005	
00006	#exec OBJ LOAD FILE=..\Sounds\TutVoiceCTF.uax PACKAGE=TutVoiceCTF
00007	
00008	var bool bOldAutoTaunt;
00009	
00010	var string CTF[27];
00011	
00012	var localized string TutMessage[30];
00013	
00014	var PlayerPawn Trainee;
00015	
00016	var int EventTimer, LastEvent, EventIndex, SoundIndex;
00017	var bool bPause;
00018	
00019	// Parse options for this game...
00020	event InitGame( string Options, out string Error )
00021	{
00022		local string InOpt;
00023	
00024		Super.InitGame(Options, Error);
00025	
00026		bRatedGame = True;
00027		TimeLimit = 0;
00028		RemainingTime = 0;
00029		GoalTeamScore = 3;
00030		FragLimit = 0;
00031		bRequireReady = False;
00032		bTournament = False;
00033		EventTimer = 3;
00034	}
00035	
00036	function InitRatedGame(LadderInventory LadderObj, PlayerPawn LadderPlayer)
00037	{
00038		Super.InitRatedGame(LadderObj, LadderPlayer);
00039		
00040		RemainingBots = 0;
00041		bRequireReady = False;
00042	}
00043	
00044	event playerpawn Login
00045	(
00046		string Portal,
00047		string Options,
00048		out string Error,
00049		class<playerpawn> SpawnClass
00050	)
00051	{
00052		Trainee = Super.Login(Portal, Options, Error, SpawnClass);
00053		Trainee.PlayerReplicationInfo.TeamName = "Red";
00054		Trainee.PlayerReplicationInfo.Team = 0;
00055		Trainee.ReducedDamageType = 'All';
00056	
00057		return Trainee;
00058	}
00059	
00060	function TutorialSound( string NewSound )
00061	{
00062		local sound MySound;
00063	
00064		MySound = sound(DynamicLoadObject( NewSound, class'Sound' ));
00065		EventTimer = GetSoundDuration( MySound ) + 2;
00066		Trainee.PlaySound( MySound, SLOT_Interface, 2.0 );
00067	}
00068	
00069	
00070	function Timer()
00071	{
00072		Super.Timer();
00073	
00074		if ((EventTimer == 0) || bPause)
00075			return;
00076	
00077		EventTimer--;
00078		if (EventTimer == 0)		// Event time is up, perform an event
00079		{
00080			if (EventIndex == LastEvent)	// No more events queued.
00081				return;
00082	
00083			// Call an event function appropriate for this event.
00084			// Is messy.  Would be nicer with function references.
00085			switch (EventIndex)
00086			{
00087				case 0:
00088					CTFTutEvent0();
00089					break;
00090				case 1:
00091					CTFTutEvent1();
00092					break;
00093				case 2:
00094					CTFTutEvent2();
00095					break;
00096				case 3:
00097					CTFTutEvent3();
00098					break;
00099				case 4:
00100					CTFTutEvent4();
00101					break;
00102				case 5:
00103					CTFTutEvent5();
00104					break;
00105				case 6:
00106					CTFTutEvent6();
00107					break;
00108				case 7:
00109					CTFTutEvent7();
00110					break;
00111				case 8:
00112					CTFTutEvent8();
00113					break;
00114				case 9:
00115					CTFTutEvent9();
00116					break;
00117				case 10:
00118					CTFTutEvent10();
00119					break;
00120				case 11:
00121					CTFTutEvent11();
00122					break;
00123				case 12:
00124					CTFTutEvent12();
00125					break;
00126				case 13:
00127					CTFTutEvent13();
00128					break;
00129				case 14:
00130					CTFTutEvent14();
00131					break;
00132				case 15:
00133					CTFTutEvent15();
00134					break;
00135				case 16:
00136					CTFTutEvent16();
00137					break;
00138				case 17:
00139					CTFTutEvent17();
00140					break;
00141				case 18:
00142					CTFTutEvent18();
00143					break;
00144				case 19:
00145					CTFTutEvent19();
00146					break;
00147				case 20:
00148					CTFTutEvent20();
00149					break;
00150				case 21:
00151					CTFTutEvent21();
00152					break;
00153				case 22:
00154					CTFTutEvent22();
00155					break;
00156				case 23:
00157					CTFTutEvent23();
00158					break;
00159				case 24:
00160					CTFTutEvent24();
00161					break;
00162			}
00163			EventIndex++;
00164		}
00165	}
00166	
00167	function CTFTutEvent0()
00168	{
00169		Trainee.ProgressTimeOut = Level.TimeSeconds;
00170		if (Trainee.IsA('TournamentPlayer'))
00171		{
00172			bOldAutoTaunt = TournamentPlayer(Trainee).bAutoTaunt;
00173			TournamentPlayer(Trainee).bAutoTaunt = False;
00174		}
00175		TournamentConsole(Trainee.Player.Console).ShowMessage();
00176		TutorialSound(CTF[0]);
00177		TournamentConsole(Trainee.Player.Console).AddMessage(TutMessage[0]);
00178		SoundIndex++;
00179	
00180		Trainee.Health = 100;
00181	}
00182	
00183	function CTFTutEvent1()
00184	{
00185		TutorialSound(CTF[1]);
00186		TournamentConsole(Trainee.Player.Console).AddMessage(TutMessage[1]);
00187		SoundIndex++;
00188	}
00189	
00190	function CTFTutEvent2()
00191	{
00192		TutorialSound(CTF[2]);
00193		TournamentConsole(Trainee.Player.Console).AddMessage(TutMessage[2]);
00194		SoundIndex++;
00195	}
00196	
00197	function CTFTutEvent3()
00198	{
00199		TutorialSound(CTF[3]);
00200		TournamentConsole(Trainee.Player.Console).AddMessage(TutMessage[3]);
00201		SoundIndex++;
00202	}
00203	
00204	function CTFTutEvent4()
00205	{
00206		local int X, Y;
00207		X = -150;
00208		Y = -350;
00209	
00210		TutorialSound(CTF[4]);
00211		TournamentConsole(Trainee.Player.Console).AddMessage(TutMessage[4]);
00212		SoundIndex++;
00213	}
00214	
00215	function CTFTutEvent5()
00216	{
00217		TutorialSound(CTF[5]);
00218		TournamentConsole(Trainee.Player.Console).AddMessage(TutMessage[5]);
00219		SoundIndex++;
00220	}
00221	
00222	function CTFTutEvent6()
00223	{
00224		TutorialSound(CTF[6]);
00225		TournamentConsole(Trainee.Player.Console).AddMessage(TutMessage[6]);
00226		SoundIndex++;
00227	}
00228	
00229	function CTFTutEvent7()
00230	{
00231		ChallengeHUD(Trainee.myHUD).bForceScores = True;
00232	
00233		TutorialSound(CTF[7]);
00234		TournamentConsole(Trainee.Player.Console).AddMessage(TutMessage[7]);
00235		SoundIndex++;
00236	}
00237	
00238	function CTFTutEvent8()
00239	{
00240		TutorialSound(CTF[8]);
00241		TournamentConsole(Trainee.Player.Console).AddMessage(TutMessage[8]);
00242		SoundIndex++;
00243	}
00244	
00245	function CTFTutEvent9()
00246	{
00247		TutorialSound(CTF[9]);
00248		TournamentConsole(Trainee.Player.Console).AddMessage(TutMessage[9]);
00249		SoundIndex++;
00250	}
00251	
00252	function CTFTutEvent10()
00253	{
00254		TutorialSound(CTF[10]);
00255		TournamentConsole(Trainee.Player.Console).AddMessage(TutMessage[10]);
00256		SoundIndex++;
00257	}
00258	
00259	function CTFTutEvent11()
00260	{
00261		// Show carrying the flag dot!
00262	
00263		TutorialSound(CTF[11]);
00264		TournamentConsole(Trainee.Player.Console).AddMessage(TutMessage[11]);
00265		SoundIndex++;
00266	}
00267	
00268	function CTFTutEvent12()
00269	{
00270		TutorialSound(CTF[12]);
00271		TournamentConsole(Trainee.Player.Console).AddMessage(TutMessage[12]);
00272		SoundIndex++;
00273	}
00274	
00275	function CTFTutEvent13()
00276	{
00277		ChallengeHUD(Trainee.myHUD).bForceScores = False;
00278	
00279		TutorialSound(CTF[13]);
00280		TournamentConsole(Trainee.Player.Console).AddMessage(TutMessage[13]);
00281		SoundIndex++;
00282	}
00283	
00284	function CTFTutEvent14()
00285	{
00286		ChallengeHUD(Trainee.myHUD).bForceScores = False;
00287	
00288		TutorialSound(CTF[14]);
00289		TournamentConsole(Trainee.Player.Console).AddMessage(TutMessage[14]);
00290		SoundIndex++;
00291	}
00292	
00293	function CTFTutEvent15()
00294	{
00295		local Mover m;
00296		foreach AllActors(class'Mover', m)
00297			m.Trigger(Trainee, Trainee);
00298	
00299		Trainee.SetLocation(vect(138, 1327, -84));
00300		Trainee.SetRotation(rot(62611, 42295, 0));
00301		Trainee.ViewRotation = rot(62611, 42295, 0);
00302		PlayTeleportEffect(Trainee, true, true);
00303		TutorialSound(CTF[15]);
00304		TournamentConsole(Trainee.Player.Console).AddMessage(TutMessage[15]);
00305		SoundIndex++;
00306	}
00307	
00308	function CTFTutEvent16()
00309	{
00310		TutorialSound(CTF[16]);
00311		TournamentConsole(Trainee.Player.Console).AddMessage(TutMessage[16]);
00312		SoundIndex++;
00313	}
00314	
00315	function CTFTutEvent17()
00316	{
00317		TutorialSound(CTF[17]);
00318		TournamentConsole(Trainee.Player.Console).AddMessage(TutMessage[17]);
00319		SoundIndex++;
00320	
00321		bPause = True;
00322		GoToState('FreeRunning1');
00323	}
00324	
00325	state FreeRunning1
00326	{
00327		function Tick(float DeltaTime)
00328		{
00329			Super.Tick(DeltaTime);
00330	
00331			if (Trainee.PlayerReplicationInfo.HasFlag != None) 
00332			{
00333				bPause = False;
00334	
00335				TutorialSound(CTF[18]);
00336				TournamentConsole(Trainee.Player.Console).AddMessage(TutMessage[18]);
00337				SoundIndex++;
00338	
00339				GotoState('');
00340			}
00341		}
00342	}
00343	
00344	function CTFTutEvent18()
00345	{
00346		// Point to flag status icons.
00347	
00348		TutorialSound(CTF[19]);
00349		TournamentConsole(Trainee.Player.Console).AddMessage(TutMessage[19]);
00350		SoundIndex++;
00351	}
00352	
00353	function CTFTutEvent19()
00354	{
00355		// Stop pointing.
00356	
00357		TutorialSound(CTF[20]);
00358		TournamentConsole(Trainee.Player.Console).AddMessage(TutMessage[20]);
00359		SoundIndex++;
00360	
00361		bPause = True;
00362		GoToState('FreeRunning2');
00363	}
00364	
00365	state FreeRunning2
00366	{
00367		function Tick(float DeltaTime)
00368		{
00369			Super.Tick(DeltaTime);
00370	
00371			if (Teams[Trainee.PlayerReplicationInfo.Team].Score > 0) 
00372			{
00373				bPause = False;
00374	
00375				TutorialSound(CTF[21]);
00376				TournamentConsole(Trainee.Player.Console).AddMessage(TutMessage[21]);
00377				SoundIndex++;
00378	
00379				GoToState('');
00380			}
00381		}
00382	}
00383	
00384	function CTFTutEvent20()
00385	{
00386		TutorialSound(CTF[22]);
00387		TournamentConsole(Trainee.Player.Console).AddMessage(TutMessage[22]);
00388		SoundIndex++;
00389	}
00390	
00391	function CTFTutEvent21()
00392	{
00393		TutorialSound(CTF[23]);
00394		TournamentConsole(Trainee.Player.Console).AddMessage(TutMessage[23]);
00395		SoundIndex++;
00396	}
00397	
00398	function CTFTutEvent22()
00399	{
00400		TutorialSound(CTF[24]);
00401		TournamentConsole(Trainee.Player.Console).AddMessage(TutMessage[24]);
00402		SoundIndex++;
00403	}
00404	
00405	function CTFTutEvent23()
00406	{
00407		TutorialSound(CTF[25]);
00408		TournamentConsole(Trainee.Player.Console).AddMessage(TutMessage[25]);
00409		SoundIndex++;
00410	}
00411	
00412	function CTFTutEvent24()
00413	{
00414		local int i;
00415	
00416		for (i = 0; i < 2; i++)
00417			Teams[i].Score = 0;
00418	
00419		GoalTeamScore = 3;
00420	
00421		bRatedGame = True;
00422		RemainingBots = RatedMatchConfig.NumBots;
00423	
00424		TournamentConsole(Trainee.Player.Console).HideMessage();
00425	}
00426	
00427	function bool SuccessfulGame()
00428	{
00429		local TeamInfo BestTeam;
00430		local int i;
00431		BestTeam = Teams[0];
00432		for ( i=1; i<MaxTeams; i++ )
00433			if ( Teams[i].Score > BestTeam.Score )
00434				BestTeam = Teams[i];
00435	
00436		if (BestTeam.TeamIndex == Trainee.PlayerReplicationInfo.Team)
00437			return (BestTeam.Score >= GoalTeamScore);
00438		else
00439			return false;
00440	}
00441	
00442	function EndGame( string Reason )
00443	{
00444		Super.EndGame(Reason);
00445	
00446		if (Trainee.IsA('TournamentPlayer'))
00447			TournamentPlayer(Trainee).bAutoTaunt = bOldAutoTaunt;
00448	
00449		if (SuccessfulGame())
00450			TutorialSound(CTF[26]);
00451		else
00452			Trainee.ClientPlaySound(sound'Announcer.LostMatch', True);
00453	
00454		if (RatedGameLadderObj != None)
00455		{
00456			RatedGameLadderObj.PendingChange = 0;
00457			RatedGameLadderObj.LastMatchType = LadderTypeIndex;
00458			if (RatedGameLadderObj.CTFPosition < 1)
00459			{
00460				RatedGameLadderObj.PendingChange = LadderTypeIndex;
00461				RatedGameLadderObj.PendingRank = 1;
00462				RatedGameLadderObj.PendingPosition = 1;
00463			}
00464		}
00465		GoToState('ServerTravel');
00466	}
00467	
00468	state ServerTravel
00469	{
00470		function Timer()
00471		{
00472			local string StartMap;
00473	
00474			StartMap = "UT-Logo-Map.unr"
00475				$"?Game=Botpack.LadderTransition";
00476	
00477			Trainee.ClientTravel(StartMap, TRAVEL_Absolute, True);
00478		}
00479	
00480		function BeginState()
00481		{
00482			SetTimer(9.0, true);
00483		}
00484	}
00485	
00486	defaultproperties
00487	{
00488	     CTF(0)="TutVoiceCTF.ctf00"
00489	     CTF(1)="TutVoiceCTF.ctf01"
00490	     CTF(2)="TutVoiceCTF.ctf02"
00491	     CTF(3)="TutVoiceCTF.ctf03"
00492	     CTF(4)="TutVoiceCTF.ctf04"
00493	     CTF(5)="TutVoiceCTF.ctf05"
00494	     CTF(6)="TutVoiceCTF.ctf06"
00495	     CTF(7)="TutVoiceCTF.ctf07"
00496	     CTF(8)="TutVoiceCTF.ctf08"
00497	     CTF(9)="TutVoiceCTF.ctf09"
00498	     CTF(10)="TutVoiceCTF.ctf10"
00499	     CTF(11)="TutVoiceCTF.ctf11"
00500	     CTF(12)="TutVoiceCTF.ctf12"
00501	     CTF(13)="TutVoiceCTF.ctf13"
00502	     CTF(14)="TutVoiceCTF.ctf26"
00503	     CTF(15)="TutVoiceCTF.ctf14"
00504	     CTF(16)="TutVoiceCTF.ctf15"
00505	     CTF(17)="TutVoiceCTF.ctf16"
00506	     CTF(18)="TutVoiceCTF.ctf17"
00507	     CTF(19)="TutVoiceCTF.ctf18"
00508	     CTF(20)="TutVoiceCTF.ctf19"
00509	     CTF(21)="TutVoiceCTF.ctf20"
00510	     CTF(22)="TutVoiceCTF.ctf21"
00511	     CTF(23)="TutVoiceCTF.ctf22"
00512	     CTF(24)="TutVoiceCTF.ctf23"
00513	     CTF(25)="TutVoiceCTF.ctf24"
00514	     CTF(26)="TutVoiceCTF.ctf25"
00515	     TutMessage(0)="Welcome to Capture the Flag combat training. This tutorial will instruct you on the basic rules of CTF. Tutorials on DeathMatch, Domination, and Assault are also available."
00516	     TutMessage(1)="Let's start by learning about the Heads Up Display (HUD). CTF adds a few new elements to the HUD you should be aware of."
00517	     TutMessage(2)="Your HUD color indicates your team affiliation. Your HUD is red, indicating you are on the red team."
00518	     TutMessage(3)="A blue HUD would indicate that you were on the blue team."
00519	     TutMessage(4)="The two flag icons indicate the status of the red and blue flags. This allows you to obtain a quick overview of battlefield conditions."
00520	     TutMessage(5)="We'll discuss the meaning of each flag status icon in a bit."
00521	     TutMessage(6)="Just to the left of each flag status icon, is that team's score."
00522	     TutMessage(7)="Now lets look at the elements CTF adds to the scoreboard..."
00523	     TutMessage(8)="Capture the Flag uses the standard Unreal teamplay scoreboard configuration."
00524	     TutMessage(9)="The left column lists the red team players and scores and the right column lists the blue team players and scores."
00525	     TutMessage(10)="Notice your name and current score of 0 listed to the left. Above your name is the name of your team. Your team's current score is listed to the right of the team's name."
00526	     TutMessage(11)="When a player in a CTF game is carrying the flag, a small dot will appear next to their name in the scoreboard."
00527	     TutMessage(12)="This can be used to quickly determine which teammate to protect or which enemy to hunt down."
00528	     TutMessage(13)="Now its time to learn the rules of Capture the Flag."
00529	     TutMessage(14)="In Capture the Flag you can use the translocator. It works the same way as in Domination, with one minor change. You are not allowed to translocate and carry the flag at the same time. If you translocate while holding the enemy flag, you will successfully translocate, but will drop the flag on the ground. This prevents you from translocating back to your base after having captured the enemy flag."
00530	     TutMessage(15)="Each CTF map has a red and a blue base. This is red base. Blue base is just down the hallway. Each base contains a flag."
00531	     TutMessage(16)="In front of you is the red flag. The object of CTF is to capture the enemy team's flag while defending your own."
00532	     TutMessage(17)="Let's give it a try. Run to the blue base and touch their flag to pick it up. Grab any equipment you find along the way."
00533	     TutMessage(18)="Great! Now you have the enemy flag. The flashing yellow message is to remind you that once you have the flag, you need to return it to your base to score."
00534	     TutMessage(19)="Notice the blue team flag status icon changed. Now it indicates that a red team player is in possession of the flag. Blue team is in trouble!"
00535	     TutMessage(20)="Take the flag back to your base and touch the red flag to capture the blue flag and score."
00536	     TutMessage(21)="Great job! You captured the enemy flag and scored a point for your team. Wasn't so hard, now, was it?"
00537	     TutMessage(22)="Its about to get harder. In a few seconds, I'm going to spawn two blue team bots and a red teammate you can practice with."
00538	     TutMessage(23)="There is one last status icon to tell you about. If a player drops the flag while carrying it, his team's flag status icon will change to a flag icon containing a downward arrow."
00539	     TutMessage(24)="If you find your flag lying on the ground after you kill an enemy who was carrying it, touch it to automatically return it to your base."
00540	     TutMessage(25)="This concludes the CTF tutorial. Let me spawn those practice bots for you. Good hunting!"
00541	     TutMessage(26)="Congratulations! You have proven yourself to be a worthy CTF player. Now its time to enter the Capture the Flag Tournament Ladder."
00542	     LastEvent=25
00543	     SingleWaitingMessage=""
00544	     bTutorialGame=True
00545	     Difficulty=0
00546	     MapPrefix="CTF-Tutorial"
00547	     BeaconName="CTF-Tutorial"
00548	     GameName="Combat Training: CTF"
00549	     bLoggingGame=False
00550	}

End Source Code