Skip to content

Commit

Permalink
fix: Merge pull request #131 from MilesWilde/master
Browse files Browse the repository at this point in the history
Replace fairy ring logic
  • Loading branch information
Torwent authored Feb 5, 2024
2 parents 8fec012 + f3e74a7 commit c42480c
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 261 deletions.
96 changes: 48 additions & 48 deletions optional/handlers/teleports/rsteleports.simba
Original file line number Diff line number Diff line change
Expand Up @@ -288,54 +288,54 @@ begin
RSTeleports.KARAMJA_GLOVES_GEM_MINE := setupTeleportLocation(ETeleportType.DIARY_ITEM, "Karamja Gloves", "Gem Mine", [3700, 5540]);
RSTeleports.KARAMJA_GLOVES_DURADEL := setupTeleportLocation(ETeleportType.DIARY_ITEM, "Karamja Gloves", "Duradel", []);
RSTeleports.FALADOR_FARM_PATCH := setupTeleportLocation(ETeleportType.DIARY_ITEM, "Explorer's Ring", "Teleport", [7608, 3288]);
RSTeleports.AIQ_MUDSKIPPER_POINT := setupTeleportLocation(ETeleportType.FAIRY_RING, "A I Q", [7378, 3992]);
RSTeleports.AIR_ISLAND_SOUTHEAST_OF_ARDOUGNE := setupTeleportLocation(ETeleportType.FAIRY_RING, "A I R", [6194, 3460]);
RSTeleports.AJQ_CAVE_SOUTH_OF_DORGESHKAAN := setupTeleportLocation(ETeleportType.FAIRY_RING, "A J Q", [3360, 698]);
RSTeleports.AJR_SLAYER_CAVE := setupTeleportLocation(ETeleportType.FAIRY_RING, "A J R", [6514, 1996]);
RSTeleports.AJS_PENGUINS_NEAR_MISCELLANIA := setupTeleportLocation(ETeleportType.FAIRY_RING, "A J S", [6502, 5130]);
RSTeleports.AKP_NECROPOLIS := setupTeleportLocation(ETeleportType.FAIRY_RING, "A K P", [8530, 5622]);
RSTeleports.AKQ_PISCATORIS_HUNTER_AREA := setupTeleportLocation(ETeleportType.FAIRY_RING, "A K Q", [4670, 1972]);
RSTeleports.AKS_FELDIP_HUNTER_AREA := setupTeleportLocation(ETeleportType.FAIRY_RING, "A K S", [5678, 4624]);
RSTeleports.ALP_ISLAND_LIGHTHOUSE := setupTeleportLocation(ETeleportType.FAIRY_RING, "A L P", [5406, 1902]);
RSTeleports.ALQ_HAUNTED_WOODS_EAST_OF_CANIFIS := setupTeleportLocation(ETeleportType.FAIRY_RING, "A L Q", [9782, 2468]);
RSTeleports.ALR_ABYSSAL_AREA := setupTeleportLocation(ETeleportType.FAIRY_RING, "A L R", [10228, 4660]);
RSTeleports.ALS_MCGRUBORS_WOOD := setupTeleportLocation(ETeleportType.FAIRY_RING, "A L S", [5970, 2468]);
RSTeleports.BIP_ISLAND_SOUTHWEST_OF_MORT_MYRE := setupTeleportLocation(ETeleportType.FAIRY_RING, "B I P", [9034, 3152]);
RSTeleports.BIQ_KALPHITE_HIVE := setupTeleportLocation(ETeleportType.FAIRY_RING, "B I Q", [8398, 4068]);
RSTeleports.BIS_ARDOUGNE_ZOO_UNICORNS := setupTeleportLocation(ETeleportType.FAIRY_RING, "B I S", [5932, 3384], False);
RSTeleports.BJP_ISLAND_ISLE_OF_SOULS := setupTeleportLocation(ETeleportType.FAIRY_RING, "B J P", [4816, 4536]);
RSTeleports.BJR_REALM_OF_THE_FISHER_KING := setupTeleportLocation(ETeleportType.FAIRY_RING, "B J R", [7764, 2650]);
RSTeleports.BJS_ISLAND_NEAR_ZULANDRA := setupTeleportLocation(ETeleportType.FAIRY_RING, "B J S", [3994, 4166]);
RSTeleports.BKP_SOUTH_OF_CASTLE_WARS := setupTeleportLocation(ETeleportType.FAIRY_RING, "B K P", [4934, 4308]);
RSTeleports.BKQ_ENCHANTED_VALLEY := setupTeleportLocation(ETeleportType.FAIRY_RING, "B K Q", [4120, 214]);
RSTeleports.BKR_MORT_MYRE_SWAMP_SOUTH_OF_CANIFIS := setupTeleportLocation(ETeleportType.FAIRY_RING, "B K R", [9268, 2724]);
RSTeleports.BKS_ZANARIS := setupTeleportLocation(ETeleportType.FAIRY_RING, "B K S", [10150, 4090]);
RSTeleports.BLP_TZHAAR_AREA := setupTeleportLocation(ETeleportType.FAIRY_RING, "B L P", [4654, 632]);
RSTeleports.BLQ_YUBIUSK := setupTeleportLocation(ETeleportType.FAIRY_RING, "B L Q", [0,0]);
RSTeleports.BLR_LEGENDS_GUILD := setupTeleportLocation(ETeleportType.FAIRY_RING, "B L R", [6354, 3044]);
RSTeleports.CIP_ISLAND_MISCELLANIA := setupTeleportLocation(ETeleportType.FAIRY_RING, "C I P", [6554, 5178]);
RSTeleports.CIQ_NORTHWEST_OF_YANILLE := setupTeleportLocation(ETeleportType.FAIRY_RING, "C I Q", [5506, 3940]);
RSTeleports.CIS_NORTH_OF_THE_ARCEUUS_LIBRARY := setupTeleportLocation(ETeleportType.FAIRY_RING, "C I S", [1950, 986]);
RSTeleports.CIR_NORTHEAST_OF_THE_FARMING_GUILD := setupTeleportLocation(ETeleportType.FAIRY_RING, "C I R", [602, 1412]);
RSTeleports.CJR_SINCLAIR_MANSION := setupTeleportLocation(ETeleportType.FAIRY_RING, "C J R", [6214, 2144]);
RSTeleports.CKP_COSMIC_ENTITYS_PLANE := setupTeleportLocation(ETeleportType.FAIRY_RING, "C K P", [9802, 400]);
RSTeleports.CKR_SOUTH_OF_TAI_BWO_WANNAI_VILLAGE := setupTeleportLocation(ETeleportType.FAIRY_RING, "C K R", [6598, 4436]);
RSTeleports.CKS_CANIFIS := setupTeleportLocation(ETeleportType.FAIRY_RING, "C K S", [9182, 2568]);
RSTeleports.CLP_ISLAND_SOUTH_OF_DRAYNOR_VILLAGE := setupTeleportLocation(ETeleportType.FAIRY_RING, "C L P", [7722, 3624]);
RSTeleports.CLR_ISLAND_APE_ATOLL := setupTeleportLocation(ETeleportType.FAIRY_RING, "C L R", [6096, 5210]);
RSTeleports.CLS_ISLAND_HAZELMERES_HOME := setupTeleportLocation(ETeleportType.FAIRY_RING, "C L S", [6120, 4124]);
RSTeleports.DIP_SIRE_BOSS_ABYSSAL_NEXUS := setupTeleportLocation(ETeleportType.FAIRY_RING, "D I P", [10142, 5106]);
RSTeleports.DIR_GORAKS_PLANE := setupTeleportLocation(ETeleportType.FAIRY_RING, "D I R", [3320, 3916]);
RSTeleports.DIQ_PLAYEROWNED_HOUSE := setupTeleportLocation(ETeleportType.FAIRY_RING, "D I Q", [0,0]);
RSTeleports.DIS_WIZARDS_TOWER := setupTeleportLocation(ETeleportType.FAIRY_RING, "D I S", [7824, 3852]);
RSTeleports.DJP_TOWER_OF_LIFE := setupTeleportLocation(ETeleportType.FAIRY_RING, "D J P", [6026, 3528]);
RSTeleports.DJR_CHASM_OF_FIRE := setupTeleportLocation(ETeleportType.FAIRY_RING, "D J R", [1214, 1828]);
RSTeleports.DKP_SOUTH_OF_MUSA_POINT := setupTeleportLocation(ETeleportType.FAIRY_RING, "D K P", [6994, 4004]);
RSTeleports.DKR_EDGEVILLE_GRAND_EXCHANGE := setupTeleportLocation(ETeleportType.FAIRY_RING, "D K R", [7910, 2464]);
RSTeleports.DKS_POLAR_HUNTER_AREA := setupTeleportLocation(ETeleportType.FAIRY_RING, "D K S", [6370, 1572]);
RSTeleports.DLQ_NORTH_OF_NARDAH := setupTeleportLocation(ETeleportType.FAIRY_RING, "D L Q", [9086, 4384]);
RSTeleports.DLR_ISLAND_POISON_WASTE_SOUTH_OF_ISAFDAR := setupTeleportLocation(ETeleportType.FAIRY_RING, "D L R", [4246, 4052]);
RSTeleports.DLS_MYREQUE_HIDEOUT_UNDER_THE_HOLLOWS := setupTeleportLocation(ETeleportType.FAIRY_RING, "D L S", [1424, 5140]);
RSTeleports.AIQ_MUDSKIPPER_POINT := setupTeleportLocation(ETeleportType.FAIRY_RING, "AIQ", [7378, 3992]);
RSTeleports.AIR_ISLAND_SOUTHEAST_OF_ARDOUGNE := setupTeleportLocation(ETeleportType.FAIRY_RING, "AIR", [6194, 3460]);
RSTeleports.AJQ_CAVE_SOUTH_OF_DORGESHKAAN := setupTeleportLocation(ETeleportType.FAIRY_RING, "AJQ", [3360, 698]);
RSTeleports.AJR_SLAYER_CAVE := setupTeleportLocation(ETeleportType.FAIRY_RING, "AJR", [6514, 1996]);
RSTeleports.AJS_PENGUINS_NEAR_MISCELLANIA := setupTeleportLocation(ETeleportType.FAIRY_RING, "AJS", [6502, 5130]);
RSTeleports.AKP_NECROPOLIS := setupTeleportLocation(ETeleportType.FAIRY_RING, "AKP", [8530, 5622]);
RSTeleports.AKQ_PISCATORIS_HUNTER_AREA := setupTeleportLocation(ETeleportType.FAIRY_RING, "AKQ", [4670, 1972]);
RSTeleports.AKS_FELDIP_HUNTER_AREA := setupTeleportLocation(ETeleportType.FAIRY_RING, "AKS", [5678, 4624]);
RSTeleports.ALP_ISLAND_LIGHTHOUSE := setupTeleportLocation(ETeleportType.FAIRY_RING, "ALP", [5406, 1902]);
RSTeleports.ALQ_HAUNTED_WOODS_EAST_OF_CANIFIS := setupTeleportLocation(ETeleportType.FAIRY_RING, "ALQ", [9782, 2468]);
RSTeleports.ALR_ABYSSAL_AREA := setupTeleportLocation(ETeleportType.FAIRY_RING, "ALR", [10228, 4660]);
RSTeleports.ALS_MCGRUBORS_WOOD := setupTeleportLocation(ETeleportType.FAIRY_RING, "ALS", [5970, 2468]);
RSTeleports.BIP_ISLAND_SOUTHWEST_OF_MORT_MYRE := setupTeleportLocation(ETeleportType.FAIRY_RING, "BIP", [9034, 3152]);
RSTeleports.BIQ_KALPHITE_HIVE := setupTeleportLocation(ETeleportType.FAIRY_RING, "BIQ", [8398, 4068]);
RSTeleports.BIS_ARDOUGNE_ZOO_UNICORNS := setupTeleportLocation(ETeleportType.FAIRY_RING, "BIS", [5932, 3384], False);
RSTeleports.BJP_ISLAND_ISLE_OF_SOULS := setupTeleportLocation(ETeleportType.FAIRY_RING, "BJP", [4816, 4536]);
RSTeleports.BJR_REALM_OF_THE_FISHER_KING := setupTeleportLocation(ETeleportType.FAIRY_RING, "BJR", [7764, 2650]);
RSTeleports.BJS_ISLAND_NEAR_ZULANDRA := setupTeleportLocation(ETeleportType.FAIRY_RING, "BJS", [3994, 4166]);
RSTeleports.BKP_SOUTH_OF_CASTLE_WARS := setupTeleportLocation(ETeleportType.FAIRY_RING, "BKP", [4934, 4308]);
RSTeleports.BKQ_ENCHANTED_VALLEY := setupTeleportLocation(ETeleportType.FAIRY_RING, "BKQ", [4120, 214]);
RSTeleports.BKR_MORT_MYRE_SWAMP_SOUTH_OF_CANIFIS := setupTeleportLocation(ETeleportType.FAIRY_RING, "BKR", [9268, 2724]);
RSTeleports.BKS_ZANARIS := setupTeleportLocation(ETeleportType.FAIRY_RING, "BKS", [10150, 4090]);
RSTeleports.BLP_TZHAAR_AREA := setupTeleportLocation(ETeleportType.FAIRY_RING, "BLP", [4654, 632]);
RSTeleports.BLQ_YUBIUSK := setupTeleportLocation(ETeleportType.FAIRY_RING, "BLQ", [0,0]);
RSTeleports.BLR_LEGENDS_GUILD := setupTeleportLocation(ETeleportType.FAIRY_RING, "BLR", [6354, 3044]);
RSTeleports.CIP_ISLAND_MISCELLANIA := setupTeleportLocation(ETeleportType.FAIRY_RING, "CIP", [6554, 5178]);
RSTeleports.CIQ_NORTHWEST_OF_YANILLE := setupTeleportLocation(ETeleportType.FAIRY_RING, "CIQ", [5506, 3940]);
RSTeleports.CIS_NORTH_OF_THE_ARCEUUS_LIBRARY := setupTeleportLocation(ETeleportType.FAIRY_RING, "CIS", [1950, 986]);
RSTeleports.CIR_NORTHEAST_OF_THE_FARMING_GUILD := setupTeleportLocation(ETeleportType.FAIRY_RING, "CIR", [602, 1412]);
RSTeleports.CJR_SINCLAIR_MANSION := setupTeleportLocation(ETeleportType.FAIRY_RING, "CJR", [6214, 2144]);
RSTeleports.CKP_COSMIC_ENTITYS_PLANE := setupTeleportLocation(ETeleportType.FAIRY_RING, "CKP", [9802, 400]);
RSTeleports.CKR_SOUTH_OF_TAI_BWO_WANNAI_VILLAGE := setupTeleportLocation(ETeleportType.FAIRY_RING, "CKR", [6598, 4436]);
RSTeleports.CKS_CANIFIS := setupTeleportLocation(ETeleportType.FAIRY_RING, "CKS", [9182, 2568]);
RSTeleports.CLP_ISLAND_SOUTH_OF_DRAYNOR_VILLAGE := setupTeleportLocation(ETeleportType.FAIRY_RING, "CLP", [7722, 3624]);
RSTeleports.CLR_ISLAND_APE_ATOLL := setupTeleportLocation(ETeleportType.FAIRY_RING, "CLR", [6096, 5210]);
RSTeleports.CLS_ISLAND_HAZELMERES_HOME := setupTeleportLocation(ETeleportType.FAIRY_RING, "CLS", [6120, 4124]);
RSTeleports.DIP_SIRE_BOSS_ABYSSAL_NEXUS := setupTeleportLocation(ETeleportType.FAIRY_RING, "DIP", [10142, 5106]);
RSTeleports.DIR_GORAKS_PLANE := setupTeleportLocation(ETeleportType.FAIRY_RING, "DIR", [3320, 3916]);
RSTeleports.DIQ_PLAYEROWNED_HOUSE := setupTeleportLocation(ETeleportType.FAIRY_RING, "DIQ", [0,0]);
RSTeleports.DIS_WIZARDS_TOWER := setupTeleportLocation(ETeleportType.FAIRY_RING, "DIS", [7824, 3852]);
RSTeleports.DJP_TOWER_OF_LIFE := setupTeleportLocation(ETeleportType.FAIRY_RING, "DJP", [6026, 3528]);
RSTeleports.DJR_CHASM_OF_FIRE := setupTeleportLocation(ETeleportType.FAIRY_RING, "DJR", [1214, 1828]);
RSTeleports.DKP_SOUTH_OF_MUSA_POINT := setupTeleportLocation(ETeleportType.FAIRY_RING, "DKP", [6994, 4004]);
RSTeleports.DKR_EDGEVILLE_GRAND_EXCHANGE := setupTeleportLocation(ETeleportType.FAIRY_RING, "DKR", [7910, 2464]);
RSTeleports.DKS_POLAR_HUNTER_AREA := setupTeleportLocation(ETeleportType.FAIRY_RING, "DKS", [6370, 1572]);
RSTeleports.DLQ_NORTH_OF_NARDAH := setupTeleportLocation(ETeleportType.FAIRY_RING, "DLQ", [9086, 4384]);
RSTeleports.DLR_ISLAND_POISON_WASTE_SOUTH_OF_ISAFDAR := setupTeleportLocation(ETeleportType.FAIRY_RING, "DLR", [4246, 4052]);
RSTeleports.DLS_MYREQUE_HIDEOUT_UNDER_THE_HOLLOWS := setupTeleportLocation(ETeleportType.FAIRY_RING, "DLS", [1424, 5140]);
RSTeleports.RSTeleportsArray := [
RSTeleports.VARROCK,
RSTeleports.LUMBRIDGE,
Expand Down
219 changes: 6 additions & 213 deletions optional/handlers/teleports/transport.simba
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@ type
fairyTeleportItem: EFairyTeleportItem;
end;

procedure TUniversalTransport.Init(fairyTeleportItem: EFairyTeleportItem; ardougneCape: TRSItem); overload;
begin
Self.Name := 'UniversalTransport';
self.fairyTeleportItem := fairyTeleportItem;
self.ardougneCape := ardougneCape;
end;


function TUniversalTransport.pathLength(path: TPointArray): Int32;
var
total: Double;
Expand Down Expand Up @@ -347,214 +339,16 @@ begin
Exit(True);
end;

function TUniversalTransport.findFairyRingMiddle(fairyRing: TTeleportLocation): TPoint;
var
fairyRingGreen: TCTS2Color := CTS2(4089424, 10, 0.14, 0.19);
fairyRingBrown: TCTS2Color := CTS2(4807548, 17, 0.07, 0.21);
fairyRingButterflyWhite: TCTS2Color := CTS2(14476264, 4, 0.36, 0.64);
brownTPA: TPointArray;
greenTPA: TPointArray;
butteryflyTPA: TPointArray;
searchBox: TBox := Mainscreen.Bounds();
nearbyColorPoints: TPointArray;
begin
SRL.FindColors(greenTPA, fairyRingGreen, searchBox);
SRL.FindColors(brownTPA, fairyRingBrown, searchBox);
nearbyColorPoints := brownTPA.Grow(2).PointsInRangeOf(greenTPA.Grow(2), 1, 10);
if (Length(nearbyColorPoints) > 0) then
Exit(nearbyColorPoints.Grow(50).Erode(30).MinAreaCircle().mean());

SRL.FindColors(butteryflyTPA, fairyRingButterflyWhite, searchBox);
if (Length(butteryflyTPA) > 0) then
Exit(butteryflyTPA.RandomValue());

Exit(ScriptWalker^.GetTileMS(fairyRing.worldPoint).mean());
end;

function TUniversalTransport.getFairyDialTeleportBox(): TBox;
var
teleportBox: TBox;
attempt: Int32;
begin
for attempt in [1..5] do
begin
OCR.LocateText(MainScreen.Bounds, 'Teleport to this location', RS_FONT_QUILL_8, TOCRColorFilter.Create([8256]), teleportBox);
Wait(300, 500);
if not (Result = teleportBox) then Exit(teleportBox);
end;
raise 'Unable to find fairy dial teleport box in 5 tries';
end;

function TUniversalTransport.getWalkableFairyRing(maximumDistance: Int32): TTeleportLocation;
var
sortedWalkableRings: array of TTeleportLocation;
ringTeleport: TTeleportLocation;
myPos: TPoint := ScriptWalker^.GetMyPos();
begin
try
sortedWalkableRings := self.getConnectingTeleports(myPos, RSTeleports.FairyRingTeleports);
except
Self.DebugLn('There is not a walkable ring nearby.');
end;
if Length(sortedWalkableRings) > 0 then
begin
for ringTeleport in sortedWalkableRings do
if (self.pathLength(ringTeleport.worldPoint, myPos) < maximumDistance)
and ringTeleport.dispatcherRing then
Exit(ringTeleport);
Self.DebugLn('There is no walkable fairy ring');
end;
end;

function TUniversalTransport.handleFairyRingTeleport(teleportLocation: TTeleportLocation): Boolean;
const
TEXT_COLORS: TIntegerArray = [4145151, 8355839];
var
travelLog: TBox;
fairyCodeTextBox: TBox;
redTPA: TPointArray;
walkableFairyRing: TTeleportLocation;
canFairyTeleport: Boolean := self.fairyTeleportItem = EFairyTeleportItem.DIARY;
travelLogOpen: Boolean;
outerAttempt, innerAttempt: Int32;
fairyTeleportStaff: TRSItem;
fairyRingChooseOption: TRSChooseOption_Option;
usedChooseOptionTeleport: Boolean;
endLocation: TBox := Box(teleportLocation.worldPoint, 200, 200);
begin
travelLog := Logout.Bounds();
travelLog.Y1 += 40;
travelLog.X2 -= 36;

// make sure dramen is equipped
Self.DebugLn('Searching for dramen staff');
if not canFairyTeleport then
for outerAttempt := 0 to 3 do
begin
case self.fairyTeleportItem of
EFairyTeleportItem.DRAMEN: fairyTeleportStaff := 'Dramen staff';
EFairyTeleportItem.LUNAR: fairyTeleportStaff := 'Lunar staff';
EFairyTeleportItem.UNAVAILABLE: raise 'You either need to configure a method for fairy teleports (dramen/lunar/diary) or not use them.';
end;

canFairyTeleport := Inventory.ClickItem(fairyTeleportStaff) or Equipment.ContainsItem(fairyTeleportStaff);

Self.DebugLn('Is it equipped? ' + ToString(canFairyTeleport));

if not canFairyTeleport then
begin
if outerAttempt = 3 then
raise "We could not find a dramen staff.";

// maybe remove this whole part and just raise no item in inventory; leave it up the caller to get the fairy teleport item
Self.DebugLn('Opening Bank');
// teleport nearby bank if possible
self.genericJewelleryBankTeleport();
if not Bank.WalkOpen() then
raise "We can't get to a bank from here: " + ToString(ScriptWalker^.GetMyPos()) + ". Consider adding some jewellery to teleport with.";
// TO DO ^ maybe add desperate teleports to banks like home teleport
Self.DebugLn('Withdrawing ', fairyTeleportStaff);
if not WaitUntil(Bank.WithdrawItem(fairyTeleportStaff, False), 200, 5000) then
raise "You do not have a dramen/lunar staff. You can turn off fairy teleports";
end;
end;

Self.DebugLn('Getting walkable fairy ring');

for outerAttempt := 0 to 3 do
begin
walkableFairyRing := self.getWalkableFairyRing(500);

// try to use ardy cloak if available
if (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));
end;

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

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");
for outerAttempt := 0 to 3 do
begin
for innerAttempt := 0 to 3 do
begin
Mouse.Move(findFairyRingMiddle(walkableFairyRing));
if not MainScreen.IsUpText("y ring") then
Antiban.RandomRotate();
if MainScreen.IsUpText("y ring") then
Break;

travelLogOpen := SRL.FindColors(redTPA, TEXT_COLORS, travelLog) > 1;
if travelLogOpen then
Break(2);
end;

Mouse.click(MOUSE_RIGHT);
Self.DebugLn('Selecting configure or previous ring');
// handle zanaris cause it's weird
if teleportLocation = RSTeleports.BKS_ZANARIS then
usedChooseOptionTeleport := ChooseOption.Select('Zanaris')
else
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);

travelLogOpen := WaitUntil((SRL.FindColors(redTPA, TEXT_COLORS, travelLog) > 1), 300, 5000);
if travelLogOpen or usedChooseOptionTeleport then
Break;
if outerAttempt = 3 then
raise "Got stuck!";
end;

if usedChooseOptionTeleport then
Exit(True);

Self.DebugLn('Scrolling to top of fairy rings');
// scroll to top of fairy rings
Mouse.Move(travelLog, True);
Mouse.Scroll(SRL.TruncatedGauss(30, 50), False);

for outerAttempt := 0 to 3 do
begin
// look for given teleport in travel log
OCR.LocateText(travelLog, teleportLocation.destination, RS_FONT_PLAIN_12, TOCRColorFilter.Create(TEXT_COLORS), fairyCodeTextBox);

if fairyCodeTextBox.Area() > 5 then
Break;

Self.DebugLn('Scrolling down fairy rings');
Mouse.Move(travelLog, True);
Mouse.Scroll(Random(1, 3), True);

for innerAttempt := 0 to 3 do
begin
Mouse.Move(fairyCodeTextBox);
if MainScreen.IsUpText(teleportLocation.destination) then
Break;
end;
end;

// click the given teleport in travel log
Mouse.Click(fairyCodeTextBox, MOUSE_LEFT);
if FairyRing.WalkOpen() then
FairyRing.ClickLogCode(teleportLocation.destination);

// click the confirm teleport in middle of screen
Mouse.Move(self.getFairyDialTeleportBox());
if WaitUntil(MainScreen.IsUpText("Confirm"), 200, 5000) then
Mouse.click(MOUSE_LEFT);
if WaitUntil(FairyRing.GetCurrentCode() = teleportLocation.destination, 200, 5000) then
FairyRing.ClickTeleportButton();
Result := WaitUntil(endLocation.Contains(ScriptWalker^.GetMyPos()), 200, 5000);
end;

function TUniversalTransport.nearGE(): Boolean;
Expand Down Expand Up @@ -689,7 +483,6 @@ end;
//begin
// try
// rsw.Setup();
// Transport.Init(EFairyTeleportItem.DRAMEN, 'ardougne cloak 2');
// if not Transport.run(teleportLocation) then
// begin
// Transport.desperateBankOpen();
Expand Down

0 comments on commit c42480c

Please sign in to comment.