SRL Archive - Senior Scripts and Snippets

SCARSbot. As fast and as accurate at RSBot! (Almost? :p)


YoHoJo

2009-12-08 21:11:56

So I've been talking to BeBe a bit on MSN and her experience with RSBot. Then I got rsbot, used it, liked it a lot, but of course I'm still always SCAR/SRL FIRST! Sorta tried to learn how to script for it, but their community blows (duh). I'm not a java guy, people suck at teaching, tuts are 1/2 assed and linked to own sites so we can click their adds ect ect, so I kinda screwed that.

But during all of this and messing with RsBot settings I had an amazing idea!
I thought, wouldn't it be great if we could use easy PASCAL/SCAR coding to do reflection stuff (like reflection.scar which is broken though)!? And then it came to me! I mainly created this for a few reasons: Too lazy/hard to learn RSBot scripting, it would be nice to do reflection stuff with SCAR code (since I'm so accustomed to it/reflection is down), and it was just a random idea I had! :p

On RsBot (for those of you who haven't used it) you can click View>Objects.
This puts and Object ID and Red Dot on every single object, like so:

You can also click View>Animation.
This puts your animation at the top right (-1 means idle), like so:

So, if RSBot can draw nice stuff for us all over the canvas, and SCAR is a colorclicker, I just put 2 and 2 together, and did some simple work got this stuff.

First, I made RSBot chars, digits 0-9 and put them in my font folder.
Then I created these functions (based off of some things from SRL) don't laugh at my bad scripting :D.

Function FindObjectID(Text:string; Click:Boolean): Boolean;
var
tx, ty, S, MyChars,X,Y: Integer;
begin
Result := False;
MyChars:=LoadChars2('C:\Program Files\SCAR 3.21\Fonts\MyChars\')
S := CreateBitmapMaskFromText(Text, MyChars);
if FindBitmapMaskTolerance(S, tx, ty, MSX1, MSY1, MSX2, MSY2, 10, 30) then
begin
Result := True;
If Click Then
Begin
X:=Tx
Y:=Ty
If FindColor(x,y,255,tx-30,ty-30,tx+30,ty+30) Then
Mouse(x,y,4,4,True);
End;
end;
FreeBitmap(S);
end;

Function MyAction(Text:string): Boolean;
var
tx, ty, S, MyChars: Integer;
begin
Result := False;
MyChars:=LoadChars2('C:\Program Files\SCAR 3.21\Fonts\MyChars\')
S := CreateBitmapMaskFromText(Text, MyChars);
if FindBitmapMaskTolerance(S, tx, ty, 62, 19, 76, 34, 10, 30) then
begin
Result := True;
end;
FreeBitmap(S);
end;

Function AmIdle:Boolean;
Begin
If (GetColor(65, 30) And GetColor(66, 30) And GetColor(67, 30)=65280) Then
Result:=True;
End;

FindObjectID(Text:string; Click:Boolean): Boolean; finds an Object based on the ID you tell it, and then looks for the nearest Red Dot, and clicks it.

Function MyAction(Text:string): Boolean; checks to see if you current action is what you asked it to be. (GetMyAction could also be useful I guess?)

AmIdle was supposed to be If MyAction('-1') Then Result:=True, but the "-" sign was giving me trouble and coming up positive a lot (its only 3 pixels long, lots of numbers contain it), so I got basic and just did a color check.

These are the 3 basic, but core functions I decided to make and test.

Next, as a test, I impimented these functions into my PMS (Power Miner Supreme) to see if they worked, and they DID! Accurate, Fast, EASY!

Here is my mining procedure edited with SCARSBot functions:
Function MineRock(WutRock:Integer):Boolean;
var I,PlusOne,tMine:Integer;
RockInFoI: TIntegerArray;
Begin
If Not(LoggedIn) Then Exit;
StatsGuise('Searching For Rock');
If OreInLast Then Exit;
Case WutRock of
1: Begin RockInFoI:=[3701475,]; End; //object IDs
2: Begin RockInFoI:=[11960, 11961, 11962]; End; //object IDs
3: Begin RockInFoI:=[11958, 11957, 11959]; End; //object IDs
4: Begin RockInFoI:=[11554, 11955, 11596]; End; //object IDs
End;
For I:=0 To High(RockInfoI) Do
Begin
Wait(200+Random(150));
If FindObjectID(IntToStr(RockInfoI[I]),True) Then //Finds object by ID and clicks it
Begin
Flag;
MarkTime(tMine);
StatsGuise('Mining Rock');
Players[CurrentPlayer].Loc:='Mining';
PlusOne:=InvCount+1;
While Amidle Do //While Idle Do, (For SPEED! :p) Once you are idle, it goes onto next function/procedure.
Begin
Wait(100);
FindNormalRandoms;
If Random(50)=1 Then SleepAndMoveMouse(500+Random(100));
If (InvCount = PlusOne) Or
(TimeFromMark(tMine) > ((Players[CurrentPlayer].Integers[2]*1000) + Random(500))) Then
Break;
End;
Result:=True;
Exit;
End;
End;
End;

Here is a ghetto picture I made about it:
http://imagebin.org/74672

Was thinking about showing this is SRL members/Anyone and even work on a very mini include for it, although those 3 functions (and maybe just a few more) are all that are really needed.
(I'm not asking for this to be a part of SRL of course, that would be crazy, just thinking of making a googlecode place for it, and seeing if people would be interested). Who knows, maybe with further development some new things will be possible/or at least easier to script.

So um yeah, just showing you guys a neat little project/concept I was trying out. What do you all I think? I lol'd hard when I ran it and it worked!

Edit: Attached the font. Just put it in a folder in C:\Program Files\SCAR 3.XX\Fonts

Widget

2009-12-08 21:52:10

Wow I can't believe no one thought of this sooner xD.

I suggest we take this one step farther and go back to what KYAB more or less was. Use SRL for the mouse functions, etc, and RSBot for getting coords of objects and such. As far as I know RSBot is GPL, we could even fork it and just use their up-to-date binaries

YoHoJo

2009-12-08 22:01:10

Yeah pretty simple idea.
I'm not very familiar with KYAB, never used it.
All we need really is a 'SMART' version of rsbot THAT STILL DRAWS ON RS and we're all good.
Anyone have ideas what functions would be useful? Animation and Object ID is all that's needed to make a basic working script, I wish so hard that that there was an option for each TILE to have their coordinates on them, that would rock. I wonder if we could make RSBot draw on certain tiles on the minimap and have scar click them!

Like color a path of tiles from VEM to Varrock East Bank on RSBot and then just have scar click them (of course with randomness).

The possibilites are endless, as long as RSBot can draw/color objects/tiles, we can SCAR script for it simply!

Once again, the reason I like is that we are using the abilities of another bot to make scripting with SCAR easier. (Like, RSBOT/Java coding is a bit difficult to me, and I'm so accustomed with SCAR, its cool that I can use a mix of SCAR scripting and RSBot features to make a functional script!

Also, I forgot to attach the fonts, ill edit the post in an hour or so.
Sorry about the messiness of this post :p.

Method

2009-12-08 23:23:49

Are you really suggesting using RSBot as a client for SCAR? I don't know if it's just me, but it seems odd to have one bot running off of another..

Also, if you want to learn to script for RSBot, I really recommend you learn Java first. You'll find it so much easier to do.

YoHoJo

2009-12-08 23:34:54

Odd yes, but it works. :D And its easier/more accurate in a sense.

Yeah you are right, I just assumed the RSBot scripting tutorials would teach me java along with standards/whatever of RSBot scripting.
I guess I should go on over to MoparIsThheBest to learn some java.

Method

2009-12-08 23:42:17

From: YoHoJo
Odd yes, but it works. :D And its easier/more accurate in a sense.

Yeah you are right, I just assumed the RSBot scripting tutorials would teach me java along with standards/whatever of RSBot scripting.
I guess I should go on over to MoparIsThheBest to learn some java.


I'd recommend reading Sun's official tutorial on Java or taking a class if you're interested in learning.

YoHoJo

2009-12-08 23:44:55

No time for actual Java Classes right now.
Ill check out Sun's tutorials then, thanks.

Bobarkinator

2009-12-09 00:16:05

I think that making a KYAB type bot out of RSBot would be easier then doing this.

YoHoJo

2009-12-09 00:47:37

Can someone please explain how KYAB worked please?
Also bob there isnt much more to do (well as far as I went at lest).

I had an all SCAR powerminer: Found rocks by color, clicked next rock when ore obtained or a timer ran out.
I just used those three functions above and now it more or less: Finds rocks by ID, and clicks next rock when your character is idle.

That's all the work I had to do :D, and it works great.

Bobarkinator

2009-12-09 01:14:34

From: YoHoJo
Can someone please explain how KYAB worked please?
Also bob there isnt much more to do (well as far as I went at lest).

I had an all SCAR powerminer: Found rocks by color, clicked next rock when ore obtained or a timer ran out.
I just used those three functions above and now it more or less: Finds rocks by ID, and clicks next rock when your character is idle.

That's all the work I had to do :D, and it works great.



KYAB used reflection to gather data from the client just like SMART. But KYAB wasn't a plugin, scar opened a connection on a certain port, 44 I believe it was. KYAB would open a connection on the same port so SCAR could send commands and KYAB would send the data back like tile or objects or anything.

Cazax

2009-12-09 06:37:50

But then these kind of scripts would rely on RSBot, if it's outdated then they are too. Though this would do fine as an alternative to reflection being broken.

n3ss3s

2009-12-09 07:13:59

Cool shit man! Except for… no minimizing :(

Boreas

2009-12-10 02:12:03

You can use this for tile walking too.

In WalkToTile, change R_FFlag to color based.
In TileToMM change getMinimapAngleRad to 0, as jagex gives us perfect(?) north by clicking on compass.
Then in TileToMM change GetMyPos to GetMyPos2, see PoC attached.

Edit: SCAR:WINE/RSBot:Linux only atm. Will add Windows support tomorrow.

Edit2: Could someone pm me a png/bmp screenie of RSBot with View>PlayerPosition checked on windows, with a 9 in there, preferably with another number on either side.

Smartzkid

2009-12-10 21:09:41

Why not use SMART?

Widget

2009-12-10 21:11:25

Because Reflection is slightly completely dead at the moment :p. RSBot has been really good about staying updated

YoHoJo

2009-12-10 21:22:22

@Cazax AFAIK Rsbot updates fast anyway so its not a problem to rely on it for this to work.
@SmartzKid, If by SMART you mean reflection, reflection is broken. And SMART doesnt debug/show all of the IDs/Tiles of everything.

=D I still think its a neat idea!

Boreas

2009-12-10 22:35:31

This might work, though it needs both SCAR and RSBot in windows/wine/vm.

Edit: Works, just had to replace rs_onminimap.

Wanted

2009-12-10 23:10:51

Lol @ this

Ruler has tried multiple times to get people to do something like this, only it was official and made specifically for SCAR and almost no one used it or was interested in it.

UBI

YoHoJo

2009-12-10 23:22:48

From: Boreas
This might work, though it needs both SCAR and RSBot in windows/wine/vm.

Edit: Works, just had to replace rs_onminimap.


Got a slightly different version of this from Boreas over MSN.
Awesome job Boreas!
Walked from Lumbridge to South Varrock.

101937ms
Successfully executed


Ediit:
Script attached below with Boreas' MM Fucntions, and my Path from Lumbrige to Varrock.
Open RSBot. View> Player Position.
Log In, Stand In Lumbrdige Spawn Area. Run The Script!
(It kinda 'ballparks' the clicks, so you may need to help if it clicks inside of a fence or something, but It works for the most part!)

Widget

2009-12-11 00:29:51

What's wrong with this to read the text?
program New;
var
x, y, PosDTM, font, i: integer;
text: string;
procedure ScriptTerminate;
begin
FreeChars2(font);
FreeDTM(PosDTM);
end;
begin
PosDTM := DTMFromString('78DA63E460606090644005FF21142394CB280' +
'C241409A8D103123204D480CC9023A006E41E79026A3408BB0700' +
'0F890755');
FindDTM(PosDTM, x, y, 0, 0, 200, 350);
x := 8; // Since it really doesn't change
y := 25;

font := LoadCharsFromFont2('Arial', 9, false, false, false, false);
repeat
i := 0;
repeat
text := GetTextAtEx(x-1, y-3+(20*i), 1, font, false, false, -1, 1, $00FF00, 50, true, tr_AllChars);
text := trim(text);
Writeln(text);
Inc(i);
until text = '';
sleep(500);
until False;
end.
Just do Replace(text, '` ', '7'); since it finds ` instead of 7 for some reason *pokes freddy*

YoHoJo

2009-12-11 02:00:00

Edit:
:'( That some people don't like it, but whatever :p.
The reason I kept it in here is just because I dont want to show SRL members for the fear that they will need to DL RSBot to use it, and then might ditch SRL for RSBot, which I would hate. All of us in here <3 SCAR and would never leave, so I just kept it here :p.
Now that Boreas has created walking this is pretty much as good as reflection (except for the lack of minimizing :( )

Lets try making a Rune Mysteries Quester or something crazy for this :p.

YoHoJo

2009-12-11 02:00:15

As you asking me whats wrong?
Or are you saying that works?
I/Boreas didn't know what font/font size the RSBot chars are so I made a font/Boreas used color, but if that works, then great thanks!

Edit:
Lumbridge To Draynor Bank Script Attached :D:
SRL Compiled in 16 msec
121860
Successfully executed


Edit:

The reason I kept it in here is just because I dont want to show SRL members for the fear that they will need to DL RSBot to use it, and then might ditch SRL for RSBot, which I would hate. All of us in here <3 SCAR and would never leave, so I just kept it here :p.
Now that Boreas has created walking this is pretty much as good as reflection (except for the lack of minimizing :( )

Lets try making a Rune Mysteries Quester or something crazy for this :p.

mixster

2009-12-11 02:55:37

I still have sauces for my Delphi plugin that allows calling Java functions from inside Scar, so if anyone felt up to it they could attempt to mod RSBot to output directly to Scar. If anyone is, I can post up this afternoon (a bit tight for time atm) - don't expect it to be amazing though as the Delphi JNI is badly documented and out of date (I know Freddy may have a more up to date or one fixed by himself that may run better, though I'm unsure of it since the sauce disappeared).

YoHoJo

2009-12-11 02:57:23

From: mixster
I still have sauces for my Delphi plugin that allows calling Java functions from inside Scar, so if anyone felt up to it they could attempt to mod RSBot to output directly to Scar. If anyone is, I can post up this afternoon (a bit tight for time atm) - don't expect it to be amazing though as the Delphi JNI is badly documented and out of date (I know Freddy may have a more up to date or one fixed by himself that may run better, though I'm unsure of it since the sauce disappeared).


I'm a little lost?
You can use a scar function to do something in Java is what your saying?
Similar to reflection then I guess?

Explain it better for dumb people like me please :).

Widget

2009-12-11 03:27:59

From: mixster
I still have sauces for my Delphi plugin that allows calling Java functions from inside Scar, so if anyone felt up to it they could attempt to mod RSBot to output directly to Scar. If anyone is, I can post up this afternoon (a bit tight for time atm) - don't expect it to be amazing though as the Delphi JNI is badly documented and out of date (I know Freddy may have a more up to date or one fixed by himself that may run better, though I'm unsure of it since the sauce disappeared).


If you're saying you could stuff the entire \src\org\rsbot\accessors folder into a plugin that'd be great :D

Boreas

2009-12-11 10:12:39

From: YoHoJo
I'm a little lost?
You can use a scar function to do something in Java is what your saying?
Similar to reflection then I guess?

Explain it better for dumb people like me please :).


Rather than control the mouse and keyboard, and look at the screen, send mouse and keyboard commands and receive tile coords, and maybe color too, so minimizing.

I think people that really want reflection (well tile walking, as rsbot uses bytecode, reading not writing) will go to rsbot/ibot anyway. In fact, giving them tilewalking in a form they are used to would be more likely to encourage them to script more IMO.

mixster

2009-12-11 11:55:26

It runs Java methods (including creating objects and the like), so you would just have to write a few Delphi procedures that would call the Java methods etc. It would most likely require a bit of reading up and knowledge of how RSBot runs to ensure it all works correctly. Anyway, this would just mean that instead of reading the RSBot screen for tile ID's etc you could just create a function for Scar to call that would collect it. It would also mean any other data RSBot stores you could access, so could be used as a non-minimizable Smart if you wanted to give it reflection capability.

Anyway, as it seems there be interest, I'll upload it after I start up my laptop.
Edit: Attached it including a test Java class (an old client I started working on and soon gave up). I'm pretty sure it's a working version, if not I did have a quick look over and it would be because the JNI is quite silly for Delphi.

Widget

2009-12-12 04:18:57

From: mixster
It runs Java methods (including creating objects and the like), so you would just have to write a few Delphi procedures that would call the Java methods etc. It would most likely require a bit of reading up and knowledge of how RSBot runs to ensure it all works correctly. Anyway, this would just mean that instead of reading the RSBot screen for tile ID's etc you could just create a function for Scar to call that would collect it. It would also mean any other data RSBot stores you could access, so could be used as a non-minimizable Smart if you wanted to give it reflection capability.

Anyway, as it seems there be interest, I'll upload it after I start up my laptop.
Edit: Attached it including a test Java class (an old client I started working on and soon gave up). I'm pretty sure it's a working version, if not I did have a quick look over and it would be because the JNI is quite silly for Delphi.

Awesome. I'll look into it once it's less 3am-ful :p

We could actually run reflection scripts unmodified except for taking out the SetupSmart line by replacing things like MoveMouse to ones that would move RSBot's mouse, so we would be using the SRL Mouse spline (which IMO is better than RSBot's). This would also be minimizable and have a nice debug screen, and not have any of SMART's evil bugs :)

I'm not sure if I'm being clear about the way this looks to me in my head so I'll try better:
- Mixster's thing loads up RSBot inside SCAR or whatever through the plugin.
- Several low-level injected functions are hooked by the plugin, and wrapped through the Reflection include (although it's technically not reflection anymore).
- SCAR's low-level keyboard and mouse functions are overwritten by a new include file, replacing smart.scar
- The not-smart.scar file moves the RSBot "mouse" as would SMART's, so minimizing would work.
- Fancy debugging :D

mastaraymond

2009-12-12 08:07:34

I don't see how this is going to work? Why would you use SRL for RSBot, when RSBot itself is way more accurate than SRL is ever going to get? That just seems stupid…

Can't we just 'steal' the hooks from RSBot and get SMART to work?

lordsaturn

2009-12-12 11:40:48

From: mastaraymond
I don't see how this is going to work? Why would you use SRL for RSBot, when RSBot itself is way more accurate than SRL is ever going to get? That just seems stupid…


Exactly, it's ironic, the way we have a more efficient and reliable method sitting right in front of us but we choose not to use it..

What I'm trying to say is, if we're trying to use reflection in our scripts, why not ACTUALLY use reflection, instead of using it's debug. That seems sorta silly.

And if we the elite want something like this, the heart of the community, how come we aren't over at RSCheata? This functionality we are discussing, a reflection-color combo can be achieved easily by iBot, or by SMART+SCAR. But at this point it seems like iBot is just a more mature version of SMART+SCAR, or an image of what we want it to become.

How can grabbing text on a screen relevant to an object's position be better than just grabbing the object's position? It doesn't make much sense to me.

mixster

2009-12-12 11:59:40

As reflection isn't working 100% at the moment, this was a suggested way to use reflection without having reflection.

Also, Widget is pretty much on track. No colour functionality though (as RSBot has none), so it would either have to be pure "reflection" else non-minimizable (though you would still have mouse and keyboard).

lordsaturn

2009-12-12 12:26:57

I think this project would be a lot more viable if we found a way to call RSBot functions from SCAR. Only then would this project be superior to RSBot.

mixster

2009-12-12 12:37:06

Yeah, that's kind of where JNI comes in…

YoHoJo

2009-12-12 13:16:39

@lordsaturn/mastaraymond
m(lowercase m)ixsters attachment is to help with you thought of "way to call RSBot functions from SCAR. Only then would this project be superior to RSBot. "
Also, the point of this is just a silly idea I had. I dont know Java at all, not many people at RSBot are helpful. IMO Many Many more willing and able people who can script pascal are here, compared to the 10000s of leechers at RSBot. So this is just a way to use easy smeasy pascal coding to do what RSBot does without the hassle of me having to lean java :p. Also RSBot doesn't have player switching :p!

If I knew Java, I'd definitely be making RSBot scripts, but since I don't, this was the next best things for me =D. Now I can make awesome accurate scripts that can even walk without having to wait for reflection or lean java, its just a ghetto temporary solution for now, and a silly idea :D.

@mastaraymond 'Stealing Hooks' is easier said than done obviously, since no one has done it yet. You need some good knowledge of java,scar,and how the RS client works from what I hear, and not many people have enough knowledge to do so/care enough?

Bobarkinator

2009-12-12 13:34:28

Seriously, I have publicly stated that I am against stealing hooks from RSBot. But seeing the current state of SRL, I am becoming more inclined to do so. I'll write up a class later to strip the hooks.

n3ss3s

2009-12-12 14:21:16

@mastaraymond 'Stealing Hooks' is easier said than done obviously, since no one has done it yet. You need some good knowledge of java,scar,and how the RS client works from what I hear, and not many people have enough knowledge to do so/care enough?


I feel deeply insulted, http://www.villavu.com/forum/showthread.php?t=31648

Wanted

2009-12-12 14:37:06

If you mean to tell us you had the capabilities to fix the hooks with ease and haven't done so, then what are you waiting for n3?????

Method

2009-12-12 15:36:27

http://www.villavu.com/forum/showthread.php?t=33606

dot dot dot

All you need to do is modify it so that the fields and interfaces you want are in there.

lordsaturn

2009-12-12 18:44:15

Would creating a working updater solve the problem?

n3ss3s

2009-12-13 05:05:18

From: lordsaturn
Would creating a working updater solve the problem?


Obviously…

lordsaturn

2009-12-13 13:33:07

If there's no way for SCAR to communicate internally with RSBot/iBot then let's just fix what we have here.

Bobarkinator

2009-12-13 14:11:39

From: lordsaturn
If there's no way for SCAR to communicate internally with RSBot/iBot then let's just fix what we have here.


There is it just needs to be coded into rsbot so it is easier to work with what we already have

lordsaturn

2009-12-14 08:05:48

From: Bobarkinator
There is it just needs to be coded into rsbot so it is easier to work with what we already have


So someone should get in contact with the RSBot developers? Unless we plan on coding it ourselves.

n3ss3s

2009-12-14 12:04:26

It shouldn't be hard to implement what KYAB did… Minimization might be harder, don't know…

Lol, thinking of KYAB, solar would rip his head off if he knew what we are trying to do at the moment :p

Bobarkinator

2009-12-14 12:14:55

From: n3ss3s
It shouldn't be hard to implement what KYAB did… Minimization might be harder, don't know…

Lol, thinking of KYAB, solar would rip his head off if he knew what we are trying to do at the moment :p


I would rather not do a socket approach and rather do something like SMART with DC's

n3ss3s

2009-12-15 08:16:38

I would rather not do a socket approach and rather do something like SMART with DC's


DC as in go for the graphical approach instead of calling the actual RSBot methods?

Bobarkinator

2009-12-15 09:06:00

As for color finding yes. I don't see any point in still using SMART for color if we're going with rsbot for ref. Use Dc for color and directly call methods for reflection

Freddy1990

2009-12-16 05:29:33

From: YoHoJo
@Cazax AFAIK Rsbot updates fast anyway so its not a problem to rely on it for this to work.
@SmartzKid, If by SMART you mean reflection, reflection is broken. And SMART doesnt debug/show all of the IDs/Tiles of everything.

=D I still think its a neat idea!


I'm actually considering to make my own kind of SMART client once I've finished SCAR 3.50, nothing like the genesis project I started once, but more similar to SMART itself…

n3ss3s

2009-12-16 13:45:16

The problem is in not having a working updater in our hands, nothing wrong with SMART…

Freddy1990

2009-12-16 14:24:08

From: n3ss3s
The problem is in not having a working updater in our hands, nothing wrong with SMART…


Never said there was… I am also working on a more convenient way to build updaters though…

Method

2009-12-16 17:48:25

From: Freddy1990
Never said there was… I am also working on a more convenient way to build updaters though…


More convenient how? You're going to have to learn about the client to be able to find fields in any case - the base of an updater is a trivial project anyways.