Walker¶
Extensions to SRL’s TWalker.
type THeightMap¶
type
THeightMap = record
Disabled: Boolean;
Map: TMufasaBitmap;
MaxHeight: Double;
MathCache: Double;
end;
THeightMap is the type responsible for handling heights with walker when using WaspLib. This type does not need to be initiated as a variable and it’s meant to be used directly with it’s static methods.
Enabled is used to toggle the THeightMap on/off. By default it will always be on unless there’s not a heightmap available for the map you load into walker. the heightmap MUST be named the same as the map you load with an “h” prepended. E.G.: hWorld.png
Map there’s not much to talk about this one, it’s simply the TMufasaBitmap loaded in the record.
MaxHeight This is what will be considered the max height possible in the calculations made by THeightMap. There’s no way to accurately know what this should be, you should debug heights and set a value that looks good to you. Values might also vary between regions but I find 30 to be a fine value that works well in a lot of places if not all.
MathCache, not very important, simply a cache variable so we don’t repeat calculations when it’s not required.
THeightMap.GetColor¶
function THeightMap.GetColor(p: TPoint): Int64;
Returns the color of the heightmap at the specified point.
Example:
WriteLn THeightMap.GetColor([100, 100]);
THeightMap.DebugPosition¶
procedure THeightMap.DebugPosition(p: TPoint);
Debug a point in the loaded heightmap.
Example:
THeightMap.DebugPosition(RSW.GetMyPos());
TWalkerMap.Load¶
procedure TWalkerMap.Load(fileName: String; Scaling: Integer); override;
procedure TWalkerMap.Load(fileName: String; aRegions: TBoxArray; Scaling: Integer; Padding: Integer = 50); override;
procedure TWalkerMap.Load(fileName: String; aRegion: TBox; scaling: Integer; padding: Integer = 50); override;
procedure TWalkerMap.Load(fileName: String; start: TPoint; scaling: Int32; out aRegion: TBox; padding: Int32 = 50); override;
Overrides SRL’s TWalkerMap.Load() so it loads the respective heightmap if it exists. This is an internal Walker method, you probably don’t need to call it.
Walker.InternalSetup¶
procedure TWalker.InternalSetup(); override;
Overrides SRL’s Walker.InternalSetup() so it uses WaspWeb as the walker webgraph and so it uses ScreenWalk by default. This is an internal Walker method, you probably don’t need to call it. It also sets up the ScriptWalker pointer which is used for several things in WaspLib like TWalkerObjects and Skunk’s transport system.
Walker.SetupNamedRegion¶
procedure TWalker.SetupNamedRegion(region: TBankRegion = []); overload;
Use this if you want to setup a walker with whatever the user has setup in WLSettings.BankLocation. You can optionally pass in your own region but it’s really meant to use the default.
Example:
WLSettings.BankLocation := EWLBankLocation.CASTLE_WARS_BANK;
Walker.SetupNamedRegion();
Walker.Map.Map.Debug();
Walker.GetHeight¶
function TWalker.GetHeight(p: TPoint = []; global: Boolean = True): Double;
Returns the height of the player at the specified coordinate with the help of THeightMap. If p is [], which is the default then we will use our current position. global decides wether the coordinate is converted to global coordinates or internal walker coordinates (read about walker regions for more info).
Example:
WriteLn rsw.GetHeight();
Walker.DebugHeightTiles¶
procedure TWalker.DebugHeightTiles(angle: Double = -1);
Displays a debug image of the tiles visible on the mainscreen with their height adjusted according to the THeightMap. This is very useful if you need to adjust THeightMap.MaxHeight.
Example:
rsw.DebugHeightTiles();
Walker.GetMyPos¶
function TWalker.GetMyPos(out height: Double): TPoint; overload;
Overload that also returns the player height.
Example:
WriteLn RSW.GetMyPos(height);
WriteLn height;
Walker.GetHeightDiff¶
function TWalker.GetHeightDiff(p: TPoint): Double;
function TWalker.GetHeightDiff(p, q: TPoint): Double; overload;
Returns the height difference between 2 points. If only one point is passed, the player position is used as one of them.
Example:
WriteLn RSW.GetMyPos(RSW.GetMyPos(), [100, 100]);
TWalker.AtTile¶
function TWalker.AtTile(worldPoint: TPoint; Distance: Int32 = 4): Boolean;
function TWalker.AtTile(worldPointArray: TPointArray; Distance: Int32 = 4): Boolean; overload;
method used to quickly check if we are within distance of a certain worldPoint. This distance is measure in pixels and in a radial way. You can optionally pass in a TPA to check if the closest point is within distance.
This is a TWalker method so it will exist both on TWalker and TWalker.
TWalker.GetClosestPoint¶
function TWalker.GetClosestPoint(worldPointArray: TPointArray): TPoint;
method used to get the closest Point to the Player out of a TPA.
This is a TWalker method so it will exist both on TWalker and TWalker.
TWalker.WebWalk¶
function TWalker.WebWalk(destinations: TPointArray; waitUntilDistance: Int32 = 0; pathRandomness: Double = 0): Boolean; overload;
method used to webwalk to the closest Point to the player. An example use case is for example, if you have sevel bank booths you can use, those would be your Destination TPA. You will likely want to use the closest bank booth to you, so you use this.
This is a TWalker method so it will exist both on TWalker and TWalker.
TWalker.WorldToMM¶
function TWalker.WorldToMM(me: TPoint; tpa: TPointArray; radians: Double): TPointArray; overload;
function TWalker.WorldToMM(tpa: TPointArray): TPointArray; overload;
function TWalker.WorldToMM(me: TPoint; atpa: T2DPointArray; radians: Double): T2DPointArray; overload;
function TWalker.WorldToMM(atpa: T2DPointArray): TPointArray; overload;
function TWalker.WorldToMM(me: TPoint; dotFilter: TDotFilter; roll: Double = $FFFF): TDotFilter; overload;
function TWalker.WorldToMM(dotFilterArray: TDotFilterArray; roll: Double = $FFFF): TDotFilterArray; overload;
Overloaded methods required for ATPAs and TDotFilters. For more information on TDotFilter check their documentation.
This is a TWalker method so it will exist both on TWalker and TWalker.
TWalker.MakePointVisible¶
function TWalker.MakePointVisible(p: TPoint): Boolean;
function TWalker.MakePointVisible(tpa: TPointArray): Boolean; overload;
Wrapper function used to attempt to make a Point visible on the MainScreen.
This are TWalker methods so they will exist both on TWalker and TWalker.
TWalker.GetCuboidMS¶
function TWalker.GetCuboidMS(me, loc: TPoint; tile: Vector3 = [1, 1, 4]; Offset: Vector2 = [0, 0]): TPointArray;
function TWalker.GetCuboidMS(loc: TPoint; tile: Vector3 = [1, 1, 4]; Offset: Vector2 = [0, 0]): TPointArray; overload;
This are TWalker methods so they will exist both on TWalker and TWalker.
To understand what this does, you should read about TMinimap.GetTileMS() and TPointArray.ConvexHull() and understand what they do. This calls TMinimap.GetCuboidMS() internally which in turn will use both methods above.
To put it simply, this will will first calculate a floor rectangle with tile.Z, or height if you prefer of 0 and then calculate the top rectangle of the tile.Z you specified.
After this 2 rectangles are calculated a polygon is then made out of the two, resulting in a ConvexHull which is returned.
This is perfect to to get an accurate bounding polygon of objects and NPCs which you can use to accurately color search after.
The example below will show you how it could be used to retrieve an accurate player bounding polygon:
Example:
Debug(RSW.GetCuboidMS([100, 100], [1, 1, 4], Offset)); //This will draw a polygon around the coordinate [100, 100].
TWalker.GetTileArrayMS¶
function TWalker.GetTileArrayMS(me: TPoint; locArray: TPointArray; tile: Vector3 = [1, 1, 0]; Offset: Vector2 = [0, 0]): TRectArray;
function TWalker.GetTileArrayMS(locArray: TPointArray; tile: Vector3 = [1, 1, 0]; Offset: Vector2 = [0, 0]): TRectArray; overload;
This are wrapper functions to retrieve multiple tiles. Refer to SRL’s TWalker.GetTileMSEx() and TWalker.GetTileMS() for more information.
This are TWalker methods so they will exist both on TWalker and TWalker.
TWalker.GetCuboidArrayMS¶
function TWalker.GetCuboidArrayMS(me: TPoint; locArray: TPointArray; tile: Vector3 = [1, 1, 4]; Offset: Vector2 = [0, 0]): T2DPointArray;
function TWalker.GetCuboidArrayMS(locArray: TPointArray; tile: Vector3 = [1, 1, 4]; Offset: Vector2 = [0, 0]): T2DPointArray;
Gives you an array of mainscreen polygons. Read Minimap.GetCuboidMS for more information.
This are TWalker methods so they will exist both on TWalker and TWalker.
Example:
TPA := Minimap.GetDots(EMinimapDot.Player); //find all player dots and returns their coodinates.
Debug(Minimap.GetCuboidArrayMS(TPA, [2, 3, 5], [2, 2])); //This will draw a polygon that is 2 by 3 tiles and height 5 in the mainscreen where each NPC is.
TWalker.GetMSPolygon¶
function TWalker.GetMSPolygon(tpa: TPointArray): TPointArray;
function TWalker.GetMSPolygonArray(atpa: T2DPointArray): T2DPointArray;
This function converts a list of points to their respective points in the minimap. This is extremely useful if you want to be sure you are within an area. To make a polygon or a polygon array easily you can use Simba/Includes/WaspLib/tools/walkerpolygon.simba.
This are TWalker methods so they will exist both on TWalker and TWalker.
Example:
Debug(RSW.GetMMPoly(TPA).Connect()); //This will draw your TPA on the minimap.
TWalker.InPoly¶
function TWalker.InPoly(locArray: TPointArray): Boolean;
Checks if you are inside a polygon. If you need to debug the polygon check the example in TWalker.GetMMPoly.
This are TWalker methods so they will exist both on TWalker and TWalker.