From 24d2155a020419204d45cd16a0394119eb264bdb Mon Sep 17 00:00:00 2001 From: monstar2 Date: Thu, 14 Mar 2019 15:28:08 -0700 Subject: [PATCH 1/2] sorceress telestomp fix --- d2bs/kolbot/libs/common/Attack.js | 15 ++++++++++----- d2bs/kolbot/libs/common/Attacks/Sorceress.js | 14 +++++++++++++- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/d2bs/kolbot/libs/common/Attack.js b/d2bs/kolbot/libs/common/Attack.js index c4138b8e6..075744fee 100644 --- a/d2bs/kolbot/libs/common/Attack.js +++ b/d2bs/kolbot/libs/common/Attack.js @@ -458,6 +458,9 @@ var Attack = { } } while (target.getNext()); } + + //possible to move sort here so we sort once? + monsterList.sort(sortfunc); while (start && monsterList.length > 0 && attackCount < 300) { if (boss) { @@ -469,12 +472,14 @@ var Attack = { return false; } - //monsterList.sort(Sort.units); - monsterList.sort(sortfunc); - target = copyUnit(monsterList[0]); - - if (target.x !== undefined && (getDistance(target, orgx, orgy) <= range || (this.getScarinessLevel(target) > 7 && getDistance(me, target) <= range)) && this.checkMonster(target)) { + + if (result == -1) { + //if we reached here, it means there was a mob around the telestomp target + monsterList.shift(); + //shift and reappend the target at end, telestomp after we have killed other monsters in list + monsterList.push(target); + } else if (target.x !== undefined && (getDistance(target, orgx, orgy) <= range || (this.getScarinessLevel(target) > 7 && getDistance(me, target) <= range)) && this.checkMonster(target)) { if (Config.Dodge && me.hp * 100 / me.hpmax <= Config.DodgeHP) { this.deploy(target, Config.DodgeRange, 5, 9); } diff --git a/d2bs/kolbot/libs/common/Attacks/Sorceress.js b/d2bs/kolbot/libs/common/Attacks/Sorceress.js index 58245bd18..f13010065 100644 --- a/d2bs/kolbot/libs/common/Attacks/Sorceress.js +++ b/d2bs/kolbot/libs/common/Attacks/Sorceress.js @@ -111,7 +111,19 @@ var ClassAttack = { } result = this.doCast(unit, timedSkill, untimedSkill); - + + //build the list and count the monsters + var monList = Attack.buildMonsterList(); + //is sorting strictly required? + var sortfunc = Attack.sortMonsters; + monList.sort(sortfunc); + var monCount = Attack.getMonsterCount(me.x, me.y, 15, monList); + //if there are 3 or more monsters in the area around me, I won't telestomp + if(monCount > 2 && Config.TeleStomp) { + return -1; + } + + //now thare are only 2 monsters, we think it's safe to telestomp if (result === 2 && Config.TeleStomp && Attack.checkResist(unit, "physical") && !!me.getMerc() && Attack.validSpot(unit.x, unit.y)) { while (Attack.checkMonster(unit)) { if (Town.needMerc()) { From 88c9975225fe0b1751e1e0fe3b26c9702732d812 Mon Sep 17 00:00:00 2001 From: monstar2 Date: Thu, 14 Mar 2019 15:45:13 -0700 Subject: [PATCH 2/2] fixed error in last commit --- d2bs/kolbot/libs/common/Attack.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/d2bs/kolbot/libs/common/Attack.js b/d2bs/kolbot/libs/common/Attack.js index 075744fee..b3fdc02cb 100644 --- a/d2bs/kolbot/libs/common/Attack.js +++ b/d2bs/kolbot/libs/common/Attack.js @@ -474,12 +474,7 @@ var Attack = { target = copyUnit(monsterList[0]); - if (result == -1) { - //if we reached here, it means there was a mob around the telestomp target - monsterList.shift(); - //shift and reappend the target at end, telestomp after we have killed other monsters in list - monsterList.push(target); - } else if (target.x !== undefined && (getDistance(target, orgx, orgy) <= range || (this.getScarinessLevel(target) > 7 && getDistance(me, target) <= range)) && this.checkMonster(target)) { + if (target.x !== undefined && (getDistance(target, orgx, orgy) <= range || (this.getScarinessLevel(target) > 7 && getDistance(me, target) <= range)) && this.checkMonster(target)) { if (Config.Dodge && me.hp * 100 / me.hpmax <= Config.DodgeHP) { this.deploy(target, Config.DodgeRange, 5, 9); } @@ -488,8 +483,13 @@ var Attack = { //me.overhead("attacking " + target.name + " spectype " + target.spectype + " id " + target.classid); result = ClassAttack.doAttack(target, attackCount % 15 === 0); - - if (result) { + + if (result == -1) { + //if we reached here, it means there was a mob around the telestomp target + monsterList.shift(); + //shift and reappend the target at end, telestomp after we have killed other monsters in list + monsterList.push(target); + } else if (result) { retry = 0; if (result === 2) {