5.6 Messages/Objectives

Display Objectives
This section will describe how to make the objectives that are displayed in the "O" window that tell you what your mission objectives are.

The script command to manipulate objectives is called "DisplayObjective". All of the following lines would be placed inside an Action scope.

To add a new display objective:


DisplayObjective("Add", "[name of display objective]")
{
 Text("[text that will be displayed]");
}


"name of display objective" is the name you are giving the objective as far as the script is concerned (won't be displayed in game). "Text" is what is displayed in the "O" window.

To make an Objective complete:


DisplayObjective("Complete", "[name of display objective]");

This will change the color of the objective text in the "O" window indicating the objective has been completed.

To remove an Objective:


DisplayObjective("Remove", "[name of display objective]");

This will remove the objective text from the "O" window.

Below is an example of the DisplayObjective command in a complete objective.


CreateObjectType("objective_destroy_base", "Objective")
{
 GameObj();
 ObjectiveObj()
 {
   Condition("TRUE");
   Action()
   {
     DisplayObjective("Add", "destroy_enemy_base")
     {
       Text("Destroy the enemy base before they can fortify");
     }
   }
 )
}


Game Messages
Game messages are used to display a message in the upper left area of the screen, and also to play sound events. In DR2, game messages were seldom used to display a message on the screen (design decision), and almost exclusively used to play sounds.

The use of game messages requires an additional .cfg file, and an inclusion of that file in types_mission.cfg. Create a text file called "types_game_messages.cfg" and put it in your mission folder. Open your types_mission.cfg. Add the line:


# include "types_game_messages.cfg"



and save. types_game_messages.cfg is the file where you configure each game message, which will later be called by your main script. The following shows how to configure each type of game message. Each message you configure needs to have a unique name.

Playing a sound (you can specify a .wav or .mp3. If you're using custom sounds, drop the sound file into your mission folder)


ConfigureGameMessage ("[message name]")
{
 Interval()
   {
     Type("Interval::None");
   }
   Sound()
   {
     Type("Sound::Stream");
     Add("[sound file name]");
   }
 Message();
}


Displaying a message
ConfigureGameMessage("[message name]")
{
 Interval()
 {
   Type("Interval::None");
 }
 Sound();
 Message()
 {
   Type("Message::Console");
   Add("[Message text that will be displayed]");
 }
}


Play a sound and display message simultaneously.
ConfigureGameMessage("[message name]")
{
 Interval()
 {
   Type("Interval::None");
 }
 Sound()
 {
   Type("Sound::Stream");
   Add("[sound file name]");
 }
 Message()
 {
   Type("Message::Console");
   Add("[Message text that will be displayed]");
 }
}


The command to make the Game Messages play will be executed in your mission script (such as objectives_player.cfg or objectives_ai.cfg) in an action scope. See below.
CreateObjectType("[objective_name]", "Objective")
{
 GameObj();
 ObjectiveObj()
 {
   Condition("[type]")
   {
     [condition];
   }

   Action()
   {
     GameMessage()
     {
       Message("[message name]");
     }
   }
 }
}



Location/Region Messages
Location messages are similar to game messages, except they are used to mark areas on the map. Most commonly used in singleplayer to create the flashing rings on the minimap that show where your next objective is.

Region messages are also configured in the file types_game_messages.cfg (if you haven't made this file, do so now and include it in types_mission.cfg). Here's the configuration for a location message (it doesn't specify much info, but it needs to be there. You can attach a sound or message if you want)


ConfigureLocationMessage("[message name]")
{
 Interval()
 {
   Type("Interval::None");
 }
 Sound();
 Message();
}


Location messages for the minimap usually use a repeating objective like the one below. Look at the Action scope. After the RegionMessage is played, it gives a NewObjective command that re-loads the objective. Since the Condition is a timer of 1.5 seconds, the RegionMessage will be played every 1.5 seconds (creating continual blips on the mini map).
CreateObjectType("location_message1", "Objective")
{
 GameObj();
 ObjectiveObj()
 {
   Condition("Timer")
   {
     Time(1.5);
   }

   Action()
   {
     RegionMessage()
     {
       Region("[region name]");
       Message("[message name]");
     }
     NewObjective("location_message1");
   }
 }
}



"Region" is the name of the region at which the circular blip will be shown on the minimap. Create a reagion at the location to mark. "Message" is the message name to play (name of location message you configured in types_game_messages.cfg)

Note that the above objective is an infinite loop, once loaded it would never stop. If you want the location message to stop playing (i.e. when the player gets there!), you'll need to use a handy command called ObjectiveAbandoned. ObjectiveAbandoned will unload any objective that is currently loaded and remove it from the game's memory. See below example


CreateObjectType("stop_location_message1", "Objective")
{
 GameObj();
 ObjectiveObj()
 {
   Condition([type])
   {
     [condition];
   }

   Action()
   {
     ObjectiveAbandoned("[objective name]");
   }
 }
}