From 37d20c9151063cfcccabe8995a86948ba41b2ca0 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 30 Jul 2024 14:26:44 +1000 Subject: [PATCH] Add some missing IT_UNLIMITED_AMMO checks where ammo is checked --- qcsrc/common/weapons/weapon/minelayer.qc | 5 ++++- qcsrc/common/weapons/weapon/shotgun.qc | 2 +- qcsrc/server/bot/default/havocbot/havocbot.qc | 6 ++++-- qcsrc/server/bot/default/havocbot/roles.qc | 3 ++- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/qcsrc/common/weapons/weapon/minelayer.qc b/qcsrc/common/weapons/weapon/minelayer.qc index 63c7b9e44..805c307d5 100644 --- a/qcsrc/common/weapons/weapon/minelayer.qc +++ b/qcsrc/common/weapons/weapon/minelayer.qc @@ -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); } } diff --git a/qcsrc/common/weapons/weapon/shotgun.qc b/qcsrc/common/weapons/weapon/shotgun.qc index b28e3c96a..f4f146a1c 100644 --- a/qcsrc/common/weapons/weapon/shotgun.qc +++ b/qcsrc/common/weapons/weapon/shotgun.qc @@ -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; diff --git a/qcsrc/server/bot/default/havocbot/havocbot.qc b/qcsrc/server/bot/default/havocbot/havocbot.qc index e7bf9e5a3..5ccd46be8 100644 --- a/qcsrc/server/bot/default/havocbot/havocbot.qc +++ b/qcsrc/server/bot/default/havocbot/havocbot.qc @@ -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 diff --git a/qcsrc/server/bot/default/havocbot/roles.qc b/qcsrc/server/bot/default/havocbot/roles.qc index 020d993be..9684c26a1 100644 --- a/qcsrc/server/bot/default/havocbot/roles.qc +++ b/qcsrc/server/bot/default/havocbot/roles.qc @@ -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; }; -- 2.39.2