kolton / d2bot-with-kolbot

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

How can I force a new game when "move retry x"? #566

Open Daisthalad opened 6 years ago

Daisthalad commented 6 years ago

I have a rather spiky connection, and I get stuck a lot when doing town chores, is there any way to leave game after "move retry x" failed attempts? Making shorter games isn't a solution for me as I only have one key and I like running long games.

franva commented 6 years ago

Same issue here. Can anyone look into this issue please?

Druxlolz commented 6 years ago

You can config max game time to your bot.

Daisthalad commented 6 years ago

Well as I said, that’s the thing I’m trying to avoid. I want to know if there is a way to exit game when say I reach “move retry 10” or “waypoint retry 3”.

fwaechter commented 6 years ago

You have to reduce the "retry" count in the bot scripts. The relevant file for moving and/or teleporting is the: Pather.js file. On Line 272 ff. you can find the relevant check and the trigger for the console message:

print("move retry " + fail);

if (fail > 0 && fail >= retry) {
    break;
}

This simply means: _if retry count is over the retry value the script will stop_. The retry count is an argument of the function Pather.moveTo():

Pather.moveTo(x, y, retry, clearPath, pop);
    x - the x coord to move to
    y - the y coord to move to
    retry - number of attempts before aborting
    clearPath - kill monsters while moving
    pop - remove last node

If the bot script doesn't provide a retry value the default is used. The default value can be found inside Pather.js on Line 155:

if (retry === undefined) {
    retry = 3;
}

Simply change this value according to your needs.

Every bot script has a .js file with instructions for the bot. Changing the retry count inside this files overwrites the default value. For Diablo runs it would be: Diablo.js. Now lets take a look at the Pather.moveTo() functions used inside there. At line 439 you'll see the following sequence:

if (Config.Diablo.Entrance) {
    Attack.clear(30, 0, false, this.sort);
    Pather.moveTo(7790, 5544);
[...]

As you can see no maximum retry count is set. This means the default (3) is used. To add a custom retry count just add your value the Pather.moveTo() function. Above we could see that the retry count is the third value. So to add your custom retry count just edit the parameters like this:

if (Config.Diablo.Entrance) {
    Attack.clear(30, 0, false, this.sort);
    Pather.moveTo(7790, 5544, 10);
[...]

Hope this helps. Please note that the entire scripts works a lot better if you're able to teleport. The walking part is only rudimentary. Rusher & Rushee without teleport is almost useless for example.

Daisthalad commented 6 years ago

Astounding my friend. Thank you for your time, as soon as I get home I will have fun with it. -- Matías Gavajda

Daisthalad commented 6 years ago

So, @fwaechter my friend, you helped me progress quite a bit, I went from this:

waypoint retry

To this:

waypoint retry fix

By modifying line 882 from Pather.js,

for (i = 0; i < 2; i += 1) { if (me.area === targetArea || me.dead) { break; }

I changed the retries from 12 to 2, but it will still cycle and break through all the scripts until finally exiting game. What I would love to know is, if there is the possibility that after it breaks the first script it just exits for good!

fwaechter commented 6 years ago

Yes, the changes above only cancel the current Pather.moveTo() sequence. To exit game after triggering the max retry value you could try the following: Add a quit(); to the retry check in the Pather.js. Revert the changes you made on line 882 before.

Change the following lines starting at line 274 :

if (fail > 0 && fail >= retry) {
    break;
}

to this:

if (fail > 0 && fail >= retry) {
    quit();
    break;
}

I'm not sure if this works and can't test at the moment. It's a real quick and dirty solution so don't expect to much.

Daisthalad commented 6 years ago

Dirty or not, it works like a charm! I just changed "(fail > 0 && fail >= retry)" to "(fail > 3 && fail >= retry)", it was insta-leaving when it sometimes fixes itself on 2nd retry. Sir, you earned my eternal gratitude!