kolton / d2bot-with-kolbot

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

Prebuffing Skills which are available only from switch weapon #797

Open Geglash15 opened 5 years ago

Geglash15 commented 5 years ago

I have quesstion to this:

https://github.com/kolton/d2bot-with-kolbot/pull/443

There is a chance to choose Precast skill for excample Energy Shield if it's only available on switch from magic staff +3 to ES and I don't put any skill point to this skill before?

Looks like it checks both slots for higher skill lvl only if this skill is able on based switch#1

DarkHorseDre commented 5 years ago

Yeah looks like the check is in precast: if (me.getSkill(58, 0) && (!me.getState(30) || force)) { this.precastSkill(58); // Energy Shield if you have hard points in the skill and ES is not active. I'm guessing you want to add an OR to check highest points from skills from items in slot 1 or 2.

I dont have access to the repo from here but I would scavenge the code for checking for skills from items and add to the precast check above, should work. if you dont get any help I may be able to implement and test some point.

note: there is also a charged skill check in misc.js - seems you may need add a check for skills from items to the getskill here too else it will only check hard skill points :\

I was thnking that the pala (and other classes) use enigma for teleport which is a similar scenario - I see in the paladin.js this line me.getStat(97, 54) - which is 97 = nonclass skill, 54 = tele. using this may be enough? I think a switch to slot 2 would be needed too, which is also handled somewhere in the code.. (Precast.weaponSwitch may be the way to go. maybe simpler to re-use the CTA weapon switch functionality as it is similar (check if have teleport on weapon switch, if so, precast skill 58)

mf022 commented 5 years ago

There is a chance to choose Precast skill for example Energy Shield, if it's only available on switch from magic staff +3 to ES and I don't put any skill point to this skill before?

if your char hasn't set any skill points than the points granted by the equipped item, you should remove the skill checking part, so the line 183 from Precast.js (limedrop-utf8 branch): if (me.getSkill(58, 0) && (!me.getState(30) || force)) { become: if (!me.getState(30) || force) {

The same removing of that check can be used by example for enchant items, considering the line 201 to be changed.

DarkHorseDre commented 5 years ago

will that work? seems the game wont see the skill unless the weapon is switched. This would work for enigma tele as its always present, but switch wont be seen (if you look at the skill tree when not showing switched weapon, skill wont be shown in blue with points in it)

Dont we just need a way of checking the skill from weapon switch?

and what does the force parameter do?

mf022 commented 5 years ago

and what does the force parameter do?

I guess that part is referring to the force situation of re-precast bo and buffs

DarkHorseDre commented 5 years ago

ok.. so about my main question: The game wont see the skill if weapon not switched, so how can it cast the switch skill without switching (and checking to avoid failed cast attempt and d/c)?

mf022 commented 5 years ago

Precast.js includes a part with checking the best slot, which has the me.weaponswitch.

me.getSkill(58, 0) will look for hard points in skill, and I guess that it won't see the skills granted by items.

idk, maybe me.getSkill(58, 1) which will return the actual skill level can be used.

DarkHorseDre commented 5 years ago

@mf022 gdam it worked! a simple getskill(40,1) made he use frozen armour from weapon that wasnt a hard skill (weapon wasnt on switch tho - I'll worry about that when I play expansion :) )

DarkHorseDre commented 5 years ago

@Geglash15 look at this line in precast.js as referenced by mf022: this.weaponSwitch(this.getBetterSlot(149));

think thats the line to look for best weapon slot for BO and switches to that slot - you then check state for bo then cast. same would apply for other skills like energy shield

CptClawPLN commented 5 years ago

if anyone could figure out how to get shiver armor to cast from swap without hard points i'd be willing to donate like $20 or something

DarkHorseDre commented 5 years ago

@CptClawPLN casting shiver armour without hardpoints but from item NOT on switch would be same as I did above, (line 187 from https://github.com/kolton/d2bot-with-kolbot/blob/master/d2bs/kolbot/libs/common/Precast.js): if (me.getSkill(50, 1)) { //checks softskills, but not on switch if (!me.getState(88) || force) { this.precastSkill(50); // cast Shiver Armor

I've made that work (just changing the ,0 to ,1 as per this thread)

What I haven't tried is the switch cast, as I referenced above: this.weaponSwitch(this.getBetterSlot(50));

give it a try, its easy to test

CptClawPLN commented 5 years ago

Yeah I tried this in sorceress attack, precast, and misc but didnt work

this.weaponSwitch(this.getBetterSlot(50)); if (me.getSkill(50, 1)) & & if (!me.getState(88) || force) { this.precastSkill(50); // cast Shiver Armor

DarkHorseDre commented 5 years ago

Elaborate on what you mean by "didnt work". was the code even executed? (how do you know?)

which item is providing the shiver armour and are they charges or "+n to shiver armour"?

CptClawPLN commented 5 years ago

+n to shiver armor

cinderstorm commented 5 years ago

could the same logic be applied to a bowazon swapping for wizspike/spirit? I find she likes to try and attack with wizspike because the weapon swap failed (or it simply tried to attack without checking to swap first)

Maybe I'm not reading precast.js correctly, but it seems we have no actual validation of which weapon slot we are in - rather we are iterating through other checks... so I'm thinking like the CTA check, a check for ranged skills/weapons should be included... I will do some work on this

Mark-William-Schumacher commented 4 years ago

If you want to cast frozen armour but its only on your switch item add these lines after the case statement at line number 146 in file Precast.js

case 1: // Sorceress
    if (!me.getState(10) || force) {
        Attack.weaponSwitch(this.getBetterSlot(40));
        this.precastSkill(40);
    }

If you want to cast shivering armor add this

case 1: // Sorceress

    if (!me.getState(88) || force) {
        Attack.weaponSwitch(this.getBetterSlot(50));
        this.precastSkill(50);
        }

If you want to cast chilling armor add this

case 1: // Sorceress
    if (!me.getState(20) || force) {
        Attack.weaponSwitch(this.getBetterSlot(50));
        this.precastSkill(60); // Chilling Armor
        }
Jstodz commented 4 years ago

Hello,

I still can't make my sorc to precast energy shield and chilling armor on switch... Any news about this? I tried what Mark just mentionned.

Thanks!

DarkHorseDre commented 4 years ago

@Jstodz ah, you have to do weaponswitch before, just like with casting bo from cta (check precast.js)

Jstodz commented 4 years ago

@DarkHorseDre got it working thanks my man! Last piece of optimization, my sorc is now doing switch, bo, switch, switch, precast, switch.

Any way I could make her do switch, bo, precast, switch? Like put the precast loop into the bo loop but so guess it will impact other chars precasting then?

Thanks!

DarkHorseDre commented 4 years ago

Glad you sorted it as I didn't have time to work it out :)

i'm not sure what you mean but I would be careful not to change precast for others.

I'd look at the section for energy shield and change it to check skill on switch and then cast maybe? cta checks for the actual cta item.. you could search for item on switch using item.bodylocation (offhand left and right) and then check the skill, then cast if its there? I'll give it a try myself in a few days - lemme know if you get stuck and I'll try and learn myself!

Jstodz commented 4 years ago

@DarkHorseDre yeah sorry It’s me, I was not clear. So basically the sequence my sorc is going through right now is :

1)Switch from weapon slot 1 to weapon slot 2 2) BO 3) Switch from weapon slot 2 to weapon slot 1 4) Switch back from weapon slot 1 to weapon slot 2 (because precast skills are on the cta) 5) Cast Energy shield and Chilling Armor 6) Switch from weapon slot 2 to weapon slot 1

Basically it works but I would like to make it more efficient and remove steps 3) and 4).

Hope it makes more sense now. It’s basically trying to have one global precast loop with bo included and not one loop of bo and then one loop of energy shield and chilling armor.

I will look into precast.js code more and try to figure it out :)

DarkHorseDre commented 4 years ago

oh yeah you can - check the 'havecta','checkCTA', 'castcta' (from memory) - you could put it in the castcta function - add a config option so it only fires for that toon (and then does the check for ES skill and casts after cta cast but before switching back to slot 1)

Jstodz commented 4 years ago

Do you have an example where I can find a config function for my char? Is it for the character class or character name / profile?

DarkHorseDre commented 4 years ago

no you would create one in char config (https://github.com/kolton/d2bot-with-kolbot/tree/master/d2bs/kolbot/libs/config) and place a new config option, e.g:

Config.PreCastESFromSwitch = true;

Then you have to (should) add it & initialise in conifg.js, e.g. (not necessarily here):

// Sorceress specific
    UseTelekinesis: false,
    CastStatic: false,
PreCastESFromSwitch: false,
    StaticList: [],
thetopfew commented 3 years ago

Ok I feel stupid, yall are saying these edits are working.. but not for me. I currently have:

        if (me.getSkill(58, 1) && (!me.getState(30) || force)) {
            Attack.weaponSwitch(this.getBetterSlot(58));
            this.precastSkill(58); // Energy Shield
        }

.. my sorc does not have hard points into ES, trying to cast from CTA side. She has yet to cast it at all. And I feel like I understood this page very well. Can anyone post the working code please?

DarkHorseDre commented 3 years ago

Mine works for s-armour and doesnt include weaponswitch- IIRC this is done anyway. the main change is to specify soft points vs hard points:

//if (me.getSkill(50, 0)) {
if (me.getSkill(50, 1)) {   //for check for oskill when no hard skill
    if (!me.getState(88) || force) {
        this.precastSkill(50); // Shiver Armor

edit - I just caught you are trying to cast from cta side - what is the source of your ES if not hard skill?

thetopfew commented 3 years ago

Mine works for s-armour and doesnt include weaponswitch- IIRC this is done anyway. the main change is to specify soft points vs hard points:

//if (me.getSkill(50, 0)) {
if (me.getSkill(50, 1)) { //for check for oskill when no hard skill
  if (!me.getState(88) || force) {
      this.precastSkill(50); // Shiver Armor

edit - I just caught you are trying to cast from cta side - what is the source of your ES if not hard skill?

As I mentioned, I am trying to cast ES from CTA. I have no hard points into ES or Chilling armor, both are on CTA. I want to precast both with BO ofc. And the code you just posted, still don't work for me for the CA either. Neither are casting from CTA staff. Below is a copy of exactly what I have.

    case 1: // Sorceress
        if (me.getSkill(57, 0) && (!me.getState(38) || force)) {
            this.precastSkill(57); // Thunder Storm
        }

        if (me.getSkill(58, 1)) {
            if (!me.getState(30) || force) {
                this.precastSkill(58); // Energy Shield
            }
        }

        if (me.getSkill(50, 0)) {
            if (!me.getState(88) || force) {
                this.precastSkill(50); // Shiver Armor
            }
        } else if (me.getSkill(60, 1)) {
            if (!me.getState(20) || force) {
                this.precastSkill(60); // Chilling Armor
            }
        } else if (me.getSkill(40, 0)) {
            if (!me.getState(10) || force) {
                this.precastSkill(40); // Frozen Armor
            }
        }

        if (me.getSkill(52, 0) && (!me.getState(16) || force)) {
            this.enchant();
        }
thetopfew commented 3 years ago

'edited out' - since it wasn't a viable solution.

DarkHorseDre commented 3 years ago

ah, saying the skills were on a staff and that was your cta weapon helped lol

@thetopfew can you zip up your character files (or just the CTA item really) and post? I want to see if I can see what the problem is

thetopfew commented 3 years ago

ah, saying the skills were on a staff and that was your cta weapon helped lol

@thetopfew can you zip up your character files (or just the CTA item really) and post? I want to see if I can see what the problem is

Sorry for the confusion, I mentioned I was casting ES from CTA with no hardpoints, my bad for not saying staff. Let me know what files you want.

Sooo.. my last post ofc worked, but only worked when BO precast was initiated, it did NOT work however if Energy Shield would be taken away from a monster, sometimes resulting in death because it wouldn't recast ES until BO ran out again! Soooo.. I spent a few more hours on this today.

OK, here we go! First off, I implemented @DarkHorseDre's idea with a new char config function. This 'does work for me 100%', it will cast all sorc precasts from secondary along with your BO (if its a CTA staff) without double swapping, as well as recast ES if it falls off from being hit hard. This was also testing on a flail CTA bearer with hard points instead too, works both ways!

  1. In config.js, add below "// Sorceress specific": PreCastFromSwitch: false, // added by me

  2. In your sorceress.charactername.js, add below "// Class specific config": Config.PreCastFromSwitch = true; // added by me (see config.js & precast.js) -- this will precast t.storm, cold armors, energy shield & enchant from switch if they exist.

  3. In precast.js, add two new functions after line#12 (before the precastCTA function):

    // added by me
    this.SwapToPrecast = function (precastId) {
        Attack.weaponSwitch();
        Skill.cast(precastId, 0); // Precast Single Given Skill If It Runs Out
        Attack.weaponSwitch();
        return true;
    };

    // added by me
    this.PreCastFromSwitch = function (force) {
        if (me.getSkill(57, 1) && (!me.getState(38) || force)) {
            Skill.cast(57, 0); // Thunder Storm
        }

        if (me.getSkill(58, 1) && (!me.getState(30) || force)) {
            Skill.cast(58, 0); // Energy Shield
        }

        if (me.getSkill(50, 1)) {
            if (!me.getState(88) || force) {
                Skill.cast(50, 0); // Shiver Armor
            }
        } else if (me.getSkill(60, 1)) {
            if (!me.getState(20) || force) {
                Skill.cast(60, 0); // Chilling Armor
            }
        } else if (me.getSkill(40, 1)) {
            if (!me.getState(10) || force) {
                Skill.cast(40, 0); // Frozen Armor
            }
        }

        if (me.getSkill(52, 1) && (!me.getState(16) || force)) {
            this.enchant();
        }
        return true;
    };
  1. In precast.js, inside the precastCTA function, below this line "Skill.cast(149, 0); // Battle Orders" add the following:
if (Config.PreCastFromSwitch !== false) { // added by me
    this.PreCastFromSwitch(force);
}
  1. In precast.js, replace the entire "case 1: // Sorceress section to this:
        case 1: // Sorceress
            if (me.getSkill(57, 1) && (!me.getState(38) || force)) {
                if (Config.PreCastFromSwitch !== false) {
                    this.SwapToPrecast(57);
                } else {
                    this.precastSkill(57); // Thunder Storm
                }
            }

            if (!me.getState(30) || force) {
                if (Config.PreCastFromSwitch !== false) {
                    this.SwapToPrecast(58);
                } else {
                    this.precastSkill(58); // Energy Shield
                }
            }       

            if (me.getSkill(50, 1)) {
                if (!me.getState(88) || force) {
                    if (Config.PreCastFromSwitch !== false) {
                        this.SwapToPrecast(50);
                    } else {
                        this.precastSkill(50); // Shiver Armor
                    }
                }
            } else if (me.getSkill(60, 1)) {
                if (!me.getState(20) || force) {
                    if (Config.PreCastFromSwitch !== false) {
                        this.SwapToPrecast(60);
                    } else {
                        this.precastSkill(60); // Chilling Armor
                    }
                }
            } else if (me.getSkill(40, 1)) {
                if (!me.getState(10) || force) {
                    if (Config.PreCastFromSwitch !== false) {
                        this.SwapToPrecast(40);
                    } else {
                        this.precastSkill(40); // Frozen Armor
                    }
                }
            }

            if (me.getSkill(52, 1) && (!me.getState(16) || force)) {
                if (Config.PreCastFromSwitch !== false) {
                    this.SwapToPrecast(52); // this only does on self
                } else {
                    this.enchant();
                }
            }

            break;
  1. In precast.js, search for line "// Force BO 30 seconds before it expires" and replace the line below it with: this.precastCTA(!me.getState(30) || !me.getState(32) || force || (getTickCount() - this.BOTick >= this.BODuration - 30000)); // edited by me

THIS WORKED FOR ME! I'm not perfect, but will power is a powerful thing! Please let me know if you find any bugs, improvements or code clean up. Thanks!

DarkHorseDre commented 3 years ago

Look for the character files - so if your es sorcs name was Twinks, the filename would be Twinks.d2s - somewhere in your \realm folder of d2 folder - they can then be loaded in single player mode.

grab all the files that start with your character name in that folder (although I think d2s is all I need)

as for your recent changes, I think there may be an easier way of doing it, but I'll have to look into it and let ya know if I figure it out (I havent done any kolbot stuff in ages)

thetopfew commented 3 years ago

Yea, there might be an easier way of doing it, I'm no professional. I'm much better with PHP. I know what the char.js files are considering what I just wrote ^_^ kinda wondering why you would want to see my char.js when all it is a setting file really. I only added one line to it for our cause, last post describes it. FYI, other than the Sorceress.NameGoesHere.js file, there are no other files named after your character name.

UPDATE: Edited my last post with final working result. At least as far as my tests went! :smiley: Let me know if anyone tests out a memory staff or enchant orb using mine. Thanks!

DarkHorseDre commented 3 years ago

I never asked for character profile js files bro.. nevermind tho, seems like you've got it

thetopfew commented 3 years ago

I never asked for character profile js files bro.. nevermind tho, seems like you've got it

Look for the character files - so if your es sorcs name was Twinks, the filename would be Twinks.d2s - somewhere in your \realm folder of d2 folder - they can then be loaded in single player mode.

grab all the files that start with your character name in that folder (although I think d2s is all I need)

as for your recent changes, I think there may be an easier way of doing it, but I'll have to look into it and let ya know if I figure it out (I havent done any kolbot stuff in ages)

Can you be clear to which files you want? If so, I can supply them no problem man! What you described, is exactly the char.js file we all know and use.

potato-T commented 3 years ago

there seems to be issues when using this with a non CTA staff.

so it seems that code is written for a staff CTA that just happens to have +ES skill. would be better for it to be separate functions. in its current state it switches to cast ES (not hard pointed) then even though weapon #1 "shiver armor" is better it still casts it with the weaker weapon #2

74Thirsty commented 2 years ago

how do i get it to stop precasting energy shield from item

thetopfew commented 2 years ago

how do i get it to stop precasting energy shield from item

Simply change this to false in step2 if you're using mine above.

In your sorceress.charactername.js, add below "// Class specific config": Config.PreCastFromSwitch = true; // added by me (see config.js & precast.js) -- this will precast t.storm, cold armors, energy shield & enchant from switch if they exist.

Pichnouf commented 2 years ago

Can the line Config.AttackSkill[0] = 58; // Preattack skill. can be modified with an idication of "slot II" somewhere? The idea is to cast ES on preattack from switch (memory staff).

thetopfew commented 2 years ago

Can the line Config.AttackSkill[0] = 58; // Preattack skill. can be modified with an idication of "slot II" somewhere? The idea is to cast ES on preattack from switch (memory staff).

Not really, the char.js is only a library of settings the bot reads for that char. In this sense, you can not just' force swap to the best slot' on this line, you need to add into prebuff.js. I mean... look at how long the BO code is... ;)

But good thought mate!