Triggers

From MyGamingTalk
Jump to navigation Jump to search
Omni-Bot Map Scripting Triggers


What is a trigger

A trigger is something that happens in the map. The most common triggers are text triggers & sound triggers. Using the goldrush map as an example, when the 1st tank barrier is blown up you will see this text come up on your screen & in console

Tank Barrier #1 has been destroyed.

This is an example of a text trigger. The next example is of a sound trigger, when the tank is past the barrier you will hear a sound saying "The tank is past the 1st barrier" but this time you will not see any message.

Locating the "MISSING_STRING"

For this part we are only interested in the "global OnMapLoad = function()" section of the script.

You will see in there something like this:

 
	OnTrigger( "MISSING_STRING", Map.Main_Entrance_Destroyed );
	OnTrigger( "MISSING_STRING", Map.documents_Taken );


Now you need to find out what the actual trigger should be to replace the "MISSING_STRING" section of the line.

There are 3 ways you can do this.

1) Copy the text you see in the console. This is not a perfect method because some map makers add colour tags.

2) Open the map PK3 file. A PK3 file is just a Zip file that has been renamed. You can open it in any Zip program. Then locate file <mapname>.script in the maps folder. Extract that file from the archive and open it in your text editor. You need to search the script for text such as wm_announce or wm_teamvoiceannounce.

3) To find the trigger text you need to open the console & type the following command.

    /bot debugtriggers

Now all you need to do is play the map & read the console messages.

Example:

    <---> Trigger: TagName: The Tank has been repaired! Action: announce Entity: (698:1) Activator: (-1:0)

Here we need to use the TagName as the trigger. From this trigger text you just use this section of text

    The Tank has been repaired!

Tip: Rather then coping text from the console you can save it by using the /condump command. Just add a filename after the command

/condump filename.txt

You will then find this in you mod folder (omnibot in this case) called filename.txt or whatever name you have called it.


Note: The maximum supported length is 71 chars. That's why in Marrakesh Streets 2 By Night script you will read:

    ^D***^WAllied team have constructed a command post.  Charge speed incre

One less or one more doesn't work well usually.

Understanding what you have done

Each time something happens in the map such as the allies destroying the main entrance the bots need a way to know this. Replacing the "MISSING_STRING" with actual text that happens in the map will run a command to go to a section in the 'global Map'

Now when the example text of "Allies have destroyed the main entrance" comes up in the game, the command "Map.Main_Entrance_Destroyed" is run, this directs the script to the section in 'global Map' called "Main_Entrance_Destroyed = function( trigger )"


 
global Map =
{
	Main_Entrance_Destroyed = function( trigger )
	{
                //This is where you would add new instructions

		Util.MapDebugPrint( "Main_Entrance_Destroyed" );
	},
};

global OnMapLoad = function()
{
       OnTrigger( "Allies have destroyed the main entrance", Map.Main_Entrance_Destroyed );
};


Command /bot makemapgm is not perfect and you will sometimes need to create extra triggers.

Supported Triggers

Most events in ET will fall into the following Omni-Bot recognized categories:

  • allied_complete
  • allied_default
  • allied_failed
  • announce
  • announce_icon
  • axis_complete
  • axis_default
  • axis_failed
  • defused
  • dynamited
  • exploded
  • faceangle
  • mover_goto x y z
  • moving
  • opened
  • closed
  • opening
  • closing
  • returned
  • stolen
  • team_announce


NOTE: For the returned trigger (i.e. documents returned) use /bot debugtriggers output for when the flag is returned by expiring (no player returns it). If the regular wm_announce message is used, the event that occurs when the flag expires will not be used. It is recommended to manually steal the flag, /kill and wait for them to be automatically returned. An example can be found in radar.gm. Most of the time it will be something like "Flag returned flag!"