PlayerIsBot

bool PlayerIsBot (int playernumber)

Usage

Returns TRUE if the player [0..7] is a bot and FALSE if not.

Examples

Giving a vital piece of puzzle or ability to a player could cause the game to become impossible if it is given to a bot rather than a human. This command can protect against such an issue. For example:

script 55 (void)
{
	int marine = Random(0, PlayerCount());
	
	while (PlayerIsBot(marine))
		// Pick another marine
		marine = Random(0, PlayerCount()); 
	
	SetActorProperty(1000 + marine, APROP_INVULNERABLE, TRUE);
	
	PrintBold(n:marine+1, s:" is totally invulnerable!");
}

script 1000 ENTER
{
	Thing_ChangeTID(0, 1000 + PlayerNumber());
}

Script 1000 just gives the players TIDs, in sequence 1000, 1001, 1002, etc. Script 55 is the important one here. First it sets marine to be the number of one of the players. However, if it picks a bot, it keeps picking a new number until it picks a non-bot player. Once it has a human player, it makes them totally invulnerable and reports to the other players that this is so.

This article is issued from Zdoom. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.