SRL Archive - SRL Archives

FindGas


Cazax

2009-01-26 10:54:41

I've heard that FindGas in SRL isn't working or is outdated. So I made a gas finder:
Function FindGas(RockX, RockY : Integer; Var GasX, GasY : Integer): Boolean;
Var
TPA, Points : TPointArray;
ATPA : T2DPointArray;
I, Bmp, Hi, temp, Bmp2, J, K, Count : Integer;
H, S, L : Extended;
Box : TBox;
Canv1, Canv2 : TCanvas;
Begin
Bmp := BitmapFromString(0, 0, '');
Bmp2 := BitmapFromString(0, 0, '');
SetLength(Points, 0);
ColorToleranceSpeed(2);
FindColorsSpiralTolerance(MSCX, MSCY, TPA, 8820900, RockX - 30, RockY - 30, RockX + 30, RockY + 30, 30);
ColorToleranceSpeed(1);
If Length(TPA) = 0 Then
Exit;
Hi := High(TPA);
For I := 0 To Hi Do
Begin
temp := GetColor(TPA[I].X, TPA[I].Y);
ColorToHSL(temp, H, S, L);
If H < 13 Then
If H > 6 Then
Begin
SetLength(Points, Length(Points) + 1);
Points[High(Points)] := TPA[I];
End;
End;
ATPA := SplitTPA(Points, 10);
Hi := High(ATPA);
For I := 0 To Hi Do
Begin
If Length(ATPA[I]) < 100 Then
Continue;
Box := GetTPABounds(ATPA[I]);
CopyClientToBitmap(Bmp, Box.X1, Box.Y1, Box.X2, Box.Y2);
Wait(250);
CopyClientToBitmap(Bmp2, Box.X1, Box.Y1, Box.X2, Box.Y2);
Canv1 := GetBitmapCanvas(Bmp);
Canv2 := GetBitmapCanvas(Bmp2);
For J := Box.X1 To Box.X2 Do
For K := Box.Y1 To Box.Y2 Do
If Canv1.Pixels[J, K] <> Canv2.Pixels[J, K] Then
Inc(Count);
If (Count / ((Box.X2 - Box.X1) + (Box.Y2 - Box.Y1))) * 100 >= 70 Then
Begin
Writeln('Found Gas!');
Result := True;
MiddleTPAex(ATPA[I], GasX, GasY);
FreeBitmap(Bmp);
FreeBitmap(Bmp2);
Exit;
End;
End;
FreeBitmap(Bmp);
FreeBitmap(Bmp2);
End;

I have tested it with gasses, haven't failed :)

Wizzup?

2009-01-26 11:15:13

Did you test on zombie clothes? Both the gasses? (Old rock gas != New rock gas)
Freaky Forester clothes?

E: AFAIK the two in my Multi Miner still work nicely?

Markus

2009-01-26 12:06:58

The two in your multiminer aren't in SRL, are they?

Cazax

2009-01-26 12:11:32

I have tested it with freaky forester clothes, and zombie ones, nothing happened. I couldn't find any old rock in f2p, the dwarf mines have new rocks.
@Markus: There is only 1 FindGas in SRL by nielsie and sumilion.

tarajunky

2009-01-26 14:19:30

I'll throw it into my mining script, have it take screenshots, and see what happens.

Edit: It doesn't compile??


Failed when compiling
Line 1: [Error] (1:1): Variable Expected in script

That's with SCAR 3.20 Beta 8.1 and the latest Dev SRL.

Cazax

2009-01-26 15:01:34

From: tarajunky
I'll throw it into my mining script, have it take screenshots, and see what happens.

Edit: It doesn't compile??


Failed when compiling
Line 1: [Error] (1:1): Variable Expected in script

That's with SCAR 3.20 Beta 8.1 and the latest Dev SRL.

The function will store the gas coords in X and Y so they have to be variables :) no need to input the rock coords.

EDIT: Then you can use Distance to see if your near that rock.

Wizzup?

2009-01-26 15:21:50

From: Cazax
The function will store the gas coords in X and Y so they have to be variables :) no need to input the rock coords.

EDIT: Then you can use Distance to see if your near that rock.


Why don't you let it return the gas coordinates with different variables?
This way is not very convenient for the scripter.

Cazax

2009-01-26 15:40:16

From: Wizzup?
Why don't you let it return the gas coordinates with different variables?
This way is not very convenient for the scripter.


Ok, updated :)

tarajunky

2009-01-26 15:49:53


Line 219: [Error] (18504:1): Unknown identifier 'DebugTPA' in script

Is that one of your functions?

edit: Nevermind, I found it and put it in. I'll let you know how it works.

Cazax

2009-01-26 15:55:14

From: tarajunky

Line 219: [Error] (18504:1): Unknown identifier 'DebugTPA' in script

Is that one of your functions?

edit: Nevermind, I found it and put it in. I'll let you know how it works.

Oops, I forgot to remove it :duh: