@@ -7,6 +7,79 @@ Methods to interact with the sailing gametab:
77{$DEFINE WL_SAILING_INCLUDED}
88{$INCLUDE_ONCE WaspLib/osrs.simba}
99
10+ type
11+ ESailingFacility = enum(HELM, REPAIR, CANNON, HOOK);
12+
13+ ERSCrewAsignee = enum(NONE, ME, CREW);
14+
15+ TSailingFacilitySlot = record
16+ Bounds, InfoBox, AssigneeBox: TBox;
17+ Buttons: TBoxArray;
18+ end;
19+
20+ TSailingFacilitySlotArray = array of TSailingFacilitySlot;
21+
22+ function TSailingFacilitySlot.Create(borders: TPointArray; area: TBox): TSailingFacilitySlot; static;
23+ var
24+ b: TBox;
25+ isHelm: Boolean;
26+ begin
27+ b := borders.Bounds;
28+
29+ case b.Height of
30+ 30:
31+ begin
32+ b.Y1 := Max(b.Y1-2,area.Y1);
33+ b.Y2 := Min(b.Y2+2, area.Y2);
34+ end;
35+ 45, 61:
36+ begin
37+ b.Y2 := b.Y1+65;
38+ b.Y1 := Max(b.Y1-4,area.Y1);
39+ isHelm := True;
40+ end;
41+ else Exit;
42+ end;
43+
44+ Result.Bounds := [area.X1, b.Y1, area.X2, b.Y2];
45+
46+ with Result.Bounds do
47+ begin
48+ Result.InfoBox := [X1, Y1, X2-41, Y2];
49+ Result.AssigneeBox.X1 := X2 - 33;
50+ if isHelm then
51+ Result.AssigneeBox.Y1 := Y1 + 19
52+ else
53+ Result.AssigneeBox.Y1 := Y1 + 2;
54+ Result.AssigneeBox.X2 := X2-4;
55+ end;
56+
57+ Result.AssigneeBox.Y2 := Result.AssigneeBox.Y1+29;
58+ end;
59+
60+ property TSailingFacilitySlot.Facility: ESailingFacility;
61+ var
62+ count: Integer;
63+ begin
64+ count := Target.CountColor(TRSInterface.BORDER, 0, Self.InfoBox);
65+
66+ case count of
67+ 372, 691: Result := ESailingFacility.HELM;
68+ 0: Result := ESailingFacility.REPAIR;
69+ 82: Result := ESailingFacility.HOOK;
70+ else Result := ESailingFacility.CANNON;
71+ end;
72+ end;
73+
74+ property TSailingFacilitySlot.Assignee: ERSCrewAsignee;
75+ begin
76+ case Target.CountColor(TRSInterface.BORDER, 0, Self.AssigneeBox) of
77+ 170: Result := ERSCrewAsignee.NONE;
78+ 174: Result := ERSCrewAsignee.ME;
79+ else Result := ERSCrewAsignee.CREW;
80+ end;
81+ end;
82+
1083type
1184(*
1285## ERSSailingTab
119192begin
120193 title := OCR.Recognize(Self.TabTitle, RSFonts.PLAIN_12, [RSFonts.ORANGE], 0);
121194
122- WriteLn title;
123195 case title of
124196 'Facilities': Result := ERSSailingTab.FACILITIES;
125197 'Stats': Result := ERSSailingTab.STATS;
@@ -154,6 +226,29 @@ begin
154226 Result := SleepUntil(Self.GetTab() = tab, RandomMode(100, 50, 1500), 4*TICK);
155227end;
156228
229+
230+ function TRSSailing.GetFacilitySlots(): TSailingFacilitySlotArray;
231+ var
232+ tpa: TPointArray;
233+ atpa: T2DPointArray;
234+ area: TBox;
235+ slot: TSailingFacilitySlot;
236+ begin
237+ if Self.GetTab() <> ERSSailingTab.FACILITIES then
238+ Exit;
239+
240+ area := Self.Scrolls[ERSSailingTab.FACILITIES].Area;
241+ tpa := Target.FindColor(TRSInterface.BORDER, 0, area);
242+ atpa := tpa.Cluster(100, 4);
243+
244+ for tpa in atpa do
245+ begin
246+ slot := TSailingFacilitySlot.Create(tpa, area);
247+ if slot <> Default(TSailingFacilitySlot) then
248+ Result += slot;
249+ end;
250+ end;
251+
157252var
158253(*
159254## Sailing variable
0 commit comments