-
Notifications
You must be signed in to change notification settings - Fork 331
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
Pathing improvements for walking bots #1381
base: master
Are you sure you want to change the base?
Conversation
can you submit a minimal version of this change that does not rename existing functions or move the code from one file to another so I can look at actual changes made |
this needs to be rebased, it includes other commits |
good grief sorry my master is a mess. I'll fix it |
there - fixed it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, I don't think this is a robust design, see my comments from discord:
4:35 PM] noah: I think the design is redundant, take this for example: function(x, y, retry, clearPath, pop, maneuvering)
[4:35 PM] noah: you have 3 args, clearPath, pop, and manuvering - these are all actually "node actions"
[4:35 PM] noah: i would change it to something like
[4:36 PM] noah: x, y, retry, action = false --- default argument is false, otherwise you pass an array of actions you want to do
[4:36 PM] noah: 'false' in this case would be same as maneuvering = true
[4:37 PM] noah: actions may include [clear, pop, openchest, ... ] etc
[4:38 PM] noah: this also eliminates maneuverTo
[4:44 PM] noah: also not seeing the reasoning behind this:
Chest.scan(5);
Chest.openChests();
why separate?
[5:49 PM] Chojun: because I've found that sometimes the two need to be done separately. And sometimes if a bot is maneuvering it may not want to open chests but simply take note of new ones that are discovered and open them later, there was a lot of considerations
[5:50 PM] Chojun: I actually wanted to change the arguments for moveTo but decided against it because I didn't want to make any breaking changes in case people are operating out of forks
[5:51 PM] Chojun: I wanted to start with an incremental change that modified the pathing behavior and then maybe down the road make changes on how scripts consume it
[5:52 PM] Chojun: ultimately that led me to just change the name to pathTo and add an argument (maneuvering) that just turns off node actions except for attacking
[5:53 PM] Chojun: the name change forces consumers to acknowledge that there is a behavior change and all they have to do is change the name. But this was just my train of thought on this
[5:55 PM] Chojun: because when pathing there are basically 2 goals - 1) move from point A to point B, and 2) move to a particular position to accomplish a task (like getting into position)
[5:56 PM] Chojun: you don't want your bot to run off and open a chest if its movement goal is to position itself on an arc so it can cast a spell at a monster, for example
[7:10 PM] noah: I don't see any instances where you are using them separately
[7:13 PM] noah: if it's to add APIs that can be used otherwise, that is fine, I would say rename to Attack.getChests(5) - which does not save to a global variables, and then you can have Attack.openChests() that allows you to send in an array of chests otherwise it will find them (ie the current implementation)
[7:13 PM] noah: you can do something like var blah = Attack.getChests(5); // do other stuff in scripts like kill some mob Attack.openChests(blah);
[7:36 PM] Chojun: they're used separately in 2 places from what I recall, once in Andariel script and the other time in the chest node action in pather.js
[7:38 PM] Chojun: I removed Attack.openChests() because I wanted separation of concerns. Pather opening chests and Attack opening chests was causing conflicts with pathing and was contributing to the problems that I was observing
[7:39 PM] Chojun: so I limited chest opening to pathing although the scripts can make calls to open chests if they would like
[11:07 PM] noah: That’s prob a good idea to remove from attack code
[11:09 PM] noah: In that case move it to pather.js
Implemented all requested changes |
…tes when pathing with clearpath
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems okay for the most part
code still needs to be cleaned up
also please make comments consistent like //_ <- make sure there is a space after //
and remove unnecessary newlines
return true; | ||
} | ||
|
||
var i, j, rval, | ||
tempArray = []; | ||
|
||
EnchantLoop: // Skip enchanted monsters | ||
EnchantLoop: // Skip enchanted monsters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these should not be indented
@@ -1327,7 +1290,7 @@ EnchantLoop: // Skip enchanted monsters | |||
} | |||
} | |||
|
|||
ImmuneLoop: // Skip immune monsters | |||
ImmuneLoop: // Skip immune monsters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these should not be indented
@@ -1342,7 +1305,7 @@ ImmuneLoop: // Skip immune monsters | |||
} | |||
} | |||
|
|||
AuraLoop: // Skip monsters with auras | |||
AuraLoop: // Skip monsters with auras |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these should not be indented
@@ -254,8 +254,11 @@ MainLoop: | |||
if (me.dead) { | |||
return false; | |||
} | |||
|
|||
//print("Picking item"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you clean up these comments
|
||
while (!me.idle) { | ||
//print("Pickit: Waiting"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you clean up these comments
path.reverse(); | ||
PathDebug.drawPath(path); | ||
} | ||
else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} else {
|
||
PathDebug.drawPath(path, 0x99); | ||
|
||
//print("path retry " + fail); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clean up prints
for (var i = 0; i < this.cancelFlags.length; i++) { | ||
if (getUIFlag(this.cancelFlags[i])) { | ||
me.cancel(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
newlines
@@ -310,7 +365,7 @@ var Pather = { | |||
maxRange = 5; | |||
} | |||
|
|||
MainLoop: | |||
MainLoop: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no indent here
@@ -393,7 +448,7 @@ MainLoop: | |||
attemptCount += 1; | |||
nTimer = getTickCount(); | |||
|
|||
ModeLoop: | |||
ModeLoop: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no indent here
What happened to this? :( Seemed so close. |
Primary changes:
Pather.moveTo() changed to Pather.pathTo() to account for behavior changes. PathTo() should be used when traveling long distances or when it's acceptable to open chests/shrines along the way.
Pather.maneuverTo() added to behave more closely to prior Pather.moveTo(). maneuverTo should be used if the bot should simply move from point A to B without opening chests/shrines (but clear monsters along the way if clearPath is set). Small movements should be performed with maneuverTo()
Added Chest object in Misc.js, improved chest opening behavior to prevent thrashing