SRL Archive - Research & Development Lounge

Function DifferentMSColours: Boolean; AND Procedure CharacterMoving; [Colour based]


Floor66

2009-04-05 14:09:20


{*******************************************************************************
Function DifferentMSColours: Boolean;
By: Floor66
Description: This function takes the colours of specific MainScreen points,
waits 100 + Random(50), takes new colours, and checks if the
colours are different from the first ones taken.
*******************************************************************************}

Function DifferentMSColours(MS_Points : Integer): Boolean;
Var
BeginColours, CheckColours : Array Of Integer;
ColorCoords : TPointArray;
i, Results : Integer;
Begin
SetLength(ColorCoords, MS_Points);
SetLength(BeginColours, MS_Points);
SetLength(CheckColours, MS_Points);
For i := 0 To High(BeginColours) Do
Begin
ColorCoords[i].x := MSCX + Random(50);
ColorCoords[i].y := MSCY + Random(50);
BeginColours[i] := GetColor(ColorCoords[i].x, ColorCoords[i].y);
End;
Wait(100 + Random(50));
For i := 0 To High(CheckColours) Do
Begin
CheckColours[i] := GetColor(ColorCoords[i].x, ColorCoords[i].y);
If BeginColours[i] <> CheckColours[i] Then
Result := True;
End;
End;

{*******************************************************************************
Procedure CharacterMoving;
By: Floor66
Description: This procedure incorporates the function DifferentMSColours to do
a check if the character is still moving. A real handy check when
doing something with walking!
*******************************************************************************}

Procedure CharacterMoving;
Var
Checks, t : Integer;
Begin
Wait(500 + Random(50));
MarkTime(t);
Repeat
If (Not DifferentMSColours(7)) Then
Inc(Checks);
If (Checks >= 2) Or (Not FlagPresent) Then
Exit;
If TimeFromMark(t) >= (10 * 1000) Then
Exit;
Until(False);
End;


In reflection, there is/was a function called CharacterMoving. But reflection breaks all the time because of hooks (no offence; it's great).

I've gotten this idea from Nadeem, who made something like this, and I sort of expanded it.

This waits until the character has 100% STOPPED moving, or if the flag disappears. It does 2 checks to make sure, and there's a 15-sec failsafe.

PLEASE TEST IT! I'M ALREADY USING IT MYSELF AND IT WORKS FOR ME, BUT I WANT TO SEE IT WITH OTHERS!

Quickmarch

2009-04-05 15:07:43

This might not work because what if it was another player at the point where you get the colours?

lordsaturn

2009-04-05 15:35:58

By nava2:
{*******************************************************************************
function IsMoving(WaitTime: Integer): Boolean;
By: Bullzeye95; Edits by Nava2
Description: Checks if the currently loaded player is moving. Uses Minimap,
ignoring all dots which can move without the player moving.
Nava2 edit: Added try..finally, also changed to work with SMART,
as well added WaitTime Parameter.
*******************************************************************************}
function IsMoving(WaitTime: Integer): Boolean;
var
BMP, BMP2, I, H, x, y: Integer;
ReplaceCols: TIntegerArray;
P: TPointArray;
DC: HDC;
begin
WaitTime := Max(100, WaitTime);
try
DC := GetTargetDC;
ReplaceCols:= [65536, 16711422, 12961221, 14869218, 16777215, 15527148, 195836, 56797, 60909, 52428,
13816530, 982782, 1310462, 62965, 2105598, 395004, 789758, 3553023, 217, 188, 241,
206, 233, 64768, 58880, 51456, 49152, 44800, 61440, 16215571, 9716750, 13129742];
BMP:= BitmapFromString(100, 100, '');
BMP2:= BitmapFromString(100, 100, '');
SafeCopyCanvas(GetClientCanvas, GetBitmapCanvas(BMP), MMCX - 50, MMCY - 50, MMCX + 50, MMCY + 50, 0, 0, 100, 100);
H := High(ReplaceCols);
for I:= 0 to H do
FastReplaceColor(BMP, ReplaceCols[I], 0);
wait(WaitTime);
SafeCopyCanvas(GetClientCanvas, GetBitmapCanvas(BMP2), MMCX - 50, MMCY - 50, MMCX + 50, MMCY + 50, 0, 0, 100, 100);
SetTargetDC(GetBitmapDC(BMP2));
for I:= 0 to H do
begin
FindColorsTolerance(P, ReplaceCols[I], 0, 0, 99, 99, 0);
for x:= 0 to High(P) do
FastSetPixel(BMP2, P[x].x, P[x].y, FastGetPixel(BMP, P[x].x, P[x].y));
end;
Result:= not FindBitmapIn(BMP, x, y, 0, 0, 100, 100);
finally
SetTargetDC(DC);
FreeBitmap(BMP);
FreeBitmap(BMP2);
end;
end;

{*******************************************************************************
function Flag: Boolean;
By: PPLSUQBAWLZ, Odie533, Nava2, and Bullzeye95
Description: Waits while flag exists.
*******************************************************************************}
function xFlag: Boolean;
var
x, y, TimeOut: Integer;
begin
Result := False;
if (FindColor(x, y, 255, MMX1, MMY1, MMX2, MMY2)) then
begin
Result := True;
TimeOut := GetTimeRunning + 3000;
while IsMoving(200) and (FindColor(x, y, 255, MMX1, MMY1, MMX2, MMY2) and LoggedIn and (GetTimeRunning < TimeOut) do
begin
if (SRL_Procs[srl_AntiBan] <> nil) then
SRL_Procs[srl_AntiBan]();
Wait(100);
end;
end;
Wait(Random(100));
end;

Floor66

2009-04-05 15:37:21

This gets colours of the Main Screen, nava2's gets of the MM which gives problems with the other dots =\.
If I am moving, and I get the colour at 50, 50. Wait. Get the colour at 50,50 again, I know that if the colour is the same I didn't move, but if it changed I know I did move. The camera moves with the character!!

lordsaturn

2009-04-05 16:20:49

ReplaceCols:= [65536, 16711422, 12961221, 14869218, 16777215, 15527148, 195836, 56797, 60909, 52428,
13816530, 982782, 1310462, 62965, 2105598, 395004, 789758, 3553023, 217, 188, 241,
206, 233, 64768, 58880, 51456, 49152, 44800, 61440, 16215571, 9716750, 13129742];
It has problems with dots, you say?

And with your function, what if a player walks past the point you've chosen? That would give false positives don't you think?

Floor66

2009-04-05 16:22:59

The mm gives an issue, nava fixed it. I was speaking about the mm in general.

and ill elaborate tomorrow

Quickmarch

2009-04-05 16:24:10

From: Floor66
This gets colours of the Main Screen, nava2's gets of the MM which gives problems with the other dots =\.
If I am moving, and I get the colour at 50, 50. Wait. Get the colour at 50,50 again, I know that if the colour is the same I didn't move, but if it changed I know I did move. The camera moves with the character!!


Yeah, i meant the one on the ms, if the colour was on a ms player and the player moves, it will be different, no?

Floor66

2009-04-06 02:03:00

As promised I'll elaborate now ;)
You both have a good point. If a colour would change out of itself by e.g: a character moving, something else moving, etc. the script will be fooled because the colour then has changed, whether you moved or not.
This is also a reason why I do two checks to see if the character is moving, in CharacterMoving.

I will not deny it, my function is not as good as Nava2's qua failsafe/coding, but the usage of this has never disappointed me. It always works for me ;). I'll continue using it too.

P.S:
I've added a wait in the beginning of CharacterMoving. The reason why? This:
You won't notice it fast, but actually, after you have clicked on the MM to walk, the camera stays still for just a little while more, and this could fool my function. That's why the wait is added.

bullzeye95

2009-04-06 02:55:34

From: lordsaturn
By nava2:
{*******************************************************************************
function IsMoving(WaitTime: Integer): Boolean;
By: Bullzeye95; Edits by Nava2
Description: Checks if the currently loaded player is moving. Uses Minimap,
ignoring all dots which can move without the player moving.
Nava2 edit: Added try..finally, also changed to work with SMART,
as well added WaitTime Parameter.
*******************************************************************************}
function IsMoving(WaitTime: Integer): Boolean;
var
BMP, BMP2, I, H, x, y: Integer;
ReplaceCols: TIntegerArray;
P: TPointArray;
DC: HDC;
begin
WaitTime := Max(100, WaitTime);
try
DC := GetTargetDC;
ReplaceCols:= [65536, 16711422, 12961221, 14869218, 16777215, 15527148, 195836, 56797, 60909, 52428,
13816530, 982782, 1310462, 62965, 2105598, 395004, 789758, 3553023, 217, 188, 241,
206, 233, 64768, 58880, 51456, 49152, 44800, 61440, 16215571, 9716750, 13129742];
BMP:= BitmapFromString(100, 100, '');
BMP2:= BitmapFromString(100, 100, '');
SafeCopyCanvas(GetClientCanvas, GetBitmapCanvas(BMP), MMCX - 50, MMCY - 50, MMCX + 50, MMCY + 50, 0, 0, 100, 100);
H := High(ReplaceCols);
for I:= 0 to H do
FastReplaceColor(BMP, ReplaceCols[I], 0);
wait(WaitTime);
SafeCopyCanvas(GetClientCanvas, GetBitmapCanvas(BMP2), MMCX - 50, MMCY - 50, MMCX + 50, MMCY + 50, 0, 0, 100, 100);
SetTargetDC(GetBitmapDC(BMP2));
for I:= 0 to H do
begin
FindColorsTolerance(P, ReplaceCols[I], 0, 0, 99, 99, 0);
for x:= 0 to High(P) do
FastSetPixel(BMP2, P[x].x, P[x].y, FastGetPixel(BMP, P[x].x, P[x].y));
end;
Result:= not FindBitmapIn(BMP, x, y, 0, 0, 100, 100);
finally
SetTargetDC(DC);
FreeBitmap(BMP);
FreeBitmap(BMP2);
end;
end;

{*******************************************************************************
function Flag: Boolean;
By: PPLSUQBAWLZ, Odie533, Nava2, and Bullzeye95
Description: Waits while flag exists.
*******************************************************************************}
function xFlag: Boolean;
var
x, y, TimeOut: Integer;
begin
Result := False;
if (FindColor(x, y, 255, MMX1, MMY1, MMX2, MMY2)) then
begin
Result := True;
TimeOut := GetTimeRunning + 3000;
while IsMoving(200) and (FindColor(x, y, 255, MMX1, MMY1, MMX2, MMY2) and LoggedIn and (GetTimeRunning < TimeOut) do
begin
if (SRL_Procs[srl_AntiBan] <> nil) then
SRL_Procs[srl_AntiBan]();
Wait(100);
end;
end;
Wait(Random(100));
end;


I made IsMoving, noob :p
He added some colors and a WaitTime parameter from what I can see.