Mouse, Flag and MouseFlag
Back to Top
Ok since I have a little bit of time today I'm going to take this opportunity to add a new section to this tutorial. I should have added it before but I guess it would be already familiar to intermediate level scripters.
This section is mainly on Flag and FFlag, an SRL procedure that (when called) waits until the red flag on the minimap disappears or is within a set distance from the minimap centre. There are really several versions of Flag but I'll only explain a couple.
procedure MouseFindNoFlag(ax, ay, xmod, ymod: Integer);I'll explain Flag first of all because it is the simplest one with no parameters needed:
The way you use this is by calling Flag after you've clicked somewhere on the minimap (by using symbols, colours or DTMs). When called, Flag check will wait until the colour 255 disappears (until the flag disappears). This means your character will stop for a couple of milliseconds before moving on thus making your character seem a bit suspicious I suppose. Thats why our wonderful SRL Devs came up with FFlag:
SCAR Code:
procedure FFlag(Distance: Integer);
Distance: The procedure will wait until the flag is within the distance specified. This means the script will continue before the character stops completely thus making it seem more human.
Although FFlag does seem quite good there is a problem with it as well as Flag where the Flag doesn't appear after a click (the click was in an area that was unclickable or the flag appeared offscreen). If this occurs, FFlag or Flag can't find the flag colour and continues thus stuffing up your main loop.
There are several ways to solve this but the most common would be to just wait a second or two before calling FFlag. This allows the Flag to appear on screen as the character starts to walk towards it:
SCAR Code:
if (FindColor(x, y, RoadColour, MMX1, MMY1, MMX2, MMY2)) then
begin
Mouse(x, y, 5, 5, True);
Wait(2000); //Waits 2 seconds for the flag to appear on screen
FFlag(10);
end;
There is also another way to solve this problem but I'll explain that later.
Now that I've explained Flag and the like, I think I might explain to you another method of map walking. It is the most unreliable method and the most suspisious as well. I like to call it "Walking Blind" or walking using coordinates. What do I mean by this? I mean using Mouse and clicking the same coordinate every time. The reason why this is unreliable is because the minimap shifts and changes the camera angle every time RS is played. Thus your character can get lost quite easily (unless of course you have lots of failsafes). Although I (as will many other scripters) frown upon it, I thought I might cover it a bit I do (I admit) use it from time to time.
This method uses the procedure Mouse or something similar to that. The only thing useful about this method is several procedures in the Mouse family that are designed for map walking:
SCAR Code:
procedure MouseFlag(cx, cy, rx, ry: Integer);
This procedure combines Mouse and Flag to form.. well MouseFlag. The paramters are the same as normal Mouse except it always left clicks.
SCAR Code:
procedure MouseFindNoFlag(ax, ay, xmod, ymod: Integer);
This procedure is a little bit different. Remember how I said there are several methods to solve the problem with the flag appearing offscreen? Well this is one of the other solutions. It is basically the same as MouseFlag except if the flag doesn't appear it will keep trying and adding the x and y mod until it appears.
After all this Flag business I would like you to note one small (and quite trival) problem. Remember how I said FFlag would wait until the colour 255 appears within a certain distance from the minimap centre? If you hadn't noticed the colour 255 is the top of the flag not the stick thing to where the character is walking to. That means if you're approaching the flag from the south, FFlag will think you're further away from the flag that you really are and vice versa for approaching from the north. Thats why I'll share with you my version of FFlag:
SCAR Code:
procedure ZephFlag(Dist: Integer);
var
Dx, Dy, m, T: Integer;
begin
MarkTime(T);
repeat
if (FindColor(Dx, Dy, 255, MMX1, MMY1, MMX2, MMY2)) then
begin
m := GetColor(317, 172);
if (Distance(Dx, Dy + 14, MMCX, MMCY) >= Dist) then
begin
Wait(100);
if (TimeFromMark(T) > 15000) then
begin
if (GetColor(317, 172) = m) then
begin
if (FindColor(Dx, Dy, 255, MMX1, MMY1, MMX2, MMY2)) then
Mouse(Dx, Dy + 14, 1, 1, True)
else
Mouse(MMCX, MMCY, 0, 0, True);
Break;
end;
end else
if (TimeFromMark(T) > 30000) then Break;
end else Break;
end;
until(not(FindColor(Dx, Dy, 255, MMX1, MMY1, MMX2, MMY2)));
end;
It has the same parameter "Distance" as FFlag but it measures the distance from the bottom of the flag and thus solves the problem with the colour 255 getting detected as the flag bottom.
Now onto the final section... Failsafes....