From: Mircea Kitsune Date: Fri, 11 Feb 2011 23:44:24 +0000 (+0200) Subject: Only refuse reload scheduled weapons if we have something else to switch to. If we... X-Git-Tag: xonotic-v0.5.0~309^2~7^2~24 X-Git-Url: http://de.git.xonotic.org/?a=commitdiff_plain;h=1b0304ff4b2e6c1e02c1f68cc331c8f5ff035658;p=xonotic%2Fxonotic-data.pk3dir.git Only refuse reload scheduled weapons if we have something else to switch to. If we somehow have no other weapon we can use, switch to anything even during combat. --- diff --git a/qcsrc/server/bot/havocbot/havocbot.qc b/qcsrc/server/bot/havocbot/havocbot.qc index 7e11c456f..3490f1488 100644 --- a/qcsrc/server/bot/havocbot/havocbot.qc +++ b/qcsrc/server/bot/havocbot/havocbot.qc @@ -942,9 +942,19 @@ void havocbot_chooseenemy() float havocbot_chooseweapon_checkreload(float new_weapon) { - if (self.weapon_load[new_weapon] < 0) // this weapon is scheduled for reloading, don't switch to it during combat - if not (weapon_action(self.weapon, WR_CHECKAMMO1) + weapon_action(self.weapon, WR_CHECKAMMO2)) // we are out of ammo for current weapon, so it's an emergency to switch to anything else - return TRUE; + // if this weapon is scheduled for reloading, don't switch to it during combat + if (self.weapon_load[new_weapon] < 0) + { + local float i, other_weapon_available; + for(i = WEP_FIRST; i <= WEP_LAST; ++i) + { + // if we are out of ammo for all other weapons, it's an emergency to switch to anything else + if (weapon_action(i, WR_CHECKAMMO1) + weapon_action(i, WR_CHECKAMMO2)) + other_weapon_available = TRUE; + } + if(other_weapon_available) + return TRUE; + } return FALSE; }