Walker¶
This file is responsible for our walking system. It is heavily inspired in the original TRSWalker by slacky and it’s future iterations made by Olly.
type PRSWalker¶
TRSWalker pointer.
type TRSWalkerEvent¶
Callback object method to use while walking. This can be used to perform custom tasks while walking.
Example:
procedure TRSWalker.WalkerTasks(walker: PRSWalker; position, destination: TPoint);
begin
Antiban.RandomTab();
end;
begin
//this assumes walker is already setup.
walker.OnWaitMoving := @walker.WalkerTasks;
end;
TRSWalker¶
TRSWalker is the record responsible for walking. To work you need to set it up with something that gives it a position function as by itself it doesn’t really do anything.
Once you have a function that gives you an accurate position, you can pass it to
into a TRSWalker variable or into the Walker one, either directly or
via the Walker.Setup method.
Walker.Setup¶
procedure TRSWalker.Setup(position: TWalkerPositionFunction; height: TWalkerHeightFunction; getLocal: TWalkerGetLocalFunction; graph: PWebGraph; mapImage: TImage);
Method responsible for setting up the TRSWalker variable.
All parameters of this function can be nil except for position.
Without a position callback you cannot use TRSWalker.
The following is purely an example, you never have to do this since Map.Setup
already does this for you anyway:
Map.Setup(ERSChunk.CATACOMBS_OF_KOUREND);
Walker.Setup(@Map.Position, @Map.Height, @Map.Loader.GetLocal, @Map.Loader.Graph, @Map.Loader.Map);
Walker Conversions¶
function TRSWalker.Point2MM(me, pt: TPoint; radians: Double): TPoint;
function TRSWalker.Point2MMVec(me, pt: TPoint; radians: Double): Vector2;
function TRSWalker.Points2MM(me: TPoint; tpa: TPointArray; radians: Double): TPointArray;
function TRSWalker.GetLocalEx(tpa: TPointArray; offset: TPoint = [0,0]): TPointArray;
function TRSWalker.GetQuadMS(me, mapPoint: TPoint; height: Double = 0; offset: Vector3 = [0,0,0]; radians: Single = $FFFF): TQuad;
function TRSWalker.MM2Map(me, minimapPoint: TPoint; radians: Single = $FFFF): TPoint;
Used to convert coordinates from TRSWalker to the minimap or the mainscreen.
Example:
//assuming walker is already setup...
me := Walker.Position();
ShowOnTarget(Walker.GetQuadMS(me, me + [4,0])); //should show you the tile to your right.
TRSWalker.InRange¶
function TRSWalker.InRangeEx(me, coordinate: TPoint; distance: Integer = 4): Boolean;
function TRSWalker.InRange(coordinate: TPoint; distance: Integer = 4): Boolean;
Returns True/False if we are within distance of a certain coordinate.
distance is measured in pixels and in a radial way.
Walker.CheckEnergy¶
procedure TRSWalker.CheckEnergy();
Internal method used to check and enable the player run. You will probably never need to call this directly.
The values used are hardcoded and if you don’t like them, it’s recommended you override the method. The following example shows how one could override the function to enable run at 50% energy everytime, keep in mind though, you shouldn’t do this, you should add randomness to it!
Example:
Map.Walker.MinEnergy := 10;
Map.Walker.CheckEnergy();
Walker.AdaptiveWalkCheck¶
procedure TRSWalker.AdaptiveWalkCheck(position: TPoint);
Internal method used to check if adaptive walk should toggle and toggle TRSWalker.ScreenWalk. You will probably never need to call this directly.
Walker.DoMouseAhead¶
procedure TRSWalker.DoMouseAhead(position: TPoint; forced: Boolean = False);
Internal method used to pre-hover the next walking step. You will probably never need to call this directly.
Walker.WaitMoving¶
procedure TRSWalker.WaitMoving(destination: TPoint; minDist: Integer);
procedure TRSWalker.WaitMoving(time: Integer = 20000; doAntiban: Boolean = True); overload;
Internal method used to wait while we are moving using walker. You will probably never need to call this directly.
This is where TRSWalker.OnWaitMoving are called.
Walker.Click¶
function TRSWalker.Click(minimapPoint: TPoint; Randomness: Integer): Boolean;
Internal method used by walker to handle clicking while walking. You will probably never need to call this directly.
If you wish to modify certain walker behaviors, it can be a good approach to override this function.
Walker.IsWalkable¶
function TRSWalker.IsWalkable(mapPoint: TPoint; me: TPoint; out mmPoint: TPoint; radians: Single): Boolean;
Internal method used by walker to decide if the destination point is within 1 click reach. You will probably never need to call this directly.
Walker.WalkStep¶
function TRSWalker.WalkStep(me: TPoint; index, minDist: Integer): Boolean;
Internal method used by walker while walking a path. You will probably never need to call this directly.
TRSWalker.WalkPath¶
function TRSWalker.WalkPath(Path: TPointArray; minDist: Integer = 0): Boolean;
Walks a path of points taken from the loaded map. We advice that minDist is not 0.
Parameters:
Path Array of points taken from the loaded map to walk. Must be ordered from start to finish.
minDist Determines when the method returns once the final point has been clicked. Default value: 0. | minDist=0 waits until the player has reached the final point. | minDist=20 waits until the player is within 20 pixels of the final point.
Example:
Walker.WalkPath([[100,100],[120,120],[140,140],[160,160],[180,180]]);
TRSWalker.WalkBlind¶
function TRSWalker.WalkBlind(Destination: TPoint; minDist: Integer = 0): Boolean;
“Blindly” walks to a point taken from the loaded map. A straight line is generated between the player’s position and destination which is then walked.
Parameters:
Destination Destination point taken from the loaded map.
minDist Determines when the method returns once the final point has been clicked. Default value: 0. | minDist=0 waits until the player has reached the final point. | minDist=20 waits until the player is within 20 pixels of the final point.
Example:
Walker.WalkBlind([300, 300]);
TRSWalker.GetClosestPoint¶
function TRSWalker.GetClosestPoint(me: TPoint; destinations: TPointArray; out path: TGraphNodeArray): TPoint;
Method used to get the closest destination point to me.
TRSWalker.WebWalk¶
function TRSWalker.WebWalkEx(me, destination: TPoint; minDist: Integer = 0; randomness: Double = 0): Boolean;
function TRSWalker.WebWalk(destination: TPoint; minDist: Integer = 0; randomness: Double = 0): Boolean;
function TRSWalker.WebWalk(destinations: TPointArray; minDist: Integer = 0; randomness: Double = 0): Boolean; overload;
Web walks to the destination point on the loaded map. Does not handle any obstacles.
TRSWalker.MakePointVisible¶
function TRSWalker.MakePointVisible(p: TPoint): Boolean;
function TRSWalker.MakePointVisible(tpa: TPointArray): Boolean; overload;
Wrapper function used to attempt to make a Point visible on the MainScreen.