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 custom Seal Order handling to Diablo and DiabloHelper #2129

Open
wants to merge 7 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
55 changes: 38 additions & 17 deletions d2bs/kolbot/libs/bots/Diablo.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* @filename Diablo.js
* @author kolton
* @desc clear Chaos Sanctuary and kill Diablo
* @return {boolean}
*/

function Diablo() {
Expand Down Expand Up @@ -235,6 +236,7 @@ function Diablo() {
};

this.infectorSeal = function () {
Precast.doPrecast(true);
print("Inf layout " + this.infLayout);
this.followPath(this.infLayout === 1 ? this.starToInfA : this.starToInfB);

Expand All @@ -259,10 +261,34 @@ function Diablo() {
return true;
};

const openSeals = (sealOrder) => {
print("seal order: " + sealOrder);
let seals = {
1: () => this.vizierSeal(),
2: () => this.seisSeal(),
3: () => this.infectorSeal(),
"vizier": () => this.vizierSeal(),
"seis": () => this.seisSeal(),
"infector": () => this.infectorSeal(),
};
sealOrder.forEach(seal => {seals[seal]()});
};

this.diabloPrep = function () {
var trapCheck,
tick = getTickCount();

switch (me.classid) {
case 1:
Pather.moveTo(7792, 5294);

break;
default:
Pather.moveTo(7788, 5292);

break;
}

while (getTickCount() - tick < 30000) {
if (getTickCount() - tick >= 8000) {
switch (me.classid) {
Expand Down Expand Up @@ -465,28 +491,23 @@ function Diablo() {
}

Attack.clear(30, 0, false, this.sort);
this.vizierSeal();
this.seisSeal();
Precast.doPrecast(true);
this.infectorSeal();

switch (me.classid) {
case 1:
Pather.moveTo(7792, 5294);

break;
default:
Pather.moveTo(7788, 5292);

break;
}

openSeals(Config.Diablo.SealOrder);

if (Config.PublicMode) {
say(Config.Diablo.DiabloMsg);
}

this.diabloPrep();
try {
print("Attempting to find Diablo");
this.diabloPrep();
} catch (error) {
print("Diablo wasn't found. Checking seals.");
this.vizierSeal();
this.seisSeal();
this.infectorSeal();
this.diabloPrep();
}

Attack.kill(243); // Diablo
Pickit.pickItems();

Expand Down
122 changes: 105 additions & 17 deletions d2bs/kolbot/libs/bots/DiabloHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* @filename DiabloHelper.js
* @author kolton
* @desc help leading player in clearing Chaos Sanctuary and killing Diablo
* @return {boolean}
*/

function DiabloHelper() {
Expand Down Expand Up @@ -72,6 +73,43 @@ function DiabloHelper() {
this.infLayout = this.getLayout(392, 7893); // 1 = "I", 2 = "J"
};

this.openSeal = function (classid) {
let i,
seal;

for (i = 0; i < 5; i += 1) {
Pather.moveToPreset(108, 2, classid, classid === 394 ? 5 : 2, classid === 394 ? 5 : 0);

seal = getUnit(2, classid);

if (!seal) {
return false;
}

if (classid === 394) {
Misc.click(0, 0, seal);
} else {
seal.interact();
}

delay(classid === 394 ? 1000 : 500);

if (!seal.mode) {
if (classid === 394 && Attack.validSpot(seal.x + 15, seal.y)) { // de seis optimization
Pather.moveTo(seal.x + 15, seal.y);
} else {
Pather.moveTo(seal.x - 5, seal.y - 5);
}

delay(500);
} else {
return true;
}
}

return false;
};

this.getBoss = function (name) {
var i, boss, glow;

Expand Down Expand Up @@ -103,6 +141,12 @@ function DiabloHelper() {
this.vizierSeal = function () {
this.followPath(this.vizLayout === 1 ? this.starToVizA : this.starToVizB, this.sort);

if (Config.DiabloHelper.OpenSeals) {
if (!this.openSeal(395) || !this.openSeal(396)) {
throw new Error("Failed to open Vizier seals.");
}
}

if (this.vizLayout === 1) {
Pather.moveTo(7691, 5292);
} else {
Expand All @@ -123,6 +167,12 @@ function DiabloHelper() {
this.seisSeal = function () {
this.followPath(this.seisLayout === 1 ? this.starToSeisA : this.starToSeisB, this.sort);

if (Config.DiabloHelper.OpenSeals) {
if (!this.openSeal(394)) {
throw new Error("Failed to open de Seis seal.");
}
}

if (this.seisLayout === 1) {
Pather.moveTo(7771, 5196);
} else {
Expand All @@ -141,8 +191,15 @@ function DiabloHelper() {
};

this.infectorSeal = function () {
Precast.doPrecast(true);
this.followPath(this.infLayout === 1 ? this.starToInfA : this.starToInfB, this.sort);

if (Config.DiabloHelper.OpenSeals) {
if (!this.openSeal(392)) {
throw new Error("Failed to open Infector seals.");
}
}

if (this.infLayout === 1) {
delay(1);
} else {
Expand All @@ -153,17 +210,47 @@ function DiabloHelper() {
throw new Error("Failed to kill Infector");
}

if (Config.DiabloHelper.OpenSeals) {
if (!this.openSeal(393)) {
throw new Error("Failed to open Infector seals.");
}
}

if (Config.FieldID) {
Town.fieldID();
}

return true;
};

const clearSeals = (sealOrder) => {
print("seal order: " + sealOrder);
let seals = {
1: () => this.vizierSeal(),
2: () => this.seisSeal(),
3: () => this.infectorSeal(),
"vizier": () => this.vizierSeal(),
"seis": () => this.seisSeal(),
"infector": () => this.infectorSeal(),
};
sealOrder.forEach(seal => {seals[seal]()});
};

this.diabloPrep = function () {
var trapCheck,
tick = getTickCount();

switch (me.classid) {
case 1:
Pather.moveTo(7793, 5291);

break;
default:
Pather.moveTo(7788, 5292);

break;
}

while (getTickCount() - tick < 30000) {
if (getTickCount() - tick >= 8000) {
switch (me.classid) {
Expand Down Expand Up @@ -393,8 +480,10 @@ AreaInfoLoop:
}
}

Pather.useWaypoint(Config.RandomPrecast ? "random" : 107);
Precast.doPrecast(true);
if (Config.DiabloHelper.SafePrecast) {
Pather.useWaypoint(Config.RandomPrecast ? "random" : 107);
Precast.doPrecast(true);
}

if (Config.DiabloHelper.SkipTP) {
if (me.area !== 107) {
Expand Down Expand Up @@ -457,23 +546,22 @@ CSLoop:

Pather.moveTo(7774, 5305);
Attack.clear(35, 0, false, this.sort);
this.vizierSeal();
this.seisSeal();
Precast.doPrecast(true);
this.infectorSeal();

switch (me.classid) {
case 1:
Pather.moveTo(7793, 5291);

break;
default:
Pather.moveTo(7788, 5292);

break;
clearSeals(Config.DiabloHelper.SealOrder);

try {
print("Attempting to find Diablo");
this.diabloPrep();
} catch (error) {
print("Diablo wasn't found");
if (Config.DiabloHelper.RecheckSeals) {
print("Rechecking seals");
this.vizierSeal();
this.seisSeal();
this.infectorSeal();
this.diabloPrep();
}
}

this.diabloPrep();
Attack.kill(243); // Diablo
Pickit.pickItems();

Expand Down
9 changes: 7 additions & 2 deletions d2bs/kolbot/libs/common/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -405,13 +405,18 @@ var Config = {
EntranceTP: "Entrance TP up",
StarTP: "Star TP up",
DiabloMsg: "Diablo",
WalkClear: false
WalkClear: false,
SealOrder: ["vizier", "seis", "infector"],
},
DiabloHelper: {
Wait: 120,
Entrance: false,
SkipIfBaal: false,
SkipTP: false
SkipTP: false,
OpenSeals: false,
SafePrecast: true,
SealOrder: ["vizier", "seis", "infector"],
RecheckSeals: false,
},
BattleOrders: {
Mode: 0,
Expand Down
5 changes: 5 additions & 0 deletions d2bs/kolbot/libs/config/Amazon.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ function LoadConfig() {
Config.Diablo.EntranceTP = "Entrance TP up";
Config.Diablo.StarTP = "Star TP up";
Config.Diablo.DiabloMsg = "Diablo";
Config.Diablo.SealOrder = ["vizier", "seis", "infector"]; // the order in which to clear the seals. If seals are excluded, they won't be checked unless diablo fails to appear
Scripts.SealLeader = false; // Clear a safe spot around seals and invite leechers in. Leechers should run SealLeecher script. Don't run with Diablo or FastDiablo.

// *** act 5 ***
Expand Down Expand Up @@ -141,6 +142,10 @@ function LoadConfig() {
Config.DiabloHelper.Entrance = true; // Start from entrance. Set to false to start from star.
Config.DiabloHelper.SkipTP = false; // Don't wait for town portal and directly head to chaos. It will clear monsters around chaos entrance and wait for the runner.
Config.DiabloHelper.SkipIfBaal = false; // End script if there are party members in a Baal run.
Config.DiabloHelper.OpenSeals = false; // Open seals as the helper
Config.DiabloHelper.SafePrecast = true; // take random WP to safely precast
Config.DiabloHelper.SealOrder = ["vizier", "seis", "infector"]; // the order in which to clear the seals. If seals are excluded, they won't be checked unless diablo fails to appear
Config.DiabloHelper.RecheckSeals = false; // Teleport to each seal and double-check that it was opened and boss was killed if Diablo doesn't appear
Scripts.AutoBaal = false; // Baal leecher with auto leader assignment
Config.AutoBaal.FindShrine = false; // false = disabled, 1 = search after hot tp message, 2 = search as soon as leader is found
Config.AutoBaal.LeechSpot = [15115, 5050]; // X, Y coords of Throne Room leech spot
Expand Down
5 changes: 5 additions & 0 deletions d2bs/kolbot/libs/config/Assassin.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ function LoadConfig() {
Config.Diablo.EntranceTP = "Entrance TP up";
Config.Diablo.StarTP = "Star TP up";
Config.Diablo.DiabloMsg = "Diablo";
Config.Diablo.SealOrder = ["vizier", "seis", "infector"]; // the order in which to clear the seals. If seals are excluded, they won't be checked unless diablo fails to appear
Scripts.SealLeader = false; // Clear a safe spot around seals and invite leechers in. Leechers should run SealLeecher script. Don't run with Diablo or FastDiablo.

// *** act 5 ***
Expand Down Expand Up @@ -141,6 +142,10 @@ function LoadConfig() {
Config.DiabloHelper.Entrance = true; // Start from entrance. Set to false to start from star.
Config.DiabloHelper.SkipTP = false; // Don't wait for town portal and directly head to chaos. It will clear monsters around chaos entrance and wait for the runner.
Config.DiabloHelper.SkipIfBaal = false; // End script if there are party members in a Baal run.
Config.DiabloHelper.OpenSeals = false; // Open seals as the helper
Config.DiabloHelper.SafePrecast = true; // take random WP to safely precast
Config.DiabloHelper.SealOrder = ["vizier", "seis", "infector"]; // the order in which to clear the seals. If seals are excluded, they won't be checked unless diablo fails to appear
Config.DiabloHelper.RecheckSeals = false; // Teleport to each seal and double-check that it was opened and boss was killed if Diablo doesn't appear
Scripts.AutoBaal = false; // Baal leecher with auto leader assignment
Config.AutoBaal.FindShrine = false; // false = disabled, 1 = search after hot tp message, 2 = search as soon as leader is found
Config.AutoBaal.LeechSpot = [15115, 5050]; // X, Y coords of Throne Room leech spot
Expand Down
5 changes: 5 additions & 0 deletions d2bs/kolbot/libs/config/Barbarian.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ function LoadConfig() {
Config.Diablo.EntranceTP = "Entrance TP up";
Config.Diablo.StarTP = "Star TP up";
Config.Diablo.DiabloMsg = "Diablo";
Config.Diablo.SealOrder = ["vizier", "seis", "infector"]; // the order in which to clear the seals. If seals are excluded, they won't be checked unless diablo fails to appear
Scripts.SealLeader = false; // Clear a safe spot around seals and invite leechers in. Leechers should run SealLeecher script. Don't run with Diablo or FastDiablo.

// *** act 5 ***
Expand Down Expand Up @@ -141,6 +142,10 @@ function LoadConfig() {
Config.DiabloHelper.Entrance = true; // Start from entrance. Set to false to start from star.
Config.DiabloHelper.SkipTP = false; // Don't wait for town portal and directly head to chaos. It will clear monsters around chaos entrance and wait for the runner.
Config.DiabloHelper.SkipIfBaal = false; // End script if there are party members in a Baal run.
Config.DiabloHelper.OpenSeals = false; // Open seals as the helper
Config.DiabloHelper.SafePrecast = true; // take random WP to safely precast
Config.DiabloHelper.SealOrder = ["vizier", "seis", "infector"]; // the order in which to clear the seals. If seals are excluded, they won't be checked unless diablo fails to appear
Config.DiabloHelper.RecheckSeals = false; // Teleport to each seal and double-check that it was opened and boss was killed if Diablo doesn't appear
Scripts.AutoBaal = false; // Baal leecher with auto leader assignment
Config.AutoBaal.FindShrine = false; // false = disabled, 1 = search after hot tp message, 2 = search as soon as leader is found
Config.AutoBaal.LeechSpot = [15115, 5050]; // X, Y coords of Throne Room leech spot
Expand Down
5 changes: 5 additions & 0 deletions d2bs/kolbot/libs/config/Druid.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ function LoadConfig() {
Config.Diablo.EntranceTP = "Entrance TP up";
Config.Diablo.StarTP = "Star TP up";
Config.Diablo.DiabloMsg = "Diablo";
Config.Diablo.SealOrder = ["vizier", "seis", "infector"]; // the order in which to clear the seals. If seals are excluded, they won't be checked unless diablo fails to appear
Scripts.SealLeader = false; // Clear a safe spot around seals and invite leechers in. Leechers should run SealLeecher script. Don't run with Diablo or FastDiablo.

// *** act 5 ***
Expand Down Expand Up @@ -141,6 +142,10 @@ function LoadConfig() {
Config.DiabloHelper.Entrance = true; // Start from entrance. Set to false to start from star.
Config.DiabloHelper.SkipTP = false; // Don't wait for town portal and directly head to chaos. It will clear monsters around chaos entrance and wait for the runner.
Config.DiabloHelper.SkipIfBaal = false; // End script if there are party members in a Baal run.
Config.DiabloHelper.OpenSeals = false; // Open seals as the helper
Config.DiabloHelper.SafePrecast = true; // take random WP to safely precast
Config.DiabloHelper.SealOrder = ["vizier", "seis", "infector"]; // the order in which to clear the seals. If seals are excluded, they won't be checked unless diablo fails to appear
Config.DiabloHelper.RecheckSeals = false; // Teleport to each seal and double-check that it was opened and boss was killed if Diablo doesn't appear
Scripts.AutoBaal = false; // Baal leecher with auto leader assignment
Config.AutoBaal.FindShrine = false; // false = disabled, 1 = search after hot tp message, 2 = search as soon as leader is found
Config.AutoBaal.LeechSpot = [15115, 5050]; // X, Y coords of Throne Room leech spot
Expand Down
Loading