From: Mircea Kitsune Date: Fri, 11 Feb 2011 23:26:18 +0000 (+0200) Subject: Simplify that last code a bit X-Git-Tag: xonotic-v0.5.0~309^2~7^2~25 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=bf8214598a5a0dad78a14c3a8791514056b5210d;p=xonotic%2Fxonotic-data.pk3dir.git Simplify that last code a bit --- diff --git a/qcsrc/server/bot/havocbot/havocbot.qc b/qcsrc/server/bot/havocbot/havocbot.qc index b29885f6b..7e11c456f 100644 --- a/qcsrc/server/bot/havocbot/havocbot.qc +++ b/qcsrc/server/bot/havocbot/havocbot.qc @@ -940,6 +940,14 @@ void havocbot_chooseenemy() self.havocbot_stickenemy = TRUE; }; +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; + return FALSE; +} + void havocbot_chooseweapon() { local float i; @@ -1006,10 +1014,7 @@ void havocbot_chooseweapon() w = bot_weapons_far[i]; if ( client_hasweapon(self, w, TRUE, FALSE) ) { - if (self.weapon_load[w] < 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, so it's an emergency to switch to anything else - continue; - if ( self.weapon == w && combo) + if ((self.weapon == w && combo) || havocbot_chooseweapon_checkreload(w)) continue; self.switchweapon = w; return; @@ -1023,10 +1028,7 @@ void havocbot_chooseweapon() w = bot_weapons_mid[i]; if ( client_hasweapon(self, w, TRUE, FALSE) ) { - if (self.weapon_load[w] < 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, so it's an emergency to switch to anything else - continue; - if ( self.weapon == w && combo) + if ((self.weapon == w && combo) || havocbot_chooseweapon_checkreload(w)) continue; self.switchweapon = w; return; @@ -1039,10 +1041,7 @@ void havocbot_chooseweapon() w = bot_weapons_close[i]; if ( client_hasweapon(self, w, TRUE, FALSE) ) { - if (self.weapon_load[w] < 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, so it's an emergency to switch to anything else - continue; - if ( self.weapon == w && combo) + if ((self.weapon == w && combo) || havocbot_chooseweapon_checkreload(w)) continue; self.switchweapon = w; return;