# POHMap The POH Map is what's responsible for mapping a user's POH. - - - (ERSHouseRoom)= ## 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 ); ``` - - - (TPOHMap)= ## type TPOHMap ```pascal type TPOHMap = record AMOUNT, SIZE: Int32; Map: TMufasaBitmap; Rooms: array of array of ERSHouseRoom; RoomsMap: TMufasaBitmap; ERoomBitmaps: array [ERSHouseRoom] of TMufasaBitmap; GrassColor: Int32; end; ``` Helper record used by the {ref}`TRSPOHHandler`. All `TPOHMap` methods are helper methods for the {ref}`TRSPOHHandler` and you shouldn't have to call them for anything. - - - ## TPOHMap.Free() ```pascal procedure TPOHMap.Free(); ``` Internal method automatically called for your on script termination. You do not have to call it yourself. - - - ## TPOHMap.Init() ```pascal procedure TPOHMap.Init(size, amount: Int32); ``` Internal method automatically called for your on script startup along with POH.Init(). You do not have to call it yourself. - - - ## TPOHMap.GetRoomBitmapBox() ```pascal function TPOHMap.GetRoomBitmapBox(room: ERSHouseRoom): TBox; ``` Internal method used to get the box of the {ref}`ERSHouseRoom` you pass in. This box is a box of the following image: ![poh rooms](../../../osr/walker/poh.png) Example: ```pascal {$I WaspLib/optional/handlers/poh.simba} begin WriteLn POH.Map.GetRoomBitmapBox(ERSHouseRoom.SUPERIOR_GARDEN); end; ``` - - - ## TPOHMap.GetRoomBitmap() ```pascal function TPOHMap.GetRoomBitmap(room: ERSHouseRoom; color: Int32 = -1): TMufasaBitmap; ``` 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.Map.GetRoomBitmap(ERSHouseRoom.SUPERIOR_GARDEN); bmp.Debug(); bmp.Free(); 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; ``` - - - ## TPOHMap.WriteRoom() ```pascal procedure TPOHMap.WriteRoom(room: ERSHouseRoom; index: TPoint); ``` 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.Map.WriteRoom(ERSHouseRoom.SUPERIOR_GARDEN, [3,3]); ``` - - - ## TPOHMap.ReadRoom() ```pascal function TPOHMap.ReadRoom(index: TPoint): ERSHouseRoom; ``` 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.Map.ReadRoom([3,3]); ``` - - - ## TPOHMap.PrintRooms() ```pascal procedure TPOHMap.PrintRooms(); ``` 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.Map.Debug()`. ``` Example: ```pascal POH.Setup(); POH.Map.PrintRooms(); ``` - - - ## TPOHMap.DrawMap() ```pascal 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 `TPOHMap.Rooms`. Example: ```pascal POH.Map.DrawMap(ERSHouseRoom.SUPERIOR_GARDEN, POH.GrassColor, [3,3]); POH.Map.Debug(); POH.Map.PrintRooms(); ``` - - - ## TPOHMap.GetPointIndex() ```pascal function TPOHMap.GetPointIndex(p: TPoint): TPoint; ``` Helper method that converts a normal TPoint to a index used by {ref}`TPOHMap.ReadRoom()`. Example: ```pascal WriteLn POH.Map.GetPointIndex(POH.GetPos()); ``` - - - ## TPOHMap.GetRoom() ```pascal function TPOHMap.GetRoom(p: TPoint): ERSHouseRoom; ``` 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.Map.GetRoom(POH.GetPos()); ``` - - - ## TPOHMap.GetRoomTopLeft() ```pascal 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.Map.GetRoomTopLeft(POH.GetPos()); ``` - - - ## TPOHMap.GetAdjacentIndices() ```pascal 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]); ``` - - - ## TPOHMap.SampleSearch() ```pascal 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; ```