kolton / d2bot-with-kolbot

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

Character progression does not save #2921

Open alvaro-rod opened 3 years ago

alvaro-rod commented 3 years ago

Hello,

I use d2bs kolbot in singles player tcp/ip games. I am facing the problem that, when scripts are finished, all the characters leave the game but some of them lose that progression they have made (exp, items, etc). You would probably say it is because if the host leaves first, the characters that were still in the game are not saving the game, but some times it is the host who is not saving. Probably even more often.

I think it has somethin to do with how the bot finishes the game. Do you know if the bot is actually using the ESC + "Save and Exit" method? Or is it just doing something else internally?

Is it possible to modify the way the bot finishes the games? Or is it in the compiled part of the code?

I have read something about a difference between quit() and quit(true), but the same guy saying it was also saying that he did not know if there was an actual difference.

Any help will be nice!

DarkHorseDre commented 3 years ago

if you didnt work this out - ask in the discord channels - sounds like an interesting question that the guys can answer

https://discord.gg/FuBG8N2

ckelly44 commented 3 years ago

Here's a hacky solution if you're desperate. It will attempt to use the esc menu to click 'save and exit'. Note, if the window is active then your mouse and keyboard inputs may screw it up, so try to keep it minimized. Save it as a js file ForceSave.js and throw it in libs/bots. In the character config add Scripts.ForceSave = true; and make sure it's the last active script.

function ForceSave() {

    delay(6000);
    D2Bot.updateRuns();
    if (Config.LogExperience) {
        Experience.log();
    }

    // initial save and exit attempt
    sendKey(0x1B);  // 'esc'
    delay(200);
    sendKey(0x0D);  // 'return'
    delay(200);

    // secondary save and exit attempt
    if(getUIFlag(0x09)) {   // if we selected options
        sendKey(0x1B);  // 'esc'
        delay(200);
        sendKey(0x1B);  // 'esc'
        delay(200);
        sendKey(0x28);  // down
        delay(200);
        sendKey(0x0D);  // 'return'
        delay(200);
    } else {    // if we selected 'return to game'
        sendKey(0x1B);  // 'esc'
        delay(200);
        sendKey(0x28);  // down
        delay(200);
        sendKey(0x28);  // down
        delay(200);
        sendKey(0x0D);  // 'return'
        delay(200);
    }

    // force quit if something went wrong
    delay(1000);    
    quit();

    return true;
}