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

Fix infinite loop in transport #118

Merged
merged 1 commit into from
Dec 12, 2023
Merged
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
30 changes: 16 additions & 14 deletions osr/handlers/teleports/transport.simba
Original file line number Diff line number Diff line change
Expand Up @@ -440,10 +440,10 @@ begin
end;
if Inventory.ContainsItem(fairyTeleportStaff) then
canFairyTeleport := WaitUntil(Inventory.ClickItem(fairyTeleportStaff), 500, 2000);

if not canFairyTeleport then
canFairyTeleport := WaitUntil(Equipment.ContainsItem(fairyTeleportStaff), 500, 2000);;

Self.DebugLn('Is it equipped? ' + ToString(canFairyTeleport));
if not canFairyTeleport then
begin
Expand All @@ -460,38 +460,40 @@ begin
raise "You do not have a dramen/lunar staff. You can turn off fairy teleports";
end;
until canFairyTeleport;

Self.DebugLn('Getting walkable fairy ring');
walkableFairyRing := self.getWalkableFairyRing(500);

// try to use ardy cloak if available
if (not (ToString(self.ardougneCape) = '')) and (walkableFairyRing.worldPoint = [0,0]) then
begin
Self.DebugLn('Looking for ', ToString(self.ardougneCape));
if not Equipment.ClickItem(self.ardougneCape, 'Monastery') then
if not (Inventory.Open() and Inventory.ClickItem(self.ardougneCape, 'Monastery')) then
raise "Couldn't find " + self.ardougneCape + " in inventory or equipment";

Wait(SRL.TruncatedGauss(4000, 5500));
// set fairy ring to walk to after teleporting
walkableFairyRing := self.getWalkableFairyRing(500);
end;

// walk to nearest fairy ring
if (walkableFairyRing.worldPoint = [0,0]) then
raise 'Fairy ring ' + walkableFairyRing.destination + ' is not configured properly';

Self.DebugLn('We are going to walk to ' + ToString(walkableFairyRing.worldPoint));
ScriptWalker^.WebWalk(walkableFairyRing.worldPoint, 40);

// open fairy ring teleports
Self.DebugLn("opening fairy ring teleports");
repeat
repeat
Mouse.Move(findFairyRingMiddle(walkableFairyRing));
if not MainScreen.IsUpText("y ring") then
Antiban.RandomRotate();
until MainScreen.IsUpText("y ring");
until MainScreen.IsUpText("y ring") or (travelLogOpen := (SRL.FindColors(redTextPoints, redTextColors, travelLog) > 1));
if travelLogOpen then
Break;
Mouse.click(MOUSE_RIGHT);
Self.DebugLn('Selecting configure or previous ring');
// handle zanaris cause it's weird
Expand All @@ -501,14 +503,14 @@ begin
for fairyRingChooseOption in ChooseOption.GetOptions() do
if Between('(',')', fairyRingChooseOption.Text) = teleportLocation.destination.Replace(' ', '') then
usedChooseOptionTeleport := ChooseOption.Select(fairyRingChooseOption.Text);

if not usedChooseOptionTeleport then
ChooseOption.Select('Configure', MOUSE_LEFT);

Wait(SRL.TruncatedGauss(3000, 4500));
travelLogOpen := (SRL.FindColors(redTextPoints, redTextColors, travelLog) > 1);
until travelLogOpen or usedChooseOptionTeleport;

if not usedChooseOptionTeleport then
begin
Self.DebugLn('Scrolling to top of fairy rings');
Expand All @@ -531,10 +533,10 @@ begin
Mouse.move(fairyCodeTextBox);
until MainScreen.IsUpText(teleportLocation.destination) or (codeFindAttempt > 3);
until foundCode;

// click the given teleport in travel log
Mouse.click(fairyCodeTextBox, MOUSE_LEFT);

// click the confirm teleport in middle of screen
Mouse.move(self.getFairyDialTeleportBox());
WaitUntil(MainScreen.IsUpText("Confirm"), 200, 5000);
Expand Down
Loading