Runescapian321
2010-03-12 20:04:51
EDIT: Everything useful in this thread has been committed to the Svn: http://scardevreflection.googlecode.com/svn/trunk. However, note that virtually only the functions mentioned in this thread work. If the hooks become outdated (after an update), check the end of this thread on how to update the necessary hooks in Hooks.scar.
J_Pizzle tells me he is very close to being done with reflection as a whole. Nonetheless, I decided to put this together so people can start using at least the walking for however long it takes J_Pizzle to finish, since people would like using Reflection walking apparently.
Save this in SCAR/Includes as RefWalk.scar and then you can include it with {.include RefWalk.scar}:
Of course, the hooks at the top will become outdated. If you wish to use this after an RS update, you must update the hooks (if you do update them, please post them on this thread so nobody else has to waste time updating). For now, you can steal them from RSBot. Using Widget's hook stealer, you can get a list of the RSBot hooks. NOTE: Replace line 44 with this in Widget's script
After you have all the RSBot hooks, you must find the ones that correspond to the SRL hooks in the include above. Here are the equivalents:
I was going to make a script to do this for you, but J_Pizzle told me he was almost done, so it's not really worth it.
Enjoy :) Let me know if I forgot/epic failed anything.
EDIT: Check out R_WalkPath.
J_Pizzle tells me he is very close to being done with reflection as a whole. Nonetheless, I decided to put this together so people can start using at least the walking for however long it takes J_Pizzle to finish, since people would like using Reflection walking apparently.
Save this in SCAR/Includes as RefWalk.scar and then you can include it with {.include RefWalk.scar}:
//****Tad's temporary reflection walking file***** Credits to J_Pizzle for his help
const
CharMotion = 'rc';
MyPlayer = 'wm.c';
BaseX = 'ii.b';
BaseY = 'rh.p';
CurrentX = 'q';
CurrentY = 'm';
FlagX = 'uq.mc';
FlagY = 'kn.t';
{*******************************************************************************
function GetMyPos:TPoint;
By: BenLand100
Description: Calculates your x,y position or [somehugenumber] if not
logged in
*******************************************************************************}
function GetMyPos:TPoint;
var
me: Integer;
begin
me := SmartGetFieldObject(0, MyPlayer);
Result.x := SmartGetFieldInt(0, BaseX) + SmartGetFieldInt(me, CurrentX) shr 7;
Result.y := SmartGetFieldInt(0, BaseY) + SmartGetFieldInt(me, CurrentY) shr 7;
SmartFreeObject(me);
end;
{*******************************************************************************
Function DistanceFrom(Tile: TPoint): Integer;
By: Widget modded by Timer
Description: Returns the distance between your player and the tile. (Tiles)
*******************************************************************************}
function DistanceFrom(Tile: TPoint): Integer;
var
MyPos: TPoint;
begin
MyPos := GetMyPos;
Result := Distance(MyPos.x, MyPos.y, Tile.X, Tile.Y);
end;
{*******************************************************************************
Function TileToIndex(Tile: TPoint; Path: TPointArray): integer;
By: RM
Description: Returns the Index of the Tile on the Path.
*******************************************************************************}
Function TileToIndex(Tile: TPoint; Path: TPointArray): integer;
begin
for Result := 0 to High(Path) do
if Tile.x = Path[Result].x then
if Tile.y = Path[Result].y then
break;
end;
{*******************************************************************************
function TileToMM(Tile: TPoint): TPoint;
By: BenLand100
Description: Converts the tile position tileX,tileY to a minimap location
*******************************************************************************}
function TileToMM(Tile: TPoint): TPoint;
var
angle: extended;
tempX, tempY: integer;
temp: TPoint;
begin
angle:= rs_GetCompassAngleRadians;
temp := GetMyPos;
tempX:= (Tile.x - Temp.x) * 4 - 2;
tempY:= (Temp.y - Tile.y) * 4 - 2;
Result.x:= round(tempX*cos(angle) - tempY*sin(angle)) + 629;
Result.y:= round(tempX*sin(angle) + tempY*cos(angle)) + 85;
end;
{*******************************************************************************
Function TileOnMM(Tile: TPoint): Boolean;
By: Timer
Description: True = Tile on MM
*******************************************************************************}
function TileOnMM(Tile: TPoint): Boolean;
var
PointEx: TPoint;
begin
PointEx := TileToMM(Tile);
Result := rs_OnMinimap(PointEx.x, PointEx.y);
end;
{*******************************************************************************
function GetFlag(var TFlag: TPoint): Boolean;
By: TheGuyWhoGotOn modded by Timer
Description: Gets your destination (Tiles)
*******************************************************************************}
function GetFlag(var TFlag: TPoint): Boolean;
var
xFlag, yFlag: LongInt;
begin
xFlag := SmartGetFieldInt(0, FlagX);
yFlag := SmartGetFieldInt(0, FlagY);
TFlag := Point((SmartGetFieldInt(0, BaseX) + xFlag), (SmartGetFieldInt(0, BaseY) + yFlag));
Result := (xFlag)and(yFlag) > 0;
end;
{*******************************************************************************
Function GetSpeed : integer;
By: Widget
Description: Gets character speed (squares per second)
*******************************************************************************}
function GetSpeed: Integer;
var
Player: Integer;
begin
Player := SmartGetFieldObject(0, MyPlayer);
result:= SmartGetFieldInt(Player, CharMotion);
SmartFreeObject(Player);
end;
{*******************************************************************************
Function CharacterMoving: boolean;
By: BenLand100
Description: True if you are moving
*******************************************************************************}
function CharacterMoving: boolean;
begin
result:= (GetSpeed > 0);
end;
{*******************************************************************************
function WaitToMove(Timeout: integer): Boolean;
By: lordsaturn
Description: Waits for the local player to move with a timeout. Returns true if
moved, false if timed out.
*******************************************************************************}
function WaitToMove(Timeout: integer): Boolean;
var
a, Player: integer;
begin
a := GetSystemTime;
while not(CharacterMoving) do
begin
if GetSystemTime - a > Timeout then Exit;
Wait(100);
end;
Result := True;
end;
{*******************************************************************************
procedure R_FFlag(Distance: Integer);
By: ZephyrsFury
Description: Similar to the original except it uses Reflection.
NOTE: May return false negative
*******************************************************************************}
procedure R_FFlag(Dist: Integer);
var
Tx, Ty, m, d1, d2: Integer;
P, D: TPoint;
begin
while (GetFlag(D)) do
begin
P := GetMyPos;
d1 := Round(Sqrt(Sqr(D.x - P.x) + Sqr(D.y - P.y)) * 4);
if (d1 >= Dist) then
begin
if not WaitToMove(1000) then Exit;
Inc(m);
Wait(100);
if SRL_Procs[SRL_AntiBan] <> nil then
SRL_Procs[SRL_AntiBan]();
if (Random(100) = 0) then IdleTime(500, 1000, 0.01);
if (m mod 100 = 0) then
if (d1 = d2) then
begin
if (FindColor(Tx, Ty, 255, MMX1, MMY1, MMX2, MMY2)) then
Mouse(Tx, Ty + 14, 0, 0, True)
else
Mouse(MMCX, MMCY, 0, 0, True);
end else d2 := d1;
end else Break;
end;
end;
{*******************************************************************************
Function WalkToTile(Tile: TPoint; Randomness, FlagD: Integer): Boolean;
By: Wizzup and TheGuyWhoGotOn
Description: Walks to the tile using minimap.
*******************************************************************************}
Function WalkToTile(Tile: TPoint; Randomness, FlagD: Integer): Boolean;
Var
wTile: TPoint;
t: Integer;
Begin
Result := False;
Tile := Point(RandomRange(Tile.X-Randomness, Tile.X+Randomness), RandomRange(Tile.Y-Randomness, Tile.Y+Randomness));
wTile := TileToMM(Tile);
If Not rs_OnMiniMap(wTile.X, wTile.Y) Then
Exit;
MFNF(wTile.x, wTile.y, -1, -1);
Wait(RandomRange(80, 100));
t := getsystemtime;
R_FFlag(FlagD);
Result := (GetSystemTime - t) < 60000;
End;
{*******************************************************************************
function ReversePath(Path: TPointArray): TPointArray;
By: Tad
Description: Reverses the order of tiles in a path.
*******************************************************************************}
function ReversePath(Path: TPointArray): TPointArray;
var
Index, AHigh: integer;
begin
SetLength(result, GetArrayLength(Path));
AHigh := High(result);
for Index:=0 to AHigh do
result[Index] := Path[AHigh - Index];
end;
{*******************************************************************************
Procedure R_Flag;
By: Timer
Description: Waits Till A COMPLETE Stop. (Not dependant on Flag hooks)
*******************************************************************************}
procedure R_Flag;
var
Ticker: Integer;
begin
Ticker := (GetSystemTime + 30000);
while (CharacterMoving) do
begin
Wait(10 + Random(10));
if SRL_Procs[SRL_AntiBan] <> nil then
SRL_Procs[SRL_AntiBan]();
if (GetSystemTime > Ticker) then
Exit;
end;
Wait(500 + Random(50));
end;Of course, the hooks at the top will become outdated. If you wish to use this after an RS update, you must update the hooks (if you do update them, please post them on this thread so nobody else has to waste time updating). For now, you can steal them from RSBot. Using Widget's hook stealer, you can get a list of the RSBot hooks. NOTE: Replace line 44 with this in Widget's script
page := GetPage('http://runedev.googlecode.com/svn/trunk/data/info.dat');After you have all the RSBot hooks, you must find the ones that correspond to the SRL hooks in the include above. Here are the equivalents:
RSBot (through Widget's stealer):
isMoving = I.kk.rc
getMyRSPlayer = wm.c
getBaseX = I.ii.b
getBaseY = I.rh.p
getX = I.lq.q (NOTE: There are multiple 'getX' and 'getY's. These are the ones right under 'getData')
getY = I.lq.m
getDestX = I.uq.mc
getDestY = I.kn.t
SRL Equivalent:
CharMotion = 'rc';
MyPlayer = 'wm.c';
BaseX = 'ii.b';
BaseY = 'rh.p';
CurrentX = 'q';
CurrentY = 'm';
FlagX = 'uq.mc';
FlagY = 'kn.t';
I was going to make a script to do this for you, but J_Pizzle told me he was almost done, so it's not really worth it.
Enjoy :) Let me know if I forgot/epic failed anything.
EDIT: Check out R_WalkPath.