There probably will come a time when you want to make a single player version of your mod that will require bots. In this section, when we refer to a single player game we are speaking of a team based game where you are a member of a team and all (or most all) the other players are bots. This type of game is also referred to as a skirmish game in deference to the script command that starts the game in Team Arena.
There are two different methods of creating a game using the menu scripts and they use different methods to add bots to fill out the teams. These methods use either the uiScript skirmishStart command or the uiScript StartServer command to start the game. Using the uiScript skirmishStart command will create a closed game which can not be joined by any other players. It is just you and the bots. Using the uiScript StartServer command creates a game that another player can join, if it is not filled to capacity with you and the bots. We'll look at each game creation method to see how bots are added.
uiScript skirmishStart
This is the method used by Team Arena to create their single player game. It uses information from the teaminfo.txt file to add bots to each team. See here for more details on this file. A skirmishStart game is fought between teams defined in the teams section in the teaminfo.txt file. To determine the two teams that will compete in the game you must choose which team you will be on and which team will be your opponent. The team members will then be selected from the information provided about each team.
To choose which team you want to be on you must place the English name of the team into the ui_teamName cvar. The best way to do this is to use the ownerdraw UI_CLANNAME command in an item such as the following :
itemDef
{
name teamname
ownerdraw UI_CLANNAME
rect 23 40 256 25
text "Clan: "
textalign ITEM_ALIGN_RIGHT
textalignx 128
textaligny 25
textscale .35
forecolor 0 0 0 1
backcolor 0 0 0 1
visible MENU_TRUE
}
By clicking on this item you can step through the list of team names and select the team you want. It also correctly sets up the team information each time you change the team name so this is the prefered method to use. By default, Team Arena sets your team name to Pagans but if this team is not defined you will be assigned the name of the first team in the teams section.
Your opponents team is chosen by placing the English name of the team into the ui_opponentName cvar. Again, the best way to achieve this is to use an ownerdraw command, in this case the ownerdraw UI_OPPONENT_NAME command. An item using this command would be like :
itemDef
{
name teamname
ownerdraw UI_OPPONENT_NAME
rect 23 70 256 25
text "Opponent: "
textalign ITEM_ALIGN_RIGHT
textalignx 128
textaligny 25
textscale .35
forecolor 0 0 0 1
backcolor 0 0 0 1
visible MENU_TRUE
}
By clicking on this item you can step through the list of team names and select the opponent team you want. This item will skip over the team name you have chosen for your team so you won't have both teams with the same name. By default, Team Arena sets the opponents team to the Stroggs but if this team is not defined it will be set to the first avalible team in the teams section.
Once you have set the team names, everything else is automatic when you start the game. For this method of creating a game, the information about the map is obtained from the maps section of the gameinfo.txt file. In this information is the maximum number of team members on each team. You and the bots are added to the game to fill the map with this maximum number of clients. For example, if the map info for the map defines a maximum of 3 team members then you and two bots are added to your team and three bots are added to the opposing team. Bots are added in order of definition in the team info section . You are the team leader on your team.
As you can see from the above, the skirmish game uses the information from the teaminfo.txt and gameinfo.txt files to add bots to the game.
uiScript StartServer
This method is used by Quake III to start a multiplayer game that can also include bots as players. The game can be either an individual game such as FFA or a team game like Team DM. The bots that are avalible for use in the game depend on whether it's game type is individual or team.
For individual games, the bots that are avalible are defined in the bots.txt file which is found in the scripts folder. For team games, the bots avalible are those that are defined in the characters section of the gameinfo.txt file. You select which bots you want to have in the game by using the ownerdraw UI_BLUETEAMx and ownerdraw UI_REDTEAMx commands in an item. An example is as follows :
itemDef
{
name teamname
ownerdraw UI_BLUETEAM1
rect 23 70 256 25
text "Player: "
textalign ITEM_ALIGN_RIGHT
textalignx 128
textaligny 25
textscale .35
forecolor 0 0 0 1
backcolor 0 0 0 1
visible MENU_TRUE
}
By clicking on this item you can step through the list of avalible bots. There is also a Closed entry to mark this player slot as unavalible (to limit the number of players in a game) and a Human entry so this slot can be filled by a human player. When the game is created any of the UI_BLUETEAMx and UI_REDTEAMx items which contain a bot name will have those bots added to the game. If it is a team game they will be added to the appropriate colored team.
In both of these methods of creating a game the skill level of the bots is set to the value of the g_spSkill cvar. This cvar is what sets the difficulty level of the game and it is modified by the ownerdraw UI_SKILL command. All bots are at this skill level when they are added to the game.
uiScript addBot
There is one last method of adding bots to a game. This one can only be done after the game has been created and therefore it must be done through the ingame menus. This method uses the uiScript addBot command to add a bot to the game. It will work regardless of how the game was created, assuming a player slot is avalible.
Before a bot can be added to the game using this command, we must setup the information about the bot. This includes the name of the bot, the skill level of the bot and the team it is to join. The name of the bot to be added is selected using the ownerdraw UI_BOTNAME command, like in the following :
itemDef
{
name botname
text "Bot Name:"
ownerdraw UI_BOTNAME
rect 15 40 200 30
textalign ITEM_ALIGN_RIGHT
textstyle ITEM_TEXTSTYLE_SHADOWED
textalignx 90
textaligny 30
textscale .35
forecolor 0.65 0.65 1 1
visible MENU_TRUE
}
By clicking on this item you will step through the list of avalible bots. For individual games, the bots that are avalible are defined in the bots.txt file which is found in the scripts folder. For team games, the bots avalible are those that are defined in the characters section of the gameinfo.txt file.
The skill level of the bot is set by the ownerdraw UI_BOTSKILL command :
itemDef
{
name botskill
text "Skill:"
ownerdraw UI_BOTSKILL
rect 15 100 200 30
textalign ITEM_ALIGN_RIGHT
textstyle ITEM_TEXTSTYLE_SHADOWED
textalignx 90
textaligny 30
textscale .35
forecolor 0.65 0.65 1 1
visible MENU_TRUE
}
Clicking on this item will step you through the various skill levels avalible. It is possible to set a bot's skill level higher than the difficulty level of the game using this method so care must be taken when setting the bot skill.
The team the bot will join is selected by the ownerdraw UI_REDBLUE command, like the following :
itemDef
{
name botteam
text "Team:"
ownerdraw UI_REDBLUE
rect 15 70 200 30
textalign ITEM_ALIGN_RIGHT
textstyle ITEM_TEXTSTYLE_SHADOWED
textalignx 90
textaligny 30
textscale .35
cvarTest "g_gametype"
disableCvar { "0" ; "1" }
forecolor 0.65 0.65 1 1
visible MENU_TRUE
}
By clicking on this item you can change the team from Blue to Red and back. Since the team is not used in individual games this item is disabled if the g_gametype cvar is FFA (0) or Tournament (1).
Once the bot's information is set using items like the above, it can be added using the uiScript addBot command, as in this item :
itemDef
{
name addbutton
style WINDOW_STYLE_SHADER
type ITEM_TYPE_BUTTON
rect 80 180 110 24
background "ui/assets/addbot0.tga"
visible MENU_TRUE
mouseEnter
{
setbackground "ui/assets/addbot1.tga"
}
mouseExit
{
setbackground "ui/assets/addbot0.tga"
}
action
{
uiScript addBot ;
uiScript closeingame
}
}
Clicking on this Button item will add a bot to the game. You can repeat this step as many times as you want, until the game is full.