XIIIMP
Class XIIIMPBombGame

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

class XIIIMPBombGame
extends XIIIMP.XIIIMPTeamGameInfo

//----------------------------------------------------------- // //-----------------------------------------------------------
Variables
 array Objectives

States
MatchInProgress

Function Summary
 void AddBot(int BotID)
     
//_____________________________________________________________________________
 void CheckScore(PlayerReplicationInfo Scorer)
     
//_____________________________________________________________________________
 void GivePointToTheDefender()
     
//_____________________________________________________________________________
 void InitObjectives()
     
//_____________________________________________________________________________
 void ReStartMatch()
     
//_____________________________________________________________________________
// ELR ::TODO:: Handle the team/class change between each match there ?
 void ScoreKill(Controller Killer, Controller Other)
     
//_____________________________________________________________________________
 void ScoreObjective(PlayerReplicationInfo Scorer, Int Score)
     
//_____________________________________________________________________________
 void StartMatch()
     
//_____________________________________________________________________________


State MatchInProgress Function Summary



Source Code


00001	//-----------------------------------------------------------
00002	//
00003	//-----------------------------------------------------------
00004	class XIIIMPBombGame extends XIIIMPTeamGameInfo;
00005	
00006	//var class<XIIIPlayerPawn> DefenderClasses[5];
00007	//var string DefenderClassesName[5];             // dynamic load of pawn classes
00008	var array<MPBombingBase> Objectives;
00009	
00010	//const NBCLASSES=5;
00011	
00012	//_____________________________________________________________________________
00013	function ScoreKill(Controller Killer, Controller Other)
00014	{
00015	    if (killer == Other)
00016	    { // Suicide or killed by something and not someone
00017	      Other.PlayerReplicationInfo.Score -= 1;
00018	      if ( PlayerController(Other) != none )
00019	        PlayerController(Other).PlayerStat.StatSuicides ++;
00020	    }
00021	    else if ( killer.PlayerReplicationInfo != None )
00022	    {
00023	      if ( Killer.PlayerReplicationInfo.Team != Other.PlayerReplicationInfo.Team )
00024	      {
00025	        if ( PlayerController(Killer) != none)
00026	          PlayerController(killer).PlayerStat.StatKills ++;
00027	        if ( PlayerController(Other) != none)
00028	          PlayerController(Other).PlayerStat.StatDeaths ++;
00029	        killer.PlayerReplicationInfo.Score += 1;
00030	        XIIIPlayerReplicationInfo(killer.PlayerReplicationInfo).MyDeathScore += 1;
00031	      }
00032	      else
00033	      {
00034	        if ( PlayerController(Killer) != none)
00035	          PlayerController(killer).PlayerStat.StatKills --;
00036	        killer.PlayerReplicationInfo.Score -= 1;
00037	      }
00038	    }
00039	
00040	    if ( GameRulesModifiers != None )
00041	      GameRulesModifiers.ScoreKill(Killer, Other);
00042	
00043	    CheckScore(Killer.PlayerReplicationInfo);
00044	}
00045	//_____________________________________________________________________________
00046	event InitGame( string Options, out string Error )
00047	{
00048	    Super.InitGame(Options, Error);
00049	    MaxTime = 600;
00050	    WinningScore = 1;
00051	}
00052	
00053	//_____________________________________________________________________________
00054	function bool ChangeClass(Controller Other, class<Pawn> InClass)
00055	{
00056		if ( Other.Pawn.Weapon!=none )
00057		{
00058			Other.Pawn.Weapon.Destroy( );
00059			Other.Pawn.Weapon = none;
00060		}
00061	
00062	    Other.PawnClass = InClass;
00063	    return true;
00064	}
00065	
00066	//_____________________________________________________________________________
00067	function GivePointToTheDefender()
00068	{
00069	    local controller C;
00070	
00071	    for (C=Level.ControllerList; C!=None; C=C.NextController )
00072	    {
00073	        if( C.PlayerReplicationInfo.Team.TeamIndex == 1 )
00074	        {
00075	            if( C.PlayerReplicationInfo.Team.Score == 0 )
00076	            {
00077	                C.PlayerReplicationInfo.Team.Score = 1.0;
00078	                break;
00079	            }
00080	        }
00081	    }
00082	}
00083	
00084	//_____________________________________________________________________________
00085	State MatchInProgress
00086	{
00087	    event BeginState()
00088	    {
00089	      bGameEnded = false;
00090	    }
00091	
00092	    event timer()
00093	    {
00094	      Super( XIIIGameInfo ).Timer();
00095	      if ( !bOverTime && (MaxTime > 0) )
00096	      {
00097	        GameReplicationInfo.bStopCountDown = false;
00098	        RemainingTime --;
00099	        XIIIGameReplicationInfo(GameReplicationInfo).XIIIRemainingTime = RemainingTime;
00100	        if ( RemainingTime % 60 == 0 )
00101	          GameReplicationInfo.RemainingMinute = RemainingTime;
00102	        if ( RemainingTime <= 0 )
00103	        {
00104	            PlayMenu(hTimeLimit);
00105	            GivePointToTheDefender();
00106	            EndGame(FindWinner(),"TimeLimit");
00107	        }
00108	        if ( RemainingTime == 60 )
00109	           PlayMenu(hLastMinute);
00110	      }
00111	    }
00112	}
00113	
00114	//_____________________________________________________________________________
00115	function StartMatch()
00116	{
00117	    local controller C;
00118	    local int Loop;
00119	
00120	
00121	    for (C=Level.ControllerList; C!=None; C=C.NextController )
00122	    {
00123	        if( SabotageBotController(C) != none )
00124	        {
00125	            for( Loop = 0 ; Loop < 3 ; Loop++ )
00126	            {
00127	                SabotageBotController(C).BombSpotStatus[ Loop ] = 1;
00128	            }
00129	        }
00130	    }
00131	
00132	    super.StartMatch();
00133	}
00134	
00135	//_____________________________________________________________________________
00136	function AddBot(int BotID)
00137	{
00138	
00139	    local SabotageBotController Bot;
00140	
00141	    Bot = spawn( class'SabotageBotController');
00142	
00143	    if ( BotClasses[ BotID ] == none )
00144	      BotClasses[ BotID ] = class<XIIIPlayerPawn>(DynamicLoadObject(BotClassesName[ BotID ], class'class'));
00145	
00146	
00147	    Bot.PawnClass = BotClasses[ BotID ];
00148	    Bot.PlayerReplicationInfo.PlayerID = CurrentID++;
00149	    Bot.bIsBot = true;
00150	
00151	    Bot.TeamID = Level.BotTeam[BotID];
00152	    Bot.Skill = level.BotLevel[BotID];
00153	    ChangeTeam(Bot,Level.BotTeam[BotID]);
00154	}
00155	
00156	//_____________________________________________________________________________
00157	function InitObjectives()
00158	{
00159	    Local MPBombingBase OB;
00160	    Local int i;
00161	
00162	    //Log("BOMBING-] Init Objectives");
00163	    i = 0;
00164	    foreach allactors(class'MPBombingBase', OB)
00165	    {
00166	      //Log("       -]   found :"@OB);
00167	      Objectives[i] = OB; // auto incrment array
00168	      i++;
00169	    }
00170	}
00171	
00172	
00173	//_____________________________________________________________________________
00174	function ScoreObjective(PlayerReplicationInfo Scorer, Int Score)
00175	{
00176	    if ( Scorer != None )
00177	    {
00178	      Scorer.Score += 10;
00179	    }
00180	    if ( GameRulesModifiers != None )
00181	      GameRulesModifiers.ScoreObjective(Scorer,Score);
00182	
00183	    CheckScore(Scorer);
00184	}
00185	
00186	//_____________________________________________________________________________
00187	function CheckScore(PlayerReplicationInfo Scorer)
00188	{
00189	    Local int i, j;
00190	    Local bool bWon;
00191	
00192	    log("*** CheckScore ***");
00193	
00194	    if( RemainingTime <= 0 )
00195	        return;
00196	
00197	    if ( (GameRulesModifiers != None) && GameRulesModifiers.CheckScore(Scorer) )
00198	      return;
00199	
00200	    if ( Objectives.Length == 0 )
00201	      InitObjectives();
00202	
00203	    // check if all objectives are on the same side
00204	    //log( "BOMBING-] CheckObjectives");
00205	    bWon = true;
00206	    for (i=0; i<Objectives.Length; i++)
00207	    {
00208	      //log( "       -] testing Objective"@Objectives[i]@"Team:"@Objectives[i].CurrentTeam);
00209	      if ( Objectives[i].CurrentTeam != 0 )
00210	        bWon = false;
00211	    }
00212	
00213	    //log( "BOMBING-] Game won ? "$bWon@Scorer.Team.Score);
00214	    if ( bWon )
00215	    {
00216	      Scorer.Team.Score = 1.0;
00217	      EndGame(Scorer, "Completed");
00218	    }
00219	}
00220	
00221	//_____________________________________________________________________________
00222	// ELR ::TODO:: Handle the team/class change between each match there ?
00223	function ReStartMatch()
00224	{
00225	    local controller C;
00226	
00227	    Log("MP-] -- RESTART MATCH --, MaxTime="$MaxTime@"RemainingTime="$XIIIGameReplicationInfo(GameReplicationInfo).XIIIRemainingTime);
00228	    for (C=Level.ControllerList; C!=None; C=C.NextController )
00229	      RestartPlayer(C);
00230	
00231	    StartMatch();
00232	}
00233	
00234	
00235	
00236	defaultproperties
00237	{
00238	     ScoreBoardType="XIIIMP.XIIIMPSabotageScoreBoard"
00239	     HUDType="XIIIMP.XIIIBombHud"
00240	     MapPrefix="SB"
00241	     GameName="Sabotage"
00242	     MutatorClass="XIIIMP.MPBombMutator"
00243	}

End Source Code