XIIIMP
Class XIIIMPTeamGameInfo

source: C:\XIII\XIIIMP\Classes\XIIIMPTeamGameInfo.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Info
         |
         +--Engine.GameInfo
            |
            +--XIII.XIIIGameInfo
               |
               +--XIIIMP.XIIIMPGameInfo
                  |
                  +--XIIIMP.XIIIMPTeamGameInfo
Direct Known Subclasses:XIIIMPBombGame, XIIIMPCTFGameInfo

class XIIIMPTeamGameInfo
extends XIIIMP.XIIIMPGameInfo

//----------------------------------------------------------- // XIIITeamGameInfo || For Team DeathMatch GamePlay //-----------------------------------------------------------
Variables
 string TeamName[2]


Function Summary
 void AddBot(int BotID)
     
//_____________________________________________________________________________
 bool ChangeTeam(Controller Other, int N)
     
//_____________________________________________________________________________
// Return whether a team change is allowed.
 bool CheckEndGame(PlayerReplicationInfo Winner, string Reason)
     
//_____________________________________________________________________________
//
 void CheckScore(PlayerReplicationInfo Scorer)
     
//_____________________________________________________________________________
//
 NavigationPoint FindPlayerStart(Controller Player, optional byte, optional string)
     
//_____________________________________________________________________________
 byte PickTeam(byte Current)
     
//_____________________________________________________________________________
// Return a picked team number if none was specified
 void PostBeginPlay()
     
//_____________________________________________________________________________
 float RatePlayerStart(NavigationPoint N, byte Team, Controller Player)
     
//_____________________________________________________________________________
// ELR re-written from UW
 void ScoreKill(Controller Killer, Controller Other)
     
//_____________________________________________________________________________
 void StartMatch()
     
//_____________________________________________________________________________



Source Code


00001	//-----------------------------------------------------------
00002	// XIIITeamGameInfo || For Team DeathMatch GamePlay
00003	//-----------------------------------------------------------
00004	class XIIIMPTeamGameInfo extends XIIIMPGameInfo;
00005	
00006	var localized string TeamName[2];
00007	
00008	//_____________________________________________________________________________
00009	function AddBot(int BotID)
00010	{
00011	    local TeamBotController Bot;
00012	
00013	    Bot = spawn( class'TeamBotController');
00014	
00015	    if ( BotClasses[ BotID ] == none )
00016	      BotClasses[ BotID ] = class<XIIIPlayerPawn>(DynamicLoadObject(BotClassesName[ BotID ], class'class'));
00017	
00018	
00019	    Bot.PawnClass = BotClasses[ BotID ];
00020	    Bot.PlayerReplicationInfo.PlayerID = CurrentID++;
00021	    Bot.bIsBot = true;
00022	
00023	    log(bot@"level"@level.BotLevel[BotID]@"--> Team"@Level.BotTeam[BotID]);
00024	
00025	    Bot.TeamID = Level.BotTeam[BotID];
00026	    Bot.Skill = level.BotLevel[BotID];
00027	
00028	    Bot.GRI = GameReplicationInfo;
00029	    ChangeTeam(Bot,Level.BotTeam[BotID]);
00030	}
00031	
00032	//_____________________________________________________________________________
00033	
00034	function BroadcastDeathMessage(Controller Killer, Controller Other, class<DamageType> damageType)
00035	{
00036	    if( Other.PlayerReplicationInfo.Team.TeamIndex == 1 )
00037	    {
00038	        if ( (Killer == Other) || (Killer == None) )
00039	          BroadcastLocalizedMessage(DeathMessageClass, 1, None, Other.PlayerReplicationInfo, damageType);
00040	        else
00041	          BroadcastLocalizedMessage(DeathMessageClass, 0, Killer.PlayerReplicationInfo, Other.PlayerReplicationInfo, damageType);
00042	    }
00043	    else
00044	    {
00045	        if ( (Killer == Other) || (Killer == None) )
00046	          BroadcastLocalizedMessage(class'XIIIMP.XIIIMPRedDeathMessage', 1, None, Other.PlayerReplicationInfo, damageType);
00047	        else
00048	          BroadcastLocalizedMessage(class'XIIIMP.XIIIMPRedDeathMessage', 0, Killer.PlayerReplicationInfo, Other.PlayerReplicationInfo, damageType);
00049	    }
00050	}
00051	
00052	//_____________________________________________________________________________
00053	
00054	function StartMatch()
00055	{
00056	    super.StartMatch();
00057	
00058	    Level.Game.GameReplicationInfo.Teams[0].score = 0;
00059	    Level.Game.GameReplicationInfo.Teams[1].score = 0;
00060	}
00061	
00062	//_____________________________________________________________________________
00063	function PostBeginPlay()
00064	{
00065	    local int i;
00066	
00067	    for (i=0; i<2; i++)
00068	    {
00069	      if (Level.Game.GameReplicationInfo.Teams[i] == none )
00070	        Level.Game.GameReplicationInfo.Teams[i] = spawn(class'Teaminfo');
00071	      Level.Game.GameReplicationInfo.Teams[i].TeamName=TeamName[i];
00072	      Level.Game.GameReplicationInfo.Teams[i].TeamIndex=i;
00073	    }
00074	}
00075	
00076	//_____________________________________________________________________________
00077	function int ReduceDamage( int Damage, pawn injured, pawn instigatedBy, vector HitLocation, vector Momentum, class<DamageType> DamageType )
00078	{
00079	    local int OriginalDamage;
00080	//    local armor FirstArmor;
00081	    local inventory I;
00082	    local int ArmorDamage;
00083	
00084	    OriginalDamage = Damage;
00085	
00086	    if (
00087	      (Injured.Controller.PlayerReplicationInfo.Team == instigatedBy.Controller.PlayerReplicationInfo.Team)
00088	      && (Injured != InstigatedBy) )
00089	      Damage *= fFriendlyFireScale;
00090	
00091	    if( injured.PhysicsVolume.bNeutralZone )
00092	      Damage = 0;
00093	    else if ( injured.InGodMode() ) // God mode
00094	      Damage = 0;
00095	    else if ( (injured.Inventory != None) && (damage > 0) && DamageType.default.bArmorStops ) //then check if carrying armor
00096	    {
00097	      if ( Injured.Vest != none )
00098	        Damage = Injured.Vest.ArmorAbsorbDamage(Damage, DamageType, HitLocation);
00099	      if ( Injured.Helm != none )
00100	        Damage = Injured.Helm.ArmorAbsorbDamage(Damage, DamageType, HitLocation);
00101	    }
00102	
00103	    if ( GameRulesModifiers != None )
00104	      return GameRulesModifiers.NetDamage( OriginalDamage, Damage,injured,instigatedBy,HitLocation,Momentum,DamageType );
00105	
00106	    return Damage;
00107	}
00108	
00109	//_____________________________________________________________________________
00110	// Return a picked team number if none was specified
00111	function byte PickTeam(byte Current)
00112	{
00113	    if (Current > 1)
00114	      return (NumPlayers % 2);
00115	}
00116	
00117	//_____________________________________________________________________________
00118	// Return whether a team change is allowed.
00119	function bool ChangeTeam(Controller Other, int N)
00120	{
00121	    Log("MP-] ChangeTeam call for"@other@"to be in team"@N);
00122	    return Level.Game.GameReplicationInfo.Teams[N].AddToTeam(Other);
00123	}
00124	
00125	//_____________________________________________________________________________
00126	function ScoreKill(Controller Killer, Controller Other)
00127	{
00128	    if (killer == Other)
00129	    { // Suicide or killed by something and not someone
00130	      Other.PlayerReplicationInfo.Score -= 1;
00131	      if ( PlayerController(Other) != none )
00132	        PlayerController(Other).PlayerStat.StatSuicides ++;
00133	    }
00134	    else if ( killer.PlayerReplicationInfo != None )
00135	    {
00136	      if ( Killer.PlayerReplicationInfo.Team != Other.PlayerReplicationInfo.Team )
00137	      {
00138	        if ( PlayerController(Killer) != none)
00139	          PlayerController(killer).PlayerStat.StatKills ++;
00140	        if ( PlayerController(Other) != none)
00141	          PlayerController(Other).PlayerStat.StatDeaths ++;
00142	        killer.PlayerReplicationInfo.Score += 1;
00143	        Killer.PlayerReplicationInfo.Team.Score += 1;
00144	        XIIIPlayerReplicationInfo(killer.PlayerReplicationInfo).MyDeathScore += 1;
00145	      }
00146	      else
00147	      {
00148	        if ( PlayerController(Killer) != none)
00149	          PlayerController(killer).PlayerStat.StatKills --;
00150	        killer.PlayerReplicationInfo.Score -= 1;
00151	        Killer.PlayerReplicationInfo.Team.Score -= 1;
00152	      }
00153	    }
00154	
00155	    if ( GameRulesModifiers != None )
00156	      GameRulesModifiers.ScoreKill(Killer, Other);
00157	
00158	    CheckScore(Killer.PlayerReplicationInfo);
00159	}
00160	
00161	//_____________________________________________________________________________
00162	//
00163	function CheckScore(PlayerReplicationInfo Scorer)
00164	{
00165	    if ( (GameRulesModifiers != None) && GameRulesModifiers.CheckScore(Scorer) )
00166	      return;
00167	
00168	    if ( (Scorer != None)
00169	      && (bOverTime || (GameReplicationInfo.GoalScore > 0))
00170	      && (Scorer.Team.Score >= GameReplicationInfo.GoalScore) )
00171	      {
00172	          PlayMenu(hFragLimit);
00173	          EndGame(Scorer,"FragLimit");
00174	      }
00175	
00176	    if ( (Scorer != None)
00177	      && (bOverTime || (GameReplicationInfo.GoalScore > 0))
00178	      && (Scorer.Team.Score == GameReplicationInfo.GoalScore-1) )
00179	      PlayMenu(hLastFragLimit);
00180	}
00181	
00182	//_____________________________________________________________________________
00183	//
00184	function bool CheckEndGame(PlayerReplicationInfo Winner, string Reason)
00185	{
00186	    local Controller P;
00187	    local PlayerController Player;
00188	    local XIIIGameReplicationInfo TGRI;
00189	
00190	    if ( (GameRulesModifiers != None) && !GameRulesModifiers.CheckEndGame(Winner, Reason) )
00191	      return false;
00192	
00193	    // check for tie
00194	    if ( Winner != none )
00195	      for ( P=Level.ControllerList; P!=None; P=P.nextController )
00196	        if ( P.bIsPlayer && (Winner.Team != P.PlayerReplicationInfo.Team) && (P.PlayerReplicationInfo.Team.Score == Winner.Team.Score) )
00197	        {
00198	          BroadcastLocalizedMessage( GameMessageClass, 0 );
00199	          return false;
00200	        }
00201	
00202	    EndTime = Level.TimeSeconds + 3.0;
00203	    TGRI = XIIIGameReplicationInfo(GameReplicationInfo);
00204	    SetGameEndMessage(TGRI, reason, winner);
00205	
00206	    log( "MP-] Game ended at "$EndTime);
00207	//    GameReplicationInfo.bStopCountDown = true;
00208	
00209	    XIIIGameReplicationInfo(GameReplicationInfo).iGameState = 3;
00210	    gotoState('MatchOver');
00211	
00212	    for ( P=Level.ControllerList; P!=None; P=P.nextController )
00213	    {
00214	      P.GotoState('GameEnded');
00215	      Player = PlayerController(P);
00216	      if ( Player != None )
00217	      {
00218	        //PlayWinMessage(Player, (Player.PlayerReplicationInfo == Winner));
00219	        Player.ClientSetBehindView(true);
00220	        if ( (Controller(Winner.Owner).Pawn != None) && !XIIIPawn(Controller(Winner.Owner).Pawn).IsDead() )
00221	          Player.SetViewTarget(Controller(Winner.Owner).Pawn);
00222	        Player.ClientGameEnded();
00223	      }
00224	    }
00225	    return true;
00226	}
00227	
00228	//_____________________________________________________________________________
00229	function NavigationPoint FindPlayerStart( Controller Player, optional byte InTeam, optional string incomingName )
00230	{
00231	    local NavigationPoint N, BestStart;
00232	    local Teleporter Tel;
00233	    local float BestRating, NewRating;
00234	    local byte Team;
00235	
00236	//    Log("XIIIMPTeamGameInfo FindPlayerStart for"@Player@"InTeam"@InTeam);
00237	    // always pick StartSpot at start of match
00238	    if( Level.bLonePlayer == true )
00239	    {
00240	        if ( (Player != None) && (Player.StartSpot != None)
00241	        && (bWaitingToStartMatch || ((Player.PlayerReplicationInfo != None) && Player.PlayerReplicationInfo.bWaitingPlayer))  )
00242	        {
00243	            return Player.StartSpot;
00244	        }
00245	    }
00246	
00247	    if ( GameRulesModifiers != None )
00248	    {
00249	      N = GameRulesModifiers.FindPlayerStart(Player,InTeam,incomingName);
00250	      if ( N != None )
00251	        return N;
00252	    }
00253	
00254	    // if incoming start is specified, then just use it
00255	    if( incomingName!="" )
00256	      foreach AllActors( class 'Teleporter', Tel )
00257	        if( string(Tel.Tag)~=incomingName )
00258	          return Tel;
00259	
00260	    // use InTeam if player doesn't have a team yet
00261	    if ( (Player != None) && (Player.PlayerReplicationInfo != None) )
00262	    {
00263	      if ( Player.PlayerReplicationInfo.Team != None )
00264	        Team = Player.PlayerReplicationInfo.Team.TeamIndex;
00265	      else
00266	        Team = 0;
00267	    }
00268	    else
00269	      Team = InTeam;
00270	
00271	    BestRating = 0;
00272	    for ( N=Level.NavigationPointList; N!=None; N=N.NextNavigationPoint )
00273	    {
00274	      NewRating = RatePlayerStart(N,InTeam,Player);
00275	      if ( NewRating > BestRating )
00276	      {
00277	        BestRating = NewRating;
00278	        BestStart = N;
00279	      }
00280	    }
00281	
00282	    if ( BestStart == None )
00283	    {
00284	      log("Warning - PATHS NOT DEFINED or NO PLAYERSTART");
00285	      foreach AllActors( class 'NavigationPoint', N )
00286	      {
00287	        NewRating = RatePlayerStart(N,InTeam,Player);
00288	        if ( NewRating > BestRating )
00289	        {
00290	          BestRating = NewRating;
00291	          BestStart = N;
00292	        }
00293	      }
00294	    }
00295	
00296	    return BestStart;
00297	}
00298	
00299	//_____________________________________________________________________________
00300	// ELR re-written from UW
00301	function float RatePlayerStart(NavigationPoint N, byte Team, Controller Player)
00302	{
00303	    local PlayerStart P;
00304	    local int Rate;
00305	
00306	    P = PlayerStart(N);
00307	    if ( P == None )
00308	      return 0;
00309	
00310	    if (Team != P.TeamNumber)
00311	      Rate = 1;
00312	    else
00313	      Rate = Super.RatePlayerStart(N,Team,Player);
00314	//    Log("Rating PlayerStart"@P@"(Team"@P.TeamNumber@") for"@Player@"Team"@Team@"Rate="$Rate);
00315	    return Rate;
00316	}
00317	
00318	
00319	
00320	defaultproperties
00321	{
00322	     TeamName(0)="The Red ones"
00323	     TeamName(1)="The Blue ones"
00324	     bTeamGame=True
00325	     ScoreBoardType="XIIIMP.XIIIMPTeamScoreBoard"
00326	     HUDType="XIIIMP.XIIITeamHUD"
00327	     GameName="Team DeathMatch"
00328	     DeathMessageClass=Class'XIIIMP.XIIIMPBlueDeathMessage'
00329	     MutatorClass="XIIIMP.XIIIMPTeamMutator"
00330	}

End Source Code