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

Members Online

»
0 Active | 74 Guests
Online:

LATEST FORUM THREADS

»
CoD: Battle Royale
CoD+UO Map + Mod Releases
Damaged .pk3's
CoD Mapping
heli to attack ai
CoD4 SP Mapping

Forums

»

Welcome to the MODSonline.com forums. Looking for Frequently Asked Questions? Check out our FAQs section or search it out using the SEARCH link below. If you are new here, you may want to check out our rules and this great user's guide to the forums and the website.
For more mapping and modding information, see our Wiki: MODSonWiki.com

Jump To:
Forum: All Forums : Call of Duty
Category: CoD Mapping
CoD mapping and level design.
Moderators: foyleman, Foxhound, Mystic, StrYdeR, batistablr, Welshy, DrBiggzz, supersword
Latest Posts
Subscribed Posts
Search
Restricted Access Topic is Locked subscribe
Author Topic: New Tutorial *SCRIPTING*
StrYdeR
General Member
Since: May 11, 2004
Posts: 11672
Last: Apr 20, 2024
[view latest posts]
Level 10
Admin
Forum Moderator
Im a HOST of MODSonair
Category: CoD Mapping
Posted: Sunday, Jul. 4, 2004 09:19 pm
You can also read this in the tutorials section - and it easier to follow there

Getting Started In Scripting (Moving Things)

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 .

Example:

simpson rotatevelocity ( (0, 0, 90), 10); // makes the entity simpson rotate 90 degrees per seconds on the axis of Z, for 10 seconds.

To wait for the end of the movement

To wait a specific number of seconds for the movement to end:
wait (< time >);

If that is not feasible, to wait for the real end of the movement:

< entity > waittill ("rotatedone”);
if the movement is a rotation

< entity > waittill ("movedone”);
if the movement is a displacement

A small example: a door which slides

For a practical exercise, we will make a door which slides vertically (upwards).
In this example, we will not try to do something reusable, therefore we will use getent () instead of getentarray ().

1) MAPPING

Create a script_brushmodel for the door, keep in mind to include a brush origin inside; give it the “targetname” "slide".
Create a trigger_use (with textures/common/trigger and give it the “targetname” "slider_trigger ".

2) SCRIPTING

Here is the script, and, having read all that precedes you should be able to include/understand how it goes.
main()
{
thread door_slider ();
}

door_slider ()
{
door = getent ("slide ", "targetname”);
trig = getent ("slider_trigger ", "targetname”);
while (1)
{
trig waittill ("trigger");
door movez (80, 2, 0, 0.5);
door waittill ("movedone”);
wait (4);
door movez (-80, 2, 0, 0.5);
door waittill ("movedone”);
}
}

StrYdeR
I would like to thank Valoche for laying down the groundwork for this tutorial


This is also up in the tutorial section and is easier to follow[angryalien] Getting Started In Scripting (Moving Things)
Share |
locz
General Member
Since: Feb 4, 2004
Posts: 105
Last: Jul 7, 2006
[view latest posts]
Level 4
Category: CoD Mapping
Posted: Sunday, Jul. 4, 2004 10:43 pm
i did not get a chance to read this due to the fact that i have to head out and do some stuff...but man thanks for this tutorial...i know alot of ppl will really appreicate it...good work!!! [twoguns]

Share |
Shotgun
General Member
Since: Feb 4, 2004
Posts: 50
Last: Oct 4, 2004
[view latest posts]
Level 2
Category: CoD Mapping
Posted: Tuesday, Jul. 6, 2004 01:54 am
You could also look at Shotguns Rooms, i just uploaded it, its got doors, bombs, lifters, music for each room, starting scripts on entry of rooms and more, all with scripts, map file, watch the mortor room doesn't get ya...

damn good tutorial though, thanks
Share |
StrYdeR
General Member
Since: May 11, 2004
Posts: 11672
Last: Apr 20, 2024
[view latest posts]
Level 10
Admin
Forum Moderator
Im a HOST of MODSonair
Category: CoD Mapping
Posted: Tuesday, Jul. 6, 2004 03:52 am
thank-you ...this is more to teach people how to script - instead of copy and paste [angryalien]
Share |
Restricted Access Topic is Locked subscribe
MODSonline.com Forums : Call of Duty : CoD Mapping

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

»