SRL Archive - SRL Suggestions

Extra DTM Functions


Abu

2012-04-13 16:34:10

Well the other function got moved to snippets so here's some of the others I was thinking of :p


MouseDTM
{ MouseDTM
~~~~~~~~~~~

.. code-block:: pascal

function MouseDTM(DTM: Integer; Text: TIntegerArray; var x, y: Integer; xs, ys, xe, ye: Integer): Boolean;

Searches for the DTM within the area xs, ys, xe, ye.
If found, checks the uptext and performs the clicktype

.. note::

by abu_jwka

Example:

.. if MouseDTM(LogsDTM, ['orm', ogs'], x, y, MIX1, MIY1, MIX2, MIY2, True) then
ClickFire;
}

function MouseDTM(DTM: Integer; Text: TStringArray; var x, y: Integer; xs, ys, xe, ye: Integer; WhichClick: Variant): Boolean;
begin
if FindDTM(DTM, x, y, xs, ys, xe, ye) then
begin
GetMousePos(x, y);
if (Length(Text) > 0) then // if searching for uptext
begin
MMouse(x, y, 0, 0);
if WaitUptextMulti(Text, 2000) then
begin
ClickMouse2(WhichClick);
Wait(20 + Random(60));
Result := True;
Exit;
end;
end;
end;
end;


FindDTMMulti
{ FindDTMMulti
~~~~~~~~~~~

.. code-block:: pascal

function FindDTMMulti: TIntegerArray; var x, y: Integer; xs, ys, xe, ye: Integer): Boolean;

Searches for Multiple DTMs within the area xs, ys, xe, ye.
Results true if found, returns the x and y co-ordinates of the first found DTM

.. note::

by abu_jwka

Example:

.. if FindDTMMulti([OakDTM, WillowDTM], x, y, MIX1, MIY1, MIX2, MIY2) then
begin
Writeln('Logs not burned yet! Clicking Tinderbox');
MouseTBox(InvBox(1),1);
end;
}

function FindDTMMulti(DTMs: TIntegerArray; var x, y: Integer; xs, ys, xe, ye: Integer): Boolean;
var
b: Integer;
begin
for b := 0 to High(DTMs) do
begin
if (FindDTM(DTMs[b], x, y, xs, ys, xe, ye)) then
begin
GetMousePos(x, y);
Result := True;
Exit;
end;
end;
end;


WaitFindDTMMulti
{ WaitFindDTMMulti
~~~~~~~~~~~

.. code-block:: pascal

function WaitFindDTMMulti: TIntegerArray; var x, y: Integer; xs, ys, xe, ye, WaitPerLoop, Maxtime: Integer): Boolean;

Searches for Multiple DTMs within the area xs, ys, xe, ye every WaitPerLoop seconds
for a maximum time defined by MaxTime
Results true if found and returns the x and y co-ordinates of the first found DTM

.. note::

by abu_jwka

Example:

.. if WaitFindDTMMulti([Oak, Willow], x, y, MIX1, MIY1, MIX2, MIY2, 5000) then
begin
Writeln('Logs not burned yet! Clicking Tinderbox');
MouseTBox(InvBox(1),1);
end;
}

function WaitFindDTMMulti(DTMs: TIntegerArray; var x, y: Integer; xs, ys, xe, ye, WaitPerLoop, Maxtime: Integer): Boolean;
var
t: Integer;
begin
t := GetSystemTime + Maxtime;
while (GetSystemTime < t) do
begin
if FindMultiDTM(DTMs, x, y, xs, ys, xe, ye) then
begin
GetMousePos(x, y);
Result := True;
Exit;
end;
Wait(WaitPerLoop);
end;
end;

FindDTMsRotated
(*
FindDTMsRotated
~~~~~~~~~~~

.. code-block:: pascal

function FindDTMsRotated(DTMs: TIntegerArray; var x, y: Integer;xs, ys, xe, ye: Integer;
sAngle, eAngle, aStep: Extended;
var aFound: Extended): Boolean;

Finds Multiple DTMs within the area xs, ys, xe, ye
Starts searching from the angle 'sAngle'
Stops searching once it reaches the angle 'eAngle'
It will rotate every 'aStep' angle from sAngle to eAngle
Results True if found and returns the x and y co-ordinates


.. note::

Author: abu_jwka

Example:

.. code-block:: pascal

if FindDTMsRotated([BankerDTM,CounterDTM], x, y, MSX1, MSX2, MSY1, MSY2, -Pi/4, Pi/4, Pi/60, aFound) then
begin
Mouse(x, y, 0, 0, False);
WaitOption('ank', 200);
end;
*)
function FindDTMMultiRotated(DTMs: TIntegerArray; var x, y: Integer;xs, ys, xe, ye: Integer;
sAngle, eAngle, aStep: Extended;
var aFound: Extended): Boolean;
var
i: Integer;
begin
for i := 0 to High(DTMs) do
if FindDTMRotated(DTMs[i], x, y, xs, ys, xe, ye, sAngle, eAngle, aStep, aFound) then
begin
GetMousePos(x, y);
Result := True;
end;
end;

Mat

2012-04-13 16:35:44

I could Use WaitFindDTMMulti :) Thanks<3

Abu

2012-04-13 16:37:20

From: Mat
I could Use WaitFindDTMMulti :) Thanks<3


It's actually WaitFindMultiDTM, just saying…:p

xtrapsp

2012-04-13 16:50:45

Think it's possible to compare DTM's? For example, Compare a DTM of the health of your char to a green one which is you poisoned and if poisoned find item in inv?


Procedure Poisoncheck;
var
x, y, i: Integer;

begin
Writeln('Checking for poison');
for i:=8 downto 1 do
if (Pos('You have been', GetChatBoxText(i, 255)) <> 0) then
begin
if FindObjEx(x, y, ['Anti', 'pois'], [1951850, 1749598, 1279303, 1211971, 2018925, 1885801], 5, 50, MIX1, MIY1, MIX2, MIY2) then
begin
Writeln('Clicking AntiPoison potion');
Mouse(x, y, 0, 0, True);
Wait(1500+Random(500))
Exit;
end;
end;
end;

This won't work… So I'm wondering if your expertise in DTM's could work :P

Abu

2012-04-13 16:57:15

From: xtrapsp
Think it's possible to compare DTM's? For example, Compare a DTM of the health of your char to a green one which is you poisoned and if poisoned find item in inv?

BLA BLA BLA

This won't work… So I'm wondering if your expertise in DTM's could work :P



Lol I'm no expert, I'm just good at playing around with functions :p


I don't think it's impossible but in the case that you mentioned, I'm sure you don't need to compare anything. You could just say
while IAmFighting do // while fighting
if FindDTM(PoisonHealth, x, y, MSX1, MSY1, MSX2, MSY2) then //if it finds you've been poisoned
MouseDTM(AntiPoisonDTM, ['nti', 'oison'], x, y, MIX1, MIY1, MIX2, MIY2); // clicks the anti poison

xtrapsp

2012-04-13 17:11:32

From: abu_jwka
Lol I'm no expert, I'm just good at playing around with functions :p


I don't think it's impossible but in the case that you mentioned, I'm sure you don't need to compare anything. You could just say
while IAmFighting do // while fighting
if FindDTM(PoisonHealth, x, y, MSX1, MSY1, MSX2, MSY2) then //if it finds you've been poisoned
MouseDTM(AntiPoisonDTM, ['nti', 'oison'], x, y, MIX1, MIY1, MIX2, MIY2); // clicks the anti poison


Ended up making my own one similar :P Thanks anyway.

just thought if you made a DTM compare you could have it added to Simba :P

Abu

2012-04-14 10:29:55

From: xtrapsp

just thought if you made a DTM compare you could have it added to Simba :P


Now that I think of it, no two DTMs are ever exactly the same - unless they've been copied and and pasted so there would no point.

Oxygen

2012-04-14 11:01:36

This stuff is crazy! You are great with DTMs, but how does FindMultiDTM work? Can't it only look for 1 DTM at a time?

Abu

2012-04-14 11:05:27

From: Oxygen
This stuff is crazy! You are great with DTMs, but how does FindMultiDTM work? Can't it only look for 1 DTM at a time?


Looks for the first DTM, if it can't find it looks for the second DTM, if it can't find that then it looks for the third DTM etc… it will return the x and y co-ordinates of the first one it finds.

Saves you having to write numerous lines of code :)

Joe

2012-04-14 12:05:57

From: abu_jwka
Looks for the first DTM, if it can't find it looks for the second DTM, if it can't find that then it looks for the third DTM etc… it will return the x and y co-ordinates of the first one it finds.

Saves you having to write numerous lines of code :)


Numerous lines make you look sofisticated :garfield:

RightClick

2012-04-14 12:07:59

Sound good :norris:

Abu

2012-04-14 13:03:43

From: JOEbot
Numerous lines make you look sofisticated :garfield:


No it doesn't, not when when you are repeating the same lines over and over again - that looks fugly

masterBB

2012-04-14 13:35:03

Is this for MMLCore or for srl?

edit:
Also FindMultiDTM sounds odd.

FindDTMs (like in FindColor and FindColors)
FindDTMMulti

maybe also add FindDTMsRotated.

Abu

2012-04-14 13:47:15

From: masterBB
Is this for MMLCore or for srl?

edit:
Also FindMultiDTM sounds odd.

FindDTMs (like in FindColor and FindColors)
FindDTMMulti

maybe also add FindDTMsRotated.


Well I don't know what MMLCore is…

Also, FindDTMs already exists, but it returns TPA's. So I guess I'll change it to FindDTMMulti?

And I'll add that other one in a bit ;)

Gucci

2012-04-14 13:53:09

Nice work Abu, could definitely use these functions:garfield:

Joe

2012-04-14 14:01:39

From: abu_jwka
No it doesn't, not when when you are repeating the same lines over and over again - that looks fugly


Oh, repetition- yeah thats ugly. But I mean in depth procedures as opposed to short to the point ones.

Joe

2012-04-14 14:02:41

From: abu_jwka
No it doesn't, not when when you are repeating the same lines over and over again - that looks fugly


Oh, repetition- yeah thats ugly. But I mean in depth procedures as opposed to short to the point ones.

EDIT: Why did it post 2x?

Abu

2012-04-14 14:19:01

From: JOEbot


EDIT: Why did it post 2x?


Because you double-clicked Submit Reply

Joe

2012-04-14 14:21:59

From: abu_jwka
Because you double-clicked Submit Reply


maybe its a sign from simba that I have been chosen
:drool:

Total

2012-04-14 14:27:38

I'm liking these functions. Could use these to update my agility script.

Abu

2012-04-14 14:43:47

From: TotalKillz
I'm liking these functions. Could use these to update my agility script.


Thanks :)

Also, added FindDTMsRotated, works the same as FindDTMRotated except for it searches for multiple DTMs