# Minimap Methods to interact with the minimap interface: ```{figure} ../../images/minimap.png ``` - - - ## ERSMinimapDots ```pascal ERSMinimapDot = enum(PLAYER, NPC, ITEM); ``` Enum representing the available minimap dots. - - - ## ERSMinimapOrb ```pascal ERSMinimapOrb = enum(HITPOINTS, PRAYER, ENERGY, SPECIAL); ``` Enum representing the 4 available minimap orbs. ```{figure} ../../images/mmorbs.png ``` - - - ## TRSMinimap Main record used to interact with the {ref}`Minimap`. - - - ## Minimap.SetupInterface ```pascal procedure TRSMinimap.SetupInterface(); ``` Internal method used to setup the {ref}`TRSMinimap` coordinates. This is automatically called for you on the {ref}`Minimap variable`. - - - ## Minimap.Contains ```pascal function TRSMinimap.Contains(pt: TPoint): Boolean; ``` Returns True/False if a point `pt` is on the minimap. Example: ```pascal WriteLn Minimap.Contains([100,100]); ``` - - - ## Minimap.Filter ```pascal function TRSMinimap.Filter(tpa: TPointArray): TPointArray; ``` Returns a TPA of the points from `tpa` that are within the minimap. Example: ```pascal tpa := TPointArray.CreateFromBox(Minimap.Bounds); ShowOnTarget(Minimap.Filter(tpa)); ``` - - - ## Minimap.RandomPoint ```pascal function TRSMinimap.RandomPoint(pt: TPoint; randomness: Integer): TPoint; ``` Generates a random point on the minimap based on the point `pt` passed. The distance of this random point will be within `randomness` amount of distance from `pt`. Example: ```pascal while True do ShowOnTarget(Minimap.RandomPoint(Minimap.Center, 30)); ``` - - - ## Minimap.Compass The minimap compass refers to the small compass on the top left corner of the minimap: ```{figure} ../../images/compass.png ``` The following properties are used to read and set the compass angle as both radians and degrees as needed. - - - ### Minimap.CompassRadians ```pascal property TRSMinimap.CompassRadians: Single; property TRSMinimap.CompassRadians(radians: Single): Boolean; property TRSMinimap.CompassRadians(minRadians, maxRadians: Single): Boolean; ``` Returns or sets the minimap compass angle as radians. The accuracy can be controlled through the `Minimap.Compass.Accuracy` variable and it's value should be in radians. It's default is aproximately 5º (`0.03*PI`). Credits: [slacky](https://slacky.one/) Example: ```pascal WriteLn Minimap.CompassRadians; WriteLn Minimap.CompassRadians := PI; WriteLn Minimap.CompassRadians; ``` - - - ### Minimap.CompassDegrees ```pascal property TRSMinimap.CompassDegrees: Single; property TRSMinimap.CompassDegrees(degrees: Single): Boolean; property TRSMinimap.CompassDegrees(minDegrees, maxDegrees: Single): Boolean; ``` Returns or sets the minimap compass angle as degrees. The accuracy can be controlled through the `Minimap.Compass.Accuracy` variable and it's value should be in radians. It's default is aproximately 5º (`0.03*PI`). Example: ```pascal WriteLn Minimap.CompassDegrees; WriteLn Minimap.CompassDegrees := 180; WriteLn Minimap.CompassDegrees; ``` If you are not sure what the compass refers to, check the image at the end of {ref}`Minimap.CompassRadians`. - - - ## Minimap.GetLevel ```pascal function TRSMinimap.GetLevel(orb: ERSMinimapOrb): Integer; ``` Returns the level of the specified `orb`. Example: ```pascal WriteLn Minimap.GetLevel(ERSMinimapOrb.PRAYER); ``` - - - ## Minimap.UnderLevel ```pascal function TRSMinimap.UnderLevel(orb: ERSMinimapOrb; level: Integer): Boolean; ``` Returns true if the level of the specified `orb` is below the specified `level` threshold. Example: ```pascal WriteLn Minimap.UnderLevel(ERSMinimapOrb.PRAYER, 50); ``` - - - ## Minimap.OverLevel ```pascal function TRSMinimap.OverLevel(orb: ERSMinimapOrb; level: Integer): Boolean; ``` Returns true if the level of the specified `orb` is over the specified `level` threshold. Example: ```pascal WriteLn Minimap.OverLevel(ERSMinimapOrb.PRAYER, 50); ``` - - - ## Minimap.GetRunEnergy ```pascal function TRSMinimap.GetRunEnergy(): Integer; ``` Returns the remaining run energy. Example: ```pascal WriteLn Minimap.GetRunEnergy(); ``` - - - ## Minimap.GetHPLevel ```pascal function TRSMinimap.GetHPLevel(): Integer; ``` Returns the remaining hitpoints. Example: ```pascal WriteLn Minimap.GetHPLevel(); ``` - - - ## Minimap.GetPrayerLevel ```pascal function TRSMinimap.GetPrayerLevel(): Integer; ``` Returns the remaining prayer points. Example: ```pascal WriteLn Minimap.GetPrayerLevel(); ``` - - - ## Minimap.GetSpecLevel ```pascal function TRSMinimap.GetSpecLevel(): Integer; ``` Returns the remaining special attack level. Example: ```pascal WriteLn Minimap.GetSpecLevel(); ``` - - - ## Minimap Orbs Statuses and States The following are methods to interact and read information from the {ref}`Minimap` {ref}`ERSMinimapOrb` orbs. - - - ### Minimap Status Methods to retrieve {ref}`Minimap` {ref}`ERSMinimapOrb` orbs statuses. - - - #### Minimap.HasPoison ```pascal function TRSMinimap.HasPoison(): Boolean; ``` Returns whether the `ERSMinimapOrb.HITPOINTS` has the poison status. Example: ```pascal WriteLn Minimap.HasPoison(); ``` - - - #### Minimap.HasVenom ```pascal function TRSMinimap.HasVenom(): Boolean; ``` Returns whether the `ERSMinimapOrb.HITPOINTS` has the venom status. Example: ```pascal WriteLn Minimap.HasVenom(); ``` - - - #### Minimap.HasStamina ```pascal function TRSMinimap.HasStamina(): Boolean; ``` Returns whether the `ERSMinimapOrb.ENERGY` has the stamina status. Example: ```pascal WriteLn Minimap.HasStamina(); ``` - - - #### Minimap.HasSpecial ```pascal function TRSMinimap.HasSpecial(): Boolean; ``` Returns whether the `ERSMinimapOrb.SPECIAL` has the special status, in other words, whether the current weapon is a special attack weapon or not. Example: ```pascal WriteLn Minimap.HasSpecial(); ``` - - - ### Minimap States Methods to retrieve {ref}`Minimap` {ref}`ERSMinimapOrb` orbs states. - - - #### Minimap.PrayerEnabled ```pascal function TRSMinimap.PrayerEnabled(): Boolean; ``` Returns whether the `ERSMinimapOrb.PRAYER` is enabled or not. Example: ```pascal WriteLn Minimap.PrayerEnabled(); ``` - - - #### Minimap.EnergyEnabled ```pascal function TRSMinimap.EnergyEnabled(): Boolean; ``` Returns whether the `ERSMinimapOrb.ENERGY` is enabled or not. Example: ```pascal WriteLn Minimap.EnergyEnabled(); ``` - - - #### Minimap.SpecialEnabled ```pascal function TRSMinimap.SpecialEnabled(): Boolean; ``` Returns whether the `ERSMinimapOrb.SPECIAL` is enabled or not. Example: ```pascal WriteLn Minimap.SpecialEnabled(); ``` - - - ## Minimap.GetPercent ```pascal function TRSMinimap.GetPercent(orb: ERSMinimapOrb): Integer; ``` Returns the percent remaining of the specified `orb`. Example: ```pascal WriteLn Minimap.GetPercent(ERSMinimapOrb.HITPOINTS); ``` - - - ## Minimap.GetHPPercent ```pascal function TRSMinimap.GetHPPercent(): Integer; ``` Returns the percent remaining of hp. Example: ```pascal WriteLn Minimap.GetHPPercent(); ``` - - - ## Minimap.GetPrayerPercent ```pascal function TRSMinimap.GetHPPercent(): Integer; ``` Returns the percent remaining of prayer. Example: ```pascal WriteLn Minimap.GetPrayerPercent(); ``` - - - ## Minimap.Toggle ```pascal function TRSMinimap.Toggle(orb: ERSMinimapOrb): Boolean; ``` Toggles a minimap orb. All orbs can be toggled except `ERSMinimapOrb.HITPOINTS`. Example: ```pascal if not Minimap.PrayerEnabled() then Minimap.Toggle(ERSMinimapOrb.PRAYER); ``` - - - ## Minimap.EnablePrayer ```pascal function TRSMinimap.EnablePrayer(): Boolean; ``` Enable the quick prayer orb. - - - ## Minimap.DisablePrayer ```pascal function TRSMinimap.DisablePrayer(): Boolean; ``` Disable the quick prayer orb. - - - ## Minimap.CurePoison ```pascal function TRSMinimap.CurePoison(): Boolean; ``` Clicks the health orb. This cures poison assuming you have potions for it in your {ref}`Inventory`. - - - ## Minimap.CureVenom ```pascal function TRSMinimap.CureVenom(): Boolean; ``` Clicks the health orb. This cures venom assuming you have potions for it in your {ref}`Inventory`. - - - ## Minimap.EnableEnergy ```pascal function TRSMinimap.EnableEnergy(): Boolean; ``` Enable the energy orb. - - - ## Minimap.DisableEnergy ```pascal function TRSMinimap.DisableEnergy(): Boolean; ``` Disable the energy orb. - - - ## Minimap.EnableSpecial ```pascal function TRSMinimap.EnableSpecial(level: Integer): Boolean; ``` Enabled the special attack orb. - - - ## Minimap.DisableSpecial ```pascal function TRSMinimap.DisableSpecial(): Boolean; ``` Disable the special attack orb. - - - ## Minimap.FindFlag ```pascal function TRSMinimap.FindFlag(out pt: TPoint): Boolean; ``` Returns True/False if the minimap walking flag is visible on the minimap. `pt` will return the coordinate where the flag was found. Example: ```pascal if Minimap.FindFlag(flagPt) then ShowOnTarget(TCircle.Create(flagPt.X, flagPt.Y, 6)); ``` - - - ## Minimap.HasFlag ```pascal function TRSMinimap.HasFlag(): Boolean; ``` Returns True/False if the minimap walking flag is visible on the minimap. Same as `Minimap.FindFlag()` but without the need for parameters. Example: ```pascal WriteLn Minimap.HasFlag(); ``` - - - ## Minimap.WaitFlag ```pascal function TRSMinimap.WaitFlag(time: Integer = 600; interval: Integer = -1): Boolean; ``` Returns True/False if the minimap walking flag becomes (or already is) visible within `time` milliseconds. Example: ```pascal pt := Minimap.RandomPoint(Minimap.Center, 30); Mouse.Click(pt, EMouseButton.LEFT); WriteLn Minimap.WaitFlag(2000); ``` - - - ## Minimap.CountColor ```pascal function TRSMinimap.CountColor(color: TColor; tolerance: Single = 0): Integer; function TRSMinimap.CountColor(color: TColorTolerance): Integer; overload; ``` Counts the specified `color` on the {ref}`Minimap`. Example: ```pascal WriteLn Minimap.CountColor($FFFFFF); ``` - - - ## Minimap.ColorPercent ```pascal function TRSMinimap.ColorPercent(color: TColor; tolerance: Single = 0): Single; function TRSMinimap.ColorPercent(color: TColorTolerance): Single; overload; ``` Counts the percentage of the specified `color` on the {ref}`Minimap`. Example: ```pascal WriteLn Minimap.ColorPercent($FFFFFF); ``` - - - ## Minimap.Normalize ```pascal function TRSMinimap.Normalize(pt: TPoint; angle: Single): TPoint; function TRSMinimap.NormalizeEx(vector: Vector2; angle: Single): Vector2; ``` Normalizes minimap coordinates to 0º. Basically, whatever `pt` or `vector` you pass into this, will be rotated to it's position on the minimap at 0º. `angle` should be in radians. Example: ```pascal pt := Minimap.RandomPoint(Minimap.Center, 30); angle := Minimap.CompassRadians; pt := Minimap.Normalize(pt, angle); ShowOnTarget(TCircle.Create(pt.X, pt.Y, 6)); ``` - - - ## Minimap.GetDots ```pascal function TRSMinimap._GetDots(img: TImage): TPointArray; function TRSMinimap.GetDots(dot: ERSMinimapDot; bounds: TBox): TPointArray; function TRSMinimap.GetDots(dot: ERSMinimapDot): TPointArray; overload; function TRSMinimap.GetDots(dots: ERSMinimapDots; bounds: TBox): TRSMinimapDotArray; overload; function TRSMinimap.GetDots(dots: ERSMinimapDots = [ERSMinimapDot.PLAYER, ERSMinimapDot.NPC, ERSMinimapDot.ITEM]): TRSMinimapDotArray; overload; ``` Returns minimap dots found. You can specify which dots you want to look for in `dot` or `dots`. You can also optionalyl specify `bounds` to returns minimap dots from just a region of the minimap. For example, this is how you can find NPC dots and debug them: ```pascal {$I WaspLib/osrs.simba} var pt: TPoint; boxes: TBoxArray; begin for pt in Minimap.GetDots(ERSMinimapDot.NPC) do boxes += TBox.Create(pt, 3, 3); ShowOnTarget(boxes); end. ``` Your result should look something like this on the minimap: ```{figure} ../../images/npcdots.png ``` - - - ## Minimap.CleanImage ```pascal function TRSMinimap.CleanImage(img: TImage; radius: Integer): TImage; ``` Cleans a TImage of the {ref}`Minimap` you pass into it. "Clean" means that minimap dots, the running flag and a few other things are removed and the colors around it will be blended in. The image i Example: ```pascal {$I WaspLib/osrs.simba} var before, after, combined: TImage; begin before := Target.GetImage(Minimap.Bounds); after := Minimap.CleanImage(before.Copy(), 65); combined := new TImage(before.Width*2, before.Height); combined.DrawImage(before, [0,0]); combined.DrawImage(after, [before.Width+1, 0]); combined.Show(); end. ``` ```{figure} ../../images/mmclean.png ``` - - - ## Minimap.GetCleanImage ```pascal function TRSMinimap.GetCleanImage(angle: Single = $FFFF; radius: Integer = -1): TImage; ``` Returns a clean `TImage` of the {ref}`Minimap`. Read {ref}`Minimap.CleanImage` for more information. Unlike {ref}`Minimap.CleanImage`, the `TImage` returned is rotated to 0º as you can see in the following example: ```pascal {$I WaspLib/osrs.simba} var img: TImage; begin while True do begin img := Minimap.GetCleanImage(); img.Show(); end; end. ``` ```{figure} ../../images/mmcleaned.gif ``` - - - ## Minimap.ScaleMinimap ```pascal function TRSMinimap.ScaleMinimap(img: TImage; scaling: Integer; radius: Integer = -1): TImage; ``` Scales down a minimap TImage passed in the `img` parameter. Example: ```pascal {$I WaspLib/osrs.simba} var img, downscaled: TImage; begin img := Minimap.GetCleanImage(); downscaled := Minimap.ScaleMinimap(img, 4); downscaled.Show(); end. ``` And this should be the result you see: ```{figure} ../../images/mmdownscale.png ``` As you can see, it's pretty small, if we zoom it in 800% it should look something like this: ```{figure} ../../images/mmdownscale2.png ``` - - - ## Minimap.IsPlayerMoving ```pascal function TRSMinimap.IsPlayerMoving(minShift: Integer = 500): Boolean; ``` Returns whether the player is moving or not according to the specified minimum pixel shift. Example: ```pascal WriteLn Minimap.IsPlayerMoving(); ``` - - - ## Minimap.WaitMoving ```pascal procedure TRSMinimap.WaitMoving(time: Integer = 20000; minShift: Integer = 500); ``` To put it simply, waits `time` milliseconds for {ref}`Minimap.IsPlayerMoving` to return false with the specified `minShift`. Example: ```pascal WriteLn Minimap.WaitMoving(); ``` - - - ## Minimap variable Global {ref}`TRSMinimap` variable.