Cage
2014-06-21 10:25:49
I am having some trouble trying to get this code to work which Frement kindly gave to me.
The logic is fine I am just having trouble feeding the function the centre coordinates of whichever rock I am mining.
Here is my object finding function to make it easier to understand. I am having trouble taking the centre point of the TPA (before random mouse movements throw it off) and pushing the coordinates to that function.
Any and all help would be greatly appreciated as always.
:)
The logic is fine I am just having trouble feeding the function the centre coordinates of whichever rock I am mining.
function DetectGas(X, Y: Integer): Boolean;
var
tmpCTS, ColorCount: Integer;
tmpHue, tmpSat: Extended;
begin
tmpCTS := GetColorToleranceSpeed;
GetColorSpeed2Modifiers(tmpHue, tmpSat);
SetColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.31, 0.35);
SMART_DrawBoxEx(True, False, IntToBox(X - 10, Y - 10, X + 10, Y + 10), clRed);
ColorCount := CountColorTolerance(8097941, X - 10, Y - 10, X + 10, Y + 20, 13);
Result := (ColorCount > 10);
SetColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(tmpHue, tmpSat);
end;Here is my object finding function to make it easier to understand. I am having trouble taking the centre point of the TPA (before random mouse movements throw it off) and pushing the coordinates to that function.
Function OreFinder : boolean;
var
X, Y, I, OriginalCTS : Integer;
OriginalHue, OriginalSat: Extended;
TPA: TPointArray;
TPAA: T2DPointArray;
begin
Wait(1000+ random(400));
OriginalCTS := GetColorToleranceSpeed;
GetColorspeed2Modifiers(OriginalHue, OriginalSat);
SetColorToleranceSpeed(2);
SetColorspeed2Modifiers(0.04, 0.29);
FindColorsSpiralTolerance(X, Y, TPA, 9340762, MSX1, MSY1, MSX2, MSY2, 13);
ColorToleranceSpeed(OriginalCTS);
SetColorspeed2Modifiers(OriginalHue, OriginalSat);
TPAA := TPAtoATPAEx(TPA, 28, 28);
if Length(TPAA) = 0 then
begin
Wait(20+ random(40));
Writeln('No Points Found - Logging out and trying a new world.');
Logout;
WorldHandler;
end;
SortATPAFromMidPoint(TPAA, Point(MSCX, MSCY));
for I := 0 to High(TPAA) do
begin
if MiddleTPAEx(TPAA[I], X, Y) then
HumanMouseMove(X, Y, 15); // if causes problems, it was previously 10
GetMousePos(GASX, GASY);
if (WaitUptext('ine', RandomRange(500,1000))) then
begin
Writeln('We have found the up text.');
Wait(20+ random(20));
ClickMouse2(false);
ChooseOption('Mine');
Result := true;
Break;
if not ChooseOption('Mine') then
begin
WriteLn('Missed first attempt for some reason, trying again');
Wait(20+ random(20));
HumanMouseMove(X, Y, 10);
ClickMouse2(true);
Break;
end;
end;
end;
SMART_DebugATPA(True, TPAA);
end;
Any and all help would be greatly appreciated as always.
:)