SRL Archive - OSR Help

How do I autocolor MM object if colors keep changing?


Cstrike

2010-07-12 12:40:55

Too long; dont read [tl;dr] at the bottom

Lets say I'm walking to the Battlefield in members, and for all you F2P, see the nice map below:
[sorry map is huge :(]


Red = Where I MAY end up
Blue = where I will travel
Other colors = Reference

^^ I'm stuck on the references.

Here is my question:
How do I make a script that will detect these trees/rocks on the minimap without knowing the color because they change? DDTM?

This is the only thing hindering me at the moment. The stupid color changing is making my life a living hell. I know how to AutoColor a road of my choosing, but I can't make it find the rock too well because my spot keeps changing.

… or are rocks/trees objects that don't change color too much?

… or, if I get a generic color, is there a way to add enough tolerance so it will find that color?

Could I [D]DTM between the two trees/rocks?
All that I need is the ability to flawlessly (for the most part, I don't need some advanced script) detect the desired minimap markers. I have reflection but I need failsafes and want a script to work if reflection blows up again. Actually the trees seem like a bad idea because they arent the same that much, but any input is greatly appreciated.
Thanks

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

tl;dr
How can I autocolor the rocks/trees so my character knows he's at the right point? Since the colors change, and my char may not end up on the same spot, meaning I can't always do GetColor (at some point) since the coordinates will be off always due to randomness?

NCDS

2010-07-12 12:46:12

Just use

FindColorsTolerance()

Look through the 'Color' functions in Simba's function list ;)

Cigue

2010-07-12 12:47:26

I think you're right to look into DDTMs. I personally don't use them since I haven't found them to be reliable, but your situation looks like just the point where you'd need them.

Otherwise, I'd advise you to make an autocolor using ACA v2 in your SCAR/SRL/Scripting Tools folder. Just log in, take a few colors, CTS2, mark best color, save them, rinse and repeat.

If you don't know how to make a finder function out of an autocolor, PM me :)

Cstrike

2010-07-12 12:51:55

From: NCDS
Just use

FindColorsTolerance()

Look through the 'Color' functions in Simba's function list ;)


So just so I have this straight, lets say I log onto world XYZ and get color 800000, if I use

Warning: Pseudo-code below

begin
FindColorsTolerance ({TpointArrayHere}, 800000, xs, ys, xe, ye, TolInc);
if not find ('color I want' with FindColorsTolerance) then
inc(TolInc, 50); // increase tolerance
end.

Using that pseudo-code, I would be able to find a color near 800000? I have ACA, but I've had bad luck with tolerances finding objects.

Would my logic be correct with that above? Get a generic color from a world, then do FindColorsTolerance, and if it finds nothing… increase tolerance

Is there an upper bound for tolerance levels? I'm unfamiliar with how big of a number is too big– though I always got the impression anything over 50 is too large.
Though thanks very much! hopefully this is what I was missing :)!!





——————————-
——————————-

From: Cigue
I think you're right to look into DDTMs. I personally don't use them since I haven't found them to be reliable, but your situation looks like just the point where you'd need them.

Otherwise, I'd advise you to make an autocolor using ACA v2 in your SCAR/SRL/Scripting Tools folder. Just log in, take a few colors, CTS2, mark best color, save them, rinse and repeat.

If you don't know how to make a finder function out of an autocolor, PM me :)


Awesome
My only question would be, if I pick a DTM at point X,Y on the minimap, and then it finds it at X+25,Y+25, will it still find it?

Shuttleu

2010-07-12 13:15:18

see here: http://villavu.com/forum/showthread.php?t=45163

~shut

NCDS

2010-07-12 13:29:05

From: cstrike
So just so I have this straight, lets say I log onto world XYZ and get color 800000, if I use

Warning: Pseudo-code below

begin
FindColorsTolerance ({TpointArrayHere}, 800000, xs, ys, xe, ye, TolInc);
if not find ('color I want' with FindColorsTolerance) then
inc(TolInc, 50); // increase tolerance
end.

Using that pseudo-code, I would be able to find a color near 800000? I have ACA, but I've had bad luck with tolerances finding objects.

Would my logic be correct with that above? Get a generic color from a world, then do FindColorsTolerance, and if it finds nothing… increase tolerance

Is there an upper bound for tolerance levels? I'm unfamiliar with how big of a number is too big– though I always got the impression anything over 50 is too large.
Though thanks very much! hopefully this is what I was missing :)!!



var
Tol: Integer;
begin
Tol := 8;
repeat
FindColorsTolerance ({TpointArrayHere}, 800000, xs, ys, xe, ye, TolInc);
if Length({TPointArray}) > 0 then // That's how you would check to see if it returned anything
Break;
IncEx(Tol, 2); // increase tolerance
until(Tol > 20);
end.

Usually I would consider a Tolerance of even 10 a little high :p

Blumblebee

2010-07-12 13:31:05

I do this:

procedure SortColors(var Colors: tIntegerArray; col: Integer);
var
tempB: tIntegerArray;
Tol: ShortInt;
I: Integer;
timer, L: LongInt;
begin
timer := getsystemtime;
tempB := Colors;
SetArrayLength(Colors, 0);
Tol := 0;
while Length(Colors) < (Length(tempB)/2 or 5) do //this lines fucked I know haha
begin
if Getsystemtime-timer > 100 then Break;
for i := 0 to High(tempB) do
begin
if SimilarColors(tempB[i], col, Tol) then
begin
L := GetArrayLength(Colors);
SetArrayLength(Colors, L+1);
Colors[L] := tempB[i];
end;
if Tol > 10 then Break;
Inc(Tol);
end;
end;
end;

function AutoColorMM(const color: Integer): Integer;
var
TPA: tPointArray;
List: tIntegerArray;
I: Integer;
begin
for i := 0 to 8 do
begin
FindColorsTolerance(TPA, color, MMx1, MMy1, MMx2, MMy2, 2+i);
if Length(TPA) > 0 then Break;
end;
if Length(TPA) <= 0 then
Exit;
List := getColors(TPA);
sortColors(List, color);
if Length(List) <= 0 then Exit;
result := List[0];
end;

it's a lot easier than it looks but your idea of raising the tolerance until the color is found is what I use aswell.

Shuttleu

2010-07-12 13:40:22

use ACA but use Tolerance Speed 2 instead of 1 and when you create it, tick all of the boxes (RGB, HSL, XYZ and Spiral Search)

~shut

HyperSecret

2010-07-12 13:41:46

Yes I would use ACA if you don't know how to create your own autocolor functions. Grab 8+ colors of each rock and tree, depending on which you want to find.

Then use the autocolor function from ACA to get the color and use a DDTM to reference that area.