Skip to content

Commit 9ebcd28

Browse files
committed
fix(TRSObject and TRSEntity): Hover now checks if the mouse is on the mainscreen
This matters especially for items where you could be hovering them in your inventory and this returns true. Also, renamed `ERSMinimapDot` to `ERSDot`
1 parent 9ca35a6 commit 9ebcd28

9 files changed

Lines changed: 95 additions & 79 deletions

File tree

osrs/antiban/antibantasks.simba

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ procedure TAntiban.RandomRightClick;
2424
procedure TAntiban.AdjustZoom;
2525
procedure TAntiban.SwivelNear(start: TBox; radius: Int32; Iterations: Int32=1); overload;
2626
procedure TAntiban.Swivel;
27-
procedure TAntiban.HoverMSTile(dotType: ERSMinimapDot; rightClick: Boolean = False);
27+
procedure TAntiban.HoverMSTile(dotType: ERSDot; rightClick: Boolean = False);
2828
procedure TAntiban.HoverRandomNPC;
2929
procedure TAntiban.HoverRandomPlayer;
3030
procedure TAntiban.HoverRandomGrounditem;
@@ -713,7 +713,7 @@ end;
713713

714714

715715

716-
procedure TAntiBan.HoverMSTile(dotType: ERSMinimapDot; rightClick: Boolean = False);
716+
procedure TAntiBan.HoverMSTile(dotType: ERSDot; rightClick: Boolean = False);
717717
var
718718
tries: Int32;
719719
a: Double;
@@ -748,17 +748,17 @@ end;
748748

749749
procedure TAntiban.HoverRandomNPC();
750750
begin
751-
Self.HoverMSTile(ERSMinimapDot.NPC);
751+
Self.HoverMSTile(ERSDot.NPC);
752752
end;
753753

754754
procedure TAntiban.HoverRandomPlayer();
755755
begin
756-
Self.HoverMSTile(ERSMinimapDot.PLAYER);
756+
Self.HoverMSTile(ERSDot.PLAYER);
757757
end;
758758

759-
procedure TAntiban.HoverRandomGrounditem();
759+
procedure TAntiban.HoverRandomGroundItem();
760760
begin
761-
Self.HoverMSTile(ERSMinimapDot.ITEM);
761+
Self.HoverMSTile(ERSDot.ITEM);
762762
end;
763763

764764

osrs/dotfilters.simba

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(*
22
# DotFilters
3-
Methods to handle DotFilters. Dot filters are filters that filter in or out ERSMinimapDots.
3+
Methods to handle DotFilters. Dot filters are filters that filter in or out ERSDots.
44
*)
55

66
{$DEFINE WL_DOTFILTERS_INCLUDED}
@@ -30,15 +30,16 @@ Type used to filter minimap dots.
3030
Timer : TCountDown;
3131
end;
3232

33-
3433
(*
3534
## TRSDotFilter.Create
3635
```pascal
3736
function TRSDotFilter.Create(bounds: TPolygon; c: TCircle; inside: Boolean; time: Int32 = -1): TRSDotFilter; static;
3837
```
3938
Static method to create a TRSDotFilter.
4039
*)
41-
function TRSDotFilter.Create(bounds: TPolygon; c: TCircle; inside: Boolean; time: Int32 = -1): TRSDotFilter; static;
40+
function TRSDotFilter.Create(
41+
bounds: TPolygon; c: TCircle; inside: Boolean; time: Int32 = -1
42+
): TRSDotFilter; static;
4243
var
4344
timer: TCountDown;
4445
begin
@@ -178,12 +179,12 @@ end;
178179
(*
179180
## TRSMinimap.GetFilteredDot
180181
```pascal
181-
function TRSMinimap.GetFilteredDotArray(dot: ERSMinimapDot; dotFilters: TRSDotFilterArray): TPointArray;
182-
function TRSMinimap.GetFilteredDot(dot: ERSMinimapDot; dotFilters: TRSDotFilterArray): TPoint;
182+
function TRSMinimap.GetFilteredDotArray(dots: ERSDots; dotFilters: TRSDotFilterArray): TPointArray;
183+
function TRSMinimap.GetFilteredDot(dots: ERSDots; dotFilters: TRSDotFilterArray): TPoint;
183184
```
184185
Retrieves and filters minimap dots according to the specified TRSDotFilters.
185186
*)
186-
function TRSMinimap.GetFilteredDotArray(dots: ERSMinimapDots; dotFilters: TRSDotFilterArray): TPointArray;
187+
function TRSMinimap.GetFilteredDotArray(dots: ERSDots; dotFilters: TRSDotFilterArray): TPointArray;
187188
var
188189
tpa, flat: TPointArray;
189190
begin
@@ -192,7 +193,7 @@ begin
192193
Result := dotFilters.FilterDots(flat);
193194
end;
194195

195-
function TRSMinimap.GetFilteredDot(dots: ERSMinimapDots; dotFilters: TRSDotFilterArray): TPoint;
196+
function TRSMinimap.GetFilteredDot(dots: ERSDots; dotFilters: TRSDotFilterArray): TPoint;
196197
var
197198
tpa: TPointArray;
198199
begin

osrs/interfaces/minimap.simba

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,21 @@ Methods to interact with the minimap interface:
1010

1111
type
1212
(*
13-
(ERSMinimapDots)=
14-
## ERSMinimapDot enum
13+
(ERSDots)=
14+
## ERSDot enum
1515
```pascal
16-
ERSMinimapDot = enum(PLAYER, NPC, ITEM);
16+
ERSDot = enum(PLAYER, NPC, ITEM);
1717
```
1818
Enum representing the available minimap dots.
1919
*)
20-
ERSMinimapDot = enum(PLAYER, NPC, ITEM);
21-
ERSMinimapDots = set of ERSMinimapDot;
22-
TRSMinimapDotArray = array [ERSMinimapDot] of TPointArray;
20+
ERSDot = enum(PLAYER, NPC, ITEM);
21+
ERSDots = set of ERSDot;
22+
TRSDotArray = array [ERSDot] of TPointArray;
2323

24+
const
25+
ALL_DOTS: ERSDots = [ERSDot.PLAYER, ERSDot.NPC, ERSDot.ITEM];
26+
27+
type
2428
(*
2529
(ERSMinimapOrb)=
2630
## ERSMinimapOrb enum
@@ -1110,11 +1114,11 @@ end;
11101114
(*
11111115
## Minimap.GetDots
11121116
```pascal
1113-
function TRSMinimap._GetDots(dot: ERSMinimapDot; img: TImage; offset: TPoint): TPointArray;
1114-
function TRSMinimap.GetDots(dot: ERSMinimapDot; bounds: TBox): TPointArray;
1115-
function TRSMinimap.GetDots(dot: ERSMinimapDot): TPointArray; overload;
1116-
function TRSMinimap.GetDots(dots: ERSMinimapDots; bounds: TBox): TRSMinimapDotArray; overload;
1117-
function TRSMinimap.GetDots(dots: ERSMinimapDots = [ERSMinimapDot.PLAYER, ERSMinimapDot.NPC, ERSMinimapDot.ITEM]): TRSMinimapDotArray; overload;
1117+
function TRSMinimap._GetDots(dot: ERSDot; img: TImage; offset: TPoint): TPointArray;
1118+
function TRSMinimap.GetDots(dot: ERSDot; bounds: TBox): TPointArray;
1119+
function TRSMinimap.GetDots(dot: ERSDot): TPointArray; overload;
1120+
function TRSMinimap.GetDots(dots: ERSDots; bounds: TBox): TRSDotArray; overload;
1121+
function TRSMinimap.GetDots(dots: ERSDots = [ERSDot.PLAYER, ERSDot.NPC, ERSDot.ITEM]): TRSDotArray; overload;
11181122
```
11191123
Returns minimap dots found.
11201124
You can specify which dots you want to look for in `dot` or `dots`.
@@ -1128,7 +1132,7 @@ var
11281132
pt: TPoint;
11291133
boxes: TBoxArray;
11301134
begin
1131-
for pt in Minimap.GetDots(ERSMinimapDot.NPC) do
1135+
for pt in Minimap.GetDots(ERSDot.NPC) do
11321136
boxes += TBox.Create(pt, 3, 3);
11331137
ShowOnTarget(boxes);
11341138
end.
@@ -1145,7 +1149,7 @@ It basically comes down to whether you want a simple solution that people can
11451149
reason with or something complex that does it accurately.
11461150
WaspLib goes with the first option.
11471151

1148-
This means that depending on the type of {ref}`ERSMinimapDot` you are trying to
1152+
This means that depending on the type of {ref}`ERSDot` you are trying to
11491153
find and the {ref}`ERSClient` you are using, you might get 2 `TPoints` per dot.
11501154

11511155
This is because the way it works is as follows:
@@ -1155,7 +1159,7 @@ This is because the way it works is as follows:
11551159
```{figure} ../../images/minimap_getdots_java.png
11561160
```
11571161

1158-
However, with `ERSMinimapDot.PLAYER` and every dot on `ERSClient.OFFICIAL` you
1162+
However, with `ERSDot.PLAYER` and every dot on `ERSClient.OFFICIAL` you
11591163
have the following issue:
11601164
```{figure} ../../images/minimap_getdots_cpp.png
11611165
```
@@ -1164,9 +1168,9 @@ The 2 bottom center pixels are not unique anymore which makes it so you get 2 po
11641168

11651169
So do have that in mind when writing your scripts.
11661170
*)
1167-
function TRSMinimap._GetDots(dot: ERSMinimapDot; img: TImage; offset: TPoint): TPointArray;
1171+
function TRSMinimap._GetDots(dot: ERSDot; img: TImage; offset: TPoint): TPointArray; static;
11681172
const
1169-
COLORS: array [ERSClient] of array [ERSMinimapDot] of array [0..1] of TColor = [
1173+
COLORS: array [ERSClient] of array [ERSDot] of array [0..1] of TColor = [
11701174
//PLAYER NPC ITEM
11711175
[[$FEFEFE, $ECECEC], [$02FCFC, $00EDED], [$0606FC, $0000F1]], //UNKNOWN
11721176
[[$FEFEFE, $ECECEC], [$02FCFC, $00EDED], [$0606FC, $0000F1]], //LEGACY
@@ -1175,19 +1179,25 @@ const
11751179
];
11761180
var
11771181
y,x: Integer;
1182+
color0, color1: TColor;
11781183
begin
1184+
color0 := COLORS[RSClient.Client][dot][0];
1185+
color1 := COLORS[RSClient.Client][dot][1];
1186+
11791187
for y := 0 to img.Height-2 do
11801188
for x := 0 to img.Width-2 do
11811189
begin
1182-
if img.Pixel[x,y] <> COLORS[RSClient.Client][dot][0] then Continue;
1183-
if img.Pixel[x+1,y] <> COLORS[RSClient.Client][dot][1] then Continue;
1190+
if img.Pixel[x,y] <> color0 then
1191+
Continue;
1192+
if img.Pixel[x+1,y] <> color1 then
1193+
Continue;
11841194
//TODO: maybe confirm dot shadow or confirm other dots in range.
11851195
//Some dots are detected twice, especially players.
11861196
Result += [x + offset.X, y + offset.Y-1];
11871197
end;
11881198
end;
11891199

1190-
function TRSMinimap.GetDots(dot: ERSMinimapDot; bounds: TBox): TPointArray;
1200+
function TRSMinimap.GetDots(dot: ERSDot; bounds: TBox): TPointArray;
11911201
var
11921202
img: TImage;
11931203
begin
@@ -1196,14 +1206,14 @@ begin
11961206
Result := Self._GetDots(dot, img, bounds.TopLeft);
11971207
end;
11981208

1199-
function TRSMinimap.GetDots(dot: ERSMinimapDot): TPointArray; overload;
1209+
function TRSMinimap.GetDots(dot: ERSDot): TPointArray; overload;
12001210
begin
12011211
Result := Self.GetDots(dot, Self._PolyBounds);
12021212
end;
12031213

1204-
function TRSMinimap.GetDots(dots: ERSMinimapDots; bounds: TBox): TRSMinimapDotArray; overload;
1214+
function TRSMinimap.GetDots(dots: ERSDots; bounds: TBox): TRSDotArray; overload;
12051215
var
1206-
dot: ERSMinimapDot;
1216+
dot: ERSDot;
12071217
img: TImage;
12081218
begin
12091219
bounds := bounds.Clip(Self._PolyBounds);
@@ -1213,7 +1223,7 @@ begin
12131223
Result[dot] := Self._GetDots(dot, img, bounds.TopLeft);
12141224
end;
12151225

1216-
function TRSMinimap.GetDots(dots: ERSMinimapDots = [ERSMinimapDot.PLAYER, ERSMinimapDot.NPC, ERSMinimapDot.ITEM]): TRSMinimapDotArray; overload;
1226+
function TRSMinimap.GetDots(dots: ERSDots = ALL_DOTS): TRSDotArray; overload;
12171227
begin
12181228
Result := Self.GetDots(dots, Self._PolyBounds);
12191229
end;
@@ -1280,11 +1290,11 @@ function TRSMinimap.GetCleanMask(img: TImage): TPointArray;
12801290
var
12811291
pt: TPoint;
12821292
bounds: TBox;
1283-
dot: ERSMinimapDot;
1293+
dot: ERSDot;
12841294
begin
12851295
bounds := [1,1,img.Width-2, img.Height-2];
12861296

1287-
for dot := ERSMinimapDot.PLAYER to ERSMinimapDot.ITEM do
1297+
for dot := ERSDot.PLAYER to ERSDot.ITEM do
12881298
for pt in Self._GetDots(dot, img, [0,0]) do
12891299
Result += _DotTPA(pt, bounds);
12901300

osrs/position/map/entities.simba

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
# RSEntities
33
This file is responsible for interacting with `RSEntities`.
44

5-
`RSEntities` is anything in the game that has a {ref}`ERSMinimapDot` assign to
5+
`RSEntities` is anything in the game that has a {ref}`ERSDot` assign to
66
it on the {ref}`Minimap`.
77

88
These are functionally very similar to {ref}`RSObjects` and you create and
99
interact with them almost the same way.
1010

11-
They only differ in the fact that `TRSEntity` can use a {ref}`ERSMinimapDot` to
11+
They only differ in the fact that `TRSEntity` can use a {ref}`ERSDot` to
1212
help find them and/or {ref}`TRSDotFilters`.
1313
Also, due to the unpredictability of entities that move, unlike {ref}`RSObjects`
1414
these do not have a rotation field.
@@ -31,7 +31,7 @@ Main type to handle {ref}`RSEntity`.
3131
Coordinates: TPointArray;
3232
Filter: TRSDotFilterArray;
3333
Finder: TColorFinder;
34-
MinimapDots: ERSMinimapDots;
34+
MinimapDots: ERSDots;
3535
LastCoordinate, DotOffset: TPoint;
3636
Walker: PRSWalker;
3737
MinDistance: Integer;
@@ -48,7 +48,7 @@ Array of {ref}`TRSEntity`.
4848
(*
4949
## TRSEntity.Create
5050
```pascal
51-
function TRSEntity.Create(var walker: TRSWalker; size: TVector3; coordinates: TPointArray; uptext: TStringArray = []; dots: ERSMinimapDots = []): TRSEntity; static;
51+
function TRSEntity.Create(var walker: TRSWalker; size: TVector3; coordinates: TPointArray; uptext: TStringArray = []; dots: ERSDots = []): TRSEntity; static;
5252
function TRSEntity.Create(var walker: TRSWalker; json: TJSONObject): TRSEntity; static; overload;
5353
```
5454
Create function to create your {ref}`TRSEntity`.
@@ -63,7 +63,7 @@ var
6363
npc: TRSEntity;
6464
begin
6565
Map.Setup([ERSChunk.VARROCK]); //varrock west southern most banker
66-
npc := TRSEntity.Create(Map.Walker, [1,1,7], [[8652,36686]], ['Banker'], [ERSMinimapDot.NPC]);
66+
npc := TRSEntity.Create(Map.Walker, [1,1,7], [[8652,36686]], ['Banker'], [ERSDot.NPC]);
6767
//npc.Finder.Colors += [$543B3B, 10.121, EColorSpace.HSV, [0.528, 1.275, 1.199]];
6868
end;
6969
```
@@ -81,7 +81,7 @@ begin
8181
end;
8282
```
8383
*)
84-
function TRSEntity.Create(var walker: TRSWalker; size: TVector3; radius: Integer; coordinates: TPointArray; uptext: TStringArray = []; dots: ERSMinimapDots = []): TRSEntity; static;
84+
function TRSEntity.Create(var walker: TRSWalker; size: TVector3; radius: Integer; coordinates: TPointArray; uptext: TStringArray = []; dots: ERSDots = []): TRSEntity; static;
8585
var
8686
pt: TPoint;
8787
begin
@@ -118,7 +118,7 @@ begin
118118
Result.UpText := [AsString];
119119

120120
if json.Item[Ord(ENPCData.MINIMAPDOT)].AsBool then
121-
Result.MinimapDots := [ERSMinimapDot.NPC];
121+
Result.MinimapDots := [ERSDot.NPC];
122122

123123
with json.Item[Ord(ENPCData.SIZE)] do
124124
begin
@@ -528,7 +528,7 @@ var
528528
npc: TRSEntity;
529529
begin
530530
Map.Setup([Chunk(Box(40,49,41,48), 0)]);
531-
npc := TRSEntity.Create(Map.Walker, [1,1,7], 8, [[10432, 37966]], ['Dominic Onion'], [ERSMinimapDot.NPC]);
531+
npc := TRSEntity.Create(Map.Walker, [1,1,7], 8, [[10432, 37966]], ['Dominic Onion'], [ERSDot.NPC]);
532532
WriteLn npc.Hover();
533533
end.
534534
```
@@ -543,8 +543,9 @@ var
543543
begin
544544
if ChooseOption.IsOpen() then
545545
begin
546-
if (Self.UpText <> []) and ChooseOption.Find(Self.UpText) then
547-
Exit(True);
546+
if MainScreen.Bounds.Contains(Mouse.Position) then
547+
if (Self.UpText <> []) and ChooseOption.Find(Self.UpText) then
548+
Exit(True);
548549
ChooseOption.Close();
549550
end;
550551

@@ -599,7 +600,7 @@ var
599600
npc: TRSEntity;
600601
begin
601602
Map.Setup([Chunk(Box(40,49,41,48), 0)]);
602-
npc := TRSEntity.Create(Map.Walker, [1,1,7], 8, [[10432, 37966]], ['Dominic Onion'], [ERSMinimapDot.NPC]);
603+
npc := TRSEntity.Create(Map.Walker, [1,1,7], 8, [[10432, 37966]], ['Dominic Onion'], [ERSDot.NPC]);
603604
WriteLn npc.WalkHover();
604605
end.
605606
```
@@ -614,8 +615,9 @@ var
614615
begin
615616
if ChooseOption.IsOpen() then
616617
begin
617-
if (Self.UpText <> []) and ChooseOption.Find(Self.UpText) then
618-
Exit(True);
618+
if MainScreen.Bounds.Contains(Mouse.Position) then
619+
if (Self.UpText <> []) and ChooseOption.Find(Self.UpText) then
620+
Exit(True);
619621
ChooseOption.Close();
620622
end;
621623

@@ -684,7 +686,7 @@ var
684686
npc: TRSEntity;
685687
begin
686688
Map.Setup([Chunk(Box(40,49,41,48), 0)]);
687-
npc := TRSEntity.Create(Map.Walker, [1,1,7], 8, [[10432, 37966]], ['Dominic Onion'], [ERSMinimapDot.NPC]);
689+
npc := TRSEntity.Create(Map.Walker, [1,1,7], 8, [[10432, 37966]], ['Dominic Onion'], [ERSDot.NPC]);
688690
WriteLn npc.Click();
689691
end.
690692
```
@@ -709,7 +711,7 @@ var
709711
npc: TRSEntity;
710712
begin
711713
Map.Setup([Chunk(Box(40,49,41,48), 0)]);
712-
npc := TRSEntity.Create(Map.Walker, [1,1,7], 8, [[10432, 37966]], ['Dominic Onion'], [ERSMinimapDot.NPC]);
714+
npc := TRSEntity.Create(Map.Walker, [1,1,7], 8, [[10432, 37966]], ['Dominic Onion'], [ERSDot.NPC]);
713715
WriteLn npc.Interact(['Dream']);
714716
end.
715717
*)
@@ -733,7 +735,7 @@ var
733735
npc: TRSEntity;
734736
begin
735737
Map.Setup([Chunk(Box(40,49,41,48), 0)]);
736-
npc := TRSEntity.Create(Map.Walker, [1,1,7], 8, [[10432, 37966]], ['Dominic Onion'], [ERSMinimapDot.NPC]);
738+
npc := TRSEntity.Create(Map.Walker, [1,1,7], 8, [[10432, 37966]], ['Dominic Onion'], [ERSDot.NPC]);
737739
WriteLn npc.WalkClick();
738740
end.
739741
```
@@ -763,7 +765,7 @@ var
763765
npc: TRSEntity;
764766
begin
765767
Map.Setup([Chunk(Box(40,49,41,48), 0)]);
766-
npc := TRSEntity.Create(Map.Walker, [1,1,7], 8, [[10432, 37966]], ['Dominic Onion'], [ERSMinimapDot.NPC]);
768+
npc := TRSEntity.Create(Map.Walker, [1,1,7], 8, [[10432, 37966]], ['Dominic Onion'], [ERSDot.NPC]);
767769
WriteLn npc.WalkInteract(['Dream']);
768770
end.
769771
```

0 commit comments

Comments
 (0)