Creating a script

From MyGamingTalk
Jump to navigation Jump to search

Run the game and load the map you wish to create script for.

Open the console and type the following:

   /bot makemapgm

This will create file "<mapname>.gm" in your ~/omni-bot/et/user folder.

You must move file from ~/omni-bot/et/user folder to ~/omni-bot/et/nav folder.

Note: for other games change 'et' to either 'rtcw' 'd3' or 'q4' depending on the game you are running.

Make sure you have backed up any mapname.gm file you may have been working on that exists in the nav folder.

Open the file in a text editor and you will see an extended version of this example.

 
global Map =
{
	Debug = 1, // please set to zero before distributing your script

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

global OnMapLoad = function()
{
	// Register callback functions
	OnTrigger( "MISSING_STRING", Map.Command_Post_Built );

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

	// Max users per goal
	//Util.SetMaxUsers( 1, "DEFEND_.*" );
	//Util.SetMaxUsers( 1, "GRENADE_.*" );
	//Util.SetMaxUsers( 1, "MOUNTMG42_.*" );

	// Camp times
	SetMapGoalProperties( "MOUNTMG42_.*", {MinCampTime=15, MaxCampTime=90} );
	SetMapGoalProperties( "MOBILEMG42_.*", {MinCampTime=10, MaxCampTime=60} );


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

global OnBotJoin = function( bot )
{
	// Uncomment for shootable breakables
	//~bot.TargetBreakableDist = 90.0;
	// Only set MaxViewDistance on maps with limited sight (e.g. fog)
	//~bot.MaxViewDistance = 2400;
};

global InitializeRoutes = function()
{
	MapRoutes =
	{
		BUILD_Command_Post =
		{
		},
	};
	Util.Routes(MapRoutes);
};


Global Map object contains many automatically generated functions related to map. You can add more functions into Map object.

Global function OnMapLoad is executed once when game starts after waypoints and goals are loaded. It is used to register Triggers, create Trigger regions, set goals Availability, Priority, Camp times, Max users.

Global function OnBotJoin is called for each bot once when the bot is added to the game. Property TargetBreakableDist is explained in article Bots shooting map objects. Property MaxViewDistance should be set only if map has fog because it overrides difficulty settings.

Global function InitializeRoutes is explained in article Routing.