PDA

View Full Version : OpenGE



P1ng
08-29-2012, 12:32 AM
TPA function for opening the grand exchange.
Input the string for whatever option you'd like to choose in the GE

Examples are:
- Talk-to
- Exchange
- History
- Sets

function OpenGE(Option: String): Boolean;
var
Options: TStringArray;
Colors, NPCArray :TPointArray;
ATPA: T2DPointArray;
MSNPC, NPCPoint :TPoint;
CTS, ii, i :Integer;
NPCBox: TBox;
begin
//
case Lowercase(Option) of
'talk': Options := ['to G', 'alk', 'k-to'];
'exchange': Options := ['ge G'];
'history': Options := ['istory', 'ry G'];
'sets': Options := ['ets', 'ts G'];
else
begin
Writeln('Please choose a valid option!');
Exit;
end;
end;
//
SetAngle(SRL_ANGLE_LOW);
NPCArray := GetMinimapDots('NPC');

if Length(NPCArray) < 1 then
Exit;

SortTPAFrom(NPCArray, Point(MMCX, MMCY));

for i := 0 to High(NPCArray) do
begin
NPCPoint := MMToMS(NPCArray[i])
if NPCPoint = Point(-1, -1) then
Continue;

CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.63, 0.11);

NPCBox := IntToBox(Max(NPCPoint.X - 40, MSX1), Max(NPCPoint.Y - 40, MSY1), Min(NPCPoint.X + 40, MSX2), Min(NPCPoint.Y + 40, MSY2));

if FindColorsSpiralTolerance(NPCPoint.x, NPCPoint.y, Colors, 2891041, NPCBox.x1, NPCBox.y1, NPCBox.x2, NPCBox.y2, 5) then
begin
SetColorSpeed2Modifiers(0.2, 0.2);
ColorToleranceSpeed(CTS);

ATPA := TPAToATPAEx(Colors, 15, 20);
SortATPASize(ATPA, True);

for ii := 0 to High(ATPA) do
begin
MSNPC := MiddleTPA(ATPA[ii]);
MMouse(MSNPC.X, MSNPC.Y, 3, 3);

if WaitUpTextMulti(['rand', 'xcha', 'change'], 200) then
begin
ClickMouse2(mouse_Right);
Result := WaitOptionMulti(Options, 600);
if Result then
Exit;
end;
end;
end;
end;
end;
Edited with Runaway's addition :)

Runaway
08-29-2012, 12:52 AM
Good job with this :) Looks very clean and efficient. Perhaps you could use a case for the options though?


function OpenGE(Option: String): Boolean;
var
Options: TStringArray;
Colors, NPCArray :TPointArray;
ATPA: T2DPointArray;
MSNPC, NPCPoint :TPoint;
CTS, ii, i :Integer;
NPCBox: TBox;
begin
//
case Lowercase(Option) of
'talk': Options := ['to G', 'alk', 'k-to'];
'exchange': Options := ['ge G'];
'history': Options := ['istory', 'ry G'];
'sets': Options := ['ets', 'ts G'];
else
begin
Writeln('Please choose a valid option!');
Exit;
end;
end;
//
SetAngle(SRL_ANGLE_LOW);
NPCArray := GetMinimapDots('NPC');

if Length(NPCArray) < 1 then
Exit;

SortTPAFrom(NPCArray, Point(MMCX, MMCY));

for i := 0 to High(NPCArray) do
begin
NPCPoint := MMToMS(NPCArray[i])
if NPCPoint = Point(-1, -1) then
Continue;

CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.63, 0.11);

NPCBox := IntToBox(Max(NPCPoint.X - 40, MSX1), Max(NPCPoint.Y - 40, MSY1), Min(NPCPoint.X + 40, MSX2), Min(NPCPoint.Y + 40, MSY2));

if FindColorsSpiralTolerance(NPCPoint.x, NPCPoint.y, Colors, 2891041, NPCBox.x1, NPCBox.y1, NPCBox.x2, NPCBox.y2, 5) then
begin
SetColorSpeed2Modifiers(0.2, 0.2);
ColorToleranceSpeed(CTS);

ATPA := TPAToATPAEx(Colors, 15, 20);
SortATPASize(ATPA, True);

for ii := 0 to High(ATPA) do
begin
MSNPC := MiddleTPA(ATPA[ii]);
MMouse(MSNPC.X, MSNPC.Y, 3, 3);

if WaitUpTextMulti(['rand', 'xcha', 'change'], 200) then
begin
ClickMouse2(mouse_Right);
Result := WaitOptionMulti(Options, 600);
if Result then
Exit;
end;
end;
end;
end;
end;


Something along those lines.

P1ng
08-29-2012, 02:23 AM
Like Runaway's edition so much I added it to the OP :)

Makes the function that little bit more user-friendly and doesn't rely on their ability to pick good text ;)

Abu
08-29-2012, 01:34 PM
Definitely useful in my eyes.

Will use in future scripts :)

litoris
08-29-2012, 01:57 PM
Get this moved to suggestions? It'd be useful.

Solar
08-29-2012, 03:06 PM
This looks quite useful.
I have a question though, if someone was to use this in a script which they then use to apply for SRL membership, even if credit was given to P1ng, would the script be refused?
I'm not close to being able to submit a decent enough script for membership yet, I'm just curious. Thanks.

Footy
08-29-2012, 03:09 PM
They wont refuse you because of parts not made by you, they will simply ignore it, and pretend its not there. Dont use too many functions made by other people though!

P1ng
08-29-2012, 03:40 PM
You may certainly use this in any scripts you write, crediting me would be nice :) But, I put it up here for others to use.

If you use this in an SRL member's application you would definitely need to credit me and I advise you don't use too many other people's functions.

If you are applying for members we generally expect you have the ability to make something similar to this function, on your own.

E: If people think there would be a genuine demand/use for this in the include then I will PM a mod and see if I can get it moved to suggestions :)

Footy
08-29-2012, 09:09 PM
Well if there is nothing like this in the include, and it works perfectly, it could definetly be added to the include! Im still wondering what type of script would need to use the GE though...

Roflme
08-31-2012, 11:59 PM
Well if there is nothing like this in the include, and it works perfectly, it could definetly be added to the include! Im still wondering what type of script would need to use the GE though...
A script that would require purchasing more supplies to run indefinitely? :p

At least that's what I'm going to try to use this for. Thank you for this function!