Botpack
Class TournamentGameInfo

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

class TournamentGameInfo
extends Engine.GameInfo

//============================================================================= // TournamentGameInfo. // // default game info is normal single player // //=============================================================================
Variables
 int BestFPHs[3]
 string BestPlayers[3]
 string BestRecordDate[3]
 class EndStatsClass
 class RedeemerClass
 int TotalDeaths
 int TotalFlags
 int TotalFrags
 int TotalGames
 bool bDisallowOverride
 bool bRatedGame


Function Summary
 bool AtCapacity(string Options)
 void BroadcastRegularDeathMessage(Pawn Killer, Pawn Other, name damageType)
 void CalcEndStats()
 string CreatureKillMessage(name damageType, Pawn Other)
 void DiscardInventory(Pawn Other)
     
//
// Discard a player's inventory after he dies.
//
 void EmptyBestSlot(int Slot)
 void GetTimeStamp(out string)
 string KillMessage(name damageType, Pawn Other)
 float PlaySpawnEffect(Inventory Inv)
 void PlayTeleportEffect(Actor Incoming, bool bOut, bool bSound)
 string PlayerKillMessage(name damageType, PlayerReplicationInfo Other)
 bool ShouldRespawn(Actor Other)



Source Code


00001	//=============================================================================
00002	// TournamentGameInfo.
00003	//
00004	// default game info is normal single player
00005	//
00006	//=============================================================================
00007	class TournamentGameInfo extends GameInfo;
00008	
00009	#exec AUDIO IMPORT FILE="Sounds\Generic\Resp2a.wav" NAME="Resp2A" GROUP="General"
00010	
00011	var(DeathMessage) localized string DeathMessage[32];    // Player name, or blank if none.
00012	var(DeathMessage) localized string DeathModifier[5];
00013	var(DeathMessage) localized string MajorDeathMessage[8];
00014	var(DeathMessage) localized string HeadLossMessage[2];
00015	var(DeathMessage) localized string DeathVerb;
00016	var(DeathMessage) localized string DeathPrep;
00017	var(DeathMessage) localized string DeathTerm;
00018	var(DeathMessage) localized string ExplodeMessage;
00019	var(DeathMessage) localized string SuicideMessage;
00020	var(DeathMessage) localized string FallMessage;
00021	var(DeathMessage) localized string DrownedMessage;
00022	var(DeathMessage) localized string BurnedMessage;
00023	var(DeathMessage) localized string CorrodedMessage;
00024	var(DeathMessage) localized string HackedMessage;
00025	var(DeathMessage) localized string MortarMessage;
00026	var(DeathMessage) localized string MaleSuicideMessage;
00027	var(DeathMessage) localized string FemaleSuicideMessage;
00028	
00029	var bool bRatedGame;
00030	
00031	var class<Weapon> RedeemerClass;
00032	var class<EndStats> EndStatsClass;
00033	
00034	var int TotalGames;
00035	var int TotalFrags;
00036	var int TotalDeaths;
00037	var int TotalFlags;
00038	
00039	var string BestPlayers[3];
00040	var int BestFPHs[3];
00041	var string BestRecordDate[3];
00042	var bool bDisallowOverride;
00043	
00044	function bool AtCapacity(string Options)
00045	{
00046		local string OverrideClass;
00047	
00048		OverrideClass = ParseOption ( Options, "OverrideClass" );	
00049		if ( OverrideClass != "" )
00050			return ( (NumSpectators >= MaxSpectators)
00051					|| ((Level.Netmode == NM_ListenServer) && (NumPlayers == 0)) );
00052		return ( (MaxPlayers>0) && (NumPlayers>=MaxPlayers) );
00053	}
00054	
00055	
00056	event playerpawn Login
00057	(
00058		string Portal,
00059		string Options,
00060		out string Error,
00061		class<playerpawn> SpawnClass
00062	)
00063	{
00064		local PlayerPawn NewPlayer;
00065		local string OverrideClass;
00066		local class<PlayerPawn> SpecClass;
00067		local string InVoice;
00068	
00069		if ( !bRatedGame )
00070		{
00071			if ( !bDisallowOverride )
00072			{
00073				OverrideClass = ParseOption ( Options, "OverrideClass" );	
00074				if ( OverrideClass != "" )
00075				{
00076					SpecClass = class<PlayerPawn>(DynamicLoadObject(OverrideClass,class'Class'));
00077					if ( (SpecClass != None) && ClassIsChildOf( SpecClass, class'CHSpectator') )
00078						SpawnClass = SpecClass;
00079				}
00080			}
00081			if ( ClassIsChildOf(SpawnClass, class'Spectator') )
00082			{
00083				if ( !ClassIsChildOf( SpawnClass, class'CHSpectator') )
00084					SpawnClass = class'CHSpectator';
00085			}
00086			else if ( !ClassIsChildOf(SpawnClass, class'TournamentPlayer') )
00087				SpawnClass = DefaultPlayerClass;
00088		}
00089		else if ( !ClassIsChildOf(SpawnClass, class'TournamentPlayer') )
00090			SpawnClass = DefaultPlayerClass;
00091	
00092		NewPlayer = Super.Login(Portal, Options, Error, SpawnClass);
00093	
00094		if ( NewPlayer != None )
00095		{
00096			if ( !NewPlayer.IsA('Spectator') )
00097			{
00098				InVoice = ParseOption ( Options, "Voice" );
00099				if ( InVoice != "" )
00100					NewPlayer.PlayerReplicationInfo.VoiceType = class<VoicePack>(DynamicLoadObject(InVoice, class'Class'));
00101				if ( NewPlayer.PlayerReplicationInfo.VoiceType == None )
00102					NewPlayer.PlayerReplicationInfo.VoiceType = class<VoicePack>(DynamicLoadObject(NewPlayer.VoiceType, class'Class'));
00103				if ( NewPlayer.PlayerReplicationInfo.VoiceType == None )
00104					NewPlayer.PlayerReplicationInfo.VoiceType = class<VoicePack>(DynamicLoadObject("Botpack.VoiceMaleOne", class'Class'));
00105			}
00106		}
00107	
00108		return NewPlayer;
00109	}
00110	
00111	
00112	function float PlaySpawnEffect(inventory Inv)
00113	{
00114		spawn( class 'EnhancedReSpawn',Inv,, Inv.Location );
00115		return 0.3;
00116	}
00117	
00118	function bool ShouldRespawn(Actor Other)
00119	{
00120		return false;
00121	}
00122	
00123	static function string KillMessage( name damageType, pawn Other )
00124	{
00125		local string message;
00126		
00127		if (damageType == 'Exploded')
00128			message = Default.ExplodeMessage;
00129		else if ( damageType == 'Eradicated' )
00130			message = Default.ExplodeMessage;
00131		else if (damageType == 'Suicided')
00132			message = Default.SuicideMessage;
00133		else if ( damageType == 'Fell' )
00134			message = Default.FallMessage;
00135		else if ( damageType == 'Drowned' )
00136			message = Default.DrownedMessage;
00137		else if ( damageType == 'Burned' )
00138			message = Default.BurnedMessage;
00139		else if ( damageType == 'Corroded' )
00140			message = Default.CorrodedMessage;
00141		else if ( damageType == 'Mortared' )
00142			message = Default.MortarMessage;
00143		else
00144			message = Default.DeathVerb$Default.DeathTerm;
00145			
00146		return message;	
00147	}
00148	
00149	static function string CreatureKillMessage(name damageType, pawn Other)
00150	{
00151		local string message;
00152		
00153		if (damageType == 'exploded')
00154			message = Default.ExplodeMessage;
00155		else if ( damageType == 'Eradicated' )
00156			message = Default.ExplodeMessage;
00157		else if ( damageType == 'Burned' )
00158			message = Default.BurnedMessage;
00159		else if ( damageType == 'Corroded' )
00160			message = Default.CorrodedMessage;
00161		else if ( damageType == 'Hacked' )
00162			message = Default.HackedMessage;
00163		else
00164			message = Default.DeathVerb$Default.DeathTerm;
00165	
00166		return ( message$Default.DeathPrep );
00167	}
00168	
00169	static function string PlayerKillMessage( name damageType, PlayerReplicationInfo Other )
00170	{
00171		local string message;
00172		local float decision;
00173		
00174		decision = FRand();
00175	
00176		if ( decision < 0.2 )
00177			message = Default.MajorDeathMessage[Rand(3)];
00178		else
00179		{
00180			if ( DamageType == 'Decapitated' )
00181				message = Default.HeadLossMessage[Rand(2)];
00182			else 
00183				message = Default.DeathMessage[Rand(32)];
00184	
00185			if ( decision < 0.75 )
00186				message = Default.DeathModifier[Rand(5)]$message;
00187		}	
00188		
00189		return ( Default.DeathVerb$message$Default.DeathPrep );
00190	} 	
00191	
00192	function PlayTeleportEffect( actor Incoming, bool bOut, bool bSound)
00193	{
00194	 	local UTTeleportEffect PTE;
00195	
00196		if ( Incoming.bIsPawn && (Incoming.Mesh != None) )
00197		{
00198			if ( bSound )
00199			{
00200	 			PTE = Spawn(class'UTTeleportEffect',,, Incoming.Location, Incoming.Rotation);
00201	 			PTE.Initialize(Pawn(Incoming), bOut);
00202				Incoming.PlaySound(sound'Resp2A',, 10.0);
00203			}
00204		}
00205	}
00206	
00207	function BroadcastRegularDeathMessage(pawn Killer, pawn Other, name damageType)
00208	{
00209		if (damageType == 'RedeemerDeath')
00210		{
00211			if ( RedeemerClass == None )
00212				RedeemerClass = class<Weapon>(DynamicLoadObject("Botpack.Warheadlauncher", class'Class'));
00213			BroadcastLocalizedMessage(DeathMessageClass, 0, Killer.PlayerReplicationInfo, Other.PlayerReplicationInfo, RedeemerClass);
00214		}
00215		else if (damageType == 'Eradicated')
00216			BroadcastLocalizedMessage(class'EradicatedDeathMessage', 0, Killer.PlayerReplicationInfo, Other.PlayerReplicationInfo, None);
00217		else if ((damageType == 'RocketDeath') || (damageType == 'GrenadeDeath'))
00218			BroadcastLocalizedMessage(DeathMessageClass, 0, Killer.PlayerReplicationInfo, Other.PlayerReplicationInfo, class'UT_Eightball');
00219		else if (damageType == 'Gibbed')
00220			BroadcastLocalizedMessage(DeathMessageClass, 8, Killer.PlayerReplicationInfo, Other.PlayerReplicationInfo, None);
00221		else {
00222			if (Killer.Weapon != None)
00223				BroadcastLocalizedMessage(DeathMessageClass, 0, Killer.PlayerReplicationInfo, Other.PlayerReplicationInfo, Killer.Weapon.Class);
00224			else
00225				BroadcastLocalizedMessage(DeathMessageClass, 0, Killer.PlayerReplicationInfo, Other.PlayerReplicationInfo, None);
00226		}
00227	}
00228	
00229	//
00230	// Discard a player's inventory after he dies.
00231	//
00232	function DiscardInventory( Pawn Other )
00233	{
00234		local actor dropped;
00235		local inventory Inv, NextInv;
00236		local weapon weap;
00237		local float speed;
00238		local LadderInventory MainLadderInventory;
00239	
00240		if( Other.DropWhenKilled != None )
00241		{
00242			dropped = Spawn(Other.DropWhenKilled,,,Other.Location);
00243			Inv = Inventory(dropped);
00244			if ( Inv != None )
00245			{ 
00246				Inv.RespawnTime = 0.0; //don't respawn
00247				Inv.BecomePickup();		
00248			}
00249			if ( dropped != None )
00250			{
00251				dropped.RemoteRole = ROLE_DumbProxy;
00252				dropped.SetPhysics(PHYS_Falling);
00253				dropped.bCollideWorld = true;
00254				dropped.Velocity = Other.Velocity + VRand() * 280;
00255			}
00256			if ( Inv != None )
00257				Inv.GotoState('PickUp', 'Dropped');
00258		}					
00259		if( (Other.Weapon!=None) && (Other.Weapon.Class!=BaseMutator.MutatedDefaultWeapon()) 
00260			&& ((Other.Weapon.Ammotype == None) || (Other.Weapon.Ammotype.AmmoAmount > 0))
00261			&& Other.Weapon.bCanThrow )
00262		{
00263			speed = VSize(Other.Velocity);
00264			weap = Other.Weapon;
00265			if (speed != 0)
00266				weap.Velocity = Normal(Other.Velocity/speed + 0.5 * VRand()) * (speed + 280);
00267			else {
00268				weap.Velocity.X = 0;
00269				weap.Velocity.Y = 0;
00270				weap.Velocity.Z = 0;
00271			}
00272			Other.TossWeapon();
00273		}
00274		Other.Weapon = None;
00275		Other.SelectedItem = None;
00276	
00277		// Destroy the inventory list.
00278		Inv = Other.Inventory;
00279		while (Inv != None)
00280		{
00281			NextInv = Inv.Inventory;
00282			if (!Inv.IsA('LadderInventory'))
00283			{
00284				Inv.DropInventory();
00285				Inv.Destroy();
00286			} else
00287				MainLadderInventory = LadderInventory(Inv);
00288			Inv = NextInv;
00289		}
00290		if (MainLadderInventory != None)
00291		{
00292			Other.Inventory = MainLadderInventory;
00293			MainLadderInventory = None;
00294		}
00295	}
00296	
00297	function CalcEndStats()
00298	{
00299		local int i, j;
00300		local float FPH;
00301		local float CurrentSeconds, CurrentMinutes;
00302	
00303		for (i=0; i<3; i++)
00304		{
00305			BestPlayers[i] = EndStatsClass.Default.BestPlayers[i];
00306			BestFPHs[i] = EndStatsClass.Default.BestFPHs[i];
00307			BestRecordDate[i] = EndStatsClass.Default.BestRecordDate[i];
00308		}
00309	
00310		Log("!!!!!!!!!!!!!!! CALC END STATS");
00311		for (i=0; i<32; i++)
00312		{
00313			if (GameReplicationInfo.PRIArray[i] != None)
00314			{
00315				TotalFrags += GameReplicationInfo.PRIArray[i].Score;
00316				TotalDeaths += GameReplicationInfo.PRIArray[i].Deaths;
00317				CurrentSeconds = Level.TimeSeconds - GameReplicationInfo.PRIArray[i].StartTime;
00318				CurrentMinutes = CurrentSeconds / 60;
00319				FPH = GameReplicationInfo.PRIArray[i].Score / (CurrentMinutes / 60);
00320				for (j=2; j>=0; j--)
00321				{
00322					if (FPH > BestFPHs[j])
00323					{
00324						EmptyBestSlot(j);
00325						BestFPHs[j] = FPH;
00326						BestPlayers[j] = GameReplicationInfo.PRIArray[i].PlayerName;
00327						GetTimeStamp(BestRecordDate[j]);
00328						j = -1; // break.
00329					}
00330				}
00331			}
00332		}
00333	
00334		for (i=0; i<3; i++)
00335		{
00336			EndStatsClass.Default.BestPlayers[i] = BestPlayers[i];
00337			EndStatsClass.Default.BestFPHs[i] = BestFPHs[i];
00338			EndStatsClass.Default.BestRecordDate[i] = BestRecordDate[i];
00339		}
00340		EndStatsClass.Default.TotalFrags = TotalFrags;
00341		EndStatsClass.Default.TotalDeaths = TotalDeaths;
00342		EndStatsClass.Default.TotalGames++;
00343		EndStatsClass.Static.StaticSaveConfig();
00344	}
00345	
00346	function EmptyBestSlot(int Slot)
00347	{
00348		if (Slot == 2)
00349		{
00350			BestFPHs[0] = BestFPHs[1];
00351			BestPlayers[0] = BestPlayers[1];
00352			BestRecordDate[0] = BestRecordDate[1];
00353	
00354			BestFPHs[1] = BestFPHs[2];
00355			BestPlayers[1] = BestPlayers[2];
00356			BestRecordDate[1] = BestRecordDate[2];
00357		} else if (Slot == 1) {
00358			BestFPHs[0] = BestFPHs[1];
00359			BestPlayers[0] = BestPlayers[1];
00360			BestRecordDate[0] = BestRecordDate[1];
00361		}
00362	}
00363	
00364	function GetTimeStamp(out string AbsoluteTime)
00365	{
00366		if (Level.Month < 10)
00367			AbsoluteTime = "0"$Level.Month;
00368		else
00369			AbsoluteTime = string(Level.Month);
00370	
00371		if (Level.Day < 10)
00372			AbsoluteTime = AbsoluteTime$"/0"$Level.Day;
00373		else
00374			AbsoluteTime = AbsoluteTime$"/"$Level.Day;
00375	
00376		AbsoluteTime = AbsoluteTime$"/"$Level.Year;
00377	
00378		if (Level.Hour < 10)
00379			AbsoluteTime = AbsoluteTime$" 0"$Level.Hour;
00380		else
00381			AbsoluteTime = AbsoluteTime$" "$Level.Hour;
00382	
00383		if (Level.Minute < 10)
00384			AbsoluteTime = AbsoluteTime$":0"$Level.Minute;
00385		else
00386			AbsoluteTime = AbsoluteTime$":"$Level.Minute;
00387	
00388		if (Level.Second < 10)
00389			AbsoluteTime = AbsoluteTime$":0"$Level.Second;
00390		else
00391			AbsoluteTime = AbsoluteTime$":"$Level.Second;
00392	}
00393	
00394	defaultproperties
00395	{
00396	     DeathMessage(0)="killed"
00397	     DeathMessage(1)="ruled"
00398	     DeathMessage(2)="smoked"
00399	     DeathMessage(3)="slaughtered"
00400	     DeathMessage(4)="annihilated"
00401	     DeathMessage(5)="put down"
00402	     DeathMessage(6)="splooged"
00403	     DeathMessage(7)="perforated"
00404	     DeathMessage(8)="shredded"
00405	     DeathMessage(9)="destroyed"
00406	     DeathMessage(10)="whacked"
00407	     DeathMessage(11)="canned"
00408	     DeathMessage(12)="busted"
00409	     DeathMessage(13)="creamed"
00410	     DeathMessage(14)="smeared"
00411	     DeathMessage(15)="shut out"
00412	     DeathMessage(16)="beaten down"
00413	     DeathMessage(17)="smacked down"
00414	     DeathMessage(18)="pureed"
00415	     DeathMessage(19)="sliced"
00416	     DeathMessage(20)="diced"
00417	     DeathMessage(21)="ripped"
00418	     DeathMessage(22)="blasted"
00419	     DeathMessage(23)="torn up"
00420	     DeathMessage(24)="spanked"
00421	     DeathMessage(25)="eviscerated"
00422	     DeathMessage(26)="neutered"
00423	     DeathMessage(27)="whipped"
00424	     DeathMessage(28)="shafted"
00425	     DeathMessage(29)="trashed"
00426	     DeathMessage(30)="smashed"
00427	     DeathMessage(31)="trounced"
00428	     DeathModifier(0)="thoroughly "
00429	     DeathModifier(1)="completely "
00430	     DeathModifier(2)="absolutely "
00431	     DeathModifier(3)="totally "
00432	     DeathModifier(4)="utterly "
00433	     MajorDeathMessage(0)="ripped a new one"
00434	     MajorDeathMessage(1)="messed up real bad"
00435	     MajorDeathMessage(2)="given a new definition of pain"
00436	     HeadLossMessage(0)="decapitated"
00437	     HeadLossMessage(1)="beheaded"
00438	     DeathVerb=" was "
00439	     DeathPrep=" by "
00440	     DeathTerm="killed"
00441	     ExplodeMessage=" was blown up."
00442	     SuicideMessage=" had a sudden heart attack."
00443	     FallMessage=" left a small crater."
00444	     DrownedMessage=" forgot to come up for air."
00445	     BurnedMessage=" was incinerated."
00446	     CorrodedMessage=" was slimed."
00447	     HackedMessage=" was hacked."
00448	     MortarMessage=" was blown up by a mortar."
00449	     MaleSuicideMessage=" killed his own dumb self."
00450	     FemaleSuicideMessage=" killed her own dumb self."
00451	     EndStatsClass=Class'Botpack.EndStats'
00452	     DefaultPlayerClass=Class'Botpack.TMale1'
00453	     DefaultWeapon=Class'Botpack.ImpactHammer'
00454	     WaterZoneType=Class'UnrealShare.WaterZone'
00455	     StatLogClass=Class'Botpack.UTStatLogFile'
00456	}

End Source Code