Add bot with custom name

Please post any questions about developing your plugin here. Please use the search function before posting!
nullable
Senior Member
Posts: 137
Joined: Sat Nov 08, 2014 7:22 pm

Add bot with custom name

Postby nullable » Thu Nov 27, 2014 3:08 pm

Hi guys,

Is it possible add bot by command like bot_add_ct or bot_add_t and set it custom name?
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Postby L'In20Cible » Thu Nov 27, 2014 4:19 pm

Code: Select all

]help bot_add
"bot_add"
 game
 - bot_add <t|ct> <type> <difficulty> <name> - Adds a bot matching the given criteria.
User avatar
Ayuto
Project Leader
Posts: 2195
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Postby Ayuto » Thu Nov 27, 2014 7:37 pm

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.
nullable
Senior Member
Posts: 137
Joined: Sat Nov 08, 2014 7:22 pm

Postby nullable » Fri Nov 28, 2014 8:19 am

Thanks. Now I have two questions about this:
1. How to set difficulty of bot?
2. How to remove bot prefix [BOT] in name?
User avatar
Ayuto
Project Leader
Posts: 2195
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Postby Ayuto » Fri Nov 28, 2014 11:23 am

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.
nullable
Senior Member
Posts: 137
Joined: Sat Nov 08, 2014 7:22 pm

Postby nullable » Fri Nov 28, 2014 1:01 pm

Ok. How about bot prefix?
User avatar
Doldol
Senior Member
Posts: 200
Joined: Sat Jul 07, 2012 7:09 pm
Location: Belgium

Postby Doldol » Fri Nov 28, 2014 3:14 pm

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.
nullable
Senior Member
Posts: 137
Joined: Sat Nov 08, 2014 7:22 pm

Postby nullable » Fri Nov 28, 2014 9:17 pm

I am interesting csgo.
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Sat Nov 29, 2014 4:59 am

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.
Image
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Postby L'In20Cible » Sat Nov 29, 2014 7:50 am

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.
nullable
Senior Member
Posts: 137
Joined: Sat Nov 08, 2014 7:22 pm

Postby nullable » Sat Nov 29, 2014 6:19 pm

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...
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Sat Nov 29, 2014 6:54 pm

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
Image
User avatar
Doldol
Senior Member
Posts: 200
Joined: Sat Jul 07, 2012 7:09 pm
Location: Belgium

Postby Doldol » Sat Nov 29, 2014 6:55 pm

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).
nullable
Senior Member
Posts: 137
Joined: Sat Nov 08, 2014 7:22 pm

Postby nullable » Sun Nov 30, 2014 9:49 am

The problem is after create a bot the bot is freezing in game. I mean it do nothing. How can fix it?
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Postby L'In20Cible » Sun Nov 30, 2014 11:14 am

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.
nullable
Senior Member
Posts: 137
Joined: Sat Nov 08, 2014 7:22 pm

Postby nullable » Wed Dec 03, 2014 7:26 am

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?
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Wed Dec 03, 2014 7:30 am

As L'In20Cible already stated, those are client-side, so there is nothing a server can do to modify them.
Image

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 146 guests