Objectives, triggering: Difference between revisions

From The DarkMod Wiki
Jump to navigationJump to search
Obsttorte (talk | contribs)
A basic setup for changing things in-game depending on objectives.
 
Line 2: Line 2:
== Description ==
== Description ==


Sometimes a map requires it, that after the completion of one or more objectives something in the map changes. The example I'll use here is the appearing of an entity/model in the map. Anyway, this method can be used for other things, too.
Sometimes a map requires that, after the completion of one or more objectives, something in the map changes. The example I'll use here is the appearance of an entity in the map. This method can be used for other things, too.


== Basics ==
== Basics ==

Revision as of 19:10, 2 January 2013

Description

Sometimes a map requires that, after the completion of one or more objectives, something in the map changes. The example I'll use here is the appearance of an entity in the map. This method can be used for other things, too.

Basics

The first thing to know is what possibilities you get with the objectives editor (OE). There are four fields in there that are interesting here. They are the success/failure target/script fields. These are the targets that get triggered or the script functions that get called, once the objective was successful or failed. Normally you wont use them very often, if even, but they are quiete useful.

Example: Let an object appear when an objective is completed

The first thing you have to do is to set up the object you want to appear once the player has finished an objective. After you've done so, set its name to object, than go to the specific objective in the OE, and typ in the success script field showObject.

Now create a script file in your maps folder called mymapname.script, where mymapname.map is the name of your map. Type in the following code:

 void showObject() {
   $object.show();
 }
 void main() {
   $object.hide();
 }

That's it. The main method is called upon map start and let the object dissapear from game. When your desired objective is completed, the method showObject is called, what let the object appear again.

Making things more complex

Of course you can use a more complex setup if needed. Let's assume you want the object to appear after a certain amount of objectives has been completed. To achieve this, create a trigger_count and a target_callscriptfunction entity. Fill the success target field of all the possible or required objectives with the name of the trigger_count. On this entity set the spawnarg "count" "N", where N is the number of objectives that must be completed and let it target the target_callscriptfunction entity. On the latter, set the spawnarg "call" "showObject". That's it.

How does it work?

Once an objective is complete, it will trigger the trigger_count entity. The counter goes up and gets compared with the spawnarg "count". Once it reaches this, it will trigger the target_callscriptfunction, which than calls the function to let the object appear in-game.

Hint: All the success script fields stay empty, the function is NOT called by any objective directly

--Obsttorte (talk) 08:41, 2 January 2013 (EST)