From 1e2ad5323718f9d9e40cfe4ebd89db6ea5c50382 Mon Sep 17 00:00:00 2001 From: Torwent Date: Mon, 5 Feb 2024 11:48:35 +0100 Subject: [PATCH] feat(poh): finished. read notes The POH Handler is finished. At least the original intention I had for it which was an accurate way of knowing a player position on anyone's POH no matter their layout. Actual walking will be done at a later time, but most people could add it in now by looking at how walker does it. It was also not my original intention for the first release to have it, but it does include some very basic interaction with some very few "Room Objects". This only includes the fairy ring, the jewellery box and the pool. I only tested this on a max house so the `Finders` might need adjustments. Also, while only this 3 objects are included as a proof of concept, it's not very hard to add other stuff, like portals, nexus, etc. Do keep in mind though, the syntax for this is subject to change in the future. Things that changed since the last updates: - All map and "cached" rooms things were moved into their own `TPOHMap` record. This is a helper record and you likely will never have to interact with it directly nor none of it's methods. - A lot of methods were renamed to make more sense - The file was renamed from pohhandler.simba to poh.simba - The whole file has been documented thoroughly and includes usage examples of the several things the POH Handler can do. --- optional.simba | 2 +- optional/handlers/houseobjects.simba | 73 ++ .../handlers/{pohhandler.simba => poh.simba} | 715 ++++++++++++------ osr/mm2ms.simba | 3 +- 4 files changed, 563 insertions(+), 230 deletions(-) rename optional/handlers/{pohhandler.simba => poh.simba} (51%) diff --git a/optional.simba b/optional.simba index 0efddc3f..acfb3694 100644 --- a/optional.simba +++ b/optional.simba @@ -32,7 +32,7 @@ However, this is not really recommended. You should include only the files you r {$IFNDEF WL_LOOT_HANDLER_INCLUDED} {$I optional/handlers/loothandler.simba} {$IFNDEF WL_COMBAT_HANDLER_INCLUDED} {$I optional/handlers/combathandler.simba} {$IFNDEF WL_HOUSEOBJECTS_INCLUDED} {$I optional/handlers/houseobjects.simba} -{$IFNDEF WL_POH_HANDLER_INCLUDED} {$I optional/handlers/pohhandler.simba} +{$IFNDEF WL_POH_HANDLER_INCLUDED} {$I optional/handlers/poh.simba} {$IFNDEF SKUNK_TELEPORT_UTILS} {$I optional/handlers/teleports/rsteleportutils.simba} {$IFNDEF SKUNK_TELEPORTS} {$I optional/handlers/teleports/rsteleports.simba} {$IFNDEF SKUNK_UNIVERSAL_TRANSPORT} {$I optional/handlers/teleports/transport.simba} diff --git a/optional/handlers/houseobjects.simba b/optional/handlers/houseobjects.simba index 8830bb17..92f66aa3 100644 --- a/optional/handlers/houseobjects.simba +++ b/optional/handlers/houseobjects.simba @@ -1,11 +1,34 @@ +(* +# RoomObjects +*) + {$DEFINE WL_HOUSEOBJECTS_INCLUDED} {$IFNDEF WL_OSR} {$I WaspLib/osr.simba} {$ENDIF} type +(* +## ERSRoomObject +```pascal +ERSRoomObject = (POOL, FAIRY_TREE, JEWELLERY_BOX, PRAYER_ALTAR, MAGIC_ALTAR, LARDER, LECTERN, MYTH_CAPE, NEXUS, PORTAL); +``` +*) ERSRoomObject = (POOL, FAIRY_TREE, JEWELLERY_BOX, PRAYER_ALTAR, MAGIC_ALTAR, LARDER, LECTERN, MYTH_CAPE, NEXUS, PORTAL); +(* +## TRoomObject +```pascal + TRoomObject = record + Coordinates: TPointArray; + Shape: Vector3; + UpText: TStringArray; + Finder: TRSObjectFinder; + RoomOffset: TPoint; + end; +``` +Record used to store and interact information about POH room objects. +*) TRoomObject = record Coordinates: TPointArray; Shape: Vector3; @@ -14,6 +37,13 @@ type RoomOffset: TPoint; end; +(* +## TRoomObject.Init() +```pascal +procedure TRoomObject.Init(upText: TStringArray; shape: Vector3; roomOffset: TPoint); +``` +This method sets up some basic info about a {ref}`TRoomObject`. +*) procedure TRoomObject.Init(upText: TStringArray; shape: Vector3; roomOffset: TPoint); begin Self := []; @@ -25,6 +55,22 @@ begin Self.Finder.Grow := 4; end; +(* +## TRoomObject.Setup() +```pascal +procedure TRoomObject.Setup(obj: ERSRoomObject); overload; +``` +Basically the same as {ref}`TRoomObject.Init()` with some already known information. + +Example: +```pascal +var + obj: TRoomObject; +begin + obj.Setup(ERSRoomObject.POOL); +end; +``` +*) procedure TRoomObject.Setup(obj: ERSRoomObject); overload; begin case obj of @@ -48,12 +94,39 @@ begin end; end; +(* +## TRoomObject.AddCoordinates() +```pascal +procedure TRoomObject.AddCoordinates(coordinates: TPointArray); +``` +Adds `coordinates` to a {ref}`TRoomObject`. +Can be called multiple times to add more `coordinates`. + +Example: +```pascal +var + obj: TRoomObject; +begin + obj.Setup(ERSRoomObject.POOL); + obj.AddCoordinates([[50, 50]]); +end; +``` +*) procedure TRoomObject.AddCoordinates(coordinates: TPointArray); begin Self.Coordinates += coordinates; end; +(* +## TRoomObject.Interact +```pascal +function TRoomObject.Hover(mmPoints: TPointArray; radians: Double): Boolean; +function TRoomObject.Click(mmPoints: TPointArray; radians: Double): Boolean; +function TRoomObject.Select(options: TStringArray; mmPoints: TPointArray; radians: Double): Boolean; +``` +Interacts with a {ref}`TRoomObject`. The interaction type is self explanatory. +*) function TRoomObject.Hover(mmPoints: TPointArray; radians: Double): Boolean; var i: Int32; diff --git a/optional/handlers/pohhandler.simba b/optional/handlers/poh.simba similarity index 51% rename from optional/handlers/pohhandler.simba rename to optional/handlers/poh.simba index 7a4c2f27..1f799f32 100644 --- a/optional/handlers/pohhandler.simba +++ b/optional/handlers/poh.simba @@ -1,9 +1,9 @@ (* -# POHHandler +# POH The POH Handler is a handler responsible for making sense of a player's POH (Player Owned House) without knowing any info about it's setup in advance. -:::{note} +```{note} :class: dropdown The POH Handler is optional and has to be explicitly included. You can include it by either including all optional files which is not recommended: @@ -14,7 +14,7 @@ Or include just the POHHandler file which is the recommended way to include it: ```pascal {$I WaspLib/optional/handlers/poh.simba} ``` -::: +``` Several rooms in a POH are unique on the minimap, with windows and/or doors of several sizes and different places. By having this rooms saved in the following format: @@ -36,95 +36,116 @@ e.g., Nexus room, Combat Hall and Quest Hall are all identical. {$I WaspLib/optional/handlers/houseobjects.simba} {$ENDIF} -{$SCOPEDENUMS ON} + type +(* +## ERSHouseRoom +```pascal +ERSHouseRoom = ( + UNKNOWN, GARDEN, SUPERIOR_GARDEN, MENAGERIE_OPEN, MENAGERIE_CLOSED, + STUDY_PARLOUR, KITCHEN_BEDROOM, ACHIEVEMENT_GALLERY, QUEST_NEXUS, COMBAT, + COSTUME, ALTAR, PORTAL, WORKSHOP +); +``` +*) +{$SCOPEDENUMS ON} ERSHouseRoom = ( UNKNOWN, GARDEN, SUPERIOR_GARDEN, MENAGERIE_OPEN, MENAGERIE_CLOSED, STUDY_PARLOUR, KITCHEN_BEDROOM, ACHIEVEMENT_GALLERY, QUEST_NEXUS, COMBAT, COSTUME, ALTAR, PORTAL, WORKSHOP ); - - TRSPOHHandler = record +{$SCOPEDENUMS OFF} +(* +## TPOHMap +```pascal +type + TPOHMap = record AMOUNT, SIZE: Int32; - RoomsMap, Map: TMufasaBitmap; - RoomsBitmaps: array [ERSHouseRoom] of TMufasaBitmap; + Map: TMufasaBitmap; Rooms: array of array of ERSHouseRoom; - RoomObjects: array [ERSRoomObject] of TRoomObject; + RoomsMap: TMufasaBitmap; + ERoomBitmaps: array [ERSHouseRoom] of TMufasaBitmap; + GrassColor: Int32; + end; +``` +Helper record used by the {ref}`TRSPOHHandler`. +All `TPOHMap` methods are helper methods and you shouldn't have to call them for anything. +*) + TPOHMap = record + AMOUNT, SIZE: Int32; + Map: TMufasaBitmap; + Rooms: array of array of ERSHouseRoom; + RoomsMap: TMufasaBitmap; + ERoomBitmaps: array [ERSHouseRoom] of TMufasaBitmap; GrassColor: Int32; - Similarity: Double; end; -{$SCOPEDENUMS OFF} (* -## POH.Free() +## TPOHMap.Free() ```pascal -procedure TRSPOHHandler.Free(); +procedure TPOHMap.Free(); ``` Internal method automatically called for your on script termination. You do not have to call it yourself. *) -procedure TRSPOHHandler.Free(); +procedure TPOHMap.Free(); var room: ERSHouseRoom; begin Self.Map.Free(); Self.RoomsMap.Free(); for room := Low(ERSHouseRoom) to High(ERSHouseRoom) do - if Self.RoomsBitmaps[room] <> nil then - Self.RoomsBitmaps[room].Free(); + if Self.ERoomBitmaps[room] <> nil then + Self.ERoomBitmaps[room].Free(); end; (* -## POH.Init() +## TPOHMap.Init() ```pascal -procedure TRSPOHHandler.Init(); +procedure TPOHMap.Init(size, amount: Int32); ``` -Internal method automatically called for your on script startup along with SRL.Setup(). +Internal method automatically called for your on script startup along with POH.Init(). You do not have to call it yourself. *) -procedure TRSPOHHandler.Init(); +procedure TPOHMap.Init(size, amount: Int32); var i: Int32; - obj: ERSRoomObject; begin - Self.SIZE := 32; - Self.AMOUNT := 12; - Self.Similarity := 0.9999; + Self.SIZE := size; + Self.AMOUNT := amount; Self.Map.Init(); - Self.Map.SetSize(Self.SIZE * Self.AMOUNT, Self.SIZE * Self.AMOUNT); + Self.Map.SetSize(size * amount, size * amount); Self.RoomsMap.Init(); Self.RoomsMap.LoadFromFile(WALKER_DIR + 'poh.png'); - SetLength(Self.Rooms, Self.AMOUNT); - for i := 0 to High(Self.Rooms) do - SetLength(Self.Rooms[i], Self.AMOUNT); - AddOnTerminate(@Self.Free); - for obj := Low(ERSRoomObject) to High(ERSRoomObject) do - Self.RoomObjects[obj].Setup(obj); + SetLength(Self.Rooms, amount); + for i := 0 to High(Self.Rooms) do + SetLength(Self.Rooms[i], amount); end; (* -## POH.GetRoomBitmapBox() +## TPOHMap.GetRoomBitmapBox() ```pascal -function TRSPOHHandler.GetRoomBitmapBox(room: ERSHouseRoom): TBox; +function TPOHMap.GetRoomBitmapBox(room: ERSHouseRoom): TBox; ``` -Internal method used to get the box of the `ERSHouseRoom` you pass in. +Internal method used to get the box of the {ref}`ERSHouseRoom` you pass in. + This box is a box of the following image: -```{figure} ../../../osr/walker/poh.png -``` +![poh rooms](../../../osr/walker/poh.png) + Example: ```pascal {$I WaspLib/optional/handlers/poh.simba} begin - WriteLn POH.GetRoomBitmapBox(ERSHouseRoom.SUPERIOR_GARDEN); + WriteLn POH.Map.GetRoomBitmapBox(ERSHouseRoom.SUPERIOR_GARDEN); end; ``` *) -function TRSPOHHandler.GetRoomBitmapBox(room: ERSHouseRoom): TBox; +function TPOHMap.GetRoomBitmapBox(room: ERSHouseRoom): TBox; var i: Int32; begin @@ -133,57 +154,101 @@ begin end; (* -## POH.GetRoomBitmap() +## TPOHMap.GetRoomBitmap() ```pascal -function TRSPOHHandler.GetRoomBitmap(room: ERSHouseRoom; color: Int32 = -1): TMufasaBitmap; +function TPOHMap.GetRoomBitmap(room: ERSHouseRoom; color: Int32 = -1): TMufasaBitmap; ``` -Internal method used to retrieve a bitmap of the `ERSHouseRoom` you pass in. +Internal method used to retrieve a bitmap of the {ref}`ERSHouseRoom` you pass in. + Example: ```pascal {$I WaspLib/optional/handlers/poh.simba} var bmp: TMufasaBitmap; begin - bmp := POH.GetRoomBitmapBox(ERSHouseRoom.SUPERIOR_GARDEN); + bmp := POH.Map.GetRoomBitmap(ERSHouseRoom.SUPERIOR_GARDEN); bmp.Debug(); bmp.Free(); end; ``` *) -function TRSPOHHandler.GetRoomBitmap(room: ERSHouseRoom; color: Int32 = -1): TMufasaBitmap; +function TPOHMap.GetRoomBitmap(room: ERSHouseRoom; color: Int32 = -1): TMufasaBitmap; var b: TBox; begin - if Self.RoomsBitmaps[room] = nil then + if Self.ERoomBitmaps[room] = nil then begin b := Self.GetRoomBitmapBox(room); Result := Self.RoomsMap.Copy(b.X1, b.Y1, b.X2, b.Y2); - Self.RoomsBitmaps[room] := Result.Copy(); + Self.ERoomBitmaps[room] := Result.Copy(); end else - Result := Self.RoomsBitmaps[room].Copy(); + Result := Self.ERoomBitmaps[room].Copy(); if color <> -1 then Result.ReplaceColor($FFFFFF, color); end; +(* +## TPOHMap.RotateBitmap() +```pascal +function TPOHMap.RotateBitmap(bitmap: TMufasaBitmap; rotation: Int32): TMufasaBitmap; static; +``` +Rotates a bitmap by 90º increments a `rotation` number of times. +This was made specifically for room bitmaps, but you could use it for other stuff I guess. +It's also a static method and can be called directly from the type. + +Example: +```pascal +{$I WaspLib/optional/handlers/poh.simba} +var + bmp: TMufasaBitmap; +begin + bmp := POH.Map.GetRoomBitmap(ERSHouseRoom.MENAGERIE_OPEN); + bmp.Debug(); + Wait(2000); + TPOHMap.RotateBitmap(bmp, 1); + bmp.Debug(); + bmp.Free(); +end; +``` +*) +function TPOHMap.RotateBitmap(bitmap: TMufasaBitmap; rotation: Int32): TMufasaBitmap; static; +var + p: TPoint; +begin + if rotation = 0 then + Exit(bitmap.Copy()); + + bitmap.Pad(1); + Result.Init(); + bitmap.RotateBitmap(PI/2*rotation, Result); + + for p.X := 0 to 3 do + for p.Y := 0 to 3 do + if Result.GetPixel(p.X, p.Y) <> 0 then + Break(2); + + Result.Crop(p.X, p.Y, p.X + 31, p.Y + 31); +end; + (* -## POH.WriteRoom() +## TPOHMap.WriteRoom() ```pascal -procedure TRSPOHHandler.WriteRoom(room: ERSHouseRoom; index: TPoint); +procedure TPOHMap.WriteRoom(room: ERSHouseRoom; index: TPoint); ``` -Internal method used to write a room to `POH.Rooms` cache. -This uses an `TPoint` as a room `index` in a 2D array of `ERSHouseRoom`. +Internal method used to write a room to `TPOHMap.Rooms` cache. +This uses an `TPoint` as a room `index` in a 2D array of {ref}`ERSHouseRoom`. Unless you know what you are doing, you definitly should not use this for anything. Example: ```pascal -POH.WriteRoom(ERSHouseRoom.SUPERIOR_GARDEN, [3,3]); +POH.Map.WriteRoom(ERSHouseRoom.SUPERIOR_GARDEN, [3,3]); ``` *) -procedure TRSPOHHandler.WriteRoom(room: ERSHouseRoom; index: TPoint); +procedure TPOHMap.WriteRoom(room: ERSHouseRoom; index: TPoint); begin if not InRange(index.X, 0, High(Self.Rooms)) then TerminateScript('index.X is not between 0 and ' + ToStr(High(Self.Rooms)) + ', got ' + ToStr(index)); @@ -194,21 +259,21 @@ begin end; (* -## POH.ReadRoom() +## TPOHMap.ReadRoom() ```pascal -function TRSPOHHandler.ReadRoom(index: TPoint): ERSHouseRoom; +function TPOHMap.ReadRoom(index: TPoint): ERSHouseRoom; ``` -Internal method used to read a cached room in `POH.Rooms`. +Internal method used to read a cached room in `TPOHMap.Rooms`. This uses an `TPoint` as a room `index`. Unless you know what you are doing, you don't need this, but there's no harm in using it. Example: ```pascal -WriteLn POH.ReadRoom([3,3]); +WriteLn POH.Map.ReadRoom([3,3]); ``` *) -function TRSPOHHandler.ReadRoom(index: TPoint): ERSHouseRoom; +function TPOHMap.ReadRoom(index: TPoint): ERSHouseRoom; begin if not InRange(index.X, 0, High(Self.Rooms)) then TerminateScript('p.X is not between 0 and ' + ToStr(High(Self.Rooms)) + ', got ' + ToStr(index)); @@ -220,27 +285,27 @@ end; (* -## POH.PrintRooms() +## TPOHMap.PrintRooms() ```pascal -procedure TRSPOHHandler.PrintRooms(); +procedure TPOHMap.PrintRooms(); ``` -Debugging helper method used to read a cached rooms in `POH.Rooms`. +Debugging helper method used to read a cached rooms in `TPOHMap.Rooms`. This will print the whole cache nicely formated in a way that is human friendly like you were looking at the house map. Unless you know what you are doing, you don't need this, but there's no harm in using it. ```{note} :class: dropdown -It's a extremely useful debugging tool when paired with `POH.Map.Debug()`. +It's a extremely useful debugging tool when paired with `POH.Map.Map.Debug()`. ``` Example: ```pascal POH.Setup(); -POH.PrintRooms(); +POH.Map.PrintRooms(); ``` *) -procedure TRSPOHHandler.PrintRooms(); +procedure TPOHMap.PrintRooms(); var str: String; i, j: Int32; @@ -264,26 +329,29 @@ begin WriteLn str; end; + (* -## POH.DrawMap() +## TPOHMap.DrawMap() ```pascal -procedure TRSPOHHandler.DrawMap(bmp: TMufasaBitmap; room: ERSHouseRoom; p: TPoint); -procedure TRSPOHHandler.DrawMap(room: ERSHouseRoom; color: Int32; p: TPoint); overload; +procedure TPOHMap.DrawMap(bmp: TMufasaBitmap; room: ERSHouseRoom; p: TPoint); +procedure TPOHMap.DrawMap(room: ERSHouseRoom; color: Int32; p: TPoint); overload; ``` -Methods used to draw the POH map and cache the rooms drawn in `POH.Rooms`. +Methods used to draw the POH map and cache the rooms drawn in `TPOHMap.Rooms`. Example: ```pascal -POH.DrawMap(ERSHouseRoom.SUPERIOR_GARDEN, POH.GrassColor, [3,3]); +POH.Map.DrawMap(ERSHouseRoom.SUPERIOR_GARDEN, POH.GrassColor, [3,3]); +POH.Map.Debug(); +POH.Map.PrintRooms(); ``` *) -procedure TRSPOHHandler.DrawMap(bmp: TMufasaBitmap; room: ERSHouseRoom; p: TPoint); +procedure TPOHMap.DrawMap(bmp: TMufasaBitmap; room: ERSHouseRoom; p: TPoint); begin Self.WriteRoom(room, p); Self.Map.DrawBitmap(bmp, [Self.SIZE * p.X, Self.SIZE * p.Y]); end; -procedure TRSPOHHandler.DrawMap(room: ERSHouseRoom; color: Int32; p: TPoint); overload; +procedure TPOHMap.DrawMap(room: ERSHouseRoom; color: Int32; p: TPoint); overload; var bmp: TMufasaBitmap; begin @@ -294,86 +362,220 @@ end; (* -## POH.GetPointIndex() +## TPOHMap.GetPointIndex() ```pascal -function TRSPOHHandler.GetPointIndex(p: TPoint): TPoint; +function TPOHMap.GetPointIndex(p: TPoint): TPoint; ``` -Helper method that converts a normal TPoint to a index used by {ref}`POH.ReadRoom()`. +Helper method that converts a normal TPoint to a index used by {ref}`TPOHMap.ReadRoom()`. Example: ```pascal -WriteLn POH.GetPointIndex(POH.GetPos()); +WriteLn POH.Map.GetPointIndex(POH.GetPos()); ``` *) -function TRSPOHHandler.GetPointIndex(p: TPoint): TPoint; +function TPOHMap.GetPointIndex(p: TPoint): TPoint; begin Result := [p.X div Self.SIZE, p.Y div Self.SIZE]; end; (* -## POH.GetMappedRoom() +## TPOHMap.GetRoom() ```pascal -function TRSPOHHandler.GetMappedRoom(p: TPoint): ERSHouseRoom; +function TPOHMap.GetRoom(p: TPoint): ERSHouseRoom; ``` -Helper method that returns the cached room in `POH.Rooms`with the help of -{ref}`POH.GetPointIndex()` and {ref}`POH.ReadRoom()`. +Helper method that returns the cached room in `TPOHMap.Rooms`with the help of +{ref}`TPOHMap.GetPointIndex()` and {ref}`TPOHMap.ReadRoom()`. Example: ```pascal -WriteLn POH.GetMappedRoom(POH.GetPos()); +WriteLn POH.Map.GetRoom(POH.GetPos()); ``` *) -function TRSPOHHandler.GetMappedRoom(p: TPoint): ERSHouseRoom; +function TPOHMap.GetRoom(p: TPoint): ERSHouseRoom; begin Result := Self.ReadRoom(Self.GetPointIndex(p)); end; + (* -## POH.GetMappedRoomTopLeft() +## TPOHMap.GetRoomTopLeft() ```pascal -function TRSPOHHandler.GetMappedRoomTopLeft(p: TPoint): TPoint; +function TPOHMap.GetRoomTopLeft(p: TPoint): TPoint; ``` Helper method that returns the top left point of a mapped room that the specified `p` belongs to. This is required to do accurate "room math". Example: ```pascal -WriteLn POH.GetMappedRoomTopLeft(POH.GetPos()); +WriteLn POH.Map.GetRoomTopLeft(POH.GetPos()); ``` *) -function TRSPOHHandler.GetMappedRoomTopLeft(p: TPoint): TPoint; +function TPOHMap.GetRoomTopLeft(p: TPoint): TPoint; begin Result := [p.X div Self.SIZE * Self.SIZE, p.Y div Self.SIZE * Self.SIZE]; end; (* -## POH.GetAdjacentRoomsMinimap() +## TPOHMap.GetAdjacentIndices() ```pascal -function TRSPOHHandler.GetAdjacentRoomsMinimap(p: TPoint): TPointArray; +function TPOHMap.GetAdjacentIndices(index: TPoint): TPointArray; static; +``` +Helper method that returns indices of the adjacent rooms (north, west, south and east) on the `TPOHMap.Rooms` cache. +It's also a static method and can be called directly from the type. + +Example: +```pascal +WriteLn TPOHMap.GetAdjacentIndices([3,3]); ``` -Helper method that returns coordinates that belong to the north, west, south and east rooms of the point passed in. -This assumes the compass is set to `0` (North) or that you've rotated your coordinates so the math works as if you had the compass set that way. -Ideally, you will want to pass in a room top left corner to this to get the top left corner of each adjacent room. *) -function TRSPOHHandler.GetAdjacentRoomsMinimap(p: TPoint): TPointArray; +function TPOHMap.GetAdjacentIndices(index: TPoint): TPointArray; static; begin - Result := [p.Offset(-32,0), p.Offset(32, 0), p.Offset(0, -32), p.Offset(0, 32)]; + Result := [index.Offset(-1,0), index.Offset(1, 0), index.Offset(0, -1), index.Offset(0, 1)]; end; + (* -## POH.GetAdjacentRoomsIndices() +## TPOHMap.SampleSearch() ```pascal -function TRSPOHHandler.GetAdjacentRoomsIndices(index: TPoint): TPointArray; +function TPOHMap.SampleSearch(minimapBMP: TMufasaBitmap; sampleSize: Int32 = 50; sampleAmount: Int32 = 3): TPoint; +``` +Helper method that returns the the position of the minimapBMP in the `TPOHMap.Map`, essentially getting the player position. + +Example: +```pascal +{$I WaspLib/optional/handlers/poh.simba} +var + minimapBMP: TMufasaBitmap; +begin + minimapBMP := TRSPOHHandler.GetCleanMinimap(); + minimapBMP.ReplaceColor(1, POH.Map.GrassColor); + WriteLn POH.Map.SampleSearch(minimapBMP, SAMPLE_SIZE); + minimapBMP.Free(); +end; ``` -Helper method that returns indices of the adjacent rooms (north, west, south and east) on the `POH.Rooms` cache. *) -function TRSPOHHandler.GetAdjacentRoomsIndices(index: TPoint): TPointArray; +function TPOHMap.SampleSearch(minimapBMP: TMufasaBitmap; sampleSize: Int32 = 50; sampleAmount: Int32 = 3): TPoint; +var + sampleSM, sampleLG: TMufasaBitmap; + offset: TPoint; + b: TBox; + matrixSM, matrixLG: TSingleMatrix; + resultSM, resultLG: TPointArray; + i, j, s: Int32; + p: TPoint; begin - Result := [index.Offset(-1,0), index.Offset(1, 0), index.Offset(0, -1), index.Offset(0, 1)]; + s := 20; + offset := minimapBMP.getCenter().Offset(2, 5); + b := Box(offset, s, s); + sampleSM := minimapBMP.Copy(b.X1, b.Y1, b.X2, b.Y2); + b := Box(offset, sampleSize, sampleSize); + sampleLG := minimapBMP.Copy(b.X1, b.Y1, b.X2, b.Y2); + + matrixSM := Self.Map.MatchTemplate(sampleSM, TM_CCOEFF_NORMED); + matrixLG := Self.Map.MatchTemplate(sampleLG, TM_CCOEFF_NORMED); + + sampleSM.Free(); + sampleLG.Free(); + + Dec(sampleAmount); + + for i := 0 to sampleAmount do + with matrixSM.ArgMax() do + begin + p := Point(X - (sampleSize - s), Y - (sampleSize - s)).Offset(sampleSize - 3, sampleSize - 5); + if Self.GetRoom(p) <> ERSHouseRoom.UNKNOWN then + resultSM += p + else + Dec(i); + matrixSM.Fill([X - 5, Y - 5, X + 5, Y + 5], 0); + end; + + for i := 0 to sampleAmount do + with matrixLG.ArgMax() do + begin + p := Point(X, Y).Offset(sampleSize - 3, sampleSize - 5); + if Self.GetRoom(p) <> ERSHouseRoom.UNKNOWN then + resultLG += p + else + Dec(i); + matrixLG.Fill([X - 5, Y - 5, X + 5, Y + 5], 0); + end; + + for i := 0 to High(resultLG) do + for j := 0 to High(resultSM) do + if resultLG[i].WithinDistance(resultSM[j], 6) then + Exit(resultLG[i]); + + Result := resultSM[0]; +end; + + +type +(* +## TRSPOHHandler +```pascal +type + TRSPOHHandler = record + Map: TPOHMap; + RoomObjects: array [ERSRoomObject] of TRoomObject; + Similarity: Double; + end; +``` +The core record used to handle navigating a POH. +*) + TRSPOHHandler = record + Map: TPOHMap; + RoomObjects: array [ERSRoomObject] of TRoomObject; + Similarity: Double; + end; + +(* +## POH.Init() +```pascal +procedure TRSPOHHandler.Init(); +``` +Internal method automatically called for your on script startup along with SRL.Setup(). +You do not have to call it yourself. +*) +procedure TRSPOHHandler.Init(); +var + obj: ERSRoomObject; +begin + Self.Map.Init(32, 12); + Self.Similarity := 0.9999; + + for obj := Low(ERSRoomObject) to High(ERSRoomObject) do + Self.RoomObjects[obj].Setup(obj); +end; + +(* +## POH.GetAdjacentRooms() +```pascal +function TRSPOHHandler.GetAdjacentRooms(p: TPoint): TPointArray; static; +``` +Helper static method that returns coordinates that belong to the north, west, south and east rooms of the point passed in. +This assumes the compass is set to `0` (North) or that you've rotated your coordinates so the math works as if you had the compass set that way. +Ideally, you will want to pass in a room top left corner to this to get the top left corner of each adjacent room. +*) +function TRSPOHHandler.GetAdjacentRooms(p: TPoint): TPointArray; static; +begin + Result := [p.Offset(-32,0), p.Offset(32, 0), p.Offset(0, -32), p.Offset(0, 32)]; end; -function TRSPOHHandler.GetMinimapRoomCoordinate(topLeft, p: TPoint; angle: Double; rotation: Int32): TPoint; +(* +## TRSPOHHandler.GetRoomCoordinate() +```pascal +function TRSPOHHandler.GetRoomCoordinate(topLeft, p: TPoint; angle: Double; rotation: Int32): TPoint; static; +``` +Helper static method that converts a room point `p` (which is always between [0,0] and [32,32] to a point on the minimap. +Optionally the point can be rotated on the room's center in 90º increments which is decided by `rotation`. +For example, if `rotation` is 3, the point will be rotated 90*3=270º on the room's center. + +This is useful to look for mainscreen objects in a room we don't know the rotation, +we can brute force all the possible rotations and look for what we want. +*) +function TRSPOHHandler.GetRoomCoordinate(topLeft, p: TPoint; angle: Double; rotation: Int32): TPoint; static; var roomCenter: TPoint; begin @@ -391,14 +593,31 @@ begin Result := Result.Rotate(PI/2 * rotation, roomCenter); end; -function TRSPOHHandler.GetCuboid(topLeft, p: TPoint; tile: Vector3; angle: Double; rotation: Int32): TCuboidEx; +(* +## POH.GetCuboid() +```pascal +function TRSPOHHandler.GetCuboid(topLeft, p: TPoint; tile: Vector3; angle: Double; rotation: Int32): TCuboidEx; static; +``` +Static mehod that returns a `TCuboidEx` on the mainscreen of a point we specify `p` with a given `rotation` on the room's center. +{ref}`TRSPOHHandler.GetRoomCoordinate()` is used to get the minimap point which then uses {ref}`Minimap.GetCuboidMS()` to give us a cuboid as a result. + +To work, this requires the room's `topLeft` TPoint and the compass `angle`. +*) +function TRSPOHHandler.GetCuboid(topLeft, p: TPoint; tile: Vector3; angle: Double; rotation: Int32): TCuboidEx; static; begin - p := Self.GetMinimapRoomCoordinate(topLeft, p, angle, rotation); + p := TRSPOHHandler.GetRoomCoordinate(topLeft, p, angle, rotation); Result := Minimap.GetCuboidMS(p, tile); end; -function TRSPOHHandler.Contains(objType: ERSRoomObject; topLeft: TPoint; angle: Double; rotation: Int32): Boolean; +(* +## POH.ContainsObject() +```pascal +function TRSPOHHandler.ContainsObject(objType: ERSRoomObject; topLeft: TPoint; angle: Double; rotation: Int32): Boolean; +``` +Checks if a {ref}`TRoomObject` stored in `POH.RoomObjects` exists in a room at a given `rotation`. +*) +function TRSPOHHandler.ContainsObject(objType: ERSRoomObject; topLeft: TPoint; angle: Double; rotation: Int32): Boolean; var obj: TRoomObject; cuboid: TCuboidEx; @@ -407,10 +626,17 @@ begin if obj.Coordinates <> [] then Exit; - cuboid := Self.GetCuboid(topLeft, obj.RoomOffset, obj.Shape, angle, rotation); + cuboid := TRSPOHHandler.GetCuboid(topLeft, obj.RoomOffset, obj.Shape, angle, rotation); Result := MainScreen.FindObject(obj.Finder, cuboid.Bounds()) <> []; end; +(* +## POH.MapRoomObjects() +```pascal +procedure TRSPOHHandler.MapRoomObjects(room: ERSHouseRoom; topLeft: TPoint; roomIndex: TPoint; angle: Double); +``` +Method responsible for mapping known {ref}`TRoomObject``TRoomObject` coordinates which later can be used to interact with them. +*) procedure TRSPOHHandler.MapRoomObjects(room: ERSHouseRoom; topLeft: TPoint; roomIndex: TPoint; angle: Double); var rotation: Int32; @@ -426,7 +652,7 @@ begin for rotation := 0 to 3 do begin obj := ERSRoomObject.POOL; - if Self.Contains(obj, topLeft, angle, rotation) then + if Self.ContainsObject(obj, topLeft, angle, rotation) then begin p := roomIndex + Self.RoomObjects[obj].RoomOffset; p := p.Rotate(PI/2*rotation, center); @@ -434,7 +660,7 @@ begin end; obj := ERSRoomObject.FAIRY_TREE; - if Self.Contains(obj, topLeft, angle, rotation) then + if Self.ContainsObject(obj, topLeft, angle, rotation) then Self.RoomObjects[obj].AddCoordinates([center]); end; end; @@ -447,7 +673,7 @@ begin for rotation := 0 to 3 do begin obj := ERSRoomObject.JEWELLERY_BOX; - if Self.Contains(obj, topLeft, angle, rotation) then + if Self.ContainsObject(obj, topLeft, angle, rotation) then begin p := roomIndex + Self.RoomObjects[obj].RoomOffset; p := p.Rotate(PI/2*rotation, center); @@ -459,30 +685,20 @@ begin end; end; -function TRSPOHHandler.RotateRoom(bitmap: TMufasaBitmap; rotation: Int32): TMufasaBitmap; -var - p: TPoint; -begin - if rotation = 0 then - Exit(bitmap.Copy()); - - bitmap.Pad(1); - Result.Init(); - bitmap.RotateBitmap(PI/2*rotation, Result); - - for p.X := 0 to 3 do - for p.Y := 0 to 3 do - if Result.GetPixel(p.X, p.Y) <> 0 then - Break(2); - - Result.Crop(p.X, p.Y, p.X + 31, p.Y + 31); -end; - +(* +## POH.MapAdjacentRooms() +```pascal +procedure TRSPOHHandler.MapAdjacentRooms(minimapBMP: TMufasaBitmap; topLeft, currentRoom: TPoint; angle: Double); +``` +The core of the "POH Handler". +This method is what's responsible for mapping unknown adjacent rooms (north, west, south and east). +If you know what you are doing you can call this directly, but this is called automatically by {ref}`POH.GetPos()` and {ref}`POH.Setup()`. +*) procedure TRSPOHHandler.MapAdjacentRooms(minimapBMP: TMufasaBitmap; topLeft, currentRoom: TPoint; angle: Double); const FLOOR_COLOR_OFFSETS: TPointArray = [[5,5], [26,5], [26,26], [5, 26]]; var - minimapTPA, localTPA: TPointArray; + minimapTPA, indices: TPointArray; p: TPoint; crop, sample, rotated, bestBMP: TMufasaBitmap; i, j, floor, r: Int32; @@ -492,16 +708,16 @@ var match, bestMatch: Single; hasCoreObject: Boolean; begin - localTPA := Self.GetAdjacentRoomsIndices(currentRoom); - minimapTPA := Self.GetAdjacentRoomsMinimap(topLeft); + indices := TPOHMap.GetAdjacentIndices(currentRoom); + minimapTPA := Self.GetAdjacentRooms(topLeft); for i := 0 to High(minimapTPA) do begin p := minimapTPA[i]; - if Self.ReadRoom(localTPA[i]) <> ERSHouseRoom.UNKNOWN then + if Self.Map.ReadRoom(indices[i]) <> ERSHouseRoom.UNKNOWN then Continue; - crop := minimapBMP.Copy(p.X, p.Y, p.X + Self.SIZE-1, p.Y + Self.SIZE-1); + crop := minimapBMP.Copy(p.X, p.Y, p.X + Self.Map.SIZE-1, p.Y + Self.Map.SIZE-1); colors := crop.GetPixels(FLOOR_COLOR_OFFSETS); floor := colors.GetMostCommon(); @@ -509,18 +725,18 @@ begin for j := 1 to Ord(High(ERSHouseRoom)) do begin case j of - 0..3: if floor <> Self.GrassColor then Continue; //Gardens or OpenMenagerie - else if floor = Self.GrassColor then Continue; + 0..3: if floor <> Self.Map.GrassColor then Continue; //Gardens or OpenMenagerie + else if floor = Self.Map.GrassColor then Continue; end; - sample := Self.GetRoomBitmap(ERSHouseRoom(j), floor); + sample := Self.Map.GetRoomBitmap(ERSHouseRoom(j), floor); for r := 0 to 3 do begin - rotated := Self.RotateRoom(sample, r); + rotated := TPOHMap.RotateBitmap(sample, r); case j of - 2: hasCoreObject := Self.Contains(ERSRoomObject.POOL, p, angle, r); - 7: hasCoreObject := Self.Contains(ERSRoomObject.JEWELLERY_BOX, p, angle, r); + 2: hasCoreObject := Self.ContainsObject(ERSRoomObject.POOL, p, angle, r); + 7: hasCoreObject := Self.ContainsObject(ERSRoomObject.JEWELLERY_BOX, p, angle, r); end; matrix := crop.MatchTemplate(rotated, TM_CCOEFF_NORMED); @@ -549,8 +765,8 @@ begin crop.Free(); if bestMatch > 0.3 then begin - Self.DrawMap(bestBMP, bestRoom, localTPA[i]); - Self.MapRoomObjects(bestRoom, p, localTPA[i], angle); + Self.Map.DrawMap(bestBMP, bestRoom, indices[i]); + Self.MapRoomObjects(bestRoom, p, indices[i], angle); bestMatch := 0; end; end; @@ -558,6 +774,13 @@ begin end; +(* +## POH.GetCleanMinimap() +```pascal +function TRSPOHHandler.GetCleanMinimap(out angle: Double): TMufasaBitmap; static; +``` +Basically the same as {ref}`Walker.GetCleanMinimap()` that returns the compass angle as well. +*) function TRSPOHHandler.GetCleanMinimap(out angle: Double): TMufasaBitmap; static; var bitmap: TMufasaBitmap; @@ -573,13 +796,26 @@ begin bitmap.Free(); end; -function TRSPOHHandler.GetCleanMinimap(): TMufasaBitmap; static; overload; -var - angle: Double; -begin - Result := TRSPOHHandler.GetCleanMinimap(angle); -end; +(* +## POH.Setup() +```pascal +procedure TRSPOHHandler.Setup(); +``` +The method that sets up the "POH Handler" so it can be used. +It's your responsibility to call it and it must be called from your POH entrance. +There is some wiggle room as from where you can use this on your garden and +you might get away using it from anywhere but for best results you should use this from +the tile right northwest to your exit portal. +This is the tile that the `POH.Setup()` assumes you will be calling it from and it's +the tile you will always be in as soon as you enter your POH no matter the method you +choose to enter it (teleport, using the portal, building or non building mode, ...). +Example: +```pascal +if MainScreen.WaitLoadingPOH(5000) then + POH.Setup(); +``` +*) procedure TRSPOHHandler.Setup(); var minimapBMP: TMufasaBitmap; @@ -588,85 +824,45 @@ var begin minimapBMP := TRSPOHHandler.GetCleanMinimap(angle); center := minimapBMP.getCenter(); - Self.GrassColor := minimapBMP.GetPixel(center.X, center.Y); - minimapBMP.ReplaceColor(1, Self.GrassColor); + Self.Map.GrassColor := minimapBMP.GetPixel(center.X, center.Y); + minimapBMP.ReplaceColor(1, Self.Map.GrassColor); - Self.Map.ReplaceColor(0, Self.GrassColor); + Self.Map.Map.ReplaceColor(0, Self.Map.GrassColor); - p := [Self.AMOUNT div 2, Self.AMOUNT div 2]; - Self.DrawMap(ERSHouseRoom.GARDEN, Self.GrassColor, p); + p := [Self.Map.AMOUNT div 2, Self.Map.AMOUNT div 2]; + Self.Map.DrawMap(ERSHouseRoom.GARDEN, Self.Map.GrassColor, p); topLeft := center.Offset(-14, -10); Self.MapAdjacentRooms(minimapBMP, topLeft, p, angle); minimapBMP.Free(); end; - +(* +## POH.LoadSuroundings() +```pascal +procedure TRSPOHHandler.LoadSuroundings(minimapBMP: TMufasaBitmap; p: TPoint; angle: double); +``` +Wrapper method that performs some common math required by {ref}`POH.MapAdjacentRooms()`. +You can use this directly if you know what you are doing, but this is called automatically for you with {ref}`POH.GetPos()`. +*) procedure TRSPOHHandler.LoadSuroundings(minimapBMP: TMufasaBitmap; p: TPoint; angle: double); var topLeft: TPoint; begin - topLeft := p - Self.GetMappedRoomTopLeft(p); + topLeft := p - Self.Map.GetRoomTopLeft(p); topLeft := minimapBMP.getCenter() - topLeft - [1,0]; - Self.MapAdjacentRooms(minimapBMP, topLeft, Self.GetPointIndex(p), angle); -end; - - -function TRSPOHHandler.SampleSearch(minimapBMP: TMufasaBitmap; sampleSize: Int32 = 50; sampleAmount: Int32 = 3): TPoint; -var - sampleSM, sampleLG: TMufasaBitmap; - offset: TPoint; - b: TBox; - matrixSM, matrixLG: TSingleMatrix; - resultSM, resultLG: TPointArray; - i, j, s: Int32; - p: TPoint; -begin - s := 20; - offset := minimapBMP.getCenter().Offset(2, 5); - b := Box(offset, s, s); - sampleSM := minimapBMP.Copy(b.X1, b.Y1, b.X2, b.Y2); - b := Box(offset, sampleSize, sampleSize); - sampleLG := minimapBMP.Copy(b.X1, b.Y1, b.X2, b.Y2); - - matrixSM := Self.Map.MatchTemplate(sampleSM, TM_CCOEFF_NORMED); - matrixLG := Self.Map.MatchTemplate(sampleLG, TM_CCOEFF_NORMED); - - sampleSM.Free(); - sampleLG.Free(); - - Dec(sampleAmount); - - for i := 0 to sampleAmount do - with matrixSM.ArgMax() do - begin - p := Point(X - (sampleSize - s), Y - (sampleSize - s)).Offset(sampleSize - 3, sampleSize - 5); - if Self.GetMappedRoom(p) <> ERSHouseRoom.UNKNOWN then - resultSM += p - else - Dec(i); - matrixSM.Fill([X - 5, Y - 5, X + 5, Y + 5], 0); - end; - - for i := 0 to sampleAmount do - with matrixLG.ArgMax() do - begin - p := Point(X, Y).Offset(sampleSize - 3, sampleSize - 5); - if Self.GetMappedRoom(p) <> ERSHouseRoom.UNKNOWN then - resultLG += p - else - Dec(i); - matrixLG.Fill([X - 5, Y - 5, X + 5, Y + 5], 0); - end; - - for i := 0 to High(resultLG) do - for j := 0 to High(resultSM) do - if resultLG[i].WithinDistance(resultSM[j], 6) then - Exit(resultLG[i]); - - Result := resultSM[0]; + Self.MapAdjacentRooms(minimapBMP, topLeft, Self.Map.GetPointIndex(p), angle); end; +(* +## POH.GetPos() +```pascal +function TRSPOHHandler.GetPos(): TPoint; +``` +Returns the player position relative to the `POH.Map`. +Whenever this method is called, if there's unknown adjacent rooms (north, west, south and east), +they will be mapped. +*) function TRSPOHHandler.GetPos(): TPoint; const SAMPLE_SIZE: Int32 = 50; @@ -675,13 +871,30 @@ var angle: Double; begin minimapBMP := TRSPOHHandler.GetCleanMinimap(angle); - minimapBMP.ReplaceColor(1, Self.GrassColor); + minimapBMP.ReplaceColor(1, Self.Map.GrassColor); - Result := Self.SampleSearch(minimapBMP, SAMPLE_SIZE); + Result := Self.Map.SampleSearch(minimapBMP, SAMPLE_SIZE); Self.LoadSuroundings(minimapBMP, Result, angle); minimapBMP.Free(); end; +(* +## POH.DebugPos() +```pascal +procedure TRSPOHHandler.DebugPos(); +``` +Debugs the current player position on the `POH.Map`. + +Example: +```pascal +{$I WaspLib/optional/handlers/poh.simba} +begin + POH.Setup(); //call from the northwest tile of your exit portal. + while True do + POH.DebugPos(); +end; +``` +*) procedure TRSPOHHandler.DebugPos(); const SAMPLE_SIZE: Int32 = 50; @@ -691,24 +904,24 @@ var angle: Double; begin minimapBMP := TRSPOHHandler.GetCleanMinimap(angle); - minimapBMP.ReplaceColor(1, Self.GrassColor); + minimapBMP.ReplaceColor(1, Self.Map.GrassColor); - p := Self.SampleSearch(minimapBMP, SAMPLE_SIZE); + p := Self.Map.SampleSearch(minimapBMP, SAMPLE_SIZE); Self.LoadSuroundings(minimapBMP, p, angle); display.Init(); - display.SetSize(Self.Map.getWidth() + minimapBMP.getWidth() + 300, Self.Map.getHeight()); + display.SetSize(Self.Map.Map.getWidth() + minimapBMP.getWidth() + 300, Self.Map.Map.getHeight()); - display.DrawBitmap(Self.Map, [0,0]); + display.DrawBitmap(Self.Map.Map, [0,0]); display.setFontAntialiasing(True); display.DrawText('MAP', [10, 10], $FFFFFF); display.setFontSize(14); - display.DrawText('Minimap sample:', [Self.Map.getWidth()+10, 0], $FFFFFF); - display.DrawBitmap(minimapBMP, [Self.Map.getWidth()+1, 20]); + display.DrawText('Minimap sample:', [Self.Map.Map.getWidth()+10, 0], $FFFFFF); + display.DrawBitmap(minimapBMP, [Self.Map.Map.getWidth()+1, 20]); display.setFontSize(10); - display.DrawText('Pos:' + ToStr(p), [Self.Map.getWidth()+10, minimapBMP.getHeight() + 40], $FFFFFF); + display.DrawText('Pos:' + ToStr(p), [Self.Map.Map.getWidth()+10, minimapBMP.getHeight() + 40], $FFFFFF); display.DrawCrosshairs(p, 1, $FFFFFF); display.Debug(); @@ -717,12 +930,45 @@ begin display.Free(); end; + +(* +## POH.GetCurrentRoom() +```pascal +function TRSPOHHandler.GetCurrentRoom(): ERSHouseRoom; +``` +Returns the current {ref}`ERSHouseRoom` we are on. + +Example: +```pascal +POH.Setup(); //call from the northwest tile of your exit portal. +WriteLn POH.GetCurrentRoom(); +``` +*) function TRSPOHHandler.GetCurrentRoom(): ERSHouseRoom; begin - Result := Self.GetMappedRoom(Self.GetPos()); + Result := Self.Map.GetRoom(Self.GetPos()); end; +(* +## POH.MapToMM() +```pascal +function TRSPOHHandler.MapToMM(me, handlerPoint: TPoint; radians: Double): TPoint; +function TRSPOHHandler.MapToMM(walkerPoint: TPoint): TPoint; overload; +function TRSPOHHandler.MapToMM(me: TPoint; tpa: TPointArray; radians: Double): TPointArray; overload; +function TRSPOHHandler.MapToMM(tpa: TPointArray): TPointArray; overload; +``` + +Converts points from the `POH.Map` to points on the minimap. +This can be used to walk or get mainscreen info with {ref}`MM2MS`. + +Example: +```pascal +POH.Setup(); //call from the northwest tile of your exit portal. +p := POH.MapToMM(Self.GetPos() + [16, 16]); +Debug(Minimap.GetCuboidMS(p, [1,1,5])); +``` +*) function TRSPOHHandler.MapToMM(me, handlerPoint: TPoint; radians: Double): TPoint; begin Result := handlerPoint - me + Minimap.Center(); @@ -747,6 +993,23 @@ begin Result := Self.MapToMM(Self.GetPos(), tpa, Minimap.GetCompassAngle(False)); end; + +(* +## POH.Interact +```pascal +function TRSPOHHandler.Hover(objType: ERSRoomObject): Boolean; +function TRSPOHHandler.Click(objType: ERSRoomObject): Boolean; +function TRSPOHHandler.Select(objType: ERSRoomObject; options: TStringArray): Boolean; +``` +Method used to interact with a {ref}`TRoomObject` by specifying a {ref}`ERSRoomObject`. +The interactions are self explanatory. + +Example: +```pascal +POH.Setup(); //call from the northwest tile of your exit portal. +WriteLn POH.Hover(ERSRoomObject.POOL); //pool has to be on the same room, north, west, south or east. +``` +*) function TRSPOHHandler.Hover(objType: ERSRoomObject): Boolean; var obj: TRoomObject; @@ -799,6 +1062,13 @@ begin end; var +(* +## var POH +```pascal +var POH +``` +Global variable to use the {ref}`TRSPOHHandler`. +*) POH: TRSPOHHandler; procedure TSRL.Setup(); override; @@ -806,14 +1076,3 @@ begin inherited; POH.Init(); end; - -(* -begin - POH.Setup(); - POH.Click(ERSRoomObject.POOL); - Wait(5000); - POH.Click(ERSRoomObject.JEWELLERY_BOX); - while True do - POH.DebugPos(); -end; -*) diff --git a/osr/mm2ms.simba b/osr/mm2ms.simba index d4d6a367..061da692 100644 --- a/osr/mm2ms.simba +++ b/osr/mm2ms.simba @@ -405,9 +405,10 @@ begin end; (* -## Minimap.GetCuboidMS +## Minimap.GetCuboidMS() ```pascal function TRSMinimap.GetCuboidMS(loc: TPoint; tile: Vector3 = [1, 1, 4]; offset: Vector2 = [0, 0]; roll: Single = $FFFF): TPointArray; +function TRSMinimap.GetCuboidMS(loc: TPoint; tile: Vector3 = [1, 1, 4]; offset: Vector2 = [0, 0]; roll: Single = $FFFF): TCuboidEx; overload; ``` To understand what this does, you should read about **TRSMinimap.GetTileMS()** and **TPointArray.ConvexHull()** and understand what they do.