Engine
Class Mutator

source: c:\runehov\Engine\Classes\Mutator.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Info
         |
         +--Engine.Mutator
Direct Known Subclasses:MutatorAxeMatch, MutatorFatBoy, MutatorInfinitePowerups, MutatorLefty, MutatorLowDamage, MutatorLowGrav, MutatorNoPowerups, MutatorNoRunes, MutatorRandWeapon, MutatorTemplate, MutatorVampireMatch, SarkBallHUDMutator, SarkBallMutator

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 DefaultShield
 class DefaultWeapon
 Mutator NextDamageMutator
 Mutator NextHUDMutator
 Mutator NextMutator
 bool bHUDMutator


Function Summary
 void AddMutator(Mutator M)
 bool AllowShieldDrop()
 bool AllowWeaponDrop()
 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 IsRelevant(Actor Other, out byte)
 void ModifyPlayer(Pawn Other)
 void Mutate(string MutateString, PlayerPawn Sender)
 void MutatorJointDamaged(out int, Pawn Victim, Pawn InstigatedBy, out Vector, out Vector, name DamageType, out int)
 
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.
*/
 Actor ReplaceWithAndReturn(Actor Other, string aClassName)
     
/* ReplaceWithAndReturn()
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 NextHUDMutator;
00013	
00014	var bool bHUDMutator;
00015	
00016	
00017	var class<Weapon> DefaultWeapon;
00018	var class<Shield> DefaultShield;
00019	
00020	event PreBeginPlay()
00021	{
00022		//Don't call Actor PreBeginPlay()
00023	}
00024	
00025	simulated event PostRender( canvas Canvas );
00026	
00027	function ModifyPlayer(Pawn Other)
00028	{	// called by GameInfo.RestartPlayer()
00029		if ( NextMutator != None )
00030			NextMutator.ModifyPlayer(Other);
00031	}
00032	
00033	function ScoreKill(Pawn Killer, Pawn Other)
00034	{	// called by GameInfo.ScoreKill()
00035		if ( NextMutator != None )
00036			NextMutator.ScoreKill(Killer, Other);
00037	}
00038	
00039	function bool AllowWeaponDrop()
00040	{	// called by GameInfo.AllowWeaponDrop()
00041		if ( NextMutator != None )
00042			return NextMutator.AllowWeaponDrop();
00043		return true;
00044	}
00045	
00046	function bool AllowShieldDrop()
00047	{	// called by GameInfo.AllowShieldDrop()
00048		if ( NextMutator != None )
00049			return NextMutator.AllowShieldDrop();
00050		return true;
00051	}
00052	
00053	// return what should replace the default weapon
00054	// mutators further down the list override earlier mutators
00055	function Class<Weapon> MutatedDefaultWeapon()
00056	{
00057		local Class<Weapon> W;
00058	
00059		if ( NextMutator != None )
00060		{
00061			W = NextMutator.MutatedDefaultWeapon();
00062			if ( W == Level.Game.DefaultWeapon )
00063				W = MyDefaultWeapon();
00064		}
00065		else
00066			W = MyDefaultWeapon();
00067		return W;
00068	}
00069	
00070	function Class<Weapon> MyDefaultWeapon()
00071	{
00072		if ( DefaultWeapon != None )
00073			return DefaultWeapon;
00074		else
00075			return Level.Game.DefaultWeapon;
00076	}
00077	
00078	function Class<Shield> MutatedDefaultShield()
00079	{
00080		local Class<Shield> S;
00081	
00082		if( NextMutator != None )
00083		{
00084			S = NextMutator.MutatedDefaultShield();
00085			if (S == Level.Game.DefaultShield)
00086				S = MyDefaultShield();
00087		}
00088		else
00089			S = MyDefaultShield();
00090		return S;
00091	}
00092	
00093	function Class<Shield> MyDefaultShield()
00094	{
00095		if (DefaultShield != None)
00096			return DefaultShield;
00097		else
00098			return Level.Game.DefaultShield;
00099	}
00100	
00101	function AddMutator(Mutator M)
00102	{
00103		if ( NextMutator == None )
00104			NextMutator = M;
00105		else
00106			NextMutator.AddMutator(M);
00107	}
00108	
00109	/* ReplaceWith()
00110	Call this function to replace an actor Other with an actor of aClass.
00111	*/
00112	function bool ReplaceWith(actor Other, string aClassName)
00113	{
00114		local Actor A;
00115		local class<Actor> aClass;
00116	
00117		if ( Other.IsA('Inventory') && (Other.Location == vect(0,0,0)) )
00118			return false;
00119		aClass = class<Actor>(DynamicLoadObject(aClassName, class'Class'));
00120		if ( aClass != None )
00121			A = Spawn(aClass,,Other.tag,Other.Location, Other.Rotation);
00122		if ( Other.IsA('Inventory') )
00123		{
00124			if ( Inventory(Other).MyMarker != None )
00125			{
00126				Inventory(Other).MyMarker.markedItem = Inventory(A);
00127				if ( Inventory(A) != None )
00128				{
00129					Inventory(A).MyMarker = Inventory(Other).MyMarker;
00130					A.SetLocation(A.Location 
00131						+ (A.CollisionHeight - Other.CollisionHeight) * vect(0,0,1));
00132				}
00133				Inventory(Other).MyMarker = None;
00134			}
00135			else if ( A.IsA('Inventory') )
00136			{
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	/* ReplaceWithAndReturn()
00150	Call this function to replace an actor Other with an actor of aClass.
00151	*/
00152	function actor ReplaceWithAndReturn(actor Other, string aClassName)
00153	{
00154		local Actor A;
00155		local class<Actor> aClass;
00156	
00157		if ( Other.IsA('Inventory') && (Other.Location == vect(0,0,0)) )
00158			return None;
00159		aClass = class<Actor>(DynamicLoadObject(aClassName, class'Class'));
00160		if ( aClass != None )
00161			A = Spawn(aClass,,Other.tag,Other.Location, Other.Rotation);
00162		if ( Other.IsA('Inventory') )
00163		{
00164			if ( Inventory(Other).MyMarker != None )
00165			{
00166				Inventory(Other).MyMarker.markedItem = Inventory(A);
00167				if ( Inventory(A) != None )
00168				{
00169					Inventory(A).MyMarker = Inventory(Other).MyMarker;
00170					A.SetLocation(A.Location 
00171						+ (A.CollisionHeight - Other.CollisionHeight) * vect(0,0,1));
00172				}
00173				Inventory(Other).MyMarker = None;
00174			}
00175			else if ( A.IsA('Inventory') )
00176			{
00177				Inventory(A).Respawntime = 0.0;
00178			}
00179		}
00180		if ( A != None )
00181		{
00182			A.event = Other.event;
00183			A.tag = Other.tag;
00184		}
00185		return A;
00186	}
00187	
00188	/* Force game to always keep this actor, even if other mutators want to get rid of it
00189	*/
00190	function bool AlwaysKeep(Actor Other)
00191	{
00192		if ( NextMutator != None )
00193			return ( NextMutator.AlwaysKeep(Other) );
00194		return false;
00195	}
00196	
00197	function bool IsRelevant(Actor Other, out byte bSuperRelevant)
00198	{
00199		local bool bResult;
00200	
00201		// allow mutators to remove actors
00202		bResult = CheckReplacement(Other, bSuperRelevant);
00203	
00204		if ( bResult && (NextMutator != None) )
00205			bResult = NextMutator.IsRelevant(Other, bSuperRelevant);
00206	
00207		return bResult;
00208	}
00209	
00210	function bool CheckReplacement(Actor Other, out byte bSuperRelevant)
00211	{
00212		return true;
00213	}
00214	
00215	function Mutate(string MutateString, PlayerPawn Sender)
00216	{
00217		if ( NextMutator != None )
00218			NextMutator.Mutate(MutateString, Sender);
00219	}
00220	
00221	function MutatorJointDamaged( out int ActualDamage, Pawn Victim, Pawn InstigatedBy, out Vector HitLocation, 
00222							out Vector Momentum, name DamageType, out int joint)
00223	{
00224		if ( NextDamageMutator != None )
00225			NextDamageMutator.MutatorJointDamaged( ActualDamage, Victim, InstigatedBy, HitLocation, Momentum, DamageType, joint );
00226	}
00227	
00228	// Registers the current mutator on the client to receive PostRender calls.
00229	simulated function RegisterHUDMutator()
00230	{
00231		local HUD MyHud;
00232	
00233		if ((Level.NetMode == NM_Client) || (Level.NetMode == NM_Standalone))
00234			foreach AllActors(class'HUD', MyHud)
00235			{
00236				NextHUDMutator = MyHud.HUDMutator;
00237				MyHud.HUDMutator = Self;
00238				bHUDMutator = True;
00239			}	
00240	}
00241	
00242	defaultproperties
00243	{
00244	}

End Source Code