SRL Archive - SRL Archives

PlayerIsMoving Re-Made


Claymore

2008-10-09 01:52:58


procedure PlayerIsMoving;
var
A, B, C, D: Integer;
Timer: LongInt;
Tries: Byte;
begin
MarkTime(Timer);
Tries := 0;
repeat
A := GetColor(MSCX - 25, MSCY - 25);
B := GetColor(MSCX + 25, MSCY + 25);
Wait(RandomRange(750, 1000));
C := GetColor(MSCX - 25, MSCY - 25);
D := GetColor(MSCX + 25, MSCY + 25);
if (C = A) and (D = B) then
Inc(Tries)
else
Tries := 0;
until (TimeFromMark(Timer) > (30000)) or (Tries = 5);
end;

This is just a general idea, nothing new but as you can see, it uses fail safe, etc.

How-It-Works.

1. Grabs the colors in the mainscreen.
2. Waits for like milli-seconds.
3. Grabs the colors in the mainscreen like before.
4. It will find out wether they match.
5. Then it will add up the count.
6. Repeat 1 - 5 untill the count = 5.
7. There you go, the playerIsMoving.

Concerns….
If place is crowded, than this function is completely usless…

Daniel

2008-10-09 07:21:15

Good idea! I might need this (will be re-made of course) ;)

EvilChicken!

2008-10-09 08:43:44

Small changes I made a long time ago ..

function PlayerIsMoving: Boolean;
var
A, B, Timer: LongInt;
Tries: Byte;

begin
Timer := GetSystemTime;
Tries := 0;
repeat
A := GetColor(MSCX - 25, MSCY - 25);
B := GetColor(MSCX + 25, MSCY + 25);
Wait(750 + Random(250));
Result := (GetColor(MSCX - 25, MSCY - 25) <> A) and (GetColor(MSCX + 25, MSCY + 25) <> B);
if Result then
Exit
else
Inc(Tries);
until (TimeFromMark(Timer) > (30000)) or (Tries = 5);
end;


But, I doubt that it'll be a good addition to SRL, simply becuase it's too uncertain. Like, if it collects the color of a player's dot, and the player moves ..

Narcle

2008-10-09 09:04:31

Quadruple check!

function PlayerIsMoving: Boolean;
var
A, B, C, D, Timer: LongInt;
Tries: Byte;

begin
Timer := GetSystemTime;
Tries := 0;
repeat
A := GetColor(MSCX - 25, MSCY - 25);
B := GetColor(MSCX + 25, MSCY + 25);
C := GetColor(MSCX + 25, MSCY - 25);
D := GetColor(MSCX - 25, MSCY + 25);
Wait(750 + Random(250));
Result := (GetColor(MSCX - 25, MSCY - 25) <> A) and (GetColor(MSCX + 25, MSCY + 25) <> B)
and (GetColor(MSCX + 25, MSCY - 25) <> C) and (GetColor(MSCX - 25, MSCY + 25) <> D);
if Result then
Exit
else
Inc(Tries);
until (TimeFromMark(Timer) > (30000)) or (Tries = 5);
end;

EvilChicken!

2008-10-09 09:10:54

From: Narcle
Quadruple check!

function PlayerIsMoving: Boolean;
var
A, B, C, D, Timer: LongInt;
Tries: Byte;

begin
Timer := GetSystemTime;
Tries := 0;
repeat
A := GetColor(MSCX - 25, MSCY - 25);
B := GetColor(MSCX + 25, MSCY + 25);
C := GetColor(MSCX + 25, MSCY - 25);
D := GetColor(MSCX - 25, MSCY + 25);
Wait(750 + Random(250));
Result := (GetColor(MSCX - 25, MSCY - 25) <> A) and (GetColor(MSCX + 25, MSCY + 25) <> B)
and (GetColor(MSCX + 25, MSCY - 25) <> C) and (GetColor(MSCX - 25, MSCY + 25) <> D);
if Result then
Exit
else
Inc(Tries);
until (TimeFromMark(Timer) > (30000)) or (Tries = 5);
end;


Butstill, what if one of those four hit a player dot? You'll still be screwed ..
Kinda why I didn't add any more points ..

Narcle

2008-10-09 09:12:18

From: EvilChicken!
Butstill, what if one of those four hit a player dot? You'll still be screwed ..
Kinda why I didn't add any more points ..


The result is AND so if one of those is a player dot then it'll ignore it if the others haven't changed. That's why I put mine up to 4 for accuracy.

EvilChicken!

2008-10-09 09:22:50

From: Narcle
The result is AND so if one of those is a player dot then it'll ignore it if the others haven't changed. That's why I put mine up to 4 for accuracy.


Dammit, you're right .. >.<'
I'm sorry, forgive my stupidity..
Didn't think over the fact about AND.



Edit: Well, nevermind. Was a bad idea >.<

Narcle

2008-10-09 09:29:14

From: EvilChicken!
Dammit, you're right .. >.<'
I'm sorry, forgive my stupidity..
Didn't think over the fact about AND.

But, I just got an idea, wouldn't it be even better to do a FindColorsTolerance with 422 tol (if that's the max) of the whole MM, and then another one about 750 MS later and compare the TPA array lengths?


Yeah I think TPA would work better. But with 422 tolerance… idk

Goobs

2008-10-09 13:11:45

You guys do know that you're grabbing pixels from the MAIN SCREEN, and not the Minimap? You don't have to worry about player pixels. Sheesh.

I've been waiting for this for a long time. Can't wait to implement it (once it's fine tuned, that be.)

Narcle

2008-10-09 13:17:14

From: ProphesyOfWolf
You guys do know that you're grabbing pixels from the MAIN SCREEN, and not the Minimap? You don't have to worry about player pixels. Sheesh.

I've been waiting for this for a long time. Can't wait to implement it (once it's fine tuned, that be.)


Haha, I didn't even look at that. Nonetheless its the concept that counts.

Claymore

2008-10-09 19:21:51

ya guys, it takes the colors in the main screen ;p its far more effective!

Claymore

2008-10-09 19:27:11

From: EvilChicken!
Small changes I made a long time ago ..

function PlayerIsMoving: Boolean;
var
A, B, Timer: LongInt;
Tries: Byte;

begin
Timer := GetSystemTime;
Tries := 0;
repeat
A := GetColor(MSCX - 25, MSCY - 25);
B := GetColor(MSCX + 25, MSCY + 25);
Wait(750 + Random(250));
Result := (GetColor(MSCX - 25, MSCY - 25) <> A) and (GetColor(MSCX + 25, MSCY + 25) <> B);
if Result then
Exit
else
Inc(Tries);
until (TimeFromMark(Timer) > (30000)) or (Tries = 5);
end;


But, I doubt that it'll be a good addition to SRL, simply becuase it's too uncertain. Like, if it collects the color of a player's dot, and the player moves ..


What did you just do? Because what it was suppose to do is wait till the player stops moving…

EvilChicken!

2008-10-09 19:44:29

From: Deathscytex
What did you just do? Because what it was suppose to do is wait till the player stops moving…


I made it do what the function name suggests, simply return wheter player is moving or not with a boolean.

bullzeye95

2008-10-09 20:58:58

This is very unreliable if you are not in a relatively empty place. It's best to use the minimap.

Nava2

2008-10-09 21:25:26

Bullzeye, why not post yours? Not to hijack, but you had a better version? :S

bullzeye95

2008-10-09 21:28:13

Too lazy :p
I'll dig it up from somewhere if someone's interested though.

Claymore

2008-10-11 15:50:36

Sad face, someone already has something more reliable ;p But if you happen to find it, maybe post it or something? ;p

bullzeye95

2008-10-11 16:26:00

Took me a while, but I managed to dig it up:
program New;
const
MMX1 = 550;
MMX2 = 703;
MMY1 = 8;
MMY2 = 161;
MMCX = 627;
MMCY = 85;

function IsMoving: Boolean;
var
BMP, BMP2, I, x, y, Handle: Integer;
ReplaceCols: TIntegerArray;
P: TPointArray;
begin
Handle:= GetClientWindowHandle;
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);
for I:= 0 to High(ReplaceCols) do
FastReplaceColor(BMP, ReplaceCols[i], 0);
wait(250);
SafeCopyCanvas(GetClientCanvas, GetBitmapCanvas(BMP2), MMCX - 50, MMCY - 50, MMCX + 50, MMCY + 50, 0, 0, 100, 100);
SetTargetBitmap(BMP2);
for I:= 0 to High(ReplaceCols) 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);
SetClientWindowHandle(Handle);
FreeBitmap(BMP);
FreeBitmap(BMP2);
end;

procedure WaitWhileMoving;
begin
while IsMoving do ;
end;

begin
// writeln(booltostr(IsMoving));
WaitWhileMoving;
end.

(Those constants may not be entirely correct anymore, but it should still work)

Claymore

2008-10-11 19:52:08

Wow, so… How the hell does it work ^.^

EDIT:

So it compares the 2 bitmaps. if there are any changes that means the player is moving. Isnt that sort of unreliable because the white dotted people andf the NPCs are moving? ;p

bullzeye95

2008-10-11 23:00:03

I took care of that too, actually. Here's the explanation: http://www.srl-forums.com/forum/showthread.php?p=414222#post414222