Skip to content

Commit 098a1d5

Browse files
committed
feat(FairyRing): unfinished, read notes
- added unfinished fairy ring interface - `RSColors.TEXT_` constants have been moved into `RSFonts` - Disable range checks for webgraph gen - More tweaks to walker
1 parent 7fd7719 commit 098a1d5

20 files changed

+806
-118
lines changed

osrs.simba

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ Summary: It includes this file until the current file is reached.
9797

9898
{$IFNDEF WL_ANTIBAN_INCLUDED} {$INCLUDE_ONCE osrs/antiban/antiban.simba}
9999

100+
{$IFNDEF WL_FAIRYRING_INCLUDED} {$INCLUDE_ONCE osrs/interfaces/mainscreen/fairyring.simba}
100101
{$IFNDEF WL_WALKER_INCLUDED} {$INCLUDE_ONCE osrs/walker.simba}
101102
{$IFNDEF WL_COLORFINDER_INCLUDED} {$INCLUDE_ONCE osrs/interfaces/mainscreen/finders/colorfinder.simba}
102103

@@ -145,7 +146,7 @@ Summary: It includes this file until the current file is reached.
145146
{$IFNDEF WL_SETUP_INCLUDED} {$INCLUDE_ONCE osrs/interfaces/setup.simba}
146147
{$IFNDEF WL_OVERRIDES_INCLUDED} {$INCLUDE_ONCE osrs/overrides.simba}
147148

148-
{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}
149+
{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}
149150
{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}
150151
{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}
151152
{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}

osrs/interfaces/chat/chat.simba

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Main record used to interact with the {ref}`Chat` interface.
4848
MessageLines: TBoxArray;
4949
InputLine: TBox;
5050
ReportButton: TRSButton;
51-
const Colors: array [ERSChatColor] of TColor = [RSColors.TEXT_BLACK, $7F0000, $FF0000, $7F007F, $2010EF, RSColors.TEXT_RED, RSColors.TEXT_WHITE, $FF9090, RSColors.TEXT_DARK_BLUE, $005F00];
51+
Colors: TColorArray;
5252
end;
5353

5454
(*
@@ -86,6 +86,8 @@ begin
8686
Self.Scroll.Area.Y2 := Self.InputLine.Y1 - 1;
8787

8888
Self.Scroll.Setup();
89+
90+
Self.Colors := [RSFonts.BLACK, $7F0000, $FF0000, $7F007F, $2010EF, RSFonts.RED, RSFonts.WHITE, $FF9090, RSFonts.DARK_BLUE, $005F00];
8991
end;
9092

9193
(*
@@ -340,7 +342,7 @@ WriteLn Chat.GetQueryAnswer();
340342
*)
341343
function TRSChat.GetQueryAnswer(): String;
342344
begin
343-
Result := OCR.Recognize(Self.Bounds, RSFonts.BOLD, [RSColors.TEXT_DARK_BLUE], 0);
345+
Result := OCR.Recognize(Self.Bounds, RSFonts.BOLD, [RSFonts.DARK_BLUE], 0);
344346
end;
345347

346348
(*

osrs/interfaces/chat/make.simba

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,13 +282,13 @@ begin
282282

283283
if quantity = ERSItemQuantity.CUSTOM then
284284
begin
285-
if amount = OCR.RecognizeNumber(Self.QuantityButtons[2], RSFonts.PLAIN_11, [Self.TEXT_COLOR, RSColors.TEXT_WHITE], 0) then
285+
if amount = OCR.RecognizeNumber(Self.QuantityButtons[2], RSFonts.PLAIN_11, [Self.TEXT_COLOR, RSFonts.WHITE], 0) then
286286
Exit(2);
287287
Exit(1);
288288
end;
289289

290290
for i := 1 to High(Self.QuantityButtons) do
291-
if amount = OCR.RecognizeNumber(Self.QuantityButtons[i], RSFonts.PLAIN_11, [Self.TEXT_COLOR, RSColors.TEXT_WHITE], 0) then
291+
if amount = OCR.RecognizeNumber(Self.QuantityButtons[i], RSFonts.PLAIN_11, [Self.TEXT_COLOR, RSFonts.WHITE], 0) then
292292
Exit(i);
293293
Result := -1;
294294
end;
@@ -307,7 +307,7 @@ WriteLn Make.IsQuantitySelected(Make.QUANTITY_ALL);
307307
*)
308308
function TRSMake.IsQuantitySelected(idx: Integer): Boolean;
309309
begin
310-
Result := Target.HasColor(RSColors.TEXT_WHITE, 0, 1, Self.QuantityButtons[idx]);
310+
Result := Target.HasColor(RSFonts.WHITE, 0, 1, Self.QuantityButtons[idx]);
311311
end;
312312

313313

osrs/interfaces/gametabs/achievements.simba

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ var
254254
slot: TRSDiarySlot;
255255
begin
256256
for slot in Self.GetSlots() do
257-
if OCR.Locate(slot.Name, Self.Names[diary], [RSColors.TEXT_RED, RSColors.TEXT_YELLOW, RSColors.TEXT_GREEN, RSColors.TEXT_WHITE], 0, RSFonts.PLAIN_11) > 0.9 then
257+
if OCR.Locate(slot.Name, Self.Names[diary], [RSFonts.RED, RSFonts.YELLOW, RSFonts.GREEN, RSFonts.WHITE], 0, RSFonts.PLAIN_11) > 0.9 then
258258
Exit(slot);
259259
end;
260260

osrs/interfaces/gametabs/worldswitcher.simba

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ WriteLn WorldSwitcher.IsLoading();
149149
*)
150150
function TRSWorldSwitcher.IsLoading(): Boolean;
151151
begin
152-
Result := not Target.HasColor(RSColors.TEXT_ORANGE, 0, 1, Self.CurrentWorldBounds);
152+
Result := not Target.HasColor(RSFonts.ORANGE, 0, 1, Self.CurrentWorldBounds);
153153
end;
154154

155155
(*
@@ -261,7 +261,7 @@ WriteLn WorldSwitcher.GetCurrentWorld();
261261
*)
262262
function TRSWorldSwitcher.GetCurrentWorld(): Integer;
263263
begin
264-
Result := OCR.RecognizeNumber(Self.CurrentWorldBounds, RSFonts.BOLD, [RSColors.TEXT_ORANGE], 0);
264+
Result := OCR.RecognizeNumber(Self.CurrentWorldBounds, RSFonts.BOLD, [RSFonts.ORANGE], 0);
265265
end;
266266

267267
(*

osrs/interfaces/interface.simba

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ end;
2929
type
3030
TRSInterfaceTitle = record
3131
Bounds, CloseButton: TBox;
32+
Font: ^TPixelFont;
3233
TitleColor: TColor;
3334
IsOpen: function (): Boolean of object;
3435
end;
@@ -50,9 +51,10 @@ begin
5051
Self.CloseButton.X2 := bounds.X2-7;
5152
Self.CloseButton.Y2 := bounds.Y1+28;
5253

53-
Self.TitleColor := RSColors.TEXT_ORANGE;
54+
Self.TitleColor := RSFonts.ORANGE;
5455

5556
Self.IsOpen := @Self._IsOpen;
57+
Self.Font := @RSFonts.BOLD;
5658
end;
5759

5860

@@ -66,14 +68,14 @@ end;
6668

6769
function TRSInterfaceTitle.GetTitle(): String;
6870
begin
69-
Result := OCR.Recognize(Self.Bounds, RSFonts.BOLD, [Self.TitleColor, $0], 0);
71+
Result := OCR.Recognize(Self.Bounds, Self.Font^, [Self.TitleColor, $0], 0);
7072
end;
7173

7274
function TRSInterfaceTitle.IsTitle(text: String; similarity: Single = 0.8): Boolean;
7375
var
7476
match: Single;
7577
begin
76-
match := OCR.LocateInvert(Self.Bounds, text, [$344049,$0], 2, RSFonts.BOLD);
78+
match := OCR.LocateInvert(Self.Bounds, text, [$344049,$0], 2, Self.Font^);
7779
Result := match >= similarity;
7880
end;
7981

osrs/interfaces/interfacearea.simba

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,11 @@ begin
8282
Result := [];
8383
end;
8484

85-
function TRSInterfaceArea.Close(escape: Boolean = True): Boolean;
85+
86+
function TRSInterfaceArea.Close(escape: Boolean): Boolean;
8687
begin
87-
if not Self.IsOpen() then Exit(True);
88+
if not Self.IsOpen() then
89+
Exit(True);
8890

8991
case escape of
9092
False: Self.GetCloseButton().Click();
@@ -94,6 +96,12 @@ begin
9496
Result := SleepUntil(not Self.IsOpen(), 50, 600);
9597
end;
9698

99+
function TRSInterfaceArea.Close(escapeProbability: Single = -1): Boolean; overload;
100+
begin
101+
if escapeProbability = -1 then escapeProbability := Biometrics.RandomDouble(0.5);
102+
Result := Self.Close(RandomBoolean(escapeProbability));
103+
end;
104+
97105

98106
function TRSInterfaceArea.CreateBounds(offset: TBox; width, height: Integer = 0): TBox;
99107
var

osrs/interfaces/mainscreen/anvil.simba

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ begin
114114
for i := 0 to High(boxes) do
115115
begin
116116
Self.QuantityButtons[i].Bounds := boxes[i];
117-
Self.QuantityButtons[i].EnabledColors := [[RSColors.TEXT_WHITE]];
117+
Self.QuantityButtons[i].EnabledColors := [[RSFonts.WHITE]];
118118
end;
119119
end;
120120

@@ -180,7 +180,7 @@ begin
180180
Exit(Self.QuantityButtons[0].Enable());
181181

182182
for i := 1 to High(Self.QuantityButtons) do
183-
if Target.HasColor(RSColors.TEXT_BLACK, 0, 1, Self.QuantityButtons[i].Bounds) then
183+
if Target.HasColor(RSFonts.BLACK, 0, 1, Self.QuantityButtons[i].Bounds) then
184184
btns += Self.QuantityButtons[i];
185185

186186
if btns = [] then Exit;

osrs/interfaces/mainscreen/bank.simba

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ begin
351351
end;
352352

353353
count := Target.CountColor($0, 0, Self._IsOpenHelperBox);
354-
tpa := Target.FindColor(RSColors.TEXT_ORANGE, 0, Self._IsOpenHelperBox);
354+
tpa := Target.FindColor(RSFonts.ORANGE, 0, Self._IsOpenHelperBox);
355355
Result := ((count = 94) and (Length(tpa) = 116)) or Self.Title.IsTitle('Bank') or Self.Title.IsTitle('Equip');
356356

357357
if Result then
@@ -822,7 +822,7 @@ Internal helper function help process the tabs text when you search.
822822
Example:
823823
```pascal
824824
if Bank.Search('logs') then
825-
if Bank._FindTabText(Target.FindColor(RSColors.TEXT_LIGHT_YELLOW, 0, bounds), bounds) then
825+
if Bank._FindTabText(Target.FindColor(RSFonts.LIGHT_YELLOW, 0, bounds), bounds) then
826826
ShowOnTarget(bounds);
827827
```
828828
*)
@@ -870,10 +870,10 @@ begin
870870
bounds := [Self.Bounds.X1 + 56, Self.Bounds.Y1 + 77, Self.Bounds.X1 + 84, bounds.Y1];
871871
if bounds.Height < 8 then Exit(0);
872872

873-
if Self._FindTabText(Target.FindColor(RSColors.TEXT_LIGHT_YELLOW, 0, bounds), bounds) then
874-
Result := OCR.RecognizeNumber(bounds, RSFonts.PLAIN_11, [RSColors.TEXT_LIGHT_YELLOW], 0);
875-
if Self._FindTabText(Target.FindColor(RSColors.TEXT_WHITE, 0, bounds), bounds) then
876-
Result := OCR.RecognizeNumber(bounds, RSFonts.PLAIN_11, [RSColors.TEXT_WHITE], 0);
873+
if Self._FindTabText(Target.FindColor(RSFonts.LIGHT_YELLOW, 0, bounds), bounds) then
874+
Result := OCR.RecognizeNumber(bounds, RSFonts.PLAIN_11, [RSFonts.LIGHT_YELLOW], 0);
875+
if Self._FindTabText(Target.FindColor(RSFonts.WHITE, 0, bounds), bounds) then
876+
Result := OCR.RecognizeNumber(bounds, RSFonts.PLAIN_11, [RSFonts.WHITE], 0);
877877
end;
878878

879879
(*

0 commit comments

Comments
 (0)