From: LordJashin
2. To detect if you are mining the rock or not, use the animation stuff ( pixel shift )
3. You could also check around the rock ( very hard to implement ) if there is any other pixel shifts going on ( like maybe someone else mining the rock )
mmm, Pixel animation is by far the best way to know if We are mining and for this reason. You are a lucky person because I will do a all in one tutorial for you Right here in my post just for you. I could simply tell you to go look into a mining script, but I feel like helping someone today.
If you don't understand after This, I don't know what to do! Hope you will rep me for this nice time I am taking to help you :P
From: osunateosu
Alright awesome, I'm not that advanced into scripting so that kind of threw me off, what I don't get is
while Mining do // Count the pixel shift to determinate if we are still mining or if We did mine the rock
because I don't see where it commands it to count the pixels.
Also I'm doing this to mine a rock like addy that takes a long time, thats why I need a command and wait won't work, because you can't really predict how long it'll take to mine a rock like that.
K, lets get back to point 1. First, you need to introduce in your script this Function I showed you in my last post which is this one below.
The role of this function is to Counts the pixel animation of your character on the screen.
Function Mining: boolean;
var
PBox: TBox;
begin
PBox := IntToBox(245, 130, 285, 195);
Result := (AveragePixelShift(PBox, 250, 500) > 350);
end;
Ok, to help you out, I will explain you each part of this function, so you will be able to understand what is going on and be able to play with the values!
Lets get started with the first part of the code which is the Box.
PBox := IntToBox(245, 130, 285, 195);
Pbox is the name we gave to the box we will make. We are going to give cords to make the dimension of our box in the () that match the position of our player on the Screen. Since we know our character is always in the middle, these value showed here are good for everyone, so you shouldn't touch them.
245 = X1, 130 = Y1, 285 = X2 and 195 = Y2.
So, to help you even more, here a small picture to show you what happen with these value in the game.

As you see, the Coordinates X1,Y1 and X2,Y2 Make a Box around our Character.
Basically, this will result into a Box that will surround only your Character.
Now, lets move to the pixels counts. The part where it calculs the Pixel animation is showed right here.
Result := (AveragePixelShift(PBox, 250, 500) > 350);
That's the part where it counts the pixels. Now, I am going to explain Each value just for you.
Result. The Result will tell us if we are mining or not depending on the number of pixel shift counted during a lapse of time.
Pbox. This is the Box we made sooner. The script will get the box on the Client and Counts the Pixel Shifts in this box!
250. This value mean our Script will recount pixels Every 250 ms to see if this function is still true. You could change this value to 1000ms. In this case, it would means the script would recount pixels Every 1 second.
500. This value is used to tell the script for How long we want to recorder the Pixel shifts animation. In this case, it is 500ms. This means the script will count the number of pixel shift during 0,5 sec. You can change this value to 3 sec if you want to!
> 350. That's where everything come into play. The number 350 is the number of Pixels Shifts. In this case, we set 350 pixel shift. So, this mean that when our script execute this function, if the number of Pixels counted during 500ms is higher than 350, Our function will return true. If the function return true, it means we are mining. On the other hand, if the number of pixels counted during 500ms is lower than 350, Our function will return false. If the function return false, it means we aren't mining anymore.
So, this function calculated the number of pixels shifts for a specific amount of time every 250ms until it returns false!
Now that we know that! We can move to the part where we are going to use this function at our advantage in our script, so we can make a effective mining script!
Lets take a look at this piece of code right here.
while Mining do
Antiban;
First, I will explain you what
'While' means since you didn't understand it. While means that if our function return true, We will do a specific action until the function is false. Basically, that's here we add Anti ban!
I will show you what kind of Anti ban you can add. This is my Anti ban used in my script.
procedure AntiBan;
begin
case random(500) of
1: PickUpMouse;
2: CheckRandomTab;
3:HoverSkills(skill_Prayer, False);
4:CheckGloryOrEmerald;
5:RandomMouvMouse;
6:RandomMouvMouse;
7:RandomMouvMouse;
8:RandomMouvMouse;
9:RandomMouvMouse;
10:RandomMouvMouse;
11:RandomMouvMouse;
12:RandomMouvMouse;
end;
end;
So, while our function return true and our script is waiting for it to return false, The script will execute the procedure Antiban. In this case, I made a case of random going up to 500, because I didn't want to do Anti ban feature each time and this also give some randomness on when they happen.
If you don't have antiban feature in your script. You can change this piece of code for this instead
While mining do
wait(50 + random(100));
This will do nothing and it will just wait for your function to return false.
Now, Did I do all this to leave you Right there and try to finish this off by yourself?
Well, no. I even took the time to show you how it would look like in your Script. Here is the total code of the mining part that your script should have!
procedure AntiBan;
begin
case random(500) of
1: PickUpMouse;
2: CheckRandomTab;
3:HoverSkills(skill_Prayer, False);
4:CheckGloryOrEmerald;
5:RandomMouvMouse;
6:RandomMouvMouse;
7:RandomMouvMouse;
8:RandomMouvMouse;
9:RandomMouvMouse;
10:RandomMouvMouse;
11:RandomMouvMouse;
12:RandomMouvMouse;
end;
end;
Function Mining: boolean;
var
PBox: TBox;
begin
PBox := IntToBox(245, 130, 285, 195);
Result := (AveragePixelShift(PBox, 250, 500) > 350);
end;
function AddyFinder(x, y : Integer): Boolean; // Credit to I am Legend
var
CTS, I: Integer; //CTS will store the ColorToleranceSpeed before we change it, for later.
TPA: TPointArray; //The TPointArray in which all Coordinates which are found later will be stored
ATPA: Array of TPointArray;
begin
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2); //Sets the color tolerance speed to 2 so we can do HSL tolerance stuff
SetColorSpeed2Modifiers(0.09,0.12);
FindColorsSpiralTolerance(MSCX, MSCY, TPA, 7044458, MSX1, MSY1, MSX2, MSY2, 12); //For tolerance, put in your own tolerance. MSCX and MSCY are the starting points in the center of the mainscreen. MSX1, MSY1, etc. are the outside of the Main Screen.
ColorToleranceSpeed(CTS); //Make sure you do this after you're done color finding, so text finding will work again.
ATPA := TPAToATPAEx(TPA, 15, 15);
For I := 0 to High(ATPA) do
begin
MiddleTPAEx(ATPA[i], x, y); //Returns the middle coords of the current TPA in the ATPA
MMouse(x, y, 2, 2); //Moves mouse over the object
if WaitUptext('Mine',500) then
begin
Result := True;
GetMousePos(x, y); //Sets the x and y values for future use (Like clicking)
Break; //Exits the For To Do statement so it doesn't keep moving around looking for the object
end;
end;
end;
Function CountOre: integer;
var TPA : TPointArray;
Begin
FindColorsTolerance(TPA, 1813784, MIX1, MIY1, MIX2, MIY2, 15);
RAaSTPAEx(TPA, 42, 36);
Result := Length(TPA);
End;
Procedure GoingToMine; // This is purely made with my imagination :P
Addyfinder;
wait(1000 + random(500));
While Mining do
Antiban;
CountOre;
if(CountOre = 27) then
begin
Writeln('We are full');
end else
begin
repeat
GoingToMine
until (CountOre = 27);
end;
end;
So, this is a full procedure to mining a Addamantite ore. I used the addy finder from I am legend mining script for this demonstration, since I didn't have any mining script to show you a piece of code.
Now, You should be able to get this working!