Vehicle Trigger Regions

From MyGamingTalk
Omni-Bot_Map_Scripting Vehicle Trigger Regions


In Omni-bot 0.8 a new version just for detecting Vehicles entering trigger regions was introduced.


The Trigger

A standard AABB trigger region text looks like this:


OnTriggerRegion(AABB(0,0,0,1,1,1),Map.YourTrigger);


For the new version you simply need to edit the section at the end like this:


OnTriggerRegion(AABB(0,0,0,1,1,1), RegionTrigger.VehicleTrigger);


What does this do

When using the new trigger it now sends a message to the console (requires "/bot debugtriggers" to see) saying vehicle name "at location".

Example:

	tank at location
	truck at location

Creating a new trigger

This next section works the same way as normal trigger text

Example

 
	OnTrigger( "tank at location", Map.vehicle_at_location );
	OnTrigger( "truck at location", Map.vehicle_at_location );


In the example there are triggers for both a truck & a tank pointing to the same trigger function "vehicle_at_location" this is because of how the next trigger function works. It does not matter if you just have 1 tank or both a tank & a truck all that matters is that the vehicles reach the trigger regions in order.


The Trigger Function

Within the new trigger function you need to setup a "switch(Map.VehicleLocation)" table. Within the table you setup a series of case's i.e. case 1, case 2 etc.


Each time the vehicle(s) enter a trigger region the "VehicleLocation" is updated so the 1st time the vehicle a trigger region is goes to case 1 & the 2nd to case 2 etc.


Within the case series you can add any scripting command such as "SetAvailableMapGoals" or make it run another standard trigger "Map.tank_at_barrier1();"

 
vehicle_at_location = function( trigger )
	{
		switch(Map.VehicleLocation)
		{
			case 1:
			{
				SetAvailableMapGoals( TEAM.AXIS, true, "MOUNT_tank_axis" );
				Map.tank_at_barrier1();
			}
			case 2:
			{
				Map.truck_at_barrier2();
			}
		}
		Util.MapDebugPrint("vehicle at location " + Map.VehicleLocation, true);
	},


Example Script

This is a edited cut down version from goldrush

 
global Map =
{
	tank_at_barrier1 = function()
	{
		Util.MapDebugPrint("tank_at_barrier1");
	},

	truck_at_barrier2 = function()
	{
		Util.MapDebugPrint("truck_at_barrier2");
	},

	vehicle_at_location = function( trigger )
	{
		switch(Map.VehicleLocation)
		{
			case 1:
			{
				SetAvailableMapGoals( TEAM.AXIS, true, "MOUNT_tank_axis" );
				Map.tank_at_barrier1();
			}
			case 2:
			{
				Map.truck_at_barrier2();
			}
		}
		Util.MapDebugPrint("vehicle at location " + Map.VehicleLocation, true);
	},
};

global OnMapLoad = function()
{
	OnTrigger( "tank at location", Map.vehicle_at_location );
	OnTrigger( "truck at location", Map.vehicle_at_location );

	OnTriggerRegion(AABB(660.253,828.462,59.548,960.874,1040.700,173.040), RegionTrigger.VehicleTrigger);
	OnTriggerRegion(AABB(480.061,-720.472,-332.313,634.705,-478.740,-222.440), RegionTrigger.VehicleTrigger);

	print( "Omni-bot map script for " + GetMapName() + " executed." );
};