Simba Code:
Program ShowOres;
{$DEFINE SMART}
{$i srl/srl.simba}
{$i sps/sps.simba}
{$I SRL/SRL/misc/SmartGraphics.simba}
Const
COLORROCK = 5988191;
COLORORE = 2635354;
ROCKTOL = 17;
ORETOL = 9;
PSX1 = 251;
PSY1 = 206;
PSX2 = 273;
PSY2 = 236;
var
box1count,box2count,box3count,box4count,box5count,box6count:Integer;
box1countI,box2countI,box3countI,box4countI,box5countI,box6countI:Integer;
box1countR,box2CountR,box3CountR,box4CountR,box5CountR,box6CountR:String;
box1countA,box2countA,box3countA,box4countA,box5countA,box6countA:boolean;
RockAOre,RockBOre,RockCOre,RockDOre,RockEOre,RockFOre:Boolean;
BOUNDSX,BOUNDSY,BOUNDSX2,BOUNDSY2:Integer;
ContainsOre:Boolean;
RockState:Integer;
function IsMining: Boolean;
var
PBox: TBox;
begin
PBox := IntToBox(PSX1, PSY1 - 50, PSX2, PSY2 - 50);
Result := (AveragePixelShift(PBox, 250, 350) > 110);
end;
function StartMine: Boolean;
var
tmpCTS, i, L, Counter: Integer;
ObjTPA: TPointArray;
ObjATPA: T2DPointArray;
X, Y, DMCount, Moves: Integer;
begin
Moves := 0;
DMCount := 0;
tmpCTS := GetToleranceSpeed;
SetColorToleranceSpeed(2);
SetToleranceSpeed2Modifiers(0.00, 0.16);
FindColorsTolerance(ObjTPA, 6383206, BOUNDSX, BOUNDSY, BOUNDSX2, BOUNDSY2, 3);
SplitTPAWrap(ObjTPA, 10, ObjATPA);
SortATPASize(ObjATPA, True);
SetColorToleranceSpeed(tmpCTS);
SetToleranceSpeed2Modifiers(0.02, 0.02);
DMCount := RandomRange(3, 5);
L := High(ObjATPA) MarkTime(Counter);
for i := 0 to L do
begin
MiddleTPAEx(ObjATPA[i], X, Y);
repeat
begin
Moves := Moves + 1;
Wait(RandomRange(400, 800));
MMouse(RandomRange(X - 5, X + 5), RandomRange(y - 5, y + 5), 0, 0);
if (RockState = 1) and (RockAOre = True) or
(RockState = 2) and (RockBOre = True) or
(RockState = 3) and (RockCOre = True) or
(RockState = 4) and (RockDOre = True) or
(RockState = 5) and (RockEOre = True) or
(RockState = 6) and (RockFOre = True) Then
Begin
While IsMining do
Wait(RandomRange(100, 400));
if (IsUpTextMultiCustom(['Mine Ir', 'ine Iro', 'ine Iron'])) then
begin
clickmouse2(mouse_Left);
Wait(RandomRange(400, 900));
if (RockState = 1) Then RockAOre := False;
if (RockState = 2) Then RockBOre := False;
if (RockState = 3) Then RockCOre := False;
if (RockState = 4) Then RockDOre := False;
if (RockState = 5) Then RockEOre := False;
if (RockState = 6) Then RockFOre := False;
Exit;
end;
Wait(RandomRange(100, 400));
Exit;
end;
End;
until (Moves > DMCount) if (TimeFromMark(Counter) > 1000) then
begin
MakeCompass(180 - Random(15));
Wait(RandomRange(2000, 5000));
Break;
end;
end;
Result := False;
end;
Procedure WriteRocks;
Begin
Writeln('|' + box1countR +'|' + box2countR + '|' + box3countR + '|');
Writeln('|' + box4countR +'|' + box5countR + '|' + box6countR + '|');
End;
Procedure DefineRocks;
Begin
{
Box 1 Counts
}
ContainsOre := False;
Begin
if (box1count >= 65) and (box1countI >= 10) then
Begin
BOUNDSX :=279;
BOUNDSY :=213-50;
BOUNDSX2 :=309;
BOUNDSY2 :=244-50;
box1countR := 'Iron'
RockState := 1;
box1countA := True;
RockAOre := True;
StartMine;
End;
if (box1Count >= 65) and (box1countI <= 10) then
Begin
box1countR := 'Rock'
// StartMine;
End;
if (box1Count <= 65) and (box1countI <= 10) Then
Begin
box1countR := 'Nothing'
End;
End;
{
Box 2 Counts
}
Begin
if (box2count >= 65) and (box2countI >= 4) then
Begin
BOUNDSX :=247;
BOUNDSY :=182-50;
BOUNDSX2 :=279;
BOUNDSY2 :=213-50;
box2countR := 'Iron'
RockState := 2;
box2countA := True;
RockBOre := True;
StartMine;
End;
if (box2Count >= 65) and (box2countI <= 4) then
Begin
box2countR := 'Rock'
// StartMine;
End;
if (box2Count <= 65) and (box2countI <= 4) then
Begin
box2countR := 'Nothing'
End;
End;
{
Box 3 Counts
}
Begin
if (box3count >= 65) and (box3countI >= 20) then
Begin
BOUNDSX :=279;
BOUNDSY :=182-50;
BOUNDSX2 :=309;
BOUNDSY2 :=213-50;
box3countR := 'Iron'
RockState := 3;
box3countA := True;
RockCOre := True;
StartMine;
End;
if (box3Count >= 65) and (box3countI <= 20) then
Begin
ContainsOre := False;
box3countR := 'Rock'
End;
if (box3Count <= 65) and (box3countI <= 20) then
Begin
ContainsOre := False;
box3countR := 'Nothing'
End;
End;
{
Box 4 Counts
}
Begin
if (box4count >= 65) and (box4countI >= 5) then
Begin
BOUNDSX :=215;
BOUNDSY :=213-50;
BOUNDSX2 :=247;
BOUNDSY2 :=244-50;
box4countR := 'Iron'
RockState := 4;
box4countA := True;
RockDOre := True;
StartMine;
End;
if (box4Count >= 65) and (box4countI <= 5) then
Begin
ContainsOre := False;
box4countR := 'Rock'
End;
if (box4Count <= 65) and (box4countI <= 5) then
Begin
ContainsOre := False;
box4countR := 'Nothing'
End;
End;
{
Box 5 Counts
}
Begin
if (box5count >= 65) and (box5countI >= 20) then
Begin
BOUNDSX :=247;
BOUNDSY :=213-50;
BOUNDSX2 :=279;
BOUNDSY2 :=244-50;
box5countR := 'Iron'
RockState := 5;
box5countA := True;
RockEOre := True;
StartMine;
End;
if (box5Count >= 65) and (box5countI <= 20) then
Begin
ContainsOre := False;
box5countR := 'Rock'
End;
if (box5Count <= 65) and (box5countI <= 20) then
Begin
ContainsOre := False;
box5countR := 'Nothing'
End;
End;
{
Box 6 Counts
}
Begin
if (box6count >= 65) and (box6countI >= 5) then
Begin
BOUNDSX :=279;
BOUNDSY :=213-50;
BOUNDSX2 :=309;
BOUNDSY2 :=244-50;
box6countR := 'Iron'
RockState := 6;
box6countA := True;
RockFOre := True;
StartMine;
End;
if (box6Count >= 65) and (box6countI <= 5) then
Begin
ContainsOre := False;
box6countR := 'Rock'
End;
if (box6Count <= 65) and (box6countI <= 5) then
Begin
ContainsOre := False;
box6countR := 'Nothing'
End;
End;
End;
Procedure GetRocks;
Begin
box1count := CountColorTolerance(COLORROCK, 215, 182-50, 247, 213-50, ROCKTOL);
box2count := CountColorTolerance(COLORROCK, 247, 182-50, 279, 213-50, ROCKTOL);
box3count := CountColorTolerance(COLORROCK, 279, 182-50, 309, 213-50, ROCKTOL);
box4count := CountColorTolerance(COLORROCK, 215, 213-50, 247, 244-50, ROCKTOL);
box5count := CountColorTolerance(COLORROCK, 247, 213-50, 279, 244-50, ROCKTOL);
box6count := CountColorTolerance(COLORROCK, 279, 213-50, 309, 244-50, ROCKTOL);
box1countI := CountColorTolerance(COLORORE, 215, 182-50, 247, 213-50, ORETOL );
box2countI := CountColorTolerance(COLORORE, 247, 182-50, 279, 213-50, ORETOL );
box3countI := CountColorTolerance(COLORORE, 279, 182-50, 309, 213-50, ORETOL );
box4countI := CountColorTolerance(COLORORE, 215, 213-50, 247, 244-50, ORETOL );
box5countI := CountColorTolerance(COLORORE, 247, 213-50, 279, 244-50, ORETOL );
box6countI := CountColorTolerance(COLORORE, 279, 213-50, 309, 244-50, ORETOL );
Writeln('*******Rock results*******')
Writeln('BOX1:' + IntToStr(box1count) + '');
Writeln('BOX2:' + IntToStr(box2count) + '');
Writeln('BOX3:' + IntToStr(box3count) + '');
Writeln('BOX4:' + IntToStr(box4count) + '');
Writeln('BOX5:' + IntToStr(box5count) + '');
Writeln('BOX6:' + IntToStr(box6count) + '');
Writeln('*******Iron Results*******');
Writeln('BOX1:' + IntToStr(box1countI) + '');
Writeln('BOX2:' + IntToStr(box2countI) + '');
Writeln('BOX3:' + IntToStr(box3countI) + '');
Writeln('BOX4:' + IntToStr(box4countI) + '');
Writeln('BOX5:' + IntToStr(box5countI) + '');
Writeln('BOX6:' + IntToStr(box6countI) + '');
End;
Begin
SetupSRL;
ActivateClient;
ContainsOre := False;
box1countR := 'Nothing';
box2countR := 'Nothing';
box3countR := 'Nothing';
box4countR := 'Nothing';
box5countR := 'Nothing';
box6countR := 'Nothing';
GetRocks;
DefineRocks;
//DoMine;
WriteRocks;
StartMine;
repeat
ClearDebug;
ContainsOre := False;
GetRocks;
DefineRocks;
//DoMine;
WriteRocks;
//GetPositions;
until False;
End.