-
Notifications
You must be signed in to change notification settings - Fork 332
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
MFHelper refactoring. #1188
base: master
Are you sure you want to change the base?
MFHelper refactoring. #1188
Conversation
// if, at worst case, the portal leads to wrong area, the command will not be executed and helper will go back to town at next loop. | ||
delay(me.ping); | ||
Pather.usePortal(null, player.name) | ||
while (!me.area) { |
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.
this is not needed, usePortal already checks for area change, use the retry method as in the original version
also there is no reason not to check the area since the info is available
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.
usePortal creates delay if we pass in the leader area, this makes the helper wait some seconds not taking the tp, which may be too late when the leader area is refreshed in the next loop pass. This is because leader area returns the previous one, not the current one where the portal has just been made due to refresh delay. This is the main fix of this PR.
but you are right for the while check, this is already done in usePortal
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.
investigate the source of the delay in usePortal, area check should not cause any significant delay
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.
That is not usPortal that makes delay. Not explicitly at least.
This is player.area which returns the previous area when tp appears.
For example, leader runs pit.
Teleport to pit level 1, area = x-1.
Teleport to pit level 2, area = x.
Make tp, send command.
Helper receive command, check leader’s area. Here is the problem.
Leader’s area returns x-1, not refreshed.
usePortal(x-1, leader)
will delay failing retrying to use portal because there is no portal to x-1, but x. (for loop of 10*(200+me.ping) between 2 and 4 seconds delay, not so important for area clearing, but for boss killing 4 seconds is too late)
Wait for the next helper loop pass where leader’s area now correctly returns x.
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.
By using usePortal(null, leader)
we don’t check failable area, and works better because the command is sent just after making a tp, so the tp is obviously the right area. And we check area if (me.area == leader.area)
after taking portal so leader.area has time to be refreshed, while taking tp.
print("Failed to use portal."); | ||
// common for all commands, go back to town after executing command. | ||
delay(1000); | ||
if (!Pather.usePortal(null, player.name)) { |
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.
add new line before this line
if (Town.goToTown(1) && Pather.usePortal(39)) { | ||
break; | ||
if (me.area != 39) { | ||
Town.goToTown(1); |
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.
retain the retry structure, there is no guarantee that the cow portal will be near stash so this check doesn't make much sense
also this part of the code won't work properly because you would have taken the players tp, the area check would avoid this redundancy
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.
yeah I forget to move cows outside
the else if cows
would be for the if (me.area === player.area)
if we failed to take leader tp (baal not done can't use player tp to cows), try to take the red portal as before
// Go to town if I'm not fighting with leader anymore. | ||
// This may happens with kurast temples script for example, where leader changes temples without going to town. | ||
if (player.area != me.area) { | ||
if (!me.inTown && !Pather.usePortal(null, player.name)) { |
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.
combine these if statements
} | ||
Town.move("portalspot"); |
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.
add newline above this
Guys I've been working through issues with I run a paladin and barb as classic hc mfhelpers with a sorc leader and, interestingly, the barb and paladin do not always mirror one another. Many area conflicts:
Mfehelper is set to use If the leader could send new command like "pause command" where the mfhelper would return to town, and then "unpause command" where the leader returns to tp then opens new tp and the follower jumps through and executes the last command (or incase of recent rejoin, the leader could just issue the same command but with the pause/unpause keyword). Precast in town: mfhlpers follow bot to acts when it switches to buy pots - I/we modified |
Refactored duplicate code.
Really want to thank Ryancrunchi and anyone else who worked on this much improved script, it runs so smoothly, bots no longer sit around waiting to enter portals. awesome job guys love this script now it's blazing fast. |
Refactored MFHelper to avoid
usePortal
failures and delays for helper to join leader.Refactored common duplicate code before and after commands.