kolton / d2bot-with-kolbot

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

How to make char quit on hell temptresses at nith just like vipers #2688

Open Xdaci opened 4 years ago

Xdaci commented 4 years ago

I'd like to make my bots quit if there are hell temptresses at nith just as they do with tomb vipers. I tried adding the monster id for hell temptresses to the end of the tomb viper line in the Nihlathak bot script but it didnt do anything.

/editing and updating

i found the actual lines in the toolsthread about checking for vipers and also quitting. i added the the monster id for hell temptresses(472) after the tomb viper id(597) in the viper check line. i then added the hell temptress id(472) after the tomb viper id(597) again in both pindleskin and nilithak bot scripts. I cant tell if its working or not tho. would this be all i need to do? or do i need to make new lines for hell temptress?

Xdaci commented 4 years ago

i found the quit on vipers function in the tootlsthread script. I added ,472 after the viper monster id in each area its listed, as well as in both the pindleskin and nilithak bot scripts as well in hopes that it will make them quit on both vipers and or hell temptresses but its hard to tell if its working. im thinking it is not. i just watched her tele past a pretty big group of hell temptresses and not quit.

maybe ill try copying those lines and creating a whole new line for quitting on hell temptresses. if anyone has any insight or recommendations id appreciate it because idk wtf im doing

DarkHorseDre commented 4 years ago

This function in toolsthread.js checks for 1 monster and returns true if it is found (and not in revived state):

    this.checkVipers = function () {
        var owner,
            monster = getUnit(1, 597);

so adding another monsterid to the function won't work - you either need to modify the function to check both, or simply add another copy of the function to check your temptress monsterid.

This section of same file checks the config.js (overridden by your char config) and calls the vipercheck function:

                if (Config.ViperCheck && getTickCount() - tick >= 250) {
                    if (this.checkVipers()) {
                        D2Bot.printToConsole("Revived Tomb Vipers found. Leaving game.", 9);

                        quitFlag = true;
                    }

                    tick = getTickCount();
                }

So you can see how it checks config to see if it should do anything, then uses function to check for vipers by monsterid.

This if statement in nihi script causes script to end if vipers found, but does NOT reference config.vipercheck:

    if (Config.Nihlathak.ViperQuit && getUnit(1, 597)) {
        print("Tomb Vipers found.");

        return true;
    }

so you can see how to end script on monsterid per script (toolsthread is global).

so the easiest thing to do is copy nihi functionality per script, but if there are too many, you can copy toolsthread structure:

  1. copy the vipercheck function and rename to something unique (e.g. checkTemptress)
  2. change the monsterid to that of Temptress'
  3. add a new config param to config.js and your char config (e.g. config.TemptressCheck )
  4. add a check for the new config.TemptressCheck in the above toolsthread if block. e.g. if ((Config.ViperCheck || Config.TemptressCheck) && getTickCount() - tick >= 250) { if (this.checkVipers()) { D2Bot.printToConsole("Revived Tomb Vipers found. Leaving game.", 9); if(this.checkTemptress()){ D2Bot.printToConsole("Temptress' found. Leaving game.", 9); } //etc
Xdaci commented 4 years ago

This function in toolsthread.js checks for 1 monster and returns true if it is found (and not in revived state):

  this.checkVipers = function () {
      var owner,
          monster = getUnit(1, 597);

so adding another monsterid to the function won't work - you either need to modify the function to check both, or simply add another copy of the function to check your temptress monsterid.

This section of same file checks the config.js (overridden by your char config) and calls the vipercheck function:

              if (Config.ViperCheck && getTickCount() - tick >= 250) {
                  if (this.checkVipers()) {
                      D2Bot.printToConsole("Revived Tomb Vipers found. Leaving game.", 9);

                      quitFlag = true;
                  }

                  tick = getTickCount();
              }

So you can see how it checks config to see if it should do anything, then uses function to check for vipers by monsterid.

This if statement in nihi script causes script to end if vipers found, but does NOT reference config.vipercheck:

  if (Config.Nihlathak.ViperQuit && getUnit(1, 597)) {
      print("Tomb Vipers found.");

      return true;
  }

so you can see how to end script on monsterid per script (toolsthread is global).

so the easiest thing to do is copy nihi functionality per script, but if there are too many, you can copy toolsthread structure:

  1. copy the vipercheck function and rename to something unique (e.g. checkTemptress)
  2. change the monsterid to that of Temptress'
  3. add a new config param to config.js and your char config (e.g. config.TemptressCheck )
  4. add a check for the new config.TemptressCheck in the above toolsthread if block. e.g. if ((Config.ViperCheck || Config.TemptressCheck) && getTickCount() - tick >= 250) { if (this.checkVipers()) { D2Bot.printToConsole("Revived Tomb Vipers found. Leaving game.", 9); if(this.checkTemptress()){ D2Bot.printToConsole("Temptress' found. Leaving game.", 9); } //etc

Thank you man, I'll test this later when I get home.

Those hell temptresses in large enough groups, especially if part of said large group is a unique pack with amp or multi shot, can do some serious damage. I'm testing early ladder budget key farming sorcs for hardcore and had one die to these bitches. I also had a super decked out lvl 95.5 light sorc die to them on hardcore earlier this ladder. What happens is a pack of 10-20+ of these things all instantly spam the red orbs at your character all at once as your char sits there trying to kill nith, a huge wave of the orbs hits you and does a huge instant chunk of life. Pair that with a unfortunate tele near a melee pack or a volley from an archer pack that hits you right as the orbs hit and you have a death despite aggressive heal/town/chicken settings with a max block high dr% char.

It may take a lot of times to have that really unlucky roll of events line up perfectly but on hadcore all it takes is one. My lvl 95.5 sorc who did a shit ton of runs with zero issues proved that your bound to have a nith map generate the perfect storm of hell temptresses paired with archers or a bad tele into niths minions for that instant death and thats what happened. So now I'm thinking if I can have them avoid hell temptresses all together they will be as safe as possible for farming nith. This will result in a shit ton of skipped nith runs lmao, she'll be skipping on cold immune, vipers and now temptresses but its better than a death where I have to painstakingly remake.

DarkHorseDre commented 4 years ago

No worries.

Yeah I hear ya - I only used to play and bot hc also (and will again one day) - think I've lost bots there :)

Think I didn't run nihi back then as I didn't know how to control those deaths or know causes.

I'd be more interested in modifying nihi script to kill those blitches bit by bit before attempting him :) (although I guess you'd need a natures peace to avoid carnage?)

Xdaci commented 4 years ago

No worries.

Yeah I hear ya - I only used to play and bot hc also (and will again one day) - think I've lost bots there :)

Think I didn't run nihi back then as I didn't know how to control those deaths or know causes.

I'd be more interested in modifying nihi script to kill those blitches bit by bit before attempting him :) (although I guess you'd need a natures peace to avoid carnage?)

I tried doing what you said, (i did it wrong apparently) bot just crashes on start everytime(soon as she gets in game i should specify). Maybe you can help me out with a bit more detail. heres what i attempted

copied viper check and pasted it directly below and changed it to temptress and the monsterid to 472(temptress) in toolsthread

this.checkVipers = function () { var owner, monster = getUnit(1, 597);

    if (monster) {
        do {
            if (monster.getState(96)) {
                owner = monster.getParent();

                if (owner && owner.name !== me.name) {
                    return true;
                }
            }
        } while (monster.getNext());
    }

    return false;
};

this.checkTemptress = function () {
    var owner,
        monster = getUnit(1, 472);

    if (monster) {
        do {
            if (monster.getState(96)) {
                owner = monster.getParent();

                if (owner && owner.name !== me.name) {
                    return true;
                }
            }
        } while (monster.getNext());
    }

    return false;
};

add this to the vipercheck in toolsthread

if ((Config.ViperCheck || Config.TemptressCheck) && getTickCount() - tick >= 250) { if (this.checkVipers()) { D2Bot.printToConsole("Revived Tomb Vipers found. Leaving game.", 9); if (this.checkTemptress()) { D2Bot.printToConsole("Temptress' found. Leaving game.", 9);

                    quitFlag = true;
                }

add these two in my sorcs config file under pindle and nith (for my current testing im doing nith only but plan to do pindle when on bnet)

Scripts.Pindleskin = false; Config.Pindleskin.UseWaypoint = false; Config.Pindleskin.KillNihlathak = true; Config.Pindleskin.ViperQuit = false; // End script if Tomb Vipers are found. Config.Pindleskin.TemptressQuit = true

Scripts.Nihlathak = true; Config.Nihlathak.ViperQuit = true; // End script if Tomb Vipers are found. Config.Nihlathak.TemptressQuit = true

finally i copied the viperquit code in both Pindleskin.js and in Nihlathak.js respectively as such

Pindleskin.js copied viper code and changed to temptress-

if (Config.Pindleskin.ViperQuit && getUnit(1, 597)) { print("Tomb Vipers found.");

        return true;
    }

    if (Config.Pindleskin.TemptressQuit && getUnit(1, 597)) {
        print("Temptresses found.");

        return true;
    }

Nihlathak.js copied viper code and changed to temptress-

if (Config.Nihlathak.TemptressQuit && getUnit(1, 472)) { print("Temptresses found.");

    return true;
}

thats all i changed. not sure where config.js is? maybe thats what im missing? or maybe i wrote some of whats above incorrectly(probably messed up both lol)

anyways if you dont mind helping me out let me know what i did wrong and right(if anything lol) and what needs changed to make it actually work.

DarkHorseDre commented 4 years ago

Bro, whenever you are seeking support anywhere, never be vague! always be specific. when you say it crashes - is there an error message on the console? (press home key as game client opens so you can see the text)

also, paste your files to pastebin.com or equivalent as reading through this mess with no syntax highlighting or line numbers is an ass ache (you want to give people as little work as possible to help ya!)

You need to know the function and location of files if you're going to customise your bot! else you'll just create a mess! Go a hunting for that very important file, and give it a read so you understand what it is doing ;)

Also, nihlathak has nothing to do with what you're doing - I mentioned that as an example of how you can do this: either file boss script by boss script or in toolsthread for all chars and all areas/bosses.

infact I just saw Config.Nihlathak.TemptressQuit that will fail if it doesn't exist too.

Know that Config.<something> refers to config.js and are name value pairs of the config object.

Xdaci commented 4 years ago

Bro, whenever you are seeking support anywhere, never be vague! always be specific. when you say it crashes - is there an error message on the console? (press home key as game client opens so you can see the text)

also, paste your files to pastebin.com or equivalent as reading through this mess with no syntax highlighting or line numbers is an ass ache (you want to give people as little work as possible to help ya!)

You need to know the function and location of files if you're going to customise your bot! else you'll just create a mess! Go a hunting for that very important file, and give it a read so you understand what it is doing ;)

Also, nihlathak has nothing to do with what you're doing - I mentioned that as an example of how you can do this: either file boss script by boss script or in toolsthread for all chars and all areas/bosses.

infact I just saw Config.Nihlathak.TemptressQuit that will fail if it doesn't exist too.

Know that Config.<something> refers to config.js and are name value pairs of the config object.

i appreciate that advice and the help, I'll compile it with exactly what i changed here. Thank you again for any help! /EDIT for some reason my highlighted clickable links take you to github, they are working links however so just copy and paste them to view.

Video of it crashing: Crashes both with D2BotLead.dbj and D2BotMap.dbj as entry script as soon as my character gets in game. Note this is on single player, all my bot testing is being done on single player atm. https://www.youtube.com/watch?v=6ifNMN-Ciwc&feature=youtu.be

Console Errors for both D2Botlead(testsorc) and D2BotMap(mh) crashes: 10:59:40 (mh) Window has unexpectedly exited... starting profile 10:59:56 (testsorc) Window has unexpectedly exited... starting profile 11:03:58 (testsorc) Crash Info: Script: none Area: out of game 11:04:06 (testsorc) Window has unexpectedly exited... starting profile 11:04:09 (testsorc) Crash Info: Script: none Area: out of game 11:04:18 (testsorc) Window has unexpectedly exited... starting profile

ToolsThread Section: Original Unedited ToolsThread.js script for reference: https://pastebin.com/eshVCV4W Note: Lines 300 and 680 are where edits will be made in the below posted Edited Version

Edited Version of ToolsThread.js with my attempts to add a Temptress check and Temptress quit: https://pastebin.com/xLeuFntP My first edit begins at line 319 and ends at 336 My second edit begins at 699 and ends at 703

Nihlathak.js and Pindleskin.js Changes: Note: I only want my bot to quit on temptresses at Nith, in both the Nihlathak.js and Pindleskin.js scripts ViperQuit is referenced, likewise in your char config under // Boss/area scripts > // act 5 > Scripts.Pindleskin and Scripts.Nihlathak ViperQuit is again referenced and requires an edit of True or False to be enabled. So my logic was to get TemptressQuit to work I have to add it to both the Nihlathak.js and Pindleskin.js scripts along side my Char Config script(see next section for char config)

Nihlathak.js edited- https://pastebin.com/YUK8SmEx My edits begin at line 24 and end at 28

Pindleskin.js edited- https://pastebin.com/SnN4iU7P My edits begin at line 60 and end at 64

Sorceress.testsorc.js Edited. Char config file Note: For my testing I only editied and tested on one bot, my sorc named testsorc https://pastebin.com/ZcrYKbLG My edits are at lines 104 and 107 (Note in regards to edits- I just realized I didn't even add a ; to the end of my edits lol)

Final comments: I posted everything I edited for full clarity, but I'm assuming the crash is rooted in ToolsThread.js seeing as how it crashes on D2BotMap as well which should be unaffected by boss scripts and my char config boss area settings.

You mentioned Config.js multiple times which I was unable to find, I assume it would be under Kolbot>Libs>Config. But besides my own character config scripts and the base char config scripts i.e. Amazon.js-Sorceress.js I don't see a Config.js. The only other config scripts are _BaseConfigFile and _CustomConfig.

I think that should be everything, let me know if you need anything else or any further clarification on what I've already posted. If you can help me get this working you will be the fucking king.

DarkHorseDre commented 4 years ago

haha thanks for all that work bro - btw that crash didn't tell me anything :p

When you paste to pastebin, don't forget to set the syntax language as JavaScript

I think you misunderstood - you either try to edit per script (actually not worth it I reckon) or do it in toolsthread (so for all toons, based upon config parameters)

Having a quick look, it seems you're missing some curly braces in the if block (I missed them out too as I was just pseudo guiding you - but you need to check!) you can use code validators - I saw someone here link it and just tried it - worth it if you don't have an IDE to validate in: https://esprima.org/demo/validate.html

so the code with correct braces looks like:

if ((Config.ViperCheck || Config.TemptressCheck) && getTickCount() - tick >= 250) {
     if (this.checkVipers()) { 
         D2Bot.printToConsole("Revived Tomb Vipers found. Leaving game.", 9);
     }
     if(this.checkTemptress()){ 
             D2Bot.printToConsole("Temptress' found. Leaving game.", 9); 
    }
}

ps you don't need to post links to the current code - it is here (well at the new home at blizzhackers) on github and can even be viewed in browser too: https://github.com/blizzhackers/kolbot

DarkHorseDre commented 4 years ago

config.js https://github.com/blizzhackers/kolbot/blob/master/d2bs/kolbot/libs/common/Config.js

you lose all points for not finding and reading that!

Xdaci commented 4 years ago

config.js https://github.com/blizzhackers/kolbot/blob/master/d2bs/kolbot/libs/common/Config.js

you lose all points for not finding and reading that!

I'm a literal complete scrub at this haha, my ONLY experience with any form of "coding" if it can even be called that. Is with d2 bot scripts lmao. If my memory serves me correct this is the only time in many many years of d2 botting I've tried to edit core scripts to add a entirely new function so my scrubness is showing even more so than normal.

I edited your fixed If code in the ToolsThread as well as added some functions for TemptressQuit into Config.js and now my bot is running and not crashing or showing any errors. So thats progress, I'll set her to do only nith and watch a few runs. See if it works as intended.

/pre post edit (decided to watch a few runs before even posting this.

It seems to be working! she quit on hell temptresses twice as I watched, unfortuneatly the print to console "Temptress' found. Leaving game." doesn't seem to work so I cant confirm 100%.

With that being said the print to console "Revived Tomb Vipers found. Leaving game." doesn't work either, been botting nith for quite some time and always use ViperQuit and it NEVER prints any messages on the console when she quits, so that function as a whole may just not work as intended.

Xdaci commented 4 years ago

config.js https://github.com/blizzhackers/kolbot/blob/master/d2bs/kolbot/libs/common/Config.js

you lose all points for not finding and reading that!

My final update as I think its working perfectly now. You were saying that I would only need to add a monsteridcheck and quit for Temptress in ToolsThread, Config.js, and my Character Config file, but I only want them to quit on Helltemptress at nith and only if I specify as such. Therefore I wanted to mimic the Config.Nihlathak.ViperQuit = true; but with Helltemptress.

So I followed your advice for ToolsThread, including your revised correctly bracketed code listed above (thank you again) then added some lines to Config.js, Nihlathak.js and finally my Characters config.js file.

Maybe if you don't mind one final go over for me, see if you think its working as intended based on what I've edited.

ToolsThread.js final revision: https://pastebin.com/8w9ggga1 Edited Lines: 319-336 Edited Lines- 699-704

Config.js final revision: Note: I wanted to add this TemptressQuit to both Nihlathak and Pindleskin because as of now I'm testing Nihlathak only, but when it comes time to run these scripts on bnet I'll most likely be using PIndleskin with Config.Pindleskin.KillNihlathak = true; https://pastebin.com/yzdy74uk Edited Lines- 347-348 Edited Lines- 351-352

Nihlathak.js final revision: https://pastebin.com/KKYbVSW9 Edited Lines- 24-28

Pindleskin.js final revision: https://pastebin.com/tnC5v4yF Edited Lines- 60-64

Sorceress.testsorc.js final revision: https://pastebin.com/HLuFGu0N Edited Lines- 104 Edited Lines- 107

With the above edits it seems to be working, but since the print to console command seemingly does not work(neither for Vipers or my edited Temptresses its hard to say with 100% certainty)

So if you wouldn't mind going over my edited scripts one final time and confirming if my edits seem like they would indeed produce the intended effect of quitting on hell temptresses or not I would greatly appreciate it.

Again though it SEEMS to be working lol, so I think with your help I may have gotten it!

Thanks again regardless brother, I truly do appreciate the help and the patience with my noob esque manner of posting and editing, etc.

DarkHorseDre commented 4 years ago

That's cool - I'm no coder either - just learning by reading, observing, doing and lastly asking ;)

D2Bot.printToConsole - that prints text to the d2bs bot window on the left. print writes text to the ingame console (visible when you press home)

I cant check all that, I'll just repeat what I said before: you don't need to touch toolsthread if you are making these changes for use in specific boss scripts. I'd take it out as it could cause problems when any bot comes across those temptresses elsewhere.

The nih viper code checks for vipers as it travels to nihi - so you could use the same logic there without toolshread