Skip to content

Commit

Permalink
POH detection functionality #patch
Browse files Browse the repository at this point in the history
  • Loading branch information
Torwent committed Aug 31, 2021
1 parent 1002a74 commit e4eba1c
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 1 deletion.
19 changes: 19 additions & 0 deletions osr/interface/mainscreen.simba
Original file line number Diff line number Diff line change
Expand Up @@ -323,3 +323,22 @@ begin
end;
Result := (Round(SRL.CountColor(CTS0(11448498, 0), B) / SRL.CountColor(CTS0(4013888, 0), B)) >= 4);
end;

(*
MainScreen.LoadingPOH
~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. pascal:: function TRSMainScreen.LoadingPOH: Boolean;

Returns true if we are loading a poh.

Example
-------

Writeln MainScreen.LoadingPOH;
*)
function TRSMainScreen.LoadingPOH: Boolean;
begin
Result := (SRL.CountColor(CTS0(13127, 0), Self.Bounds) = 892) and
(SRL.CountColor(CTS0(8247, 0), Self.Bounds) = 900);
end;

98 changes: 97 additions & 1 deletion osr/interface/minimap.simba
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Minimap
Methods to handle Minimap. Extends SRL's Minimap.
*)


{$DEFINE WL_MINIMAP_INCLUDED}
{$IFNDEF WL_OSR}
{$I WaspLib/osr.simba}
Expand Down Expand Up @@ -62,22 +61,71 @@ begin
Result := OCR.RecognizeNumber([Orb.X-35, Orb.Y-1, Orb.X-15, Orb.Y+9], TOCRShadowRule.Create(), RS_FONT_PLAIN_11);
end;

(*
Minimap.GetSpecLevel
~~~~~~~~~~~~~~~~~~~~~~
.. pascal:: procedure TRSMinimap.GetSpecLevel;

**Minimap.GetSpecLevel** is used to retrieve the special attack level from the minimap orb.

Example
-------

Writeln Minimap.GetSpecLevel;
*)
function TRSMinimap.GetSpecLevel: Int32;
begin
Result := Self.GetOrbLevel(Self.GetSpecAttackCircle);
end;

(*
Minimap.IsSpecEnabled
~~~~~~~~~~~~~~~~~~~~~~
.. pascal:: procedure TRSMinimap.IsSpecEnabled;

**Minimap.IsSpecEnabled** returns true if the special attack is enabled.

Example
-------

Writeln Minimap.IsSpecEnabled;
*)
function TRSMinimap.IsSpecEnabled: Boolean;
begin
Result := SRL.CountColor(CTS2(8682326, 16, 0.03, 1.15), Self.GetSpecAttackCircle.Bounds) > 1;
end;

(*
Minimap.IsSpecWeapon
~~~~~~~~~~~~~~~~~~~~~~
.. pascal:: procedure TRSMinimap.IsSpecWeapon;

**Minimap.IsSpecWeapon** returns true if the current weapon has a special attack.
Returns false if the special attack level is at 0 or if the weapon doesn't have a special attack.

Example
-------

Writeln Minimap.IsSpecWeapon;
*)
function TRSMinimap.IsSpecWeapon: Boolean;
begin
Result := ((SRL.CountColor(CTS2(8480786, 19, 0.05, 1.36), Self.GetSpecAttackCircle.Bounds) > 0) or
Self.IsSpecEnabled);
end;

(*
Minimap.EnableSpec
~~~~~~~~~~~~~~~~~~~~~~
.. pascal:: procedure TRSMinimap.EnableSpec(MinSpec: Int32): Boolean;

**Minimap.EnableSpec** attempts to enable the special attack if we have at leas **MinSpec** special attack level.

Example
-------

Minimap.EnableSpec(25);
*)
function TRSMinimap.EnableSpec(MinSpec: Int32): Boolean;
var
T: UInt64;
Expand All @@ -101,6 +149,18 @@ begin
end;
end;

(*
Minimap.DisableSpec
~~~~~~~~~~~~~~~~~~~~~~
.. pascal:: procedure TRSMinimap.DisableSpec;

**Minimap.DisableSpec** attempts to disable the special attack.

Example
-------

Minimap.DisableSpec;
*)
function TRSMinimap.DisableSpec: Boolean;
var
T: UInt64;
Expand All @@ -122,13 +182,49 @@ begin
end;
end;

(*
Minimap.HasStamina
~~~~~~~~~~~~~~~~~~~~~~
.. pascal:: procedure TRSMinimap.HasStamina;

**Minimap.HasStamina** returns true if we are stamina boosted.

Example
-------

WriteLn Minimap.HasStamina;
*)
function TRSMinimap.HasStamina: Boolean;
begin
Result := SRL.CountColor(CTS0(2709951, 38), Self.GetRunCircle.Bounds) > 0;
end;

(*
Minimap.InPOH
~~~~~~~~~~~~~~~~~~~~~~
.. pascal:: procedure TRSMinimap.InPOH;

**Minimap.InPOH** returns true if we are in a POH.
This might give false positives if you are upstairs or in a place with few colors on the minimap.
It might also give false negatives if the POH is crowded.

Example
-------

WriteLn Minimap.InPOH;
*)
function TRSMinimap.InPOH: Boolean;
var
TPA: TPointArray;
ColorAmount: Int32;
begin
TPA := Self.GetPolygon.Connect;
TPA.Fill;

ColorAmount := Length(GetColors(TPA, True));
Writeln ColorAmount;
Result := (ColorAmount > 3) and (ColorAmount < 40); //I'm not sure if 50 is too generous.
end;



Expand Down
2 changes: 2 additions & 0 deletions utils.simba
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ var
{$IFNDEF WL_GUIUTILS_INCLUDED} {$I utils/guiutils.simba}
{$IFNDEF WL_SCRIPTCONFIG_INCLUDED} {$I utils/scriptconfig.simba}
{$IFNDEF WL_DRAWING_INCLUDED} {$I utils/drawing.simba}
{$IFNDEF WL_COLOR_INCLUDED} {$I utils/color.simba}

{$ELSE}{$ENDIF}
{$ELSE}{$ENDIF}
Expand All @@ -38,3 +39,4 @@ var
{$ELSE}{$ENDIF}
{$ELSE}{$ENDIF}
{$ELSE}{$ENDIF}
{$ELSE}{$ENDIF}
6 changes: 6 additions & 0 deletions utils/color.simba
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{$DEFINE WL_COLOR_INCLUDED}
{$IFNDEF WL_UTILS}
{$I WaspLib/utils.simba}
{$ENDIF}

//placeholder

0 comments on commit e4eba1c

Please sign in to comment.