Wizzup?
2008-03-14 15:58:12
finding the essence mine locations!
Since alot of people have been PM'ing me about my essence miner…
I thought I should show that I am working on the Essence Miner again…
I think it works 100%. And it is very fast (just remove the wait(1000) and the DebugMM ;) )
I think in total it takes less than 16ms.
Does anyone feel like testing it?
BTW: Since (3.14?) With … Do also works with your own records!
Since alot of people have been PM'ing me about my essence miner…
I thought I should show that I am working on the Essence Miner again…
I think it works 100%. And it is very fast (just remove the wait(1000) and the DebugMM ;) )
I think in total it takes less than 16ms.
Does anyone feel like testing it?
program New;
{.include srl/srl.scar}
Type
EssLoc = Record
Name: String;
Info: Array Of Array Of Integer;
L: Integer;
End;
EssLocArray = Array Of EssLoc;
Var
EssInfo: EssLocArray;
Procedure DebugMM(TPA: TPointArray);
Var
I, l: Integer;
C: TCanvas;
Begin
displaydebugimgwindow(0, 0);
displaydebugimgwindow(mmx2-mmx1, mmy2-mmy1);
C := GetDebugCanvas;
CopyCanvas(GetClientCanvas, C, MMX1, MMY1, MMX2, MMY2, 0, 0, MMX2 - MMX1, MMY2 - MMy1);
l := high(tpa);
for i := 0 to l do
C.pixels[tpa[i].x - mmx1, tpa[i].y - mmy1] := 255;
displaydebugimgwindow(mmx2-mmx1, mmy2-mmy1);
End;
Function GetCurrentTPA: TPointArray;
Var
cts: Integer;
Begin
cts := GetColorToleranceSpeed;
ColorToleranceSpeed(1);
FindColorsTolerance(Result, clWhite, MMX1, MMy1, MMX2, MMY2, 421);
ColorToleranceSpeed(cts);
End;
Function ScanMM(Const TPA: TPointArray; SD, ED, MinR, MaxR: Integer): Integer;
Begin
FilterPointsPie(TPA, SD, ED, MinR, MaxR, MMCX, MMCY);
Result := Length(TPA);
DebugMM(TPA);
End;
Function RetInt(a: Array Of Integer): Array Of Integer;
Begin
Result := a;
End;
Procedure LoadLocations;
Begin
SetLength(EssInfo, 6);
With EssInfo[0] Do
Begin
Name := 'North West';
Info := [RetInt([80, 160, 60, 70, 400]), RetInt([270, 30, 30, 50, 900])];
L := 1;
End;
With EssInfo[1] Do
Begin
Name := 'Middle North';
Info := [RetInt([0, 80, 60, 70, 320]), RetInt([80, 180, 55, 70, 320]),
RetInt([170, 260, 60, 70, 210]), RetInt([270, 340, 30, 75, 1000])];
L := 3;
End;
With EssInfo[2] Do
Begin
Name := 'Middle South';
Info := [RetInt([170, 270, 30, 70, 1700]), RetInt([330, 120, 25, 50, 1700])];
L := 1;
End;
With EssInfo[3] Do
Begin
Name := 'North East';
Info := [RetInt([350, 130, 30, 60, 2000]), RetInt([180, 270, 60, 74, 700])];
L := 1;
End;
With EssInfo[4] Do
Begin
Name := 'South West';
Info := [RetInt([290, 70, 0, 74, 3000])];
L := 0;
End;
With EssInfo[5] Do
Begin
Name := 'South East';
Info := [RetInt([285, 0, 0, 74, 1600]), RetInt([0, 270, 0, 50, 2800])];
L := 1;
End;
End;
Function AdeptDegree(CompassAngle: Extended; Degree: Integer): Integer;
Begin
Result := Round(Abs(CompassAngle + Degree));
While Result > 360 Do
Result := Result - 360;
End;
Function GetPos: String;
Var
TPA: TPointArray;
I, C, E, r: Integer;
CA: Extended;
Begin
r:=getsystemtime;
TPA := GetCurrentTPA;
CA := rs_GetCompassAngleDegrees;
WriteLn(FloatToStr(CA));
writeln(inttostr(getsystemtime - r));
For I := Low(EssInfo) To High(EssInfo) Do
Begin
With EssInfo[I] Do
Begin
WriteLn(EssInfo[I].Name + ': Info Length ' + IntToStr(Length(Info)));
For C := 0 To L Do
Begin
Wait(1000);
E := ScanMM(TPA, AdeptDegree(CA, Info[C][0]), AdeptDegree(CA, Info[C][1]),
Info[C][2], Info[C][3]);
writeln(inttostr(c) + '...' + inttostr(E) + ' vs ' + inttostr(info[C][4]));
If E < Info[C][4] Then
Begin
WriteLn('Breaking... ' + IntToStr(C) + ' E('+inttostr(E) + ') was smaller than info[C][4](' + inttostr(info[C][4]) + ')');
Break;
End;
End;
If C = L + 1 Then
Begin
Result := Name;
WriteLn('Location: ' + Result);
Exit;
End;
End;
End;
End;
Var
I, t: Integer;
TPA: TPointArray;
begin
setupsrl;
cleardebug;
LoadLocations;
GetPos;
end.BTW: Since (3.14?) With … Do also works with your own records!