Engine
Class Mutator

source: e:\games\UnrealTournament\Engine\Classes\Mutator.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Info
         |
         +--Engine.Mutator
Direct Known Subclasses:Arena, ChainsawMelee, DMMutator, FatBoy, InstantRockets, JumpMatch, LowGrav, NoPowerups, NoRedeemer, Stealth

class Mutator
extends Engine.Info

//============================================================================= // Mutator. // called by the IsRelevant() function of DeathMatchPlus // by adding new mutators, you can change actors in the level without requiring // a new game class. Multiple mutators can be linked together. //=============================================================================
Variables
 class DefaultWeapon
 Mutator NextDamageMutator
 Mutator NextHUDMutator
 Mutator NextMessageMutator
 Mutator NextMutator
 bool bHUDMutator


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 CheckReplacement(Actor Other, out byte)
 bool HandleEndGame()
 bool HandlePickupQuery(Pawn Other, Inventory item, out byte)
 bool HandleRestartGame()
 bool IsRelevant(Actor Other, out byte)
 void ModifyPlayer(Pawn Other)
 void Mutate(string MutateString, PlayerPawn Sender)
 bool MutatorBroadcastMessage(Actor Sender, Pawn Receiver, out coerce, optional bool, out optional)
 void MutatorTakeDamage(out int, Pawn Victim, Pawn InstigatedBy, out Vector, out Vector, name DamageType)
 bool MutatorTeamMessage(Actor Sender, Pawn Receiver, PlayerReplicationInfo PRI, string S, name Type, optional bool)
 bool PreventDeath(Pawn Killed, Pawn Killer, name damageType, vector HitLocation)
 
simulated
RegisterHUDMutator()
     
// Registers the current mutator on the client to receive PostRender calls.
 bool ReplaceWith(Actor Other, string aClassName)
     
/* ReplaceWith()
Call this function to replace an actor Other with an actor of aClass.
*/
 void ScoreKill(Pawn Killer, Pawn Other)



Source Code


00001	//=============================================================================
00002	// Mutator.
00003	// called by the IsRelevant() function of DeathMatchPlus
00004	// by adding new mutators, you can change actors in the level without requiring
00005	// a new game class.  Multiple mutators can be linked together. 
00006	//=============================================================================
00007	class Mutator expands Info
00008		native;
00009	
00010	var Mutator NextMutator;
00011	var Mutator NextDamageMutator;
00012	var Mutator NextMessageMutator;
00013	var Mutator NextHUDMutator;
00014	
00015	var bool bHUDMutator;
00016	
00017	var class<Weapon> DefaultWeapon;
00018	
00019	event PreBeginPlay()
00020	{
00021		//Don't call Actor PreBeginPlay()
00022	}
00023	
00024	simulated event PostRender( canvas Canvas );
00025	
00026	function ModifyPlayer(Pawn Other)
00027	{
00028		// called by GameInfo.RestartPlayer()
00029		if ( NextMutator != None )
00030			NextMutator.ModifyPlayer(Other);
00031	}
00032	
00033	function bool HandleRestartGame()
00034	{
00035		if ( NextMutator != None )
00036			return NextMutator.HandleRestartGame();
00037		return false;
00038	}
00039	
00040	function bool HandleEndGame()
00041	{
00042		// called by GameInfo.RestartPlayer()
00043		if ( NextMutator != None )
00044			return NextMutator.HandleEndGame();
00045		return false;
00046	}
00047	
00048	function bool HandlePickupQuery(Pawn Other, Inventory item, out byte bAllowPickup)
00049	{
00050		if ( NextMutator != None )
00051			return NextMutator.HandlePickupQuery(Other, item, bAllowPickup);
00052		return false;
00053	}
00054	
00055	function bool PreventDeath(Pawn Killed, Pawn Killer, name damageType, vector HitLocation)
00056	{
00057		if ( NextMutator != None )
00058			return NextMutator.PreventDeath(Killed,Killer, damageType,HitLocation);
00059		return false;
00060	}
00061	
00062	function ModifyLogin(out class<playerpawn> SpawnClass, out string Portal, out string Options)
00063	{
00064		if ( NextMutator != None )
00065			NextMutator.ModifyLogin(SpawnClass, Portal, Options);
00066	}
00067	
00068	function ScoreKill(Pawn Killer, Pawn Other)
00069	{
00070		// called by GameInfo.ScoreKill()
00071		if ( NextMutator != None )
00072			NextMutator.ScoreKill(Killer, Other);
00073	}
00074	
00075	// return what should replace the default weapon
00076	// mutators further down the list override earlier mutators
00077	function Class<Weapon> MutatedDefaultWeapon()
00078	{
00079		local Class<Weapon> W;
00080	
00081		if ( NextMutator != None )
00082		{
00083			W = NextMutator.MutatedDefaultWeapon();
00084			if ( W == Level.Game.DefaultWeapon )
00085				W = MyDefaultWeapon();
00086		}
00087		else
00088			W = MyDefaultWeapon();
00089		return W;
00090	}
00091	
00092	function Class<Weapon> MyDefaultWeapon()
00093	{
00094		if ( DefaultWeapon != None )
00095			return DefaultWeapon;
00096		else
00097			return Level.Game.DefaultWeapon;
00098	}
00099	
00100	function AddMutator(Mutator M)
00101	{
00102		if ( NextMutator == None )
00103			NextMutator = M;
00104		else
00105			NextMutator.AddMutator(M);
00106	}
00107	
00108	/* ReplaceWith()
00109	Call this function to replace an actor Other with an actor of aClass.
00110	*/
00111	function bool ReplaceWith(actor Other, string aClassName)
00112	{
00113		local Actor A;
00114		local class<Actor> aClass;
00115	
00116		if ( Other.IsA('Inventory') && (Other.Location == vect(0,0,0)) )
00117			return false;
00118		aClass = class<Actor>(DynamicLoadObject(aClassName, class'Class'));
00119		if ( aClass != None )
00120			A = Spawn(aClass,Other.Owner,Other.tag,Other.Location, Other.Rotation);
00121		if ( Other.IsA('Inventory') )
00122		{
00123			if ( Inventory(Other).MyMarker != None )
00124			{
00125				Inventory(Other).MyMarker.markedItem = Inventory(A);
00126				if ( Inventory(A) != None )
00127				{
00128					Inventory(A).MyMarker = Inventory(Other).MyMarker;
00129					A.SetLocation(A.Location 
00130						+ (A.CollisionHeight - Other.CollisionHeight) * vect(0,0,1));
00131				}
00132				Inventory(Other).MyMarker = None;
00133			}
00134			else if ( A.IsA('Inventory') )
00135			{
00136				Inventory(A).bHeldItem = true;
00137				Inventory(A).Respawntime = 0.0;
00138			}
00139		}
00140		if ( A != None )
00141		{
00142			A.event = Other.event;
00143			A.tag = Other.tag;
00144			return true;
00145		}
00146		return false;
00147	}
00148	
00149	/* Force game to always keep this actor, even if other mutators want to get rid of it
00150	*/
00151	function bool AlwaysKeep(Actor Other)
00152	{
00153		if ( NextMutator != None )
00154			return ( NextMutator.AlwaysKeep(Other) );
00155		return false;
00156	}
00157	
00158	function bool IsRelevant(Actor Other, out byte bSuperRelevant)
00159	{
00160		local bool bResult;
00161	
00162		// allow mutators to remove actors
00163		bResult = CheckReplacement(Other, bSuperRelevant);
00164		if ( bResult && (NextMutator != None) )
00165			bResult = NextMutator.IsRelevant(Other, bSuperRelevant);
00166	
00167		return bResult;
00168	}
00169	
00170	function bool CheckReplacement(Actor Other, out byte bSuperRelevant)
00171	{
00172		return true;
00173	}
00174	
00175	function Mutate(string MutateString, PlayerPawn Sender)
00176	{
00177		if ( NextMutator != None )
00178			NextMutator.Mutate(MutateString, Sender);
00179	}
00180	
00181	function MutatorTakeDamage( out int ActualDamage, Pawn Victim, Pawn InstigatedBy, out Vector HitLocation, 
00182							out Vector Momentum, name DamageType)
00183	{
00184		if ( NextDamageMutator != None )
00185			NextDamageMutator.MutatorTakeDamage( ActualDamage, Victim, InstigatedBy, HitLocation, Momentum, DamageType );
00186	}
00187	
00188	function bool MutatorTeamMessage( Actor Sender, Pawn Receiver, PlayerReplicationInfo PRI, coerce string S, name Type, optional bool bBeep )
00189	{
00190		if ( NextMessageMutator != None )
00191			return NextMessageMutator.MutatorTeamMessage( Sender, Receiver, PRI, S, Type, bBeep );
00192		else
00193			return true;
00194	}
00195	
00196	function bool MutatorBroadcastMessage( Actor Sender, Pawn Receiver, out coerce string Msg, optional bool bBeep, out optional name Type )
00197	{
00198		if ( NextMessageMutator != None )
00199			return NextMessageMutator.MutatorBroadcastMessage( Sender, Receiver, Msg, bBeep, Type );
00200		else
00201			return true;
00202	}
00203	
00204	function bool MutatorBroadcastLocalizedMessage( Actor Sender, Pawn Receiver, out class<LocalMessage> Message, out optional int Switch, out optional PlayerReplicationInfo RelatedPRI_1, out optional PlayerReplicationInfo RelatedPRI_2, out optional Object OptionalObject )
00205	{
00206		if ( NextMessageMutator != None )
00207			return NextMessageMutator.MutatorBroadcastLocalizedMessage( Sender, Receiver, Message, Switch, RelatedPRI_1, RelatedPRI_2, OptionalObject );
00208		else
00209			return true;
00210	}
00211	
00212	// Registers the current mutator on the client to receive PostRender calls.
00213	simulated function RegisterHUDMutator()
00214	{
00215		local Pawn P;
00216	
00217		ForEach AllActors(class'Pawn', P)
00218			if ( P.IsA('PlayerPawn') && (PlayerPawn(P).myHUD != None) )
00219			{
00220				NextHUDMutator = PlayerPawn(P).myHud.HUDMutator;
00221				PlayerPawn(P).myHUD.HUDMutator = Self;
00222				bHUDMutator = True;
00223			}	
00224	}
00225	
00226	defaultproperties
00227	{
00228	}

End Source Code