SRL Archive - SRL Bugs

Are MMDots and Flag broken? (Keep talk about it in this thread!)


YoHoJo

2011-12-06 13:18:20

It seems like MM Dots and Flag are now dynamic colors?
By eye MMdots look the same to me, but the flag looks different.
There are many people talking about it/rumors lets figure it out and get it fixed in this ONE THREAD.

I'm using MSI and the walking is working just fine (so far) so I think flag is okay..?
What about MM dots guys?

Everyone post your finding and fixes here!

weequ

2011-12-06 13:25:59

FlagPresent didn't work for me. I'm working on a new one.

Home

2011-12-06 13:30:48

They are all broken. Confirmed.


~Home

weequ

2011-12-06 13:35:27

I wonder if they really think they can stop color bots this way?


program FlagTest;
{.include SRl\SRL.scar}

function FlagPresent2: Boolean;
var
I: Integer;
TPA: TPointArray;
Colors: TIntegerArray;
begin
FindColorsTolerance(TPA, 794856, MMX1, MMY1, MMX2, MMY2, 45);//Color and tolerance needs to be optimized with ACA.
Colors := GetColors(TPA);
ClearSameIntegers(Colors);
for I := 0 to High(Colors) do
begin
FindColors(TPA, Colors[I], MMX1, MMY1, MMX2, MMY2);
if (Length(TPA) = 15) then
begin
Result := True;
Exit;
end;
end;
Result := False;
end;


begin
if FlagPresent2 then WriteLn('Flag found');;
end.
It looks for the main color in flag. It should always have 15 pixels of the exactly same color. I also checked that Item Dots don't contain any of the same color.

Edit: Perhaps I should add TPABounds check to make sure it's not just finding excatly 15 of some other very similar color?

Edit2: Flag only changes when you reload client.

Edit3: Here is an example of the current flag and how much it can change. Shape stays the same so it shouldn't be a problem.

weequ

2011-12-06 14:52:45

Can someone confirm if this works?

function FlagPresent3: Boolean;
var
Bmp, x, y: Integer;
TPA: TPointArray;
begin
Bmp := BitmapFromString(8, 9, 'meJxjYCAW/P//n0hBPIoxxf/DAFZBZHGsKnEBAOywLNQ=');
Result := FindBitmapMaskTolerance(Bmp, x, y, MMX1, MMY1, MMX2, MMY2, 0, 0);
FreeBitmap(Bmp);
end;

Attached the bitmap I put into String format.

YoHoJo

2011-12-06 14:57:55

Not sure if 0 tol will work, try switching servers, going up/down ladders and such and see if it still works or not. Thanks antti!

weequ

2011-12-06 15:01:06

YoHoJo the area of the flag I took to the mask is all covered by the same color so 0 should do fine. I'm not 100% sure what the countour tolerance means though.

Markus

2011-12-06 15:02:00

It looks like there's still the famous relation between colours (the add/substract one). Maybe we can do something with that?

YoHoJo

2011-12-06 15:03:00

From: Markus
It looks like there's still the famous relation between colours (the add/substract one). Maybe we can do something with that?


I do not know what the words you are talking mean :duh:

weequ

2011-12-06 15:06:11

From: Markus
It looks like there's still the famous relation between colours (the add/substract one). Maybe we can do something with that?
I checked that first and couldn't find any relations. You can check it with the bitmap I posted earlier.

From: YoHoJo
I do not know what the words you are talking mean :duh:
I'll explain.

Lets say there is a rock that contains 2 different colors.

When the colors change they would both change as much meaning Color1-Color2 would always be the same. That way it was very easy to make autocolor functions.

euphemism

2011-12-06 15:25:10

weequ, if you are fixing the flag finding, make sure you aren't decreasing functionality. You don't want to look for the red, you want to look for one of the shaft colors. That way, even if you click on the very edge of the minimap, the function will still be able to find the flag.

noidea

2011-12-06 15:30:56

From: Markus
It looks like there's still the famous relation between colours (the add/substract one). Maybe we can do something with that?


The best way to do it imo. It'll be much better than using bitmaps.

@YoHoJo, I use it to find the onion patch next to the draynor bank. Things are so simple when they do that. Findcolorstolerance() then compare all the colors at each point to see if its a constant relationship.

weequ

2011-12-06 15:31:05

Perhaps you are right ephemism. I wish we had something like a Mask that supports more than one color.

noidea

2011-12-06 15:40:10

Check to see if theres a relationship between the bottom of the flag, the next pixel up, then the pixel to the left. It'll probably work. I'd do it now, but I've got a paper to do right now and a dress rehearsal tonight.

weequ

2011-12-06 15:42:44

From: noidea
Check to see if theres a relationship between the bottom of the flag, the next pixel up, then the pixel to the left. It'll probably work. I'd do it now, but I've got a paper to do right now and a dress rehearsal tonight.
Yeah lol I was just coming to post about that relation. It works. I wonder why jagex made some of the colors not related but others not..? I think it's just plain stupid.

noidea

2011-12-06 15:43:55

From: weequ
Yeah lol I was just coming to post about that relation. It works. I wonder why jagex made some of the colors not related but others not..?


I cant remember if they request colours from the server or if the client calls Math.random(). Either way, if it had to do it all the time, it would use a lot of resources to do it for every color.

weequ

2011-12-06 15:45:32

From: noidea
I cant remember if they request colours from the server or if the client calls Math.random(). Either way, if it had to do it all the time, it would use a lot of resources to do it for every color.
As I posted earlier they only change Flag when you reload client.

noidea

2011-12-06 15:49:31

From: weequ
As I posted earlier they only change Flag when you reload client.


Then it may be something to do with the human eye. The eye may perceive it as ugly if there wasnt a constant contrast? Im sure it has more to do with this.

weequ

2011-12-06 15:56:03

Yea but they could add a little bit of randomness too if they really wanted to give us more challenges.

Edit: Can someone test this?

function FlagPresent4: Boolean;
var
I: Integer;
TPA: TPointArray;
begin
Freeze;
FindColors(TPA, 65536, MMX1, MMY1, MMX2, MMY2);
for I := 0 to High(TPA) do
begin
if (GetColor(TPA[I].X-1, TPA[I].Y-1) - GetColor(TPA[I].X, TPA[I].Y-1) = 6381921) then
begin
Unfreeze;
Result := True;
Exit;
end;
end;
Unfreeze;
Result := False;
end;

Edit2: Added freeze and unfreeze. Should work better now.

Coh3n

2011-12-06 23:12:27

Committed weequ's flag fixes from the other thread.

Aegis

2011-12-06 23:37:04

From: Coh3n
Committed weequ's flag fixes from the other thread.


Awesome, thanks Coh3n!

mormonman

2011-12-06 23:39:06

Dot colors also have those sort of relationships. NPC difference = 4369. Drop difference = 23.

mormonman

2011-12-07 00:11:01

Need team and clan differences.
Use these two pixels:

{*******************************************************************************
function GetMiniMapDotsIn(WhatDot: String; x1, y1, x2, y2: Integer): TPointArray;
By: euphemism, mormonman
Description: Results the dots specified by WhatDot in the box x1, y1, x2, y2.
Usage : 'npc', 'yellow', 'n', 'y' : Yellow Dot;
'cape', 'blue', 'team', 't', 'b' : Blue Dot;
'item', 'red', 'i', 'r' : Red Dot;
'player', 'white', 'p', 'w' : White Dot;
'friend', 'green', 'f', 'g' : Green Dot;
*******************************************************************************}
function GetMiniMapDotsIn(WhatDot: String; x1, y1, x2, y2: Integer): TPointArray;
var
I, Dif, Radius, Hi, C: Integer;
TPA: TPointArray;
begin
case LowerCase(WhatDot) of
'npc', 'n', 'yellow', 'y': Dif := 4369;
'item', 'i', 'red', 'r': Dif := 23;
'player', 'p', 'white', 'w': Dif := 1907997;
'friend', 'f', 'green', 'g': Dif := 5376;
{'team', 't', 'blue', 'b', 'cape': Dif := -1;
'clan', 'c', 'orange', 'o': Dif := -1;}
else
srl_Warn('GetMiniMapDotsIn', '"' + WhatDot + '" is not a valid dot type', warn_AllVersions);
end;
Freeze;
Radius := Max((x2-x1)/2, (y2-y1)/2);
FindColorsPie(TPA, 65536, 0, 0, 360, 0, radius, x1, y1, x2, y2, (x1+x2)/2, (y1+y2)/2);
Hi := High(TPA);
SetLength(Result, Hi + 1);
if (Hi < 0) then Exit;
C := 0;
for I := 0 to Hi do
begin
if (GetColor(TPA[I].X-1, TPA[I].Y-1) - GetColor(TPA[I].X, TPA[I].Y-1) = Dif) then
begin
Result[C] := Point(TPA[I].x, TPA[i].y - 2);
Inc(C);
end;
end;
Unfreeze;
SetLength(Result, C);
end;

Coh3n

2011-12-07 00:20:21

How do you get the differences?

mormonman

2011-12-07 00:30:55

Look at my post, I added an image. Get the color at both pixels surrounded by a green box. Subtract one on right from one on the left.

NCDS

2011-12-07 00:36:02

Confirmed this working with npc:

{*******************************************************************************
function GetMiniMapDotsIn(WhatDot: String; x1, y1, x2, y2: Integer): TPointArray;
By: euphemism, mormonman
Description: Results the dots specified by WhatDot in the box x1, y1, x2, y2.
Usage : 'npc', 'yellow', 'n', 'y' : Yellow Dot;
'cape', 'blue', 'team', 't', 'b' : Blue Dot;
'item', 'red', 'i', 'r' : Red Dot;
'player', 'white', 'p', 'w' : White Dot;
'friend', 'green', 'f', 'g' : Green Dot;
*******************************************************************************}
function GetMiniMapDotsIn(WhatDot: String; x1, y1, x2, y2: Integer): TPointArray;
var
I, Dif, Radius, Hi, C: Integer;
TPA: TPointArray;
begin
case LowerCase(WhatDot) of
'npc', 'n', 'yellow', 'y': Dif := 4369;
'item', 'i', 'red', 'r': Dif := 23;
'player', 'p', 'white', 'w': Dif := 1907997;
'friend', 'f', 'green', 'g': Dif := 5376;
{'team', 't', 'blue', 'b', 'cape': Dif := -1;
'clan', 'c', 'orange', 'o': Dif := -1;}
else
srl_Warn('GetMiniMapDotsIn', '"' + WhatDot + '" is not a valid dot type', warn_AllVersions);
end;
Freeze;
Radius := Max((x2-x1)/2, (y2-y1)/2);
FindColorsPie(TPA, 65536, 0, 0, 360, 0, radius, x1, y1, x2, y2, (x1+x2)/2, (y1+y2)/2);
Hi := High(TPA);
SetLength(Result, Hi + 1);
if (Hi < 0) then Exit;
C := 0;
for I := 0 to Hi do
begin
if (GetColor(TPA[I].X-1, TPA[I].Y-1) - GetColor(TPA[I].X, TPA[I].Y-1) = Dif) then
begin
Result[C] := Point(TPA[I].x, TPA[i].y - 2);
Inc(C);
end;
end;
Unfreeze;
SetLength(Result, C);
end;
If someone can confirm the rest I'll commit.

Coh3n

2011-12-07 01:26:28

From: mormonman
Look at my post, I added an image. Get the color at both pixels surrounded by a green box. Subtract one on right from one on the left.
Oh, haha. Literally the difference of the two numbers. :p

E: Here it is with team dots working:

function GetMiniMapDotsIn(WhatDot: String; x1, y1, x2, y2: Integer): TPointArray;
var
I, Dif, Radius, Hi, C: Integer;
TPA: TPointArray;
begin
case LowerCase(WhatDot) of
'npc', 'n', 'yellow', 'y': Dif := 4369;
'item', 'i', 'red', 'r': Dif := 23;
'player', 'p', 'white', 'w': Dif := 1907997;
'friend', 'f', 'green', 'g': Dif := 5376;
'team', 't', 'blue', 'b', 'cape': Dif := 2171941;
{'clan', 'c', 'orange', 'o': Dif := -1;}
else
srl_Warn('GetMiniMapDotsIn', '"' + WhatDot + '" is not a valid dot type', warn_AllVersions);
end;
Freeze;
Radius := Max((x2-x1)/2, (y2-y1)/2);
FindColorsPie(TPA, 65536, 0, 0, 360, 0, radius, x1, y1, x2, y2, (x1+x2)/2, (y1+y2)/2);
Hi := High(TPA);
SetLength(Result, Hi + 1);
if (Hi < 0) then Exit;
C := 0;
for I := 0 to Hi do
begin
if (GetColor(TPA[I].X-1, TPA[I].Y-1) - GetColor(TPA[I].X, TPA[I].Y-1) = Dif) then
begin
Result[C] := Point(TPA[I].x, TPA[i].y - 2);
Inc(C);
end;
end;
Unfreeze;
SetLength(Result, C);
end;

E: Committed this for now since it works, and clan is probably never used, but can easily be added.

YoHoJo

2011-12-07 06:10:16

Pink… really?
Saw it twice when I logged in at two different times today.
Those are pinkish right…?

kingarabian

2011-12-07 06:11:58

From: YoHoJo
Pink… really?
Saw it twice when I logged in at two different times today.
Those are pinkish right…?

They are pimps :D. Interestingly you really have to look close to notice they are pink.

YoHoJo

2011-12-07 06:12:52

They stood out to me instantly, wtfaa!
I've logged in/out many times today doing things, but only twice did they appear pink.

euphemism

2011-12-07 11:25:30

Yes, no close look required. Those are very, very pink. The question is, will the legitimate player-base stand for these ridiculous color changes?

Coh3n

2011-12-07 13:37:52

From: euphemism
Yes, no close look required. Those are very, very pink. The question is, will the legitimate player-base stand for these ridiculous color changes?
I doubt it. It looks ridiculous.

Sir R. M8gic1an

2011-12-08 11:48:55

Edit2: Flag only changes when you reload client.


I suggest we add a FlagColor variable? Once found for the first time it'll then make it faster to search for the correct color than to search for a color difference…

RSColors.FlagColor, RSColors.PlayerDotColor, RSColors.NPCDotColor, etc..

… And then we could have our functions search for colors as we usually do, going through a FindColorThroughDifference function if Colour = 0

~RM

Coh3n

2011-12-08 12:29:36

Flag is working fine for me, and I've reloaded the client several times.

Home

2011-12-08 13:36:20

function FindFlagEx(var X, Y: Integer): Boolean;
var
AX, AY, XX, YY, W, H, Map : Integer;
MapColors :T2DIntegerArray;
begin
AX:= MMX2 - MMX1;
AY:= MMY2 - MMY1;
Map := BitmapFromString(MMX2 - MMX1, MMY2 - MMY1, '');
CopyClientToBitmap(Map, MMX1, MMY1, MMX2, MMY2);
SetTargetBitmap(Map);
GetBitmapSize(Map, W, H);
MapColors := GetBitmapAreaColors(Map, 0, 0, W - 1, H - 1);
for XX := 0 to AX do
for YY := 0 to AY do
If MapColors[XX][YY] = 65536 then
If MapColors[XX - 1][YY - 1] - MapColors[XX][YY - 1] = 6381921 then
begin
Result := True;
X := XX + MMX1;
Y := YY + MMY1;
end;
FreeTarget(Map);
FreeBitmap(Map);
end;

Takes 52 MS. To find.
Might be little bit slower, but should be more accurate.


~Home

mormonman

2011-12-08 16:53:17

Almost twice as fast.
function FindFlagEx(var X, Y: Integer): Boolean;
var
i, Hi, W, H, MapB,
KMTarget, ITarget : Integer;
TPA: TPointArray;
begin
MapB := BitmapFromString(MMX2 - MMX1, MMY2 - MMY1, '');
CopyClientToBitmap(MapB, MMX1, MMY1, MMX2, MMY2);
KMTarget := GetKeyMouseTarget;
ITarget := GetImageTarget;
SetTargetBitmap(MapB);
GetBitmapSize(MapB, W, H);
if FindColors(TPA, 65536, 0, 0, W - 1, H - 1) then
begin
Hi := High(TPA);
for i := 0 to Hi do
if ((FastGetPixel(MapB, TPA[i].x - 1, TPA[i].y - 1)
- FastGetPixel(MapB, TPA[i].x, TPA[i].y - 1)) = 6381921) then
begin
Result := True;
X := TPA[i].x + MMX1;
Y := TPA[i].y + MMY1;
Break;
end;
end;
FreeTarget(GetImageTarget);
FreeBitmap(MapB);
SetKeyMouseTarget(KMTarget);
SetImageTarget(ITarget);
end;

Home

2011-12-08 16:59:23

From: mormonman
Almost twice as fast.
function FindFlagEx(var X, Y: Integer): Boolean;
var
i, Hi, W, H, MapB,
KMTarget, ITarget : Integer;
TPA: TPointArray;
begin
MapB := BitmapFromString(MMX2 - MMX1, MMY2 - MMY1, '');
CopyClientToBitmap(MapB, MMX1, MMY1, MMX2, MMY2);
KMTarget := GetKeyMouseTarget;
ITarget := GetImageTarget;
SetTargetBitmap(MapB);
GetBitmapSize(MapB, W, H);
if FindColors(TPA, 65536, 0, 0, W - 1, H - 1) then
begin
Hi := High(TPA);
for i := 0 to Hi do
if ((FastGetPixel(MapB, TPA[i].x - 1, TPA[i].y - 1)
- FastGetPixel(MapB, TPA[i].x, TPA[i].y - 1)) = 6381921) then
begin
Result := True;
X := TPA[i].x + MMX1;
Y := TPA[i].y + MMY1;
Break;
end;
end;
FreeTarget(GetImageTarget);
FreeBitmap(MapB);
SetKeyMouseTarget(KMTarget);
SetImageTarget(ITarget);
end;


Yes true. :)

~Home

Wizzup?

2011-12-08 17:09:16

From: mormonman
Almost twice as fast.
function FindFlagEx(var X, Y: Integer): Boolean;
var
i, Hi, W, H, MapB,
KMTarget, ITarget : Integer;
TPA: TPointArray;
begin
MapB := BitmapFromString(MMX2 - MMX1, MMY2 - MMY1, '');
CopyClientToBitmap(MapB, MMX1, MMY1, MMX2, MMY2);
KMTarget := GetKeyMouseTarget;
ITarget := GetImageTarget;
SetTargetBitmap(MapB);
GetBitmapSize(MapB, W, H);
if FindColors(TPA, 65536, 0, 0, W - 1, H - 1) then
begin
Hi := High(TPA);
for i := 0 to Hi do
if ((FastGetPixel(MapB, TPA[i].x - 1, TPA[i].y - 1)
- FastGetPixel(MapB, TPA[i].x, TPA[i].y - 1)) = 6381921) then
begin
Result := True;
X := TPA[i].x + MMX1;
Y := TPA[i].y + MMY1;
Break;
end;
end;
FreeTarget(GetImageTarget);
FreeBitmap(MapB);
SetKeyMouseTarget(KMTarget);
SetImageTarget(ITarget);
end;


There's also BitmapFromClient, I think. This doesn't look bad and is what I had in mind. :p You could still use Freeze I suppose, but that would load the entire client (in the backend anyway), rather than only a part. So if you're going for speed this is nice. Good work both of you. Now we just need to know it this works well enough. :)

E: http://docs.villavu.com/simba/scriptref/bitmaps.html?#bitmapfromclient

weequ

2011-12-08 17:25:27

Wow mormonman that looks great! I learned something very usefull from your code. I will probably be using your method to write FindColoredAreaTolerance :)

Also is FastGetPixel faster than GetColor?

mormonman

2011-12-08 17:27:21

It worked very well during my tests.

function FindFlagEx2(var X, Y: Integer): Boolean;
var
i, Hi, W, H, MapB,
KMTarget, ITarget : Integer;
TPA: TPointArray;
begin
MapB := BitmapFromClient(MMX1, MMY1, MMX2, MMY2);
KMTarget := GetKeyMouseTarget;
ITarget := GetImageTarget;
SetTargetBitmap(MapB);
GetBitmapSize(MapB, W, H);
if FindColors(TPA, 65536, 0, 0, W - 1, H - 1) then
begin
Hi := High(TPA);
for i := 0 to Hi do
if ((FastGetPixel(MapB, TPA[i].x - 1, TPA[i].y - 1)
- FastGetPixel(MapB, TPA[i].x, TPA[i].y - 1)) = 6381921) then
begin
Result := True;
X := TPA[i].x + MMX1;
Y := TPA[i].y + MMY1;
Break;
end;
end;
FreeTarget(GetImageTarget);
FreeBitmap(MapB);
SetKeyMouseTarget(KMTarget);
SetImageTarget(ITarget);
end;

Edit: New dots function too(its 1 ms faster :0 )
function GetMiniMapDotsIn(WhatDot: String; x1, y1, x2, y2: Integer): TPointArray;
var
MapB, KMTarget, ITarget, W, H,
I, Dif, Radius, Hi, C: Integer;
TPA: TPointArray;
begin
case LowerCase(WhatDot) of
'npc', 'n', 'yellow', 'y': Dif := 4369;
'item', 'i', 'red', 'r': Dif := 23;
'player', 'p', 'white', 'w': Dif := 1907997;
'friend', 'f', 'green', 'g': Dif := 5376;
'team', 't', 'blue', 'b', 'cape': Dif := 2171941;
{'clan', 'c', 'orange', 'o': Dif := -1;}
else
srl_Warn('GetMiniMapDotsIn', '"' + WhatDot + '" is not a valid dot type', warn_AllVersions);
end;
MapB := BitmapFromClient(x1, y1, x2, y2);
KMTarget := GetKeyMouseTarget;
ITarget := GetImageTarget;
SetTargetBitmap(MapB);
GetBitmapSize(MapB, W, H);
C := 0;
if FindColors(TPA, 65536, 0, 0, W - 1, H - 1) then
begin
Hi := High(TPA);
SetLength(Result, Hi + 1);
for I := 0 to Hi do
begin
if ((FastGetPixel(MapB, TPA[i].x - 1, TPA[i].y - 1)
- FastGetPixel(MapB, TPA[i].x, TPA[i].y - 1)) = Dif) then
begin
Result[C] := Point(TPA[I].x + x1, TPA[i].y + y1 - 2);
Inc(C);
end;
end;
end;
FreeTarget(GetImageTarget);
FreeBitmap(MapB);
SetKeyMouseTarget(KMTarget);
SetImageTarget(ITarget);
SetLength(Result, C);
end;

mormonman

2011-12-08 17:44:39

From: weequ
Wow mormonman that looks great! I learned something very usefull from your code. I will probably be using your method to write FindColoredAreaTolerance :)

Also is FastGetPixel faster than GetColor?


I used fastgetpixel because its a bitmap.

Edit: Oops on the double post

Narcle

2011-12-08 17:50:38

Have to agree, your FindFlag working the best for me as well.

Wizzup?

2011-12-08 18:04:39

From: mormonman
I used fastgetpixel because its a bitmap.

Edit: Oops on the double post


I think GetColor should work on the bitmap as well, with the same speed. :)

mormonman

2011-12-08 18:14:30

From: Wizzup?
I think GetColor should work on the bitmap as well, with the same speed. :)


Run this :)

program Default;
{$DEFINE SMART}
{$i srl\srl.scar}

const
{---SMART Setup Constants---}
WORLD = 35;
MEMBERS = false;
SIGNED = true;
SUPERDETAIL = false;
{---------------------------}

var
bmp: integer;

begin
Smart_Members := MEMBERS;
Smart_Server := WORLD;
Smart_Signed := SIGNED;

SetupSRL;

Bmp := BitmapFromString(100, 65, 'meJzt2lsKgzAQBdCNtH92/xtT1' +
'1CKYNtEYyKKjxw4H8FSSC8zYyw2j64BALib9ugNXNLr+TGuD98P96' +
'VDE/qjN3BmC5VjcK2Orgb/N7h0IG3wlarEvzq6opyKohBXKNFZUx8' +
'NAbo5si2NyYbamTUk5JSN0hp9jwEZJ/nKxeHkXKlW0QlTbp25tH+q' +
'1RJCkWB2zTWmVCf9xtJHCxJxpS/CsqV/2pXWutwIhCNdgBl0X5ahl' +
'rxIs5bj1mImImJfppas4EK0IZyDR0X5bMZgL+TxEAAAgDJvqvncXA==');
SetTargetBitmap(bmp);
writeln(GetColor(1,1));
writeln(fastgetpixel(bmp,1,1));
end.

Coh3n

2011-12-09 00:30:07

mormonman, I've added your versions of FindFlag and GetMiniMapDots in to my repos. I'm running a test run over night to make sure it all works without runtime errors, and I'll commit them, along with several other bug fixes tomorrow.

E: FindFlag seems to be working, but GetMiniMapDotsIn returns 0 points, no matter which kind of dot I try.

E2: FindFlag seems to work when I test like writeln(booltoStr(flagPresent)));, but when I use it in a loop, like this, it ALWAYS returns true, even when the player has stopped walking.

mouse(577, 131, 3, 3, true);
while (flagPresent) do
wait(50);
Could be something stupid I'm overlooking, it's late. >.<

E: Seems like it always returns true after it's found it once.

Wizzup?

2011-12-09 05:22:13

From: mormonman
Run this :)

program Default;
{$DEFINE SMART}
{$i srl\srl.scar}

const
{---SMART Setup Constants---}
WORLD = 35;
MEMBERS = false;
SIGNED = true;
SUPERDETAIL = false;
{---------------------------}

var
bmp: integer;

begin
Smart_Members := MEMBERS;
Smart_Server := WORLD;
Smart_Signed := SIGNED;

SetupSRL;

Bmp := BitmapFromString(100, 65, 'meJzt2lsKgzAQBdCNtH92/xtT1' +
'1CKYNtEYyKKjxw4H8FSSC8zYyw2j64BALib9ugNXNLr+TGuD98P96' +
'VDE/qjN3BmC5VjcK2Orgb/N7h0IG3wlarEvzq6opyKohBXKNFZUx8' +
'NAbo5si2NyYbamTUk5JSN0hp9jwEZJ/nKxeHkXKlW0QlTbp25tH+q' +
'1RJCkWB2zTWmVCf9xtJHCxJxpS/CsqV/2pXWutwIhCNdgBl0X5ahl' +
'rxIs5bj1mImImJfppas4EK0IZyDR0X5bMZgL+TxEAAAgDJvqvncXA==');
SetTargetBitmap(bmp);
writeln(GetColor(1,1));
writeln(fastgetpixel(bmp,1,1));
end.


Ah. That's because SMART is overriding the Simba GetColor method. Nothing we can do about that, until SMART adds support for EIOS.

Narcle

2011-12-09 05:26:21

From: Coh3n
mormonman, I've added your versions of FindFlag and GetMiniMapDots in to my repos. I'm running a test run over night to make sure it all works without runtime errors, and I'll commit them, along with several other bug fixes tomorrow.

E: FindFlag seems to be working, but GetMiniMapDotsIn returns 0 points, no matter which kind of dot I try.

E2: FindFlag seems to work when I test like writeln(booltoStr(flagPresent)));, but when I use it in a loop, like this, it ALWAYS returns true, even when the player has stopped walking.

mouse(577, 131, 3, 3, true);
while (flagPresent) do
wait(50);
Could be something stupid I'm overlooking, it's late. >.<

E: Seems like it always returns true after it's found it once.


Yeah what seems to work best for me is FFlag(10) to 20 with mormonman's FindFlag, but it still seems off sometimes.

What it looks like so far is the color doesn't change unless you reload the client. I'm going to try a different approach by getting a temporary flag color and use that for FindFlag afterwards.

BraK

2011-12-09 06:07:23

Doesn't one point on the flag never change color? If so you could get all the colors Around that spot in a box. Then get rid of all the color that have a duplicate. By get rid of I mean remove completely not clear duplicates that still leaves one of the color in the Array. After that you can take all the Remaining colors and do a count color tolerance for the Correct amount of colors. Then make the Colors of the Flag dynamic.

That's the general Idea Anyway. Hope I explained it properly.

Narcle

2011-12-09 07:43:12

From: BraK
Doesn't one point on the flag never change color? If so you could get all the colors Around that spot in a box. Then get rid of all the color that have a duplicate. By get rid of I mean remove completely not clear duplicates that still leaves one of the color in the Array. After that you can take all the Remaining colors and do a count color tolerance for the Correct amount of colors. Then make the Colors of the Flag dynamic.

That's the general Idea Anyway. Hope I explained it properly.


Ahh, yes good idea. I will try this.

WT-Fakawi

2011-12-09 07:50:40

Or, you could grab the color of the flag once, and keep it in memory while we are still in the same session. I believe the flag color is stable for the session as long as you stay logged in, no?
That would keep things simple. You might do a click on MMcentre once to grab the Flag color at script startup, and from that monent on do a simple findcolor like we used to do.

Wizzup?

2011-12-09 07:53:39

If the flag is on top of everything else, a FindBitmapTolerance should also work, no? (With 0 as transparent colour)

BraK

2011-12-09 07:54:57

From: WT-Fakawi
Or, you could grab the color of the falg once, and keep it in memory while we are still in the same session. I believe the flag color is stable for the session as long as you stay logged in, no?
That would keep things simple. You might do a click on MMcentre once to grab the Flag color at script startup, and from that monent on do a simple findcolor like we used to do.


That's the end result I was talking about but the color Spectrum they are using currently is so wide you have to get the colors dynamicly during runtime on the start up. What I was discribing was like GetFlagColors to be used in conjunction with FindFlag.

Narcle

2011-12-11 00:36:45

I've looked at it more and come to a conclusion of sorts.

The flag changes color after an initial click. When you first click it its a lighter color very subtle and then shortly after stays a more darker color.

Our current methods just aren't fast enough from grabbing from the screen. Freeze should work but doesn't fully (no clue why). Currently the best FindFlag is mormonman's which I'm going to commit for now.

Edit:
Maybe not, I'm not getting delays with it. /sigh

Coh3n

2011-12-11 01:44:41

Has anyone tried a simple findColors with tolerance and some split/sort TPA work? I don't see why that wouldn't work. I'm still convinced that the major change in colour of the flag is a bug in RS (the same with the pink dots on the MM).

Narcle

2011-12-11 01:54:07

From: Coh3n
Has anyone tried a simple findColors with tolerance and some split/sort TPA work? I don't see why that wouldn't work. I'm still convinced that the major change in colour of the flag is a bug in RS (the same with the pink dots on the MM).


I've been trying some things via TPA to findflag. But don't have the correct TPA sort/find functions in Simba to make it faster.

I've even been trying something like this which works in theory but the speed/functions aren't there. Also this errors if it doesn't find colors /sigh

Function FindFlag(var X, Y: Integer): Boolean;
var
i: integer;
TPA1, TPA2, FlagTPA, TempTPA, MTPA: TPointArray;
begin
FlagTPA := [Point(5, 0), Point(4, 1), Point(4, 2), Point(3, 3), Point(4, 3),
Point(2, 4), Point(3, 4), Point(4, 4), Point(1, 5), Point(2, 5),
Point(3, 5), Point(4, 5), Point(0, 6), Point(1, 6), Point(2, 6)];
FindColorsSpiralTolerance(MMCX, MMCY, TPA1, 65536, MMX1, MMY1, MMX2, MMY2, 0);
FindColorsSpiralTolerance(MMCX, MMCY, TPA2, 14333, MMX1, MMY1, MMX2, MMY2, 40);

H := High(TPA1);

for i := 0 to H do
begin
TempTPA := CopyTPA(FlagTPA);
OffsetTPA(TempTPA, Point(TPA[i].x-6, TPA[i].y-14));
GetSamePointsATPA([TPA2, TempTPA], MTPA);
if Length(MTPA) = Length(FlagTPA) then
begin
Result := true;
X := TPA[i].x;
Y := TPA[i].y;
Exit;
end;
end;
end;

Coh3n

2011-12-11 01:57:21

Hmm, I feel like we might be over thinking it. What method did we use previously?

mormonman

2011-12-17 18:20:50

This should work better.
function GetMiniMapDotsIn(WhatDot: String; x1, y1, x2, y2: Integer): TPointArray;
var
MapB, KMTarget, ITarget, W, H,
I, Dif, Radius, Hi, C: Integer;
TPA: TPointArray;
P1, P2: TPoint;
begin
case LowerCase(WhatDot) of
'npc', 'n', 'yellow', 'y': Dif := 4369;
'item', 'i', 'red', 'r': Dif := 23;
'player', 'p', 'white', 'w': Dif := 1907997;
'friend', 'f', 'green', 'g': Dif := 5376;
'team', 't', 'blue', 'b', 'cape': Dif := 2171941;
{'clan', 'c', 'orange', 'o': Dif := -1;}
else
srl_Warn('GetMiniMapDotsIn', '"' + WhatDot + '" is not a valid dot type', warn_AllVersions);
end;
MapB := BitmapFromClient(x1, y1, x2, y2);
KMTarget := GetKeyMouseTarget;
ITarget := GetImageTarget;
SetTargetBitmap(MapB);
GetBitmapSize(MapB, W, H);
C := 0;
if FindColors(TPA, 65536, 0, 0, W - 1, H - 1) then
begin
Hi := High(TPA);
SetLength(Result, Hi + 1);
for I := 0 to Hi do
begin
P1 := Point(TPA[i].x + 1, TPA[i].y);
P2 := Point(TPA[i].x + 2, TPA[i].y);
if PointInBox(P1, IntToBox(0, 0, W - 1, H - 1))
and PointInBox(P2, IntToBox(0, 0, W - 1, H - 1)) then
if ((FastGetPixel(MapB, P1.x, P1.y)
- FastGetPixel(MapB, P2.x, P2.y)) = Dif) then
begin
Result[C] := Point(TPA[I].x + x1 + 2, TPA[i].y + y1 - 1);
Inc(C);
end;
end;
end;
FreeTarget(GetImageTarget);
FreeBitmap(MapB);
SetKeyMouseTarget(KMTarget);
SetImageTarget(ITarget);
SetLength(Result, C);
RAaSTPA(TPA, 3);
end;

legoace

2011-12-18 10:43:56

From: Coh3n
I'm still convinced that the major change in colour of the flag is a bug in RS (the same with the pink dots on the MM).


These are obviously not bugs. They are directed at stopping us. You have to realize this. Jagex is actively attacking us.

I'm not saying it like it's anything to be more worried about, but continuing to call these "bugs" is frankly ignorant.

Brandon

2011-12-18 19:46:35

I don't know if this was never fix.. but I think it may be broken AGAIN..

I noticed: When the bot clicks the minimap, flag is bright red.. When character starts moving, flag is dark red.. The same goes for the flag stick.. Is this just happening to me alone? or anyone else?

Character doesn't know that it reached the flag.. I have to use while (ismoving) do wait(1);

Narcle

2011-12-18 20:07:08

From: ggzz
I don't know if this was never fix.. but I think it may be broken AGAIN..

I noticed: When the bot clicks the minimap, flag is bright red.. When character starts moving, flag is dark red.. The same goes for the flag stick.. Is this just happening to me alone? or anyone else?

Character doesn't know that it reached the flag.. I have to use while (ismoving) do wait(1);


No it happens, and yes I knew about the color change and checked it. It still is same color difference though so technically it should still detect it… but randomly it doesn't, what I'm curious about is WHY…

Any suggestions not already tried?

mormonman

2011-12-18 20:15:19

Narcle can you commit my last function? It is incredibly more stable.

Narcle

2011-12-18 20:30:00

Yes I will. There's other stuff I need to commit later tonight as well will do it then.

Edit: Success!
Fixed FindFlag!!!! Added bmpFlag to global call
Fixed FindNPCChatText will now search for more then one word at a time (its not the best fix though)
Added mormonman's GetMiniMapDotsIn
Removed unneeded call in SRL for text shadow

Home

2011-12-27 11:21:43

Fastest and most accurate Flag.


function FindFlag(var X, Y: Integer): Boolean;
var
KMTarget, ITarget, I, Hi, Map, W, H: Integer;
TPA: TPointArray;
begin
Result := False;
Map := BitmapFromString(MMX2 - MMX1, MMY2 - MMY1, '');
CopyClientToBitmap(Map, MMX1, MMY1, MMX2, MMY2);
KMTarget := GetKeyMouseTarget;
ITarget := GetImageTarget;
SetTargetBitmap(Map);
GetBitmapSize(Map, W, H);
FindColors(TPA, 65536, 0, 0, W - 1, H -1);
FilterPointsDist(TPA, 0, 75.5, W / 2, H / 2);
Hi := Length(TPA);
for I := 0 to Hi - 1 do
if ((FastGetPixel(Map, TPA[I].X - 1, TPA[I].Y - 1) - FastGetPixel(Map, TPA[I].X, TPA[I].Y - 1)) = 6381921) then
begin
Result := True;
X := TPA[I].X + MMX1;
Y := TPA[I].Y + MMY1;
Break;
end;
FreeTarget(GetImageTarget);
FreeBitmap(Map);
SetKeyMouseTarget(KMTarget);
SetImageTarget(ITarget);
end;


~Home

Brandon

2011-12-27 11:30:06

From: Home
Fastest and most accurate Flag.
~Home



Testing it atm.. I have to say it finds the flag much faster than before.. Problemo though:

Every time it reaches the flag, it will wait till a complete stop even if I have FFlag(10); Using SPS_WalkPath(TPointArray);



Edit:

What is with the Simba tags.. I've noticed sometimes when editing a post or quoting one, the simba tags get sooo messed up :S

Home

2011-12-27 11:32:43

From: ggzz
Testing it atm.. I have to say it finds the flag much faster than before.. Problemo though:

Every time it reaches the flag, it will wait till a complete stop even if I have FFlag(10); Using SPS_WalkPath(TPointArray);



Edit:

What is with the Simba tags.. I've noticed sometimes when editing a post or quoting one, the simba tags get sooo messed up :S


Thanks for your input, I will try re produce problem. (I don't use SPS) I will check out SPS walkpath function.


Edit: Something is wrong with SPS walkPath.




~Home

DeSnob

2011-12-28 10:20:33

From: Home
blah


Thank you Home. SRL's function doesn't work properly. Yours however, works just fine.

Claymore

2011-12-29 03:27:14

From: Home
Fastest and most accurate Flag.


function FindFlag(var X, Y: Integer): Boolean;
var
KMTarget, ITarget, I, Hi, Map, W, H: Integer;
TPA: TPointArray;
begin
Result := False;
Map := BitmapFromString(MMX2 - MMX1, MMY2 - MMY1, '');
CopyClientToBitmap(Map, MMX1, MMY1, MMX2, MMY2);
KMTarget := GetKeyMouseTarget;
ITarget := GetImageTarget;
SetTargetBitmap(Map);
GetBitmapSize(Map, W, H);
FindColors(TPA, 65536, 0, 0, W - 1, H -1);
FilterPointsDist(TPA, 0, 75.5, W / 2, H / 2);
Hi := Length(TPA);
for I := 0 to Hi - 1 do
if ((FastGetPixel(Map, TPA[I].X - 1, TPA[I].Y - 1) - FastGetPixel(Map, TPA[I].X, TPA[I].Y - 1)) = 6381921) then
begin
Result := True;
X := TPA[I].X + MMX1;
Y := TPA[I].Y + MMY1;
Break;
end;
FreeTarget(GetImageTarget);
FreeBitmap(Map);
SetKeyMouseTarget(KMTarget);
SetImageTarget(ITarget);
end;


~Home


Currently works for my scripts.

Narcle

2011-12-29 07:51:38

I figured it out. Its not FindFlag making it wrong. In fact because that function is slower it makes it higher chance to detect it. They make the flag disappear randomly for 100-250ms so fast you don't even see it do it (most of the time).

Tricky little bastards.

Home

2011-12-30 14:51:45

From: Narcle
I figured it out. Its not FindFlag making it wrong. In fact because that function is slower it makes it higher chance to detect it. They make the flag disappear randomly for 100-250ms so fast you don't even see it do it (most of the time).

Tricky little bastards.


I'v thought a fix for this.

Yes this is ugly but this works.

FFlag(10);
FFlag(10);

~Home :P

Narcle

2011-12-30 15:26:09

I have it resolved in SRL5.

HardRockers

2012-01-01 23:54:38

Flag; Is now not working for me, but only in certain locations.

At Yanille it worked, Now I am trying to use it near Seers, and its not working at all. I used the same procedure in both places, just different colors and positions.


Procedure WalkToSpinner;

Begin
if not LoggedIn then Exit;
FindNormalRandoms;
ClickNorth(True);
Walking(2717036, 20, Point(576, 59));
Flag;
Walking(733019, 20, Point(611, 35));
Flag;
Walking(5405324, 20, Point(601, 65));
Flag;
End;

Daniel

2012-01-02 00:56:58

From: Narcle
I figured it out. Its not FindFlag making it wrong. In fact because that function is slower it makes it higher chance to detect it. They make the flag disappear randomly for 100-250ms so fast you don't even see it do it (most of the time).

Tricky little bastards.


No it doesn't?


program FlagTracker;
{$i SRL\SRL.scar}

var
x, y: Integer;
Found: Boolean;

begin
ActivateClient;
Writeln('You now have 2 seconds to place a flag');
Sleep(2000);
repeat
Found := FindColor(x, y, 17378, MMX1, MMY1, MMX2, MMY2);
MoveMouse(x, y);
Writeln(Found);
Until(IsKeyDown(VK_F4));
end.

Always was spewing out True until I personally saw the flag disappear, which was when it was spewing out False. It is incredibly fast (since it is a static colour with no tolerance comparison), and I deliberately placed the flag in the top-left corner (which is the area first to be found by FindColor).

Narcle

2012-01-02 06:56:11

From: HardRockers
Flag; Is now not working for me, but only in certain locations.

At Yanille it worked, Now I am trying to use it near Seers, and its not working at all. I used the same procedure in both places, just different colors and positions.


Procedure WalkToSpinner;

Begin
if not LoggedIn then Exit;
FindNormalRandoms;
ClickNorth(True);
Walking(2717036, 20, Point(576, 59));
Flag;
Walking(733019, 20, Point(611, 35));
Flag;
Walking(5405324, 20, Point(601, 65));
Flag;
End;


Recent Simba update messed up FindBitmap making FindFlag messed up.

From: Daniel
No it doesn't?


program FlagTracker;
{$i SRL\SRL.scar}

var
x, y: Integer;
Found: Boolean;

begin
ActivateClient;
Writeln('You now have 2 seconds to place a flag');
Sleep(2000);
repeat
Found := FindColor(x, y, 17378, MMX1, MMY1, MMX2, MMY2);
MoveMouse(x, y);
Writeln(Found);
Until(IsKeyDown(VK_F4));
end.

Always was spewing out True until I personally saw the flag disappear, which was when it was spewing out False. It is incredibly fast (since it is a static colour with no tolerance comparison), and I deliberately placed the flag in the top-left corner (which is the area first to be found by FindColor).


Wait what? Are you saying it does or doesn't disappear bc… I have like 50 screen shots to prove otherwise lol.

Daniel

2012-01-03 03:53:04

From: Narcle
Wait what? Are you saying it does or doesn't disappear bc… I have like 50 screen shots to prove otherwise lol.


Nope, it doesn't. It didn't even in Al-Kharid for me, where you said it "definitely" does. :-/