BotLib: add cvar bot_prefix, add method SetName() which respects it.

This commit is contained in:
Marco Cawthorne 2022-05-24 15:32:37 -07:00
parent 6bc54d4219
commit 68974053f4
Signed by: eukara
GPG Key ID: CE2032F0A2882A22
4 changed files with 18 additions and 1 deletions

View File

@ -89,6 +89,8 @@ class bot:player
virtual void(entity) SetEnemy;
virtual float(void) GetRunSpeed;
virtual float(void) GetWalkSpeed;
virtual void(string) SetName;
};
entity Bot_AddQuick(void);

View File

@ -520,6 +520,15 @@ bot::PostFrame(void)
}
}
void
bot::SetName(string nickname)
{
if (autocvar_bot_prefix)
forceinfokey(this, "name", sprintf("%s %s", autocvar_bot_prefix, nickname));
else
forceinfokey(this, "name", nickname);
}
void
bot::bot(void)
{

View File

@ -24,7 +24,11 @@ Bot_PickName(entity target)
if (clienttype(pbot) == CLIENTTYPE_BOT)
n++;
forceinfokey(target, "name", sprintf("Bot %i", n));
if (autocvar_bot_prefix)
forceinfokey(target, "name", sprintf("%s Bot %i", autocvar_bot_prefix, n));
else
forceinfokey(target, "name", sprintf("Bot %i", n));
forceinfokey(target, "model", "robo");
}

View File

@ -20,3 +20,5 @@ var int autocvar_bot_aimless = FALSE;
var int autocvar_nav_linksize = 256;
var int autocvar_nav_radius = 8;
var string autocvar_bot_prefix = "";