SRL Archive - OSR Help

Mining coal procedure


P1ng

2012-05-10 04:33:32

I am just fiddling around trying to make a guild coal miner/banker, but as of yet haven't written any procedures for walking because I am struggling to work out which method will be the best for what I am doing.

Never the less, this is my current coal mining procedure which works reasonably well at the moment. A few questions -

- Once the script finds the initial color (the slightly lighter rock color) I then want it to draw the ATPA boxes and check to see if the dark "coal present" color is within that box, before moving the mouse and clicking. At present it simply searches for the light color and then checks the uptext, if thats wrong it will rotate the camera angle and move on until it finds one with the appropriate uptext. but this looks rather 'bot-like' and would prefer it just recognised the coal before it moved and clicked with the uptext being more of a failsafe than a necessary procedure.

- It's currently using FindColorsSpiralTolerance and I have it set to spiral from the centre of the main screen. However, it seems to like clicking rocks on the outer edges of the main screen even when there are coal-filled rocks right near my character.. Any ideas as to why that's happening?

procedure MineCoal;
var
i,C,T,CTS: integer;
MyTPA: TPointArray;
TPAA: T2DPointArray;
M: TPoint;
begin
if not LoggedIn then
TerminateScript else
if not FindNormalRandoms then
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
if not FindColorsSpiralTolerance(MSCX,MSCY,MyTPA,4688547,MSX1,MSY1,MSX2,MSY2,3) then
FindColorsSpiralTolerance(MSCX,MSCY,MyTPA,789773,MSX1,MSY1,MSX2,MSY2,3) else
if FindColorsSpiralTolerance(MSCX,MSCY,MyTPA,4688547,MSX1,MSY1,MSX2,MSY2,3) then
begin
ColorToleranceSpeed(CTS);
TPAA := TPAToATPAEx(MyTPA, 26, 24);
SortATPASize(TPAA, True);
for i:= 0 to High(MyTPA) do
M:= MyTPA[i];
WriteLn(IntToStr(High(MyTPA)));
MMouse(M.x-1,M.y-1,3,3);
end else
begin
repeat
CompassMovement(10,180,False);
WriteLn('Couldnt Find Coal, Exiting');
Exit;
until (FindColorsSpiralTolerance(MSCX,MSCY,MyTPA,789773,MSX1,MSY1,MSX2,MSY2,3)) or (FindColorsSpiralTolerance(MSCX,MSCY,MyTPA,4688547,MSX1,MSY1,MSX2,MSY2,3))
end;
if WaitUpTextMulti(['oal'],600) then
begin
C:= InvCount;
ClickMouse2(True);
FFlag(0);
MarkTime(T);
While IsMining do
Wait(RandomRange(500,1000));
if FindBlackChatMessage('o ore') or FindBlackChatMessage('anage') or (InvCount <> C) or (T > 10000) then
Exit;
end else
WriteLn('Couldnt Find UpText, Try Again');
CompassMovement(10,180,False);
Exit;
end;

Also, if there are any recommendations for failsafes I should add in, different, easier or more human-like ways to do any of this procedure please let me know. Any feedback and criticism is welcome and appreciated.

Abu

2012-05-10 12:30:15

Try something like this?:

Excerpt from 'a lowdown on WizzyPlugin':

GetTPABounds

[php]{*******************************************************************************
function GetTPABounds(TPA: TPointArray): TBox;
Description: Returns the boundaries of the TPA as a TBox.
*******************************************************************************}
[/php]

This is one more useful function, it seems that the most used functions seem to be included at the end :/. What GetTPABounds does is that it makes a box around all the points 'TPA' and returns the Boundaries in the form of data type TBox.
A picture:


Usage:
{.Include SRL/SRL.Scar}
Var
TPA : TPointArray;
TB : TBox;
Begin
SetupSRL;
FindColorsTolerance(TPA, ClBlack, MSX1, MSY1, MSX2, MSY2, 50);
TB := GetTPABounds(TPA);
MouseBox(TB.X1, TB.Y1, TB.X2, TB.Y2, 1);
End.


What this script does it that it stores all the occurances of the color black, found in the RuneScape mainscreen to the TPA. It then gets the boundaries of the TPA and clicks randomly inside the box using MouseBox();.

P1ng

2012-05-10 23:39:56

Just what i was looking for! Thank you, will give this a try when I get home from work.
Any ideas on the spiral and why it always chooses further away rocks?

Abu

2012-05-11 02:09:31

From: p1ng
Just what i was looking for! Thank you, will give this a try when I get home from work.
Any ideas on the spiral and why it always chooses further away rocks?


I have no idea, In fact I see it's been happening to me too.

however, if you use GetTPABounds and replace MSX1, MSY1, MSX2, MSY2 with the bound of the TPA, you may be able to stop that.