Prologue
This was created by Sersh, credit for the texts and informations go to him.
Don't be intimidated, this is not really that hard.
I broke this up as much as I could to make it as easy as possible.
Part #1: The First Functions
I will explain what they are and what they mean one by one.
1. A OnEnter
This means that when your tank touches/enters an object, something happens.
It will look like this:
Code: Select all
function FUNCTIONNAME::OnEnter(%db, %this, %tank)
{
}
Now, I will explain how to add things to make it actually "do" something.

1. B What Can It Do?
If you want to give the person that enters extra points, use this:
Code: Select all
%tank.incScore(3,3);
To change how many points are given just change the numbers.
You function should look like this now
Code: Select all
function FUNCTIONNAME ::onenter(%db, %this, %tank)
{
%tank.incScore(3,3);
}
If your already confused, better stop reading.
2.A Adding The Object To A Mission
Place an object in ModWizard where-ever you want the object that has the function to be.
Make sure that this is the actual object you want to add the function to or this won't really work.
Save it.
Now scroll down to where you see the object in the .mis file.
This part is a bit tricky so pay attention!
In the .mis file, you should see something like this:
Code: Select all
new TSStatic() {
position = "-15.0168 -3.39374 231.699";
rotation = "-0.207608 -0.144924 -0.967417 103.418";
scale = "1 1 1";
shapeName = "game/data/shapes/Green/rockgreen05.dts";
treeLighting = "0";
lightBoost = "0";
};
Code: Select all
new PowerUp() {
dataBlock = "Reload";
position = "106.898 -46.88 206.269";
rotation = "-0.0203159 -0.00403374 0.999785 209.782";
scale = "1 1 1";
lightBoost = "0";
};
and put it in the PowerUp's position and rotation.
It should look like this:
Code: Select all
new PowerUp() {
dataBlock = "Reload";
position = "-15.0168 -3.39374 231.699";
rotation = "-0.207608 -0.144924 -0.967417 103.418";
scale = "1 1 1";
lightBoost = "0";
};
B.2 Adding the function to the object
Now this part is really easy.
Remember how I said to remember the FUNCTIONNAME in this?
Code: Select all
function FUNCTIONNAME::OnEnter(%db, %this, %tank)
{
%tank.incScore(3,3);
}
Code: Select all
function pointgiver::OnEnter(%db, %this, %tank)
Remember the power up thing I just told you about? Go back to it and do this:
Change It To:
Code: Select all
new PowerUp() {
dataBlock = "pointgiver";
position = "-15.0168 -3.39374 231.699";
rotation = "-0.207608 -0.144924 -0.967417 103.418";
scale = "1 1 1";
lightBoost = "0";
};
Ok you still aren't done yet though
This is just "making the power-up" so the game knows what "pointgiver" means.
Right under:
Code: Select all
function pointgiver::OnEnter(%db, %this, %tank)
{
%tank.incScore(3,3);
}
Code: Select all
datablock powerupdata(pointgiver)
{
category = "PowerUp";
shape = "game/data/shapes/Common/reload.dts";
type = "bounce";
shadow = true;
shadowAnimation = true;
startOn = true;
minOff = 1;
maxOff = 2;
Sound = "PupOnSound";
soundOff = "PupOffSound";
};
Code: Select all
function pointgiver::OnEnter(%db, %this, %tank)
{
%tank.incScore(3,3);
}
datablock powerupdata(pointgiver)
{
category = "PowerUp";
shape = "game/data/shapes/Common/reload.dts";
type = "bounce";
shadow = true;
shadowAnimation = true;
startOn = true;
minOff = 1;
maxOff = 2;
Sound = "PupOnSound";
soundOff = "PupOffSound";
};
Remember this?
Code: Select all
new TSStatic() {
position = "-15.0168 -3.39374 231.699";
rotation = "-0.207608 -0.144924 -0.967417 103.418";
scale = "1 1 1";
shapeName = "game/data/shapes/Green/rockgreen05.dts";
treeLighting = "0";
lightBoost = "0";
};
Okay! If you made it until here and your not confused yet! Great!
C.1 Where To Place?
C.1.1
Code: Select all
function pointgiver::OnEnter(%db, %this, %tank)
{
%tank.incScore(3,3);
}
datablock powerupdata(pointgiver)
{
category = "PowerUp";
shape = "game/data/shapes/Common/reload.dts";
type = "bounce";
shadow = true;
shadowAnimation = true;
startOn = true;
minOff = 1;
maxOff = 2;
Sound = "PupOnSound";
soundOff = "PupOffSound";
};
Goes above the //--- OBJECT WRITE BEGIN --- at the top of the .mis-file.
C.1.2
The:
Code: Select all
new PowerUp() {
dataBlock = "pointgiver";
position = "-15.0168 -3.39374 231.699";
rotation = "-0.207608 -0.144924 -0.967417 103.418";
scale = "1 1 1";
lightBoost = "0";
};
C.2 Functions
Code: Select all
%tank.incScore(3,3);
Code: Select all
%tank.hurtMe(999);
Code: Select all
messageall(10,"YOUR MESSAGE HERE",10);
Code: Select all
centerprintall("YOUR MESSAGE HERE",4,4);
Code: Select all
bottomprintall("YOUR MESSAGE HERE",4,4);
Code: Select all
messageall(10,%tank.client.namebase SPC "YMH",10);
You can also put them together. Like this:
Code: Select all
function pointgiver::OnEnter(%db, %this, %tank)
{
%tank.hurtme(999);
%tank.incScore(3,3);
messageall(10,%tank.client.namebase SPC "picked up the bonus!",10);
}
Okay! These are the real basics of scripting.
For more information on scripting, visit these sites/threads:
[/url]