Post by '¿!N!¿'Lepro$Y on Apr 27, 2004 6:35:04 GMT -5
Basic Coding Stuff
How to Make a Mutate Mutator
Including;
# How to create and compile a MutateString mutator
# How to use the following symbols += -= && != == *
#How to spawn an actor
#How to make a rotation axes into a velocity vector
#How to set physics of an actor
#How to create a new default property that can be changed in-game
#How to make an .int file for your mutator
This tutorial will presume that you know virtually nothing about coding for Rune.
You have opened your Rune Editor, on the right there should be a list of classes, make sure the "Actor classes only" box up the top has a tick in it.
Look for the class called "Info" and click the little tab to expand it and see its sub-classes. Now you should be able to see the class "Mutator", click on it once to highlight it and then click on "New" in the classes menu under the class list.
You will then have to give your mutator a name and give the mutator’s package a name, I usually use the same name for both the mutator and its package. After you put in the names and click "Create New Class", a blank code page will pop up on the screen that says "YourMutatorName expands Mutator".
Now the important thing the mutator needs is a Mutator function. A function is what calls an action to be performed by the mutator. There are functions that call actions upon a player being killed or an actor being spawned for example.
The best thing to do is open the "Mutator template" to see a list of mutator functions. To do this expand the mutator class so you can see its sub-classes.
One of the sub-classes will be "Mutator template", double click on it so it opens the Mutator template code page, it should look like this;
// MutatorTemplate
// empty mutator showing all possible overrides
//=============================================================================
class MutatorTemplate expands Mutator;
// Called before gameplay starts
function PreBeginPlay()
{
Super.PreBeginPlay();
}
// Called each time an actor is spawned, returns relevancy
function bool CheckReplacement(Actor Other, out byte bSuperRelevant)
{
return true;
}
function bool AllowWeaponDrop()
{
return Super.AllowWeaponDrop();
}
function bool AllowShieldDrop()
{
return Super.AllowShieldDrop();
}
// Called each time there is a kill
function ScoreKill(Pawn Killer, Pawn Other)
{
Super.ScoreKill(Killer, Other);
}
// Called after render
simulated event PostRender( canvas Canvas );
// Called by GameInfo.RestartPlayer()
function ModifyPlayer(Pawn Other)
{
Super.ModifyPlayer(Other);
}
function Mutate(string MutateString, PlayerPawn Sender)
{
Super.Mutate(MutateString, Sender);
}
// Called for all damage
function MutatorJointDamaged( out int ActualDamage, Pawn Victim, Pawn InstigatedBy, out Vector HitLocation, out Vector Momentum, name DamageType, out int joint)
{
Super.MutatorJointDamaged(ActualDamage, Victim, InstigatedBy, HitLocation, Momentum, DamageType, joint);
}
The mutator function I will explain in this tutorial is the "MutateString" function. This is the function used by the infamous "Critter’s Kicker" mutator and it calls an action when a player types a mutate command.
So highlight the template of the "MutateString" function, which is this bit;
function Mutate(string MutateString, PlayerPawn Sender)
{
Super.Mutate(MutateString, Sender);
}
Use the edit menu up the top or Alt C to copy it, then click back on your new mutator page and paste the function in there again using the edit menu or Alt V.
All the code you type in will be between the first { and the line Super.Mutate(MutateString, Sender);
First lets make line of code that changes something about the player who types the mutate command.
function Mutate(string MutateString, PlayerPawn Sender)
{
if(mutatestring ~= "morefat")
{
Sender.desiredfatness += 10;
}
Super.Mutate(MutateString, Sender);
}
This will make it so that a player who types; mutate morefat will get a bit fatter.
Note that the player who types the command is always referred to as "Sender". The line that creates the command word that goes after "mutate", is this line if(mutatestring ~= " "), you can put any word you like in between the " ".
Another handy thing to note is the +=, the plus and equal symbols together like this means "add and apply", so in the example above it will add and apply 10 points of desiredfatness to the players current desiredfatness.
Lets add another mutate command that will make the player less fatter;
function Mutate(string MutateString, PlayerPawn Sender)
{
if(mutatestring ~= "morefat")
{
Sender.desiredfatness += 10;
}
if(mutatestring ~= "lessfat")
{
Sender.desiredfatness -= 10;
}
Super.Mutate(MutateString, Sender);
}
This command makes use of subtract and apply -=, using the minus and equals symbols together.
Now using the hotkeys, set input n mutate morefat and set input m mutate lessfat, you can fatten and unfatten your player at the touch of a button.
Now lets try something a little more complicated, adding a command that summons something and makes it shoot off from the player.
I will try and explain what all these new bits mean after the below example
var () float kegvel;
var () float kegvelZ;
function Mutate(string MutateString, PlayerPawn Sender)
{
local Keg Lepskeg;
local vector X,Y,Z;
if(mutatestring ~= "morefat")
{
Sender.desiredfatness += 10;
}
if(mutatestring ~= "lessfat")
{
Sender.desiredfatness -= 10;
}
if(mutatestring ~= "bang")
{
Lepskeg = Spawn(class'keg',,,Sender.Location,Sender.Rotation);
GetAxes(Sender.Rotation, X,Y,Z);
Lepskeg.SetPhysics(Phys_falling);
Lepskeg.Velocity = X*kegvel;
Lepskeg.Velocity.z += kegvelZ;
}
Super.Mutate(MutateString, Sender);
}
First you have to declare what you are going to summon and give it a name, lets summon a Keg.
You do this by adding it as a local variable at the start of the function.
local Keg Lepskeg;
Lepskeg will now refer to the summoned Keg in the same way that the player typing the mutate command is referred to as Sender.
Next you use the spawn function to summon the keg
Lepskeg = Spawn(class'keg',,,Sender.Location,Sender.Rotation);
The commas between the brackets separates the parameters, The 1st parameter is the most important as it decides the class of what is to be spawned, just put the name of the class you want summoned in this bit class'………'
The other parameters after class'' are all optional, they go in this order;
Spawned actor’s owner, Spawned actor’s tag, Spawned actor’s location, Spawned actor’s rotation.
If you want to leave out an optional parameter you still put the commas in but just have nothing in between.
You usually don’t need to use the owner or tag parameters, the location and rotation parameters are far more commonly used. In the above example you can see that the location of the spawned Keg is set as the location of the Sender who summons it, the Keg also gets spawned with the rotation of the Sender.
The next line is this;
GetAxes(Sender.Rotation, X,Y,Z);
This function line converts the rotation of the Sender into a vector that can be used to make the keg shoot off in the direction that the Sender is facing. You will see how this is done below.
You will also need to put another local variable in for the vectors used in the GetAxes function command, this is the line;
local vector X,Y,Z;
Put it under the other local line.
..... Continued in Making a Mutator: part2
How to Make a Mutate Mutator
Including;
# How to create and compile a MutateString mutator
# How to use the following symbols += -= && != == *
#How to spawn an actor
#How to make a rotation axes into a velocity vector
#How to set physics of an actor
#How to create a new default property that can be changed in-game
#How to make an .int file for your mutator
This tutorial will presume that you know virtually nothing about coding for Rune.
You have opened your Rune Editor, on the right there should be a list of classes, make sure the "Actor classes only" box up the top has a tick in it.
Look for the class called "Info" and click the little tab to expand it and see its sub-classes. Now you should be able to see the class "Mutator", click on it once to highlight it and then click on "New" in the classes menu under the class list.
You will then have to give your mutator a name and give the mutator’s package a name, I usually use the same name for both the mutator and its package. After you put in the names and click "Create New Class", a blank code page will pop up on the screen that says "YourMutatorName expands Mutator".
Now the important thing the mutator needs is a Mutator function. A function is what calls an action to be performed by the mutator. There are functions that call actions upon a player being killed or an actor being spawned for example.
The best thing to do is open the "Mutator template" to see a list of mutator functions. To do this expand the mutator class so you can see its sub-classes.
One of the sub-classes will be "Mutator template", double click on it so it opens the Mutator template code page, it should look like this;
// MutatorTemplate
// empty mutator showing all possible overrides
//=============================================================================
class MutatorTemplate expands Mutator;
// Called before gameplay starts
function PreBeginPlay()
{
Super.PreBeginPlay();
}
// Called each time an actor is spawned, returns relevancy
function bool CheckReplacement(Actor Other, out byte bSuperRelevant)
{
return true;
}
function bool AllowWeaponDrop()
{
return Super.AllowWeaponDrop();
}
function bool AllowShieldDrop()
{
return Super.AllowShieldDrop();
}
// Called each time there is a kill
function ScoreKill(Pawn Killer, Pawn Other)
{
Super.ScoreKill(Killer, Other);
}
// Called after render
simulated event PostRender( canvas Canvas );
// Called by GameInfo.RestartPlayer()
function ModifyPlayer(Pawn Other)
{
Super.ModifyPlayer(Other);
}
function Mutate(string MutateString, PlayerPawn Sender)
{
Super.Mutate(MutateString, Sender);
}
// Called for all damage
function MutatorJointDamaged( out int ActualDamage, Pawn Victim, Pawn InstigatedBy, out Vector HitLocation, out Vector Momentum, name DamageType, out int joint)
{
Super.MutatorJointDamaged(ActualDamage, Victim, InstigatedBy, HitLocation, Momentum, DamageType, joint);
}
The mutator function I will explain in this tutorial is the "MutateString" function. This is the function used by the infamous "Critter’s Kicker" mutator and it calls an action when a player types a mutate command.
So highlight the template of the "MutateString" function, which is this bit;
function Mutate(string MutateString, PlayerPawn Sender)
{
Super.Mutate(MutateString, Sender);
}
Use the edit menu up the top or Alt C to copy it, then click back on your new mutator page and paste the function in there again using the edit menu or Alt V.
All the code you type in will be between the first { and the line Super.Mutate(MutateString, Sender);
First lets make line of code that changes something about the player who types the mutate command.
function Mutate(string MutateString, PlayerPawn Sender)
{
if(mutatestring ~= "morefat")
{
Sender.desiredfatness += 10;
}
Super.Mutate(MutateString, Sender);
}
This will make it so that a player who types; mutate morefat will get a bit fatter.
Note that the player who types the command is always referred to as "Sender". The line that creates the command word that goes after "mutate", is this line if(mutatestring ~= " "), you can put any word you like in between the " ".
Another handy thing to note is the +=, the plus and equal symbols together like this means "add and apply", so in the example above it will add and apply 10 points of desiredfatness to the players current desiredfatness.
Lets add another mutate command that will make the player less fatter;
function Mutate(string MutateString, PlayerPawn Sender)
{
if(mutatestring ~= "morefat")
{
Sender.desiredfatness += 10;
}
if(mutatestring ~= "lessfat")
{
Sender.desiredfatness -= 10;
}
Super.Mutate(MutateString, Sender);
}
This command makes use of subtract and apply -=, using the minus and equals symbols together.
Now using the hotkeys, set input n mutate morefat and set input m mutate lessfat, you can fatten and unfatten your player at the touch of a button.
Now lets try something a little more complicated, adding a command that summons something and makes it shoot off from the player.
I will try and explain what all these new bits mean after the below example
var () float kegvel;
var () float kegvelZ;
function Mutate(string MutateString, PlayerPawn Sender)
{
local Keg Lepskeg;
local vector X,Y,Z;
if(mutatestring ~= "morefat")
{
Sender.desiredfatness += 10;
}
if(mutatestring ~= "lessfat")
{
Sender.desiredfatness -= 10;
}
if(mutatestring ~= "bang")
{
Lepskeg = Spawn(class'keg',,,Sender.Location,Sender.Rotation);
GetAxes(Sender.Rotation, X,Y,Z);
Lepskeg.SetPhysics(Phys_falling);
Lepskeg.Velocity = X*kegvel;
Lepskeg.Velocity.z += kegvelZ;
}
Super.Mutate(MutateString, Sender);
}
First you have to declare what you are going to summon and give it a name, lets summon a Keg.
You do this by adding it as a local variable at the start of the function.
local Keg Lepskeg;
Lepskeg will now refer to the summoned Keg in the same way that the player typing the mutate command is referred to as Sender.
Next you use the spawn function to summon the keg
Lepskeg = Spawn(class'keg',,,Sender.Location,Sender.Rotation);
The commas between the brackets separates the parameters, The 1st parameter is the most important as it decides the class of what is to be spawned, just put the name of the class you want summoned in this bit class'………'
The other parameters after class'' are all optional, they go in this order;
Spawned actor’s owner, Spawned actor’s tag, Spawned actor’s location, Spawned actor’s rotation.
If you want to leave out an optional parameter you still put the commas in but just have nothing in between.
You usually don’t need to use the owner or tag parameters, the location and rotation parameters are far more commonly used. In the above example you can see that the location of the spawned Keg is set as the location of the Sender who summons it, the Keg also gets spawned with the rotation of the Sender.
The next line is this;
GetAxes(Sender.Rotation, X,Y,Z);
This function line converts the rotation of the Sender into a vector that can be used to make the keg shoot off in the direction that the Sender is facing. You will see how this is done below.
You will also need to put another local variable in for the vectors used in the GetAxes function command, this is the line;
local vector X,Y,Z;
Put it under the other local line.
..... Continued in Making a Mutator: part2