PDA

View Full Version : How to make a DTM that the user can select the colour of



r4ndom
01-06-2007, 03:45 PM
INTRODUCTION

If you ask any good scripter which method of colour finding is most accurate the chances are that he will tell you to use DTMs so you've read the DTM tutorials on the site and know how to use them. However now you've hit a bump in the road; for your new auto fighter your working on you cant use DTMs. Unless of course you made a DTM for every single monster on the game its impossible to let the user just pick a monster. So you sigh and write a script like this.


procedure findandfight;
begin
if(findcolor(x,y,monstercolour,MSX1,MSY1,MSX2,MSY2 ))then
begin
mmouse(x,y,2,2);
if(istextat2(9,9,'Attack ' + monstername,100)) and (not infightat(x,y)then
begin
mouse(x,y,2,2,True);
end;
end;
end;

This is pretty nice scripting but when you run the script look what happens most likely it will move the mouse over random places with the same colour and not really get anywhere also depending on the speed of your computer it will be quite laggy as well.

MY TECHNIQUE

here is an interesting technique that I use.


program fighter;

{.include SRL/SRL.scar}

const unique = 325753;
const common = 352752;

procedure fight;
begin
if(findcolor(x,y,unique,MSX1,MSY1,MSX2,MSY2)) and (FindColorEllipse(x,y,common,20,x-75,y-75,x+75,y+75))then
begin
mouse(x,y,2,2,True);
end;
end;


begin
fight;
end.
How it works is first of all it finds a unique colour eg. the red bit of a guards helm then it sees if it can find a more common colour eg. the brown part in a 75 by 75 area of where it found the first colour. heres a diagram to explain

http://img152.imageshack.us/img152/8270/diagrmafi0.png

you see scar searches the whole screen then finds the unique colour it then limits the search to a 75 by 75 area and finds a more common colour so theres less waggling about of the mouse to find the monster mess about with the coordinates and stuff and add extra colours to get used to the technique it can be very effective when there are a lot of a similar colour about.

Killerdou
01-06-2007, 04:01 PM
looks... ok, but you could use findobj too... it basicly combines findcolorspiraltolerance and isuptext:) but your idea looks good too:)

r4ndom
01-06-2007, 04:06 PM
looks... ok, but you could use findobj too... it basicly combines findcolorspiraltolerance and isuptext:) but your idea looks good too:)

the idea of mine is to replace findobj as find object does a lot of mouse waving about if their is a lot of the colour your searching for mine works on the principles of DTMS except allowing the end user to change colours

r4ndom
01-06-2007, 05:47 PM
noone bothered reading ?

WhiteShadow
01-06-2007, 06:39 PM
"How to make a DTM that the user can select the colour of"

and when does this come into play?

Good job, this is just color searching though. ;]

r4ndom
01-07-2007, 01:30 PM
"How to make a DTM that the user can select the colour of"

and when does this come into play?

Good job, this is just color searching though. ;]

a DTM is just colour searching isn't it if not please explain what it searches for because I thought that a DTM just searched for more than one colour at the same time e.g what im doing

Killerdou
01-07-2007, 03:46 PM
a DTM is somewhat like a bitmap, its a picture:)

Boreas
01-07-2007, 05:09 PM
It's colors but with positional relationships between them. For example, a DTM could be a parent dot of Color1 with a secondary dot of Color2 that is 5 pixels to the right and 6 pixels below the parent dot.



#
\
\
\
@




Also, if you have a unique color that works, then why use another color? And if the unique color isn't unique, it will find the first one (I think it goes from top left to bottom right), and will then only look for the second color there.

You can do something similar in another situation though: when what you are trying to find has multiple colors in it, and these colors are found else where (jagex does this a lot, go to aubury and look at the white torches on the wall, or the range near the al karid furnace, or a table near a bank booth), however the only place where all of the colors are found together is your object. If this is the case, you can do something like what you did. One thing to add though is looking for the first color multiple times until it finds the second (third etc) color near it. You can do this by either splitting up the screen into boxes, and looking in each one, or finding the first one (left to right etc) and skipping false positives, repeating until you get one that has the other colors near it.

To do a sort of DTM, it would be similar except instead of 'near' the first color, it would be in a box that is
x+5,y+6 x+7,y+8 or something, and you would have to make sure to check more of the occurrences of the first color. This would be inefficient compared to making a DTM with the DTM editor and adding tolerance. If kait told us how the DTM editor translates coords and colors to the string it outputs, we could do some really cool stuff. Until then, on the fly DTMs aren't really feasible. However, on the fly bitmapmasks are, and I will (when I get time) be releasing a tool to demonstrate this that makes bitmapmasks automatically, and I will explain how it works.