Scripting : How To show triggered units.
By: Wolfsong
Published :24 November 2006


This scripting tutorial by Wolfsong explains how to show units triggered by player in a zone using example XML code.

Items needed from map editor:
- 1x area (I called it area_intel)
- 1x human (I called the group intel_group01)

Define A Trigger Zone For Player (place in beginning of script_data, after include)

<area_group name="area_intel" area_name="area_intel" group_id="friendly1" interval="0.3" condition="1"/>

name  What you call it (use same as area_name)  
area_name Name given to area in editor
group_id Who can trigger it? ("friendly1" == mitchell/server,
"mp_players" == all players MP,
"players" == all ghosts SP/MP,
or any group_id set for a human/humans in the map editor)
interval Seconds between checks
condition  How many from group_id is needed? 

NOTE: If you want a vehicle to trigger an area just replace group_id with vehicle_id and enter the name of the vehicle as defined in the map editor. You also have to remove the condition variable. Like in this example:

<area_group name="area_intel" area_name="area_intel" vehicle_id="my_tank" interval="0.3"/>

Activate Trigger Zone
(place in an event, example in if active from beginning <event name="start_game">)


<element type="UnitInArea" area="area_intel" state="activate" start_time="1.0"/>

type what action to take, UnitInArea check selected
area ok, which UnitInArea check?, area_group defined earlier
state what to do with it?, activate/deactivate
start_time when?, seconds delay after event executed

Create Trigger For Player In Zone

<user name="area_intel" type="once">
<trigger type="UnitInArea" area="area_intel"/>

Define trigger/condition to run

type what will trigger it? ("UnitInArea == zone trigger)
area which defined area_group?

<event name="show_area_intel"/>

What will happen?

name event to run if trigger ok

</user>

Create Event To Run When Zone Is Triggered

<event name="show_area_intel">

name name to call to run event

<element type="DebugString" msg="show_area_intel" start_time="0.0"/>
Feedback in debug mode

type gives message in debug mode
msg message shown
start_time delay in seconds

<element type="UnitInArea" area="area_intel" state="deactivate"/>
Prevents zone being activated again by deactivating it

type what action to take, UnitInArea check selected
area which UnitInArea check?, area_group defined earlier
state activate/deactivate

<element type="ActivateGroup" group_id="intel_group01" start_time="0"/>
Activate group of humans, make them visible and start their given actions

type what action to take, "ActivateGroup"
group_id ok then, which group?
start_time when?, seconds delay after event executed

(add as many elements as you want, all executes when "show_area_intel" in run)
</event>

And the clean XML code with only overview comments:

<!-- Define A Trigger Zone For Player (place in beginning of script_data, after include)-->
<area_group name="area_intel" area_name="area_intel" group_id="friendly1" interval="0.3" condition="1"/>

<!-- Activate Trigger Zone (place in an event, example in if active from beginning <event name="start_game">)-->
<element type="UnitInArea" area="area_intel" state="activate" start_time="1.0"/>

<!-- Create Trigger For Player In Zone -->
<user name="area_intel" type="once">
<trigger type="UnitInArea" area="area_intel"/>
<event name="show_area_intel"/>
</user>

<!-- Create Event To Run When Zone Is Triggered -->
<event name="show_area_intel">
<element type="DebugString" msg="show_area_intel" start_time="0.0"/>
<element type="UnitInArea" area="area_intel" state="deactivate"/>
<element type="ActivateGroup" group_id="intel_group01" start_time="0"/>
</event>

 


© GhostRecon.net