SRL Archive - OSR Help

Help with Gas Detection


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.

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.

:)

Wetish

2014-06-21 11:04:53

After MiddleTPAEx

Gasx := x;
Gasy := y;

Get rid of GetMousePos(gasx,gasy)

Frement

2014-06-21 11:33:43

No, you have to find the same rock after you have started mining, because now when you start mining and the rock isn't near you, you move, and the coordinates change. So while moving, track your rock.

Wetish

2014-06-21 11:45:34

I didn't think of that. I've never written a mining script that isn't for the 3 iron rocks.

Cage

2014-06-21 17:00:21

Thankfully mines only in a 3 rock area like Wetish said. However, I would be interested in seeing how one could track the location of the rock without reflection if you could provide that Frement? :)

bonsai

2014-06-21 20:04:12

How unique is that color? As long as you don't start getting false positives, I would just use a box centered on the player that is large enough to contain the rock being mined.

So DetectGas would need no parameters.

Frement

2014-06-21 20:41:32

From: Cage
Thankfully mines only in a 3 rock area like Wetish said. However, I would be interested in seeing how one could track the location of the rock without reflection if you could provide that Frement? :)


If you take a look at my maple script, I remember it would have color detection for the trees.

From: bonsai
How unique is that color? As long as you don't start getting false positives, I would just use a box centered on the player that is large enough to contain the rock being mined.

So DetectGas would need no parameters.


And that would lead to false positives if the gas is not on the rock you are mining, but someone elses rock.