]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add some missing IT_UNLIMITED_AMMO checks where ammo is checked
authorMario <mario.mario@y7mail.com>
Tue, 30 Jul 2024 04:26:44 +0000 (14:26 +1000)
committerMario <mario.mario@y7mail.com>
Tue, 30 Jul 2024 04:26:44 +0000 (14:26 +1000)
qcsrc/common/weapons/weapon/minelayer.qc
qcsrc/common/weapons/weapon/shotgun.qc
qcsrc/server/bot/default/havocbot/havocbot.qc
qcsrc/server/bot/default/havocbot/roles.qc

index 63c7b9e44395cb62e21a3930e21ffb18704e765f..805c307d55ce82e1b68f5064a0bcf72b89be06dd 100644 (file)
@@ -432,7 +432,10 @@ METHOD(MineLayer, wr_think, void(entity thiswep, entity actor, .entity weaponent
     if(autocvar_g_balance_minelayer_reload_ammo && actor.(weaponentity).clip_load < WEP_CVAR(minelayer, ammo)) // forced reload
     {
         // not if we're holding the minelayer without enough ammo, but can detonate existing mines
-        if(!(W_MineLayer_PlacedMines(actor, weaponentity, false) && GetResource(actor, thiswep.ammo_type) < WEP_CVAR(minelayer, ammo))) {
+        bool enough_ammo = (GetResource(actor, thiswep.ammo_type) >= WEP_CVAR(minelayer, ammo));
+        if(actor.items & IT_UNLIMITED_AMMO)
+               enough_ammo = true;
+        if(!(W_MineLayer_PlacedMines(actor, weaponentity, false) && !enough_ammo)) {
             thiswep.wr_reload(thiswep, actor, weaponentity);
         }
     }
index b28e3c96a090806cac04a8c5aa8f610298a480d0..f4f146a1cfa290c36e46ff63fc70bd154ed7c88a 100644 (file)
@@ -253,7 +253,7 @@ METHOD(Shotgun, wr_think, void(entity thiswep, entity actor, .entity weaponentit
     // force reload weapon when clip is empty or insufficent
     if(WEP_CVAR(shotgun, reload_ammo) && actor.(weaponentity).clip_load < WEP_CVAR_PRI(shotgun, ammo))
     {
-        if(actor.(weaponentity).clip_load >= 0 && GetResource(actor, thiswep.ammo_type) > 0)
+        if(actor.(weaponentity).clip_load >= 0 && (GetResource(actor, thiswep.ammo_type) > 0 || (actor.items & IT_UNLIMITED_AMMO)))
         {
             thiswep.wr_reload(thiswep, actor, weaponentity);
             return;
index e7bf9e5a33936337f884f2f528de6f1ae27aa8fd..5ccd46be841a88bea278254ecfa3022db29fc6ea 100644 (file)
@@ -461,7 +461,7 @@ void havocbot_movetogoal(entity this)
        // Jetpack navigation
        if(this.navigation_jetpack_goal)
        if(this.goalcurrent==this.navigation_jetpack_goal)
-       if(GetResource(this, RES_FUEL))
+       if(GetResource(this, RES_FUEL) > 0 || (this.items & IT_UNLIMITED_AMMO))
        {
                if(autocvar_bot_debug_goalstack)
                {
@@ -1469,7 +1469,7 @@ void havocbot_chooseenemy(entity this)
                this.havocbot_stickenemy_time = 0;
 }
 
-float havocbot_chooseweapon_checkreload(entity this, .entity weaponentity, int new_weapon)
+bool havocbot_chooseweapon_checkreload(entity this, .entity weaponentity, int new_weapon)
 {
        // bots under this skill cannot find unloaded weapons to reload idly when not in combat,
        // so skip this for them, or they'll never get to reload their weapons at all.
@@ -1480,6 +1480,8 @@ float havocbot_chooseweapon_checkreload(entity this, .entity weaponentity, int n
        // if this weapon is scheduled for reloading, don't switch to it during combat
        if (this.(weaponentity).weapon_load[new_weapon] < 0)
        {
+               if(this.items & IT_UNLIMITED_AMMO)
+                       return true;
                FOREACH(Weapons, it != WEP_Null, {
                        if(it.wr_checkammo1(it, this, weaponentity) + it.wr_checkammo2(it, this, weaponentity))
                                return true; // other weapon available
index 020d993bed9fb03f133e630d3a9df5f771d90b6b..9684c26a1c9b2e532d79ddfec702efcd6f37d433 100644 (file)
@@ -47,12 +47,13 @@ bool havocbot_goalrating_item_can_be_left_to_teammate(entity this, entity player
        if (GetResource(item, RES_HEALTH) && GetResource(player, RES_HEALTH) <= GetResource(this, RES_HEALTH)) {return true;}
        if (GetResource(item, RES_ARMOR) && GetResource(player, RES_ARMOR) <= GetResource(this, RES_ARMOR)) {return true;}
        if (STAT(WEAPONS, item) && !(STAT(WEAPONS, player) & STAT(WEAPONS, item))) {return true;}
+       if (item.itemdef.instanceOfPowerup) {return true;}
+       if (this.items & IT_UNLIMITED_AMMO) {return true;}
        if (GetResource(item, RES_SHELLS) && GetResource(player, RES_SHELLS) <= GetResource(this, RES_SHELLS)) {return true;}
        if (GetResource(item, RES_BULLETS) && GetResource(player, RES_BULLETS) <= GetResource(this, RES_BULLETS)) {return true;}
        if (GetResource(item, RES_ROCKETS) && GetResource(player, RES_ROCKETS) <= GetResource(this, RES_ROCKETS)) {return true;}
        if (GetResource(item, RES_CELLS) && GetResource(player, RES_CELLS) <= GetResource(this, RES_CELLS)) {return true;}
        if (GetResource(item, RES_PLASMA) && GetResource(player, RES_PLASMA) <= GetResource(this, RES_PLASMA)) {return true;}
-       if (item.itemdef.instanceOfPowerup) {return true;}
 
        return false;
 };