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.
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.