Skip to content

Commit d0185b8

Browse files
committed
feat(sailing minimap): sailing minimap related methods and properties
1 parent 26d1143 commit d0185b8

File tree

4 files changed

+180
-9
lines changed

4 files changed

+180
-9
lines changed

osrs.simba

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ Summary: It includes this file until the current file is reached.
7777
{$IFNDEF WL_CHOOSEOPTION_INCLUDED} {$INCLUDE_ONCE osrs/interfaces/chooseoption.simba}
7878
{$IFNDEF WL_MAINSCREEN_INCLUDED} {$INCLUDE_ONCE osrs/interfaces/mainscreen/mainscreen.simba}
7979
{$IFNDEF WL_MINIMAP_INCLUDED} {$INCLUDE_ONCE osrs/interfaces/minimap.simba}
80+
{$IFNDEF WL_SAILING_MINIMAP_INCLUDED} {$INCLUDE_ONCE osrs/interfaces/sailing_minimap.simba}
8081

8182
{$IFNDEF WL_OVERHEADFINDER_INCLUDED} {$INCLUDE_ONCE osrs/finders/overheadfinder.simba}
8283

@@ -185,4 +186,4 @@ Summary: It includes this file until the current file is reached.
185186
{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}
186187
{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}
187188
{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}
188-
{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}
189+
{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}{$ENDIF}

osrs/data/data.simba

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -370,19 +370,15 @@ var
370370
ids: TStringArray;
371371
id: String;
372372
json: TJSONItem;
373-
stackable: Boolean;
374373
begin
375374
if item.IsNumeric then ids := [item]
376375
else ids := ItemFinder.Database.GetAll(item.ToLower(), 'item', 'id');
376+
377377
for id in ids do
378378
begin
379379
json := Self.GetDefinition(id);
380-
case json.Item[Ord(EItemDataKey.STACKABLE)].AsInt of
381-
0: stackable := False;
382-
1: stackable := True;
383-
end;
384-
if stackable then
385-
Exit(stackable);
380+
if json.Item[Ord(EItemDataKey.STACKABLE)].AsInt <> 0 then
381+
Exit(True);
386382
end;
387383
end;
388384

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
(*
2+
# Sailing Minimap
3+
Methods to interact with the minimap interface while sailing:
4+
```{figure} ../../images/sailing_minimap.png
5+
```
6+
*)
7+
8+
{$DEFINE WL_SAILING_MINIMAP_INCLUDED}
9+
{$INCLUDE_ONCE WaspLib/osrs.simba}
10+
11+
type
12+
(*
13+
## ERSBoat enum
14+
```pascal
15+
ERSBoat = enum(RAFT, SKIFF, SLOOP);
16+
```
17+
Enum representing the types of boat the player can own and use.
18+
*)
19+
ERSBoat = enum(RAFT, SKIFF, SLOOP);
20+
21+
function TRSMinimap._GetBoat(out black, brown: TPointArray): TPointArray;
22+
var
23+
grown, tpa: TPointArray;
24+
atpa: T2DPointArray;
25+
begin
26+
black := Target.FindColor($010000, 0, Minimap.Bounds);
27+
if black = [] then
28+
Exit;
29+
30+
brown := Target.FindColor([$364E79, 0.9, EColorSpace.HSL, [1.888, 0.826, 0.288]], Minimap.Bounds);
31+
if brown = [] then
32+
Exit;
33+
34+
atpa := brown.Cluster(5);
35+
36+
brown := [];
37+
for tpa in atpa do
38+
if tpa.MinAreaRect().Contains(Minimap.Center) then
39+
begin
40+
brown := tpa;
41+
Break;
42+
end;
43+
44+
if brown = [] then
45+
Exit;
46+
47+
grown := brown.Grow(2);
48+
49+
for tpa in black.Cluster(5) do
50+
if tpa.Intersection(grown) <> [] then
51+
begin
52+
black := tpa;
53+
Exit(black+brown);
54+
end;
55+
end;
56+
57+
(*
58+
## Minimap.GetBoat
59+
```pascal
60+
function TRSMinimap.GetBoat(): TPointArray;
61+
```
62+
Returns a `TPointArray` of the player's boat.
63+
64+
Example:
65+
```pascal
66+
{$I WaspLib/osrs.simba}
67+
begin
68+
while True do
69+
ShowOnTarget(Minimap.GetBoat());
70+
end.
71+
```
72+
```{figure} ../../images/getboat.png
73+
```
74+
*)
75+
function TRSMinimap.GetBoat(): TPointArray;
76+
var
77+
black, brown: TPointArray;
78+
begin
79+
Result := Self._GetBoat(black, brown);
80+
end;
81+
82+
(*
83+
## Minimap.BoatRadians
84+
```pascal
85+
property TRSMinimap.BoatRadians: Single;
86+
```
87+
Returns a the boat angle as radians.
88+
89+
Example:
90+
```pascal
91+
{$I WaspLib/osrs.simba}
92+
begin
93+
WriteLn Minimap.BoatRadians;
94+
end.
95+
```
96+
*)
97+
property TRSMinimap.BoatRadians: Single;
98+
var
99+
boat, black, brown, tpa: TPointArray;
100+
tipTPA: TVector2Array;
101+
tip, center: TVector2;
102+
i: Integer;
103+
begin
104+
boat := Self._GetBoat(black, brown);
105+
if boat = [] then
106+
Exit;
107+
108+
tpa := black.Difference(black.PointsNearby(brown, 0, 5)).SortFrom(Minimap.Center);
109+
for i := High(tpa) downto 0 do
110+
begin
111+
tipTPA += tpa[i];
112+
if Length(tipTPA) > 3 then
113+
Break;
114+
end;
115+
116+
tip := tipTPA.Mean();
117+
118+
center := boat.MinAreaRect().Mean;
119+
120+
Result := Modulo(ArcTan2(Minimap.Center.Y-tip.Y, Minimap.Center.X-tip.X) - HALF_PI, TAU);
121+
end;
122+
123+
(*
124+
## Minimap.BoatDegrees
125+
```pascal
126+
property TRSMinimap.BoatDegrees: Single;
127+
```
128+
Returns a the boat angle as degrees.
129+
130+
Example:
131+
```pascal
132+
{$I WaspLib/osrs.simba}
133+
begin
134+
WriteLn Minimap.BoatDegrees;
135+
end.
136+
```
137+
*)
138+
property TRSMinimap.BoatDegrees: Single;
139+
begin
140+
Result := RadToDeg(Self.BoatRadians);
141+
end;
142+
143+
(*
144+
## Minimap.BoatType
145+
```pascal
146+
property TRSMinimap.BoatType: ERSBoat;
147+
```
148+
Returns a the boat {ref}`ERSBoat` type.
149+
150+
Example:
151+
```pascal
152+
{$I WaspLib/osrs.simba}
153+
begin
154+
WriteLn Minimap.BoatType;
155+
end.
156+
```
157+
*)
158+
property TRSMinimap.BoatType: ERSBoat;
159+
var
160+
tpa: TPointArray;
161+
size: Integer;
162+
begin
163+
tpa := Self.GetBoat();
164+
size := tpa.MinAreaRect().Area;
165+
166+
//todo:
167+
if InRange(size, 0, 5) then
168+
Exit(ERSBoat.RAFT);
169+
//todo:
170+
if InRange(size, 6, 20) then
171+
Exit(ERSBoat.SKIFF);
172+
if InRange(size, 800, 1100) then
173+
Exit(ERSBoat.SLOOP);
174+
end;

wasplib-docs

0 commit comments

Comments
 (0)