Availability

From omni-bot
Omni-Bot_Map_Scripting Enabling & Disabling Map Goals


Finding Mapgoal names

There is more then 1 way to find out the MapGoal name, here are a few examples.

Method 1

Stand next to the mapgoal (say the command post) open the console & type

/bot sgn 200

This will list all mapgoals within 200 units of your position in console.


Method 2

Open console & type:

/bot show_goals

This will give you the full list of all the mapgoals.


Method 3

Open console & type

/bot makemapgoallist

This save a list of all map goals into file mapname_goals.gm. You can find this in your ~omni-bot\et\user folder.


Disabling Goals

When the map starts all mapgoals are active so the 1st thing to do is disable mapgoals that we don't want the bots to do at the start of the map. A good example is defending bots will go and build the command post, in some maps is fine to build the command post but on many maps it can be some distance away and you would not want the bots to go and build it.

Way 1

The 1st way to do this is by setting the mapgoal to false.

In your script locate where you have just added the trigger text, under this section there will be 3 example lines that look like this:

 
	//~Util.DisableGoal( ".*", true ); // all but routes
	//~SetAvailableMapGoals( TEAM.AXIS, true, "ATTACK_.*" );
	//~SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_.*" );


Ignore this 1st line for now that will be explained later & look at the 2nd/3rd line. The 1st 3 (//~) letters can also be ignored as well they just stop the lines from being read in the script.

Now you need to find out the actual name of the goal.

For this example we are going to use this mapgoal name "BUILD_Axis_Command_Post".

A good place to add this the line under the examples.

This is how you would disable axis from building the command post


 
	SetAvailableMapGoals( TEAM.AXIS, false, "BUILD_Axis_Command_Post" );


Way 2

There is a 2nd way to do this and that is to disable all the map goals (except routes) at the start. This can be the better option when you have added a few goals, then you only have to enable the goals you want active instead of having to deactivate all the goals you don't want.

In the OnLoadMap there is a line you ignored in the last example, this time were are going to use it. Simply remove the "//~"

 
	Util.DisableGoal( ".*", true ); // all but routes


This will now disable all goals for both teams.


Wildcards

The wildcard ".*" is used to select all goals it can also be used to after a mapgoal type such as "PLANT" like this:

	SetAvailableMapGoals( TEAM.AXIS, false, "PLANT_.*" );


Note: Because there are 2 goals starting with "PLANT" (PLANT & PLANTMINE goal) the underscore should be used after the word PLANT so it only enables The Plant goals and not the Plantmine goal.

Enabling Goals

Now we want to enable some mapgoals for this example we are going to activate the "PLANT_Main_Entrance" and for this you just need to use the "SetAvailableMapGoals" command but this time using true. If you have disabled the goals using using the 1st way you don't have to enable the goals as they will be still enabled.

 
global OnMapLoad = function()
 
{
        OnTrigger( "Allies have destroyed the main entrance", Map.Main_Entrance_Destroyed );
 
	Util.DisableGoal( ".*", true ); // all but routes
	SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Main_Entrance" );
};


Trigger Functions

Once you have enabled/disabled the goals you want active at the start of the map you need to look at the mapgoals you want enabled/disabled when events happen in the map.

You now need to look at the trigger functions in "Global Map"

For this the allies have destroyed the main entrance so this if you added the correct trigger text the script will to go to the "Main_Entrance_Destroyed" trigger function in the Global Map.

We want to now disable the "PLANT_Main_Entrance" goal & enable a new goal "PLANT_Big_Gun" for allies & enable a mounted mg emplacement for axis "MOUNTMG42_North". As with the "Global OnLoadMap" section you just have to use the "SetAvailableMapGoals" command.

 
global Map =
{
	Main_Entrance_Destroyed = function( trigger )
	{
	        SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Main_Entrance" );
	        SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Big_Gun" );
	        SetAvailableMapGoals( TEAM.AXIS, true, "MOUNTMG42_North" );
 
		Util.MapDebugPrint( "Main_Entrance_Destroyed" );
	},
};
 
global OnMapLoad = function()
{
        OnTrigger( "Allies have destroyed the main entrance", Map.Main_Entrance_Destroyed );
 
	Util.DisableGoal( ".*", true ); // all but routes
	SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Main_Entrance" );
};