YoHoJo
2009-12-08 21:11:56
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