SRL Archive - First Scripts

Iron dropper for HD


dudutzu

2010-02-07 12:39:09

Well lately I found myself power mining while waiting for a certain type of ore to re-spawn .

As usual, quickly, I got bored of dropping the Iron ore. So decided to use an auto dropper.But to my surprise i was unable find one that suited my needs:
- Working in HD (more likely with a big screen because i had almost all other "improvements" disabled).
- Being able to drop just a certain type of ore/item.
- Dropping when i wanted and not hen inventory is full.


So in conclusion after many years of leaching (using other people scripts) i start writing one.The "way of thinking" was not a problem, the issue was not knowing the functions in SCAR/SRL.


Anyway this is it (without the lalala and all other crap)

Version 1.2 is available to download !
  • In this version the mouse is more "undetectable"
  • The ore check loop is a little simplified
  • More comments are added !
  • Bitmap is cleared at the end of the script too preserve memory

THANKS CIGUE FOR THE ADVICES !



program DropHD ;
{.include srl/srl.scar}

const

Tol = 5; // Tolerance in finding the Iron ore. During tests with 5 tolerance worked perfectly.
Speed = 25; // Mouse Speed
TimeBetweenOres = 600 ; // Time to wait between ore.

var Loads:integer;

procedure Drop;
var IronOres, x, y: Integer ;
begin
IronOres := BitmapFromString(7, 3, 'beNpTkNCTFjGUFTN' + //Iron_Ore [10-12-09]
'XkLBRkQYiSyVJIBsoYiIvDmQjCwJFgCSKIAAisglL');
while(FindBitmapTolerance(IronOres, x, y,tol)) do
begin
MouseItem(CoordsToItem(x, y), false);
WaitOption('Drop', RandomRange(100, 300));
Wait(TimeBetweenOres+Random(200));
Inc(Loads);
end;
end;

// Main
begin
SetupSRL;
mousespeed := Speed;
Loads:=0;
repeat
if (IsFunctionKeyDown(0)) then Drop; // Makes the script Drop each time you press the Shift key
until(IsFunctionKeyDown(8)); // Makes the script STOP, validates the repeat condition
FreeBitmap(IronOres);
writeln(IntToStr(Loads) + ' iron ores war droped.');
end.

THINGS YOU SHOULD KNOW !

1) The script was tested and written to work with this setting made in RS :

2) I know here is room for improvement !!

Known Issues !!!

Exception: Can't allocate the DIB handle
Not due to script !!!
In order to fix refocus SCAR on RuneScape window !

Mentions !!!

Yes i know that i could take the Bitmap straight from SRL but the calling procedure just didn't work for me … so this was a simple fix !!
If you can provide any help with that part then PLEASE TELL ME !!! (Its driving me nuts)

Next !!

1) Trying to use :
FindBitmapSpiralTolerance(bitmap: Integer; var x, y: Integer; x1, y1, x2, y2: Integer; Tolerance: Integer): Boolean;
but without specifying where to look for the bitmap (resizeable window).
Again if you could help then PLEASE do …

2) After solving the issue with getting bmp's from scar/core/bitmaps.scar i'm thinking to add the option to pick what to drop and what to keep … (depending on what time i have available…)

THANKS for your time and PLEASE say something about it (especially if you are a SRL Member…)

Sir R. M8gic1an

2010-02-07 12:47:49


if IsFKeyDown(0) then
begin
GetMousePos(x, y);
TB := PointToInvBox(x, y);
//Create bmp from TBox
while (DropBMP) do wait(100+random(50));
FreeBitmap(BMP);
end;

That makes it easy to choose what to drop. Justpu your mosue over t before clicking the FKey ;)

~RM

dudutzu

2010-02-07 13:17:13

1) And is that working in resizeable mode ? … ? since the menu is in a different position every time ?
Getting over point 1) ….
2) I don't think that it gets along with my future plan, being able to select witch ore to drop or witch to keep.
For an example if I wish to discard iron and coal while kipping Adamant and Mithril …
NOT SAYING THAT YOU COULD NOT ADAPT IT 2 FIT this situation !! ( I just findit mor complicated) …

P.S. What do you think about the standards … ? (LOL)

Cigue

2010-02-07 14:28:33

I think you did this script in a very innovative way. I can see you've created a script with an use, which is rare for a first script. :) The way you comment particular lines really makes it easier to understand too.

There are only three minor things I could see you improving. First and easiest, standards : always put two spaces after begin and repeat. You already put one, so I figure you know what I mean. :)

The second this is the isfunctionkeydown(0) and (8) test. what is it for? it looks like you'd only need to run Drop; once, so why put a repeat..until ?

Third, you should always free your bitmaps.

I uploaded a modded version with the changes I suggested and some other stuff.

MouseItem(CoordsToItem(x, y), False) right clicks the item found in x, y with ± 15 tol, so it's undetectable.

WaitOption('Drop', RandomRange(100, 300)) waits 100-300 ms and clicks drop.

FreeBitmap(IronOres) frees bitmap for memory.

Enjoy !

dudutzu

2010-02-07 15:07:22

Thanks Cigue …
Specially for the advices …

I absolutely forgot about freeing bitmaps … [UPSS !!]

The isfunctionkeydown(0) and (8) are Shift and ALT GR keys and the test makes the script to repeat itsealf each time you press the shift key…
the second key (ALT) validates the repeat condition end finishes the script …

In 2 words it removes the burden of starting the script each time you want to drop … (it more convenient for me this way… )


~~ Observation considering the modification you made ~~

1)
I see in the modified script that you change the "repeat" to a "while" …
And I'm asking where the hell was my mind … :( i was not thinking strait …

2)
The variable logs is global because its incremented inside the drop procedure and then printed on the screen in the main program; therefor it need to be global.



P.S. anything about my questions in the original post ? … ?

A and a big THANKS !

Cigue

2010-02-07 15:13:56

What questions? x]

dudutzu

2010-02-07 15:23:26

1) Bitmap straight from SRL

2) Implement FindBitmapSpiralTolerance , to make the script drop the ore that is closer to the mouse.
( at this moment it drops the ore in the same order every time )

Sex

2010-02-07 15:53:10

You said it was for HD yet you are not in HD..

dudutzu

2010-02-08 10:50:00

Happy now sex ?

Cigue

2010-02-09 21:44:47

1) No, sorry.

2) You'll need to add functions two that loop, that is

1. GetMousePos(x,y) puts mouse coords in x, y.
2. FindBitmapSpiralTolerance(nameofBMP, x, y, MIX1, MIY1, MIX2, MIY2, tolerance) will start search at x, y and record bitmap location at x, y too.