Replacing a Single ZED

From Tripwire Interactive Wiki
Revision as of 18:08, 16 November 2012 by WhiskyGartley (talk | contribs) (Page Creation)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This tutorial will show you how to replace an existing ZED with a custom one.

Prerequisites

Creating A Basic Mutator

The Mutator

:

class MutZEDReplace extends Mutator;

function PostBeginPlay() {

 setTimer(5.0,false);

}

function Timer() {

       local KFGameType KF;

local byte i,j; local class<KFMonster> MC;

KF = KFGameType(Level.Game); if( KF==None ) Error("This mutator is only for KFGameType!"); else { //normal squads for( i=0; i<KF.InitSquads.Length; i++) { for( j=0; j < KF.InitSquads[i].MSquad.Length; j++ ) { if ( String(KF.InitSquads[i].MSquad[j]) == "KFChar.ZEDTOREPLACE" ) { MC = Class<KFMonster>(DynamicLoadObject("PACKAGENAME.NEWZED", class'class')); KF.InitSquads[i].MSquad[j] = MC; } } }

//special squads for (i=0;i<KF.SpecialSquads.Length;i++) { for (j=0; j<KF.SpecialSquads[i].ZedClass.Length;j++) { if (KF.SpecialSquads[i].ZedClass[j] == "KFChar.ZEDTOREPLACE") KF.SpecialSquads[i].ZedClass[j]= "PACKAGENAME.NEWZED"; } }

//final squads for (i=0;i<KF.FinalSquads.Length;i++) { for (j=0; j<KF.FinalSquads[i].ZedClass.Length;j++) { if (KF.FinalSquads[i].ZedClass[j] == "KFChar.ZEDTOREPLACE") KF.FinalSquads[i].ZedClass[j]= "PACKAGENAME.NEWZED"; } } } }

Breakdown

We use a timer in this mutator so that it waits until the game has set itself up (loading the monster classes and the like) before we overwrite it. We set the timer with a delay of 5 seconds and tell it only to run once.

:

function PostBeginPlay() {

 setTimer(5.0,false);

}

At start of the timer function declare the variables and also take this time to add a small error check; after all, we don't need this running on any other gametype then KF's default.

:

local KFGameType KF; local byte i,j; local class<KFMonster> MC;

KF = KFGameType(Level.Game); if( KF==None ) Error("This mutator is only for KFGameType!"); else

In the timer we use FOR loops to work through the arrays that control monster spawns and IF statements to check for the ZEDs we wish to replace. When the IF statement returns true we replace that class with our own. You'll have to do this for the InitSquads, SpecialSquads and FinalSquads.

:

//normal squads for( i=0; i<KF.InitSquads.Length; i++) { for( j=0; j < KF.InitSquads[i].MSquad.Length; j++ ) { if ( String(KF.InitSquads[i].MSquad[j]) == "KFChar.ZEDTOREPLACE" ) { MC = Class<KFMonster>(DynamicLoadObject("PACKAGENAME.NEWZED", class'class')); KF.InitSquads[i].MSquad[j] = MC; } } }

Remember to add the mutators default properties. Compile, run the client with the mutator on and you should now have your custom ZED in place of his original.