SRL Archive - Reflection Development

Zasz Presents Reflection Smarter walking.


ZaSz

2009-05-25 07:06:27

Just make sure no mountains are in the way, unless its easy to navigate them.


My function R_Smartwalk will walk towards a tile smartly. The tile doesn't have to be on the screen. And you can set a minimum tiles it can be away from until results.

All these functions are needed for R-Smartwalk


function GetWalkDir(points:tpoint):string;
var
playerpoint:tpoint;
xs,ys :integer;
begin
playerpoint := getmypos;
xs := playerpoint.x - points.x;
ys := playerpoint.y - points.y;
if xs <= 0 then
begin
result := 'east';
end else
result := 'west';
end;

function insmartbox(ThePoint:tpoint;minaway:integer):boolean;
var
minxus,minyus,mynum: integer;
playerpoint:tpoint;
begin
playerpoint:= getmypos;
minxus := playerpoint.x - ThePoint.x;
if(minxus<0)then
minxus := iAbs(minxus);
minyus := playerpoint.y - ThePoint.y;
if(minyus<0)then
minyus := iAbs(minyus);
if((minxus+minyus)<=minaway)then
result := true;
end;

function Smartgetlengthaway(pointz:tpoint):integer;
var
minxus,minyus,mynum: integer;
playerpoint:tpoint;
begin
playerpoint:= getmypos;
minxus := playerpoint.x - pointz.x;
if(minxus<0)then
minxus := iAbs(minxus);
minyus := playerpoint.y - pointz.y;
if(minyus<0)then
minyus := iAbs(minyus);
if((minxus+minyus)>=10)then
result := 17;
if((minxus+minyus)<10)then
result := 14;
end;

function R_smartwalk(ThePoint:tpoint;minaway:integer):boolean;
var
zaszsvar :integer;
thewalkpoint,playerpoint:tpoint;
begin
repeat
playerpoint := getmypos;
MakeCompass('n');
wait(200+random(500));
case GetWalkDir(ThePoint) of
'east' : begin
x2 := (p.x + Smartgetlengthaway(ThePoint) - 7 -random(4))
end;
'west' : begin
x2 := (p.x - Smartgetlengthaway(ThePoint) + 7 +random(4))
end;
end;
thewalkpoint:= (point(y2+2+random(3),ThePoint.y+random(2)));
walktotile(point(thewalkpoint.x,thewalkpoint.y),2,2);
wait(200+random(500));
until((insmartbox(ThePoint,minaway))or(zaszsvar=100));
if(insmartbox(ThePoint,minaway))then
result := true;
end;

^ I know, standards are weird.

Lets break each 1 down.

function GetWalkDir(points:tpoint):string;
var
playerpoint:tpoint;
xs,ys :integer;
begin
playerpoint := getmypos;
xs := playerpoint.x - points.x;
ys := playerpoint.y - points.y;
if xs <= 0 then
begin
result := 'east';
end else
result := 'west';
end;

^ that returns the direction the point is witch is East or West.


function insmartbox(ThePoint:tpoint;minaway:integer):boolean;
var
minxus,minyus,mynum: integer;
playerpoint:tpoint;
begin
playerpoint:= getmypos;
minxus := playerpoint.x - ThePoint.x;
if(minxus<0)then
minxus := iAbs(minxus);
minyus := playerpoint.y - ThePoint.y;
if(minyus<0)then
minyus := iAbs(minyus);
if((minxus+minyus)<=minaway)then
result := true;
end;

^ returns if you are the minaway amount of tiles from the point.

function Smartgetlengthaway(pointz:tpoint):integer;
var
minxus,minyus,mynum: integer;
playerpoint:tpoint;
begin
playerpoint:= getmypos;
minxus := playerpoint.x - pointz.x;
if(minxus<0)then
minxus := iAbs(minxus);
minyus := playerpoint.y - pointz.y;
if(minyus<0)then
minyus := iAbs(minyus);
if((minxus+minyus)>=10)then
result := 17;
if((minxus+minyus)<10)then
result := 14;
end;

^ Returns the long or short amount for length to walk.

function SmarthTilesAway(pointz:tpoint):integer;
var
minxus,minyus,mynum: integer;
playerpoint:tpoint;
begin
playerpoint:= getmypos;
minxus := playerpoint.x - pointz.x;
if(minxus<0)then
minxus := iAbs(minxus);
minyus := playerpoint.y - pointz.y;
if(minyus<0)then
minyus := iAbs(minyus);
result := minxus + minyus;
end;

^ Turns the actual tiles away.

function R_smartwalk(ThePoint:tpoint;minaway:integer):boolean;
var
zaszsvar :integer;
thewalkpoint,playerpoint:tpoint;
begin
repeat
playerpoint := getmypos;
MakeCompass('n');
wait(200+random(500));
case GetWalkDir(ThePoint) of
'east' : begin
x2 := (p.x + Smartgetlengthaway(ThePoint) - 7 -random(4))
end;
'west' : begin
x2 := (p.x - Smartgetlengthaway(ThePoint) + 7 +random(4))
end;
end;
thewalkpoint:= (point(y2+2+random(3),ThePoint.y+random(2)));
walktotile(point(thewalkpoint.x,thewalkpoint.y),2,2);
wait(200+random(500));
inc(zaszsvar);
until((insmartbox(ThePoint,minaway))or(zaszsvar=100));
if(insmartbox(ThePoint,minaway))then
result := true;
end;

^ uses all the functions above to the box..

example of usage.

SmartWalk(point(3050,3266),5);

^ that will attempt to walk to that point but will attempt to walk by the point until its within 5 tiles from it.

Please note: Some tiles have to be pretty close even if they are off the minimap and some don't.

Creds to the people that helped me with IAbs.

Da 0wner

2009-05-25 07:16:19

Pretty sexy :D. But "people" didn't help you with iAbs, I did :p.

mormonman

2009-05-25 07:22:58

Problem #1: gates, fences, or other obstacles that give you the illusion that you can walk there. Plus some places can't just be walked to with a straight line.

ZaSz

2009-05-25 08:22:41

this doesn't walk in a straight line which makes it smarter. just make it walk to gate and open then use the next point. <- failsafe… Fences can be walked around when you click on other side.

mormonman

2009-05-25 08:26:28

what about buildings… it will walk inside buildings a lot if it is trying to navigate in a city and that is bannable.

Blumblebee

2009-05-25 08:30:28

From: mormonman
what about buildings… it will walk inside buildings a lot if it is trying to navigate in a city and that is bannable.


so dont use it for walking through a city? Just use it where it applies practically.

ZaSz

2009-05-25 08:32:31

From: Blumblebee
so dont use it for walking through a city? Just use it where it applies practically.


+1:D

Camaro'

2009-05-26 00:17:28

Like from Barbarian village to varrock?

Is that too far?

ZaSz

2009-05-26 00:24:32

Shouldn't, might need a r_smartwalk for a point inbetween as a failsafe.

mormonman

2009-05-26 01:22:31

it will only work for straight paths. i am not totally against this, not you(zasz) but the idea of it is kinda stupid. i believe each script needs to have its own path(s). It could be good for the straight away parts though.

Edit: was this used in your unfinished world walker?

jakeyboy29

2009-05-26 01:30:07

this could be used for example, in a script;
start
find location
at cammy
walk to minning guild
start script.

ZaSz

2009-05-26 02:19:57

From: mormonman
it will only work for straight paths. i am not totally against this, not you(zasz) but the idea of it is kinda stupid. i believe each script needs to have its own path(s). It could be good for the straight away parts though.

Edit: was this used in your unfinished world walker?


I made it for the world walker. To big a project for 1 person though.

Now im using it for multi-buyer script.