Engine
Class Mutator

source: C:\XIII\Engine\Classes\Mutator.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Info
         |
         +--Engine.Mutator
Direct Known Subclasses:XIIISoloMutator, XIIIMPMutator

class Mutator
extends Engine.Info

//============================================================================= // Mutator. // // Mutators allow modifications to gameplay while keeping the game rules intact. // Mutators are given the opportunity to modify player login parameters with // ModifyLogin(), to modify player pawn properties with ModifyPlayer(), to change // the default weapon for players with GetDefaultWeapon(), or to modify, remove, // or replace all other actors when they are spawned with CheckRelevance(), which // is called from the PreBeginPlay() function of all actors except those (Decals, // Effects and Projectiles for performance reasons) which have bGameRelevant==true. //=============================================================================
Variables
 class DefaultWeapon
 string DefaultWeaponName
 Mutator NextMutator


Function Summary
 void AddMutator(Mutator M)
     
//_____________________________________________________________________________
 bool AlwaysKeep(Actor Other)
     
//_____________________________________________________________________________
// Force game to always keep this actor, even if other mutators want to get rid of it
 bool CheckRelevance(Actor Other)
     
//_____________________________________________________________________________
// the function called in each Actor PreBeginPlay
 bool CheckReplacement(Actor Other, out byte)
     
//_____________________________________________________________________________
 bool IsRelevant(Actor Other, out byte)
     
//_____________________________________________________________________________
 void ModifyLogin(out string, out string)
     
//_____________________________________________________________________________
// Modify the login (add option if not present...) before it is treated
 void ModifyPlayer(Pawn Other)
     
//_____________________________________________________________________________
// called by GameInfo.RestartPlayer()
//	change the players jumpz, etc. here
// call isAddDefaultInventory -> SetPlayerDefaults -> ModifyPlayer
 bool ReplaceWith(Actor Other, string aClassName)
     
//_____________________________________________________________________________
// ReplaceWith()
// Call this function to replace an actor Other with an actor of aClass.



Source Code


00001	//=============================================================================
00002	// Mutator.
00003	//
00004	// Mutators allow modifications to gameplay while keeping the game rules intact.
00005	// Mutators are given the opportunity to modify player login parameters with
00006	// ModifyLogin(), to modify player pawn properties with ModifyPlayer(), to change
00007	// the default weapon for players with GetDefaultWeapon(), or to modify, remove,
00008	// or replace all other actors when they are spawned with CheckRelevance(), which
00009	// is called from the PreBeginPlay() function of all actors except those (Decals,
00010	// Effects and Projectiles for performance reasons) which have bGameRelevant==true.
00011	//=============================================================================
00012	class Mutator extends Info
00013		native;
00014	
00015	var Mutator NextMutator;
00016	var class<Weapon> DefaultWeapon;
00017	var string DefaultWeaponName;
00018	
00019	//_____________________________________________________________________________
00020	// Don't call Actor PreBeginPlay() for Mutator
00021	event PreBeginPlay();
00022	
00023	//_____________________________________________________________________________
00024	// Modify the login (add option if not present...) before it is treated
00025	function ModifyLogin(out string Portal, out string Options)
00026	{
00027	    if ( NextMutator != None )
00028	    NextMutator.ModifyLogin(Portal, Options);
00029	}
00030	
00031	//_____________________________________________________________________________
00032	// called by GameInfo.RestartPlayer()
00033	//	change the players jumpz, etc. here
00034	// call isAddDefaultInventory -> SetPlayerDefaults -> ModifyPlayer
00035	function ModifyPlayer(Pawn Other)
00036	{
00037	    if ( NextMutator != None )
00038	      NextMutator.ModifyPlayer(Other);
00039	}
00040	
00041	//_____________________________________________________________________________
00042	// return what should replace the default weapon
00043	// mutators further down the list override earlier mutators
00044	function Class<Weapon> GetDefaultWeapon()
00045	{
00046	    local Class<Weapon> W;
00047	
00048	    if ( NextMutator != None )
00049	    {
00050	      W = NextMutator.GetDefaultWeapon();
00051	      if ( W == None )
00052	        W = MyDefaultWeapon();
00053	    }
00054	    else
00055	      W = MyDefaultWeapon();
00056	    return W;
00057	}
00058	
00059	//_____________________________________________________________________________
00060	function class<Weapon> MyDefaultWeapon()
00061	{
00062	    if ( (DefaultWeapon == None) && (DefaultWeaponName != "") )
00063	      DefaultWeapon = class<Weapon>(DynamicLoadObject(DefaultWeaponName, class'Class'));
00064	
00065	    return DefaultWeapon;
00066	}
00067	
00068	//_____________________________________________________________________________
00069	function AddMutator(Mutator M)
00070	{
00071	    if ( NextMutator == None )
00072	      NextMutator = M;
00073	    else
00074	      NextMutator.AddMutator(M);
00075	}
00076	
00077	//_____________________________________________________________________________
00078	// ReplaceWith()
00079	// Call this function to replace an actor Other with an actor of aClass.
00080	function bool ReplaceWith(actor Other, string aClassName)
00081	{
00082	    local Actor A;
00083	    local class<Actor> aClass;
00084	
00085	    if ( Other.IsA('Inventory') && (Other.Location == vect(0,0,0)) )
00086	      return false;
00087	    aClass = class<Actor>(DynamicLoadObject(aClassName, class'Class'));
00088	    if ( aClass != None )
00089	      A = Spawn(aClass,Other.Owner,Other.tag,Other.Location, Other.Rotation);
00090	    if ( Other.IsA('Pickup') )
00091	    {
00092	      if ( Pickup(Other).MyMarker != None )
00093	      {
00094	        Pickup(Other).MyMarker.markedItem = Pickup(A);
00095	        if ( Pickup(A) != None )
00096	        {
00097	          Pickup(A).MyMarker = Pickup(Other).MyMarker;
00098	          A.SetLocation(A.Location
00099	            + (A.CollisionHeight - Other.CollisionHeight) * vect(0,0,1));
00100	        }
00101	        Pickup(Other).MyMarker = None;
00102	      }
00103	      else if ( A.IsA('Pickup') )
00104	        Pickup(A).Respawntime = 0.0;
00105	    }
00106	    if ( A != None )
00107	    {
00108	      A.event = Other.event;
00109	      A.tag = Other.tag;
00110	      return true;
00111	    }
00112	    return false;
00113	}
00114	
00115	//_____________________________________________________________________________
00116	// the function called in each Actor PreBeginPlay
00117	function bool CheckRelevance(Actor Other)
00118	{
00119	    local bool bResult;
00120	    local byte bSuperRelevant;
00121	
00122	    if ( AlwaysKeep(Other) )
00123	      return true;
00124	
00125	    // allow mutators to remove actors
00126	    bResult = IsRelevant(Other, bSuperRelevant);
00127	    return bResult;
00128	}
00129	
00130	//_____________________________________________________________________________
00131	// Force game to always keep this actor, even if other mutators want to get rid of it
00132	function bool AlwaysKeep(Actor Other)
00133	{
00134	    if ( NextMutator != None )
00135	      return ( NextMutator.AlwaysKeep(Other) );
00136	    return false;
00137	}
00138	
00139	//_____________________________________________________________________________
00140	function bool IsRelevant(Actor Other, out byte bSuperRelevant)
00141	{
00142	    local bool bResult;
00143	
00144	    bResult = CheckReplacement(Other, bSuperRelevant);
00145	    if ( bResult && (NextMutator != None) )
00146	      bResult = NextMutator.IsRelevant(Other, bSuperRelevant);
00147	
00148	    return bResult;
00149	}
00150	
00151	//_____________________________________________________________________________
00152	function bool CheckReplacement(Actor Other, out byte bSuperRelevant)
00153	{
00154	    return true;
00155	}
00156	
00157	defaultproperties
00158	{
00159	}

End Source Code