tutorials for ut2k4

Making A Preload Mutator For Invasion

This tutorial assumes you already have basic knowledge of unreal code.

When using/making custom monsters for Invasion, its a good idea to have the game preload the required monster files as to reduce the amount of "lag" caused when they spawn.

A few things first: "DynamicLoadObject" is used almost exclusively to load a resource (anytype, e.g .utx, ukx...). "PrecacheMaterial" can only be used to precache Textures and StaticMeshes.

First you need to create a new blank .uc file and add "class "yourclass" extends Mutator;" so it should look like this:

class "yourclass" extends Mutator;

Now we need to tell the file which packages are required to make this mutator (#exec obj load file) only loads up the files for compiling

#exec obj load file=yourtexturefile.utx //texture file that contains the texture you want to preload #exec obj load file=yourstaticmeshfile.usx //staticmesh file that contains the texture you want to preload #exec obj load file=youranimationfile.ukx #exec obj load file=yoursoundfile.uax #exec obj load file=yoursytemfile.u

The following function can be used to "preload objects" such as Meshes and textures (you can preload anything here).

function PreBeginPlay() { local material SomeMat; local sound SomeSound; local mesh SomeMesh; Super.PreBeginPlay(); Log("MONSTER PRELOAD INITIALIZED"); // You can change "MONSTER PRELOAD INITIALIZED" to anything you want it to say in the log. //A quick note for log messages. DynamicLoadObject has a variable "MayFail" that tells it to write an error message if an object couldnt be loaded, //if False or Omitted then the error will be logged. If True then the error message will not. //first, lets assign a material to our variable SomeMat=material(DynamicLoadObject("TexturePackage.ATexture",class'Material',False)); //Here i have added the MayFail var as False to check in the log //that it is working. If all looks good in the log then set this to True, (note you dont need to type False, if it is Omitted it will do the same thing) //heres an example: SomeMat=material(DynamicLoadObject("AlleriaTerrain.glacier01AL",class'Material')); //now lets load up a sound SomeSound=sound(DynamicLoadObject("SoundPackage.ASound",class'sound')); //heres an example: SomeSound=sound(DynamicLoadObject("GeneralImpacts.Water.ImpactSplash2",class'sound')); //Time for that mesh SomeMesh=mesh(DynamicLoadObject("MeshPackage.AMesh",class'mesh')); //heres an example: SomeMesh=mesh(DynamicLoadObject("Weapons.LinkGun_1st",class'mesh')); }

Now for the default properties of the mutator.

defaultproperties { bAddToServerPackages=True //no need to edit the ini file with this property. GroupName="Textureskin" //if another mut has the same group name, you wont be able to use them both at the same time. FriendlyName="TexturePreloads" //what you will see on the mutator list Description="Use this mutator to preload monster resources" bAlwaysRelevant=True RemoteRole=ROLE_SimulatedProxy }

Well done! you have just made a texture preload mutator!
It should look something like this:

class "yourclass" extends Mutator; #exec obj load file=yourtexturefile.utx #exec obj load file=yourstaticmeshfile.usx #exec obj load file=youranimationfile.ukx #exec obj load file=yoursoundfile.uax #exec obj load file=yoursytemfile.u function PreBeginPlay() { local material SomeMat; local sound SomeSound; local mesh SomeMesh; Super.PreBeginPlay(); Log("MONSTER PRELOAD INITIALIZED"); SomeMat=material(DynamicLoadObject("TexturePackage.ATexture",class'Material',True)); SomeSound=sound(DynamicLoadObject("SoundPackage.ASound",class'sound',True)); SomeMesh=mesh(DynamicLoadObject("MeshPackage.AMesh",class'mesh',True)); } defaultproperties { bAddToServerPackages=True GroupName="Textureskin" FriendlyName="TexturePreloads" Description="Use this mutator to preload monster resources" bAlwaysRelevant=True RemoteRole=ROLE_SimulatedProxy }