SRL Archive - Research & Development Lounge

[SRL 4] The Grand Exchange


Drakan

2008-05-25 21:05:37

Hey these are my Grand Exchange functions! I'm adding more as i go along, so give me ideas or post your functions and I'll add them to the list! Tell me what you think ;)

//  » procedure LoadGEDtm(which: string);                                           | by The[Cheese]
// » procedure FreeGeDTM; | by The[Cheese]
// » function InGE: boolean; | by The[Cheese]
// » function InGEOffer: boolean; | by The[Cheese]
// » function OpenSlot(slot: integer): boolean; | by The[Cheese]
// » function OpenGE(side: string): boolean; | by The[Cheese]
// » function OpenAvailableBuySlot: boolean; | by The[Cheese]
// » function OpenAvailableSellSlot: boolean; | by The[Cheese]

{*******************************************************************************
procedure LoadGEDtm(which: string);
By: The[Cheese]
Description: Loads GE Dtms.
*******************************************************************************}
procedure LoadGEDtm(which: string);
begin
case lowercase(which) of
'buydtm': GeDTM := DTMFromString('78DA637CCCC0C0D0C78002361F6366E002D28' +
'C40FC1F0818416A96A1AA51E382D08C503EE37B20319F809AEB40' +
'62010135F781442B0135CF09AB0100A3F50F4E');

'selldtm': GeDTM := DTMFromString('78DA6354666460E8664001C7329919B880345' +
'086E13F103082D4B4A0AA51E382D08C503EA31E90359F801A3120' +
'6B010135E240D644026A7480AC4904D4280259CBF0AB0100B9650' +
'B73');
end;
end;

{*******************************************************************************
procedure FreeGeDTM;
By: The[Cheese]
Description: Frees GE Dtms.
*******************************************************************************}
procedure FreeGeDTM;
begin
FreeDTM(GeDTM);
end;

{*******************************************************************************
function InGE: boolean;
By: The[Cheese]
Description: Checks to see if we are in the GE by looking for the coins in the
top left corner of the GE screen.
*******************************************************************************}
function InGE: boolean;
var
gesymbol, x1, y1: integer;
begin
gesymbol := BitmapFromString(5, 9, 'beNpby7C1mOH5Wobnexn+/3' +
'8PZFgaSrRYQhEDAz7ZIEtNUmWrnTggslGWqCYDAEYsOlU=');
Result := false;
Result := (FindBitMapToleranceIn(gesymbol, x1, y1, 24, 24, 58, 58, 15))
Writeln(booltostr(Result));
FreeBitmap(gesymbol);
end;

{*******************************************************************************
function InGEOffer: boolean;
By: The[Cheese]
Description: Checks to see if we are in an offer screen by looking for the
arrow in the bottom left corner.
*******************************************************************************}
function InGEOffer: boolean;
var
x1, y1: integer;
begin
Result := false;
Result := (FindColorTolerance(x1, y1, 11909574, 29, 279, 69, 312, 10));
Writeln(booltostr(Result));
end;

{*******************************************************************************
function OpenSlot(slot: integer): boolean;
By: The[Cheese]
Description: Opens a slot [1 to 12]
*******************************************************************************}
function OpenSlot(slot: integer): boolean;
var
SlotArray: TPointArray;
begin
if(InGEOffer)then MouseBox(39, 287, 56, 303, 1);
wait(500+Random(500));
SetLength(SlotArray, 12);
SlotArray[0].x := 70; SlotArray[0].y := 151;
SlotArray[1].x := 134; SlotArray[1].y := 151;
SlotArray[2].x := 226; SlotArray[2].y := 151;
SlotArray[3].x := 289; SlotArray[3].y := 151;
SlotArray[4].x := 383; SlotArray[4].y := 151;
SlotArray[5].x := 447; SlotArray[5].y := 151;
SlotArray[6].x := 70; SlotArray[6].y := 273;
SlotArray[7].x := 134; SlotArray[7].y := 273;
SlotArray[8].x := 226; SlotArray[8].y := 273;
SlotArray[9].x := 289; SlotArray[9].y := 273;
SlotArray[10].x := 383; SlotArray[10].y := 273;
SlotArray[11].x := 447; SlotArray[11].y := 273;

Mouse(SlotArray[(slot-1)].x, SlotArray[(slot-1)].y, 10, 10, true);
repeat
wait(500);
until(InGEOffer);
Writeln('We are in the trade screen!');
end;

{*******************************************************************************
function OpenAvailableBuySlot: boolean;
By: The[Cheese]
Description: Opens an available buy slot.
*******************************************************************************}
function OpenAvailableBuySlot: boolean;
var
xx, yy: integer;
begin
LoadGEDtm('buydtm');
if(DTMRotated(GeDTM, xx, yy, MSX1, MSY1, MSX2, MSY2))then
begin
Mouse(xx, yy, 5, 5, true);
Result := true;
end else Result := false;
FreeGEDtm;
end;

{*******************************************************************************
function OpenAvailableSellSlot: boolean;
By: The[Cheese]
Description: Opens an available sell slot.
*******************************************************************************}
function OpenAvailableSellSlot: boolean;
var
xx, yy: integer;
begin
LoadGEDtm('selldtm');
if(DTMRotated(GeDTM, xx, yy, MSX1, MSY1, MSX2, MSY2))then
begin
Mouse(xx, yy, 5, 5, true);
Result := true;
end else Result := false;
FreeGEDtm;
end;

{*******************************************************************************
function OpenGE(side: string): boolean;
By: The[Cheese]
Description: Opens the Grand Exchange by clicking one of the GE Clerks.
*******************************************************************************}
function OpenGE(side: string): boolean;
var
TheTPA: TPointArray;
UpTextArray: TStringArray;
i, time: integer;
begin
case Lowercase(side) of
'n': MakeCompass('s');
's': MakeCompass('n');
'e': MakeCompass('w');
'w': MakeCompass('e');
end;
FindColorsSpiralTolerance(15, 41, TheTPA, 3744043, MSX1, MSY1, MSX2,MSY2, 10);
MarkTime(Time);
if(Length(TheTPA) > 0)then
begin
for i:= 0 to High(TheTPA) do
begin
MMouse(TheTPA[i].x, TheTPA[i].y, 0, 0);
wait(100);
if(IsUpTextMultiCustom(['Grand Exchange','Clerk','xchan']))then
begin
Mouse(TheTPA[i].x, TheTPA[i].y, 0, 0, false);
ChooseOption('Exchange');
Flag;
repeat
wait(500);
until((InGE) or (TimeFromMark(Time) > 10000));
if(TimeFromMark(Time) > 10000)then
begin
Writeln('***Failed to open GE!***');
Result := false;
Exit;
end;
Writeln('Found the banker or clerk!');
Result := true;
wait(500 + Random(500));
Exit;
end else Result := false;
if(TimeFromMark(Time) > 10000)then Exit;
end;
end else Result := false;
end;


Dusk412

2008-05-25 21:11:02

Hey nice work :D. hey I am curious as to what OpenSlot does. I mean it opens one of the 12 GE slots? Does it go to buy or sell or what. I am rather confused on that one.

Edit: Your InGE is identical almost to the one I used in the script I am making lol and I made it before you even posted this lol. Nice… :D.

Edit: Also I tried to use your OpenGE as my main function and then mine as a backup (mine works for me perfectly anyways I just figured the power of two meant it could never possible mess up). For some reason yours didn't open it up. I may have set it up wrong but I don't know.

Edit: You should add a FindGE to this compilation. If they are near by, it checks the minimap for a DTM of the GE and puts them at one of the sides. Here is the one I have been using for my Grand Exchange Merchanter (by request) and it puts the character at the southwest corner. You can edit it up or make one from scratch but I think it would be a good addition.


{*******************************************************************************
function FindGE : Boolean;
By: Dusk412
Description: Finds The GE (southwest corner) on the minimap using a DTM and clicks
*******************************************************************************}
function FindGE : Boolean;
var i;
begin
MakeCompass('N');
SetAngle(True);
GrandExchangeDTM := DTMFromString('78DA6314606060906140014545590CFF81342' +
'310FF0702467E20431C22C70C55F3E70F13033F540D0880D50811' +
'500392E727A0460C48F01150234D845DD244B819242F45408D306' +
'135004BDA1831');
i := 0;
repeat
i := i + 1;
if (DTMRotated(GrandExchangeDTM, x, y, MMX1, MMY1, MMX2, MMY2)) then
begin
Wait(500+random(150));
Mouse(x, y, 3, 3, True);
FFlag(2);
Result := True;
Break;
end else
begin
MMouse(645, 330, 20, 20);
if (i >= 5) then
begin
Result := True;
end;
end;
until( i>=5 );
FreeDTM(GrandExchangeDTM);
end;

Drakan

2008-05-25 21:16:16

slot 1 is buy, slot 2 is sell, slot 3 is buy slot 4 is sell :p its in that order =]

EDIT: Added 2 new functions:
{*******************************************************************************
function OpenAvailableBuySlot: boolean;
By: The[Cheese]
Description: Opens an available buy slot.
*******************************************************************************}
function OpenAvailableBuySlot: boolean;
var
xx, yy: integer;
begin
LoadGEDtm('buydtm');
if(DTMRotated(GeDTM, xx, yy, MSX1, MSY1, MSX2, MSY2))then
begin
Mouse(xx, yy, 5, 5, true);
Result := true;
end else Result := false;
FreeGEDtm;
end;

{*******************************************************************************
function OpenAvailableSellSlot: boolean;
By: The[Cheese]
Description: Opens an available sell slot.
*******************************************************************************}
function OpenAvailableSellSlot: boolean;
var
xx, yy: integer;
begin
LoadGEDtm('selldtm');
if(DTMRotated(GeDTM, xx, yy, MSX1, MSY1, MSX2, MSY2))then
begin
Mouse(xx, yy, 5, 5, true);
Result := true;
end else Result := false;
FreeGEDtm;
end;

These will open the first available buy or sell slot it comes too :D

Dusk412

2008-05-25 21:22:45

Oh okay that makes sense. Nice work. I got another function for you that I'll post as soon as I finish. Just adding some touchups. (It will use your InGE function :D).

Edit: You Will Have To Wait And See LOL! I am almost done anyways.

Drakan

2008-05-25 21:26:37

Ok cool what is it? :p

Dusk412

2008-05-25 22:44:04

Edit: Your LoadGEDtm one needs the var of GEDTM : Integer. Actually so does FreeGeDTM, OpenAvailablyBuySlot, and OpenAvailableSellSlot. And your function OpenSlot doesnt return a value so add Result := True or something somewhere. And OpenGE doesn't use your UpTextArray at all.

Edit: Okay this is weird, your OpenGE won't work for me either. What Brightness did you make this on?

Ok I finished it so here it is. It works perfectly except for that your InGE function kept returning false even though I was in the screen? If that had worked for me this would be good so here it is:


{*******************************************************************************
function CloseGE(Method : String) : Boolean;
By: Dusk412
Description: If GE is up, it closes the screen. Returns true if successful.
Valid Values for Method : String: quick - uses coordinates; slow - uses DTM
*******************************************************************************}
function CloseGE(Method : String) : Boolean;
var
qx, qy, CloseGEDTM : Integer;
begin
if (InGE) then
begin
Wait(1000+random(150));
case Lowercase(Method) of
'quick':
begin
Mouse(485, 42, 4, 4, True)
if (InGE) then
begin
Result := False;
end else
begin
Result := True;
end;
Wait(500+random(150));
end;
'slow':
begin
CloseGEDTM := DTMFromString('78DA63E4616060006124A0A52C0BA619A17C4' +
'67E20C181AA464C5810530D3FAA1A432D2554351C44AA21601700' +
'DAE50257');
if (FindDTM(CloseGEDTM, qx, qy, 465, 25, 505, 60)) then
begin
Wait(500+random(150));
Mouse(qx, qy, 2, 2, True);
Result := True;
end else
begin
Result := False;
end;
FreeDTM(CloseGEDTM);
Wait(500+random(150));
end;
end;
end else
begin
Writeln('GE Screen Not Up');
Result := False;
end;
end;

Drakan

2008-05-25 23:22:12

Oh i forgot I have 2 things of this. One is in a program form and has all that stuff you just said rofl!