Skip to content

Commit

Permalink
Safari: Fixup multiple problems
Browse files Browse the repository at this point in the history
Fixup repeat type reseting to "only-once"

The default was always set to false during Automation start-up. It's now
only set if no value was previously set.

---

Safari: Fixup deadlock in path-finding

When the following case occured:
 _ _
|x|p|
 - -
|d|e|
 - -

With: x: obstacle
      p: player
      d: first grass
      e: second grass

The automation was stuck and never moved.
The automation target order was changed to prevent this to occur.
  • Loading branch information
Farigh committed Mar 8, 2024
2 parents c36113c + 8bd3ab0 commit 46bf1ba
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/lib/Instances/Safari.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ class AutomationSafari
Automation.Utils.LocalStorage.setDefaultValue(this.Settings.CollectItems, true);
Automation.Utils.LocalStorage.setDefaultValue(this.Settings.FocusOnBaitAchievements, false);

// Set to solo run by default
Automation.Utils.LocalStorage.setDefaultValue(this.Settings.InfinitRepeat, false);

this.__internal__buildMenu();

// Disable the feature by default
Expand Down Expand Up @@ -165,9 +168,6 @@ class AutomationSafari
|*** Repeat button ***|
\**************************/

// Set to solo run by default
Automation.Utils.LocalStorage.setValue(this.Settings.InfinitRepeat, false);

const repeatButtonContainer = document.createElement("div");
repeatButtonContainer.style.display = "inline-block";
repeatButtonContainer.style.paddingRight = "10px";
Expand Down Expand Up @@ -655,16 +655,15 @@ class AutomationSafari
// Don't move if the player is still moving
if (Safari.walking || Safari.isMoving) return;

let dest;
let dest = this.__internal__safariMovesList.at(-1);
if (this.__internal__safariMovesList.length > 2)
{
dest = this.__internal__safariMovesList.at(-1);
this.__internal__safariMovesList.pop();
}
else
else if ((dest.x == Safari.playerXY.x) && (dest.y == Safari.playerXY.y))
{
// Two moves left, alternate between those until a fight pops
dest = this.__internal__safariMovesList.find(t => ((t.x != Safari.playerXY.x) || (t.y != Safari.playerXY.y)));
dest = this.__internal__safariMovesList[0];
}
this.__internal__moveToTile(dest.x, dest.y);
}
Expand Down

0 comments on commit 46bf1ba

Please sign in to comment.