Scripting : Mission Objectives And The GUI
By: Wolfsong
Published :27 November 2006


In the second of his scripting series Wolfsong shows how to code Mission Objectives and have them display in the user interface.

Mission Objectives In The User Interface

NOTE: You can add as many elements as you want in these events. Everything you want to happen when the objective starts and ends should be put into these events.


Create Event To Add A Mission Objective To The GUI

<event name="add_objective1">

name Add Objective Info

<element type="Objective" id="objective1" headline_id="my_mission_head_obj1" txt_id="my_mission_txt_obj1" state="add" mode="1" start_time="1.0/>

type define that you're dealing with an objective
id name for this element inside the script, used for deactivating and changing info
headline_id which string entry to show as headline for objective, example "Search and destroy ADA unit"
txt_id which string entry to show as description text for objective, example "Search and destroy the mobile ADA unit. Use your C4 or other explosives to neutralize it."
state what you want to do with the objective? add/remove
mode keep this set to 1
start_time when to show it?, seconds delay after event executed

Add Objective CrossCom Marker
<element type="Objective" id="objective1_wp" waypoint_id="my_mission_wp_obj1" state="add" waypoint="10171.8555 -9296.7939 106.4334" mode="1" start_time="3.0"/>

type define that you're dealing with an objective
id name for this element inside the script, used for deactivating and changing info
waypoint_id which string entry to show as name tag for marker
state what you want to do with the objective? add/remove
waypoint x,y,z coordinates on map to place it
start_time when to show it?Seconds delay after event executed

</event>

Create Event To Update A Mission Objective On The GUI
<event name="update_objective1">
Update Objective Info

<element type="Objective" id="objective1" headline_id="my_mission_head2_obj1" txt_id="my_mission_txt2_obj1" state="add" mode="1" start_time="3.0"/>

type define that you're dealing with an objective
id define which objective you want to work with, same as id when you created it
headline_id which string entry to show as new headline for objective, example "Get a move on, Search and destroy ADA unit"
state what you want to do with the objective? add/remove, use add when updating
txt_is which string entry to show as new description text for objective, example "Search and destroy the mobile ADA unit. Use your C4 or other explosives to neutralize it. The ADA is on the move!"
mode keep this set to 1
start_time when to update it?, seconds delay after event executed

Create Event To Remove Mission Objective From The GUI
<event name="remove_objective1">
Remove Objective CrossCom Marker

<element type="Objective" id="objective1_wp" state="remove" mode="1" start_time="0.0"/>

type define that you're dealing with an objective
id define which objective you want to work with, same as id when you created it
state what you want to do with the objective? add/remove
mode keep this set to 1
start_time when to remove it?Seconds delay after event executed

Remove Objective Info
<element type="Objective" id="objective1" state="remove"/>

type define that you're dealing with an objective
id define which objective you want to work with, same as id when you created it
state what you want to do with the objective? add/remove

Add Next Objective
</event>


And the clean XML code with only overview comments:

Adding A Mission Objective To The GUI

<event name="add_objective1">
<element type="Objective" id="objective1" headline_id="my_mission_head_obj1" txt_id="my_mission_txt_obj1" state="add" mode="1" start_time="1.0/>
<element type="Objective" id="objective1_wp" waypoint_id="my_mission_wp_obj1" state="add" waypoint="10171.8555 -9296.7939 106.4334" mode="1" start_time="3.0"/>
</event>

Update A Mission Objective On The GUI

<event name="update_objective1">
<element type="Objective" id="objective1" headline_id="my_mission_head2_obj1" txt_id="my_mission_txt2_obj1" state="add" mode="1" start_time="3.0"/>
</event>

Removing A Mission Objective From The GUI
<event name="remove_objective1">
<element type="Objective" id="objective1_wp" state="remove" mode="1" start_time="0.0"/>
<element type="Objective" id="objective1" state="remove"/>
</event>


NOTE: The creation of marker and info can all be done in one go!

<element type="Objective" id="objective1" headline_id="my_mission_head_obj1" txt_id="my_mission_txt_obj1" waypoint_id="my_mission_wp_obj1" state="add" waypoint="23432.975 26290.469 -1044.3226" mode="1" start_time="1.0"/>

But as you can see there is no id for just the marker defined, which gives that you can't just update the waypoint if you need to. It's all in one big package.

On the other hand your marker will get deleted with your info, using only one element.

<element type="Objective" id="objective1" state="remove"/>

So it depends on the type of objective you have which way to deal with the user interface.


The Strings
There was a few string entrys used in these scripts. These are found in the strings/mission.xml.
in our case it would be a short file like this:


<stringset>
<string id="my_mission_briefing" value="Get to it."/>
<string id="my_mission_head_obj1" value="Search and destroy ADA unit"/>
<string id="my_mission_txt_obj1" value="Search and destroy the mobile ADA unit. Use your C4 or other explosives to neutralize it."/>
<string id="my_mission_wp_obj1" value="ADA location"/>
<string id="my_mission_head2_obj1" value="Get a move on, Search and destroy ADA unit"/>
<string id="my_mission_txt2_obj1" value="Search and destroy the mobile ADA unit. Use your C4 or other explosives to neutralize it. The ADA is on the move!"/>
</stringset>

Notice that the mission briefing text is also in this file. wink.gif

 



 

 

 


© GhostRecon.net