Rich
2009-10-10 06:03:28
{*******************************************************************************
function IsUpText(UpText: String): Boolean;
By: Freddy1990, edited by R1ch
Description: Returns up text that might be to the right
*******************************************************************************}
function IsUpText(UpText: string): Boolean;
begin
Result:= IsUpTextMulti([UpText]);
end;
{*******************************************************************************
function IsUpTextMulti(Text: TStringArray): Boolean;
By: Starblaster100 / Nielsie95 / Freddy1990, edited by R1ch
Description: Checks for the occurance of any of the strings in the array.
Use: IsUpTextMulti(['Att', 'ttac', 'ack', 'monst', 'ster'])
*******************************************************************************}
function IsUpTextMulti(Text: TStringArray): Boolean;
var
I : Integer;
begin
for I:= 0 to High(Text) do
begin
Result:= (Pos(Text[I], GetUpText) > 0);
if Result then
Exit;
end;
end;
{*******************************************************************************
function WaitUpTextMulti(S: TStringArray; Time: integer): Boolean;
By: Marpis & N1ke!, edited by R1ch
Description: Waits for a TStringArray of UpText, returns true if found
*******************************************************************************}
function WaitUpTextMulti(S: TStringArray; Time: Integer): Boolean;
var
T: Integer;
begin
Result := false;
T := GetSystemTime + Time;
while (GetSystemTime < T) do
begin
if (IsUpTextMulti(S)) then
begin
Result := True;
Exit;
end;
Wait(20 + Random(20));
end;
end;
{*******************************************************************************
function WaitFunc(Func: Function: Boolean; WaitPerLoop, MaxTime: Integer): Boolean;
By: Rasta Magician, small edit by EvilChicken!, even smaller by R1ch
Description: Waits for function Func to be true. WaitPerLoop is how often you
want to call "Func" function.
Example: "WaitFunc(@BankScreen, 10 + Random(15), 750);" will check if BankScreen
is open every 10-25th millisecond, for a maximum of 750 milliseconds.
Notice the '@'.
*******************************************************************************}
function WaitFunc(Func: Function: Boolean; WaitPerLoop, MaxTime: Integer): Boolean;
var
T: Integer;
begin
T := GetSystemTime + MaxTime;
while (GetSystemTime < T) do
begin
Result:= (Func());
if Result then
Exit;
Wait(WaitPerLoop);
end;
end;
{*******************************************************************************
Function DidClick(Red: Boolean; Time: integer);
By: Rasta Magician, edited by R1ch
Description: Checks for the X after a click, Times Out after Time.
*******************************************************************************}
Function DidClick(Red: Boolean; Time: integer): boolean;
var
TimeOut, X, Y, Trash: integer;
C : TIntegerArray;
begin
GetMousePos(x, y);
SetLength(C, 2);
C:= [255, 65535];
TimeOut := GetSystemTime + Time;
while (GetSystemTime < TimeOut) do
for I:= 0 to 1 do
if FindColor(Trash, Trash, C[I], X - 15, Y - 15, X + 15, Y + 15) then
begin
Result:= ((Red) xor (I = 0)) then
Exit;
end;
end;
{*******************************************************************************
procedure ClickNorth(AngleHigh : boolean);
By: R1ch
Description: Clicks the compass to make it perfect North. Will set angle at
highest or lowest depending on AngleHigh
*******************************************************************************}
procedure ClickNorth(AngleHigh: boolean);
begin
if Random(4) = 1 then
begin
MouseCircle(542, 24, 15, 2);
WaitOptionMulti(['ace', 'orth'], 1200);
end else
MouseCircle(542, 24, 15, 1);
SetAngle(AngleHigh);
end;There was no custom options in IsUptextMultiCustom, so just changed the name to IsUptextMulti. Also shortened it.
Changed IsUptext and WaitUpTextMulti to use IsUptextMulti.
Shortened WaitFunc a little bit.
Shortened DidClick by a lot.
Changed ClickNorth to use MouseCircle.
Comments?