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 all commits
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
97 changes: 86 additions & 11 deletions d2bs/kolbot/libs/bots/BattleOrders.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,63 @@
/**
* @filename BattleOrders.js
* @author kolton
* @author kolton, jmichelsen
* @desc give or receive Battle Orders buff
* @return {boolean}
*/

function BattleOrders() {
function BattleOrders () {
this.checkForPlayers = function () {
if (Misc.getPlayerCount() <= 1) {
throw new Error("Empty game"); // Alone in game
}
};

this.amTardy = function () {
let party = getParty();

AreaInfoLoop:
while (true) {
try {
this.checkForPlayers();
} catch (e) {
if (Config.BattleOrders.Wait) {
print("Waiting " + Config.BattleOrders.Wait + " seconds for other players...");

while (getTickCount() - tick < Config.BattleOrders.Wait * 1000) {
me.overhead("Waiting " + Math.round(((tick + (Config.BattleOrders.Wait * 1000)) - getTickCount()) / 1000) + " Seconds for other players");
delay(1000);
}

this.checkForPlayers();
}
}

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

if (party) {
do {
if (party.area === 131 || party.area === 132 || party.area === 108 || party.area === 39) {
// Player is in Throne of Destruction, Worldstone Chamber, Chaos Sanctuary, or Cows
print("ÿc1I'm late to BOs. Moving on...");

return true;
}
} while (party.getNext());
}

return false; // Not late; wait.
};

this.giveBO = function (list) {
var i, unit,
let i,
unit,
failTimer = 60,
tick = getTickCount();

Expand All @@ -18,7 +69,12 @@ function BattleOrders() {
if (getTickCount() - tick >= failTimer * 1000) {
showConsole();
print("ÿc1BO timeout fail.");
quit();

if (Config.BattleOrders.QuitOnFailure) {
quit();
}

break;
}

Precast.doPrecast(true);
Expand All @@ -37,25 +93,39 @@ function BattleOrders() {
} catch (wperror) {
showConsole();
print("ÿc1Failed to take waypoint.");
quit();

if (Config.BattleOrders.QuitOnFailure) {
quit();
}

return false;
}

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

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

MainLoop:
MainLoop:
while (true) {
if (Config.BattleOrders.SkipIfTardy && this.amTardy()) {
break;
}

switch (Config.BattleOrders.Mode) {
case 0: // Give BO
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.QuitOnFailure) {
quit();
}

break MainLoop;
}

delay(500);
Expand All @@ -77,7 +147,12 @@ MainLoop:
if (getTickCount() - tick >= failTimer * 1000) {
showConsole();
print("ÿc1BO timeout fail.");
quit();

if (Config.BattleOrders.QuitOnFailure) {
quit();
}

break MainLoop;
}

break;
Expand All @@ -88,7 +163,7 @@ MainLoop:

Pather.useWaypoint(1);

if (Config.BattleOrders.Mode === 0 && Config.BattleOrders.Wait) {
if (Config.BattleOrders.Mode === 0 && Config.BattleOrders.Idle) {
for (i = 0; i < Config.BattleOrders.Getters.length; i += 1) {
while (Misc.inMyParty(Config.BattleOrders.Getters[i])) {
delay(500);
Expand All @@ -97,4 +172,4 @@ MainLoop:
}

return true;
}
}
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
Idle: false, // Idle until player receiving BO leaves
QuitOnFailure: false, // Quit the game if BO fails
SkipIfTardy: true, // Proceed with scripts if other players already moved on from BO spot
Wait: 10, // Duration to wait for players to join game
},
Enchant: {
Triggers: ["chant", "cows", "wps"],
Expand Down
5 changes: 4 additions & 1 deletion d2bs/kolbot/libs/config/Amazon.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ function LoadConfig() {
// Battle orders script - Use this for 2+ characters (for example BO barb + sorc)
Scripts.BattleOrders = false;
Config.BattleOrders.Mode = 0; // 0 = give BO, 1 = get BO
Config.BattleOrders.Wait = false; // Idle until the player that received BO leaves.
Config.BattleOrders.Idle = false; // Idle until the player that received BO leaves.
Config.BattleOrders.Getters = []; // List of players to wait for before casting Battle Orders (mode 0). All players must be in the same area as the BOer.
Config.BattleOrders.QuitOnFailure = false; // Quit the game if BO fails
Config.BattleOrders.SkipIfTardy = true; // Proceed with scripts if other players already moved on from BO spot
Config.BattleOrders.Wait = 10; // Duration to wait for players to join game in seconds (default: 10)

// Team MF system
Config.MFLeader = false; // Set to true if you have one or more MFHelpers. Opens TP and gives commands when doing normal MF runs.
Expand Down
5 changes: 4 additions & 1 deletion d2bs/kolbot/libs/config/Assassin.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ function LoadConfig() {
// Battle orders script - Use this for 2+ characters (for example BO barb + sorc)
Scripts.BattleOrders = false;
Config.BattleOrders.Mode = 0; // 0 = give BO, 1 = get BO
Config.BattleOrders.Wait = false; // Idle until the player that received BO leaves.
Config.BattleOrders.Idle = false; // Idle until the player that received BO leaves.
Config.BattleOrders.Getters = []; // List of players to wait for before casting Battle Orders (mode 0). All players must be in the same area as the BOer.
Config.BattleOrders.QuitOnFailure = false; // Quit the game if BO fails
Config.BattleOrders.SkipIfTardy = true; // Proceed with scripts if other players already moved on from BO spot
Config.BattleOrders.Wait = 10; // Duration to wait for players to join game in seconds (default: 10)

// Team MF system
Config.MFLeader = false; // Set to true if you have one or more MFHelpers. Opens TP and gives commands when doing normal MF runs.
Expand Down
5 changes: 4 additions & 1 deletion d2bs/kolbot/libs/config/Barbarian.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ function LoadConfig() {
// Battle orders script - Use this for 2+ characters (for example BO barb + sorc)
Scripts.BattleOrders = false;
Config.BattleOrders.Mode = 0; // 0 = give BO, 1 = get BO
Config.BattleOrders.Wait = false; // Idle until the player that received BO leaves.
Config.BattleOrders.Idle = false; // Idle until the player that received BO leaves.
Config.BattleOrders.Getters = []; // List of players to wait for before casting Battle Orders (mode 0). All players must be in the same area as the BOer.
Config.BattleOrders.QuitOnFailure = false; // Quit the game if BO fails
Config.BattleOrders.SkipIfTardy = true; // Proceed with scripts if other players already moved on from BO spot
Config.BattleOrders.Wait = 10; // Duration to wait for players to join game in seconds (default: 10)

// Team MF system
Config.MFLeader = false; // Set to true if you have one or more MFHelpers. Opens TP and gives commands when doing normal MF runs.
Expand Down
5 changes: 4 additions & 1 deletion d2bs/kolbot/libs/config/Druid.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ function LoadConfig() {
// Battle orders script - Use this for 2+ characters (for example BO barb + sorc)
Scripts.BattleOrders = false;
Config.BattleOrders.Mode = 0; // 0 = give BO, 1 = get BO
Config.BattleOrders.Wait = false; // Idle until the player that received BO leaves.
Config.BattleOrders.Idle = false; // Idle until the player that received BO leaves.
Config.BattleOrders.Getters = []; // List of players to wait for before casting Battle Orders (mode 0). All players must be in the same area as the BOer.
Config.BattleOrders.QuitOnFailure = false; // Quit the game if BO fails
Config.BattleOrders.SkipIfTardy = true; // Proceed with scripts if other players already moved on from BO spot
Config.BattleOrders.Wait = 10; // Duration to wait for players to join game in seconds (default: 10)tleOrders.Getters = []; // List of players to wait for before casting Battle Orders (mode 0). All players must be in the same area as the BOer.

// Team MF system
Config.MFLeader = false; // Set to true if you have one or more MFHelpers. Opens TP and gives commands when doing normal MF runs.
Expand Down
5 changes: 4 additions & 1 deletion d2bs/kolbot/libs/config/Necromancer.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ function LoadConfig() {
// Battle orders script - Use this for 2+ characters (for example BO barb + sorc)
Scripts.BattleOrders = false;
Config.BattleOrders.Mode = 0; // 0 = give BO, 1 = get BO
Config.BattleOrders.Wait = false; // Idle until the player that received BO leaves.
Config.BattleOrders.Idle = false; // Idle until the player that received BO leaves.
Config.BattleOrders.Getters = []; // List of players to wait for before casting Battle Orders (mode 0). All players must be in the same area as the BOer.
Config.BattleOrders.QuitOnFailure = false; // Quit the game if BO fails
Config.BattleOrders.SkipIfTardy = true; // Proceed with scripts if other players already moved on from BO spot
Config.BattleOrders.Wait = 10; // Duration to wait for players to join game in seconds (default: 10)

// Team MF system
Config.MFLeader = false; // Set to true if you have one or more MFHelpers. Opens TP and gives commands when doing normal MF runs.
Expand Down
5 changes: 4 additions & 1 deletion d2bs/kolbot/libs/config/Paladin.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ function LoadConfig() {
// Battle orders script - Use this for 2+ characters (for example BO barb + sorc)
Scripts.BattleOrders = false;
Config.BattleOrders.Mode = 0; // 0 = give BO, 1 = get BO
Config.BattleOrders.Wait = false; // Idle until the player that received BO leaves.
Config.BattleOrders.Idle = false; // Idle until the player that received BO leaves.
Config.BattleOrders.Getters = []; // List of players to wait for before casting Battle Orders (mode 0). All players must be in the same area as the BOer.
Config.BattleOrders.QuitOnFailure = false; // Quit the game if BO fails
Config.BattleOrders.SkipIfTardy = true; // Proceed with scripts if other players already moved on from BO spot
Config.BattleOrders.Wait = 10; // Duration to wait for players to join game in seconds (default: 10)

// Team MF system
Config.MFLeader = false; // Set to true if you have one or more MFHelpers. Opens TP and gives commands when doing normal MF runs.
Expand Down
5 changes: 4 additions & 1 deletion d2bs/kolbot/libs/config/Sorceress.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ function LoadConfig() {
// Battle orders script - Use this for 2+ characters (for example BO barb + sorc)
Scripts.BattleOrders = false;
Config.BattleOrders.Mode = 0; // 0 = give BO, 1 = get BO
Config.BattleOrders.Wait = false; // Idle until the player that received BO leaves.
Config.BattleOrders.Idle = false; // Idle until the player that received BO leaves.
Config.BattleOrders.Getters = []; // List of players to wait for before casting Battle Orders (mode 0). All players must be in the same area as the BOer.
Config.BattleOrders.QuitOnFailure = false; // Quit the game if BO fails
Config.BattleOrders.SkipIfTardy = true; // Proceed with scripts if other players already moved on from BO spot
Config.BattleOrders.Wait = 10; // Duration to wait for players to join game in seconds (default: 10)

// Team MF system
Config.MFLeader = false; // Set to true if you have one or more MFHelpers. Opens TP and gives commands when doing normal MF runs.
Expand Down