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

Pathing improvements for walking bots #1381

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion d2bs/kolbot/libs/bots/AncientTunnels.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function AncientTunnels() {
Pather.useWaypoint(44);
Precast.doPrecast(true);

if (Config.AncientTunnels.OpenChest && Pather.moveToPreset(me.area, 2, 580) && Misc.openChests(5)) {
if (Config.AncientTunnels.OpenChest && Pather.moveToPreset(me.area, 2, 580) && Chest.openChests(5)) {
Pickit.pickItems();
}

Expand Down
2 changes: 1 addition & 1 deletion d2bs/kolbot/libs/bots/ChestMania.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function ChestMania() {
for (i = 0; i < Config.ChestMania[prop].length; i += 1) {
Pather.journeyTo(Config.ChestMania[prop][i]);
Precast.doPrecast(i == 0 ? true : false);
Misc.openChestsInArea(Config.ChestMania[prop][i]);
Chest.openChestsInArea(Config.ChestMania[prop][i]);
}

Town.doChores();
Expand Down
2 changes: 1 addition & 1 deletion d2bs/kolbot/libs/bots/Countess.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function Countess() {
Attack.clear(20, 0, getLocaleString(2875)); // The Countess

if (Config.OpenChests) {
Misc.openChestsInArea();
Chest.openChestsInArea();
}

return true;
Expand Down
2 changes: 1 addition & 1 deletion d2bs/kolbot/libs/bots/Eldritch.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function Eldritch() {

chest = getUnit(2, 455);

if (Misc.openChest(chest)) {
if (Chest.openChest(chest)) {
Pickit.pickItems();
}
}
Expand Down
3 changes: 1 addition & 2 deletions d2bs/kolbot/libs/bots/Follower.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,8 +433,7 @@ function Follower() {

unit = unitList.shift();

if (unit) {
Misc.openChest(unit);
if (unit && Chest.openChest(unit)) {
Pickit.pickItems();
}
}
Expand Down
6 changes: 3 additions & 3 deletions d2bs/kolbot/libs/bots/Mephisto.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,11 @@ function Mephisto() {

if (Config.OpenChests) {
Pather.moveTo(17572, 8011);
Attack.openChests(5);
Chest.openChests(5); //Chest stuff should no longer be necessary but leaving it here just in case
Pather.moveTo(17572, 8125);
Attack.openChests(5);
Chest.openChests(5);
Pather.moveTo(17515, 8061);
Attack.openChests(5);
Chest.openChests(5);
}

if (Config.Mephisto.TakeRedPortal) {
Expand Down
2 changes: 1 addition & 1 deletion d2bs/kolbot/libs/bots/Questing.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ function Questing() {

stand = getUnit(2, 193);

Misc.openChest(stand);
Chest.openChest(stand);
delay(300);

book = getUnit(4, 548);
Expand Down
3 changes: 2 additions & 1 deletion d2bs/kolbot/libs/bots/Radament.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ function Radament() {

Attack.kill(229); // Radament
Pickit.pickItems();
Attack.openChests(20);
Chest.scan(20);
Chest.openChests();

return true;
}
6 changes: 3 additions & 3 deletions d2bs/kolbot/libs/bots/Rushee.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function Rushee() {
return false;
}

Misc.openChest(chest);
Chest.openChest(chest);

item = getUnit(4, classid);

Expand Down Expand Up @@ -170,7 +170,7 @@ function Rushee() {
return false;
}

Misc.openChest(orifice);
Chest.openChest(orifice);

staff = me.getItem(91);

Expand Down Expand Up @@ -515,7 +515,7 @@ function Rushee() {

target = getUnit(2, 193);

Misc.openChest(target);
Chest.openChest(target);
delay(300);

target = getUnit(4, 548);
Expand Down
4 changes: 2 additions & 2 deletions d2bs/kolbot/libs/bots/Tristram.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function Tristram() {

tree = getUnit(2, 30);

Misc.openChest(tree);
Chest.openChest(tree);
delay(300);

scroll = getUnit(4, 524);
Expand Down Expand Up @@ -82,7 +82,7 @@ function Tristram() {
throw new Error("Failed to move to Cain's Gibbet");
}

Misc.openChest(gibbet);
Chest.openChest(gibbet);
}

if (Config.Tristram.PortalLeech) {
Expand Down
61 changes: 12 additions & 49 deletions d2bs/kolbot/libs/common/Attack.js
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,6 @@ var Attack = {
}

ClassAttack.afterAttack(pickit);
this.openChests(range, orgx, orgy);

if (attackCount > 0 && pickit) {
Pickit.pickItems();
Expand Down Expand Up @@ -722,7 +721,6 @@ var Attack = {
}

ClassAttack.afterAttack(true);
this.openChests(30);

if (attackCount > 0) {
Pickit.pickItems();
Expand Down Expand Up @@ -863,7 +861,7 @@ var Attack = {

var room, result, rooms, myRoom, currentArea, previousArea;

function RoomSort(a, b) {
function RoomSort (a, b) {
return getDistance(myRoom[0], myRoom[1], a[0], a[1]) - getDistance(myRoom[0], myRoom[1], b[0], b[1]);
}

Expand Down Expand Up @@ -905,7 +903,7 @@ var Attack = {
result = Pather.getNearestWalkable(room[0], room[1], 18, 3);

if (result) {
Pather.moveTo(result[0], result[1], 3, spectype);
Pather.moveTo(result[0], result[1], 3, spectype, true);
previousArea = result;
//this.countUniques();

Expand Down Expand Up @@ -1008,42 +1006,6 @@ var Attack = {
return true;
},

// Open chests when clearing
openChests: function (range, x, y) {
if (!Config.OpenChests) {
return false;
}

if (x === undefined || y === undefined) {
x = me.x;
y = me.y;
}

var i, unit,
list = [],
ids = ["chest", "chest3", "weaponrack", "armorstand"];

unit = getUnit(2);

if (unit) {
do {
if (unit.name && getDistance(unit, x, y) <= range && ids.indexOf(unit.name.toLowerCase()) > -1) {
list.push(copyUnit(unit));
}
} while (unit.getNext());
}

while (list.length) {
list.sort(Sort.units);

if (Misc.openChest(list.shift())) {
Pickit.pickItems();
}
}

return true;
},

buildMonsterList: function () {
var monster,
monList = [];
Expand Down Expand Up @@ -1093,7 +1055,7 @@ var Attack = {
return false;
}

function sortGrid(a, b) {
function sortGrid (a, b) {
//return getDistance(a.x, a.y, idealPos.x, idealPos.y) - getDistance(b.x, b.y, idealPos.x, idealPos.y);
return getDistance(b.x, b.y, unit.x, unit.y) - getDistance(a.x, a.y, unit.x, unit.y);
}
Expand All @@ -1120,7 +1082,7 @@ var Attack = {
if (typeof index === "number") {
//print("Dodge build time: " + (getTickCount() - tick));

return Pather.moveTo(grid[index].x, grid[index].y, 0);
return Pather.moveTo(grid[index].x, grid[index].y, 0, false);
}

return false;
Expand Down Expand Up @@ -1251,13 +1213,14 @@ var Attack = {

if ((unit.spectype & 0x7) && Config.SkipException && Config.SkipException.indexOf(unit.name) > -1) {
print("ÿc1Skip Exception: " + unit.name);

return true;
}

var i, j, rval,
tempArray = [];

EnchantLoop: // Skip enchanted monsters
EnchantLoop: // Skip enchanted monsters
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these should not be indented

for (i = 0; i < Config.SkipEnchant.length; i += 1) {
tempArray = Config.SkipEnchant[i].toLowerCase().split(" and ");

Expand Down Expand Up @@ -1327,7 +1290,7 @@ EnchantLoop: // Skip enchanted monsters
}
}

ImmuneLoop: // Skip immune monsters
ImmuneLoop: // Skip immune monsters
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these should not be indented

for (i = 0; i < Config.SkipImmune.length; i += 1) {
tempArray = Config.SkipImmune[i].toLowerCase().split(" and ");

Expand All @@ -1342,7 +1305,7 @@ ImmuneLoop: // Skip immune monsters
}
}

AuraLoop: // Skip monsters with auras
AuraLoop: // Skip monsters with auras
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these should not be indented

for (i = 0; i < Config.SkipAura.length; i += 1) {
rval = true;

Expand Down Expand Up @@ -1550,7 +1513,7 @@ AuraLoop: // Skip monsters with auras
Pather.walkTo(unit.x, unit.y, 3);
}
} else {
Pather.moveTo(unit.x, unit.y, 0);
Pather.moveTo(unit.x, unit.y, 0, false);
}

return !CollMap.checkColl(me, unit, coll);
Expand Down Expand Up @@ -1598,12 +1561,12 @@ AuraLoop: // Skip monsters with auras
if (getDistance(me, coords[i]) < 6 && !CollMap.checkColl(me, coords[i], 0x5)) {
Pather.walkTo(coords[i].x, coords[i].y, 2);
} else {
Pather.moveTo(coords[i].x, coords[i].y, 1);
Pather.moveTo(coords[i].x, coords[i].y, 1, false);
}

break;
default:
Pather.moveTo(coords[i].x, coords[i].y, 1);
Pather.moveTo(coords[i].x, coords[i].y, 1, false);

break;
}
Expand All @@ -1620,4 +1583,4 @@ AuraLoop: // Skip monsters with auras

return false;
}
};
};
2 changes: 1 addition & 1 deletion d2bs/kolbot/libs/common/Cubing.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ var Cubing = {
chest = getUnit(2, 354);

if (chest) {
Misc.openChest(chest);
Chest.openChest(chest);

for (i = 0; i < 5; i += 1) {
cube = getUnit(4, 549);
Expand Down
Loading