Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
D2BotChannel.dbj, D2BotFollow.dbj - fixed join request from other d2botfollow profiles, changed mule trigger, added torchTrigger exception from join game requests
D2BotFollow.dbj - added torchTrigger exception from join game requests
AutoMule.js, TorchSystem.js - fixed a bug where follow profiles could join mule game
Attack.js - tweaked Attack.kill code not to throw errors when boss unit is invalidated
Wereform.js - changed to proper filename and description
CollMap.js - fixed getNearbyRooms error
Misc.js - added a simple text-based item log which logs sold, kept, stashed, dropped and skipped (due to no inventory space) items.

added item txt logger settings to char configs
  • Loading branch information
kolton committed Aug 20, 2013
1 parent db07d7e commit 78d7fcb
Show file tree
Hide file tree
Showing 22 changed files with 129 additions and 24 deletions.
8 changes: 5 additions & 3 deletions d2bs/kolbot/D2BotChannel.dbj
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,14 @@ function ReceiveCopyData(mode, msg) {

break;
case 3: // Game request
if (muleTrigger || torchMuleTrigger || torchTrigger) {
break;
}

if (gameInfo) {
obj = JSON.parse(msg);

D2Bot.joinMe(obj.profile, me.gamename || "", "", me.gamepassword || "", joinInfo.inGame);
D2Bot.joinMe(obj.profile, me.gamename || "", "", me.gamepassword || "", me.gameReady ? "yes" : "no");
}

break;
Expand Down Expand Up @@ -265,9 +269,7 @@ MainSwitch:
if (ingame) {
// ### automule ###
if (muleTrigger || torchMuleTrigger) {
removeEventListener('copydata', ReceiveCopyData);
AutoMule.outOfGameCheck(torchMuleTrigger ? 1 : 0);
addEventListener('copydata', ReceiveCopyData);

muleTrigger = false;
// torchMuleTrigger is set to false elsewhere because it would trigger normal mule if set to false here
Expand Down
7 changes: 3 additions & 4 deletions d2bs/kolbot/D2BotFollow.dbj
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ function ScriptMsgEvent(msg) {
}

function ReceiveCopyData(mode, msg) {
//print(mode + " " + msg);
var obj;

switch (msg) {
Expand All @@ -141,14 +140,14 @@ function ReceiveCopyData(mode, msg) {

break;
case 3: // Game request
if (muleTrigger || torchMuleTrigger) {
if (muleTrigger || torchMuleTrigger || torchTrigger) {
break;
}

if (joinInfo) {
if (gameInfo) {
obj = JSON.parse(msg);

D2Bot.joinMe(msg, joinInfo.gameName, gameCount, joinInfo.gamePass, joinInfo.inGame);
D2Bot.joinMe(obj.profile, me.gamename || "", "", me.gamepassword || "", me.gameReady ? "yes" : "no");
}

break;
Expand Down
3 changes: 1 addition & 2 deletions d2bs/kolbot/D2BotLead.dbj
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ function sayMsg(string) {
}

function ReceiveCopyData(mode, msg) {
//print(mode + " " + msg);
var obj;

switch (msg) {
Expand All @@ -114,7 +113,7 @@ function ReceiveCopyData(mode, msg) {

break;
case 3: // Game request
if (muleTrigger || torchMuleTrigger) {
if (muleTrigger || torchMuleTrigger || torchTrigger) {
break;
}

Expand Down
3 changes: 2 additions & 1 deletion d2bs/kolbot/libs/AutoMule.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,8 @@ MainLoop:
joinGame(muleObj.muleGameName[0], muleObj.muleGameName[1]);
delay(5000);

return true;
//return true;
break MainLoop;
default:
failCount += 1;

Expand Down
4 changes: 4 additions & 0 deletions d2bs/kolbot/libs/TorchSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ var TorchSystem = {

delay(5000);

while (me.ingame) {
delay(1000);
}

return true;
}

Expand Down
4 changes: 2 additions & 2 deletions d2bs/kolbot/libs/common/Attack.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ var Attack = {
target = getUnit(1, -1, -1, gid);
}

if (copyUnit(target).x === undefined) { // Check if unit got invalidated, happens if necro raises a skeleton from the boss's corpse.
if (!target || !copyUnit(target).x) { // Check if unit got invalidated, happens if necro raises a skeleton from the boss's corpse.
break;
}

Expand All @@ -179,7 +179,7 @@ var Attack = {

ClassAttack.afterAttack();

if (copyUnit(target).x === undefined) {
if (!target || !copyUnit(target).x) {
return true;
}

Expand Down
4 changes: 2 additions & 2 deletions d2bs/kolbot/libs/common/Attacks/Wereform.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @filename Amazon.js
* @filename Wereform.js
* @author kolton
* @desc Amazon attack sequence
* @desc Wereform attack sequence
*/

var ClassAttack = {
Expand Down
15 changes: 13 additions & 2 deletions d2bs/kolbot/libs/common/CollMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,19 @@ var CollMap = new function () {
this.maps = [];

this.getNearbyRooms = function (x, y) {
var i,
rooms = getRoom(x, y).getNearby();
var i, room, rooms;

room = getRoom(x, y);

if (!room) {
return false;
}

rooms = getRoom(x, y).getNearby();

if (!rooms) {
return false;
}

for (i = 0; i < rooms.length; i += 1) {
if (this.getRoomIndex(rooms[i].x * 5, rooms[i].y * 5, true) === undefined) {
Expand Down
3 changes: 3 additions & 0 deletions d2bs/kolbot/libs/common/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ var Config = {
ScanShrines: [],
Debug: false,

ItemInfo: false,
ItemInfoQuality: [],

Cubing: false,
Recipes: [],
MakeRunewords: false,
Expand Down
5 changes: 3 additions & 2 deletions d2bs/kolbot/libs/common/Cubing.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ var Cubing = {
return;
}

//print("We have " + Config.Recipes.length + " cubing recipe(s).");
print("We have " + Config.Recipes.length + " cubing recipe(s).");

this.buildRecipes();
this.buildGemList();
Expand Down Expand Up @@ -797,7 +797,8 @@ IngredientLoop:

break;
case 1:
Misc.logItem("Cubing kept", items[j], result.line);
Misc.itemLogger("Cubing Kept", items[j]);
Misc.logItem("Cubing Kept", items[j], result.line);

break;
}
Expand Down
36 changes: 35 additions & 1 deletion d2bs/kolbot/libs/common/Misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ var Misc = {
}

if (!me.idle) {
Misc.click(0, 0, me); // Click to stop walking in case we got stuck
Misc.click(0, 0, me.x, me.y); // Click to stop walking in case we got stuck
}

return false;
Expand Down Expand Up @@ -819,6 +819,40 @@ var Misc = {
return tempArray;
},

itemLogger: function (action, unit) {
if (!Config.ItemInfo) {
return false;
}

var desc;

switch (action) {
case "Sold":
if (Config.ItemInfoQuality.indexOf(unit.quality) === -1) {
return false;
}

desc = this.getItemDesc(unit).split("\n").join(" | ").replace(/ÿc[0-9!"+<;.*]/gi, "").trim();

break;
case "Kept":
case "Field Kept":
case "Runeword Kept":
case "Cubing Kept":
case "Shopped":
case "Gambled":
desc = this.getItemDesc(unit).split("\n").join(" | ").replace(/ÿc[0-9!"+<;.*]/gi, "").trim();

break;
default:
desc = unit.fname.split("\n").reverse().join(" ").replace(/ÿc[0-9!"+<;.*]/gi, "").trim();

break;
}

return this.fileAction("logs/ItemLog.txt", 2, "[" + me.profile + "] <" + action + "> " + desc + "\n");
},

// Log kept item stats in the manager.
logItem: function (action, unit, keptLine) {
var i, lastArea, code, desc, sock, itemObj,
Expand Down
2 changes: 1 addition & 1 deletion d2bs/kolbot/libs/common/Pather.js
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ ModeLoop:
delay(me.ping + 1);
}

throw new Error("useWaypoint: Failed to use waypoint " + (getTickCount() - timer));
throw new Error("useWaypoint: Failed to use waypoint");
},

makePortal: function (use) {
Expand Down
2 changes: 2 additions & 0 deletions d2bs/kolbot/libs/common/Pickit.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ var Pickit = {
if (canFit) {
this.pickItem(item, status.result, status.line);
} else {
Misc.itemLogger("No room for", this.pickList[0]);
print("ÿc7Not enough room for " + color + this.pickList[0].name);

if (!!AutoMule.getMule() && AutoMule.getMuleItems().length > 0) {
Expand Down Expand Up @@ -267,6 +268,7 @@ MainLoop:
switch (status) {
case 1:
if (this.ignoreLog.indexOf(stats.type) === -1) {
Misc.itemLogger("Kept", item);
Misc.logItem("Kept", item, keptLine);
}

Expand Down
3 changes: 2 additions & 1 deletion d2bs/kolbot/libs/common/Runewords.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,8 @@ RuneLoop:
D2Bot.printToConsole("Made runeword: " + items[0].fname.split("\n").reverse().join(" ").replace(/ÿc[0-9!"+<;.*]/, ""), 5);

if (NTIP.CheckItem(items[0], this.pickitEntries)) {
Misc.logItem("Runeword kept", items[0]);
Misc.itemLogger("Runeword Kept", items[0]);
Misc.logItem("Runeword Kept", items[0]);
}
}

Expand Down
26 changes: 23 additions & 3 deletions d2bs/kolbot/libs/common/Town.js
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ MainLoop:
// Items for gold, will sell magics, etc. w/o id, but at low levels
// magics are often not worth iding.
case 4:
Misc.itemLogger("Sold", item);
item.sell();

break;
Expand Down Expand Up @@ -465,6 +466,7 @@ MainLoop:

switch (result.result) {
case 1:
Misc.itemLogger("Kept", item);
Misc.logItem("Kept", item, result.line);

break;
Expand All @@ -473,6 +475,7 @@ MainLoop:
case 3: // just in case
break;
default:
Misc.itemLogger("Sold", item);
item.sell();

timer = getTickCount() - this.sellTimer; // shop speedup test
Expand Down Expand Up @@ -547,10 +550,12 @@ MainLoop:

switch (result.result) {
case 0:
Misc.itemLogger("Dropped", unids[i]);
unids[i].drop();

break;
case 1:
Misc.itemLogger("Kept", unids[i]);
Misc.logItem("Kept", unids[i], result.line);

break;
Expand Down Expand Up @@ -590,10 +595,12 @@ MainLoop:

switch (result.result) {
case 0:
Misc.itemLogger("Dropped", item);
item.drop();

break;
case 1:
Misc.itemLogger("Field Kept", item);
Misc.logItem("Field Kept", item, result.line);

break;
Expand Down Expand Up @@ -720,6 +727,7 @@ CursorLoop:
if (result.result === 1) {
try {
if (Storage.Inventory.CanFit(items[i]) && me.getStat(14) + me.getStat(15) >= items[i].getItemCost(0)) {
Misc.itemLogger("Shopped", items[i]);
Misc.logItem("Shopped", items[i], result.line);
items[i].buy();
}
Expand Down Expand Up @@ -787,6 +795,7 @@ CursorLoop:

switch (result.result) {
case 1:
Misc.itemLogger("Gambled", newItem);
Misc.logItem("Gambled", newItem, result.line);
list.push(newItem.gid);

Expand All @@ -797,6 +806,7 @@ CursorLoop:

break;
default:
Misc.itemLogger("Sold", newItem);
newItem.sell();
delay(500);

Expand Down Expand Up @@ -1101,13 +1111,20 @@ MainLoop:

me.cancel();

var i,
var i, result,
items = Storage.Inventory.Compare(Config.Inventory);

if (items) {
for (i = 0; i < items.length; i += 1) {
if (this.ignoredItemTypes.indexOf(items[i].itemType) === -1 && ((Pickit.checkItem(items[i]).result > 0 && Pickit.checkItem(items[i]).result < 4) || Cubing.keepItem(items[i]) || Runewords.keepItem(items[i]))) {
Storage.Stash.MoveTo(items[i]);
if (this.ignoredItemTypes.indexOf(items[i].itemType) === -1 && Storage.Stash.CanFit(items[i])) {
result = Pickit.checkItem(items[i]).result > 0 && Pickit.checkItem(items[i]).result < 4 ? "pickit" :
Cubing.keepItem(items[i]) ? "cubing" :
Runewords.keepItem(items[i]) ? "runewords" : false;

if (result) {
Misc.itemLogger("Stashed", items[i]);
Storage.Stash.MoveTo(items[i]);
}
}
}
}
Expand Down Expand Up @@ -1330,6 +1347,7 @@ MainLoop:

for (i = 0; !!items && i < items.length; i += 1) {
if (items[i].location === 3 && items[i].mode === 0 && items[i].itemType === 22) {
Misc.itemLogger("Dropped", items[i]);
items[i].drop();
}
}
Expand Down Expand Up @@ -1399,8 +1417,10 @@ MainLoop:
) {
try {
if (loseItemAction === sellAction) {
Misc.itemLogger("Sold", items[i]);
items[i].sell();
} else {
Misc.itemLogger("Dropped", items[i]);
items[i].drop();
}
} catch (e) {
Expand Down
4 changes: 4 additions & 0 deletions d2bs/kolbot/libs/config/Amazon.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,10 @@ function LoadConfig() {
Config.PickRange = 40; // Pick radius
Config.FastPick = false; // Check and pick items between attacks

// Additional item info log settings. All info goes to \logs\ItemLog.txt
Config.ItemInfo = false; // Log stashed, skipped (due to no space) or sold items.
Config.ItemInfoQuality = []; // The quality of sold items to log.

// Item identification settings
Config.CainID.Enable = false; // Identify items at Cain
Config.CainID.MinGold = 2500000; // Minimum gold (stash + character) to have in order to use Cain.
Expand Down
4 changes: 4 additions & 0 deletions d2bs/kolbot/libs/config/Assassin.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,10 @@ function LoadConfig() {
Config.PickRange = 40; // Pick radius
Config.FastPick = false; // Check and pick items between attacks

// Additional item info log settings. All info goes to \logs\ItemLog.txt
Config.ItemInfo = false; // Log stashed, skipped (due to no space) or sold items.
Config.ItemInfoQuality = []; // The quality of sold items to log.

// Item identification settings
Config.CainID.Enable = false; // Identify items at Cain
Config.CainID.MinGold = 2500000; // Minimum gold (stash + character) to have in order to use Cain.
Expand Down
Loading

0 comments on commit 78d7fcb

Please sign in to comment.