Skip to content

Commit 99f0026

Browse files
committed
fix(TRSMinimap): rework orbs
- renamed several orb methods to be consistent - checked all colors and fixed the ones that were bad - also updated the bounds where the colors are checked for several of the methods so they can have a bigger tolerance and be more reliable - poison and venom methods kind of worked interchangeable before but not anymore
1 parent c85ccec commit 99f0026

File tree

1 file changed

+160
-37
lines changed

1 file changed

+160
-37
lines changed

osrs/interfaces/minimap.simba

Lines changed: 160 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -455,58 +455,169 @@ end;
455455

456456

457457
(*
458-
## Minimap Orb Status
458+
## Minimap Orbs Statuses and States
459+
The following are methods to interact and read information from the
460+
{ref}`Minimap` {ref}`ERSMinimapOrb` orbs.
461+
*)
462+
463+
(*
464+
### Minimap Status
465+
Methods to retrieve {ref}`Minimap` {ref}`ERSMinimapOrb` orbs statuses.
466+
*)
467+
468+
(*
469+
#### Minimap.HasPoison
459470
```pascal
460-
function TRSMinimap.Poisoned(): Boolean;
461-
function TRSMinimap.Envenomed(): Boolean;
462-
function TRSMinimap.EnergyEnabled(): Boolean;
463-
function TRSMinimap.HasStamina(): Boolean;
464-
function TRSMinimap.PrayerEnabled(): Boolean;
465-
function TRSMinimap.SpecialEnabled(): Boolean;
466-
function TRSMinimap.HasSpecialWeapon(): Boolean;
471+
function TRSMinimap.HasPoison(): Boolean;
467472
```
468-
Returns a status from a minimap orb.
473+
Returns whether the `ERSMinimapOrb.HITPOINTS` has the poison status.
469474

470475
Example:
471476
```pascal
472-
WriteLn Minimap.Poisoned();
477+
WriteLn Minimap.HasPoison();
473478
```
474479
*)
475-
function TRSMinimap.Poisoned(): Boolean;
480+
function TRSMinimap.HasPoison(): Boolean;
481+
var
482+
b: TBox;
476483
begin
477-
Result := Target.HasColor(16391, 3, 1, Self.Orbs[ERSMinimapOrb.HITPOINTS].Circle.Bounds);
484+
with Self.Orbs[ERSMinimapOrb.HITPOINTS].Circle.Bounds do
485+
b := [X1+3, Y2-4, X2-3, Y2+1];
486+
ShowOnTarget(b);
487+
Result := Target.HasColor($004007, 8, 1, b);
478488
end;
479489

480-
function TRSMinimap.Envenomed(): Boolean;
490+
(*
491+
#### Minimap.HasVenom
492+
```pascal
493+
function TRSMinimap.HasVenom(): Boolean;
494+
```
495+
Returns whether the `ERSMinimapOrb.HITPOINTS` has the venom status.
496+
497+
Example:
498+
```pascal
499+
WriteLn Minimap.HasVenom();
500+
```
501+
*)
502+
function TRSMinimap.HasVenom(): Boolean;
503+
var
504+
b: TBox;
481505
begin
482-
Result := Target.HasColor(ColorTolerance($283818, 0.637, EColorSpace.HSL, [1.885, 0.891, 0.226]), 1, Self.Orbs[ERSMinimapOrb.HITPOINTS].Circle.Bounds);
506+
with Self.Orbs[ERSMinimapOrb.HITPOINTS].Circle.Bounds do
507+
b := [X1+3, Y2-4, X2-3, Y2+1];
508+
Result := Target.HasColor([$2D351B, 8.330, EColorSpace.HSV, [0.882, 1.148, 0.971]], 1, b);
483509
end;
484510

485-
function TRSMinimap.EnergyEnabled(): Boolean;
511+
(*
512+
#### Minimap.HasStamina
513+
```pascal
514+
function TRSMinimap.HasStamina(): Boolean;
515+
```
516+
Returns whether the `ERSMinimapOrb.ENERGY` has the stamina status.
517+
518+
Example:
519+
```pascal
520+
WriteLn Minimap.HasStamina();
521+
```
522+
*)
523+
function TRSMinimap.HasStamina(): Boolean;
524+
var
525+
b: TBox;
486526
begin
487-
Result := Target.HasColor(ColorTolerance($0E567F, 8.845, EColorSpace.HSV, [1.295, 1.247, 0.459]), 1, Self.Orbs[ERSMinimapOrb.ENERGY].Circle.Bounds);
527+
with Self.Orbs[ERSMinimapOrb.ENERGY].Circle.Center do
528+
b := TBox.Create([X,Y], 4, 4);
529+
Result := Target.HasColor([$2D61C1, 1.475, EColorSpace.HSV, [2.455, 0.300, 0.247]], 1, b);
488530
end;
489531

490-
function TRSMinimap.HasStamina(): Boolean;
532+
(*
533+
#### Minimap.HasSpecial
534+
```pascal
535+
function TRSMinimap.HasSpecial(): Boolean;
536+
```
537+
Returns whether the `ERSMinimapOrb.SPECIAL` has the special status, in other
538+
words, whether the current weapon is a special attack weapon or not.
539+
540+
Example:
541+
```pascal
542+
WriteLn Minimap.HasSpecial();
543+
```
544+
*)
545+
function TRSMinimap.HasSpecial(): Boolean;
546+
var
547+
b: TBox;
491548
begin
492-
Result := Target.HasColor(ColorTolerance($2D61C1, 1.475, EColorSpace.HSV, [2.455, 0.300, 0.247]), 1, Self.Orbs[ERSMinimapOrb.ENERGY].Circle.Bounds);
549+
with Self.Orbs[ERSMinimapOrb.SPECIAL].Circle.Bounds do
550+
b := [X1+3, Y2-4, X2-3, Y2];
551+
Result := Target.HasColor([$6A6330, 12.309, EColorSpace.HSV, [1.620, 0.532, 0.850]], 1, b);
493552
end;
494553

554+
555+
(*
556+
### Minimap States
557+
Methods to retrieve {ref}`Minimap` {ref}`ERSMinimapOrb` orbs states.
558+
*)
559+
560+
(*
561+
#### Minimap.PrayerEnabled
562+
```pascal
563+
function TRSMinimap.PrayerEnabled(): Boolean;
564+
```
565+
Returns whether the `ERSMinimapOrb.PRAYER` is enabled or not.
566+
567+
Example:
568+
```pascal
569+
WriteLn Minimap.PrayerEnabled();
570+
```
571+
*)
495572
function TRSMinimap.PrayerEnabled(): Boolean;
496573
begin
497-
Result := Target.HasColor(ColorTolerance($2188AB, 10.980, EColorSpace.HSV, [1.317, 1.076, 0.609]), 1, Self.Orbs[ERSMinimapOrb.PRAYER].Circle.Bounds);
574+
Result := Target.HasColor(ColorTolerance($2188AB, 10.980, EColorSpace.HSV, [1.317, 1.076, 0.609]), 8, Self.Orbs[ERSMinimapOrb.PRAYER].Circle.Bounds);
498575
end;
499576

500-
function TRSMinimap.SpecialEnabled(): Boolean;
577+
(*
578+
#### Minimap.EnergyEnabled
579+
```pascal
580+
function TRSMinimap.EnergyEnabled(): Boolean;
581+
```
582+
Returns whether the `ERSMinimapOrb.ENERGY` is enabled or not.
583+
584+
Example:
585+
```pascal
586+
WriteLn Minimap.EnergyEnabled();
587+
```
588+
*)
589+
function TRSMinimap.EnergyEnabled(): Boolean;
590+
var
591+
b: TBox;
501592
begin
502-
Result := Target.HasColor(ColorTolerance($999273, 1.308, EColorSpace.RGB, [0.122, 0.640, 2.240]), 1, Self.Orbs[ERSMinimapOrb.SPECIAL].Circle.Bounds);
593+
with Self.Orbs[ERSMinimapOrb.ENERGY].Circle.Bounds do
594+
b := [X1+3, Y2-3, X2-3, Y2];
595+
ShowOnTarget(b);
596+
Result := Target.HasColor([$2A6C8E, 9.954, EColorSpace.HSV, [1.771, 0.726, 0.505]], 8, b);
503597
end;
504598

505-
function TRSMinimap.HasSpecialWeapon(): Boolean;
599+
(*
600+
#### Minimap.SpecialEnabled
601+
```pascal
602+
function TRSMinimap.SpecialEnabled(): Boolean;
603+
```
604+
Returns whether the `ERSMinimapOrb.SPECIAL` is enabled or not.
605+
606+
Example:
607+
```pascal
608+
WriteLn Minimap.SpecialEnabled();
609+
```
610+
*)
611+
function TRSMinimap.SpecialEnabled(): Boolean;
612+
var
613+
b: TBox;
506614
begin
507-
Result := Target.HasColor(ColorTolerance($A68F56, 5.999, EColorSpace.RGB, [0.270, 1.494, 1.237]), 1, Self.Orbs[ERSMinimapOrb.SPECIAL].Bounds);
615+
with Self.Orbs[ERSMinimapOrb.SPECIAL].Circle.Bounds do
616+
b := [X1+3, Y2-4, X2-3, Y2];
617+
Result := Target.HasColor([$718B63, 8.414, EColorSpace.HSV, [0.258, 0.495, 2.249]], 8, b);
508618
end;
509619

620+
510621
(*
511622
## Minimap.GetPercent
512623
```pascal
@@ -528,8 +639,8 @@ begin
528639
ERSMinimapOrb.HITPOINTS:
529640
begin
530641
col := ColorTolerance($030575, 1.242, EColorSpace.RGB, [0.064, 1.068, 1.869]);
531-
if Self.Poisoned then col := ColorTolerance($02851C, 1.688, EColorSpace.LCH, [0.201, 0.166, 2.635]);
532-
if Self.Envenomed then col := ColorTolerance($27361A, 0.983, EColorSpace.LCH, [0.227, 0.346, 2.428]);
642+
if Self.HasPoison then col := ColorTolerance($02851C, 1.688, EColorSpace.LCH, [0.201, 0.166, 2.635]);
643+
if Self.HasVenom then col := ColorTolerance($27361A, 0.983, EColorSpace.LCH, [0.227, 0.346, 2.428]);
533644
end;
534645
ERSMinimapOrb.PRAYER:
535646
begin
@@ -569,7 +680,7 @@ begin
569680
ERSMinimapOrb.PRAYER: state := Self.PrayerEnabled();
570681
ERSMinimapOrb.ENERGY: state := Self.EnergyEnabled();
571682
ERSMinimapOrb.SPECIAL:
572-
if not Self.HasSpecialWeapon() then
683+
if not Self.HasSpecial() then
573684
Exit
574685
else
575686
state := Self.SpecialEnabled();
@@ -632,22 +743,34 @@ function TRSMinimap.CurePoison(): Boolean;
632743
```
633744
Clicks the health orb.
634745

635-
This cures poison and venom assuming you have potions for
636-
it in your {ref}`Inventory`.
746+
This cures poison assuming you have potions for it in your {ref}`Inventory`.
637747
*)
638748
function TRSMinimap.CurePoison(): Boolean;
639749
begin
640-
if Self.Envenomed() then
641-
begin
642-
Mouse.Click(Self.Orbs[ERSMinimapOrb.HITPOINTS].Circle, EMouseButton.LEFT, True);
643-
Exit(SleepUntil(not Self.Envenomed(), 200, 2*TICK));
644-
end;
750+
if not Self.HasPoison() then
751+
Exit(True);
752+
753+
Mouse.Click(Self.Orbs[ERSMinimapOrb.HITPOINTS].Circle, EMouseButton.LEFT, True);
754+
Result := SleepUntil(not Self.HasPoison(), 200, 2*TICK);
755+
end;
756+
757+
(*
758+
## Minimap.CureVenom
759+
```pascal
760+
function TRSMinimap.CureVenom(): Boolean;
761+
```
762+
Clicks the health orb.
645763

646-
if not Self.Poisoned() then
764+
This cures venom assuming you have potions for
765+
it in your {ref}`Inventory`.
766+
*)
767+
function TRSMinimap.CureVenom(): Boolean;
768+
begin
769+
if not Self.HasVenom() then
647770
Exit(True);
648771

649772
Mouse.Click(Self.Orbs[ERSMinimapOrb.HITPOINTS].Circle, EMouseButton.LEFT, True);
650-
Result := SleepUntil(not Self.Poisoned(), 200, 2*TICK);
773+
Result := SleepUntil(not Self.HasVenom(), 200, 2*TICK);
651774
end;
652775

653776

@@ -703,7 +826,7 @@ begin
703826
if Self.SpecialEnabled() then
704827
Exit(True);
705828

706-
if Self.HasSpecialWeapon() and (Self.GetLevel(ERSMinimapOrb.SPECIAL) >= level) then
829+
if Self.HasSpecial() and (Self.GetLevel(ERSMinimapOrb.SPECIAL) >= level) then
707830
begin
708831
Mouse.Click(Self.Orbs[ERSMinimapOrb.SPECIAL].Circle, EMouseButton.LEFT, True);
709832
Result := SleepUntil(Self.SpecialEnabled(), 200, 2*TICK);
@@ -719,7 +842,7 @@ Disable the special attack orb.
719842
*)
720843
function TRSMinimap.DisableSpecial(): Boolean;
721844
begin
722-
if not Self.SpecialEnabled() or Self.HasSpecialWeapon() then
845+
if not Self.SpecialEnabled() or Self.HasSpecial() then
723846
Exit(True);
724847

725848
Mouse.Click(Self.Orbs[ERSMinimapOrb.SPECIAL].Circle, EMouseButton.LEFT, True);

0 commit comments

Comments
 (0)