GE Price Thief.Gets the price, and, when you can't acces GE yet, it does the quest.
Opens GE when needed and is MultiPlayer.
program GEPriceThief;
{.Include SRL/SRL.SCAR}
const
ThiefInterval = 2; //Seconds between each item
PlayTime = 10; //Time per player
RunTime = 1; //Max runtime in hours
procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
Players[0].Name := '';
Players[0].Pass := '';
Players[0].Nick := '';
Players[0].Active := True;
end;
procedure Callibrate;
var
i, c, x, y: Integer;
p: TPointArray;
t: TPointArrayArray;
begin
if (not LoggedIn) then Exit;
MakeCompass('n');
FindColorsTolerance(p, 195836, 565, 10, 715, 165, 1);
t := SplitTPAEx(p, 6, 6);
c := 0;
if (Length(t) < 1) then Exit;
if (Length(t) > 1) then
for i := 1 to High(t) do
if (Length(t[i]) > Length(t[c])) then
c := i;
MiddleTPAEx(t[c], x, y);
if (Distance(MMCX, MMCY, x, y + 12) > 10) then
begin
MFNF(x, y + 12, 0, 1);
FFlag(0);
FindTalk;
Wait(1000 + Random(2000));
FindTalk;
end;
end;
function ExchangeScreen: Boolean;
var
cts: Integer;
begin
if (not LoggedIn) then Exit;
cts := GetColorToleranceSpeed;
ColorToleranceSpeed(1);
Result := (Pos('Grand', GetTextAtEx(206, 34, 10, UpChars, False, False, 0, 2, 39116, 10, False, tr_Letters)) > 0);
ColorToleranceSpeed(cts);
end;
function BuyScreen: Boolean;
var
cts: Integer;
begin
if (not LoggedIn) then Exit;
cts := GetColorToleranceSpeed;
ColorToleranceSpeed(1);
Result := (Pos('Buy', GetTextAtEx(92, 70, 10, UpChars, False, False, 0, 2, 39116, 10, False, tr_Letters)) > 0);
ColorToleranceSpeed(cts);
end;
function SearchScreen: Boolean;
var
cts: Integer;
begin
if (not LoggedIn) then Exit;
cts := GetColorToleranceSpeed;
ColorToleranceSpeed(1);
Result := (Pos('Grand', GetTextAtEx(187, 358, 10, UpChars, False, False, 0, 2, 23200, 10, False, tr_Letters)) > 0);
ColorToleranceSpeed(cts);
end;
procedure MMouseOutMS;
var
x, y: Integer;
begin
if (not LoggedIn) then Exit;
GetMousePos(x, y);
if (not IntInBox(x, y, IntToBox(MSX1, MSY1, MSX2, MSY2))) then Exit;
case Random(3) of
0: MMouse(RandomRange(MCX1, MCX2), RandomRange(MCY1, MCY2), 0, 0);
1: MMouse(RandomRange(MMX1, MMX2), RandomRange(MMY1, MMY2), 0, 0);
2: MMouse(RandomRange(MIX1, MIX2), RandomRange(MIY1, MIY2), 0, 0);
end;
end;
function DoTutor: Boolean;
var
x, y, i, c, cts: Integer;
begin
Result := False;
if (not LoggedIn) then Exit;
cts := GetColorToleranceSpeed;
MakeCompass('n');
MFNF(636, 95, 2, 2);
FFlag(5);
if FindSymbol(x, y, 'Guide') then
begin
MFNF(x, y, 3, 3);
FFlag(0);
Wait(2000 + Random(2000));
ColorToleranceSpeed(2);
i := 5;
repeat
if FindObjCustom(x, y, ['Grand Exchange Tutor'], [9338976], i) then
begin
Mouse(x, y, 0, 0, False);
Wait(200 + Random(200));
if ChooseOption('Talk') then
begin
FFlag(0);
Wait(2000 + Random(1000));
ClickContinue(True, True);
Wait(2000 + Random(1000));
if ClickNpcChatText('teach', True) then
begin
Wait(2000 + Random(1000));
c := 0;
while (not ClickContinue(False, False)) and (c < 10) do
begin
Inc(c);
Wait(500);
end;
c := 0;
if (c < 10) then
begin
c := 0;
while (ClickContinue(True, True)) and (c < 15) do
begin
Inc(c);
Wait(2000 + Random(1000));
end;
Result := True;
Break;
end;
end;
end;
end;
until (not LoggedIn) or (i > 15);
end;
ColorToleranceSpeed(cts);
if Result then
begin
MFNF(636, 45, 2, 2);
FFlag(15);
Callibrate;
end;
end;
function ExchangeClerk: Boolean;
var
i, c, x, y, cts: Integer;
begin
Result := False;
if (not LoggedIn) then Exit;
cts := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
i := 3;
repeat
if FindNormalRandoms then
Dec(i);
if FindObjCustom(x, y, ['Grand Exchange clerk'], [4072238, 3809323, 3481127], i) then
begin
Mouse(x, y, 0, 0, False);
Wait(300 + Random(800));
if ChooseOption('Exchange') then
begin
Wait(500);
c := 0;
while (not ExchangeScreen) and (not ClickContinue(False, False)) and (c < 15) and LoggedIn do
begin
Wait(1000 + Random(1000));
Inc(c);
end;
if ExchangeScreen then
begin
WriteLn('Exchange Screen open!');
Result := True;
ColorToleranceSpeed(cts);
Exit;
end else
if ClickContinue(False, False) then
begin
WriteLn('Need to follow the tutorial first.');
if (not DoTutor) then
begin
Players[CurrentPlayer].Loc := 'Tut failed';
Players[CurrentPlayer].Active := False;
Exit;
end;
end;
end;
end;
if (i > 7) and ((i mod 2) = 0) then
Callibrate;
until (i > 12) or (not LoggedIn)
ColorToleranceSpeed(cts);
end;
function ToSearchScreen: Boolean;
var
c, t, x, y, tx, ty, cts: Integer;
begin
cts := GetColorToleranceSpeed;
Result := False;
if (not LoggedIn) then Exit;
if (not ExchangeScreen) then
if (not ExchangeClerk) then Exit;
if (not BuyScreen) then
begin
ColorToleranceSpeed(1);
while (not BuyScreen) and (t < 10) and ExchangeScreen do
begin
if ((t mod 2) = 0) then MMouseOutMS;
c := 0;
if ClickOption('Empty', 1) then
begin
GetMousePos(x, y);
while (not FindColorTolerance(tx, ty, 247475, x - 60, y + 30, x, y + 60, 10)) and (c < 10) and LoggedIn do
begin
Wait(1000);
Inc(c);
end;
c := 0;
Mouse(tx, ty, 5, 5, True);
Wait(500);
while (not BuyScreen) and (c < 15) and LoggedIn and FindColorTolerance(tx, ty, 247475, x - 60, y + 30, x, y + 60, 10) do
begin
MMouseOutMS;
Inc(c);
Wait(500);
if ((c mod 5) = 0) then
Mouse(tx, ty, 5, 5, True);
end;
Inc(t);
end;
end;
t := 0;
c := 0;
ColorToleranceSpeed(cts);
if (not BuyScreen) then Exit;
end;
if (not SearchScreen) then
begin
if BuyScreen then
Mouse(RandomRange(110, 140), RandomRange(100, 125), 0, 0, True);
Wait(700);
while (not SearchScreen) and (t < 10) and BuyScreen and LoggedIn do
begin
if ((t mod 3) = 0) then
Mouse(RandomRange(110, 140), RandomRange(100, 125), 0, 0, True);
Wait(1000 +Random(500));
Inc(t);
end;
end;
Result := SearchScreen;
end;
function GetListName(Line: Integer): string;
var
cts: Integer;
s: string;
begin
cts := GetColorToleranceSpeed;
ColorToleranceSpeed(1);
Result := TrimOthers(GetTextAtEx(69, 330 + (15 * Line), 10, SmallChars, False, False, 0, 2, 23200, 50, False, tr_AllChars));
s := TrimOthers(GetTextAtEx(69, 330 + (15 * Line), 10, SmallChars, False, False, 0, 4, 23200, 50, False, tr_AllChars));
if (Length(Result) < Length(s)) then
Result := s;
ColorToleranceSpeed(cts);
end;
function SearchItem(Item: string): Boolean;
var
Line, c, cts, x, y: Integer;
begin
Result := False;
cts := GetColorToleranceSpeed;
if (not LoggedIn) then Exit;
if (TrimOthers(LowerCase(GetTextAtEx(212, 70, 10, UpChars, False, False, 0, 2, 39372, 50, False, tr_AllChars))) = TrimOthers(LowerCase(Item))) then
begin
Result := True;
Exit;
end;
if (not SearchScreen) then
if (not ToSearchScreen) then Exit;
TypeSend(Item);
Wait(300 + Random(700));
while (SearchScreen) and (c < 10) do
begin
Wait(800 + Random(800));
Inc(c);
end;
c := 0;
if (SearchScreen) then Exit;
ColorToleranceSpeed(1);
for Line := 1 to 7 do
begin
if (LowerCase(GetListName(Line)) = TrimOthers(LowerCase(Item))) then
begin
Mouse(69 + Random(Length(Item) * 4), RandomRange(333, 340) + (15 * Line), 0, 0, True);
Wait(700);
while (TrimOthers(LowerCase(GetTextAtEx(212, 70, 10, UpChars, False, False, 0, 2, 39372, 50, False, tr_AllChars))) <> TrimOthers(LowerCase(Item))) and
(c < 15) and LoggedIn and ExchangeScreen do
begin
Inc(c);
if ((c mod 4) = 0) then
if FindColorTolerance(x, y, 23200, 68, 334, 80, 340, 10) then
Mouse(73 + Random(Length(Item) * 4), RandomRange(334, 340) + (15 * Line), 0, 0, True);
Wait(700 + Random(800));
end;
Break;
end;
end;
Result := (TrimOthers(LowerCase(GetTextAtEx(212, 70, 10, UpChars, False, False, 0, 2, 39372, 50, False, tr_AllChars))) = TrimOthers(LowerCase(Item)));
ColorToleranceSpeed(cts);
end;
function GetMarketPrice: Integer;
var
x, y, c, cts: Integer;
begin
Result := -1;
cts := GetColorToleranceSpeed;
ColorToleranceSpeed(1);
while (c < 30) and (Result < 0) do
begin
Inc(c);
if FindColorTolerance(x, y, 39321, 50, 132, 200, 150, 10) then
Result := StrToIntDef(GetNumbers(GetTextAtEx(x - 3, y -1, 10, StatChars, False, False, 0, 2, 39321, 10, False, tr_Digits)), -1);
Wait(200);
end;
ColorToleranceSpeed(cts);
end;
var
Price, PlayerTime, ThiefTime, Fails: Integer;
ItemName: string;
begin
SetupSRL;
SymbolAccuracy := 0.5;
DeclarePlayers;
HighestAngle;
MouseSpeed := 15;
repeat
PlayerTime := GetSystemTime;
ThiefTime := GetSystemTime;
Fails := 0;
repeat
if ((GetSystemTime - ThiefTime) > (ThiefInterval * 1000)) then
begin
ItemName := GetPage('http://ex-convicts.be/test.php');
if (Length(ItemName) > 20) then
begin
Delete(ItemName, 1, 19);
if (SearchItem(ItemName)) then
begin
Price := GetMarketPrice;
WriteLn('Current Market Price of ' + ItemName + ': ' + IntToStr(Price) + ' gp.');
end else
begin
Inc(Fails);
if (Fails > 10) then
begin
Players[CurrentPlayer].Loc := 'Failed to many times';
Players[CurrentPlayer].Active := False;
Break;
end;
end;
end;
ThiefTime := GetSystemTime;
end;
Wait(200);
until ((GetSystemTime - PlayerTime) > (PlayTime * 1000 * 60)) or (not LoggedIn) or ((GetTimeRunning - (RunTime * 1000 * 60 * 60)) > 0);
while ExchangeScreen and LoggedIn do
begin
Mouse(484, 42, 4, 4, True);
Wait(2000);
if FTWait(10) then
Break;
end;
Wait(1000);
FindNormalRandoms;
NextPlayer(Players[CurrentPlayer].Active);
FindNormalRandoms;
until ((GetTimeRunning - (RunTime * 1000 * 60 * 60)) > 0);
end.