Negaal
02-15-2008, 10:26 PM
Some functions by me, have fun...
Finds gas near x & y
function GasIn(X, Y : integer) : Boolean;
var
CTS, i, a : integer;
PCount : TIntegerArray;
begin
SetLength(PCount, 2);
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorspeed2Modifiers(0.08, 0.25);
if FindColorTolerance(a, a, 7835543, X - 25, Y - 25, X + 25, Y + 25, 15) then
begin
for i:=0 to 1 do
begin
PCount[i]:= CountColorTolerance(7835543, X - 25, Y - 25, X + 25, Y + 25, 15);
if i = 0 then wait(250);
end;
if PCount[0] <> PCount[1] then
begin
Result := True;
Writeln('Gas found, Pixelcount change: '+FloatToStr((Abs(PCount[0] - PCount[1]) * PCount[0]) / 100)+'%');
end;
end;
SetColorspeed2Modifiers(0.2, 0.2);
ColorToleranceSpeed(CTS);
end;
Makes <Array of Array of Integer> to <Array of integer>
Function TIAAtoTIA(dd :Array of TIntegerArray) : TIntegerArray;
var
New : TIntegerArray;
L, K, i, j, g, d, add, ddl : integer;
begin
g := length(dd);
d := high(dd)
for g := 0 to d do
ddl := ddl + Length(dd[g]);
SetLength(New, ddl)
L := High(dd);
For i := 0 to L do
begin
K := High(dd[i])
For j := 0 to K do
begin
New[add] := dd[i][j];
Inc(Add);
end;
end;
Result := New;
end;
Finds a dummy! :p
function FindDummy(var a, b : integer) : Boolean;
var
TPA : TPointArray;
ATPA : TPointArrayArray;
I, CTS, L : integer;
begin
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorspeed2Modifiers(0.2, 0.8);
FindColorsTolerance(TPA, 8429238, MSX1, MSY1, MSX2, MSY2, 12);
SetColorspeed2Modifiers(0.2, 0.2);
ColorToleranceSpeed(CTS);
ATPA := SplitTPAEx(TPA, 10, 10);
SortATPAFrom(ATPA, IntToPoint(MSCX, MSCY));
L := High(ATPA)
For i := 0 to L do
if Length(ATPA[i]) >= 100 then
begin
MiddleTPAEx(ATPA[i], a, b);
MMouse(a - 5, b - 8, 3, 17);
Wait(50 + random(50));
if (pos('mmo', rs_GetUpText) > 0) then
begin
Getmousepos(a, b);
Result := True;
status('Dummy found!');
Exit;
end;
end;
end;
Find all items execpt colors given, and does what uptext says
procedure DoItemsExceptColors(colorz : TIntegerArray; todo : string);
var
IC : TPoint;
I, J, x, y : integer;
begin
if (GetCurrentTab <> 4) then
begin
Gametab(4);
Wait(1000 + random(1000));
end;
for i := 1 to 28 do
begin
if ExistsItem(i) then
begin
Wait(1000);
if not ExistsItem(i) then Continue;
IC := ItemCoords(i)
For j := 0 to High(Colorz) do
begin
if FindColorSpiralTolerance(x, y, colorz[j],ic.x - 20, ic.y - 20, ic.x + 20, ic.y + 20, 5) then Continue;
if j = High(Colorz) then
begin
MMouseItem(i);
Getmousepos(x, y);
if pos(todo, Rs_GetUpText) > 0 then
Mouse(x, y, 0, 0, true)
else
begin
Mouse(x, y, 0, 0, false)
ChooseOption(ToDo);
end;
end;
end;
end;
end;
end;
Finds an object, Mincount is integer, that how much pixels should that object have
function FindObjTPA(var x, y, Color, MinPoints : integer; Text : String) : Boolean;
var
TPA : TPointArray;
ATPA : TPointArrayArray;
I, L : integer;
begin
FindColorsTolerance(TPA, Color, MSX1, MSY1, MSX2, MSY2, 12);
ATPA := SplitTPAEx(TPA, 10, 10);
SortATPAFrom(ATPA, IntToPoint(MSCX, MSCY));
L := High(ATPA)
For i := 0 to L do
if Length(ATPA[i]) >= MinPoints then
begin
MiddleTPAEx(ATPA[i], a, b);
MMouse(x - 5, y - 5, 11, 11);
Wait(50 + random(50));
if (pos(text, rs_GetUpText) > 0) then
begin
Getmousepos(x, y);
Result := True;
status('Object found!');
Exit;
end;
end;
end;
Finds gas near x & y
function GasIn(X, Y : integer) : Boolean;
var
CTS, i, a : integer;
PCount : TIntegerArray;
begin
SetLength(PCount, 2);
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorspeed2Modifiers(0.08, 0.25);
if FindColorTolerance(a, a, 7835543, X - 25, Y - 25, X + 25, Y + 25, 15) then
begin
for i:=0 to 1 do
begin
PCount[i]:= CountColorTolerance(7835543, X - 25, Y - 25, X + 25, Y + 25, 15);
if i = 0 then wait(250);
end;
if PCount[0] <> PCount[1] then
begin
Result := True;
Writeln('Gas found, Pixelcount change: '+FloatToStr((Abs(PCount[0] - PCount[1]) * PCount[0]) / 100)+'%');
end;
end;
SetColorspeed2Modifiers(0.2, 0.2);
ColorToleranceSpeed(CTS);
end;
Makes <Array of Array of Integer> to <Array of integer>
Function TIAAtoTIA(dd :Array of TIntegerArray) : TIntegerArray;
var
New : TIntegerArray;
L, K, i, j, g, d, add, ddl : integer;
begin
g := length(dd);
d := high(dd)
for g := 0 to d do
ddl := ddl + Length(dd[g]);
SetLength(New, ddl)
L := High(dd);
For i := 0 to L do
begin
K := High(dd[i])
For j := 0 to K do
begin
New[add] := dd[i][j];
Inc(Add);
end;
end;
Result := New;
end;
Finds a dummy! :p
function FindDummy(var a, b : integer) : Boolean;
var
TPA : TPointArray;
ATPA : TPointArrayArray;
I, CTS, L : integer;
begin
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorspeed2Modifiers(0.2, 0.8);
FindColorsTolerance(TPA, 8429238, MSX1, MSY1, MSX2, MSY2, 12);
SetColorspeed2Modifiers(0.2, 0.2);
ColorToleranceSpeed(CTS);
ATPA := SplitTPAEx(TPA, 10, 10);
SortATPAFrom(ATPA, IntToPoint(MSCX, MSCY));
L := High(ATPA)
For i := 0 to L do
if Length(ATPA[i]) >= 100 then
begin
MiddleTPAEx(ATPA[i], a, b);
MMouse(a - 5, b - 8, 3, 17);
Wait(50 + random(50));
if (pos('mmo', rs_GetUpText) > 0) then
begin
Getmousepos(a, b);
Result := True;
status('Dummy found!');
Exit;
end;
end;
end;
Find all items execpt colors given, and does what uptext says
procedure DoItemsExceptColors(colorz : TIntegerArray; todo : string);
var
IC : TPoint;
I, J, x, y : integer;
begin
if (GetCurrentTab <> 4) then
begin
Gametab(4);
Wait(1000 + random(1000));
end;
for i := 1 to 28 do
begin
if ExistsItem(i) then
begin
Wait(1000);
if not ExistsItem(i) then Continue;
IC := ItemCoords(i)
For j := 0 to High(Colorz) do
begin
if FindColorSpiralTolerance(x, y, colorz[j],ic.x - 20, ic.y - 20, ic.x + 20, ic.y + 20, 5) then Continue;
if j = High(Colorz) then
begin
MMouseItem(i);
Getmousepos(x, y);
if pos(todo, Rs_GetUpText) > 0 then
Mouse(x, y, 0, 0, true)
else
begin
Mouse(x, y, 0, 0, false)
ChooseOption(ToDo);
end;
end;
end;
end;
end;
end;
Finds an object, Mincount is integer, that how much pixels should that object have
function FindObjTPA(var x, y, Color, MinPoints : integer; Text : String) : Boolean;
var
TPA : TPointArray;
ATPA : TPointArrayArray;
I, L : integer;
begin
FindColorsTolerance(TPA, Color, MSX1, MSY1, MSX2, MSY2, 12);
ATPA := SplitTPAEx(TPA, 10, 10);
SortATPAFrom(ATPA, IntToPoint(MSCX, MSCY));
L := High(ATPA)
For i := 0 to L do
if Length(ATPA[i]) >= MinPoints then
begin
MiddleTPAEx(ATPA[i], a, b);
MMouse(x - 5, y - 5, 11, 11);
Wait(50 + random(50));
if (pos(text, rs_GetUpText) > 0) then
begin
Getmousepos(x, y);
Result := True;
status('Object found!');
Exit;
end;
end;
end;