Automatic Bot Names

(botnames is also available from GitHub.)

(this plugin was first posted to this thread at AlliedMods.net.)

This is a simple plugin I wrote for SourceMod to give names to bots when they are created. I wrote it and tested it under TF2, but theoretically it should work fine with other games. In particular, I have heard that CS:S works well. However, it certainly does not work with Left 4 Dead (2) and INS servers.

The current source for version 1.3.0 is here.

I wrote this plugin because the names for the new bots for TF2 KOTH (and now Dustbowl) are hardcoded into the game, and I don’t think that’s very cool. This plugin reads bot names from a file, and gives every new bot an appropriate name.

Yes, CS:S has a file for this. I’ve heard it’s non-trivial to edit, though. And I know for a fact that TF2 has no such file.

About botnames.txt

botnames.txt should be at {sourcemod}/configs/botnames.txt (so, for me, it’s in valve/orangebox/tf/addons/sourcemod/configs/botnames.txt). It’s a simple text file, with one name per line, and some basic comments. Anything on a line after a ‘# or ‘// is ignored, as are blank lines. Excessive whitespace on the names is trimmed.

I’ve placed a generic botnames.txt here, with names of Physicists, and an extra one here with character names from science fiction novels, as a quick start and as examples. For best results, write your own!

Loading Names from a Database

Alternately, as of version 1.2, you can tell botnames to load the names to use from a database table. To do this, set sm_botnames_db_name to the name of the database configuration to use, from SourceMod’s databases.cfg. Then, set sm_botnames_db_table to the name of the table to load from, and sm_botnames_db_column to the name of the column that contains the bot names.

As of version 1.2.1, there is additional support for more advanced database setups. You can set sm_botnames_order_by to a column name to get the list of names in ascending order according to that column. You may also set sm_botnames_descending to “1” to reverse this order. Setting sm_botnames_db_limit to a non-zero number will limit the amount of names loaded to that number.

If you are using a MySQL database and would like to load UTF8 names, set sm_botnames_db_use_utf8 to “1”. Note that this will emit a warning and do nothing on other types of database connections.

Plugin CVars

Here’s a list of the supported cvars, their defaults, and what they do:

Reloading of botnames.txt, and setting new values for sm_botnames_prefix and sm_botnames_random is done on map load. To do this manually, use the sm_botnames_reload command.

Implementation Details

Random Names

The random names are implemented so that it is unlikely that two bots in the same server will have the same name, as long as botnames.txt has enough names. Note that it is not impossible: to do that would be an unreasonable load on the server for just random bot names. Still, you should never see it happen under routine circumstances.

The random names are implemented by shuffling the name list after it is loaded, then going through the shuffled list in order, and looping back around at the end.

Quota Mode TF2 Bots

If you use the built-in bot quota system for TF2, there is an additional caveat. These bots are renamed immediately after changing teams, and these name changes totally ignore the usual rules agains too many name changes in a row. Unfortunately, my code has to follow these rules.

If I rename the bots before they join a team, my name is lost. If I do it right after the team join, my name change triggers a “too many name changes” error. So, right now, I must do these name changes after 10 entire seconds.

So, these auto-fill bots will name change after 10 seconds, but not before. This is annoying and not an ideal solution. I’m looking into a better solution. If anyone knows how to entirely block name changes in SourceMod, please tell me.

Bugs and Patches

If you’ve found a bug in Automatic Bot Names, please tell me. Please provide as much information as you reasonably can.

As with all my other projects, I accept patches graciously. If you have improved Automatic Bot Names, or have fixed a bug, I would love to hear from you. If you want to make things easy for me, use a pull request.

License

The source botnames.sp for Automatic Bot Names, as well as the example files botnames.txt and botnames.scifi.txt, are in the Public Domain. That is, they have no license. Do with them what you will.