Skip to content

Commit aaaf316

Browse files
committed
feat(TRSSailing): added basic sailing tab support
1 parent 517890b commit aaaf316

File tree

8 files changed

+174
-27
lines changed

8 files changed

+174
-27
lines changed

osrs.simba

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ Summary: It includes this file until the current file is reached.
9090
{$IFNDEF WL_SLOT_INTERFACE_INCLUDED} {$INCLUDE_ONCE osrs/interfaces/slotinterface.simba}
9191
{$IFNDEF WL_ITEM_INTERFACE_INCLUDED} {$INCLUDE_ONCE osrs/interfaces/iteminterface.simba}
9292

93+
{$IFNDEF WL_SAILING_INCLUDED} {$INCLUDE_ONCE osrs/interfaces/gametabs/sailing.simba}
9394
{$IFNDEF WL_COMBAT_INCLUDED} {$INCLUDE_ONCE osrs/interfaces/gametabs/combat.simba}
9495
{$IFNDEF WL_STATS_INCLUDED} {$INCLUDE_ONCE osrs/interfaces/gametabs/stats.simba}
9596
{$IFNDEF WL_ACHIEVEMENTS_INCLUDED} {$INCLUDE_ONCE osrs/interfaces/gametabs/achievements.simba}
@@ -183,4 +184,4 @@ Summary: It includes this file until the current file is reached.
183184
{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}
184185
{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}
185186
{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}
186-
{$ENDIF}{$ENDIF}
187+
{$ENDIF}{$ENDIF}{$ENDIF}

osrs/interfaces/gametabs/achievements.simba

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ Attempts to open the specified `tab` {ref}`ERSAchievementTab`.
441441

442442
Example:
443443
```pascal
444-
WriteLn Achievements.OpenTab( ERSAchievementTab.DIARIES);
444+
WriteLn Achievements.OpenTab(ERSAchievementTab.DIARIES);
445445
```
446446
*)
447447
function TRSAchievements.OpenTab(tab: ERSAchievementTab): Boolean;
@@ -463,7 +463,7 @@ begin
463463
end;
464464

465465
Mouse.Click(b, EMouseButton.LEFT);
466-
Result := SleepUntil(Self.GetTab() = tab, RandomMode(100, 50, 1500), 2000);
466+
Result := SleepUntil(Self.GetTab() = tab, RandomMode(100, 50, 1500), 4*TICK);
467467
end;
468468

469469

osrs/interfaces/gametabs/combat.simba

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ type
106106
Main record responsible with handling the combat gametab.
107107
*)
108108
TRSCombat = record
109-
AutoRetaliateBox, SpecialAttackBox,
109+
SailingBox, AutoRetaliateBox, SpecialAttackBox,
110110
CategoryBox, _StylesBox: TBox;
111111
_StyleBoxes: array [0..2] of TBoxArray;
112112
end;
@@ -115,25 +115,11 @@ procedure TRSCombat.SetupGameTab();
115115
begin
116116
with GameTab.TopLeft do
117117
begin
118-
Self.AutoRetaliateBox.X1 := X+18;
119-
Self.AutoRetaliateBox.Y1 := Y+155;
120-
Self.AutoRetaliateBox.X2 := X+165;
121-
Self.AutoRetaliateBox.Y2 := Y+196;
122-
123-
Self.SpecialAttackBox.X1 := X+18;
124-
Self.SpecialAttackBox.Y1 := Y+206;
125-
Self.SpecialAttackBox.X2 := X+165;
126-
Self.SpecialAttackBox.Y2 := Y+229;
127-
128-
Self.CategoryBox.X1 := X+22;
129-
Self.CategoryBox.Y1 := Y+235;
130-
Self.CategoryBox.X2 := X+161;
131-
Self.CategoryBox.Y2 := Y+255;
132-
133-
Self._StylesBox.X1 := X+18;
134-
Self._StylesBox.Y1 := Y+47;
135-
Self._StylesBox.X2 := X+165;
136-
Self._StylesBox.Y2 := Y+148;
118+
Self.SailingBox := [X-3, Y+1, X+22, Y+26];
119+
Self.AutoRetaliateBox := [X+18, Y+155, X+165, Y+196];
120+
Self.SpecialAttackBox := [X+18, Y+206, X+165, Y+229];
121+
Self.CategoryBox := [X+22, Y+235, X+161, Y+255];
122+
Self._StylesBox := [X+18, Y+47, X+165, Y+148];
137123

138124
Self._StyleBoxes[0] := TBoxArray.Create([X+18,Y+47], 2, 2, 68, 44, [11, 10]);
139125
Self._StyleBoxes[1] := Copy(Self._StyleBoxes[0], 0, 3);
@@ -157,7 +143,7 @@ WriteLn Combat.IsOpen();
157143
*)
158144
function TRSCombat.IsOpen(): Boolean;
159145
begin
160-
Result := GameTabs.IsOpen(ERSGameTab.COMBAT);
146+
Result := GameTabs.IsOpen(ERSGameTab.COMBAT) and not Sailing.IsOpen();
161147
end;
162148

163149
(*
@@ -175,6 +161,11 @@ WriteLn Combat.Open();
175161
function TRSCombat.Open(): Boolean;
176162
begin
177163
Result := GameTabs.Open(ERSGameTab.COMBAT);
164+
if Result and not Self.IsOpen() then
165+
begin
166+
Mouse.Click(Self.SailingBox, EMouseButton.LEFT);
167+
Result := SleepUntil(Self.IsOpen(), RandomMode(100, 50, 1500), 4*TICK);
168+
end;
178169
end;
179170

180171

osrs/interfaces/gametabs/gametabs.simba

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,8 @@ WriteLn GameTabs.Open(ERSGameTab.INVENTORY);
260260
*)
261261
function TRSGameTabs.Open(tab: ERSGameTab; fkeyProbability: Single = -1): Boolean;
262262
begin
263-
if Self.IsOpen(tab) then Exit(True);
263+
if Self.IsOpen(tab) then
264+
Exit(True);
264265

265266
if Self.KeybindsEnabled then
266267
begin
Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
(*
2+
# Sailing
3+
Methods to interact with the sailing gametab:
4+
```{figure} ../../images/sailingtab.png
5+
```
6+
*)
7+
{$DEFINE WL_SAILING_INCLUDED}
8+
{$INCLUDE_ONCE WaspLib/osrs.simba}
9+
10+
type
11+
(*
12+
## ERSSailingTab
13+
```pascal
14+
ERSSailingTab = enum(FACILITIES, STATS, CREW);
15+
```
16+
Enum represinting the available sailing tabs.
17+
*)
18+
ERSSailingTab = enum(FACILITIES, STATS, CREW);
19+
20+
(*
21+
## TRSSailing
22+
Main record responsible with handling the Sailing gametab.
23+
*)
24+
TRSSailing = record
25+
CombatBox, ShipNameBox, ShipHealthBox, TabTitle: TBox;
26+
Tabs: TBoxArray;
27+
end;
28+
29+
procedure TRSSailing.SetupGameTab();
30+
begin
31+
with GameTab.Bounds do
32+
begin
33+
Self.CombatBox := [X1-3, Y1+1, X1+22, Y1+26];
34+
Self.ShipNameBox := [X1+26, Y1+4, X2-2, Y1+26];
35+
Self.ShipHealthBox := [X1+8, Y1+30, X2-6, Y1+42];
36+
37+
Self.Tabs := TBoxArray.Create([X1+2, Y1+46], 3, 1, 55, 20, [7,0]);
38+
Self.TabTitle := [X1+32, Y1+68, X2-32, Y1+82];
39+
end;
40+
end;
41+
42+
(*
43+
## Sailing.IsOpen
44+
```pascal
45+
function TRSSailing.IsOpen(): Boolean;
46+
```
47+
Returns true/false if the sailing tab is open.
48+
49+
Example:
50+
```pascal
51+
WriteLn Sailing.IsOpen();
52+
```
53+
*)
54+
function TRSSailing.IsOpen(): Boolean;
55+
begin
56+
Result := Target.HasColor([$1ABD1A, 7, EColorSpace.RGB, [1.247, 0.507, 1.247]], 1, Self.ShipHealthBox);
57+
end;
58+
59+
(*
60+
## Sailing.Open
61+
```pascal
62+
function TRSSailing.Open(): Boolean;
63+
```
64+
Attempts to open the sailing gametab.
65+
66+
Example:
67+
```pascal
68+
WriteLn Sailing.Open();
69+
```
70+
*)
71+
function TRSSailing.Open(): Boolean;
72+
begin
73+
Result := GameTabs.Open(ERSGameTab.COMBAT);
74+
if Result and not Self.IsOpen() then
75+
begin
76+
Mouse.Click(Self.CombatBox, EMouseButton.LEFT);
77+
Result := SleepUntil(Self.IsOpen(), RandomMode(100, 50, 1500), 4*TICK);
78+
end;
79+
end;
80+
81+
82+
property TRSSailing.ShipName: String;
83+
begin
84+
Result := OCR.Recognize(Self.ShipNameBox, RSFonts.BOLD_SHADOW, [RSFonts.ORANGE], 0);
85+
end;
86+
87+
property TRSSailing.ShipHealth: Integer;
88+
var
89+
str: String;
90+
begin
91+
str := OCR.Recognize(Self.ShipHealthBox, RSFonts.PLAIN_11, [RSFonts.WHITE], 0);
92+
Result := str.Before('/').ExtractInteger();
93+
end;
94+
95+
(*
96+
## Sailing.GetTab
97+
```pascal
98+
function TRSSailing.GetTab(): ERSSailingTab;
99+
```
100+
Returns the currently active {ref}`ERSSailingTab`.
101+
102+
Example:
103+
```pascal
104+
WriteLn Sailing.GetTab();
105+
```
106+
*)
107+
function TRSSailing.GetTab(): ERSSailingTab;
108+
var
109+
title: String;
110+
begin
111+
title := OCR.Recognize(Self.TabTitle, RSFonts.PLAIN_12, [RSFonts.ORANGE], 0);
112+
113+
WriteLn title;
114+
case title of
115+
'Facilities': Result := ERSSailingTab.FACILITIES;
116+
'Stats': Result := ERSSailingTab.STATS;
117+
'Crew': Result := ERSSailingTab.CREW;
118+
end;
119+
end;
120+
121+
(*
122+
## Sailing.OpenTab
123+
```pascal
124+
function TRSSailing.OpenTab(tab: ERSSailingTab): Boolean;
125+
```
126+
Attempts to open the specified `tab` {ref}`ERSSailingTab`.
127+
128+
Example:
129+
```pascal
130+
WriteLn Sailing.OpenTab(ERSSailingTab.CREW);
131+
```
132+
*)
133+
function TRSSailing.OpenTab(tab: ERSSailingTab): Boolean;
134+
var
135+
b: TBox;
136+
begin
137+
if not Self.Open() then
138+
Exit;
139+
if tab = Self.GetTab() then
140+
Exit(True);
141+
142+
b := Self.Tabs[tab];
143+
144+
Mouse.Click(b, EMouseButton.LEFT);
145+
Result := SleepUntil(Self.GetTab() = tab, RandomMode(100, 50, 1500), 4*TICK);
146+
end;
147+
148+
var
149+
(*
150+
## Sailing variable
151+
Global {ref}`TRSSailing` variable.
152+
*)
153+
Sailing: TRSSailing;

osrs/interfaces/setup.simba

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ begin
1616
GameTabs.SetupInterface(); //Has to be before gametab
1717
GameTab.SetupInterface(); //Has to be before all gametabs
1818

19+
Sailing.SetupGameTab();
1920
Combat.SetupGameTab();
2021
Stats.SetupGameTab();
2122
Achievements.SetupGameTab();

utils/webgraphgen.simba

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ end;
2424

2525
type
2626
(*
27-
## TWebGraphGenerator
27+
## TWebGraphGenerator type
2828
Record responsible for generating webgraphs from collision map images.
2929
*)
3030
TWebGraphGenerator = record

wasplib-docs

0 commit comments

Comments
 (0)