5.5 More Scripting Basics and Examples

The following section will provide more help on how to do the most common things that a single player mission requires that weren't covered in the previous tutorial. It is by no means comprehensive, and is only to provide some extra help and examples.

Condition Types
Condition Types followed by an example.

TRUE - Condition becomes true when objective loaded


CreateObjectType("[objective name]", "Objective")
{
 GameObj();
 ObjectiveObj()
 {
   Condition("TRUE");
   Action()
   {
     [action];
   }
 }
}


FALSE - Condition always false, will never trigger action. Used only for testing (if you want to disable an action). Same usage as TRUE.

NOT - See following example. Within the NOT condition is another condition running an InRegion check. In this case, we are testing to see when a particular object is NOT in that region. The action would be triggered as soon as the tag "juggernaut" left the region. NOT can be used with any Condition Type.


CreateObjectType("[objective name]"), "Objective")
{
 GameObj();
 ObjectiveObj()
 {
   Condition("NOT")
   {
     Condition("InRegion")
     {
       Region("JDA_base");
       Tag("juggernaut")
       {
         Amount(0);
         Operator(">");
       }
     Team("JDA");
     }
   }
   Action()
   {
     [action];
   }
 }
}


AND - Requires two sub-conditions to become true before executing the Action scope. In this example, both the TagCount and InRegion checks have to become true to make the entire condition true
CreateObjectType("[objective name]", "Objective")
{
 GameObj();
 ObjectiveObj()
 {
   Condition("AND")
   {
     Condition("TagCount")
     {
       Tag("players_units")
       {
         Operator("==");
         Amount(0);
       }
     }
     Condition("InRegion")
     {
       Region("goal");
       Tag("players_units")
       {
         Amount(0);
         Operator(">");
       }
       Team("player");
     }
   }
   Action()
   {
     [action];
   }
 }
}


OR - Condition will become true if ANY sub-conditions become true. In this example, if either the TagCount OR the InRegion check become true, the entire condition will be true.
CreateObjectType("[objective name]", "Objective")
{
 GameObj();
 ObjectiveObj()
 {
   Condition("OR")
   {
     Condition("TagCount")
     {
       Tag("players_units")
       {
         Operator("==");
         Amount(0);
       }
     }
     Condition("InRegion")
     {
       Region("goal");
       Tag("players_units")
       {
         Amount(0);
         Operator(">");
       }
       Team("player");
     }
   }
   Action()
   {
     [action];
   }
 }
}


TIMER - Condition becomes true after the specified time has elapsed (in seconds).

(note: if you enter two values in the Time() line, i.e. Time(60,120), it will trigger at a random time between those intervals)


CreateObjectType("[objective_name]", "Objective")
{
 GameObj();
 ObjectiveObj()
 {
   Condition("Timer")
   {
     Time(60);
   }
   Action()
   {
     [action];
   }
 }
}


These are the most common condition types, but there are several more that are handy. See the DR2 Technical Reference Manual for more info.