kolton / d2bot-with-kolbot

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

Pather.js : kill wraith/ghost/stormcasters #2511

Open mtz33 opened 4 years ago

mtz33 commented 4 years ago

Dear Community, I would like to update the pather.js so my bot will kill on its path wraith/ghosts/fingermages. I tried to add configs like Countess kill ghost as recommended in #592 but it doesn't work and have error message at begining of script (config.summoner.killghosts not defined). I tried to use already existing Config.Countess.KillGhosts and added other areas like :

if (Config.Countess.KillGhosts && [21, 22, 23, 24, 25, 66, 67, 68, 69, 70, 71, 72, 88, 89, 91, 104, 105, 107, 113, 114, 115, 116, 118, 119, 128, 129, 130].indexOf(me.area) > -1) {
            monList = Attack.getMob(38, 39, 40, 41, 42, 631, 632, 633, 641, 304, 305, 306, 692, 693);

            if (monList) {
                Attack.clearList(monList);
            }
        }

This time no error msg the bot goes on but ignores ghosts etc.

Any insights?

Thanks

DarkHorseDre commented 4 years ago

config.summoner.killghosts is not checked in your function.

Config.Countess.KillGhosts is it set true in your character config?

assuming you have only added area id's and classid's for monsters, this should work (I have used a similar method for other mob types)

mtz33 commented 4 years ago
Scripts.Countess = true;
        Config.Countess.KillGhosts = true;

In pather.js =

// Kill monsters while pathing
    killMonsters: function (arg) {
        var monList;

        if (Config.Countess.KillGhosts && [21, 22, 23, 24, 25, 66, 67, 68, 69, 70, 71, 72, 88, 89, 91, 104, 105, 107, 113, 114, 115, 116, 118, 119, 128, 129, 130].indexOf(me.area) > -1) {
            monList = Attack.getMob(38, 39, 40, 41, 42, 631, 632, 633, 641, 304, 305, 306, 692, 693);

            if (monList) {
                Attack.clearList(monList);
            }
        }

Bot is ignoring all the mobs while the Id are corrects...

DarkHorseDre commented 4 years ago

ah I checked the code, you should check how to use getMob - this is how the function is specified in attack.js:

getMob: function (classid, spectype, range, center) {
mtz33 commented 4 years ago

Appreciate your help mate. I'm really a rookie in there, I like the struggle but I'm a bit lost. I wonder why copying same kind of code from Config.Countess.KillGhosts doesn't work. Actually can it be done by default ? Adding a list of monster id on the pather to kill while pathing ? Thanks again if you can help me out :)

DarkHorseDre commented 4 years ago

ok, so "by default" - yes and no. the whole code for this bot was written in a modular fashion and can be extended or modified, but then of course you need to manage that..

in this case the getMob function only works for a single mob classid (which works well for ghosts in the countess case). you could add a set of commands for each class but that would be inefficient (and I'm no coder so won't try to tell you the most efficient method!)

looking at attack.js, clearList may be better for your needs:

// Clear an already formed array of monstas
clearList: function (mainArg, sortFunc, refresh) {

so you could pass an array of monster id's to it (edit: needs more than that - I will have to see later). I can't read/test it all now, but if you can't get it to work lemme know and I'll look later (or someone else may help)

mtz33 commented 4 years ago

Thanks @DarkHorseDre

I give up :p I tried to set up only for tomb just below countess kill ghost script in pather.js

// Kill monsters while pathing
    killMonsters: function (arg) {
        var monList;

        if (Config.Countess.KillGhosts && [21, 22, 23, 24, 25].indexOf(me.area) > -1) {
            monList = Attack.getMob(38, 0, 30);

            if (monList) {
                Attack.clearList(monList);
            }
        }

        if (Config.Tomb.Apparition && [34, 35, 36, 37].indexOf(me.area) > -1) {
            monList = Attack.getMob(41, 0, 30);

            if (monList) {
                Attack.clearList(monList);
            }
        }

And in my config file

    Scripts.Tombs = true;
        Config.Tomb.Apparition = true;

Then I get this error message

[05/22/20 16:54:00] D2BS 26156: ÿc2D2BSÿc0 :: Starting default.dbj
[05/22/20 16:54:00] D2BS 26156: ÿc2D2BSÿc0 :: default.dbj running.
[05/22/20 16:54:00] D2BS 26156: [Strict Warning] Code(162) File(c:\xxx\kolbot\d2bs\kolbot\libs\config\sorceress.MYNAME.js:65) reference to undefined property Config.Tomb
Line: (null)
[05/22/20 16:54:00] D2BS 26156: [Error] Code(0) File(c:\XXX\kolbot\d2bs\kolbot\libs\common\config.js:95) Error: Config.init: Error in character config.
Line: (null)
[05/22/20 16:54:00] D2BS 26156: [ÿc9Strict Warningÿc0 (162)] File(kolbot\libs\config\sorceress.MYNAME.js:65) reference to undefined property Config.Tomb
[05/22/20 16:54:00] D2BS 26156: ÿc8Error in sorceress.MYNAME.js(line 65): Config.Tomb is undefined
[05/22/20 16:54:00] D2BS 26156: [ÿc1Errorÿc0 (0)] File(kolbot\libs\common\config.js:95) Error: Config.init: Error in character config.

I'll have a break :) Any help / fix is welcome.

DarkHorseDre commented 4 years ago

lol well it may need to be in the actual config: Config is the name of a file (config.js as per the error - the error is telling you something!) open that and see how it is setup. You usually have to add the entry to that AND your char config. (when the bot loads it has all the values initialised in config.js to default values, then your char config overrides it)

you should also paste your code to somewhere like pastebin.com so we get syntax highlighting and can check it easier.

read the wiki too - it has some good starter info - you shouldn't try to hack this bot without understanding its structure :) https://github.com/kolton/d2bot-with-kolbot/wiki

as for the OP request - thats quite easy but I need to be able to test my solution before I give it, and I cant do that just now

DarkHorseDre commented 4 years ago

Did you apply those corrections bro?

mtz33 commented 4 years ago

@DarkHorseDre , hey mate, no didn't have time lately and I fear diving in it again as I would need extra focus to get back to it ;p Almost gave up :( Thanks for your help tho. 👍

DarkHorseDre commented 4 years ago

no worries - setting config.js woulda cleared that problem

I worked out a way to cycle through more than 1 classid but not sure it wouldnt cause performance problems.. let's hope others can chip-in on that one!