SRL Archive - SRL Archives

New, GetVarrockRoadColor


Wizzup?

2007-05-29 10:09:35

EDIT:

From: nielsie95
Nice! This works for every road for me! :) (Draynor, Falador, Varrock).



program New;

{.include SRL/SRL.scar}

Var
RColor: Integer;

Function ClearTPointArray(a: TPointArray): TPointArray;

Var
I, C: Integer;

Begin
For I := 0 To GetArrayLength(a) - 1 Do
If rs_OnMiniMap(a[i].x, a[i].y) Then
Begin
C := C + 1;
SetArrayLength(Result, C + 1);
Result[C] := a[i];
End;
End;

Function NumberDoesntExist(Ar2: Array Of Integer; Number: Integer): Boolean;

Var
I: Integer;
Begin
Result := False;
For I := 0 To GetArrayLength(Ar2) - 1 Do
If Ar2[I] = Number Then
Exit;
Result := True;
End;

Function ShrinkArray(YourArray: Array Of Integer): Array Of Integer;

Var
I: Integer;

Begin
SetArrayLength(Result, 0);
For I := 0 To GetArrayLength(YourArray) - 1 Do
Begin
If NumberDoesntExist(Result, YourArray[I]) Then
Begin
SetArrayLength(Result, GetArrayLength(Result) + 1);
Result[GetArrayLength(Result) - 1] := YourArray[I];
End;
End;
End;

Function GetVarrockRoadColor: Integer;

Var
Points: TPointArray;
Colors, Colors2, Colors3, Amount, Amount2: Array Of Integer;
I, iZ: Integer;
myZ: Extended;
X, Y, Z: Array Of Extended;


Begin
ColorToleranceSpeed(0);
FindColorsTolerance(Points, RColor, MMX1, MMY1, MMX2, MMY2, 50);
Points := ClearTPointArray(Points);
Colors := ShrinkArray(GetColors(Points));
SetArrayLength(Amount, GetArrayLength(Colors));

For I := 0 To GetArrayLength(Colors) - 1 Do
Begin
Amount[i] := CountColor(Colors[I], MMX1, MMY1, MMX2, MMY2);
// If Amount[I] > 50 Then WriteLn('Color ' + IntToStr(Colors[I]) + ': '+IntToStr(Amount[I]));
End;

For I := 0 To GetArrayLength(Colors) - 1 Do
Begin
If Amount[I] > 200 Then // You might want to tweak the 200.
Begin
SetArrayLength(Amount2, GetArrayLength(Amount2) + 1);
SetArrayLength(Colors2, GetArrayLength(Colors2) + 1);
Amount2[GetArrayLength(Amount2) - 1] := Amount[I];
Colors2[GetArrayLength(Colors2) - 1] := Colors[I];
End;
End;
SetArrayLength(X, GetArrayLength(Colors2));
SetArrayLength(Y, GetArrayLength(Colors2));
SetArrayLength(Z, GetArrayLength(Colors2));

For I := 0 To GetArrayLength(Colors2) - 1 Do
Begin
ColorToXYZ(Colors2[I], X[I], Y[I], Z[I]);
If (X[I] > 10) And (X[I] < 30) And (Y[I] > 10) And (Y[I] < 30)
And (Z[I] > 10) And (Z[I] < 30) Then
Begin
SetArrayLength(Colors3, GetArrayLength(Colors3) + 1);
Colors3[GetArrayLength(Colors3) - 1] := Colors2[I];
AddToReport('Color['+IntToStr(I)+']: ' + IntToStr(Colors3[GetArrayLength(Colors3) - 1]));
End;
End;
MyZ := 0;
For I := 0 To GetArrayLength(Colors3) - 1 Do
Begin
If MaxE(Z[I], MyZ) <> MyZ Then
Begin
iZ := I;
MyZ := MaxE(Z[I], MyZ);
End;
End;
If iZ < GetArrayLength(Colors3) Then Result := Colors3[iZ]
Else Result := -1;
WriteLn('The Color is: '+IntToStr(Result));
End;

Var
I1, I2: LongInt;

begin
SetupSRL;
ClearDebug;
RColor := 8357513;
Repeat
I1 := GetSystemTime;
GetVarrockRoadColor;
I2 := GetSystemTime;
WriteLn(InttoStr(I2-I1));
Wait(1000);
ClearReport;
Until False;
end.

Pentti

2007-05-29 10:12:07

Yeah! At last! :D
Thanks!

WhiteShadow

2007-05-29 19:14:45

Quick, and effective. :]

I'll have to look into XYZ later. =\

Buckleyindahouse

2007-05-29 19:56:18

WOW, that code looks so confusing lol. Anyways nice work Wizzy.

WhiteShadow

2007-05-29 20:05:40

From: Buckleyindahouse
WOW, that code looks so confusing lol. Anyways nice work Wizzy.


Well, when you come to a certain point it isn't anymore. You'll have to effectively understand arrays, TPoints, and TPointArrays. After that, just look into aspects of colors. HSL, RGB, XYZ(this one). Even when colors are visually very different and dynamic, they all have similarities(value ranges) when you convert down to it's (base values[Hue, Saturation, Luminance, Red, green, blue, xyz? (don't know shiet about that one) Wizzup explain a bit pl0x.) if you will.

Wizzup?

2007-05-30 02:37:54

http://en.wikipedia.org/wiki/CIE_1931_color_space

WhiteShadow

2007-05-30 02:44:47

From: Wizzup?
http://en.wikipedia.org/wiki/CIE_1931_color_space


Yeah, I really wanted to read all that..thanks. (h) :p

I must of read 20 pages of research today history report (ew..). :[

da_professa

2007-05-31 00:50:44

This code only works for divi :(..

Bobarkinator

2007-05-31 01:06:48

XYZ…blah

Wizzup?

2007-05-31 01:54:37

From: da_professa
This code only works for divi :(..


Yes.. it uses GetColors();
Just switch to Scar Divi already man, it rocks!

rkroxpunk

2007-05-31 07:00:44

hmmm is it still working for u Wizz? stopped for me on my update for VEM

Wizzup?

2007-05-31 09:45:48

From: rkroxpunk
hmmm is it still working for u Wizz? stopped for me on my update for VEM


Huh? I'll try it again..

EDIT: Yup, still works.

rkroxpunk

2007-05-31 10:01:19

:s well hmm take a look at this


I was using that exact radial in exact same spot, with it clearly covering the road and it didn't work :s

I'd post the code but I accidentally just deleted every single script I ever made. The Josh is grumpy…..:fiery:

Sumilion

2007-05-31 10:04:59

Wonderfull :)

nielsie95

2007-06-01 14:09:13

Nice! This works for every road for me! :) (Draynor, Falador, Varrock).

Rune Hacker

2007-06-03 20:54:15

Wizzup, your a freak, no one should make soemthign that confusing lol. I guess good job, but this still looks creepy lol. Makes absolutely NO sense to me.

Wizzup?

2007-06-04 02:52:33

From: Rune Hacker
Wizzup, your a freak, no one should make soemthign that confusing lol. I guess good job, but this still looks creepy lol. Makes absolutely NO sense to me.


Thanks.. I guess.. ;)

Wanted

2007-06-13 18:02:49

This is the most 1337 chunk of code I've ever seen, I didn't even know CIE XYZ color space was in SCAR O_O.

This defiantly opens up a window of opportunities for me thanks man…

Rune Hacker

2007-06-13 19:21:59

From: Icefire908

This defiantly opens up a window of opportunities for me thanks man…

Yeah, it opens up a new window of oportunity….IF you get any of it which I don't :D . By looking at it I have no idea how ot works or anything, makes 0% sense to me :redface:

Wizzup?

2007-06-14 09:38:26

From: Icefire908
This is the most 1337 chunk of code I've ever seen, I didn't even know CIE XYZ color space was in SCAR O_O.

This defiantly opens up a window of opportunities for me thanks man…


Glad it helped. :)

Wanted

2007-06-14 12:55:14

I'm just curious to know, what method do you most for finding XYZ and HSL?

I've recently been inspired to learn RBG, HSL, and XYZ :)

Edit: Nvm…

procedure ColortoXYZ(Color: TColor; var X, Y, Z: Extended);
Converts a Color to XYZ values of the CIE color space.

Another Edit:

From: Rune Hacker
Yeah, it opens up a new window of oportunity….IF you get any of it which I don't :D . By looking at it I have no idea how ot works or anything, makes 0% sense to me :redface:


Well, from what I see Wizzup? is finding an array of colors FindColorsTolerance(Points, RColor, MMX1, MMY1, MMX2, MMY2, 50); then turning the value of the color into XYZ color space values, then he is using this

For I := 0 To GetArrayLength(Colors2) - 1 Do
Begin
ColorToXYZ(Colors2[i], X[i], Y[i], Z[i]);
If (X[i] > 10) And (X[i] < 30) And (Y[i] > 10) And (Y[i] < 30)
And (Z[i] > 10) And (Z[i] < 30) Then
Begin
SetArrayLength(Colors3, GetArrayLength(Colors3) + 1);
Colors3[GetArrayLength(Colors3) - 1] := Colors2[i];
AddToReport('Color['+IntToStr(I)+']: ' + IntToStr(Colors3[GetArrayLength(Colors3) - 1]));
End;

As you can see he's checking the XYZ values using greater and less than signs to return a matching color.

It's a little more complicated, but it's basically using more than just the decimal value of a color to check to see if its the right color.

WhiteShadow

2007-06-14 17:11:18

From: Icefire908
As you can see he's checking the XYZ values using greater and less than signs to return a matching color.


He is creating a new array that holds colors that qualify his x, y, z values. After that he makes sure all the Z values are <> to 0. Result := Colors3(iz) is the current loop it was on that worked. So it's then color number iz.. is the resulting color.

That's what I read, just now.

This function has way to much array assortment involved ! >:]

Wanted

2007-06-14 18:28:49

Meh!

You can never have to many arrays!