Changing spawns

From omni-bot
Revision as of 08:08, 18 August 2015 by Palota (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Spawn points should always be changed in the OnBotJoin function, otherwise they would not work on dedicated servers, because players can join or leave during game.

You need to change spawn points in triggers too. It is recommended to define one function which will be called from both triggers and OnBotJoin.

This example sets spawn point for 50% of allied bots after they have taken the gold. You can adjust number 5 after RandInt if you want more or less bots to use new spawn.

global Map =
{
	TruckLoaded = false,
 
	SetSpawn1 = function(bot)
	{
		if (bot.GetTeam() == TEAM.ALLIES) {
			if (Map.TruckLoaded && RandInt(0,9) < 5) {
				bot.ChangeSpawnPoint(3);
			} else {
				bot.ChangeSpawnPoint(0);
			}
		}
	},
 
	SetSpawn = function()
	{
		foreach(bot in BotTable)
		{
			Map.SetSpawn1(bot);
		}
	},
 
	allies_taking_gold = function( trigger )
	{
		Map.TruckLoaded = true;
		Map.SetSpawn();
	},
};
 
global OnMapLoad = function()
{
	OnTrigger( "Allied team is escaping with the Gold Crates!", Map.allies_taking_gold );
};
 
global OnBotJoin = function( bot )
{
	Map.SetSpawn1(bot);
};