CheckMovement
You know how when you click on the other side of a fence, the character walks around it? Most of the time, this means the flag will not be visible! Also, sometimes you can be stuck behind something, but the flag may still be there. This function will check if your character is moving without using the flag.
UPDATE: This function should now work with SMART
WaitUntilStop
Uses CheckMovement to wait until you character stops.
The Script
(Last two are the ones that would be used by others. The first two are used in CheckMovement)
SCAR Code:program New;
{.include SRL/SRL.scar}
function ColorCheck(Color: Integer; Smart: Boolean): Boolean;
var
Dots, W, H, x, y : Integer;
begin
Dots := BitmapFromString(17, 15, 'beNpjYPgPAwxEA2pp+W9' +
'm9o+HB1nkHxjgNASoXkHhDxvbS1T1QPDmzRusWoDmA9V/ZGA4h6oF' +
'qP7SpUs47GG8ycCwB8yAizx69Ojo0aNIIlh0Ycgy4lVPMmDn5mOgG' +
'fj3T/jfPz6S1P/5w/T1K8Pdu8RqAaoHordvGc6cId4eRqD5YPUkhS' +
'RxIQ8AaQdf5g==');
SetTargetBitmap(Dots);
GetBitmapSize(Dots, W, H);
if(FindColorTolerance(x, y, Color, 0, 0, W, H, 10)or(Color=65536))then Result:=False
else Result:=True;
FreeBitmap(Dots);
if(Smart=True)then SetTargetDC(SmartGetDC)
else ResetDC;
end;
function FindGoodPoint(x1, y1, x2, y2: Integer; Smart: Boolean; var Color: Integer):TPoint; //finds good coords, duh!
var
y, x: Integer;
begin
y:=y1-1;
repeat
begin
y:=y+1;
x:=x1;
repeat
begin
x:=x+1;
Result.x:=x;
Result.y:=y;
Color:=GetColor(x, y);
end;
until(ColorCheck(GetColor(x, y), Smart)or(x=x2+1));
end;
until((ColorCheck(GetColor(x, y), Smart))or((y=y2)and(x=x2+1)));
if((y=y2)and(x=x2+1))then
begin
Result.x:=-1;
Result.y:=-1;
end;
end;
{*******************************************************************************
function CheckMovement(Smart: Boolean): Integer;
By: Macrosoft
Description: Set whether you are useing SMART or not.
Returns 0 if an error occured.
Returns 1 if not moving.
Returns 2 if moving.
*******************************************************************************}
function CheckMovement(Smart: Boolean): Integer;
var
RPoint: Tpoint;
RColor, i, Strikes: Integer;
NColor: Integer;
begin
i:=0;
RPoint:=FindGoodPoint(570, 33, 683, 135, Smart, RColor);
if(RPoint.x=-1)then
begin
WriteLn('Error: Could not find referance point');
Result:=0;
Exit;
end;
Strikes:=0;
repeat
begin
Wait(500);
NColor:=GetColor(RPoint.x, RPoint.y);
if(ColorCheck(NColor, Smart))and(not(NColor= RColor))then //if color changes
begin
i:=i+1;
Strikes:=0;
RColor:=NColor;
end else
begin
i:=0;
Strikes:=Strikes+1;
end;
end;
until(i=3) or (Strikes=3);
if(i=3)then
begin
Result:=2;
WriteLn('We are moving!');
end else
begin
Result:=1;
WriteLn('We are not moving!');
end;
end;
{*******************************************************************************
function WaitUntilStop(Smart: Boolean): Integer;
By: Macrosoft
Description: Waits until the character stops moving.
Set whether you are useing SMART or not.
Returns 0 if and error occured.
Returns 1 if you are caught on something and the flag
remains while you are still
Returns 2 if stopped.
*******************************************************************************}
function WaitUntilStop(Smart: Boolean): Integer;
var
i, Strikes: Integer;
begin
Strikes:=0;
i:=0;
repeat
begin
i:=CheckMovement(Smart);
if(i=0)then Strikes:=Strikes+1 else Strikes:=0;
end;
until(i=1) or (Strikes=3);
if(Strikes=3)then
begin
Writeln('Some error has occured');
Result:=0;
Exit;
end;
if(FlagPresent)then
begin
Writeln('You are caught on something!');
Result:=1;
Exit;
end;
Result:=2;
end;
begin
SetupSRL;
CheckMovement(False);
end.
Your move N1Ke, I told ya so (Were having a little Teacher Student brawl)




Reply With Quote















.
).


