diff --git a/d2bs/kolbot/libs/bots/MFHelper.js b/d2bs/kolbot/libs/bots/MFHelper.js index e59b5aabf..44e07495d 100644 --- a/d2bs/kolbot/libs/bots/MFHelper.js +++ b/d2bs/kolbot/libs/bots/MFHelper.js @@ -5,14 +5,14 @@ */ function MFHelper() { - var i, player, playerAct, split, + var i, player, playerAct, split, LeaderArea, oldCommand = "", command = ""; function ChatEvent(name, msg) { if (!player) { var i, - match = ["kill", "clearlevel", "clear", "quit", "cows", "council"]; + match = ["kill", "clearlevel", "clear", "quit", "cows", "council", "TeamCheck","FinishCheck"]; if (msg) { for (i = 0; i < match.length; i += 1) { @@ -26,6 +26,9 @@ function MFHelper() { } if (player && name === player.name) { + if (msg.match("Position ")){ + LeaderArea = msg.split("Position ")[1]; + } command = msg; } } @@ -184,8 +187,9 @@ MainLoop: split = command.split("kill ")[1]; - for (i = 0; i < 5; i += 1) { - if (Pather.usePortal(player.area, player.name)) { + for (i = 0; i < 30; i += 1) { + if (Pather.usePortal(LeaderArea, player.name)) { + delay(500); break; } @@ -217,8 +221,9 @@ MainLoop: } else if (command.indexOf("clearlevel") > -1) { print("ÿc4MFHelperÿc0: Clear Level"); - for (i = 0; i < 5; i += 1) { - if (Pather.usePortal(player.area, player.name)) { + for (i = 0; i < 30; i += 1) { + if (Pather.usePortal(LeaderArea, player.name)) { + delay(500); break; } @@ -241,8 +246,9 @@ MainLoop: split = command.split("clear ")[1]; - for (i = 0; i < 5; i += 1) { - if (Pather.usePortal(player.area, player.name)) { + for (i = 0; i < 30; i += 1) { + if (Pather.usePortal(LeaderArea, player.name)) { + delay(500); break; } @@ -275,8 +281,9 @@ MainLoop: } else if (command.indexOf("cows") > -1) { print("ÿc4MFHelperÿc0: Clear Cows"); - for (i = 0; i < 5; i += 1) { + for (i = 0; i < 30; i += 1) { if (Town.goToTown(1) && Pather.usePortal(39)) { + delay(500); break; } @@ -297,8 +304,9 @@ MainLoop: } else if (command.indexOf("council") > -1) { print("ÿc4MFHelperÿc0: Kill Council"); - for (i = 0; i < 5; i += 1) { + for (i = 0; i < 30; i += 1) { if (Pather.usePortal(player.area, player.name)) { + delay(500); break; } @@ -315,6 +323,18 @@ MainLoop: } else { print("Failed to use portal."); } + } else if (command.indexOf("TeamCheck") > -1 ) { + say("Ready"); + delay(1000); + if (!me.inTown){ + Town.goToTown; + } + } else if (command.indexOf("FinishCheck") > -1){ + say("Finished"); + delay(1000); + if (!me.inTown){ + Town.goToTown; + } } } } @@ -323,4 +343,4 @@ MainLoop: } return true; -} \ No newline at end of file +} diff --git a/d2bs/kolbot/libs/common/Attack.js b/d2bs/kolbot/libs/common/Attack.js index c4138b8e6..4eaef0de5 100644 --- a/d2bs/kolbot/libs/common/Attack.js +++ b/d2bs/kolbot/libs/common/Attack.js @@ -233,6 +233,8 @@ var Attack = { if (Config.MFLeader) { Pather.makePortal(); + Pather.TeamCheck(1); //add by WhyY0416 + delay(1000); say("kill " + classId); } @@ -298,6 +300,10 @@ var Attack = { throw new Error("Failed to kill " + target.name + errorInfo); } + if (Config.MFLeader) { + Pather.TeamCheck(2); + } + return true; }, @@ -384,6 +390,8 @@ var Attack = { if (Config.MFLeader && !!bossId) { Pather.makePortal(); + Pather.TeamCheck(1); //add by WhyY0416 + delay(1000); say("clear " + bossId); } @@ -556,6 +564,10 @@ var Attack = { if (attackCount > 0 && pickit) { Pickit.pickItems(); } + + if (Config.MFLeader && !!bossId) { + Pather.TeamCheck(2); + } return true; }, @@ -858,7 +870,9 @@ var Attack = { clearLevel: function (spectype) { if (Config.MFLeader) { Pather.makePortal(); - say("clearlevel " + getArea().name); + Pather.TeamCheck(1); //add by WhyY0416 + delay(1000); + say("clearlevel"); //dhd enable unique name for tombs } var room, result, rooms, myRoom, currentArea, previousArea; @@ -920,6 +934,9 @@ var Attack = { } //this.storeStatistics(Pather.getAreaName(me.area)); + if (Config.MFLeader) { + Pather.TeamCheck(2); + } return true; }, @@ -1620,4 +1637,4 @@ AuraLoop: // Skip monsters with auras return false; } -}; \ No newline at end of file +}; diff --git a/d2bs/kolbot/libs/common/Pather.js b/d2bs/kolbot/libs/common/Pather.js index f9514dea0..ebff056b4 100644 --- a/d2bs/kolbot/libs/common/Pather.js +++ b/d2bs/kolbot/libs/common/Pather.js @@ -1578,6 +1578,81 @@ MainLoop: return true; }, + /* + Pather.TeamCheck(); + Make Leader communication to others. Add by WhyY0416 + */ + TeamCheck: function (phase) { + var MemberCount = 0, + Member = [], + timeOut = 600; //How to put this in character's config ? + + function ChatEvent(name,msg) { + if (me.name !== name){ + var i, command, + match = ["Ready","Finished"]; + + if (msg) { + for (i = 0; i < match.length; i += 1) { + if (msg.match(match[i])) { + if(Member.indexOf(name) > -1){ + continue; + } + else{ + Member.push(name); + break; + } + } + } + } + } + } + + addEventListener("chatmsg", ChatEvent); + + if (me.area === 108){ //Diablo Script. + return true; + } + + if (MemberCount === 0){ //Except MFLeader!!! + var party = getParty(); + do { + if (party.name !== me.name){ + MemberCount += 1; + } + } + while (party.getNext()); + if (!party){ //single playermode. + return true; + } + } + + if (phase === 1){ + say("Position " + getArea().id); + delay(1000); + } + + +MainLoop: + while (timeOut > 0){ + if (Member.length === MemberCount){ + break MainLoop; + } + if (timeOut % 5 === 0){ + if (phase === 1){ + say("TeamCheck"); + } + else if (phase === 2){ + say("FinishCheck"); + } + } + timeOut -= 1; + delay(1000); + } + Member.length = 0; + return true; + }, + /* Pather.getAreaName(area); area - id of the area to get the name for @@ -1724,4 +1799,4 @@ MainLoop: return areas[area]; } -}; \ No newline at end of file +};