From 87e1db376f98ac720dbbbd85cfe5d7e9d9630193 Mon Sep 17 00:00:00 2001 From: Jesse Michelsen Date: Thu, 20 Feb 2020 21:16:43 -0700 Subject: [PATCH 1/7] Add DeepStats reporting functionality This is a skeleton feature. It does not have any backend attached so you must build your own backend to recieve the data --- d2bs/kolbot/libs/OOG.js | 60 +++++++++++++++++++++++++- d2bs/kolbot/libs/common/Config.js | 12 ++++++ d2bs/kolbot/libs/common/Misc.js | 56 ++++++++++++++++++++++-- d2bs/kolbot/libs/config/Amazon.js | 7 +++ d2bs/kolbot/libs/config/Assassin.js | 7 +++ d2bs/kolbot/libs/config/Barbarian.js | 7 +++ d2bs/kolbot/libs/config/Druid.js | 7 +++ d2bs/kolbot/libs/config/Necromancer.js | 7 +++ d2bs/kolbot/libs/config/Paladin.js | 7 +++ d2bs/kolbot/libs/config/Sorceress.js | 7 +++ d2bs/kolbot/libs/modules/Events.js | 5 ++- d2bs/kolbot/libs/modules/HTTP.js | 52 ++++++++++++++++++++++ d2bs/kolbot/libs/modules/Socket.js | 57 ++++++++++++++++++++++++ d2bs/kolbot/tools/ToolsThread.js | 43 ++++++++++++++++++ 14 files changed, 328 insertions(+), 6 deletions(-) create mode 100644 d2bs/kolbot/libs/modules/HTTP.js create mode 100644 d2bs/kolbot/libs/modules/Socket.js diff --git a/d2bs/kolbot/libs/OOG.js b/d2bs/kolbot/libs/OOG.js index e914af3c7..ce49c7545 100644 --- a/d2bs/kolbot/libs/OOG.js +++ b/d2bs/kolbot/libs/OOG.js @@ -383,6 +383,7 @@ var DataFile = { experience: 0, deaths: 0, lastArea: "", + lastAreaID: 0, gold: 0, level: 0, name: "", @@ -423,7 +424,7 @@ var DataFile = { print("Error reading DataFile. Using null values."); - return {runs: 0, experience: 0, lastArea: "", gold: 0, level: 0, name: "", gameName: "", ingameTick: 0, handle: 0, nextGame: ""}; + return {runs: 0, experience: 0, lastArea: "", lastAreaID: 0, gold: 0, level: 0, name: "", gameName: "", ingameTick: 0, handle: 0, nextGame: ""}; }, getStats: function () { @@ -463,6 +464,7 @@ var DataFile = { } obj.lastArea = Pather.getAreaName(me.area); + obj.lastAreaID = me.area; break; case "gold": @@ -499,6 +501,62 @@ var DataFile = { } }; +const DeepStats = { + create: function () { + let obj = [], + string; + + string = JSON.stringify(obj); + + Misc.fileAction("data/deepstats/" + me.profile + ".dump.json", 1, string); + + return obj; + }, + + getObj: function () { + let obj, string; + + if (!FileTools.exists("data/deepstats/" + me.profile + ".dump.json")) { + DeepStats.create(); + } + + string = Misc.fileAction("data/deepstats/" + me.profile + ".dump.json", 0); + + try { + obj = JSON.parse(string); + } catch (e) { + // If we failed, file might be corrupted, so create a new one + obj = this.create(); + } + + if (obj) { + return obj; + } + + print("Error reading DeepStats file. Using null values."); + + return []; + }, + + updateStats: function (value) { + while (me.ingame && !me.gameReady) { + delay(100); + } + + let currentStats, string; + + currentStats = this.getObj(); + + if (typeof value === "string") { + currentStats.push(value); + } + + string = JSON.stringify(currentStats); + + Misc.fileAction("data/deepstats/" + me.profile + ".dump.json", 1, string); + } +}; + var ControlAction = { mutedKey: false, diff --git a/d2bs/kolbot/libs/common/Config.js b/d2bs/kolbot/libs/common/Config.js index f6bc3d19c..cbcf3a1aa 100644 --- a/d2bs/kolbot/libs/common/Config.js +++ b/d2bs/kolbot/libs/common/Config.js @@ -195,6 +195,18 @@ var Config = { SkipException: [], ScanShrines: [], Debug: false, + DeepStats: { + StatsEnabled: false, + SOJReportsEnabled: false, + DCloneReportsEnabled: false, + FileLogOnly: false, + API: { + Token: "", // Auth token used to authenticate, if required, to your backend of choice + ReportItem: "", // Item endpoint at your backend of choice + ReportDClone: "", // DClone reporting endpoint at your backend of choice + ReportSOJsSold: "" // SOJs Sale reporting endpoint at your backend of choice + } + }, AutoMule: { Trigger: [], diff --git a/d2bs/kolbot/libs/common/Misc.js b/d2bs/kolbot/libs/common/Misc.js index fe72eac1e..495ef50d1 100644 --- a/d2bs/kolbot/libs/common/Misc.js +++ b/d2bs/kolbot/libs/common/Misc.js @@ -1361,7 +1361,7 @@ var Misc = { return false; } - var i; + let i; if (!Config.LogKeys && ["pk1", "pk2", "pk3"].indexOf(unit.code) > -1) { return false; @@ -1397,15 +1397,18 @@ var Misc = { } } - var lastArea, code, desc, sock, itemObj, + let lastArea, code, desc, raw_desc, sock, itemObj, deepstatsData, + lastAreaID = 0, color = -1, name = unit.fname.split("\n").reverse().join(" ").replace(/ÿc[0-9!"+<:;.*]|\/|\\/g, "").trim(); + raw_desc = this.getItemDesc(unit); desc = this.getItemDesc(unit); color = unit.getColor(); if (action.match("kept", "i")) { lastArea = DataFile.getStats().lastArea; + lastAreaID = DataFile.getStats().lastAreaID; if (lastArea) { desc += ("\n\\xffc0Area: " + lastArea); @@ -1583,6 +1586,53 @@ var Misc = { sockets: this.getItemSockets(unit) }; + if (Config.DeepStats.Enabled) { + deepstatsData = { + item_id: Date.now().toString(36) + "$" + unit.gid + ":" + unit.classid + ":" + unit.location + ":" + unit.x + ":" + unit.y + (unit.getFlag(0x400000) ? ":eth" : ""), + name: name, + fname: unit.fname, + description: desc, + action: action, + ilvl: unit.ilvl, + lvlreq: unit.lvlreq, + quality: unit.quality, + code: code, + class_id: unit.classid, + ethereal: !!unit.getFlag(0x400000), + last_area: lastAreaID, + difficulty: me.diff, + player_count: this.playerCount(), + char_name: me.charname, + char_level: me.charlvl, + char_class: me.classid, + char_mf: me.getStat(80), + ladder: me.ladder > 0, + realm: me.realm, + hardcore: me.playertype, + expansion: me.gametype === 1, + can_teleport: me.getSkill(54, 1) > 0 + }; + + if (Config.DeepStats.FileLogOnly) { + DeepStats.updateStats(JSON.stringify(deepstatsData)); + } else if (!Config.DeepStats.API.Token) { + throw new Error("An auth token is required. Set Config.DeepStats.Token"); + } else { + const HTTP = require("../modules/HTTP"); + DeepStats.updateStats(JSON.stringify(deepstatsData)); + HTTP({ + url: Config.DeepStats.API.ReportItem, + method: "POST", + headers: { + "Authorization": "Token " + Config.DeepStats.API.Token, + "Content-Type": "application/json", + "Connection": "close" + }, + data: JSON.stringify(deepstatsData) + }); + } + } + D2Bot.printToItemLog(itemObj); return true; @@ -1941,7 +1991,7 @@ MainLoop: }, // Use a NPC menu. Experimental function, subject to change - // id = string number (with exception of Ressurect merc). + // id = string number (with exception of Ressurect merc). http://www.blizzhackers.cc/viewtopic.php?f=209&t=378493 useMenu: function (id) { //print("useMenu " + getLocaleString(id)); diff --git a/d2bs/kolbot/libs/config/Amazon.js b/d2bs/kolbot/libs/config/Amazon.js index 086215b0b..73d38c9f8 100644 --- a/d2bs/kolbot/libs/config/Amazon.js +++ b/d2bs/kolbot/libs/config/Amazon.js @@ -16,6 +16,13 @@ function LoadConfig() { // User addon script. Read the description in libs/bots/UserAddon.js Scripts.UserAddon = true; // !!!YOU MUST SET THIS TO FALSE IF YOU WANT TO RUN BOSS/AREA SCRIPTS!!! + // DeepStats item logging and reporting + DeepStats.StatsEnabled = false; + DeepStats.API.Token = ""; // Auth token used to authenticate, if required, to your backend of choice + DeepStats.SOJReportsEnabled = false; + DeepStats.DCloneReportsEnabled = false; + DeepStats.FileLogOnly = false; + // 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 diff --git a/d2bs/kolbot/libs/config/Assassin.js b/d2bs/kolbot/libs/config/Assassin.js index 367a85144..71cf51761 100644 --- a/d2bs/kolbot/libs/config/Assassin.js +++ b/d2bs/kolbot/libs/config/Assassin.js @@ -16,6 +16,13 @@ function LoadConfig() { // User addon script. Read the description in libs/bots/UserAddon.js Scripts.UserAddon = true; // !!!YOU MUST SET THIS TO FALSE IF YOU WANT TO RUN BOSS/AREA SCRIPTS!!! + // DeepStats item logging and reporting + DeepStats.StatsEnabled = false; + DeepStats.API.Token = ""; // Auth token used to authenticate, if required, to your backend of choice + DeepStats.SOJReportsEnabled = false; + DeepStats.DCloneReportsEnabled = false; + DeepStats.FileLogOnly = false; + // 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 diff --git a/d2bs/kolbot/libs/config/Barbarian.js b/d2bs/kolbot/libs/config/Barbarian.js index 2b6a2e649..7f6b573d0 100644 --- a/d2bs/kolbot/libs/config/Barbarian.js +++ b/d2bs/kolbot/libs/config/Barbarian.js @@ -16,6 +16,13 @@ function LoadConfig() { // User addon script. Read the description in libs/bots/UserAddon.js Scripts.UserAddon = true; // !!!YOU MUST SET THIS TO FALSE IF YOU WANT TO RUN BOSS/AREA SCRIPTS!!! + // DeepStats item logging and reporting + DeepStats.StatsEnabled = false; + DeepStats.API.Token = ""; // Auth token used to authenticate, if required, to your backend of choice + DeepStats.SOJReportsEnabled = false; + DeepStats.DCloneReportsEnabled = false; + DeepStats.FileLogOnly = false; + // 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 diff --git a/d2bs/kolbot/libs/config/Druid.js b/d2bs/kolbot/libs/config/Druid.js index 375e75cfd..92347927b 100644 --- a/d2bs/kolbot/libs/config/Druid.js +++ b/d2bs/kolbot/libs/config/Druid.js @@ -16,6 +16,13 @@ function LoadConfig() { // User addon script. Read the description in libs/bots/UserAddon.js Scripts.UserAddon = true; // !!!YOU MUST SET THIS TO FALSE IF YOU WANT TO RUN BOSS/AREA SCRIPTS!!! + // DeepStats item logging and reporting + DeepStats.StatsEnabled = false; + DeepStats.API.Token = ""; // Auth token used to authenticate, if required, to your backend of choice + DeepStats.SOJReportsEnabled = false; + DeepStats.DCloneReportsEnabled = false; + DeepStats.FileLogOnly = false; + // 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 diff --git a/d2bs/kolbot/libs/config/Necromancer.js b/d2bs/kolbot/libs/config/Necromancer.js index b48fc5ba1..faa279383 100644 --- a/d2bs/kolbot/libs/config/Necromancer.js +++ b/d2bs/kolbot/libs/config/Necromancer.js @@ -16,6 +16,13 @@ function LoadConfig() { // User addon script. Read the description in libs/bots/UserAddon.js Scripts.UserAddon = true; // !!!YOU MUST SET THIS TO FALSE IF YOU WANT TO RUN BOSS/AREA SCRIPTS!!! + // DeepStats item logging and reporting + DeepStats.StatsEnabled = false; + DeepStats.API.Token = ""; // Auth token used to authenticate, if required, to your backend of choice + DeepStats.SOJReportsEnabled = false; + DeepStats.DCloneReportsEnabled = false; + DeepStats.FileLogOnly = false; + // 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 diff --git a/d2bs/kolbot/libs/config/Paladin.js b/d2bs/kolbot/libs/config/Paladin.js index 2ac843eae..d4cc165e8 100644 --- a/d2bs/kolbot/libs/config/Paladin.js +++ b/d2bs/kolbot/libs/config/Paladin.js @@ -16,6 +16,13 @@ function LoadConfig() { // User addon script. Read the description in libs/bots/UserAddon.js Scripts.UserAddon = true; // !!!YOU MUST SET THIS TO FALSE IF YOU WANT TO RUN BOSS/AREA SCRIPTS!!! + // DeepStats item logging and reporting + DeepStats.StatsEnabled = false; + DeepStats.API.Token = ""; // Auth token used to authenticate, if required, to your backend of choice + DeepStats.SOJReportsEnabled = false; + DeepStats.DCloneReportsEnabled = false; + DeepStats.FileLogOnly = false; + // 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 diff --git a/d2bs/kolbot/libs/config/Sorceress.js b/d2bs/kolbot/libs/config/Sorceress.js index 5d8f928ee..5ffe8bc8d 100644 --- a/d2bs/kolbot/libs/config/Sorceress.js +++ b/d2bs/kolbot/libs/config/Sorceress.js @@ -16,6 +16,13 @@ function LoadConfig() { // User addon script. Read the description in libs/bots/UserAddon.js Scripts.UserAddon = true; // !!!YOU MUST SET THIS TO FALSE IF YOU WANT TO RUN BOSS/AREA SCRIPTS!!! + // DeepStats item logging and reporting + DeepStats.StatsEnabled = false; + DeepStats.API.Token = ""; // Auth token used to authenticate, if required, to your backend of choice + DeepStats.SOJReportsEnabled = false; + DeepStats.DCloneReportsEnabled = false; + DeepStats.FileLogOnly = false; + // 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 diff --git a/d2bs/kolbot/libs/modules/Events.js b/d2bs/kolbot/libs/modules/Events.js index b1f6f44c1..027e20f27 100644 --- a/d2bs/kolbot/libs/modules/Events.js +++ b/d2bs/kolbot/libs/modules/Events.js @@ -7,6 +7,7 @@ (function (module, require) { const Events = module.exports = function () { const Worker = require('Worker'), self = this; + let hook; this.hooks = []; @@ -32,11 +33,11 @@ this.once = function (name, callback) { if (callback === undefined && typeof name === 'function') [callback,name] = [name,callback]; - const Hook = new Hook(name, function (...args) { + hook = new Hook(name, function (...args) { callback.apply(undefined, args); delete self.hooks[this.id]; }); - Hook.__callback = callback; + hook.__callback = callback; }; this.off = function (name, callback) { diff --git a/d2bs/kolbot/libs/modules/HTTP.js b/d2bs/kolbot/libs/modules/HTTP.js new file mode 100644 index 000000000..b8dd41294 --- /dev/null +++ b/d2bs/kolbot/libs/modules/HTTP.js @@ -0,0 +1,52 @@ +/** + * @description Do a http request + * @author jaenster + */ + +(function (module, require) { + + const Socket = require('Socket'); + const Promise = require('Promise'); + + const defaultOptions = { + url: '', + headers: { + 'User-Agent': 'd2bs', + 'Accept': '*/*', + }, + port: 80, + method: 'GET', + data: '', // Fill with content for post + }; + + const HTTP = function (config = {}) { + config = Object.assign(defaultOptions, config); + if (!config.url) { + throw new Error('Must give a url to connect to') + } + const [fullUrl, protocol, hostname, uri] = config.url.match(/^(.*:)\/\/([A-Za-z0-9\-\.]+)?(.*)/); + const socket = new Socket(hostname, config.port); + + socket.connect(); + if (!socket.connected) { + throw new Error('failed to connect to ' + hostname); + } + + if (config.data.length) { // in case we send data + config.headers['Content-Length'] = config.data.length; + } + config.headers['Host'] = hostname; // required for HTTP/1.1 + + const data = [config.method + ' ' + uri + ' ' + 'HTTP/1.1']; + Object.keys(config.headers).forEach((key) => data.push(key + ': ' + config.headers[key])); + + socket.send(data.join('\r\n') + '\r\n\r\n' + config.data); + + let recvd = false; // where we store recv'd data + socket.once('data', data => recvd = data); + return new Promise((resolve) => recvd && resolve(recvd)); + }; + + module.exports = HTTP; + +}).call(null, module, require); diff --git a/d2bs/kolbot/libs/modules/Socket.js b/d2bs/kolbot/libs/modules/Socket.js new file mode 100644 index 000000000..3e55f2dc2 --- /dev/null +++ b/d2bs/kolbot/libs/modules/Socket.js @@ -0,0 +1,57 @@ +/** + * @description a wrapper around the socket object + * @author Jaenster + */ + + +(function (module, require, buildinSock) { + const Worker = require('Worker'); + const Events = require('Events'); + + /** @constructor Socket*/ + function Socket(hostname, port) { + typeof Socket.__socketCounter === 'undefined' && (Socket.__socketCounter = 0); + this.connected = false; + const myEvents = new Events; + this.connect = () => (this.socket = buildinSock.open(hostname, port)) && (this.connected = true) && this; + + this.on = myEvents.on; + this.off = myEvents.off; + this.once = myEvents.once; + + const close = () => { + this.socket = null; + this.connected = false; + myEvents.emit('close', this); + }; + + this.recv = () => { + if (!this.connected || !this.socket || !this.socket.readable) return; + + const data = (() => { + try { + return this.socket.read() + } catch (e) { + close(); + } + return undefined; + })(); + + data && myEvents.emit('data', data); + }; + + this.send = (data) => { + if (!data || !this.socket) return; + + try { + this.socket.send(data); + } catch (e) { + close(); + } + }; + + Worker.runInBackground['__socket__' + (++Socket.__socketCounter)] = () => this.recv() || this.send() || true; + } + + module.exports = Socket; +}).call(null, module, require, Socket); diff --git a/d2bs/kolbot/tools/ToolsThread.js b/d2bs/kolbot/tools/ToolsThread.js index 31c9a4bc6..4e78026c2 100644 --- a/d2bs/kolbot/tools/ToolsThread.js +++ b/d2bs/kolbot/tools/ToolsThread.js @@ -48,6 +48,7 @@ function main() { CraftingSystem.buildLists(); Runewords.init(); Cubing.init(); + const HTTP = require("../libs/modules/HTTP"); for (i = 0; i < 5; i += 1) { timerLastDrink[i] = 0; @@ -466,6 +467,28 @@ function main() { if (Config.SoJWaitTime && me.gametype === 1) { // only do this in expansion D2Bot.printToConsole(param1 + " Stones of Jordan Sold to Merchants on IP " + me.gameserverip.split(".")[3], 7); + + if (Config.DeepStats.SOJReportsEnabled) { + if (!Config.DeepStats.API.Token) { + throw new Error("An auth token is required. Set Config.DeepStats.API.Token"); + } + let soj_data = { + ip_address: me.gameserverip.split(".")[3], + realm: me.realm, + ladder: me.ladder > 0, + current_count: param1, + }; + HTTP({ + url: Config.DeepStats.API.ReportSOJsSold, + method: "POST", + headers: { + "Authorization": "Token " + Config.DeepStats.API.Token, + "Content-Type": "application/json", + }, + data: JSON.stringify(soj_data) + }); + } + Messaging.sendToScript("default.dbj", "soj"); } @@ -491,6 +514,26 @@ function main() { me.maxgametime = 0; + if (Config.DeepStats.DCloneReportsEnabled) { + if (!Config.DeepStats.API.Token) { + throw new Error("An auth token is required. Set Config.DeepStats.API.Token"); + } + let dclone_data = { + ip_address: me.gameserverip.split(".")[3], + realm: me.realm, + ladder: me.ladder > 0, + }; + HTTP({ + url: Config.DeepStats.API.ReportDClone, + method: "POST", + headers: { + "Authorization": "Token " + Config.DeepStats.API.Token, + "Content-Type": "application/json", + }, + data: JSON.stringify(dclone_data) + }); + } + if (Config.KillDclone) { load("tools/clonekilla.js"); } From 63dd627c365bf16f4741b8d947d54127104c7d91 Mon Sep 17 00:00:00 2001 From: Jesse Michelsen Date: Wed, 26 Feb 2020 13:57:20 -0700 Subject: [PATCH 2/7] Add getEstimateBuild to stats dumped This will check your chars skill allocation and estimate the build you are running --- d2bs/kolbot/libs/common/Misc.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/d2bs/kolbot/libs/common/Misc.js b/d2bs/kolbot/libs/common/Misc.js index 495ef50d1..cac68c694 100644 --- a/d2bs/kolbot/libs/common/Misc.js +++ b/d2bs/kolbot/libs/common/Misc.js @@ -1201,6 +1201,15 @@ var Misc = { return false; }, + getEstimatedBuild: function () { + let counter, build = 0, builds = [49, 53, 56, 59, 64, 97, 106, 112, 147, 149, 151, 152]; + for (counter = 0; counter < builds.length; counter++) { + if (me.getSkill(builds[counter], 1) > build) { + build = builds[counter]; + } + } + }, + getItemDesc: function (unit) { var i, desc, index, stringColor = ""; @@ -1586,7 +1595,7 @@ var Misc = { sockets: this.getItemSockets(unit) }; - if (Config.DeepStats.Enabled) { + if (Config.DeepStats.StatsEnabled) { deepstatsData = { item_id: Date.now().toString(36) + "$" + unit.gid + ":" + unit.classid + ":" + unit.location + ":" + unit.x + ":" + unit.y + (unit.getFlag(0x400000) ? ":eth" : ""), name: name, @@ -1598,10 +1607,11 @@ var Misc = { quality: unit.quality, code: code, class_id: unit.classid, + type: unit.itemType, ethereal: !!unit.getFlag(0x400000), last_area: lastAreaID, difficulty: me.diff, - player_count: this.playerCount(), + player_count: this.getPlayerCount(), char_name: me.charname, char_level: me.charlvl, char_class: me.classid, @@ -1610,7 +1620,8 @@ var Misc = { realm: me.realm, hardcore: me.playertype, expansion: me.gametype === 1, - can_teleport: me.getSkill(54, 1) > 0 + can_teleport: me.getSkill(54, 1) > 0, + build: this.getEstimatedBuild(), }; if (Config.DeepStats.FileLogOnly) { From 611f8712ee40b76817cdc1db02bd65bf16617b57 Mon Sep 17 00:00:00 2001 From: Jesse Michelsen Date: Wed, 26 Feb 2020 14:03:11 -0700 Subject: [PATCH 3/7] Remove unused raw_desc param --- d2bs/kolbot/libs/common/Misc.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/d2bs/kolbot/libs/common/Misc.js b/d2bs/kolbot/libs/common/Misc.js index cac68c694..5c224c90e 100644 --- a/d2bs/kolbot/libs/common/Misc.js +++ b/d2bs/kolbot/libs/common/Misc.js @@ -1406,12 +1406,11 @@ var Misc = { } } - let lastArea, code, desc, raw_desc, sock, itemObj, deepstatsData, + let lastArea, code, desc, sock, itemObj, deepstatsData, lastAreaID = 0, color = -1, name = unit.fname.split("\n").reverse().join(" ").replace(/ÿc[0-9!"+<:;.*]|\/|\\/g, "").trim(); - raw_desc = this.getItemDesc(unit); desc = this.getItemDesc(unit); color = unit.getColor(); From af552e0acc41af5f3182c877151381d9820056d4 Mon Sep 17 00:00:00 2001 From: Jesse Michelsen Date: Wed, 26 Feb 2020 14:04:54 -0700 Subject: [PATCH 4/7] Fix inaccurate string in thown error message --- d2bs/kolbot/libs/common/Misc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/d2bs/kolbot/libs/common/Misc.js b/d2bs/kolbot/libs/common/Misc.js index 5c224c90e..bb7975496 100644 --- a/d2bs/kolbot/libs/common/Misc.js +++ b/d2bs/kolbot/libs/common/Misc.js @@ -1626,7 +1626,7 @@ var Misc = { if (Config.DeepStats.FileLogOnly) { DeepStats.updateStats(JSON.stringify(deepstatsData)); } else if (!Config.DeepStats.API.Token) { - throw new Error("An auth token is required. Set Config.DeepStats.Token"); + throw new Error("An auth token is required. Set Config.DeepStats.API.Token"); } else { const HTTP = require("../modules/HTTP"); DeepStats.updateStats(JSON.stringify(deepstatsData)); From c2d6bb2fd55fe073018a8dde09e194401a57d83e Mon Sep 17 00:00:00 2001 From: Jesse Michelsen Date: Wed, 26 Feb 2020 14:07:39 -0700 Subject: [PATCH 5/7] Remove dead link --- d2bs/kolbot/libs/common/Misc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/d2bs/kolbot/libs/common/Misc.js b/d2bs/kolbot/libs/common/Misc.js index bb7975496..a51b91f27 100644 --- a/d2bs/kolbot/libs/common/Misc.js +++ b/d2bs/kolbot/libs/common/Misc.js @@ -2001,7 +2001,7 @@ MainLoop: }, // Use a NPC menu. Experimental function, subject to change - // id = string number (with exception of Ressurect merc). http://www.blizzhackers.cc/viewtopic.php?f=209&t=378493 + // id = string number (with exception of Ressurect merc). useMenu: function (id) { //print("useMenu " + getLocaleString(id)); From 1933e8cf095a7d3f8ea46eab13b126054fd2fac8 Mon Sep 17 00:00:00 2001 From: Jesse Michelsen Date: Wed, 26 Feb 2020 14:10:54 -0700 Subject: [PATCH 6/7] Remove stub of deepstats from config templates --- d2bs/kolbot/libs/config/Amazon.js | 7 ------- d2bs/kolbot/libs/config/Assassin.js | 7 ------- d2bs/kolbot/libs/config/Barbarian.js | 7 ------- d2bs/kolbot/libs/config/Druid.js | 7 ------- d2bs/kolbot/libs/config/Necromancer.js | 7 ------- d2bs/kolbot/libs/config/Paladin.js | 7 ------- d2bs/kolbot/libs/config/Sorceress.js | 7 ------- 7 files changed, 49 deletions(-) diff --git a/d2bs/kolbot/libs/config/Amazon.js b/d2bs/kolbot/libs/config/Amazon.js index 73d38c9f8..086215b0b 100644 --- a/d2bs/kolbot/libs/config/Amazon.js +++ b/d2bs/kolbot/libs/config/Amazon.js @@ -16,13 +16,6 @@ function LoadConfig() { // User addon script. Read the description in libs/bots/UserAddon.js Scripts.UserAddon = true; // !!!YOU MUST SET THIS TO FALSE IF YOU WANT TO RUN BOSS/AREA SCRIPTS!!! - // DeepStats item logging and reporting - DeepStats.StatsEnabled = false; - DeepStats.API.Token = ""; // Auth token used to authenticate, if required, to your backend of choice - DeepStats.SOJReportsEnabled = false; - DeepStats.DCloneReportsEnabled = false; - DeepStats.FileLogOnly = false; - // 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 diff --git a/d2bs/kolbot/libs/config/Assassin.js b/d2bs/kolbot/libs/config/Assassin.js index 71cf51761..367a85144 100644 --- a/d2bs/kolbot/libs/config/Assassin.js +++ b/d2bs/kolbot/libs/config/Assassin.js @@ -16,13 +16,6 @@ function LoadConfig() { // User addon script. Read the description in libs/bots/UserAddon.js Scripts.UserAddon = true; // !!!YOU MUST SET THIS TO FALSE IF YOU WANT TO RUN BOSS/AREA SCRIPTS!!! - // DeepStats item logging and reporting - DeepStats.StatsEnabled = false; - DeepStats.API.Token = ""; // Auth token used to authenticate, if required, to your backend of choice - DeepStats.SOJReportsEnabled = false; - DeepStats.DCloneReportsEnabled = false; - DeepStats.FileLogOnly = false; - // 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 diff --git a/d2bs/kolbot/libs/config/Barbarian.js b/d2bs/kolbot/libs/config/Barbarian.js index 7f6b573d0..2b6a2e649 100644 --- a/d2bs/kolbot/libs/config/Barbarian.js +++ b/d2bs/kolbot/libs/config/Barbarian.js @@ -16,13 +16,6 @@ function LoadConfig() { // User addon script. Read the description in libs/bots/UserAddon.js Scripts.UserAddon = true; // !!!YOU MUST SET THIS TO FALSE IF YOU WANT TO RUN BOSS/AREA SCRIPTS!!! - // DeepStats item logging and reporting - DeepStats.StatsEnabled = false; - DeepStats.API.Token = ""; // Auth token used to authenticate, if required, to your backend of choice - DeepStats.SOJReportsEnabled = false; - DeepStats.DCloneReportsEnabled = false; - DeepStats.FileLogOnly = false; - // 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 diff --git a/d2bs/kolbot/libs/config/Druid.js b/d2bs/kolbot/libs/config/Druid.js index 92347927b..375e75cfd 100644 --- a/d2bs/kolbot/libs/config/Druid.js +++ b/d2bs/kolbot/libs/config/Druid.js @@ -16,13 +16,6 @@ function LoadConfig() { // User addon script. Read the description in libs/bots/UserAddon.js Scripts.UserAddon = true; // !!!YOU MUST SET THIS TO FALSE IF YOU WANT TO RUN BOSS/AREA SCRIPTS!!! - // DeepStats item logging and reporting - DeepStats.StatsEnabled = false; - DeepStats.API.Token = ""; // Auth token used to authenticate, if required, to your backend of choice - DeepStats.SOJReportsEnabled = false; - DeepStats.DCloneReportsEnabled = false; - DeepStats.FileLogOnly = false; - // 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 diff --git a/d2bs/kolbot/libs/config/Necromancer.js b/d2bs/kolbot/libs/config/Necromancer.js index faa279383..b48fc5ba1 100644 --- a/d2bs/kolbot/libs/config/Necromancer.js +++ b/d2bs/kolbot/libs/config/Necromancer.js @@ -16,13 +16,6 @@ function LoadConfig() { // User addon script. Read the description in libs/bots/UserAddon.js Scripts.UserAddon = true; // !!!YOU MUST SET THIS TO FALSE IF YOU WANT TO RUN BOSS/AREA SCRIPTS!!! - // DeepStats item logging and reporting - DeepStats.StatsEnabled = false; - DeepStats.API.Token = ""; // Auth token used to authenticate, if required, to your backend of choice - DeepStats.SOJReportsEnabled = false; - DeepStats.DCloneReportsEnabled = false; - DeepStats.FileLogOnly = false; - // 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 diff --git a/d2bs/kolbot/libs/config/Paladin.js b/d2bs/kolbot/libs/config/Paladin.js index d4cc165e8..2ac843eae 100644 --- a/d2bs/kolbot/libs/config/Paladin.js +++ b/d2bs/kolbot/libs/config/Paladin.js @@ -16,13 +16,6 @@ function LoadConfig() { // User addon script. Read the description in libs/bots/UserAddon.js Scripts.UserAddon = true; // !!!YOU MUST SET THIS TO FALSE IF YOU WANT TO RUN BOSS/AREA SCRIPTS!!! - // DeepStats item logging and reporting - DeepStats.StatsEnabled = false; - DeepStats.API.Token = ""; // Auth token used to authenticate, if required, to your backend of choice - DeepStats.SOJReportsEnabled = false; - DeepStats.DCloneReportsEnabled = false; - DeepStats.FileLogOnly = false; - // 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 diff --git a/d2bs/kolbot/libs/config/Sorceress.js b/d2bs/kolbot/libs/config/Sorceress.js index 5ffe8bc8d..5d8f928ee 100644 --- a/d2bs/kolbot/libs/config/Sorceress.js +++ b/d2bs/kolbot/libs/config/Sorceress.js @@ -16,13 +16,6 @@ function LoadConfig() { // User addon script. Read the description in libs/bots/UserAddon.js Scripts.UserAddon = true; // !!!YOU MUST SET THIS TO FALSE IF YOU WANT TO RUN BOSS/AREA SCRIPTS!!! - // DeepStats item logging and reporting - DeepStats.StatsEnabled = false; - DeepStats.API.Token = ""; // Auth token used to authenticate, if required, to your backend of choice - DeepStats.SOJReportsEnabled = false; - DeepStats.DCloneReportsEnabled = false; - DeepStats.FileLogOnly = false; - // 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 From 10e6050dd3171f4e18351fb6b17dcccd1231ce66 Mon Sep 17 00:00:00 2001 From: Jesse Michelsen Date: Wed, 26 Feb 2020 14:14:33 -0700 Subject: [PATCH 7/7] Add DeepStats file log sample --- d2bs/kolbot/data/deepstats/sample.json | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 d2bs/kolbot/data/deepstats/sample.json diff --git a/d2bs/kolbot/data/deepstats/sample.json b/d2bs/kolbot/data/deepstats/sample.json new file mode 100644 index 000000000..417027f69 --- /dev/null +++ b/d2bs/kolbot/data/deepstats/sample.json @@ -0,0 +1,3 @@ +[ + "{\"item_id\":\"k6x1zs56$2604023116:522:3:1:3\",\"name\":\"The Stone of Jordan Ring\",\"fname\":\"Ring\\nThe Stone of Jordan\",\"description\":\"\\\\xffc4The Stone of Jordan (75)\\n\\\\xffc4Ring\\n\\\\xffc0Required Level: 29\\n\\\\xffc3+1 to All Skills\\n\\\\xffc3Adds 1-12 lightning damage\\n\\\\xffc3+20 to Mana\\n\\\\xffc3Increase Maximum Mana 25%\\n\\\\xffc0Area: Catacombs Level 4\\n\\\\xffc0Line: perfect.nip #268$\",\"action\":\"Kept\",\"ilvl\":75,\"lvlreq\":29,\"quality\":7,\"code\":\"rin4\",\"size\":[1,1],\"class_id\":522,\"type\":10,\"ethereal\":false,\"pickit_line\":\"perfect.nip #268\",\"act\":1,\"last_area\":37,\"difficulty\":2,\"player_count\":2,\"char_name\":\"DaBest\",\"char_level\":99,\"char_class\":1,\"char_mf\":416,\"ladder\":true,\"realm\":\"USWest\",\"hardcore\":false,\"expansion\":true,\"can_teleport\":true}" +]