SRL Archive - SRL Archives

Great MapWalking/ RunAway Procedures


SKy Scripter

2007-04-21 04:08:21

ok, you might say well this has already been created.
not like this!! this super useful because it walks in the given
direction no matter wich way your map is facing!

also my RunToEx should be replaced with RunTo,
and my RunBackEx should be replaced with RunBack

FixCoords Is way Useful if you now how to use right….

AnyWays i thought i would share these procedures because i they been
helping alot!



{*******************************************************************************
Function ReturnDirDegrees(Dir : String) : Integer;
By: Sky Scripter
Description: Used To Return The Degrees Of Directions
*******************************************************************************}
Function ReturnDirDegrees(Dir : String) : Integer;
begin
Dir:= Trim(lowercase(dir));
Case Dir Of
's', 'south' : Result := 180;
'e', 'east' : Result := 90;
'w', 'west' : Result := 270;
end;
end;

{*******************************************************************************
Procedure FixCoords(Var x, y: Integer; Dir : String; Radius, Tol : Integer);
By: Sky Scripter
Description: Sets The coords from Point x, y point to wards the given direction
*******************************************************************************}
Procedure FixCoords(Var x, y: Integer; Dir : String; Radius, Tol : Integer);
Var
Deg : Integer; // it may not show "north" but it still works
begin
Deg:= ReturnDirDegrees(Dir)
x:= Trunc(Radius * Sin((Pi / 180) * (Rs_GetCompassAngleDegrees + FixD(Deg + Tol))) + x);
y:= Trunc(-Radius * Cos((Pi / 180) * (Rs_GetCompassAngleDegrees + FixD(Deg + Tol))) + y);
end;


{*******************************************************************************
Procedure CompassWalk(Dir : String; Radius, Tol : Integer);
By: Sky Scripter
Description: Walks The Direction given,
Raduis is the distance of how far to walk.
Tol is the add on, if tol is postive i goes more to Right, if it is negitave number
it goes to the left.
*******************************************************************************}
Procedure CompassWalk(Dir : String; Radius, Tol : Integer);
Var
dx, dy, Deg : Integer; // By Sky Scripter
begin
If (Not(LoggedIn)) then Exit;
Deg:= ReturnDirDegrees(Dir)
dx:= Trunc(Radius * Sin((Pi / 180) * (Rs_GetCompassAngleDegrees + FixD(Deg + Tol))) + 648);
dy:= Trunc(-Radius * Cos((Pi / 180) * (Rs_GetCompassAngleDegrees + FixD(Deg + Tol))) + 83);
MouseFindFlag(dx, dy, -1, 1);
end;

{*******************************************************************************
Procedure RunToEx(Dir : String; RunFar : Boolean);
By: Sky Scripter
Description: Just Like "Runto" but this will run to the direction no matter what
Direction your map is facing!
*******************************************************************************}
Procedure RunToEx(Dir : String; RunFar : Boolean);
Var
Dist:Integer;
begin
Case RunFar Of
True : Dist := 60 + Random(10);
False : Dist := 40 + Random(10);
end;
SendInterSCARInteger('RunEx_Dist', Dist);
SendInterSCARInteger('RunEx_Deg', ReturnDirDegrees(Dir));
CompassWalk(Dir, Dist, Random(5) - Random(5));
SetRun(True);
Flag;
SetRun(False);
GameTab(4);
end;

{*******************************************************************************
Procedure RunBackEx;
By: Sky Scripter
Description: Runs Back From RunToEx;
*******************************************************************************}
Procedure RunBackEx;
Var
Dist, Deg, dx, dy, Tol :Integer;
begin
Dist:= ReadInterSCARInteger('RunEx_Dist');
Deg := ReadInterSCARInteger('RunEx_Deg') - 180;
Tol := Random(5) - Random(5);
dx:= Trunc(Dist * Sin((Pi/180) * (Rs_GetCompassAngleDegrees + FixD(Deg + Tol))) + 648);
dy:= Trunc(-Dist * Cos((Pi/180) * (Rs_GetCompassAngleDegrees + FixD(Deg + Tol))) + 83);
MouseFindFlag(dx, dy, 1, 1);
SetRun(True);
Flag;
SetRun(False);
GameTab(4);
end;

Rune Hacker

2007-04-21 04:10:45

Wow those can really come in handy. Where do you learn to make things like these btw because these functions are new to me lol. Where do you learn how to use them properly and stuff.

SKy Scripter

2007-04-21 04:25:28

Wow those can really come in handy. Where do you learn to make things like these btw because these functions are new to me lol. Where do you learn how to use them properly and stuff.


Dude i practice alot lol… read tons of SRL Scripts
and look for weaknesses that need inprovement…
i love reading BenLad100 Scripts because he is Really Smart!
and i learn alot from him..