## XIIIMP
Class XIIIMPPlayerController

source: C:\XIII\XIIIMP\Classes\XIIIMPPlayerController.uc

    Core.Object
       |
       +--Engine.Actor
          |
          +--Engine.Controller
             |
             +--Engine.PlayerController
                |
                +--XIII.XIIIPlayerController
                   |
                   +--XIIIMP.XIIIMPPlayerController

Direct Known Subclasses:XIIIAdmin

class XIIIMPPlayerController
extends XIII.XIIIPlayerController

    //-----------------------------------------------------------
    //
    //-----------------------------------------------------------

Variables
`int` | `TimeBeforeRespawn`
`bool` | `bImmortal`
`int` | `matchTimestamp`
`int` | `once`
`XboxLiveManager` | `xboxlive`

States
Dead, GameEnded

Function Summary
`void` | `AltFire(optional float)`
    //_____________________________________________________________________________
`void` | `ChangeClass(int N)`
`void` | `ChangeTeam(int N)`
    //_____________________________________________________________________________
`void` | `ClientGameEnded()`
    //_____________________________________________________________________________
`void` | `Fire(optional float)`
    //_____________________________________________________________________________
`int` | `GetIntOption(string Options, string ParseString, int CurrentValue)`
`void` | `GetKeyValue(string Pair, out string, out string)`
    // break up a key=value pair into its key and value.
`void` | `Grab()`
    //_____________________________________________________________________________
`bool` | `GrabOption(out string, out string)`
    //_____________________________________________________________________________
    // Grab the next option from a string.
`string` | `ParseOption(string Options, string InKey)`
    // Find an option in the options string and return it.
`void` | `StatUpdate()`
    //_____________________________________________________________________________
    // Called to update stats on xboxlive
`void` | `SwitchClass(int N)`
    //_____________________________________________________________________________

State Dead Function Summary
`void` | `PlayerMove(float DeltaTime)`
`void` | `Fire(optional float)`
`void` | `AltFire(optional float)`
`void` | `ServerRestartPlayer()`

State GameEnded Function Summary
`void` | `ProcessMove(float DeltaTime, vector newAccel, eDoubleClickDir DoubleClickMove, rotator DeltaRot)`
`void` | `PlayerMove(float DeltaTime)`
`void` | `AltFire(optional float)`

Source Code

    00001	//-----------------------------------------------------------
    00002	//
    00003	//-----------------------------------------------------------
    00004	class XIIIMPPlayerController extends XIIIPlayerController;
    00005
    00006	var bool bImmortal;
    00007	var int matchTimestamp;
    00008	var XboxLiveManager xboxlive;
    00009	var int TimeBeforeRespawn;
    00010	var int once;
    00011
    00012	//_____________________________________________________________________________
    00013	replication
    00014	{
    00015		reliable if( Role<ROLE_Authority )
    00016			ChangeClass;
    00017	}
    00018
    00019	//_____________________________________________________________________________
    00020	exec function SwitchClass(int N)
    00021	{
    00022	    ChangeClass(N);
    00023	}
    00024
    00025	function ChangeClass( int N )
    00026	{
    00027	    local class<Pawn> InClass;
    00028
    00029	    InClass = class<Pawn>(DynamicLoadObject(class'MPClassList'.default.ClassListInfo[N].ClassName, class'Class'));
    00030	    if ( InClass != PawnClass )
    00031	    {
    00032	      if ( Level.Game.ChangeClass(self, InClass) )
    00033	        Pawn.Died( self, class'DTSuicided', Pawn.Location );
    00034	    }
    00035	}
    00036
    00037	//_____________________________________________________________________________
    00038	function ChangeTeam( int N )
    00039	{
    00040	    local TeamInfo OldTeam;
    00041
    00042	    OldTeam = PlayerReplicationInfo.Team;
    00043	    Level.Game.ChangeTeam(self, N);
    00044	    if ( Level.Game.bTeamGame && (PlayerReplicationInfo.Team != OldTeam) )
    00045	      Pawn.Died( self, class'DTSuicided', Pawn.Location );
    00046	}
    00047
    00048	//_____________________________________________________________________________
    00049	event PlayerTick( float DeltaTime )
    00050	{
    00051	  local Controller C;
    00052	  local Pawn P;
    00053	  local PlayerReplicationInfo PRI;
    00054	  //local PlayerController plr[16];
    00055	  //local PlayerReplicationInfo plr[16];
    00056	  local Pawn plr[16];
    00057	  local int counter,q;
    00058	    super.PlayerTick(DeltaTime);
    00059
    00060	  // SouthEnd - Test if the server went down or we got kicked. If so, go to the ingame menu which will take over automatically...
    00061	  if ( Level.GetPlateForme() == 2)
    00062	  {
    00063	    if ( xboxlive == none )
    00064	      xboxlive = New Class'XboxLiveManager';
    00065	    if (!bMenuIsActive && (xboxlive.IsServerDown() || xboxlive.IsKicked() || xboxlive.IsLoggedInTwice() || (xboxlive.IsLoggedIn(xboxLive.GetCurrentUser()) && !xboxlive.IsNetCableIn())))
    00066	    {
    00067	        ShowMenu();
    00068	    }
    00069
    00070	    // Check and update listeners (only for xbox live, only server)
    00071	    if (xboxlive.IsHost())
    00072	    {
    00073	      once--;
    00074	      if (xboxlive.IsLoggedIn(xboxLive.GetCurrentUser()) && once<=0)
    00075	      {
    00076	        once = 100;
    00077	        xboxlive.UpdateServerListeners();
    00078	      }
    00079	    }
    00080	  }
    00081	}
    00082
    00083	//_____________________________________________________________________________
    00084	// Grab the next option from a string.
    00085	function bool GrabOption( out string Options, out string Result )
    00086	{
    00087	    if( Left(Options,1)=="?" )
    00088	    {
    00089	      // Get result.
    00090	      Result = Mid(Options,1);
    00091	      if( InStr(Result,"?")>=0 )
    00092	        Result = Left( Result, InStr(Result,"?") );
    00093
    00094	      // Update options.
    00095	      Options = Mid(Options,1);
    00096	      if( InStr(Options,"?")>=0 )
    00097	        Options = Mid( Options, InStr(Options,"?") );
    00098	      else
    00099	        Options = "";
    00100
    00101	      return true;
    00102	    }
    00103	    else return false;
    00104	}
    00105
    00106	// break up a key=value pair into its key and value.
    00107	function GetKeyValue( string Pair, out string Key, out string Value )
    00108	{
    00109	    if( InStr(Pair,"=")>=0 )
    00110	    {
    00111	      Key   = Left(Pair,InStr(Pair,"="));
    00112	      Value = Mid(Pair,InStr(Pair,"=")+1);
    00113	    }
    00114	    else
    00115	    {
    00116	      Key   = Pair;
    00117	      Value = "";
    00118	    }
    00119	}
    00120
    00121	// Find an option in the options string and return it.
    00122	function string ParseOption( string Options, string InKey )
    00123	{
    00124	    local string Pair, Key, Value;
    00125	    while( GrabOption( Options, Pair ) )
    00126	    {
    00127	      GetKeyValue( Pair, Key, Value );
    00128	      if( Key ~= InKey )
    00129	        return Value;
    00130	    }
    00131	    return "";
    00132	}
    00133
    00134	function int GetIntOption( string Options, string ParseString, int CurrentValue)
    00135	{
    00136	  local string InOpt;
    00137
    00138	  InOpt = ParseOption( Options, ParseString );
    00139	  if ( InOpt != "" )
    00140	  {
    00141	//    log(ParseString@InOpt);
    00142	    return int(InOpt);
    00143	  }
    00144	  return CurrentValue;
    00145	}
    00146
    00147	//_____________________________________________________________________________
    00148	// Called to update stats on xboxlive
    00149	function StatUpdate()
    00150	{
    00151	    local int kills, deaths, suicides, minutes, games, gameswon, flagscapt, flagsret;
    00152
    00153	//    Log("STATS StatUpdate '"$StatsMem$"'");
    00154	    kills = GetIntOption(StatsMem, "KI", 0);
    00155	    deaths = GetIntOption(StatsMem, "DE", 0);
    00156	    suicides = GetIntOption(StatsMem, "SU", 0);
    00157	    minutes = GetIntOption(StatsMem, "MI", 0);
    00158	    flagscapt = GetIntOption(StatsMem, "FS", 0);
    00159	    flagsret = GetIntOption(StatsMem, "FR", 0);
    00160	    games =  GetIntOption(StatsMem, "MP", 0);
    00161	    Log("STATS for"@self@"::");
    00162	    Log("  Kills +="@kills);
    00163	    Log("  Deaths +="@deaths);
    00164	    Log("  Suicides +="@suicides);
    00165	    Log("  Minutes +="@minutes);
    00166	    Log("  Flags Scored +="@flagscapt);
    00167	    Log("  Flags Returned +="@flagsret);
    00168	    Log("  Matches played +="@games);
    00169	    gameswon = 0; // unused/not implemented
    00170	    if ( xboxlive != none )
    00171	    {
    00172	      switch ( GameReplicationInfo.GameClass )
    00173	      {
    00174	        case "XIIIMP.XIIIMPBombGame" :
    00175	          xboxlive.SetStatisticsType(GT_Sabotage);
    00176	          break;
    00177	        case "XIIIMP.XIIIMPCTFGameInfo" :
    00178	          xboxlive.SetStatisticsType(GT_CTF);
    00179	          break;
    00180	        case "XIIIMP.XIIIMPTeamGameInfo" :
    00181	          xboxlive.SetStatisticsType(GT_TeamDM);
    00182	          break;
    00183	        case "XIIIMP.XIIIMPGameInfo" :
    00184	        default:
    00185	          xboxlive.SetStatisticsType(GT_DM);
    00186	          break;
    00187	      }
    00188	      xboxlive.StatsUpdateMyStats(kills, deaths, suicides, minutes, games, gameswon, flagscapt, flagsret);
    00189	    }
    00190	/*
    00191	      //order is important here because all team games 'extend' XIIITeamHud
    00192	      if(MyHud.IsA('XIIIMPHud') == true)
    00193	      {
    00194	        if(MyHud.IsA('XIIITeamHud') == true)
    00195	        {
    00196	          if(MyHud.IsA('XIIICTFHud') == true)
    00197	          {
    00198	            xboxlive.SetStatisticsType(GT_CTF);
    00199	            xboxlive.StatsUpdateMyStats(kills, deaths, suicides, minutes, games, gameswon, flagscapt, flagsret);
    00200	          }
    00201	          else if(MyHud.IsA('XIIIBombHud') == true)
    00202	          {
    00203	            xboxlive.SetStatisticsType(GT_Sabotage);
    00204	            xboxlive.StatsUpdateMyStats(kills, deaths, suicides, minutes, games, gameswon, flagscapt, flagsret);
    00205	          }
    00206	          else
    00207	          {
    00208	            xboxlive.SetStatisticsType(GT_TeamDM);
    00209	            xboxlive.StatsUpdateMyStats(kills, deaths, suicides, minutes, games, gameswon, flagscapt, flagsret);
    00210	          }
    00211	        }
    00212	        else
    00213	        {
    00214	          xboxlive.SetStatisticsType(GT_DM);
    00215	          xboxlive.StatsUpdateMyStats(kills, deaths, suicides, minutes, games, gameswon, flagscapt, flagsret);
    00216	        }
    00217	      }
    00218	    }
    00219	*/
    00220	}
    00221
    00222	//_____________________________________________________________________________
    00223	event ClientMessage( coerce string S, optional Name Type )
    00224	{
    00225	    if ( Type == 'STATS' )
    00226	    {
    00227	      Log("STATS update received '"$S$"'");
    00228	      StatsMem = S;
    00229	      if ( xboxlive == none )
    00230	      	xboxlive = New Class'XboxLiveManager';
    00231
    00232	      if (xboxlive.IsLoggedIn(xboxlive.GetCurrentUser()))
    00233	         xboxlive.SetShouldUpdateStats(true);
    00234
    00235	      return;
    00236	    }
    00237	    if (Type == '')
    00238	      Type = 'Event';
    00239
TeamMessage(PlayerReplicationInfo, S, Type); 00240 } 00241 00242 //_____________________________________________________________________________ 00243 function ClientGameEnded() 00244 { 00245 GotoState('GameEnded'); 00246 } 00247 00248 //_____________________________________________________________________________ 00249 exec function Fire( optional float F ) 00250 { 00251 if ( Level.Pauser == PlayerReplicationInfo ) 00252 { 00253 SetPause(false); 00254 return; 00255 } 00256 if (!bImmortal) 00257 Super.Fire(F); 00258 } 00259 00260 //_____________________________________________________________________________ 00261 exec function AltFire( optional float F ) 00262 { 00263 if ( Level.Pauser == PlayerReplicationInfo ) 00264 { 00265 SetPause(false); 00266 return; 00267 } 00268 if (!bImmortal) 00269 Super.AltFire(F); 00270 } 00271 00272 //_____________________________________________________________________________ 00273 exec function Grab() 00274 { 00275 local PowerUps PwrU; 00276 00277 // No grab in multiplayer 00278 // then interact w/ door 00279 if ( MyInteraction.bCanDoor ) 00280 { 00281 if ( MyInteraction.bCanUnLockDoor ) 00282 { 00283 // ELR Select required item if in inventory 00284 PwrU = TryInteractWithDoor(MyInteraction.TargetActor); 00285 if ( ( bWeaponMode ) && (PwrU != none) ) 00286 { 00287 cNextItem(); 00288 XIIIPawn(Pawn).PendingItem = PwrU; 00289 if ( (XIIIPawn(Pawn).PendingItem != None) && (XIIIPawn(Pawn).PendingItem != Pawn.SelectedItem) ) 00290 XIIIItems(Pawn.SelectedItem).PutDown(); 00291 } 00292 else if ( (!bWeaponMode) && (PwrU != none) ) 00293 { 00294 if (PwrU == Pawn.SelectedItem) 00295 Pawn.SelectedItem.Activate(); 00296 else 00297 { 00298 cNextItem(); 00299 XIIIPawn(Pawn).PendingItem = PwrU; 00300 if ( (XIIIPawn(Pawn).PendingItem != None) && (XIIIPawn(Pawn).PendingItem != Pawn.SelectedItem) ) 00301 XIIIItems(Pawn.SelectedItem).PutDown(); 00302 } 00303 } 00304 else 00305 { 00306 // ELR End Select required item if in inventory 00307 MyHud.LocalizedMessage(class'XIIISoloMessage', 5); 00308 XIIIMover(MyInteraction.TargetActor).PlayerTrigger(self, Pawn); 00309 } 00310 } 00311 else 00312 { 00313 XIIIMover(MyInteraction.TargetActor).PlayerTrigger(self, Pawn); 00314 XIIIPawn(Pawn).PlayOpenDoor(); 00315 return; 00316 } 00317 } 00318 if ( bWeaponMode && (Pawn.Weapon.Default.ReloadCount > Pawn.Weapon.ReloadCount) ) 00319 { 00320 ReLoad(); 00321 return; 00322 } 00323 } 00324 00325 //_____________________________________________________________________________ 00326 state GameEnded 00327 { 00328 exec function AltFire( optional float F ); 00329 event BeginState() 00330 { 00331 if ( Pawn.weapon != none ) 00332 { 00333 Pawn.weapon.bHidden = true; 00334 Pawn.weapon.RefreshDisplaying(); 00335 } 00336 if ( Pawn.SelectedItem != none ) 00337 Pawn.SelectedItem.bOwnerNoSee = true; 00338 00339 XIIIMPHUD( PlayerController(Pawn.Controller).MyHud).MarioBonus = 0; 00340 XIIIMPHUD( PlayerController(Pawn.Controller).MyHud).OldScore = XIIIPlayerReplicationInfo(PlayerReplicationInfo).MyDeathScore; 00341 XIIIMPHUD( PlayerController(Pawn.Controller).MyHud).UpdateBonusSound(); 00342 XIIIMPHUD( PlayerController(Pawn.Controller).MyHud).bDrawBonusText = false; 00343 00344 Pawn.SetDrawType(DT_None); 00345 SetTimer2(0.25,true); 00346 super.BeginState(); 00347 } 00348 00349 function PlayerMove(float DeltaTime) 00350 { 00351 ViewShake(DeltaTime); 00352 ViewFlash(DeltaTime); 00353 } 00354 function ProcessMove( float DeltaTime, vector newAccel, eDoubleClickDir DoubleClickMove, rotator DeltaRot); 00355 00356 event Timer2() 00357 { 00358 if ( XIIIGameReplicationInfo(GameReplicationInfo).iGameState == 1 ) 00359 { 00360 SetTimer2(0,false); 00361 bWeaponBlock = false; 00362 GotoState('PlayerWaiting' ); 00363 } 00364 } 00365 } 00366 00367 //_____________________________________________________________________________ 00368 state Dead 00369 { 00370 ignores SeePlayer, HearNoise, KilledBy, SwitchWeapon; 00371 00372 function ServerRestartPlayer() 00373 { 00374 if ( bFrozen ) 00375 return; 00376 Super.ServerRestartPlayer(); 00377 } 00378 exec function AltFire( optional float F ); 00379 exec function Fire( optional float F ) 00380 { 00381 if ( !bFrozen ) 00382 ServerReStartPlayer(); 00383 } 00384 00385 event Timer() 00386 { 00387 // Log("DEAD Timer"); 00388 myHUD.bShowScores = true; 00389 bPressedJump = false; 00390 if ( GameReplicationInfo.GameClass == "XIIIMP.XIIIMPBombGame" ) 00391 { 00392 if ( PlayerReplicationInfo.Team.TeamIndex == 0 ) 00393 TimeBeforeRespawn = 4.0 ; 00394 else 00395 TimeBeforeRespawn = 8.0 ; 00396 SetTimer2(1.0,true); 00397 } 00398 else 00399 bFrozen = false; 00400 } 00401 00402 event Timer2() 00403 { 00404 // Log("DEAD Timer2"); 00405 TimeBeforeRespawn--; 00406 if( TimeBeforeRespawn <= 0 ) 00407 { 00408 SetTimer2(0.0,false); 00409 bFrozen = false; 00410 } 00411 } 00412 00413 function PlayerMove(float DeltaTime) 00414 { 00415 local vector X,Y,Z; 00416 local rotator ViewRotation; 00417 00418 if ( !bFrozen ) 00419 { 00420 if ( bPressedJump ) 00421 { 00422 // Fire(0); 00423 bPressedJump = false; 00424 } 00425 GetAxes(Rotation,X,Y,Z); 00426 // Update view rotation. 00427 ViewRotation = Rotation; 00428 ViewRotation.Yaw += 32.0 * DeltaTime * aTurn; 00429 ViewRotation.Pitch += 32.0 * DeltaTime * aLookUp; 00430 ViewRotation.Pitch = ViewRotation.Pitch & 65535; 00431 If ((ViewRotation.Pitch > 18000) && (ViewRotation.Pitch < 49152)) 00432 { 00433 If (aLookUp > 0) 00434 ViewRotation.Pitch = 18000; 00435 else 00436 ViewRotation.Pitch = 49152; 00437 } 00438 SetRotation(ViewRotation); 00439 if ( Role < ROLE_Authority ) // then save this move and replicate it 00440 ReplicateMove(DeltaTime, vect(0,0,0), DCLICK_None, rot(0,0,0)); 00441 } 00442 ViewShake(DeltaTime); 00443 ViewFlash(DeltaTime); 00444 } 00445 00446 simulated event BeginState() 00447 { 00448 local SavedMove Next; 00449 00450 // Log("DEAD BeginState"); 00451 Enemy = None; 00452 bBehindView = true; 00453 bFrozen = true; 00454 bPressedJump = false; 00455 FindGoodView(); 00456 SetTimer(1.0, false); 00457 DefaultFOV = default.DefaultFOV; 00458 DesiredFOV = DefaultFOV; 00459 FOVAngle = DefaultFOV; 00460 00461 // clean out saved moves 00462 while ( SavedMoves != None ) 00463 { 00464 Next = SavedMoves.NextMove; 00465 SavedMoves.Destroy(); 00466 SavedMoves = Next; 00467 } 00468 if ( PendingMove != None ) 00469 { 00470 PendingMove.Destroy(); 00471 PendingMove = None; 00472 } 00473 } 00474 00475 } 00476 00477 //_____________________________________________________________________________ 00478 // MyInteractionClass="XIIIMP.XIIIMPBotInteraction" 00479 00480 00481 defaultproperties 00482 { 00483 bHasRollOff=True 00484 bHasPosition=True 00485 }

End Source Code