From 1b0304ff4b2e6c1e02c1f68cc331c8f5ff035658 Mon Sep 17 00:00:00 2001 From: Mircea Kitsune Date: Sat, 12 Feb 2011 01:44:24 +0200 Subject: [PATCH] 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. --- qcsrc/server/bot/havocbot/havocbot.qc | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) 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; } -- 2.39.2