kolton / d2bot-with-kolbot

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

Error in cows, Failed to buy tome / Failed to cube leg. #2804

Open Sirk74 opened 4 years ago

Sirk74 commented 4 years ago

So, some times (quite a few indeed), my sorc quit cows script.

The reason is quite simple: sometimes during the quick teleport rush to fetch the leg, something that is in the pickit list drops (from a merc kill) and she picks it up. Since I have (as many do I believe), only 4x2 free spaces, sometimes there is no space for the tome after the leg has been picked up (like, by having picked a 3x1 weapon), sometimes the is no space even for the leg in the first place (like after a 2x2 item).

The idea here is to tell the bot not to pick up anything in area 4 (Stony Field) and 38 (Tristram), but I have no clue on how to do it.

I though even about setting the pickup range to 0 during to do the same, and I know that there is a way to set a different config value just during the execution of a script, problem is if I do that, it would remain true during all cows.js.

So, either I create 2 different scripts, one to fetch the leg and one to clear cows and set pickup range to 0 during the first, but it does seem a bit of a patchy solution. Or I follow the suggestions posted here :D

DarkHorseDre commented 4 years ago

Yeah I found the same when I enabled clearpath! bot was suddenly finding stuff on the way to leg.

The easiest thing to do is force a town visit before you pick the leg.
https://github.com/blizzhackers/kolbot/issues/53

You could extend that to check if the leg can fit the leg (1x3 in size):

    if (!portal) {
            throw new Error("Tristram portal not found");
        }

        Pather.moveTo(25048, 5177);
        const fakeItem = { //dhd added
            sizex: 1,
            sizey: 3,
        }
        if ((!Storage.Inventory.FindSpot(fakeItem))) { //dhd added
            Town.goToTown();
            Town.doChores(); //dhd added - leg is not picked if inv full, no error.
            Pather.usePortal(null, me.name); //dhd added - go back to trist by leg
        }

        if (!getUnit(2, 268)) { //if body already interacted
            print("*****Failed to prod body");
            //todo: if body already intereacted this will fail - need to quit? pick from ground?
            return false;
        } else {
            wirt = getUnit(2, 268); //dhd 268 is wirts body - if leg already dropped, bot wont pick, but will fail 'wirt.interact()' below (2 = object)
        }

        for (i = 0; i < 8; i += 1) {
            wirt.interact();
            delay(500);

I added a few extra bits for other failures, but the fakeitem const and then the findspot check --> town is the main thing to clear inv before interacting with wirts body

Sirk74 commented 4 years ago

I just noticed I did not explain completely. In my run cows is the first thing with that character and it starts with town chores before cows script, so when cows starts the inventory has enough space (in my case the usual 2x4). The point is that sometimes it picks up something during the way and I don't know how to fix it because it's "inside" cows script.

If I got your script correctly, it should check if there is space enough to fit the leg and give error if not. But even then, there would be the need for another check when it buys the tome.

Actually I tried to do it manually and insert a town chores between getting leg and getting tome, but OF COURSE it drops the legs because it's not in pickit (lol). And if I put the leg in pickit list, it puts it into the stash (lol again). So you cannot use chores to make space after you got the leg.

I still think an easy win would be preventing picking up during leg fetching (and losing the Lo Rakanishu would drop for sure the first time I run it this way :P). Would it work by inserting a Config.PickRange = 0; at the beginning of cows script and a Config.PickRange = 40; after picking leg? Well, I'm just trying and will let you know ^^

DarkHorseDre commented 4 years ago

no, you did, my answer is the same ;)

the code moves to wirts spot (doesnt interact), checks for space, and goes to town to clear inv if not enough space, then returns and continues to pick the leg (not what you did),

if you somehow don't have space for leg AND the tome after a town visit, pick, then town again, then change the fake item space you check for 2x3 (and ensure you have enough free slots marked in inventory).

have a look at the code AND the comments.

I'll repeat - my changes solved the problem of full stash when I try to pick leg.

Sirk74 commented 4 years ago

Ok, thanks for explaining :) Will implement your solution then!