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

Add red portal use in Summoner + minor fix #1419

Merged
merged 8 commits into from
Apr 11, 2019
Merged

Add red portal use in Summoner + minor fix #1419

merged 8 commits into from
Apr 11, 2019

Conversation

5noop
Copy link
Contributor

@5noop 5noop commented Apr 4, 2019

Summoner.js, Duriel.js, Loader.js

  • If Duriel script is run after Summoner, use red portal instead of going to town

Andariel.js, Duriel.js

Town.js, Pather.js

  • If bot starts in act2, use Warriv to go to act 1 instead of walking across Lut Gholein. Implemented in useWaypoint and doChores

@5noop
Copy link
Contributor Author

5noop commented Apr 5, 2019

There is one bug left with Warriv:
In single player in the first game after a profile starts, openMenu() on Warriv fails so the bot cannot move to a1 and starts walking to the waypoint when it's done trying to talk to Warriv. There is no problem in the following games or on battle.net.
Let me know if you want me to remove this feature.

@noah-
Copy link
Collaborator

noah- commented Apr 5, 2019

There is one bug left with Warriv:
In single player in the first game after a profile starts, openMenu() on Warriv fails so the bot cannot move to a1 and starts walking to the waypoint when it's done trying to talk to Warriv. There is no problem in the following games or on battle.net.
Let me know if you want me to remove this feature.

Hmm this is odd, I'll look into it. The spaces you had previously were correct, feel free to put them back.

@@ -67,13 +67,18 @@ var Town = {

// Do town chores
doChores: function (repair = false) {
var i,
cancelFlags = [0x01, 0x02, 0x04, 0x08, 0x14, 0x16, 0x0c, 0x0f, 0x19, 0x1a],
npc = getUnit(1, "warriv");
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use NPC.Warriv variable for npc name to ensure compatibility with different locales.


for (i = 0; i < 12; i += 1) {
if (me.area === targetArea || me.dead) {
break;
}

if (me.inTown) {
if (me.area === 40 && npc && getDistance(me, npc) < 50) {
Copy link
Contributor

Choose a reason for hiding this comment

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

npc isn't defined here.

} else if (me.area === 40 && npc && getDistance(me, npc) < 50) {
if (npc.openMenu()) {
Misc.useMenu(0x0D37);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

While using warriv to travel to A1 for chores may save time in common cases, it changes behavior for bots that may expect to be on current act for other tasks. Most definitely this isn't desired behavior for bots on normal difficulty because pots are lower tiered in a1.

}

if (townCheck) {
print("ÿc2Starting script: ÿc9" + i);
//scriptBroadcast(JSON.stringify({currScript: i}));
Messaging.sendToScript("tools/toolsthread.js", JSON.stringify({currScript: i}));
this.scriptIndex++;
Copy link
Collaborator

@noah- noah- Apr 6, 2019

Choose a reason for hiding this comment

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

consider the following refactor:

		for (s in Scripts) {
			if (Scripts[s]) {
				scriptList.push(s);
			}
		}

		for (this.scriptIndex = 0; this.scriptIndex < charScripts.length; this.scriptIndex++) {
			script = this.scriptList[this.scriptIndex];

			if (this.fileList.indexOf(script) < 0) {
				Misc.errorReport("ÿc1Script " + script + " doesn't exist.");
				continue;
			}

			if (!include("bots/" + script + ".js")) {
				Misc.errorReport("Failed to include script: " + script);
				continue;
			}

			if (isIncluded("bots/" + script + ".js")) {
				try {
					if (typeof (global[script]) !== "function") {
						throw new Error("Invalid script function name");
					}

					if (this.skipTown.indexOf(script) > -1 || Town.goToTown()) {
						print("ÿc2Starting script: ÿc9" + script);
						//scriptBroadcast(JSON.stringify({currScript: script}));
						Messaging.sendToScript("tools/toolsthread.js", JSON.stringify({currScript: script}));

						reconfiguration = typeof Scripts[script] === 'object';

						if (reconfiguration) {
							print("ÿc2Copying Config properties from " + script + " object.");
							this.copy(Scripts[script], Config);
						}

						global[script]();

						if (reconfiguration) {
							print("ÿc2Reverting back unmodified config properties.");
							this.copy(unmodifiedConfig, Config);
						}
					}
				} catch (error) {
					Misc.errorReport(error, script);
				}
			}
		}

change existing scriptList to fileList
move charScripts from scriptName to main function, rename charScripts to scriptList
change the loader loop from what it is to for loop using new scriptList you have created

Copy link
Contributor Author

Choose a reason for hiding this comment

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

looks good, modifications done

@noah-
Copy link
Collaborator

noah- commented Apr 8, 2019

Looks good to me. Thanks.

@noah- noah- merged commit 2ddba43 into kolton:master Apr 11, 2019
MikeKGilmore pushed a commit to MikeKGilmore/d2bot-with-kolbot that referenced this pull request Apr 13, 2019
* Summoner script now uses red portal to move to Duriel

* Change attack function in Andariel and Duriel for classic compatibility

* Use Warriv to move to act 1 if game starts in act 2

* always precast at duriel start

* Remove warriv use in doChores + revisions

* Loader refactoring

* scriptName now returns null instead of undefined
MikeKGilmore pushed a commit to MikeKGilmore/d2bot-with-kolbot that referenced this pull request Apr 14, 2019
* Summoner script now uses red portal to move to Duriel

* Change attack function in Andariel and Duriel for classic compatibility

* Use Warriv to move to act 1 if game starts in act 2

* always precast at duriel start

* Remove warriv use in doChores + revisions

* Loader refactoring

* scriptName now returns null instead of undefined
MikeKGilmore pushed a commit to MikeKGilmore/d2bot-with-kolbot that referenced this pull request Apr 14, 2019
* Summoner script now uses red portal to move to Duriel

* Change attack function in Andariel and Duriel for classic compatibility

* Use Warriv to move to act 1 if game starts in act 2

* always precast at duriel start

* Remove warriv use in doChores + revisions

* Loader refactoring

* scriptName now returns null instead of undefined
MikeKGilmore pushed a commit to MikeKGilmore/d2bot-with-kolbot that referenced this pull request Apr 15, 2019
* Summoner script now uses red portal to move to Duriel

* Change attack function in Andariel and Duriel for classic compatibility

* Use Warriv to move to act 1 if game starts in act 2

* always precast at duriel start

* Remove warriv use in doChores + revisions

* Loader refactoring

* scriptName now returns null instead of undefined
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants