Rich
2012-05-15 10:17:41
(*
SearchBankEx
~~~~~~~~~~~~~~~~~~~~
.. code-block:: pascal
function SearchBankEx(var X, Y : Integer; Item : string; TextOrDTM : Integer) : Boolean;
Searches for bank for Item. If Item is exact name, set UseDTM false and set DTM
as 0, else set it true and DTM is the name of your DTM. If not UseDTM, will
return true on item existing in bank slot 1, else will return true on DTM being
found. X, Y will be where it's found.
.. note::
Author: Rich
Last Modified: 15/05/12
Example:
.. code-block:: pascal
if SearchBankEx(X, Y, 'Willow Logs', False, 0) then
Mouse(X, Y, 5, 5, True);
if SearchBank(X, Y, 'Willow', True, WillowLogsDTM) then
Mouse(X, Y, 5, 5, True);
*)
function SearchBankEx(var X, Y : Integer; Item : string; UseDTM : Boolean; DTM : Integer) : Boolean;
var
T, II: Integer;
begin
if (not(BankScreen)) then Exit;
for II := 0 to 2 do
begin
FixBankTab;
Mouse(75, 300, 20, 10, mouse_left);
T:= GetSystemTime;
while ((BankScreen) and (GetSystemTime - T < 6000)) do
begin
Wait(500 + Random(500));
if (FindTextTPA(0, 0, 350, 392, 399, 410, 'search', UpCharsEx, Nothing)) then
TypeSend(Item);
end;
Wait(500 + Random(500));
end;
if UseDTM then
Result:= FindDTM(DTM, X, Y, MSX1, MSY1, MSX2, MSY2)
else
Result:= FindColor(X, Y, 131072, 32, 94, 74, 126);
end;
(*
SearchBank
~~~~~~~~~~
.. code-block:: pascal
function SearchBank(Item : string) : Boolean;
Searches for Item in your bank. Relies on item existing in bank slot 1.
.. note::
Author: Rich
Last Modified: 15/05/12
Example:
.. code-block:: pascal
if SearchBank('Willow Logs') then
Mouse(X, Y, 5, 5, mouse_Left);
*)
function SearchBank(Item : string) : Boolean;
var
X, Y : Integer;
begin
Result:= SearchBankEx(X, Y, Item, False, 0);
end;
(*
SearchBankDTM
~~~~~~~~~~
.. code-block:: pascal
function SearchBankDTM(Item : string; DTM : Integer) : Boolean;
Searches for Item in your bank using. Results true if DTM is found.
.. note::
Author: Rich
Last Modified: 15/05/12
Example:
.. code-block:: pascal
if SearchBankDTM('Willow', WillowLogsDTM) then
Mouse(X, Y, 5, 5, mouse_Left);
*)
function SearchBankDTM(Item : string; DTM : Integer) : Boolean;
var
X, Y : Integer;
begin
Result:= SearchBankEx(X, Y, Item, True, DTM);
end;(*
MissMouseEx
~~~~~~~~~
.. code-block:: pascal
procedure MissMouseEx(eX, eY, rX, rY : Integer; Action : Variant);
Human-like miss-and-correct mouse movement/clicking.
.. note::
Author: Rich
Last Modified: 15/05/12
Example:
.. code-block:: pascal
MissMouseEx(500, 500, 10, 10, mouse_Left);
*)
procedure MissMouseEx(eX, eY, rX, rY : Integer; Action : Variant);
var
RandSpeed: Extended;
X, Y, A, Dist, MP: Integer;
begin
A:= MouseSpeed;
GetMousePos(X, Y);
Dist:= Distance(X, Y, eX, eY);
MP:= Round(Dist/150);
if (MP < 0) then
MP:= 1;
RandSpeed := ((Random(MouseSpeed) / 2.0 + MouseSpeed) / 10.0);
MMouse(RandomRange(eX-(A*MP), eX+(A*MP)), RandomRange(eY-(A*MP), eY+(A*MP)), 0, 0);
Mouse(eX, eY, rX, rY, Action);
end;
(*
MissMouse
~~~~~~~~~
.. code-block:: pascal
procedure MissMouse(eX, eY);
Human-like miss-and-correct mouse movement.
.. note::
Author: Rich
Last Modified: 15/05/12
Example:
.. code-block:: pascal
MissMouse(500, 500);
*)
procedure MissMouse(eX, eY : Integer);
begin
MissMouseEx(eX, eY, 0, 0, mouse_Move);
end;Made a function with options on which condition to return true and named it SearchBankEx. Also added SearchBankDTM which will result true on a DTM being found after searching. It seemed illogical for SearchBank to be just a procedure, so is now a function. However it was still work the same and not break any scripts due to no parameter changes.
MissMouse would only move the mouse and have no randomness on the final position, which also seemed illogical. Therefore made MissMouseEx which can click and also has randomness on final stopping point. MissMouse will also still work the same and not break any scripts.