Page 1 of 1

Add bot with custom name

Posted: Thu Nov 27, 2014 3:08 pm
by nullable
Hi guys,

Is it possible add bot by command like bot_add_ct or bot_add_t and set it custom name?

Posted: Thu Nov 27, 2014 4:19 pm
by L'In20Cible

Code: Select all

]help bot_add
"bot_add"
 game
 - bot_add <t|ct> <type> <difficulty> <name> - Adds a bot matching the given criteria.

Posted: Thu Nov 27, 2014 7:37 pm
by Ayuto
You could also create a bot with these two commands.

Syntax: Select all

from engines.server import engine_server

engine_server.create_fake_client(<name>)

Syntax: Select all

from players.bot import bot_manager

bot_manager.create_bot(<name>)
After that you can switch them to the team you want.

Posted: Fri Nov 28, 2014 8:19 am
by nullable
Thanks. Now I have two questions about this:
1. How to set difficulty of bot?
2. How to remove bot prefix [BOT] in name?

Posted: Fri Nov 28, 2014 11:23 am
by Ayuto
With this method you can't set the difficulty without using the memory module. So, if you want to set the difficulty I would suggest you to use L'In20Cible's method.

Posted: Fri Nov 28, 2014 1:01 pm
by nullable
Ok. How about bot prefix?

Posted: Fri Nov 28, 2014 3:14 pm
by Doldol
nullable wrote:Ok. How about bot prefix?


If you're using CS:S (does not work in CS:GO AFAIK):

Code: Select all

"bot_prefix" = ""          game replicated
- This string is prefixed to the name of all bots that join the game.
<difficulty> will be replaced with the bot's difficulty.
<weaponclass> will be replaced with the bot's desired weapon class.
<skill> will be replaced with a 0-100 representation of the bot's skill.

Posted: Fri Nov 28, 2014 9:17 pm
by nullable
I am interesting csgo.

Posted: Sat Nov 29, 2014 4:59 am
by satoon101
bot_prefix is hidden in CS:GO, but you can still get/set it using the ConVar class. However, BOT is automatically added to the beginning of the name/prefix. I would imagine there is a way to change it (with dynamic/virtual function hooking), but I'm not sure exactly how to accomplish this right now.

Posted: Sat Nov 29, 2014 7:50 am
by L'In20Cible
There is no way to remove the BOT prefix from the server since this is formatted client-side.

Code: Select all

// client.dll @ sub_103AE6C0

.text:103AE9BE                 mov     esi, offset aSfui_bot_decor ; "#SFUI_bot_decorated_name"
And in the translation files you can find:

Code: Select all

      "SFUI_bot_decorated_name"   "BOT %s1"
The only way I could see of, would be to tell the clients that bots are real players (which will probably trick the master server and can get your IP banned from the research) but I don't think it worth it.

Posted: Sat Nov 29, 2014 6:19 pm
by nullable
Hmm. When I try to add bot it added without problem but when called event player_connect I have error when I want to get index of player:

Syntax: Select all

def load():
bot_manager.create_bot('Cliffe')

@Event
def player_connect(game_event):
userid = game_event.get_int('userid')
name = game_event.get_string('name')
print('PLAYER_NAME:%s' % name)
index = index_from_userid(userid)


The trace is:

Syntax: Select all

index = index_from_userid(userid) 

ValueError: Conversion failed...

Posted: Sat Nov 29, 2014 6:54 pm
by satoon101
Not at home, currently, so I can't check, but 'index' should be an event variable in player_connect. At least, I know it is in CS:S.
http://wiki.sourcepython.com/pages/Event-cstrike:player_connect

Posted: Sat Nov 29, 2014 6:55 pm
by Doldol
My guess is that since player_connect fires very early on, index_from_userid can't run. In general I prefer using player_activate, which fires later, typically when the player sees your motd.

However if you really want to use this event, this is better practice and solves your issue:

Syntax: Select all

def load():
bot_manager.create_bot('Cliffe')


@Event
def player_connect(game_event):
name = game_event.get_string('name')
print('PLAYER_NAME:%s' % name)
index = game_event.get_int('index')


Edit: Oops, didn't notice Satoon's post, but he's right I tested it (in CS:S).

Posted: Sun Nov 30, 2014 9:49 am
by nullable
The problem is after create a bot the bot is freezing in game. I mean it do nothing. How can fix it?

Posted: Sun Nov 30, 2014 11:14 am
by L'In20Cible
bot_manager.create_bot is just creating a fake client, they cannot play. Use the bot_add command to add a bot linked to the CCSBot's AI.

Posted: Wed Dec 03, 2014 7:26 am
by nullable
I changed SFUI_bot_controlled_by and SFUI_bot_decorated_name in file serverfiles/csgo/resource/csgo_english.txt but the result is not no avail. What could be the problem?

Posted: Wed Dec 03, 2014 7:30 am
by satoon101
As L'In20Cible already stated, those are client-side, so there is nothing a server can do to modify them.