Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add BattleOrders tardy check and quit/continue vars #2013

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 62 additions & 4 deletions d2bs/kolbot/libs/bots/BattleOrders.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,43 @@
*/

function BattleOrders() {
this.AmTardy = function() {
let party;

if (Config.BattleOrders.SkipIfTardy) {
jmichelsen marked this conversation as resolved.
Show resolved Hide resolved
party = getParty();

AreaInfoLoop:
while (true) {
if (Misc.getPlayerCount() <= 1) {
jmichelsen marked this conversation as resolved.
Show resolved Hide resolved
throw new Error("Empty game"); // Alone in game
}

if (party) {
do {
if (party.name !== me.name && party.area) {
break AreaInfoLoop; // Can read player area
}
} while (party.getNext());
}

delay(1000);
}

if (party) {
do {
if (party.area === 131 || party.area === 132 || party.area === 108 || party.area === 39) { // Player is in Throne of Destruction or Worldstone Chamber or Chaos Sanctuary
print("ÿc1I'm late to BOs. Moving on...");
return true;
jmichelsen marked this conversation as resolved.
Show resolved Hide resolved
}
} while (party.getNext());
return false; // Not late; wait.
}

}
return Config.BattleOrders.SkipIfTardy; // Not late; wait.
};

this.giveBO = function (list) {
var i, unit,
failTimer = 60,
Expand All @@ -18,7 +55,11 @@ function BattleOrders() {
if (getTickCount() - tick >= failTimer * 1000) {
showConsole();
print("ÿc1BO timeout fail.");
quit();
if (Config.BattleOrders.QuitOnFailedGive) {
quit();
} else {
break;
jmichelsen marked this conversation as resolved.
Show resolved Hide resolved
}
}

Precast.doPrecast(true);
Expand All @@ -42,20 +83,29 @@ function BattleOrders() {

Pather.moveTo(me.x + 6, me.y + 6);

var i,
let i,
tick = getTickCount(),
failTimer = 60;

MainLoop:
while (true) {
switch (Config.BattleOrders.Mode) {
case 0: // Give BO
if (this.AmTardy()) {
jmichelsen marked this conversation as resolved.
Show resolved Hide resolved
break MainLoop;
}

for (i = 0; i < Config.BattleOrders.Getters.length; i += 1) {
while (!Misc.inMyParty(Config.BattleOrders.Getters[i]) || !getUnit(0, Config.BattleOrders.Getters[i])) {
if (getTickCount() - tick >= failTimer * 1000) {
showConsole();
print("ÿc1BO timeout fail.");
quit();
if (Config.BattleOrders.QuitOnFailedGive) {
jmichelsen marked this conversation as resolved.
Show resolved Hide resolved
quit();
} else {
break MainLoop;
}

}

delay(500);
Expand All @@ -74,10 +124,18 @@ MainLoop:
break MainLoop;
}

if (this.AmTardy()) {
jmichelsen marked this conversation as resolved.
Show resolved Hide resolved
break MainLoop;
}

if (getTickCount() - tick >= failTimer * 1000) {
showConsole();
print("ÿc1BO timeout fail.");
quit();
if (Config.BattleOrders.QuitOnFailedGet) {
jmichelsen marked this conversation as resolved.
Show resolved Hide resolved
quit();
} else {
break MainLoop;
}
}

break;
Expand Down
5 changes: 4 additions & 1 deletion d2bs/kolbot/libs/common/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,10 @@ var Config = {
BattleOrders: {
Mode: 0,
Getters: [],
Wait: false
Wait: false,
QuitOnFailedGive: false,
QuitOnFailedGet: false,
jmichelsen marked this conversation as resolved.
Show resolved Hide resolved
SkipIfTardy: true
},
Enchant: {
Triggers: ["chant", "cows", "wps"],
Expand Down