SRL Archive - Unofficial Development

[R] spinDo 0.1 - Write entire botting scripts in just a few lines! Your Welcome!


killm3

2014-11-15 22:41:24

I'm new and thought I'd contribute.

spinDo is a single function that does pretty much everything you'd want from a script in a single function.

The script makes sure your character has stayed within the pre-defined area (and walks there if not), finds whatever object you're looking for, and performs an action.

MAKE SURE TO SET CAMERA TO HIGHEST ANGLE

{*******************************************************************************
Function R_spinDo(objectName, objectAction: String; centerOfRovingArea: TPoint;
radiusOfRovingArea, searchDistance, howLongToSearch: Integer;)
By: A Proud American
Description: Basically an AIO function to reliably search an area for an object
and perform an action on it. Works best if object isn't moving (non-NPC).
*******************************************************************************}
Function R_spinDo(objectName, objectAction: String; centerOfRovingArea: TPoint; radiusOfRovingArea, searchDistance, howLongToSearch: Integer): Boolean;
var
Timer: Integer;
hereWeAre, hereWeAreLooking: TPoint;
begin
//Make sure we are within (radiusOfRovingArea) of (centerOfRovingArea)
if not (R_NearTile(centerOfRovingArea,radiusOfRovingArea)) then
begin
R_BlindWalk(centerOfRovingArea[ATTACH]24445[/ATTACH]);
end;
//Begin Spinning
KeyDown(VK_RIGHT);
//Mark the time we started Spinning
markTime(Timer);
//Start Main search Cycle
repeat
//Log out current tile
hereWeAre := R_GetTileGlobal();
//Move the Mouse to a a random tile within (searchDistance)
hereWeAreLooking := Point((hereWeAre.x + RandomRange(1, searchDistance)), hereWeAre.y);
hereWeAreLooking := R_TileToMs(hereWeAreLooking);
MMouse(hereWeAreLooking.x,hereWeAreLooking.y,10,10);
Wait(RandomRange(1111, 2222)+RandomRange(1, 555));
//Continue Spinning until we find the object or we timeout
until((R_IsUpText(objectName) = true) or (timeFromMark(Timer)>howLongToSearch))
//Stop Spinning
KeyUp(VK_RIGHT);
KeyUp(VK_LEFT);
//Confirm that object and action are under the mouse
if(R_IsUpText((objectAction + ' ' + objectName)) = true) then
begin
ClickMouse2(Mouse_Right);
Wait(RandomRange(11, 77)+RandomRange(1, 555));
R_ChooseOption((objectAction + ' ' + objectName));
Result := true;
end else
begin
Result := false;
end;
end;

Feel free to include it in any script you want.

Here's an example of a very stable and short power-woodcutting script that can run for hours if you add in antirandoms.

procedure cutTrees;
begin
repeat
repeat
//objectName, objectAction, centerOfRovingArea, radiusOfRovingArea, searchDistance, howLongToSearch
if(R_spinDo('Willow', 'Chop down', Point(2917, 3298), 15, 5, 10000) = true) then
begin
//If the above returned true, give the character time to start performing action
Wait(RandomRange(3333, 5555)+RandomRange(1, 555));
while (R_IsAnimating = true) do
begin
Writeln('Performing Action!');
Wait(RandomRange(3333, 5555)+RandomRange(1, 555));
end;
end;
until(R_InvCount = 28)
Writeln('Finished Chopping, Dropping Logs!');
DropArray([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28]);
clearDebug;
until(false);
end;

KeepBotting

2014-11-16 09:27:51

Quite interesting. So basically - it moves the camera whilst walking to the object it wants to interact with?

I can see how that'd be useful, if your desired object isn't on the screen, or is, but invisible at your current camera angle.

Pretty nice. Thanks for the share!

Krazy_Meerkat

2014-11-18 20:25:44

Nice effort but some things you may want to consider:
      KeyDown(VK_RIGHT);
Don't always use the same direction, how about a 50/50 chance for right/left like so:
RightPressed:= false;
if (Random(2) = 0) then
begin
KeyDown(VK_RIGHT);
RightPressed:= true;
end else
KeyDown(VK_LEFT);
Notice the boolean, that is so that you can tell which KeyUp to use
        KeyUp(VK_RIGHT);
KeyUp(VK_LEFT);
the correct use of KeyUp is like so:
if (RightPressed) then
begin
KeyUp(VK_RIGHT);
end else
KeyUp(VK_LEFT);

Looking over your function some more, I noticed you only add randomRange for the X co-ordinate:
        hereWeAreLooking := Point((hereWeAre.x + RandomRange(1, searchDistance)), hereWeAre.y);
You will likely want it on your Y co-ord as well, but how about making the radius (searchDistance) a box around your player and not just from the center to the east/north, here's something I prepared earlier to show you:
hereWeAreLooking := Point((hereWeAre.x + RandomRange(-searchDistance, searchDistance)), hereWeAre.y + RandomRange(-searchDistance, searchDistance)));
Not bad for a first attempt, but what is going on with those standards? Neaten it up please!

Qw4rt6yu9

2014-11-19 06:30:06

Would this work for old school?

Hoodz

2014-11-19 06:37:35

From: Qw4rt6yu9
Would this work for old school?


this is only for oldschool since rs3 (simba) doesnt support reflection.

Qw4rt6yu9

2014-11-19 06:43:43

From: hoodz
this is only for oldschool since rs3 (simba) doesnt support reflection.


Thanks, been out of the loop for a while.