Skip to content

Commit

Permalink
Fix boGiver waiting issue with late-arriving getters
Browse files Browse the repository at this point in the history
Fixes an issue where the boGiver would continue to wait even after successfully casting bo on a late-arriving getter after the wait timer had expired.

- remove getters from the list after they receive bo
- giveBO() function returns immediately once all getters have received bo
- stop the main loop once all getters have received bo
  • Loading branch information
Antiwarden authored Dec 27, 2024
1 parent d9bc354 commit f100955
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions d2bs/kolbot/libs/scripts/BattleOrders.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ const BattleOrders = new Runnable(
}

totalBoed.add(p.name.toLowerCase());
boGetters.delete(p.name.toLowerCase());
console.debug("Bo-ed " + p.name);
boed = true;
}
Expand All @@ -164,6 +165,13 @@ const BattleOrders = new Runnable(
delay(5000); // Giving the barb a coffee break?
} */

if (boGetters.size === 0) {
return {
success: boed,
count: playersToBo.length
};
}

return {
success: boed,
count: playersToBo.length
Expand Down Expand Up @@ -224,10 +232,8 @@ const BattleOrders = new Runnable(
case boMode.Give:
// check if anyone is near us
nearPlayer = Game.getPlayer();

removeMissing(); // remove missing getters from the list
//console.debug("Getters in game: " + [...boGetters].join(", "));

if (nearPlayer) {
do {
if (nearPlayer.name !== me.name) {
Expand All @@ -238,8 +244,7 @@ const BattleOrders = new Runnable(
&& Misc.inMyParty(nearPlayerName)) {
let result = giveBO();
if (result.success) {
if (result.count === boGetters.size
|| totalBoed.size === boGetters.size) {
if (boGetters.size === 0) {
// we bo-ed everyone we are set to, don't wait around any longer
break MainLoop;
}
Expand Down

0 comments on commit f100955

Please sign in to comment.