Cleaned up code quite a bit.
Added some comments, any more help, am I doing this correctly now? I think I should have another for loop somewhere but I'm not sure….
Function MineRock(WutRock:Integer):Boolean;
Function MineRock(WutRock:Integer):Boolean;
var I,PlusOne,tMine:Integer;
OrePts, RockPts, Bingo:TPointArray;
OrePtsBox, RockPtsBox, BingoBox: T2DPointArray;
OrePt, BingoPt: TPoint;
HighRock:Integer;
Begin
If Not(LoggedIn) Then Exit;
StatsGuise('Searching For Rock: '+ IntToStr(InvCount));
If OreInLast Then Exit;
//Get Iron Ore and Rock Points
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.06,1.22);
FindColorsSpiralTolerance(MSCX,MSCY,OrePts,3293028,MSX1,MSY1,MSX2,MSY2,5);
SetColorSpeed2Modifiers(0.02, 0.09);
FindColorsSpiralTolerance(MSCX, MSCY, RockPts, 3565690, MSX1, MSY1, MSX2, MSY2, 12);
SetColorSpeed2Modifiers(0.2,0.2);
ColorToleranceSpeed(1);
//Split TPA into 30X30 boxes of color
RockPtsBox:=TPAtoATPAEx(RockPts,30,30);
OrePtsBox:= TPAtoATPAEx(OrePts,10,10);
//Seaches within RockPts for OrePts, calls matches Bingo.
FindTPAinTPA(OrePts, RockPts, Bingo);
Writeln('OrePts ' + IntToStr (GetArrayLength(OrePts) ) );
Writeln('RockPts ' + IntToStr (GetArrayLength(RockPts) ) );
Writeln( IntToStr (GetArrayLength(Bingo) ) );
//Creates T2DPointArray called BingoBox
BingoBox:= TPAtoATPAEx(Bingo, 30, 30);
//Sorted BingoBoxes from center of mainscreen outwards
SortATPAFrom(BingoBox,Point(MSCX,MSCY));
HighRock:=High(BingoBox);
For I:=0 To HighRock Do
Begin
If Not(LoggedIn) Then Break;
Writeln( IntToStr (GetArrayLength(BingoBox) ) );
If (GetArrayLength(BingoBox[I]) > 6) Then
Begin
If YDebug Then DebugATPA(BingoBox,'');
BingoPt:= MiddleTPA(BingoBox[I]);
If CheckAndClick('ine',BingoPt.x,BingoPt.y) Then
Begin
Result:=True;
MarkTime(tMine);
StatsGuise('Mining Rock: '+ IntToStr(InvCount));
Players[CurrentPlayer].Loc:='Mining';
PlusOne:=InvCount+1;
Repeat
If Not(LoggedIn) Then Break;
Wait(200);
If Random(2) = 0 Then
Begin
RT:=GetSystemTime;
If FindNormalRandoms Then
IncEx(WeMined,GetSystemTime - RT);
End;
If Random(50)=1 Then SleepAndMoveMouse(500+Random(100));
//If (Not(IsMoving)) Then Begin Writeln('a'); Break; End;
Until (InvCount = PlusOne) Or (TimeFromMark(tMine) > ((Players[CurrentPlayer].Integers[2]*1000) + Random(500)));
Exit;
End;
End;
Wait(250+Random(100));
End;
End;
Cleaned it more, added debug.
OrePts 64 (Finds 64 pixels of iron ore color)
RockPts 4026 (Finds 4026 pixels of rock color)
Bingo 0 ( After calling FindTPAinTPA(OrePts, RockPts, Bingo); the TPA 'Bingo' is still empty, meaning it's not finding any Iron ore pts within rock pts how is this so?)