arclight
2014-11-03 22:42:46
Okay, so, for my Kyatt Summoning Script, I was wondering if there is a better way than what I currently do to find the banker. Here is the code for that method:
Basically it finds TPAs for the banker, makes ATPAs out of it, moves mouse to location, find TPAs again and compares it to original if the mouse over text starts with bank, and proceeds based off that knowledge. The compare step just sees if the TPAs are 50% different at least. Is there a better way to solve this problem? I would assume people would have heavily explored it already.
sidenote: I should probably use break rather than invalidating the for loop index, but I didn't remember if that was a feature of LAPE or not.
function findBankerAndClick(button : integer = mouse_Left) : boolean;
var
x, y, index, tries: integer;
TPA, copyTPA, checkTPA : TPointArray;
ATPA : T2DPointArray;
begin
for tries := 0 to 6 do
begin
findColorsSpiralTolerance(x, y, TPA, 2268349, mainScreen.getBounds, 8, colorSetting(2, 0.22, 2.24));
ATPA := TPA.toATPA(10,10);
ATPA.sortFromMidPoint(mainscreen.playerPoint);
//can't see banker, try to click minimap
if(length(ATPA) = 0) then
begin
minimap.clickCompass;
findColorsSpiralTolerance(x, y, TPA, 2268349, mainScreen.getBounds, 8, colorSetting(2, 0.22, 2.24));
ATPA := TPA.toATPA(10,10);
ATPA.sortFromMidPoint(mainscreen.playerPoint);
end;
if(length(ATPA) = 0) then
exit(false);
for(index := 0) to (high(ATPA)) do
begin
mouse(MiddleTPA(ATPA[index]), MOUSE_MOVE);
findColorsSpiralTolerance(x, y, checkTPA, 2268349, mainScreen.getBounds, 8, colorSetting(2, 0.22, 2.24));
copyTPA := TPA;
//checking if he moved
if((length(copyTPA.clearTPAFrom(checkTPA)) > (0.5 * length(TPA)))) then
begin
//probably moved, going to have to be careful
if(button = mouse_Right) then
begin
fastClick(button);
wait(gaussRangeInt(250, 500));
if(chooseOption.optionsExist(['Bank '])) then
exit(true);
end else
begin
//technically could click someone's familar or something for a false
//positive, but at least we probably see the banker, I think
if(didClick(true)) then
exit(true);
end;
index := high(ATPA);
wait(gaussRangeInt(250, 500));
end else if(isMouseOverText(['Bank '], 250)) then
begin
fastClick(button);
exit(true);
end;
end;
end;
writeln('totally failed at getting that banker');
exit(false);
end; Basically it finds TPAs for the banker, makes ATPAs out of it, moves mouse to location, find TPAs again and compares it to original if the mouse over text starts with bank, and proceeds based off that knowledge. The compare step just sees if the TPAs are 50% different at least. Is there a better way to solve this problem? I would assume people would have heavily explored it already.
sidenote: I should probably use break rather than invalidating the for loop index, but I didn't remember if that was a feature of LAPE or not.