Log in

View Full Version : DTM help



Deadly Serious
01-17-2012, 09:38 AM
Edit: Can anyone answer this?
Does anyone know how to stop a DTM from searching after it's already clicked the DTM?



I'm making another dtm for port sarim, fishing shops' door. For my harpoon buying script but I'm having a lot of trouble making it.
Every time I set the color tolerance between 1 and 9 it is unable to find the door but if I set it to 10 it clicks on the door and then the mouse starts to randomly hover all over my the screen going for the same color.
This is confusing me a lot, since I've made a DTM for this door that worked perfectly but it broke today.
The angle is fine and I have selected the runescape client/ smart. I've tried everything I can think of.
No TPAs, bitmaps, findcustom, etc work in this room for that door.

KingKong
01-17-2012, 10:58 AM
Don't use dtms for mainscreen object detection, use tpa's/atpa's(if they don't work give us a screenshot and the rest of us here can help) they're far more accurate. As for your mouse moving randomly, you probably didn't tell it stop searching for the dtm after you clicked it.

Deadly Serious
01-17-2012, 08:33 PM
Don't use dtms for mainscreen object detection, use tpa's/atpa's(if they don't work give us a screenshot and the rest of us here can help) they're far more accurate. As for your mouse moving randomly, you probably didn't tell it stop searching for the dtm after you clicked it.

TPAs don't work in there, there are things with the same color tolerance and height in there. How do I stop the DTM from searching after you click it?

NexPB
01-17-2012, 09:58 PM
TPAs don't work in there, there are things with the same color tolerance and height in there. How do I stop the DTM from searching after you click it?
Im sure tpas do work in there, why shouldn't it?

anyways u can use this:

if DTMRotated(DTM, x, y, MMX1, MMY1, MMX2, MMY2) then
begin
Mouse(x, y, 5, 5, true);
end;

Deadly Serious
01-17-2012, 10:08 PM
Im sure tpas do work in there, why shouldn't it?

anyways u can use this:

if DTMRotated(DTM, x, y, MMX1, MMY1, MMX2, MMY2) then
begin
Mouse(x, y, 5, 5, true);
end;


It auto corrects runescapes' random small rotation every trip.
TPAs don't work there because there's 2 boxes that stack up which are nearly the same height/ width, which are exactly the same color on spots if you get the color picker and check.
Edit: I fixed it, I put 10 tolerance for the main point and then I put 5 tolerance for the subpoints and it seemed to work.
Edit: Spoke to soon, does the hovering shit again :S

bg5
01-17-2012, 10:13 PM
Post screenshot here ,maybe someone will be able to help you with finding function.

Deadly Serious
01-17-2012, 10:24 PM
http://i42.tinypic.com/34t30hc.png

NexPB
01-17-2012, 10:25 PM
It auto corrects runescapes' random small rotation every trip.
TPAs don't work there because there's 2 boxes that stack up which are nearly the same height/ width, which are exactly the same color on spots if you get the color picker and check.
Edit: I fixed it, I put 10 tolerance for the main point and then I put 5 tolerance for the subpoints and it seemed to work.
Edit: Spoke to soon, does the hovering shit again :S

Here is my object clicking and finding method maybe you can use it if u credit me


function ClickObject(col, col2, tol: integer; uptext, action: String; LeftClick: boolean): boolean;
var
i, x, y, cts: Integer;
tpa: TPointArray;
atpa: T2DPointArray;
pt: TPoint;
begin
cts := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
FindColorsTolerance(tpa, col, MSX1, MSY1, MSX2, MSY2, tol);
if Length(tpa) = 0 then FindColorsTolerance(tpa, col2, MSX1, MSY1, MSX2, MSY2, tol);
ColorToleranceSpeed(cts);
atpa := TPAtoATPA(tpa, High(tpa));
SortATPAFrom(atpa, Point(MSCX, MSCY));
for i := 0 to High(atpa) do
begin
pt := MiddleTPA(atpa[i]);
MMouse(pt.x, pt.y, 4, 4);
wait(300 + random(250));
if (IsUpText(uptext)) then
begin
writeln('Found object.');
GetMousePos(x, y);
if (not(LeftClick)) then
begin
Mouse(x, y, 0, 0, False);
wait(500 + random(150));
ChooseOption(action);
if (DidRedClick) then
wait(1250 + random(500));
result := true;
Exit;
end else
if (LeftClick) then
begin
Mouse(x, y, 0, 0, true);
if (DidRedClick) then
wait(750 + random(350));
result := true;
Exit;
end;
end;
end;
end;

Sabzi
01-17-2012, 10:29 PM
doorprofiles.simba

Very neat stuff.
I don't think it will work though, colors changed at minimum, but other things may be broken too. Either try to fix it yourself, file a bug at the tracker or just use it as an idea.
Yeah, if it works it should solve your problems if I get correctly what problems you got :p.

It's in srl's misc folder btw.
There are plenty very very useful, yet quiet forgotten functions.

wantonman
01-17-2012, 10:30 PM
you CLEARLY have A GIANT WHITE line to work with the top to the wall to the door

Deadly Serious
01-17-2012, 10:38 PM
Here is my object clicking and finding method maybe you can use it if u credit me


function ClickObject(col, col2, tol: integer; uptext, action: String; LeftClick: boolean): boolean;
var
i, x, y, cts: Integer;
tpa: TPointArray;
atpa: T2DPointArray;
pt: TPoint;
begin
cts := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
FindColorsTolerance(tpa, col, MSX1, MSY1, MSX2, MSY2, tol);
if Length(tpa) = 0 then FindColorsTolerance(tpa, col2, MSX1, MSY1, MSX2, MSY2, tol);
ColorToleranceSpeed(cts);
atpa := TPAtoATPA(tpa, High(tpa));
SortATPAFrom(atpa, Point(MSCX, MSCY));
for i := 0 to High(atpa) do
begin
pt := MiddleTPA(atpa[i]);
MMouse(pt.x, pt.y, 4, 4);
wait(300 + random(250));
if (IsUpText(uptext)) then
begin
writeln('Found object.');
GetMousePos(x, y);
if (not(LeftClick)) then
begin
Mouse(x, y, 0, 0, False);
wait(500 + random(150));
ChooseOption(action);
if (DidRedClick) then
wait(1250 + random(500));
result := true;
Exit;
end else
if (LeftClick) then
begin
Mouse(x, y, 0, 0, true);
if (DidRedClick) then
wait(750 + random(350));
result := true;
Exit;
end;
end;
end;
end;


I'll try it and I'll credit you if it works.


doorprofiles.simba

Very neat stuff.
I don't think it will work though, colors changed at minimum, but other things may be broken too. Either try to fix it yourself, file a bug at the tracker or just use it as an idea.
Yeah, if it works it should solve your problems if I get correctly what problems you got :p.

It's in srl's misc folder btw.
There are plenty very very useful, yet quiet forgotten functions.

Looks interesting, I'll try it soon.


you CLEARLY have A GIANT WHITE line to work with the top to the wall to the door

If I used that line it'll just start hovering all over the room, since it's all the same color.

Kasi
01-17-2012, 10:45 PM
I'd Make the compass to north, find the red line on the Minimap, Use MMToMS then Do a spiral TPA search?

KingKong
01-17-2012, 11:10 PM
TPAs don't work in there, there are things with the same color tolerance and height in there.

Tried using more than one color from the door?

Deadly Serious
01-17-2012, 11:48 PM
I'd Make the compass to north, find the red line on the Minimap, Use MMToMS then Do a spiral TPA search?

Hm, I might need to do a little bit more research before I could pull that off :P



Tried using more than one color from the door?

Yes, I've used multiple colors, receiving the same outcome.

KingKong
01-18-2012, 01:27 AM
Hm, I might need to do a little bit more research before I could pull that off :P




Yes, I've used multiple colors, receiving the same outcome.

I meant use, more than one color at the same time to find the door. That shouldn't fail. Also you should sort your ATPA properly, nothing is impossible, just very hard.

bg5
01-18-2012, 01:57 AM
I'm working on it. On your screenshot i reduced objects to 3..

http://puu.sh/dKfH
However testing in game is much harder ,I've got here 10-20 separated objects.

http://puu.sh/dKGRhttp://puu.sh/dKJi

I have now simple idea how to do it. I think my function is a bit overpowered for this search (I tangled 3 colors to find objects):redface: So:

simple make door color TPA (FindColorstolerance) ,but search inside box appointed by walls of building (FindColorstolerance and GetTpaBounds)
make ATPA (TPAtoATPAEx)
now sort subTPAs by higher y position of their middle point (MiddleTPA) --> higher y position means that object is more on south
As long as compas is faced north mouse will find doors at first try (ATPA[0] = doors) :)


Only thing I'm afraid is color changing.

Deadly Serious
01-18-2012, 04:16 AM
I'm working on it. On your screenshot i reduced objects to 3..

http://puu.sh/dKfH
However testing in game is much harder ,I've got here 10-20 separated objects.

http://puu.sh/dKGRhttp://puu.sh/dKJi

I have now simple idea how to do it. I think my function is a bit overpowered for this search (I tangled 3 colors to find objects):redface: So:

simple make door color TPA (FindColorstolerance) ,but search inside box appointed by walls of building (FindColorstolerance and GetTpaBounds)
make ATPA (TPAtoATPAEx)
now sort subTPAs by higher y position of their middle point (MiddleTPA) --> higher y position means that object is more on south
As long as compas is faced north mouse will find doors at first try (ATPA[0] = doors) :)


Only thing I'm afraid is color changing.

Thanks for all that, mate. You've obviously put a lot of effort into that and I'll try to implement it into my script when I get a chance.

bg5
01-18-2012, 05:15 AM
I'm doing this for myself. I just started exploring ATPA and it was challenge.And I like hard challenges :) It gave me opportunity to learn a lot about ATPA stuff.

Done:
http://puu.sh/dLEl

I will post the code when I clean it up. However I suggest you to make your own function ,it's great way to learn something.

Have fun:)
program PortSarimDoorOpener; // by beginner5

{ Opening doors to Port Sarim fishing shop. Edge of doors must be visible }
{$DEFINE SRL5}
{$DEFINE SMART}
{$i srl/srl.simba}

var
tries: integer;
opened : boolean;
procedure start;
begin
ClearDebug;
Smart_Server := 139;
Smart_Members := True;
Smart_Signed := True;
Smart_SuperDetail := False;
activateclient;
SetupSRL;

end;

//Returns random point in box -- by beginner5
function RandomPointInBox (box :Tbox):Tpoint;
begin
Result.x:=box.x1+random(box.x2-box.x1);
Result.y:=box.y1+random(box.y2-box.y1);
end;

// Sorting ATPA by x or y position of SubTPA's middle points. -- by beginner5
procedure SortATPAbyMidTPA(var ATPA: T2DPointArray; SortByX , SortUp : boolean);
var a,hi ,x,y:integer;
SortArr :Tintegerarray;
begin
hi := High(ATPA);
setlength(SortArr,hi+1);
if (SortByX) then
begin
for a:= 0 to hi do
begin
MiddleTPAEx(ATPA[a],x,y);
SortArr[a]:=x;
end;
end else begin
for a:= 0 to hi do
begin
MiddleTPAEx(ATPA[a],x,y);
SortArr[a]:=y;
end;
end;
QuickATPASort(SortArr,ATPA,0,hi,SortUp);
end;

// Result is TPA of that points from tpa1 ,which has in neighborhood any point from tpa2. -- by beginner5
function AND_TPA (tpa1 , tpa2 :TpointArray ; MinDist ,MaxDist : extended) : TPointArray;
var
a : integer;
temp_tpa1 :tPointarray;
begin
Setlength(Result,0);
for a:=0 to High(tpa2) do
begin
temp_tpa1 := tpa1; // Don't want FilterPointsDist overwrite tpa1
FilterPointsDist(temp_tpa1,MinDist,MaxDist,tpa2[a].x,tpa2[a].y);
CombineTPAWrap(Result,temp_tpa1,Result);
end;
// Need here function which remove duplicated points from tpa.
end;

function FindDoor : T2dPointArray;
var
WallColor , DoorEdgeColor ,AdditionalDoorColor ,AdditionalDoorColor2 : integer;
TPA1 ,TPA2 ,TPA3 ,TPA4 : TPointArray;
houseBox :TBox;
begin
/////////////SETUP/////////////
WallColor := 13955062;
DoorEdgeColor := 3627875 ;
AdditionalDoorColor := 3361102 ;
AdditionalDoorColor2 := 604482 ;
///////////////////////////////

if FindColorstolerance(TPA4,WallColor,msx1,msy1,msx2, msy2,15) then
houseBox :=GetTpaBounds(TPA4) else writeln('Cannot find wall - update color!');

FindColorstolerance(TPA1,DoorEdgeColor ,houseBox.x1,houseBox.y1,houseBox.x2+10,houseBox.y 2+10,10);
FindColorstolerance(TPA2,AdditionalDoorColor ,houseBox.x1,houseBox.y1,houseBox.x2+10,houseBox.y 2+10,10);
FindColorstolerance(TPA3,AdditionalDoorColor2 ,houseBox.x1,houseBox.y1,houseBox.x2+10,houseBox.y 2+10,15);

RAaSTPAEx(TPA1,10,10);
RAaSTPAEx(TPA2,10,10);
RAaSTPAEx(TPA3,10,10);

TPA1:=AND_TPA(TPA1,TPA2,0,15);
TPA1:=AND_TPA(TPA1,TPA3,0,15);
TPAtoATPAExWrap(TPA1,50,2,Result);
if (High(Result)=-1) then
begin
writeln('ATPA is empty! Something with colors');
terminatescript;
end;
SortATPAbyMidTPA(Result,False,False);
end;

function OpenDoor (ATPA : T2dPointArray) : Boolean;
var a, x ,y : integer;
TPAbox : Tbox ;
begin
for a:=0 to 5 do
begin
TPAbox := GetTpaBounds(ATPA[a]);
x:=RandomPointInBox(TPAbox).x;
y:=RandomPointInBox(TPAbox).y;
MMouse(x,y,1,1);
wait(100+random(200));
if IsUpTextMultiCustom(['open','oor']) then break;
wait(100+random(200));
end;
Result := IsUpTextMultiCustom(['open','oor']);

end;
/////////////////////////////// Main Loop /////////////////////////
begin
start;
ClickNorth(0);
for tries:=0 to 5 do
begin
if (OpenDoor (FindDoor ) ) then
begin
ClickMouse2(0);
opened := True;
break;
end else writeln('Opening failed');
end;
if (opened) then
writeln ('Doors was opened!') else writeln ('Cannot open doors ,maybe they are already opened?');
end.

Deadly Serious
01-18-2012, 10:23 AM
I'm doing this for myself. I just started exploring ATPA and it was challenge.And I like hard challenges :) It gave me opportunity to learn a lot about ATPA stuff.

Done:
http://puu.sh/dLEl

I will post the code when I clean it up. However I suggest you to make your own function ,it's great way to learn something.

Have fun:)
program PortSarimDoorOpener; // by beginner5

{ Opening doors to Port Sarim fishing shop. Edge of doors must be visible }
{$DEFINE SRL5}
{$DEFINE SMART}
{$i srl/srl.simba}

var
tries: integer;
opened : boolean;
procedure start;
begin
ClearDebug;
Smart_Server := 139;
Smart_Members := True;
Smart_Signed := True;
Smart_SuperDetail := False;
activateclient;
SetupSRL;

end;

//Returns random point in box -- by beginner5
function RandomPointInBox (box :Tbox):Tpoint;
begin
Result.x:=box.x1+random(box.x2-box.x1);
Result.y:=box.y1+random(box.y2-box.y1);
end;

// Sorting ATPA by x or y position of SubTPA's middle points. -- by beginner5
procedure SortATPAbyMidTPA(var ATPA: T2DPointArray; SortByX , SortUp : boolean);
var a,hi ,x,y:integer;
SortArr :Tintegerarray;
begin
hi := High(ATPA);
setlength(SortArr,hi+1);
if (SortByX) then
begin
for a:= 0 to hi do
begin
MiddleTPAEx(ATPA[a],x,y);
SortArr[a]:=x;
end;
end else begin
for a:= 0 to hi do
begin
MiddleTPAEx(ATPA[a],x,y);
SortArr[a]:=y;
end;
end;
QuickATPASort(SortArr,ATPA,0,hi,SortUp);
end;

// Result is TPA of that points from tpa1 ,which has in neighborhood any point from tpa2. -- by beginner5
function AND_TPA (tpa1 , tpa2 :TpointArray ; MinDist ,MaxDist : extended) : TPointArray;
var
a : integer;
temp_tpa1 :tPointarray;
begin
Setlength(Result,0);
for a:=0 to High(tpa2) do
begin
temp_tpa1 := tpa1; // Don't want FilterPointsDist overwrite tpa1
FilterPointsDist(temp_tpa1,MinDist,MaxDist,tpa2[a].x,tpa2[a].y);
CombineTPAWrap(Result,temp_tpa1,Result);
end;
// Need here function which remove duplicated points from tpa.
end;

function FindDoor : T2dPointArray;
var
WallColor , DoorEdgeColor ,AdditionalDoorColor ,AdditionalDoorColor2 : integer;
TPA1 ,TPA2 ,TPA3 ,TPA4 : TPointArray;
houseBox :TBox;
begin
/////////////SETUP/////////////
WallColor := 13955062;
DoorEdgeColor := 3627875 ;
AdditionalDoorColor := 3361102 ;
AdditionalDoorColor2 := 604482 ;
///////////////////////////////

if FindColorstolerance(TPA4,WallColor,msx1,msy1,msx2, msy2,15) then
houseBox :=GetTpaBounds(TPA4) else writeln('Cannot find wall - update color!');

FindColorstolerance(TPA1,DoorEdgeColor ,houseBox.x1,houseBox.y1,houseBox.x2+10,houseBox.y 2+10,10);
FindColorstolerance(TPA2,AdditionalDoorColor ,houseBox.x1,houseBox.y1,houseBox.x2+10,houseBox.y 2+10,10);
FindColorstolerance(TPA3,AdditionalDoorColor2 ,houseBox.x1,houseBox.y1,houseBox.x2+10,houseBox.y 2+10,15);

RAaSTPAEx(TPA1,10,10);
RAaSTPAEx(TPA2,10,10);
RAaSTPAEx(TPA3,10,10);

TPA1:=AND_TPA(TPA1,TPA2,0,15);
TPA1:=AND_TPA(TPA1,TPA3,0,15);
TPAtoATPAExWrap(TPA1,50,2,Result);
if (High(Result)=-1) then
begin
writeln('ATPA is empty! Something with colors');
terminatescript;
end;
SortATPAbyMidTPA(Result,False,False);
end;

function OpenDoor (ATPA : T2dPointArray) : Boolean;
var a, x ,y : integer;
TPAbox : Tbox ;
begin
for a:=0 to 5 do
begin
TPAbox := GetTpaBounds(ATPA[a]);
x:=RandomPointInBox(TPAbox).x;
y:=RandomPointInBox(TPAbox).y;
MMouse(x,y,1,1);
wait(100+random(200));
if IsUpTextMultiCustom(['open','oor']) then break;
wait(100+random(200));
end;
Result := IsUpTextMultiCustom(['open','oor']);

end;
/////////////////////////////// Main Loop /////////////////////////
begin
start;
ClickNorth(0);
for tries:=0 to 5 do
begin
if (OpenDoor (FindDoor ) ) then
begin
ClickMouse2(0);
opened := True;
break;
end else writeln('Opening failed');
end;
if (opened) then
writeln ('Doors was opened!') else writeln ('Cannot open doors ,maybe they are already opened?');
end.

I hope you don't mind, I posted the link on my harpoon buyer on where to find the door detection fix.
If you want me to, I'll take down the link.
Thank you very much, for all the time and effort you've spent into developing that.

YILDIRIM
01-24-2012, 04:29 AM
can you please pm me a working harpoon buy/sell bot please or post a acctual link up ?

Deadly Serious
01-24-2012, 04:46 AM
can you please pm me a working harpoon buy/sell bot please or post a acctual link up ?

There's one in my signature. Unfortunately you have to fix a few common errors that occur in scripting. It isn't that hard, I posted up a link on where you can find nearly all the fixes to my script.