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

Members Online

0 Active | 162 Guests


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


CoD Mapping
Awful Rating
Poor Rating
Average Rating
Good Rating
Excellent Rating
Retreive the Documents Objective
Versions: You must be logged in to view history.
kainfury shows you how to add a retreive the documents type of objective to your sp map

Creating a "Get the documents" Objective in a Single Player Map

by kainfury (kainfury@hotmail.com)

Thanks to Avatar, Sumaleth and Boco for this one

Creating a "Get the documents" objective in a SP map is fairly easy, once you've understood how the scripting language works.

So, in this tutorial, we'll create an objective where the player will have to get enemy documents. Once the docuemtns will be taken, the objective will be completed.

So, let's go step-by-step.

A.Creating a small map

Create a small map. What I did is make 2 rooms, which are connected by a corridor.

The player will start in one room, and get the documents in the second one. I made 2 rooms, because we'll be able to see the objective on the compass later on.

B.Making a crate or a table where the documents will be placed

Documents rarely lay on the floor (unless you're messy as I am). So what we'll do in this tutorial, is create a crate on which the documents will be placed. It could be also a table, or whatever you might think of; use your imagination.

Don't make the crate too high (in this map, the crate is 40 units high), so the player can see the documents.

C. Placing the documents on the crate

If you have scorpio's cod.def, goto part a.

If you have no idea of what the hell i'm talking about, goto part b.

a. If you have installed Scorpio's cod.def (which allow you to choose most of the models from that menu):

You will now have to place the documents on the crate. To do so, on the grid, click on the right-mouse button: a menu will appear.

1. Scroll down the list, until you see: xmodel-cuments1

2. If you click on this option, another menu will open, with only 1 option: objective.
You will now see a model of a document (which will glow yellow in the game).

3. Select that.

4. With the documents still selected, press N; the entity editor will appear.

For now, you'll see 2 entries for that entity: classname = xModel-cuments1_objective and
model = xmodel/documents1_objective.

5. Now, the classname here is wrong: you will have to change it to: script_model.classname = script_model

A script model is like a static model (misc_model), only you might influence its behavior with a script.
Now, jump to part c.

b. If you haven't installed Scorpio's cod.def

You will now have to place the documents on the crate. To do so, on the grid, click on the right-mouse button: a menu will appear.

1. Select the option script

2. You now have 4 options: choose model.

We want to create a script_model here. A script model is like a static model (misc_model), only you might influence its behavior with a script.

3. As soon as you choose the model option, a window will open, asking you to select a model file. Enter whatever as a filename (ex.: aaaaaaaa ) ; we'll get the model by another way.

You now have a red square on your map that says: script_model

4. Now, with this square selected, press N. This will open the entity editor. For now, you will see 2 entries for that entity: classname = scriptmodel and model = maps/aaaaaaaa

5. You will have to change the model name. Change it's value to: model = xmodel/documents1_objectiveYou will now see a model of a document (which will glow yellow in the game).

c. Setting up the documents script_model

1. Select the documents script_model, and press N to bring up the entity editor

You will now have to give a targetname to the documents.
A targetname is a unique name that defines the model, so it can be linked to another entity later on.

We already have:

1. The model (xmodel/documents1_objective)
2. The classname (script_model)

Now, give a targetname to the documents. in this example, i've given it the targetname of "logbook" (targetname = logbook)

That's all for the documents.

D. Placing a trigger_use on the documents

You will now have to put a trigger_use on the documents.
A trigger_use is a trigger that changes the behavior of other entites when the player presses the "USE" function near it.

To do so:

1. Click on the right-mouse button to open the menu

2. Choose the option trigger, then Use

3. A small, red box will appear on the map. Now, you have to change the dimensions of the box, so the documents are INSIDE the box. I suggest you make the box bigger than the documents, so the player can be a bit farther than the documents, and still be able to take them.

4. With the box still selected, on the top menu, choose texture, then "common". Look for a dark gray texture written "trig" on it.

Each time you put a trigger in your map, you have to put that texture on it, so the system knows it's really a trigger.

5. With your box still selected, press N, to bring up the entity editor. You will have to create entries:

1. Delay = 99999999 This is the time it will take before you can use the trigger a second time (note: i'm not sure if this has an impact for this tutorial)

2. Hinstring = Press [Use] to take the documents A hinstring is the message that will show when the player is next to the trigger_use. Always put use between brackets. You can write any message you want.

3. Targetname = take You have to give the trigger_use a targetname, but it can be anything you want

E. Placing a script_origin

Finally, if you want, you can place a script_origin near your documents. This way, the player will see where the objective is located on his compass. If you don't want him to see where it's located, don't use a script_origin.

Placing a script_origin is very easy:

1. Click on the right-mouse button to open the menu, and choose script, then originA small red box will appear on the map.

2. Press N to bring up the entity editor

3. Put targetname = docs It can be whatever targetname you want

4. Put the script_origin near the documents (i normally put it on top of it). Make sure it does not overlap with the trigger_use

That's all for the map! You can now compile it. Now for the scripting...

Open Notepad, and put that script in it. You will see explanations about the different commands.

Once your script is done, save this file as "mymapname.gsc" and put it in the main/maps folder, where your map is located.

Important: The .gsc file has to have the exact same name as your map, otherwise the system won't recognize it.



// Do this at the beginning of all your levels, sets up all the global scripts.


// If we don't take the player's weapons, he'll have the generically assigned ones

level.player takeallweapons();
level.player giveweapon("thompson");
level.player giveweapon("luger");
level.player switchToWeapon("luger");

The last line tells which weapon will be shown in the player's hand at the beginning of the map

iprintlnbold ("Go get the documents at the other side of the corridor.");

//The previous line shows a message on the screen at the start of the game

objective_add(1, "active", "Go get the documents", getent("docs", "targetname").origin);

//The previous line sets up the objective in the game.
// The format is: objective_add(objective number, "active", objective text, origin)

/*Now, in this example, we add an objective (1), that is currently "active" when you press TAB. And the message that will show up when you press TAB is: "Go get the documents".

Finally, we ask the system to put the objective on the compass, which is determined by the script_origin we put in the map earlier. We ask the system to look for it with the command: getent (it means "get entity").

This command is used frequently in scripting. What we do in this example is to ask the system to look for an entity that has the targetname "docs".

In order for the system to put the objective on the compass, you have to put the extension .origin, after the command, like above.*/


This line tells the system that the current objective (which is highlighted in green when you press TAB, is objective // 1.


documents = getent("take", "targetname");

This is a command often used as well in scripting. What it does is simply define the entity with another name. In this example, we tell the system that from now on in the script, when we write "documents", it means that we're talking about the entity that has the
targetname "take" (which is our trigger_use). this way, we will avoid to always write getent("take", "targetname"). */

documents waittill("trigger");

Ok, this command is very important. It tells the system to wait for the trigger (trigger_use in this case, which is now defined as "documents") to be activated before executing the other commands below.

papers = getent("logbook", "targetname");

Here we define the script_model that has the
targetname "logbook" (in this case, our documents model) under the name of "papers", simply to avoid writing getent(blah blah blah) all the time.*/

documents delete();

Ok, now that our trigger_use has been activated, we need to remove it. Otherwise, the message "Press [Use] to take the documents" will still show up, even after the documents are taken.

papers delete();

This command is the same as the other before, but this time we remove the documents model from the game (before the player took them).

objective_state(1, "done");

Finally, once the documents are taken, we tell the system that the objective 1 is done. This will put a checkmark on the objective, if you press TAB, and you<ll see a message that says: objective completed when you play the game.


/*Thats all for this tutorial.

Here are a few notes about scripting:

1. Always make sure your commands are incuded in brackets {}. This will tell the system what is included in the script, otherwise you'll get an error message when you start the game (bad syntax).

2. Always put a semi-colon after each command, otherwise the system will continue reading te next line and will be confused (error: bad syntax or unkown function).

Click Here to download the map and the script for this tutorial

Bodger2 adds:

just wondering why your not using _documents.gsc from the maps folder in pak4.pk3.Since you say you don't have a pick up sound.
_documents.gsc takes care of the sound for you,it also takes care of the hint string for picking them up.Basicly it does the scripting for you,thats why they made it.

But if you are making your own scripting heres a little hint for the sound.

level thread maps_utility::playSoundinSpace("paper_pickup",self.document.origin);

I have a documents objective in a test map I made and I used this,

thread maps_documents::main(2,&"TEST_OBJECTIVE_OBJ2","documents","documents_found");
//(objective_number,&"objective_text", "array_targetname", "activate_notify");

As for the mission complete it depends on how you want to end your level.
I tried one using a trigger once,gave it a targetname then added this after the last objective.

thread end_level();

then the thread

iprintlnbold ("Find the end level trigger!");

mission_over = getent ("end_level_trigger","targetname");
objective_add(7, "active",&"TEST_OBJECTIVE_OBJ7", mission_over getorigin());
mission_over waittill ("trigger");

missionSuccess (true);//works but gives next level on success screen

//missionSuccess ("dawnville", true);//works,loads dawnville as next level on success screen

//This loads the game finished credits
//setcvar("nextmap", "map credits");
//setcvar("g_lastsavegame", "");
//setcvar("beat_the_game", "I_sure_did");

I used a trigger,but there are other ways of ending a level

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