pwnaz0r
2008-10-25 19:35:02
Ok this is some work I did on a GE Include, that was requested. I heard after I started working on it that munk was almost done with one, but now so am I :). So for now I will just post it here for comments. Updating regularly…
//-----------------------------------------------------------------//
//-- Scar Standard Resource Library --//
//-- ยป Grand Exchange Routines --//
//-----------------------------------------------------------------//
type
TGrandExchangeBox = record
IsOpen: boolean;
Coords, BuyCoords, SellCoords: TBox;
end;
//By: Boreas and Pwnaz0r
function FindGEClerkEx(CheckUpText:boolean): boolean;
var
pPoints, mPoints: TPointArray;
bpoints,bpoints3: TPointArray;
cPoints, bpoints2: T2DPointArray;
i: integer;
begin
//SetAngle(true);
FindColorsTolerance(bPoints, 1315861, MSX1, MSY1, MSX2, MSY2, 5);
bPoints2:= SplitTPA(bPoints, 2);
SortATPAFromSize(bpoints2,200,false);
SetLength(bPoints3, Length(bpoints2));
bPoints3[0]:= bpoints2[0][(length(bpoints2[0])-1)];
writeln(inttostr(bpoints3[0].x)+' '+inttostr(bpoints3[0].y))
//terminatescript;
FindColorsTolerance(pPoints, 4860728, MSX1, bpoints3[0].y, MSX2, MSY2, 15);
if (Length(pPoints) < 1)then
exit;
cPoints:= SplitTPAEx(pPoints, 14, 24);
SetLength(mPoints, Length(cPoints));
for i:= 0 to High(cPoints) do
try
mPoints[I]:= MiddleTPA(cPoints[I]);
except
end;
bpoints3[0].y:=bpoints3[0].y;
SortTPAFrom(mpoints,bpoints3[0]);
SortTPAFrom(mPoints, Point(Round(MSX2/2), Round(MSY2/2)));
for I:= 0 to High(mPoints) do
begin
result:=true;
if CheckUpText then
begin
MMouse(mPoints[I].x, mPoints[I].y, 0, 0);
result:= IsUpText('rand');
end;
if (result)then
begin
Mouse(mPoints[I].x, mPoints[I].y, 0, 0, false);
result:= ChooseOption('Exchange'); //must be full word.
if (result)then break;
end;
end;
end;
// BY: Pwnaz0r
function FindGEClerk: boolean;
begin
result:= (FindGEClerkEx(true));
if not (result)then
result:= (FindGEClerkEx(false));
end;
// By: Pwnaz0r
function GrandExchangeScreen: boolean;
begin
result:= FindTextTpa(39116, 10, 250, 29, 317, 52, 'xchange', UpChars, Nothing);
end;
// By: Pwnaz0r
function SellScreen: boolean;
begin
result:= FindTextTpa(39116, 10, 97, 69, 125, 91, 'ell', UpChars, Nothing);
if Result then
Writeln('Sell Screen.');
end;
// By: Pwnaz0r
function BuyScreen: boolean;
begin
result:= FindTextTpa(39116, 10, 101, 74, 120, 87, 'uy', UpChars, Nothing);
if Result then
Writeln('Buy Screen.');
end;
// By: Pwnaz0r
procedure MainScreen;
begin
if BuyScreen or SellScreen then
Mouse(37, 290, 21, 14, true);
wait(800);
end;
//By: Pwnaz0r
function GrandExchangeBox(Num: integer): TBox;
var
SPoint: TPoint;
begin
if not (GrandExchangeScreen)then exit;
MainScreen;
if not (InRange(Num, 1, 6))then
exit;
if (Num >= 4)then
begin
SPoint:= Point(34, 204)
Num:= Num - 3;
end else
SPoint:= Point(34, 84);
// Main Coords
Result.X1:= (Round(SPoint.X + ((Num-1) * (17 + 138))));
Result.Y1:= SPoint.Y;
Result.X2:= Result.X1 + 138;
Result.Y2:= Result.Y1 + 108;
end;
//By : pwnaz0r
function BoxOpen(Num: integer): boolean;
var
GEBox: TBox;
X, Y: integer;
begin
GEBox:= GrandExchangeBox(Num);
result:= not FindColor(X, Y, 0, GEBox.X1 + 18, GEBox.Y1 + 80, GEBox.X1 + 133, GEBox.Y1 + 94);
//Writeln('Box '+IntToStr(Num)+' open : '+BoolToStr(Result));
end;
//by Pwnaz0r;
function BoxInfo(Num: integer): TGrandExchangeBox;
begin
result.Coords:= GrandExchangeBox(Num);
result.IsOpen:= BoxOpen(Num);
//Buy Coords
Result.BuyCoords.X1:= Result.Coords.X1 + 16;
Result.BuyCoords.Y1:= Result.Coords.Y1 + 45;
Result.BuyCoords.X2:= Result.BuyCoords.X1 + 44;
Result.BuyCoords.Y2:= Result.BuyCoords.Y1 + 42;
//Sell Coords
Result.SellCoords.X1:= Result.Coords.X1 + 79;
Result.SellCoords.Y1:= Result.Coords.Y1 + 45;
Result.SellCoords.X2:= Result.SellCoords.X1 + 44;
Result.SellCoords.Y2:= Result.SellCoords.Y1 + 42;
end;
function GEBoxInfos: array of TGrandExchangeBox;
var
I: integer;
begin
SetArrayLength(result, 7);
for I:= 1 to 6 do
result[I]:= BoxInfo(I);
end;
function FindOpenBox: integer;
var
I: integer;
begin
result:= -1;
for I:= 1 to 6 do
if BoxOpen(I)then
begin
result:= I;
exit;
end;
end;
procedure ConfirmOffer;
var
I: integer;
begin
I:= 0;
repeat
Inc(i);
Mouse(206, 276, (320 - 206), (313 - 276), true);
wait(800);
until((not (BuyScreen)) and (not (SellScreen)));
end;
procedure Ge_AdjQuantityPrice(Quantity :integer; Price: string);
var
mark: integer;
begin
if ((not(BuyScreen)) and (not(SellScreen)))then
exit;
if Quantity <> 0 then
begin
Mouse(222, 212, (251 - 222), (230 - 212), true);
mark:= GetSystemTime;
repeat
if ((GetSystemTime - Mark) >= 5000)then
begin
Writeln('Error setting quantity.');
Typesend('');
exit;
end;
until(FindTextTpa(0, 0, 210, 393, 261, 409, 'amount', UpChars, Nothing));
TypeSend(IntToStr(Quantity));
end;
case Lowercase(Price) of
'max','maximum': Mouse(379, 211, (407-379), (230-211), true);
'none','market': Mouse(325, 211, (354-325), (230-211), true);
'min','minimum': Mouse(273, 211, (302-273), (231-211), true);
end;
end;
// quantity = 0 = all.
// price = Min, Market, Max
function GESellItem_Number(Num, Quantity: integer; Price: string): boolean;
var
I: integer;
Box: TGrandExchangeBox;
Mark: integer;
begin
if not ExistsItem(Num)then
begin
Writeln('Item '+IntToStr(Num)+' does not exist.');
exit;
end;
if not (GrandExchangeScreen)then exit;
I:= FindOpenBox;
if (I = -1) then
exit;
Box:= BoxInfo(I);
Mouse(Box.SellCoords.X1, Box.SellCoords.Y1, (Box.SellCoords.X2 - Box.SellCoords.X1), (Box.SellCoords.Y2 - Box.SellCoords.Y1), true);
mark:= GetSystemTime;
repeat
if ((GetSystemTime - Mark) >= 5000)then
begin
Writeln('Error selling item.');
exit;
end;
until(SellScreen);
MouseItem(Num, true);
mark:= GetSystemTime;
repeat
if ((GetSystemTime - Mark) >= 5000)then
begin
Writeln('Error selling item.');
exit;
end;
until(not FindTextTpa(39116, 10, 213, 69, 263, 84, 'hoose', UpChars, Nothing));
Ge_AdjQuantityPrice(Quantity, Price);
ConfirmOffer;
result:= true;
end;
function GESellItem_Name(Name: string; Quantity: integer; Price: string): boolean;
var
I: integer;
begin
for I:= 1 to 28 do
if ExistsItem(I)then
begin
MMouseItem(I);
wait(800);
if IsUpText(Name)then
if GESellItem_Number(I, Quantity, Price)then
begin
result:= true;
exit;
end;
end;
end;
function ItemsToClaim(Box: TGrandExchangeBox): boolean;
var
X, Y: integer;
begin
MainScreen;
try
if (GetColor(Box.Coords.X1 + (321 - 168), Box.Coords.Y1 + (168 - 84))= 1048714)then
result:= true;
if not (result)then
if (GetColor(Box.Coords.X1 + (321 - 168), Box.Coords.Y1 + (168 - 84))= 1999423)then
result:= true;
except
Writeln('ERROR FINDING COLORS');
end;
end;
procedure ClaimItem(Box: TGrandExchangeBox);
var
aBool: Boolean;
Mark: integer;
begin
if (InvFull)then
exit;
if not (BuyScreen) or (SellScreen)then
begin
if not(ItemsToClaim(Box))then
exit;
Mouse(Box.Coords.X1, Box.Coords.Y1, 138, 108, true);
end;
Mark:= GetSystemTime;
repeat
if ((GetSystemTime - Mark) >= 5000)then
begin
Writeln('Error selling item.');
exit;
end;
until(SellScreen) or (BuyScreen);
MMouse(402, 283, (435-402), (312-283));
wait(500);
if IsUpText('ollec')then
Mouse(402, 283, (435-402), (312-283), true);
MMouse(451, 284, (483-451), (312-284));
wait(500);
if IsUpText('ollec')then
Mouse(451, 284, (483-402), (312-284), true);
end;
procedure ClaimAllItems;
var
I, T, Col, Mark: integer;
cBox: TGrandExchangeBox;
mPoint: TPoint;
cPoints: TPointArray;
begin
if InvFull then exit;
for I:= 1 to 6 do
begin
for T:= 1 to 2 do
begin
case T of
1: Col:= 1048714;
2: Col:= 1999423
end;
cBox:= BoxInfo(I);
FindColorsTolerance(cPoints, Col, cBox.Coords.X1, cBox.Coords.Y1, cBox.Coords.X2, cBox.Coords.Y2, 10);
if (Length(cPoints) > 50)then
begin
mPoint:= MiddleTPA(cPoints);
Mouse(mPoint.x, mPoint.y, 5, 0, true);
Mark:= GetSystemTime;
repeat
if ((GetSystemTime - Mark) >= 5000)then
begin
Writeln('Error selling item.');
exit;
end;
until(SellScreen) or (BuyScreen);
MMouse(402, 283, (435-402), (312-283));
wait(500);
if IsUpText('ollec')then
Mouse(402, 283, (435-402), (312-283), true);
wait(1000);
if(not(BuyScreen) and not(SellScreen))then
exit;
MMouse(451, 284, (483-451), (312-284));
wait(500);
if IsUpText('ollec')then
Mouse(451, 284, (483-402), (312-284), true);
end;
end;
end;
end;
{function AbortItem(Box: TGrandExchangeBox): boolean;
var
Mark: integer;
begin
if not Box.IsOpen then
begin
Mouse(Box.Coords.X1, Box.Coords.Y1, 138, 108, true);
mark:= GetSystemTime;
repeat
if ((GetSystemTime - Mark) >= 5000)then
begin
Writeln('Error selling item.');
exit;
end;
until(SellScreen);
Mouse(358, 280, 10, 12, true);
end;
end; }