Just to help others who came across this thread on how to embed a mutator into a map:
The beyondunreal wiki has already a page on how to. But this is for UT2k4. Most of the code can be ported.
http://wiki.beyondunreal.com/Legacy:...bedded_Mutator
However, i'll provide an easy example.
First of all, you need add a class defition placeable to the class you want to add on design time (classes can be added differently to a map, but if the placeable attribute is not set, the class/actor won't show up in the browser).
A mutator needs to be registered. In UT3, you need to put this mutator into the chain of mutators (BaseMutator of a Game; BaseMutator.NextMutator = ???).
In addition, as the embedded mutator is added afterwards, we need to call the InitMutator method to initialize mutators like InstaGib.
The following code is a actor to load a mutator if the map is running. Just place the actor into your map. You can specify what mutator to load with the MyMutPath variable (packagename + Mutator class) or you can select a mutator out of the dropdown on MyMutClass. In order to use MyMutClass, you need to set bUseMyMutPath to false in its properties.
!!! There is no additional check if a mutator is already loaded or if it is not allowed to run. But you can check the original AddMutator of the GameInfo class. !!!
Code:
class EGenericLoader extends Info
placeable
HideCategories(Mutator, Advanced, Attachment, Debug, Physics)
AutoExpandCategories(EGenericLoader);
var bool bPreInitialized;
var() bool bUseMutPath;
var() String MyMutPath;
var() class<Mutator> MyMutClass;
function PreBeginPlay()
{
if (!bPreInitialized ) {
bPreInitialized = true;
AddMutatorToGame(true);
}
super.PreBeginPlay();
}
function AddMutatorToGame(optional bool UserAdded)
{
local string Error;
local class<Mutator> mutClass;
local Mutator mut;
local GameInfo G;
G = WorldInfo.Game;
if (bUseMutPath)
mutClass = class<Mutator>(DynamicLoadObject(MyMutPath , class'Class'));
else
mutClass = MyMutClass;
if (mutClass == None)
return;
mut = Spawn(mutClass);
if (mut == None)
return;
mut.bUserAdded = UserAdded;
if (G.BaseMutator == None)
G.BaseMutator = mut;
else
G.BaseMutator.AddMutator(mut);
mut.InitMutator(G.ServerOptions, Error);
}
DefaultProperties
{
bUseMutPath=true
MyMutPath="UTGame.UTMutator_Instagib"
}
The following code is an example on how to disable the fall damage with an embedded mutator.
Code:
class EMut extends UTMutator
placeable
HideCategories(Mutator, Advanced, Attachment, Debug, Physics)
AutoExpandCategories(EMut);
var bool bPreInitialized;
function PreBeginPlay()
{
local string Error;
if (!bPreInitialized ) {
bPreInitialized = true;
self.NextMutator = WorldInfo.Game.BaseMutator;
WorldInfo.Game.BaseMutator = self;
InitMutator(WorldInfo.Game.ServerOptions,Error);
}
super.PreBeginPlay();
}
function ModifyPlayer(Pawn Other)
{
Other.MaxFallSpeed = 0;
Super.ModifyPlayer(Other);
}
function AddMutator(Mutator M)
{
if (M == self) {
return;
}
super.AddMutator(M);
}
DefaultProperties
{
}
Bookmarks