Login x
User Name:
Password:
Social Links Facebook Twitter YouTube Steam RSS News Feeds
Watch MODSonair

Members Online

»
0 Active | 167 Guests
Online:

LATEST FORUM THREADS

»
Mohaa maps on Cod2?
CoD2 MP Mapping
is this place alive?
CoDBO3 Mapping
Call of DutyŽ: WWII
CoD WW2 General

Tutorials

»
CoD Mapping
ratings:
Awful Rating
Poor Rating
Average Rating
Good Rating
Excellent Rating
Getting Started in Scripting (Moving Things)
Versions: You must be logged in to view history.
An introduction to scripting for CoD
1) If you want to make something move in the game, you need both mapping and scripting .

2) Anything that moves is a script_whatever (script_model for a model, script_brushmodel for a brush)

3) Anything that moves must have an origin (a script_model inevitably has one of them, a script_brushmodel does not have any by itself).

Now lets get on with the tutorial

To create a script_brushmodel with an origin

OK, lets create moving brushes.

First of all, the brushes should be created representing the object to be moved. I suggest you start with an artistic assembly of paving stones.
You can use any number of brushes
Then, you create a brush with textures/common/origin, that you can size and place as you want.Later, the center of this brush will be in fact the origin of your script_brushmodel, that you will dimension and place it suits.

Finally, select all your brushes including the brush origin.
Then right-click in the 2d window and select script/brushmodel.

You now have your script_brushmodel.

If you want to select it, SHIFT+ALT+left-click in the 3d window (camera view) and that will select all the brushes of the component. If you want to move a brush individually, you also can, just select it and move it like a normal brush .

If you want to remove a brush component of your script_brushmodel it is not of problem. On the other hand, if you want to add a brush component, it is a little more work.

First, select the script_brushmodel in its entirety (Shift+Alt+left-click). Then, right-click in the 2d window and chose “ungroup entity” (all your brushes are back to normal now).

Add your new brush and follow the above steps to recreate the script_brushmodel.

Like any entity, a script_brushmodel can have keys/values.
We will give ours:

“targetname” “simpson”
*where “targetname” is the key and “simpson” is the value

To recover an entity in a script

By now, you should have a script_model or a script_brushmodel in your map. You’re off to a good start, but now we need to tell the game engine exactly how to handle this situation…so a little scripting is necessary.

- To recover an entity which is the only one to have a particular “targetname” of "simpson"we use:
entity = getent ( "simpson ", "targetname”);

- To recover all the entities which have an identical “targetname” of "simpson" we use:
entities = getentarray ("simpson ", "targetname”);

Now, you are looking at this and saying “If I use getentarray() and only have 1 entity with the “targetname” of “simpson” – will it still work?” The answer is YES…but if you use getent() and have several entities with the “targetname” of “simpson” the script will crash.

In short:
getent ( value, key) turns over an entity
getentarray (value, key) turns over a table of entities.

Threads and the key word "self"

A thread (not a thread which is part of the script) is carried out independently of the remainder of script.

For example, if I make:

function1();
function2();
The function2 will be carried out after the end of the function1.

On the other hand, if I make:

thread function1();
function2();
The function2 will be carried out immediately, at the same time as the function1.

I could also make:

thread function1();
thread function2();
If I want other parts of script to be carried out at the same time as the function1 and the function2.

Now, let us suppose that I make:
simpson1 thread function();
simpson2 thread function();
The same function will be carried out 2 times in parallel.

Following the syntax then:

< entity> thread < function> ;
Indicates in script that when it carries out the function requested, self-service refers to the .

Example:

simpson1 thread function();
simpson2 thread function();
According to the thread "self" will refer to "simpson1" or "simpson2".

If you make your function calls like this:
thread function();
Self "will be inherited" through the self-service of the higher function.

If that confused you, here is a small example:

simpson1 thread function();
simpson2 thread function();

function()
{
thread function2();
}

function2()
{
iprintlnbold ("Hello”);
}

In function(), "self" is either "simpson1", or "simpson2".
In function2() "self" amounts to the same thing. So, the call:
thread function();
is equivalent to:
self thread function();

Here, simpsons.size is the size of the table simpson (that is to say the number of entities having the “targetname” of "simpson ").
For each entity, one launches the thread function(); in which "self" will refer to one of simpsons table.

To make the entities move

OK, so here we are, the answer to your initial question.

This is the syntax to make something move:

< entity > < movement_function> ( < movement_paramaters>, < time>, < acceleration>, < deceleration>);

< entity>: the entity that you want to make move.
< movement_function>: one of the many functions allowing movement tricks in COD, we will see them later.
< movement_paramaters>: according to the function, it is a number of units, an angle, or a vector.
< time>: time what will take the entity to achieve the required movement.
< acceleration>: optional parameter, which indicates for how long the required movement is in phase of acceleration.
< deceleration>: optional parameter, which indicates for how long the required movement is in phase of deceleration.
*IMPORTANT NOTE*
< acceleration> + < deceleration> must be lower or equal to < time>, if not script will crash.

Various functions of movement

In what follows, < vector> is in this form:
(X , Y, Z) Which are you co-ordinates on the map


moveto (< vector>, < time>, < accel>, < decel>)
Moves to the position specified < vector>.

Examples:

simpson moveto ((100,200,300), 1); // will move simpson to the co-ordinates (100,200,300)

simpson1 moveto (simpson2.origin, 1); // will move simpson1 to the same place simpson2 is


movex (< units>, < time>, < accel>, < decel>)
Moves along the specified X axis (< units>, 0, 0) from the current co-ordinates.

Example:

simpson movex ( 10, 1); // will move simpson +10 units on the x axis.


movey ( < units>, < time>, < accel>, < decel>)
Moves along the specified Y axis (< units>, 0, 0) from the current co-ordinates.

Example:

simpson movey ( 20, 1); // will move simpson +20 units on the y axis.


movez ( < units>, < time>, < accel>, < decel>)
Moves along the specified Z axis (< units>, 0, 0) from the current co-ordinates.

Example:

simpson movez ( 30, 1); // will move simpson +30 units on the axis of Z.


movegravity ( < vector>, < time>)
Moves according to a during < time> seconds (complying with the rules of physics). The force of launching depends on the length of the vector.

Example:

simpson movegrativy ( (0,0,100), 2); // will launch simpson into the air 100 units at a physically calculated speed so that simpson will stop have stopped moving after 2 seconds


rotateto (< vector>, < time>, < accel>, < decel>)
Rotation according to 3 axis' (X, Y, Z). Add the angles to the entity.

Examples:

simpson rotateto ( (0, 0, 90), 1); // will make simpson rotate 90 degrees from simpsons angle of origin.

simpson rotateto ( (10, 20, 30), 1); // will add 10, 20 and 30 degrees respectively on, the X, Y and Z axis of the entity simpson.


rotateyaw ( < angle>, < time>, < accel>, < decel>)
To add < angle> degrees on the axis "yaw ".


rotatepitch ( < angle>, < time>, < accel>, < decel>)
To add < angle> degrees on the axis "pitch".


rotateroll ( < angle>, < time>, < accel>, < decel>)
To add < angle> degrees on the axis "roll".


rotatevelocity ( < vector>, < time>)
Rotates an entity degrees per second for a specified time

Latest Syndicated News

»
Codutility.com up and runn...
Nice, and there still using the logo and template for the screenshots, which...
Codutility.com up and runn...
dundy writes...Quote:Call of Duty modding and mapping is barly alive only a ...
Codutility.com up and runn...
Mystic writes...Quote:It seems to me the like the site is completely dead? ...
Codutility.com up and runn...
It seems to me the like the site is completely dead?

Partners & Friends

»