riwu
2012-10-27 10:33:36
I've just made this base for an Oak Dungeon Door script that i'm currently working on. This is a generic function that some might find useful so i'm posting it here. Just made it though and haven't tested so might have some errors. The reason why the function don't return the point in which the object is at (like what most obj finding function does) is because your mouse is already at the obj when the result is true! So just start clicking!
Suggestions are appreciated.
And btw i reused some variables (eg. i, ATPA), this shouldn't affect functionality but is it good practice?
type
ObjRecord = record
Color, Tol: TIntegerArray;
HMod,SMod: TExtendedArray;
UpText: TStringArray;
MinL, Split: Integer;
end;
function FObj(Obj: ObjRecord): Boolean;
var
ATPA: T2DPointArray;
i, l, x, y: Integer;
playerTPA, TPA: TPointArray;
begin
ColorToleranceSpeed(2);
l:= High(Obj.Color);
SetLength(ATPA, l + 1);
for i:=0 to l do
begin
SetColorSpeed2Modifiers(Obj.HMod[i], Obj.SMod[i]);
FindColorsTolerance(ATPA[i], Obj.Color[i], MSX1, MSY1, MSX2, MSY2, Obj.Tol[i]);
end;
ColorToleranceSpeed(1);
MergeATPAWrap(ATPA, TPA);
TPAFromBoxWrap(IntToBox(247, 156, 271, 186), playerTPA);
ClearTPAFromTPAWrap(TPA, playerTPA, TPA);
if Length(TPA) < Obj.MinL then
Exit;
SplitTPAWrap(TPA, Obj.Split, ATPA);
SortATPAFromMidPoint(ATPA, Point(MSCX, MSCY));
for i:=0 to High(ATPA) do
if Length(ATPA[i]) > Obj.MinL then
begin
MiddleTPAEx(ATPA[i], x, y);
MMouse(x, y, 2, 2);
if WaitUpTextMulti(Obj.UpText, 618) then
begin
// if DEBUG_MODE then
writeln('Found Obj: ' + ToStr(Obj));
Result:= True;
Exit;
end;
end;
end; Suggestions are appreciated.
And btw i reused some variables (eg. i, ATPA), this shouldn't affect functionality but is it good practice?

