kolton / d2bot-with-kolbot

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

undefined property Hephasto Wakka #2906

Open dynnast opened 3 years ago

dynnast commented 3 years ago

hey guys, I get errors in lines 85 and 144 in every char config file I've tested so far. that is sorceress, druid, paladin

Bot tells me Config.Hephasto and Config.Wakka are undefined properties and fails to load char config. I've just commented them out and everything works fine but I can't use the scripts.

Only thing I did after loading d2b with kolbot through svn was add autosmurf nothing else that i did should have caused this error...

Alexflu commented 3 years ago

can you post those two lines?

dynnast commented 3 years ago

85: // Config.Hephasto.ClearRiver = false; // Clear river after killing Hephasto 144: // Config.Wakka.Wait = 1; // Minutes to wait for leader

These are the two lines that return the error The scripts are both there:

sorry i'm terrible with formatting on here..

Hephasto:

function Hephasto() { Town.doChores(); Pather.useWaypoint(107); Precast.doPrecast(true);

if (!Pather.moveToPreset(me.area, 2, 376)) {
    throw new Error("Failed to move to Hephasto");
}

try {
    Attack.kill(getLocaleString(1067)); // Hephasto The Armorer
} catch (e) {
    print("Heph not found. Carry on");
}
Pickit.pickItems();

if (Config.Hephasto.ClearRiver) {
    Attack.clearLevel(Config.Hephasto.ClearType);
}

return true;
    }

Wakka:

var stopLvl = 99;

function Wakka() { let i, safeTP, portal, vizClear, seisClear, infClear, tick, diablo, timeout = Config.Wakka.Wait, minDist = 50, maxDist = 80, leaderUnit = null, leaderPartyUnit = null, leader = "";

function autoLeaderDetect(destination) { // autoleader by Ethic
    let solofail, suspect;

    do {
        solofail = 0;
        suspect = getParty(); // get party object (players in game)

        do {
            if (suspect.name !== me.name) { // player isn't alone
                solofail += 1;
            }

            if (suspect.area === destination && !getPlayerFlag(me.gid, suspect.gid, 8)) { // first player not hostile found in destination area...
                leader = suspect.name; // ... is our leader

                if (suspect.area === 131) {
                    return false;
                }

                print("ÿc4Wakka: ÿc0Autodetected " + leader);

                return true;
            }
        } while (suspect.getNext());

        if (solofail === 0) { // empty game, nothing left to do
            return false;
        }

        delay(500);

        if (getTickCount() - me.gamestarttime >= timeout * 6e4) {
            throw new Error("No leader found");
        }
    } while (!leader); // repeat until leader is found (or until game is empty)

    return false;
}

this.checkMonsters = function (range, dodge) {
    var monList = [],
        monster = getUnit(1);

    if (monster) {
        do {
            if (monster.y < 5565 && Attack.checkMonster(monster) && getDistance(me, monster) <= range) {
                if (!dodge) {
                    return true;
                }

                monList.push(copyUnit(monster));
            }
        } while (monster.getNext());
    }

    if (!monList.length) {
        return false;
    }

    monList.sort(Sort.units);

    if (getDistance(me, monList[0]) < 25 && !checkCollision(me, monList[0], 0x4)) {
        Attack.deploy(monList[0], 25, 5, 15);
    }

    return true;
};

this.getLayout = function (seal, value) {
    var sealPreset = getPresetUnit(108, 2, seal);

    if (!seal) {
        throw new Error("Seal preset not found. Can't continue.");
    }

    switch (seal) {
    case 396:
        if (sealPreset.roomy * 5 + sealPreset.y === value) {
            return 1;
        }

        break;
    case 394:
    case 392:
        if (sealPreset.roomx * 5 + sealPreset.x === value) {
            return 1;
        }

        break;
    }

    return 2;
};

this.getCoords = function () {
    this.vizCoords = this.getLayout(396, 5275) === 1 ? [7707, 5274] : [7708, 5298];
    this.seisCoords = this.getLayout(394, 7773) === 1 ? [7812, 5223] : [7809, 5193];
    this.infCoords = this.getLayout(392, 7893) === 1 ? [7868, 5294] : [7882, 5306];
};

this.checkBoss = function (name) {
    var i, boss,
        glow = getUnit(2, 131);

    if (glow) {
        for (i = 0; i < 10; i += 1) {
            if (me.getStat(12) >= stopLvl) {
                D2Bot.stop();
            }

            boss = getUnit(1, name);

            if (boss && boss.mode === 12) {
                return true;
            }

            delay(500);
        }

        return true;
    }

    return false;
};

this.getCorpse = function () {
    if (me.mode === 17) {
        me.revive();
    }

    var corpse,
        rval = false;

    corpse = getUnit(0, me.name, 17);

    if (corpse) {
        do {
            if (getDistance(me, corpse) <= 15) {
                Pather.moveToUnit(corpse);
                corpse.interact();
                delay(500);

                rval = true;
            }
        } while (corpse.getNext());
    }

    return rval;
};

this.followPath = function (dest) {
    var path = getPath(me.area, me.x, me.y, dest[0], dest[1], 0, 10);

    if (!path) {
        throw new Error("Failed go get path");
    }

    while (path.length > 0) {
        if (me.getStat(12) >= stopLvl) {
            D2Bot.stop();
        }

        if (me.mode === 17 || me.inTown) {
            return false;
        }

        if (!leaderUnit || !copyUnit(leaderUnit).x) {
            leaderUnit = getUnit(0, leader);
        }

        if (leaderUnit) {
            if (this.checkMonsters(45, true) && getDistance(me, leaderUnit) <= maxDist) { // monsters nearby - don't move
                path = getPath(me.area, me.x, me.y, dest[0], dest[1], 0, 15);

                delay(200);

                continue;
            }

            if (getDistance(me, leaderUnit) <= minDist) { // leader within minDist range - don't move
                delay(200);

                continue;
            }
        } else {
            // leaderUnit out of getUnit range but leader is still within reasonable distance - check party unit's coords!
            leaderPartyUnit = getParty(leader);

            if (leaderPartyUnit) {
                if (leaderPartyUnit.area !== me.area) { // leader went to town - don't move
                    delay(200);

                    continue;
                }

                // if there's monsters between the leecher and leader, wait until monsters are dead or leader is out of maxDist range
                if (this.checkMonsters(45, true) && getDistance(me, leaderPartyUnit.x, leaderPartyUnit.y) <= maxDist) {
                    path = getPath(me.area, me.x, me.y, dest[0], dest[1], 0, 15);

                    delay(200);

                    continue;
                }
            }
        }

        if (Pather.moveTo(path[0].x, path[0].y)) {
            path.shift();
        }

        this.getCorpse();
    }

    return true;
};

// start
Town.goToTown(4);
Town.move("portalspot");

if (Config.Leader) {
    leader = Config.Leader;

    for (i = 0; i < 30; i += 1) {
        if (Misc.inMyParty(leader)) {
            break;
        }

        delay(1000);
    }

    if (i === 30) {
        throw new Error("Wakka: Leader not partied");
    }
}

autoLeaderDetect(108);
Town.doChores();

if (leader) {
    while (Misc.inMyParty(leader)) {
        if (me.getStat(12) >= stopLvl) {
            D2Bot.stop();
        }

        switch (me.area) {
        case 103:
            //portal = Pather.getPortal(108, leader);
            portal = Pather.getPortal(108, null);

            if (portal) {
                if (!safeTP) {
                    delay(5000);
                }

                //Pather.usePortal(108, leader);
                Pather.usePortal(108, null);
            }

            break;
        case 108:
            if (!safeTP) {
                if (this.checkMonsters(25, false)) {
                    me.overhead("hot tp");
                    //Pather.usePortal(103, leader);
                    Pather.usePortal(103, null);
                    this.getCorpse();

                    break;
                } else {
                    this.getCoords();

                    safeTP = true;
                }
            }

            if (!vizClear) {
                if (!this.followPath(this.vizCoords)) {
                    break;
                }

                if (tick && getTickCount() - tick >= 5000) {
                    vizClear = true;
                    tick = false;

                    break;
                }

                if (this.checkBoss(getLocaleString(2851))) {
                    if (!tick) {
                        tick = getTickCount();
                    }

                    me.overhead("vizier dead");
                }

                break;
            }

            if (!seisClear) {
                if (!this.followPath(this.seisCoords)) {
                    break;
                }

                if (tick && getTickCount() - tick >= 7000) {
                    seisClear = true;
                    tick = false;

                    break;
                }

                if (this.checkBoss(getLocaleString(2852))) {
                    if (!tick) {
                        tick = getTickCount();
                    }

                    me.overhead("seis dead");
                }

                break;
            }

            if (!infClear) {
                if (!this.followPath(this.infCoords)) {
                    break;
                }

                if (tick && getTickCount() - tick >= 2000) {
                    infClear = true;
                    tick = false;

                    break;
                }

                if (this.checkBoss(getLocaleString(2853))) {
                    if (!tick) {
                        tick = getTickCount();
                    }

                    me.overhead("infector dead");
                }

                break;
            }

            Pather.moveTo(7767, 5263);

            diablo = getUnit(1, 243);

            if (diablo && (diablo.mode === 0 || diablo.mode === 12)) {
                return true;
            }

            break;
        }

        if (me.mode === 17) {
            me.revive();
        }

        delay(200);
    }
} else {
    throw new Error("Empty game.");
}

return true;
    }
Alexflu commented 3 years ago

you've not changed these lines?
from timeout = 5, // minutes to timeout = Config.Wakka.Wait,

and for hephasto.. this isn't in my script

if (Config.Hephasto.ClearRiver) { Attack.clearLevel(Config.Hephasto.ClearType); }

sorry I'm pretty new to this.. I haven't tried to add anything new to my scripts yet are you running d2bot 20.6.7.100? if you can't get it to work and the goal is to clear the river you could add the river to the clear any area script after hephasto. I know this is undesirable I've had a similar issue where I would like for it to kill rakenishu then enter portal, kill gris and then get wirts leg for cows instead of teleing to town but I have yet to try editing scripts

fridayaction commented 3 years ago

hi guys, i'm just curious, if there is a soultion to this issue yet? :)

did it help to change timeout = Config.Wakka.Wait, to timeout = 5, // minutes in Wakka

and remove if (Config.Hephasto.ClearRiver) { Attack.clearLevel(Config.Hephasto.ClearType); } from Hephasto Script?

dynnast commented 3 years ago

Hey Alex and friday,

seems like i forgot to finish replying and it got scrapped.

I commented out the config.wakka.wait in the char config and replaced it with a number in the script file, that definitely did the trick and the script is working. No idea how that ended up in there anyways...

Haven't tried editing the hephasto script but i think you should be fine if you just delete the lines. who clears river of flame anyway.

Alexflu commented 3 years ago

Glad to hear it worked! Since you had posted your configs I was able to transfer them both, test, fix, & repost :D

I'm not sure how they got there either.. lol

I've considered adding it to my runs it's same lvl as sanctuary correct?