From e4eba1c57802bb58e1209181d9fd3f6576e26abd Mon Sep 17 00:00:00 2001 From: Torwent Date: Tue, 31 Aug 2021 13:18:04 +0200 Subject: [PATCH] POH detection functionality #patch --- osr/interface/mainscreen.simba | 19 +++++++ osr/interface/minimap.simba | 98 +++++++++++++++++++++++++++++++++- utils.simba | 2 + utils/color.simba | 6 +++ 4 files changed, 124 insertions(+), 1 deletion(-) create mode 100644 utils/color.simba diff --git a/osr/interface/mainscreen.simba b/osr/interface/mainscreen.simba index fa617dad..b257320b 100644 --- a/osr/interface/mainscreen.simba +++ b/osr/interface/mainscreen.simba @@ -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; + diff --git a/osr/interface/minimap.simba b/osr/interface/minimap.simba index 288fb00e..8d67a262 100644 --- a/osr/interface/minimap.simba +++ b/osr/interface/minimap.simba @@ -4,7 +4,6 @@ Minimap Methods to handle Minimap. Extends SRL's Minimap. *) - {$DEFINE WL_MINIMAP_INCLUDED} {$IFNDEF WL_OSR} {$I WaspLib/osr.simba} @@ -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; @@ -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; @@ -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; diff --git a/utils.simba b/utils.simba index 3d0b5252..87e12fd7 100644 --- a/utils.simba +++ b/utils.simba @@ -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} @@ -38,3 +39,4 @@ var {$ELSE}{$ENDIF} {$ELSE}{$ENDIF} {$ELSE}{$ENDIF} +{$ELSE}{$ENDIF} diff --git a/utils/color.simba b/utils/color.simba new file mode 100644 index 00000000..82a585da --- /dev/null +++ b/utils/color.simba @@ -0,0 +1,6 @@ +{$DEFINE WL_COLOR_INCLUDED} +{$IFNDEF WL_UTILS} + {$I WaspLib/utils.simba} +{$ENDIF} + +//placeholder