// Returns first bot with matching name
entity find_bot_by_name(string name)
{
- entity bot;
-
- bot = findchainflags(flags, FL_CLIENT);
- while (bot)
+ FOREACH_CLIENT(IS_BOT_CLIENT(it) && it.netname == name,
{
- if(IS_BOT_CLIENT(bot))
- if(bot.netname==name)
- return bot;
-
- bot = bot.chain;
- }
+ return it;
+ });
return NULL;
}
float bot_cmd_eval(entity this, string expr)
{
// Search for numbers
- if(strstrofs("0123456789", substring(expr, 0, 1), 0) >= 0)
- {
+ if(IS_DIGIT(substring(expr, 0, 1)))
return stof(expr);
- }
// Search for cvars
if(substring(expr, 0, 5)=="cvar.")
- {
return cvar(substring(expr, 5, strlen(expr)));
- }
// Search for fields
switch(expr)
if(!this.bot_cmd_current)
{
this.bot_cmd_current = new_pure(bot_cmd);
- this.bot_cmd_current.is_bot_cmd = true;
}
bot_cmd = this.bot_cmd_current;