Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Team check function #1860

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 31 additions & 11 deletions d2bs/kolbot/libs/bots/MFHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -26,6 +26,9 @@ function MFHelper() {
}

if (player && name === player.name) {
if (msg.match("Position ")){
LeaderArea = msg.split("Position ")[1];
}
command = msg;
}
}
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -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;
}
}
}
}
Expand All @@ -323,4 +343,4 @@ MainLoop:
}

return true;
}
}
21 changes: 19 additions & 2 deletions d2bs/kolbot/libs/common/Attack.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ var Attack = {

if (Config.MFLeader) {
Pather.makePortal();
Pather.TeamCheck(1); //add by WhyY0416

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

your changes are annotated in git, so your name is already on these lines as far as git is concerned. You don't need these comments with your name :)

delay(1000);
say("kill " + classId);
}

Expand Down Expand Up @@ -298,6 +300,10 @@ var Attack = {
throw new Error("Failed to kill " + target.name + errorInfo);
}

if (Config.MFLeader) {
Pather.TeamCheck(2);
}

return true;
},

Expand Down Expand Up @@ -384,6 +390,8 @@ var Attack = {

if (Config.MFLeader && !!bossId) {
Pather.makePortal();
Pather.TeamCheck(1); //add by WhyY0416
delay(1000);
say("clear " + bossId);
}

Expand Down Expand Up @@ -556,6 +564,10 @@ var Attack = {
if (attackCount > 0 && pickit) {
Pickit.pickItems();
}

if (Config.MFLeader && !!bossId) {
Pather.TeamCheck(2);
}

return true;
},
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -920,6 +934,9 @@ var Attack = {
}

//this.storeStatistics(Pather.getAreaName(me.area));
if (Config.MFLeader) {
Pather.TeamCheck(2);
}

return true;
},
Expand Down Expand Up @@ -1620,4 +1637,4 @@ AuraLoop: // Skip monsters with auras

return false;
}
};
};
77 changes: 76 additions & 1 deletion d2bs/kolbot/libs/common/Pather.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Config.js holds the default Config variables that are overridden in the character config files. You can put this in both those places, and the one in Config.js will be used as a default if the character config doesn't have it

Copy link

@jmichelsen jmichelsen Jan 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

something like Config.TeamCheck.Timeout or whatever


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
Expand Down Expand Up @@ -1724,4 +1799,4 @@ MainLoop:

return areas[area];
}
};
};