kolton / d2bot-with-kolbot

d2bot game manager by D3STROY3R with kolbot libs by kolton for d2bs
346 stars 332 forks source link

Help Me Display Socketed Jewel Mods Using UserAddon.js & D2BotBlank #3194

Open thetopfew opened 1 year ago

thetopfew commented 1 year ago

While I'm no guru, I've successfully created many of my own modifications in the past. This one has me stumped on some bugs in my changes.

While running D2BotBlank, you can hover over an item to show the runes socketed & jewel names only, but it does not show you the jewels' mods in popup. (see code how I am cheating it for now inside game console!)

In UserAddon.js, after Line#212, add this:


if (this.socketedItems[i].itemType === 58) { //if jewel
    // Get jewel data
    var modLine = Misc.getItemDesc(this.socketedItems[i]); //uses the getItemDesc(unit) function from Misc.js

    // Begin to clean it up & organize into array
    modLine = modLine.replace(/(\\xff|ÿ)c[0-9!"+<:;.*]|\/|\\/gi, "").trim(); //remove the nasty identifiers
    modLine = modLine.replace("Can be Inserted into Socketed Items\n", ""); //remove this stupid mod line
    modLine = modLine.split("\n"); //turn into an array by splitting text lines from item description text

    //#reference: modLine[0] is now name, modLine[1] is (see next line), modLine[2] is jewel's first mod, and then so on.
    //#this fixes when sometimes the modLine[1] is === 'Jewel' and not 'Required Level: ##'
    if (modLine[1].indexOf("Jewel") > -1) { modLine.splice(1, 1); }
    modLine.splice(1, 1); //optional - now we are certain this removes 'Required Level: ##' line

    // Display each mod line
    for (let j = 0; j < modLine.length; j += 1) {
        //#PRINT WORKS!!! EASY WAY OUT TO GET THE JOB DONE, FOR NOW...
        print(modLine[j]);

        //#FIXME: this is NOT so nice.. yet
        //this.hooks.push(new Text(modLine[j], this.x, this.y + (j + 4) * 15, 0, 13, 2));
        //frameYsize += 15;

        //#FIXME: attempt to make boxes as wide as the longest element in array,
        //#then needs to be added to new Box hook
        //if (modLine[j].length > frameXsize) {
        //frameXsize = modLine[j].length;
        //}
    }
}

PROGRESS --> You can use this to easily print jewel mods in game console!

CURRENTLY --> Popup display is unreadable where you hover. I noticed it will work better while hovering over a mercs' helm area sometimes. Also, the main item image disappears, but you can pause to see it again.

This works for me to see jewel mods, however it would be great to share a nice total completion (popup and all) to community. Thanks!