kolton / d2bot-with-kolbot

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

[Single Player]how to work with 1.13C that patched PlugY 11.02? #338

Open q3594302 opened 6 years ago

q3594302 commented 6 years ago

sorry bro, there is 2 issue: how to make kolbot work with d2x 1.13c and how to support that stash midified by PlugY( 10x10 squares /page multiply almost Infinite pages of storage space) . I can only find that 1.13d supported but no D2loader for 1.13d can work with plugy. only single player. no bnet.

noah- commented 6 years ago

You will need to build d2bs for 1.13c and replace the 1.14d binary, however, there may be other incompatibilities with PlugY.

q3594302 commented 6 years ago

thanks noah. this really stumped me. I use kolbot for fun in single player mod, It is a kind of happyness to see that bot picked one by one more Item into the PlugY stash ,it is better if bot can switch to next page once current one full ,and bot with PlugY fill more and more pages itself maybe the greatest thing for players like me who has no coding skill and no so much spare time (had to work hard to earn money for baby ) but still love this game. that's a pity. whatever , It maybe waiting for a new one who has the will and the power to do this .

I may missed 1.13d d2hackmap src and 1.13d d2multi loader, and in win 7x64 it is a poor performance to start with game.exe or diabloii.exe even plus -w ?. anywhere to get them?

q3594302 commented 6 years ago

if U have a copy, could you pls mail me one? mail to rex_android@hotmail.com as attachments if U can. sorry, the ip like mine is limited to visit / download from those netdisk site in your country.

jonashan commented 5 years ago

@q3594302 did you get the bot to work with plugy? :) I can't seem to get it to work :(

3594302 commented 5 years ago

@jonashan U mean the endless page using ?modify town.js to use say() function to make PlugY command "/insertpage" effect when current page full,I have no idea of toggle page by mimic mouse movement, maybe U could find the right way, and if U got it pls feel free to share it with us; modify storage.js to support 10 * 10 cell like below: this.StashY = me.gametype === 0 ? 4 : 10; this.Stash = new Container("Stash", 10, this.StashY, 7);

Gawson01 commented 5 years ago

Im trying to get the bot to work in the following ways.

Single player 1.13c TCP/IP games

1 leader that i control 7 leechers that follow main / assist / attack with leader ( ex: 1 barb 7 sorc )

Problems : Couldn't get the bot to work with plugy 1.13c. Couldn't even launch the game.

If i can get by this problem, im sure its easy to configure the setup im looking for.

Any tips, links or bot version to make it work on 1.13c?

WooFelele commented 5 years ago

@Gawson01 Maybe you forgot to add correct parameters (like -direct -txt) while creating a bot profile or to start a bot program as an admin?

Karyoplasma commented 4 years ago

@3594302 PlugY has functions to insert a blank stash page and to swap page contents and that's what I did to "manage" full stash pages. It's not perfect, the bot will leave empty spaces in the stash due to how I implemented it, but it works well enough for me.

Go to Town.js and into the section where it attempts to stash items (was around line 1540 for me). After the "if (items)" check, I loop through the array to check if there is any item my bot cannot stash.

var needPage = false;
for (i = 0; i < items.length; i += 1) {
    if (!Storage.Stash.CanFit(items[i])){
        needPage = true;
        break;
    }
}

if (needPage) {
    say("/insertpage");
}

"/insertpage" creates a blank new stash page behind the current active one and sets the new one as active, so you bot can stash items afterwards. After the bot stashed the items in the new page, I check if it created a new page again to swap its contents with the first page which is loaded when a new game is initiated.

if (needPage){ say("/swap 1"); }

This sets the new page as page 1 and the bot can use that new page until it needs more space.

Typing this, I realized it's probably better to swap the pages directly, so the bot attempts to fill the almost full page first, but I can't be bothered to change that. That would mean that the bot will simply stash the item that was too big to fit in the next run.

AuraofMana commented 4 years ago

@Karyoplasma How do you build against Plugy? I got the 1.13d (core15) but when I try to point it at Plugy.exe it won't show up.

Karyoplasma commented 4 years ago

@AuraofMana The PlugY zip version comes with an exe that integrates PlugY into a dll file, so you can do that and use game.exe.

AuraofMana commented 4 years ago

@Karyoplasma Wow, that was simple. Never knew you could install PlugY this way. Can you share your Town.js for the storage function getting the bot to make flip to a new page?

AuraofMana commented 4 years ago

Also confused why you did the /insertpage function this way. There is a check at for each item the bot is attempting to stash: "if (this.canStash(items[i]))" -> why not just pull out this condition, and if it ever becomes false (bot cannot store this item), do /insertpage, then keep going and put the item in the stash?

That way you don't need to deal with /swap or anything. The bot will store all items.

Unfortunately, it seems like this logic is written backward. For whatever reason, it checks if the item is stash-able before checking if it wants to stash it. So you may end up in a situation where there is an item (e.g. 8 slot bow) that it can't stash, so it go to the next page, then you end up dumping the bow anyway. Maybe the next item, which you do want to store, is a ring (1 slot) and it would have fit anyway.

BJWesenberg commented 4 years ago

@Karyoplasma Can you elaborate a little more on "The PlugY zip version comes with an exe that integrates PlugY into a dll file, so you can do that and use game.exe."? I cannot get the bot to work with PlugY. @AuraofMana maybe you could also give me some pointers? :)

Thanks in advance

Sopatis commented 4 years ago

Hello dear Diablo II community,  

I'm going to elaborate a bit on the topic Kobold & Plugy.  

First of all a huge THANK YOU to all the amazing people creating D2BS, Kobold and Plugy, and all the other contributors like @Karyoplasma and @3594302!

This guide aims to allow you to play Diablo II 1.13d with Kobold and Plugy in Single Player mode. This setup is not perfect as sometimes stash tabs are not perfectly filled, but meh, it works. =)

1. Install Diablo II 1.13d with Plugy 

We use 1.13d, because the corresponding Plugy version 11.02 is integrable into D2gfx.dll. (Like @Karyoplasma stated) Install Diablo II and patch the game to version 1.13d (Files for patching up or down as well as "PlugY, The Survival Kit v11.02 Zip" can be found at the bottom of http://plugy.free.fr/ ) Backup your D2gfx.dll and use PatchD2file.exe to integrate Plugy into D2gfx.dll (When you start the game.exe, the game will start with Plugy enabled)

2. Get Diablo II 1.13d to run on Windows 10

Unlike Version 1.14d, Version 1.13d is not really compatible with Win10, so we need a workaround: -To start the game without D2Bot: Use a shortcut to your game.exe and add the "-w" command (you may also add the nofixaspect command), so the end of your target looks like: .....Diablo II\Game.exe" -w -nofixaspect -For manual play, I recommend http://www.svenswrapper.de/, as the game just looks better and works in fullscreen, but the bot sadly does not support the Glide-Wrapper. You may also give your game.exe administrator rights and set the compatibility mode to Win XP.

3. Set up Kobold

I tried several versions and could only get patch-113d-core15 to work, so I suggest you try that one: https://github.com/blizzhackers/kolbot/tree/patch-113d-core15

4. Teach bot bigger Stash Size

Go to ..\patch-113d-core15\d2bs\kolbot\libs\common\storage.js and find line 290 Here you adjust 6X and 8Y to 10X and 10Y, so the storage function looks like this: (thanks to @3594302)

var Storage = new function () {
    this.Init = function () {
        this.StashY = me.gametype === 0 ? 4 : 10;
        this.Inventory = new Container("Inventory", 10, 4, 3);
        this.TradeScreen = new Container("Inventory", 10, 4, 5);
        this.Stash = new Container("Stash", 10, this.StashY, 7);
        this.Belt = new Container("Belt", 4 * this.BeltSize(), 1, 2);
        this.Cube = new Container("Horadric Cube", 3, 4, 6);
        this.InvRef = [];
        this.Reload();
    };

5. Teach Bot to create new Stash Tabs

Go to ..\patch-113d-core15\d2bs\kolbot\libs\common\town.js and find line 1533 We teach the bot to create a new stash tab, set it active, and switch it to position 1, as this is the tab the bot will use at the start of each run. We add four lines to the if (items) function, so it looks like this:

if (items) {                        
        for (i = 0; i < items.length; i += 1) {                 
        if (!Storage.Stash.CanFit(items[i])){               
        say("/insertpage");             
        say("/swap 1");
        D2Bot.printToConsole("New Stash Created! =)", 7);
        }

        if (this.canStash(items[i])) {              

            result = (Pickit.checkItem(items[i]).result > 0 && Pickit.checkItem(items[i]).result < 4) || Cubing.keepItem(items[i]) || Runewords.keepItem(items[i]) || CraftingSystem.keepItem(items[i]);            

            // Don't stash low tier autoequip items.            
            if (Config.AutoEquip && Pickit.checkItem(items[i]).result === 1) {          
                tier = NTIP.GetTier(items[i]);      

                if (tier > 0 && tier < 100) {       
                    result = false; 
                }       
            }           

            if (result) {           
                Misc.itemLogger("Stashed", items[i]);       
                Storage.Stash.MoveTo(items[i]);     
            }           
        }               
    }                   
}               

I hope this setup works for you as well as it does for me! =)

JusticeCother commented 4 years ago

@Sopatis I can't believe you did this just today. Over the last 48hours I have been looking into this incessantly. I decided today I would sit down and make sure I figured it out today. So I reloaded this link and scrolled down and found your comment. I was like, wait this wasnt here yesterday. Sure enough you planted this bad boy 8hours ago. AMAZING. I am working on it right now.

My only question is can we get this to work with multiple bots? TCP/IP? Spoofed Bnet server?

Sopatis commented 4 years ago

@jmcother I'm glad I made it on time. XD I realized it will create a new stash page for each item it can't fit - so if your bot is on Dyson-mode, it may create multiple pages, but usually, it's not a thing.

Anyways, I think the greatest hope for TCP/IP or other servers would be "https://github.com/haxifix/PlugY" creating such a DLL-injection like "http://plugy.free.fr/en/index.html" because then we could use the latest Kobold for 1.14d and it has more modes for TCP/IP and open B-Net. With our current 1.13d-Core 15 Kobold version we have only SP and Bnet and I don't know how to change that, sorry. In case it would work I wonder how the interaction between multiple bots and the Plugy -Stash works. Maybe you need an individual Diablo-Setup for each bot so everyone has his Plugy-Stash or all could work with one Plugy-Stash. I'm going to try two SP bots at one time and find out. Actually, you could do this: run several SP bots and simulate MP with players x command XD

JusticeCother commented 4 years ago

@Sopatis Well the stash for multiple bots is actually perfect. The reason is the stashes are separate except for when you open the shared stash. Then you can move items around easily. TCP/IP Seems like it would be more difficult to pull off than creating a private server to run the bots off the existing commands the already exist for the 1.13d version. I'm going to check into creating a private server run on my computer and if it works then I'll be able to play harder than I can on Bnet but still with all the perks and MORE since PlugY has better options for playing.

Sengiraa commented 4 years ago

Hello dear Diablo II community,  

I'm going to elaborate a bit on the topic Kobold & Plugy.  

First of all a huge THANK YOU to all the amazing people creating D2BS, Kobold and Plugy, and all the other contributors like @Karyoplasma and @3594302!

This guide aims to allow you to play Diablo II 1.13d with Kobold and Plugy in Single Player mode. This setup is not perfect as sometimes stash tabs are not perfectly filled, but meh, it works. =)

1. Install Diablo II 1.13d with Plugy 

We use 1.13d, because the corresponding Plugy version 11.02 is integrable into D2gfx.dll. (Like @Karyoplasma stated) Install Diablo II and patch the game to version 1.13d (Files for patching up or down as well as "PlugY, The Survival Kit v11.02 Zip" can be found at the bottom of http://plugy.free.fr/ ) Backup your D2gfx.dll and use PatchD2file.exe to integrate Plugy into D2gfx.dll (When you start the game.exe, the game will start with Plugy enabled)

2. Get Diablo II 1.13d to run on Windows 10

Unlike Version 1.14d, Version 1.13d is not really compatible with Win10, so we need a workaround: -To start the game without D2Bot: Use a shortcut to your game.exe and add the "-w" command (you may also add the nofixaspect command), so the end of your target looks like: .....Diablo II\Game.exe" -w -nofixaspect -For manual play, I recommend http://www.svenswrapper.de/, as the game just looks better and works in fullscreen, but the bot sadly does not support the Glide-Wrapper. You may also give your game.exe administrator rights and set the compatibility mode to Win XP.

3. Set up Kobold

I tried several versions and could only get patch-113d-core15 to work, so I suggest you try that one: https://github.com/blizzhackers/kolbot/tree/patch-113d-core15

4. Teach bot bigger Stash Size

Go to ..\patch-113d-core15\d2bs\kolbot\libs\common\storage.js and find line 290 Here you adjust 6X and 8Y to 10X and 10Y, so the storage function looks like this: (thanks to @3594302)

var Storage = new function () {
  this.Init = function () {
      this.StashY = me.gametype === 0 ? 4 : 10;
      this.Inventory = new Container("Inventory", 10, 4, 3);
      this.TradeScreen = new Container("Inventory", 10, 4, 5);
      this.Stash = new Container("Stash", 10, this.StashY, 7);
      this.Belt = new Container("Belt", 4 * this.BeltSize(), 1, 2);
      this.Cube = new Container("Horadric Cube", 3, 4, 6);
      this.InvRef = [];
      this.Reload();
  };

5. Teach Bot to create new Stash Tabs

Go to ..\patch-113d-core15\d2bs\kolbot\libs\common\town.js and find line 1533 We teach the bot to create a new stash tab, set it active, and switch it to position 1, as this is the tab the bot will use at the start of each run. We add four lines to the if (items) function, so it looks like this:

if (items) {                      
      for (i = 0; i < items.length; i += 1) {                 
      if (!Storage.Stash.CanFit(items[i])){               
      say("/insertpage");             
      say("/swap 1");
      D2Bot.printToConsole("New Stash Created! =)", 7);
      }

      if (this.canStash(items[i])) {              

          result = (Pickit.checkItem(items[i]).result > 0 && Pickit.checkItem(items[i]).result < 4) || Cubing.keepItem(items[i]) || Runewords.keepItem(items[i]) || CraftingSystem.keepItem(items[i]);            

          // Don't stash low tier autoequip items.            
          if (Config.AutoEquip && Pickit.checkItem(items[i]).result === 1) {          
              tier = NTIP.GetTier(items[i]);      

              if (tier > 0 && tier < 100) {       
                  result = false; 
              }       
          }           

          if (result) {           
              Misc.itemLogger("Stashed", items[i]);       
              Storage.Stash.MoveTo(items[i]);     
          }           
      }               
  }                   
}             

I hope this setup works for you as well as it does for me! =)

Hey man, thanks a lot for this. I have been wanting to do this for quite some time! However I am running into a lot of issues with this rn, any chance you'd add me on discord and help me out? Sengira#5589

CBShore commented 3 years ago

Hello, thanks very much for this guide, I really appreciate it

I got the Kolbolt to work fine until I added the stash and items code in town.js and storgae.js

I've tried to sort it on my own by I am extremely poor at coding, any help is appreciated

Below is a shot of the error; Kolbolt Error

texxxmex commented 3 years ago

Hello, thanks very much for this guide, I really appreciate it

I got the Kolbolt to work fine until I added the stash and items code in town.js and storgae.js

I've tried to sort it on my own by I am extremely poor at coding, any help is appreciated

Below is a shot of the error; Kolbolt Error

CBShore, looks like your character name is invalid. Can’t tell what it is from the s/s but I’d check that first.

injectJon commented 3 years ago

5. Teach Bot to create new Stash Tabs

Go to ..\patch-113d-core15\d2bs\kolbot\libs\common\town.js and find line 1533 We teach the bot to create a new stash tab, set it active, and switch it to position 1, as this is the tab the bot will use at the start of each run. We add four lines to the if (items) function, so it looks like this:

if (items) {                      
      for (i = 0; i < items.length; i += 1) {                 
      if (!Storage.Stash.CanFit(items[i])){               
      say("/insertpage");             
      say("/swap 1");
      D2Bot.printToConsole("New Stash Created! =)", 7);
      }

      if (this.canStash(items[i])) {              

          result = (Pickit.checkItem(items[i]).result > 0 && Pickit.checkItem(items[i]).result < 4) || Cubing.keepItem(items[i]) || Runewords.keepItem(items[i]) || CraftingSystem.keepItem(items[i]);            

          // Don't stash low tier autoequip items.            
          if (Config.AutoEquip && Pickit.checkItem(items[i]).result === 1) {          
              tier = NTIP.GetTier(items[i]);      

              if (tier > 0 && tier < 100) {       
                  result = false; 
              }       
          }           

          if (result) {           
              Misc.itemLogger("Stashed", items[i]);       
              Storage.Stash.MoveTo(items[i]);     
          }           
      }               
  }                   
}             

I hope this setup works for you as well as it does for me! =)

@Sopatis Thank you for such a detailed solution to a problem many were having, including myself! I made a few changes to "5. Teach Bot to create new Stash Tabs". Here is my solution:

if (items) {
    var madeNewTab = false;
    for (i = 0; i < items.length; i += 1) {
        if (this.canStash(items[i])) {
            result = (Pickit.checkItem(items[i]).result > 0 && Pickit.checkItem(items[i]).result < 4) || Cubing.keepItem(items[i]) || Runewords.keepItem(items[i]) || CraftingSystem.keepItem(items[i]);

            // Don't stash low tier autoequip items.
            if (Config.AutoEquip && Pickit.checkItem(items[i]).result === 1) {
                tier = NTIP.GetTier(items[i]);

                if (tier > 0 && tier < 100) {
                    result = false;
                }
            }

            if (result) {
                // PlugY stash routine for creating stash pages as needed
                if (!madeNewTab && !Storage.Stash.CanFit(items[i])) {
                    say("/insertpage");
                    say("/swap 1");
                    madeNewTab = true;
                    Misc.itemLogger("Created new stash tab");
                }

                Misc.itemLogger("Stashed", items[i]);
                Storage.Stash.MoveTo(items[i]);
            }
        }
    }
}

We move the Stash.CanFit check such that it's only ran if we have confirmed we'll be stashing the item, and we add a flag variable (madeNewTab) to ensure we only ever create one new tab per Stash instance.

scjww commented 3 years ago

Running D2 1.14d, Plugy 14.02, Kolbot core 15.

The following seems to work for me. If the bot picks up an item it wants to stash but doesn't have the space to do so, it ends up creating a new page and stashing it in the new page on the next game.

Not sure why this placement worked for me and not the others listed in previous posts, but if someone else has the same problem I had, maybe this will help.

if (items) {
    for (i = 0; i < items.length; i += 1) {
        if (this.canStash(items[i])) {
            result = (Pickit.checkItem(items[i]).result > 0 && Pickit.checkItem(items[i]).result < 4) || Cubing.keepItem(items[i]) || Runewords.keepItem(items[i]) || CraftingSystem.keepItem(items[i]);

            // Don't stash low tier autoequip items.
            if (Config.AutoEquip && Pickit.checkItem(items[i]).result === 1) {
                tier = NTIP.GetTier(items[i]);

                if (tier > 0 && tier < 100) {
                    result = false;
                }
            }
            if (result) {
                Misc.itemLogger("Stashed", items[i]);
                Storage.Stash.MoveTo(items[i]);
            }
        }

        //Make new page and swap
        if (!Storage.Stash.CanFit(items[i])) {
            say("/ip");
            say("/sp 1");
            Misc.itemLogger("Created new stash tab");
        }
    }
}