kolton / d2bot-with-kolbot

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

Feature Request - Cast Item Charged Skill #1099

Closed braxtonKappes closed 5 years ago

braxtonKappes commented 5 years ago

I didn't do a ton of looking into the scripts but is there anyway to precast "Sage Oak" when Wisp Projector is equipped?

DarkHorseDre commented 5 years ago

Try this at the top of doPrecast function (but below precastcta) of precast.js, I used similar for frozen armour etc when on item but not a hard skill:

if (me.getSkill(226, 1) && (!me.getState(149) || force)) { this.precastSkill(226); // skillid 226 = oak sage; state 149 = oaksage }

check to see if the charges are repaired then bot goes to town as I wouldn't assume they would be repaired with other charges, as it should!

for the other skills on wisp or other item, just check the skillid via the pastebin page referenced in the char configs (http://pastebin.com/baShRwWM), and state ids from the d2bs/kolbot/sdk/states.txt file

braxtonKappes commented 5 years ago

Thank you for the response! So no error messages or anything like that but my bots are still not precasting oak sage. This is what my precast.js looks like for this specific section...

    // Force BO 15 seconds before it expires
    this.precastCTA(!me.getState(32) || force || (getTickCount() - this.BOTick >= this.BODuration - 15000));

if (me.getSkill(226, 1) && (!me.getState(149) || force)) {
this.precastSkill(226); // skillid 226 = oak sage; state 149 = oaksage
}

    switch (me.classid) {
    case 0: // Amazon
        if (Config.SummonValkyrie) {
            this.summon(32); // Valkyrie
DarkHorseDre commented 5 years ago

Hhmmmm.. maybe i was premature - checking/casting charged skills may be different.. I'd test but i'm at work and my bot is 200k in line to create game since Monday QQ

check attack/town.js and see how it reads charges.. you may need to check for them and then cast it somehow :\

braxtonKappes commented 5 years ago

Ahh okay! Well I do appreciate your help on this issue and any future help you could provide would be great! I'm an amateur at best with coding haha but I'll give the attack/town.js and see what I can find

DarkHorseDre commented 5 years ago

.. you and me both :) There are guys on here who would know how to do this so hang tight - that said, I dont think I've seen much done with charges, but lots of these guys customise stuff like this in their installation.. lets hope they see this!

braxtonKappes commented 5 years ago

I hope so too! :) I'm sure this could help out a lot of other people as well wondering how to customize item charges into their bot configs

DarkHorseDre commented 5 years ago

I'd love to test this but cant (82k in line.. QQ)

I can see how to detect charges and read skills, just not sure about finding skill id of charges and casting (you can detect charges by skill in pickit nip files..)

braxtonKappes commented 5 years ago

RIP... Does not sound like a good time man lol

Ya I'm stuck on this issue. Everything I try doesn't work but again I'm not educated very well in coding to understand all the lines. I can make educated guesses but I'm just not having any luck with my testings.

DarkHorseDre commented 5 years ago

oops, doesnt look good - searched the issues :) https://github.com/kolton/d2bot-with-kolbot/issues/795

braxtonKappes commented 5 years ago

oh nooo! That sucks hahah alright well thank you for being so helpful!! Really do appreciate it. Keeping my fingers crossed for an update on this issue in the near future!!

DarkHorseDre commented 5 years ago

Needs someone with skill and time.. there are a few people writing changes right now, but they are doing their things.. maybe befriend someone and raise this as a feature request!

*infact, rename this issue and put feature request in the subject, you (we) may get lucky :)

braxtonKappes commented 5 years ago

Not a bad idea lol and I've gone ahead and edited the title! Now all we can do is wait and see if this catches a coders attention. FINGERS CROSSED

DarkHorseDre commented 5 years ago

lol - maybe change it to be more generic, like:

feature request - cast item charged skill

braxtonKappes commented 5 years ago

done :)

Kosoleld commented 5 years ago

I know how to get this done, contact me on discord to discuss. Kosoleld#2612

DarkHorseDre commented 5 years ago

@kosoleld if you can do this, why not share with the community here so its a persistent entry for all to find?

Kosoleld commented 5 years ago

@DarkHorseDre "Why don't you give to me for free" why dont you pay me something for the hours i spent on it? I'm not one of the devs of kolbot.

5noop commented 5 years ago

I'm not one of the devs of kolbot.

But you could be, kolbot would not exist without users ready to spend some of their free time on it ;)

DarkHorseDre commented 5 years ago

I'm glad you re-posted the response you deleted earlier, @Kosoleld

Nobody is judging you for deciding if you want to make some dollar, but as @5noop says, you COULD choose to share: That's why the bot exists - through the donation of code from of others.

I realise there are people whom sell their mods, but the spirit of this forum (github FREE code which we modify), and discord etc. is that the vast majority of people, myself included, help people out.

Kosoleld commented 5 years ago

Where have you helped out?

braxtonKappes commented 5 years ago

I stopped playing diablo 2 therefore have no more interest in using the bot at such time, but in the future if I ever plan on going back into Diablo2 botting world (which is more likely than not) then I'll happily pay you for that code. I understand that github is a free coding site, but by no means is anyone obligated to just give their hard work away. With that being said if anyone is looking for this solution, as I was a few months back, then I'd highly recommend reaching out to Kosoleld even if it costs you some money. Kolbot is however free and I see it as paying for a plugin for a free software.

Thanks for the responses and Kosoleld for a possible solution. I'm closing this thread for now.

DarkHorseDre commented 5 years ago

lol just got this working - simple fix. seems nobody bothered to share the update, but intended to.

lemme know if anyone wants to do this 'fo free

ChaoticDerbs commented 4 years ago

Is there anyway to far cast with this bot on map or mule mode for pvp purposes?

Kosoleld commented 4 years ago

I've changed my mind and become more willing to share my stuff since my previous posts. I also got this working, it's not very hard. If someone wants to get it working, it's basically just this:

I've put the function in misc.js and added a call to it in the towncheck loop which works for me. I can set up which wisp to use by changing the char's config file Config.Wisp = "Oak sage"/"Heart of Wolverine"/"Spirit of Barbs"

castWisp: function() { var wisp = Config.Wisp; if(!wisp) { //Default as oak sage return true; } var wispItem; if(me.inTown) { // getState for wisps always false in town return true; } switch(wisp) { case "Oak Sage": if(me.getState(149)) { // Already up return true;
} for(var i=0;i<Skill.charges.length;i++) { switch (Skill.charges[i].skill) { case 226: //Oak sage wispItem = Skill.charges[i].unit; break; default: break; } } if(!wispItem) { wispItem = Item.getEquippedItem(4,true); } //Skill.setSkill(54, 0); me.setSkill(226, 0, wispItem); Packet.castSkill(0, me.x, me.y); return true; case "Heart of Wolverine": if(me.getState(148)) { // Already up return true;
} for(var i=0;i<Skill.charges.length;i++) { switch (Skill.charges[i].skill) { case 236: //Heart of Wolverine wispItem = Skill.charges[i].unit; break; default: break; } } //Skill.setSkill(54, 0); me.setSkill(236, 0, wispItem); Packet.castSkill(0, me.x, me.y); return true; case "Spirit of Barbs": if(me.getState(147)) { // Already up return true;
} for(var i=0;i<Skill.charges.length;i++) { switch (Skill.charges[i].skill) { case 246: //Spirit of Barbs wispItem = Skill.charges[i].unit; break; default: break; } } //Skill.setSkill(54, 0); me.setSkill(246, 0, wispItem); Packet.castSkill(0, me.x, me.y); return true; default: return true; } },

Edit: dno whats up with the code, I'm pasting it in the text field with newline characters......ok without code tags it shows the newlines but no leading space/tabs sorry guys.

DarkHorseDre commented 4 years ago

just fyi - if hoto is used by toon and the toon weapon switches, regardless of where the oak sage charge was cast from (wisp, np, hoto), the game kills the oak, so you cant buff it (you need to cta buff, switch first then cast oak sage).

Bonesmuggler commented 4 years ago

lol just got this working - simple fix. seems nobody bothered to share the update, but intended to.

lemme know if anyone wants to do this 'fo free

I can't seem to get this to work, can you help a brother out?

DarkHorseDre commented 4 years ago

lol just got this working - simple fix. seems nobody bothered to share the update, but intended to. lemme know if anyone wants to do this 'fo free

I can't seem to get this to work, can you help a brother out?

Did you try what Kosoleld explained?

Bonesmuggler commented 4 years ago

I did I’m just confused on where to put the code to actually cast it. I edited the two files prototype.Js and misc.js, but not sure where to go from there

DarkHorseDre commented 4 years ago

As per the thread - precast.js

Bonesmuggler commented 4 years ago

Should I use Kosoleld's method or this one : Add the ability to use charged skills easily #1523??

DarkHorseDre commented 4 years ago

you said you were using kosolelds suggestion and asked where to put it. I told you, now youre asking about something else,

why are you asking? why dont you do what you said you were trying so you can solve this and move on?

Bonesmuggler commented 4 years ago

you said you were using kosolelds suggestion and asked where to put it. I told you, now youre asking about something else,

why are you asking? why dont you do what you said you were trying so you can solve this and move on?

I was just looking threw the different links, wasn't sure if Kosolelds would work with a HOTO, as it looks like it was made for a wisp. It if will work I'm assuming I put this in chr config file - Config.Wisp = "Oak sage"/"Heart of Wolverine"/"Spirit of Barbs" and the rest of the code goes in the precast.js file under the BO check.

XPZ2k15 commented 4 years ago

Any luck on this? I ended up using Kosolelds method of putting the function instead of misc.js .. I then go inside of precast.js and fine the switch for the sorceress and I add the line Skill.castWisp(); . I also added Config.Wisp = 'Oak Sage'; . I did not get it to summon the oak sage. Any solutions?

Kosoleld commented 4 years ago

Like I said, I added the function above town check in misc and put a call to it in the town check loop.

Bonesmuggler commented 4 years ago

Ok that gets me closer, so after I add the function part in misc.js do I add the Config.wisp in the character file. And I have idea how or where to put a call into the town check loop.

DarkHorseDre commented 4 years ago

ok so I wasn't gonna share my implementation as its particular to my needs (see below) and isn't as flexible as kosolelds, but I've seen many people ask so here it is.

ofc where mine differs, you can change. indeed, koselds does it all so take your pick 🤷

Summary: I don't cast from hoto as summons are killed by the game when you weapon switch (for cta, mf switch etc), rings don't switch but wisp has a low level oak sage. Natures peace was therefore my preferred choice.

Structure: I put all the code in a new file and call it from precast.js - I prefer this so I make no or minimal changes to kolton files. my file wont be merged when I svn update, which makes my life easier (I'm sure there is a better way of managing this but...)

The idea is that whenever my bot precasts, it also checks for oak sage and casts if not present.
It also doesn't recast everytime oak dies as it can die often - and your bot will be left there casting endlessly in these conditions.

I also cast oak first then cta (if I have it) so the oak is buffed = you get more life.

common/precastChargedSkill.js: https://pastebin.com/HqqGdr3k

precast.js - do NOT copy my precast.js over yours - it has many changes and some are experimental ;) instead search for the 5 entries of "precastchargedskill" and place the lines in your precast.js (or just implement it differently) https://pastebin.com/6yPjdzhp

default.dbj - I also added this line to the top to ensure I could include my file - not sure if correct, but it works :)

if (!isIncluded("common/precastChargedSkill.js")) { include("common/precastChargedSkill.js"); };

Vid demo (you'll see life go from start 1256, then 19xx after oak, then 2490 after bo and buffed oak): https://youtu.be/0YVTRYk2vMo

Kosoleld commented 4 years ago

Thanks for sharing yours too. I think it's nice to let the bots evolve by sharing code. I'm pretty sure mine has that weakness. If you wear HOTO and try to recast it using a ring, it will use HOTO. I wrote the loop through items in order as they come and check if they have charged skill oak sage and to use the first one it finds. I can rewrite it if someone wants it but you can probably get it working from DarkHorseDre's post.

DirtNasti commented 3 years ago

ok so I wasn't gonna share my implementation as its particular to my needs (see below) and isn't as flexible as kosolelds, but I've seen many people ask so here it is.

ofc where mine differs, you can change. indeed, koselds does it all so take your pick 🤷

Summary: I don't cast from hoto as summons are killed by the game when you weapon switch (for cta, mf switch etc), rings don't switch but wisp has a low level oak sage. Natures peace was therefore my preferred choice.

Structure: I put all the code in a new file and call it from precast.js - I prefer this so I make no or minimal changes to kolton files. my file wont be merged when I svn update, which makes my life easier (I'm sure there is a better way of managing this but...)

The idea is that whenever my bot precasts, it also checks for oak sage and casts if not present. It also doesn't recast everytime oak dies as it can die often - and your bot will be left there casting endlessly in these conditions.

I also cast oak first then cta (if I have it) so the oak is buffed = you get more life.

common/precastChargedSkill.js: https://pastebin.com/HqqGdr3k

precast.js - do NOT copy my precast.js over yours - it has many changes and some are experimental ;) instead search for the 5 entries of "precastchargedskill" and place the lines in your precast.js (or just implement it differently) https://pastebin.com/6yPjdzhp

default.dbj - I also added this line to the top to ensure I could include my file - not sure if correct, but it works :)

if (!isIncluded("common/precastChargedSkill.js")) { include("common/precastChargedSkill.js"); };

Vid demo (you'll see life go from start 1256, then 19xx after oak, then 2490 after bo and buffed oak): https://youtu.be/0YVTRYk2vMo

@DarkHorseDre How do I implement using spirit of barbs instead of oak sage? I tried changing skill 226 to 246 on line 25, 31 and 41 in PrecastChargedSkill.js. However, he does cast spirit of barbs instead of oak sage but he teleports once then casts a new spirit of barbs. Rinse repeat till he is out of charges and has to repair, then the cycle continues. This is how my PrecastChargedSkill.js file appears;

/**

function PrecastChargedSkill (force) {

if (!force && me.getState(149)) {
    //print("failed getstate");
    return true;
}
if (me.gametype === 0 || me.inTown) {
    return false;
}

var bestChargeLevel = 0;

    for (var i = 0; i < Skill.charges.length; i++) {

        var oakItem;
        if (bestChargeLevel === 0 && Skill.charges[i].skill === 246) { //initially set the first encountered oak sage skill as target
            bestChargeLevel = Skill.charges[i].level;
            oakItem = Skill.charges[i].unit;
            //print("best charge level initial: " + bestChargeLevel);
            continue;
        }
        if (Skill.charges[i].level > bestChargeLevel && Skill.charges[i].skill === 246) { //now compare each match on oaksage on skill level
            bestChargeLevel = Skill.charges[i].level;
            oakItem = Skill.charges[i].unit;
            //print("best charge level subsequent: " + bestchargelevel);
            continue;
        }

    }

    //print(JSON.stringify(oakItem));
        Skill.setSkill(246, 0, oakItem); //0 is right hand, charged skills always right
        Packet.castSkill(0, me.x, me.y); //cannot be skill.cast

    return true;

};

DarkHorseDre commented 3 years ago

mate, if you're going to paste code and get responses, please paste to pastebin.com or similar site and paste the link here as reading code without syntax highlighting is that much more harder, and long pastes make the threads unnecessarily long to scroll.

I haven't read your code but remember to check for the state of the skill you are using. you can see the code getState(149) for oak - find what you need for your skill and change Everything - read through the code. the states are in states.txt

DirtNasti commented 3 years ago

mate, if you're going to paste code and get responses, please paste to pastebin.com or similar site and paste the link here as reading code without syntax highlighting is that much more harder, and long pastes make the threads unnecessarily long to scroll.

I haven't read your code but remember to check for the state of the skill you are using. you can see the code getState(149) for oak - find what you need for your skill and change Everything - read through the code. the states are in states.txt

My apologies and thank you for the info.

DirtNasti commented 3 years ago

@DarkHorseDre I edited my PrecastChargedSkill.js to this https://pastebin.com/b5wkY3uy. He is still doing the same thing. I can see that its using a partial name of the skill oaksage as oakItem, so I'm thinking that I need to change this but unsure of what the correct phrase is as I have searched through the files for a corresponding identifier to no avail. I did try replacing oakItem with barbsItem but no luck.

DarkHorseDre commented 3 years ago

no worries - just a general fyi as you wont get much help otherwise!

ah ok I don't know anything about dudu skills :) Seems that barbs is a minion and not an aura, so you have to cast differently.

Try this: as per precast.js use skill.cast.

change the command Packet.castSkill(0, me.x, me.y);

to: Skill.cast(246, 0);

DirtNasti commented 3 years ago

no worries - just a general fyi as you wont get much help otherwise!

ah ok I don't know anything about dude skills :) Seems that barbs is a minion and not an aura, so you have to cast differently.

Try this: as per precast.js use skill.cast.

change the command Packet.castSkill(0, me.x, me.y);

to: Skill.cast(246, 0);

Ok I'll give it a try but I'm pretty sure spirit of the barbs is exactly like oak sage. I mean they are both casted minions that give auras, fingers crossed.

So as I suspected it's trying to use it as an aura, like an hdin uses vigor with holy bolt in baal runs to kill the unravellers that are immune to magic. This is what I changed https://pastebin.com/Ex5V6nP7

Also in the PrecastChargedSkill.js file it does say //cannot be skill.cast

DirtNasti commented 3 years ago

@DarkHorseDre Got any other ideas on how to get this working, I'm at a loss?

DarkHorseDre commented 3 years ago

ok so it seems we've gone around the houses.

your first pastebin should have worked - I just changed mine to what I think it should be and it worked, then compared to your first one and they are the same.

Which item are you equipping to give you spirit of barbs?

DirtNasti commented 3 years ago

ok so it seems we've gone around the houses.

your first pastebin should have worked - I just changed mine to what I think it should be and it worked, then compared to your first one and they are the same.

Which item are you equipping to give you spirit of barbs?

I'm using wisp projector ring.

DarkHorseDre commented 3 years ago

Good. well I equipped WP and changed the state and skill id's as previously mentioned and per your first pastebin and it works.

If yours is not working then you need to double check what you're doing re-read the posts too.

ps - did you get oaksage to cast with natures peace? if you didnt then...

DirtNasti commented 3 years ago

Good. well I equipped WP and changed the state and skill id's as previously mentioned and per your first pastebin and it works.

If yours is not working then you need to double check what you're doing re-read the posts too.

ps - did you get oaksage to cast with natures peace? if you didnt then...

Yes oaksage works perfectly fine but when I change the state and skill id's it goes bonkers.

DirtNasti commented 3 years ago

@DarkHorseDre Maybe pastebin a copy of your file using spirit of barbs and ill copy that in. something must have gotten changed in process.

DarkHorseDre commented 3 years ago

welp I'm not gonna attach it if this the same as yours and I made the changes you can read above..

do you have wisp and np equipped at same time? I didn't test that.. just equip wp and no np (can be anything else) and check that. if no joy then re read this thread..