kolton / d2bot-with-kolbot

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

Run one script twice per game #2223

Closed ARkaine2 closed 4 years ago

ARkaine2 commented 4 years ago

Is it possible to run one script twice per game? For example in such case:

    // SCRIPTS BOSS/AREA

    Scripts.Mausoleum = true;
        Config.Mausoleum.ClearCrypt = true;

    Scripts.Pit = true;
        Config.Pit.ClearPit1 = true;

    Scripts.Cows = true;

    Scripts.AncientTunnels = true;

    Scripts.ClearAnyArea = true;
        Config.ClearAnyArea.AreaList = [62, 63, 64];    // Maggot Lair (Level 1--3)

    Scripts.Travincal = true;

    Scripts.Mephisto = true;
        Config.Mephisto.KillCouncil = true;
        Config.Mephisto.TakeRedPortal = true;

    Scripts.ClearAnyArea = true;
        Config.ClearAnyArea.AreaList = [104, 105];  // Outer Steppes and Plains Of Despair

    Scripts.ClearAnyArea = true;
        Config.ClearAnyArea.AreaList = [107];       // River of Flame

    Scripts.Diablo = true;
        Config.Diablo.Entrance = false;

ClearAnyArea script works as River of Flame in place of Maggot Lair, then in runs Diablo script and ends game.

Is it possible to make ClearAnyArea script run all arreas separatly, not in a row, if we choose something like:

    Scripts.ClearAnyArea = true;
        Config.ClearAnyArea.AreaList = [62, 63, 64, 104, 105];  // Maggot Lair (Level 1--3), Outer Steppes and Plains Of Despair
InterestingIndeed commented 4 years ago

The code you posted last will make the bot clear those 5 areas.

fa-b posted here that you can change the order the scripts are executed by changing the order in the config file. Im having a bit of a hard time understanding what your bot does with your code posted above.

Is Maggots Lair being cleared before Travincal? Maybe you can quickly post a list of what is done and in which order? From my understanding you want this:

  1. Mausoleum
  2. Pit
  3. Cows
  4. Tunnels
  5. clear Lair
  6. Travincal
  7. Mephisto
  8. clear Outer Steppes
  9. clear Plains
  10. clear River of Flames
  11. Diablo

I want to move the ClearAnyArea Script in my own config as well, to make my multiple characters synch up better, so im really interested in solving your issue as well.

From my understanding, the config files are "sending" their values to another script at the activation of a profile. If "Scripts.ClearAnyArea" is present at multiple stages of the config files, the values in AreaList are being "send" multiple times, each time overwriting the values that have been stored before. In you case, "River of Flames" is the last setting that overrides the previous runs, so only that area will be cleared. Sadly, my understanding of the inner works of the bot are very limited and Im hoping someone will answer this question before I will try it out myself.

Maybe the script can be executed multiple times be creating copies of the script (eg. ClearAnyAreaA, ClearAnyAreaB etc) and adding those to the general config as well. If I dont get any answer for this, I will try it out myself, most likely killing my bot in the process ^^

ARkaine2 commented 4 years ago

I tried to create multiple versions of ClearAnyArea.js And I got error "Invalid script function name". I found this (https://github.com/kolton/d2bot-with-kolbot/issues/1257) thread and there was solution: I renamed "function ClearAnyArea" in each file. But i got another problem: Scripts ClearAnyAreaA, ClearAnyAreaB, ClearAnyAreaC, ClearAnyAreaD start from last location of them and then only repeat it. For example: ClearAnyAreaA runs River of Flames, then ClearAnyAreaB, ClearAnyAreaC, ClearAnyAreaD runs already cleared River of Flames etc, untill all ClearAnyArea scripts will be completed.

ARkaine2 commented 4 years ago

InterestingIndeed, any success?

ARkaine2 commented 4 years ago

InterestingIndeed, if you are interested, i found solution.

We should change AreaList to other name (for example for AreaList1 like in this code):

function ClearAnyArea1() {
    var i;

    Town.doChores();

    for (i = 0; i < Config.ClearAnyArea.AreaList1.length; i += 1) {
        if (Pather.journeyTo(Config.ClearAnyArea.AreaList1[i])) {
            Attack.clearLevel(Config.ClearType);
        }
    }

    return true;
}