// 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;
}
if(id < WEP_FIRST || id > WEP_LAST)
return CMD_STATUS_ERROR;
- if(client_hasweapon(this, Weapons_from(id), true, false))
- PS(this).m_switchweapon = Weapons_from(id);
+ .entity weaponentity = weaponentities[0]; // TODO: unhardcode
+
+ if(client_hasweapon(this, Weapons_from(id), weaponentity, true, false))
+ this.(weaponentity).m_switchweapon = Weapons_from(id);
else
return CMD_STATUS_ERROR;
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(f)
{
this.colormod = '0 8 8';
- LOG_INFO("Bot ", this.netname, " using ", this.weaponname, " wants to fire, inhibited by weaponentity state\n");
+ LOG_INFO("Bot ", this.netname, " using ", this.(weaponentity).weaponname, " wants to fire, inhibited by weaponentity state\n");
}
}
else if(ATTACK_FINISHED(this, slot) > time)
if(f)
{
this.colormod = '8 0 8';
- LOG_INFO("Bot ", this.netname, " using ", this.weaponname, " wants to fire, inhibited by ATTACK_FINISHED (", ftos(ATTACK_FINISHED(this, slot) - time), " seconds left)\n");
+ LOG_INFO("Bot ", this.netname, " using ", this.(weaponentity).weaponname, " wants to fire, inhibited by ATTACK_FINISHED (", ftos(ATTACK_FINISHED(this, slot) - time), " seconds left)\n");
}
}
- else if(this.tuba_note)
+ else if(this.(weaponentity).tuba_note)
{
if(f)
{
this.colormod = '8 0 0';
- LOG_INFO("Bot ", this.netname, " using ", this.weaponname, " wants to fire, bot still has an active tuba note\n");
+ LOG_INFO("Bot ", this.netname, " using ", this.(weaponentity).weaponname, " wants to fire, bot still has an active tuba note\n");
}
}
else
if(!f)
{
this.colormod = '8 8 0';
- LOG_INFO("Bot ", this.netname, " using ", this.weaponname, " thinks it has fired, but apparently did not; ATTACK_FINISHED says ", ftos(ATTACK_FINISHED(this, slot) - time), " seconds left\n");
+ LOG_INFO("Bot ", this.netname, " using ", this.(weaponentity).weaponname, " thinks it has fired, but apparently did not; ATTACK_FINISHED says ", ftos(ATTACK_FINISHED(this, slot) - time), " seconds left\n");
}
}