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
^ I know, standards are weird.
Lets break each 1 down.
^ that returns the direction the point is witch is East or West.
^ returns if you are the minaway amount of tiles from the point.
^ Returns the long or short amount for length to walk.
^ Turns the actual tiles away.
^ uses all the functions above to the box..
example of usage.
^ 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.
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.