#include <common/state.qh>
#include <common/physics/player.qh>
+#include <common/wepent.qh>
#include "bot.qh"
if(id < WEP_FIRST || id > WEP_LAST)
return CMD_STATUS_ERROR;
- .entity weaponentity = weaponentities[0]; // TODO: unhardcode
+ bool success = false;
- if(client_hasweapon(this, Weapons_from(id), weaponentity, true, false))
- this.(weaponentity).m_switchweapon = Weapons_from(id);
- else
+ for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+ {
+ .entity weaponentity = weaponentities[slot];
+ if(this.(weaponentity).m_weapon == WEP_Null && slot != 0)
+ continue;
+
+ if(client_hasweapon(this, Weapons_from(id), weaponentity, true, false))
+ {
+ success = true;
+ this.(weaponentity).m_switchweapon = Weapons_from(id);
+ }
+ }
+
+ if(!success)
return CMD_STATUS_ERROR;
return CMD_STATUS_FINISHED;
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)
{
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;