SRL Archive - SRL Archives

My code


n3ss3s

2008-01-26 17:09:27

From now on, I will post my functions only here, and functions less "significant" will only be edited instead of getting their own post.


To start…:


Function FindWhirlPool(x1, y1, x2, y2: Integer): Boolean;
Var
CTS, X, Y, L, C, I, WM: Integer;
wPools: Array of TPointArray;
wPts: TPointArray;
TB: TBox;
Begin
If Not LoggedIn Then Exit;
CTS := GetColorToleranceSpeed;
If Not CTS = 2 Then ColorToleranceSpeed(2);
FindColorsSpiralTolerance(MSCX, MSCY, wPts, 14935266, x1, y1, x2, y2, 15);
wPools := SplitTPA(wPts, 1);
L := High(wPools);
SetArrayLength(wPts, 0);
For I := 0 To L Do
If GetArrayLength(wPools[i]) >= 20 Then
Begin
SetArrayLength(wPts, GetArrayLength(wPools[i]));
wPts := wPools[i];
Result := True;
Break;
End;
If Result Then
Begin
MouseFindFlag(MMCX, MMCY, 1, 1);
Writeln('*** FOUND WHIRLPOOL ***');
FFlag(0);
TB := BoxFromTPA(wPts);
MiddleTPAEx(wPts, X, Y);
C := GetColor(X, Y);
WM := GetSystemTime;
While FindColorTolerance(X, Y, C, TB.x1, TB.y1, TB.x2, TB.y2, 5) Do
If GetSystemTime - WM > 12000 + Random(1000) Then
Break;
End;
ColorToleranceSpeed(CTS);
End;


and something I had this nice idea of using in a rock finder:


Function GrabTPA(TPA: TPointArray; x1, y1, x2, y2: Integer): TPointArray;
Var
I, Z, L: Integer;
B: TBox;
Begin
L := High(TPA);
B := IntToBox(x1, y1, x2, y2);
SetArrayLength(Result, GetArrayLength(TPA));
For I := 0 To L Do
If PointInBox(TPA[i], B) Then
Begin
Result[i] := TPA[i];
Z := Z + 1;
End;
SetArrayLength(Result, Z);
End;

The idea was to take a TPA of the mud, then the bounds of the mud tpa, and "grab the tpa there" and get the percent of the ore in the mud.




Function GetPlayers: Integer;
Var
TPAA: Array of TPointArray;
TPA: TPointArray;
I, CTS: Integer;
Begin
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
FindColorsTolerance(TPA, 16711422, MMCX - 35, MMCY - 35, MMCX + 35, MMCY + 35, 5);
TPAA := TPAToATPAEx(TPA, 4, 4);
For I := 0 To High(TPAA) Do
If GetArraylength(TPAA[i]) >= 10 Then
Result := Result + 1;
ColorToleranceSpeed(CTS);
End;




Function RadialTPAWalk(Color: Integer; MinPix, SR, ER, MinD, MaxD, M: Integer): Boolean;
Var
TPAA: Array of TPointArray;
X, Y, Z, I, S, E: Integer;
TPA: TPointArray;
Begin
FindColorsSpiralTolerance(MMCX, MMCY, TPA, Color, MMX1, MMY1, MMX2, MMY2, 0);
FilterPointsPie(TPA, 0, 359, MinD, MaxD, MMCX, MMCY);
TPAA := TPAToATPA(TPA, Round(Sqrt(MinPix)));
S := SR + Round(Rs_GetCompassAngleDegrees);
E := ER + Round(Rs_GetCompassAngleDegrees);
If S > 360 Then S := S - 315;
If E > 360 Then E := E - 315;
For I := High(TPAA) DownTo 0 Do
Begin
MiddleTPAEx(TPAA[i], X, Y);
If M <> 1 Then
Begin
Z := Round(Degrees(ArcTan2(MMCY - Y, MMCX - X))) - 90;
If Z < 0 Then
Z := Z + 360;
End Else
Z := Round(Degrees(ArcTan2(MMCY - Y, MMCX - X))) - 90;
If Z > SR Then
If Z < ER Then
Begin
MouseFindFlag(X, Y, 1, 1);
Flag;
Result := True;
Exit;
End;
End;
End;




Function HarborWalk(SD, ED: Integer): Boolean;
Var
S, E, L, I, CTS, Z: Integer;
TPAA: Array of TPointArray;
t1, t2, TPA: TPointArray;
Begin
If Not LoggedIn Then Exit;
CTS := GetColorTolerancespeed;
ColorToleranceSpeed(2);
FindColorsSpiralTolerance(MMCX, MMCY, t1, 2049872, MMX1, MMY1, MMX2, MMY2, 5);
FindColorsSpiralTolerance(MMCX, MMCY, t2, 2248798, MMX1, MMY1, MMX2, MMY2, 5);
TPA := CombineTPA(t1, t2);
S := SD { + Round(Rs_GetCompassAngleDegrees)};
E := ED {+ Round(Rs_GetCompassAngleDegrees)};
TPAA := TPAToATPA(TPA, 10);
L := High(TPAA);
SetArrayLength(TPA, 0);
For I := 0 To L Do
If GetArrayLength(TPAA[i]) >= 20 Then
Begin
SetArrayLength(TPA, GetArrayLength(TPA) + 1);
TPA[High(TPA)] := MiddleTPA(TPAA[i]);
End;
// SortTPAFrom(TPA, IntToPoint(MMCX, MMCY));
L := High(TPA);
For I := 0 To L Do
If Distance(TPA[i].x, TPA[i].y, MMCX, MMCY) >= 35 Then
Begin
Try
Z := Round(Degrees(ArcTan2(MMCY - TPA[i].y, MMCX - TPA[i].x))) - 90;
If Z < 0 Then
Z := Z + 360;
Except
Continue;
End;
If Z < E Then
If Z > S Then
Begin
Mouse(TPA[i].x, TPA[i].y, 1, 1, True);
Flag;
Result := True;
Break;
End;
End;
ColorToleranceSpeed(CTS);
End;



and this one is a radialwalk kind of for walking in port sarim, though the two colors have to be picked manually since I don't have an autocolor and I'm really not in the mood for making over 0.4 speed2mods.



Function FindIrons: TPointArray;
Var
TPAA: Array of TPointArray;
TPA: TPointArray;
CTS, I: Integer;
Begin
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.22, 0.23);
FindColorsSpiralTolerance(MSCX, MSCY, TPA, 2964577, 20, 20, MSX2 - 20, MSY2 - 20, 3);
TPAA := TPAToATPAEx(TPA, 20, 19);
For I := 0 To High(TPAA) Do
If GetArrayLength(TPAA[i]) > 7 Then
Begin
SetArrayLength(Result, GetArrayLength(Result) + 1);
Result[High(Result)] := MiddleTPA(TPAA[i]);
End;
SetColorSpeed2Modifiers(0.2, 0.2);
ColorToleranceSpeed(2);
End;

Iron finder that finds all irons (new rocks) on the mainscreen, needs only 3 Tol, maybe even less since it uses the Hue and Sat mods, which aren't very big either.

Negaal

2008-01-26 18:00:14

Well, mind my making willowfinder?

Because usually I'll end up like this…

MylesMadness

2008-01-26 22:18:03

If you made that in scar can you give me the code how?
Edit:I'm a lesser demon now! W00T
Edit edit:n3s has 4 posts LOL!

footballjds

2008-01-27 01:41:57

n3ss3s just patent the 3 letters TPA… also im loving it myles!
^^ the spammer(not really, kinda though :p) got 0wned :D

n3ss3s

2008-01-27 04:08:20

Lol, I didn't get owned, I requested it to be zeroed.

Negaal

2008-01-27 06:29:11

Haha, Lol'ed, Ownt nd Pwnt:D
Dude with longetivity over 60% and activity 100% has 10 posts…Ben Ftw!

Myles, search for DebugATPA or DebugTPA

n3ss3s

2008-01-27 07:12:55

Haha, Lol'ed, Ownt nd Pwnt


There's no owned in it when I asked it to be reset -.-

P1nky

2008-01-27 12:43:28

[offtopic]why would you want it back to ZERO ;S though that makes you ZERO THE HERO jk lol i know that is corny[offtopic]

n3ss3s

2008-01-27 13:02:42

Because.

Lets keep this ontopic please.

Santa_Clause

2008-01-27 18:16:02

From: Negaal
Well, mind my making willowfinder?

Because usually I'll end up like this…


After FindColorsSpiralTolerance put:

SplitTPA(WillowArray, 30)

Negaal

2008-01-28 01:32:15

SplitTPA(WillowArray, 30)

I have it, and 30 is way too much, I just have changed Color := Random(123123123) to Color := 255, because sometimes it makes me color what I cannot see[eg some green color]
Problem is it finds some ground ^^

I got another idea now…
First, I'll find tree by dark colours.
Then GetTpaBounds
And then I'll try to find all trees using best colors

Sounds good?:D

Santa_Clause

2008-01-28 05:27:11

What do you have it on? 30 isn't too much. I'm pretty sure the width/height is more than 30 pixels.

n3ss3s

2008-02-01 07:57:26

Santa, are you sure that you acknowledge that if you would have for example color 255 pixels every 30 * 30 on the screen, SplitTPA(TPA, 30) would find them all :p

Edit: Something for checking how many ore colors there is found in a rock :)


{*******************************************************************************
Function CheckOre(OreX, OreY, RefColor, Tol, Area: Integer): Integer;
By: n3ss3s
Description: Checks the certain ore. Returns how many colors match.
*******************************************************************************}
Function CheckOre(OreX, OreY, RefColor, Tol: Integer): Integer;
Var
I, X, Y, Z, fx: Integer;
Begin
Z := 4 * 4 - 1;
For I := 0 To Z Do
Begin
If (I mod 4) + 1 > 2 Then
fx := 2 - (I mod 4 + 1)
Else
fx := (I mod 4 + 1);
X := OreX + fx;
Y := OreY + (I div 4);
If SimilarColors(GetColor(X, Y), RefColor, Tol) Then
Result := Result + 1;
End;
End;

EDIT: Fixed it, it didn't work how I wanted afterall, now it does :)

footballjds

2008-02-01 09:25:20

n3ss3s no need to auto color port serim dock, just use FindBridgeColor ftw :D
it works cause i use that with my radial walking :D

n3ss3s

2008-02-01 10:02:17

Oh, thanks, saves me time… Though I have to make one for the lighter color, but that shouldn't be too much trouble.

Santa_Clause

2008-02-01 12:45:38

From: n3ss3s
Santa, are you sure that you acknowledge that if you would have for example color 255 pixels every 30 * 30 on the screen, SplitTPA(TPA, 30) would find them all :p

Edit: Something for checking how many ore colors there is found in a rock :)


{*******************************************************************************
Function CheckOre(OreX, OreY, RefColor, Tol, Area: Integer): Integer;
By: n3ss3s
Description: Checks the certain ore. Returns how many colors match.
*******************************************************************************}

Function CheckOre(OreX, OreY, RefColor, Tol, Area: Integer): Integer;
Var
I, X, Y, Z: Integer;
Begin
Z := Area * Area - 1;
For I := 0 To Z Do
Begin
X := OreX + (I mod Area);
Y := OreY + (I div Area);
If SimilarColors(GetColor(X, Y), RefColor, Tol) Then
Result := Result + 1;
End;
End;


I do…but no harm done :p Why'd you use Mod and Div and not 2 Mods?

n3ss3s

2008-02-01 13:10:51

It's not the same thing, 16 Div 4 is 4, 16 Mod 4 is 0, look at the output of this code:

program New;
Var
I: Integer;
begin
For I := 0 To 15 Do // As if area being 4
Begin
Writeln('Mod '+IntToStr(I mod 4));
Writeln('Div '+IntToStr(I div 4));
End;
end.

and thats how I want it to go if I want it to do

1, 1, 2, 1, 3, 1, 4, 1
1, 2, 2, 2, 3, 2, 4, 2
1, 3, 2, 3, 3, 3, 4, 3
1, 4, 2, 4, 3, 4, 4, 4

and there we have a fine 4 * 4 box :)

Santa_Clause

2008-02-01 15:15:11

Oh dang…sorry…don't know what happened to me.

n3ss3s

2008-02-01 16:32:04

Lol, you're talking like you had offended me the worse kind? :p

No need to apologize for a small code mistake :)

Home

2008-02-06 10:39:33

You are good :D I'm so out of this TPA.. I'v looked in Tuts and so on.. But can't really get the Idea.. What is TPA ?

~Home

Bobarkinator

2008-02-06 13:16:34

TPointArray. TPoints just store two numbers, an x coordinate and y coordinate. It would be the same as saying


x,y: Array of Integer;

It's just in one variable

n3ss3s

2008-02-08 13:52:19

Something I did to parse many "betweens", useful for getting loads of info from websites :


Function BetweenEx(S, Str1, Str2: String): TStringArray;
Var
L_Pos, x, z, p1, p2, l: Integer;
Begin
L_Pos := 1;
L := Length(Str1);
SetArrayLength(Result, Length(S));
Repeat
x := L_Pos;
p1 := PosEx(Str1, S, L_Pos);
Writeln('p1 '+IntToStr(p1));
If p1 > 0 Then
Begin
p2 := PosEx(Str2, S, p1);
Writeln('p2 '+IntToStr(p2));
If p2 > 0 Then
Begin
L_Pos := p2;
Result[z] := Copy(S, p1 + L, iAbs((p1 + l) - p2));
Z := Z + 1;
End;
End;
p1 := 0;
p2 := 0;
Until(x = L_Pos);
SetArrayLength(Result, Z);
End;

Var
TSA: TStringArray;
I: Integer;

Begin
TSA := BetweenEx('<x>mo</x><x>mo</x><x>hi</x>', '<x>', '</x>');
For I := 0 To High(TSA) Do
Writeln(TSA[i]);
End.

Blank
Blank
Blank
Blank
Blank
Blank


A new rock finder, I don't know does it work, stupid rs doesn't let me in so haven't got a chance to test bugs, but anyhow:


program New;

Type
TRock = Record
OCP: Extended;
Color, X, Y: Integer;

// OCP = OreColorPercent - Amount of OreColor / The pixels of gap in the
// dirt of the rock, the percent, e.g 80, not 0.8

End;


Function Mean(Values: TExtendedArray): Extended;
Var
I: Integer;
Begin
For I := 0 To High(Values) Do
Result := Result + Values[i];
Result := Result / GetArrayLength(Values);
End;


Function UpdateColorFromArray(Ref: Integer; Colors: TIntegerArray): Integer;
Var
Dif: Array of Array [0..2] Of Extended;
HSL, HSL2: Array [0..2] Of Extended;
SortedDif: TExtendedArray;
C, I, L, D: Integer;
R: Extended;
Begin
ColorToHSL(Ref, HSL[0], HSL[1], HSL[2]);
SetArrayLength(Dif, GetArrayLength(Colors));
L := High(Colors);
For I := 0 To L Do
Begin
ColorToHSL(Colors[i], HSL2[0], HSL2[1], HSL2[2]);
For C := 0 To 2 Do
Dif[i][c] := Abs(HSL[c] - HSL2[c]);
End;
L := High(Dif);
SetArrayLength(SortedDif, L + 1);
For D := 0 To L Do
SortedDif[d] := Mean([Dif[d][0], Dif[d][1], Dif[d][2]]);
R := AMinE(SortedDif);
For C := 0 To L Do
If SortedDif[c] = R Then
Begin
Result := Colors[c];
Exit;
End;
End;


Function newRock(C: TIntegerArray; X, Y, Ref, Amount: Integer): TRock;
Begin
Result.Color := UpdateColorFromArray(Ref, C);
Result.X := X;
Result.Y := Y;
Result.OCP := Amount / GetArrayLength(C) * 100 + 0.001;
End;


Function n_FindRocks(Rocks: Array of TRock; oreColor, mudColor, oTol, mTol, hM, sM: Integer): Boolean;
Var
mudBlobs, veins: Array of TPointArray;
CTS, L, I, M, Z, X, Y, C: Integer;
mudTPA, tmp: TPointArray;
vein: TIntegerArray;
Begin
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(hM, sM)
FindColorsSpiralTolerance(MSCX, MSCY, mudTPA, mudColor, msx1, msy1, msx2, msy2, mTol);
mudBlobs := TPAToATPAEx(mudTPA, 22, 22);
L := High(mudBlobs);
For I := 0 To L Do
Begin
If GetArrayLength(mudBlobs[i]) < 50 Then
Continue;
veins := FindGapsTPA(mudBlobs[i], 7);
For C := 0 To High(veins) Do
tmp := CombineTPA(tmp, veins[c]);
vein := GetColors(tmp);
For C := 0 To High(vein) Do
If SimilarColors(vein[c], oreColor, oTol) Then
M := M + 1;
z := GetArrayLength(tmp);
If z > 8 Then
If m / z + 0.001 > 0.8 Then
Begin
If MiddleTPAEx(CombineTPA(tmp, mudBlobs[i]), X, Y) Then
If Not Result Then
Result := True
Else
Continue;
SetArrayLength(Rocks, GetArrayLength(Rocks) + 1);
Rocks[High(Rocks)] := newRock(vein, X, Y, oreColor, m);
End;
End;
SetColorSpeed2Modifiers(0.2, 0.2);
ColorToleranceSpeed(CTS);
End;





Okay, a new rock finder once again -


Function FindRocks(OreColor: Integer): TPointArray;
Var
I, C, Co, Le, CTS, xM, yM: Integer;
H, Hh, S, Ss, L, Ll: Extended;
Veins: T2DPointArray;
orePts, tmp: TPointArray;
TIA: TIntegerArray;
TB: TBox;
Begin
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
ColorToHSL(OreColor, H, S, L);
FindColorsSpiralTolerance(MSCX, MSCY, orePts, OreColor, MSX1, MSY1, MSX2, MSY2, gCT);
Veins := TPAToATPAEx(orePts, 7, 7);
Le := High(Veins);
For I := 0 To Le Do
Begin
TIA := GetColors(Veins[i]);
tmp := Veins[i];
TB := GetTPABounds(tmp);
xM := TB.x2 - TB.x1;
yM := TB.y2 - TB.y1;
For C := 0 To High(TIA) Do
Begin
Co := TIA[c];
ColorToHSL(Co, Hh, Ss, Ll);
If Abs(Hh - H + 0.001) < 1.38 Then
If Abs(Ss - S + 0.001) < 2.14 Then
If Abs(Ll - L + 0.001) < 24.54 Then
Begin
If (xM < 15) and (yM < 15) Then
If GetArrayLength(tmp) < xM * yM Then
Begin
SetArrayLength(Result, GetArrayLength(Result) + 1);
Result[High(Result)] := MiddleTPA(tmp);
End;
End;
End;
End;
RAaSTPA(Result, 20);
ColorToleranceSpeed(CTS);
End;

footballjds

2008-02-10 16:15:47

Result := ReArrangeAndShortenArray(Result, 20); should just be:
RAaSTPA(Result, 20);
RAaSTPA(Result, 20); is 2 ms faster AND you don't need result :=, because result is a var in RAaSTPA(Result, 20); :D

also, n3ss3s, do you mind if i used your rock finder and a jr mem script? its a varrock east miner. ? atm im using your first one:
Function FindIrons: TPointArray;
var
TPAA: array of TPointArray;
TPA: TPointArray;
CTS, I: Integer;
begin
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.22, 0.23);
FindColorsSpiralTolerance(MSCX, MSCY, TPA, 2964577, 20, 20, MSX2 - 20, MSY2 - 20, 3);
TPAA := TPAToATPAEx(TPA, 20, 19);
for I := 0 To High(TPAA) do
if GetArrayLength(TPAA[i]) > 7 then
begin
SetArrayLength(Result, GetArrayLength(Result) + 1);
Result[High(Result)] := MiddleTPA(TPAA[i]);
end;
SortTPAFrom(Result, IntToPoint(259, 160));
SetColorSpeed2Modifiers(0.2, 0.2);
ColorToleranceSpeed(cts);
end;

but i might use your newer one, what do you say?
ofcourse il credit, //from n3ss3s :D awesome n3ss3s :D SUPER HERO n3ss3s :rolleyes:

Gu3st...

2008-02-11 08:01:46

From: Negaal
Well, mind my making willowfinder?

Because usually I'll end up like this…


wtf? someone made the scar paint *color* to 255? On-screen in runescape? for real? really? does not rs paint over?

n3ss3s

2008-02-11 08:34:29

wtf? someone made the scar paint *color* to 255? On-screen in runescape? for real? really? does not rs paint over?


Omg! Impossible! Except for if we do

(first prepare the bitmap - msBmp := BitmapFromString(MSX2, MSY2, '');

0. DisplayDebugImgWindow(MSX2, MSY2);
1. CopyClientToBitmap(msBmp, MSX1, MSY1, MSX2, MSY2);
2. Do the paintings to the bmp…
3. CopyCanvas(GetBitmapCanvas(msBmp), GetDebugCanvas, 0, 0, MSX2, MSY2, 0, 0, MSX2, MSY2);

voila - you have the mainscreen painted in the debug window.

See the bitmap painting functions in SCAR manual.


@Negaal:

a) I r <3 Result :=
b) Thanks for the 2ms…

Feel free to use…

footballjds

2008-02-11 08:40:48

From: n3ss3s

@Negaal:

a) I r <3 Result :=
b) Thanks for the 2ms…

Feel free to use…


i presume you mean footballjds? and you don't mind if i use right? remember it is in a jr mem script and this is the srl member section, thats why im asking.

n3ss3s

2008-02-11 08:59:49

Oh, sorry, I mean footballjds, yea, you can use. Yea if you credit…

footballjds

2008-02-11 09:34:37

From: n3ss3s
Oh, sorry, I mean footballjds, yea, you can use. Yea if you credit…


i said i would credit ;)

ofcourse il credit, //from n3ss3s awesome n3ss3s SUPER HERO n3ss3s

Timer

2008-02-15 14:03:50

For your WhirlPool…
Unknown identifier 'BoxFromTPA'

n3ss3s

2008-02-15 14:17:02

BoxFromTPA is a function of mine, if you want to use it, you might want to tweak it to GetTPABounds etc.

Also I don't know does it work, you also propably need to change a few values.

Because it was made by pure theory, even the color I made in photoshop.

Timer

2008-02-15 14:32:02

gimme 1 that compiles, and ill test it! lol
and for the debug, ho do u making it highlich the colors to 255?

n3ss3s

2008-02-15 14:34:37

highlich


Is that closer to Heimlich or Highlight? :p Jk/Jk, no, the colors in the RuneScape client aren't being highlighted, its just a CopyClientToBitmap and FastDraw functions, see scar manual…

Timer

2008-02-15 14:35:57

can u fix the whilpool for me?

n3ss3s

2008-03-06 13:49:57

Ben is the only one here who can cause a nature catastrophe with pure power of will.


= gimme a whirlpool, slowpoke!



Function GetPixelChange(Color, x1, y1, x2, y2, Tol, WaitTime: Integer): Extended;
Var
aPts, bPts: TPointArray;
L, I, Count: Integer;
Begin
FindColorsTolerance(aPts, Color, x1, y1, x2, y2, Tol);
Wait(WaitTime);
FindColorsTolerance(bPts, Color, x1, y1, x2, y2, Tol);
L := Min(High(aPts), High(bPts));
For I := 0 To L Do
If (aPts[i].x <> bPts[i].x) and (aPts[i].y <> bPts[i].y) Then
Count := Count + 1;
Result := Count / (L + 1);
End;

^^ useful for gas / ent checking.



An other kind of MiddleTPA, the one in WizzyPlugin uses the Mean Average, this uses Median.

It isn't in plugin so with arrays that has thousands of points it takes some time, 6501 points took 541ms, but 400 points took 0-15 ms.

How it works -

in WizzyPlugin, it does X := X + Point.x and same for Y and then divides it by the length of the array.

Mine gets the "middliest" point in an array that is sorted from small to large, the X and Y arrays, and then simply put does X := xArray[middle].x etc.

It takes the median point, go read from wikipedia…



Function Median(Ints: TIntegerArray): Extended;
Var
I: Integer;
Begin
BubbleSort(Ints);
I := GetArrayLength(Ints);
If I Mod 2 <> 0 Then
Begin
Result := Ints[Round(High(Ints) / 2)];
End Else
Begin
Result := (Ints[Round(High(Ints) / 2)-1] + Ints[Round(High(Ints) /2)]) / 2;
End;
End;

Function n_MiddleTPAEx(TPA: TPointArray; Var mX, mY: Integer): Boolean;
Var
xA, yA: TIntegerArray;
I: Integer;
Begin
Result := GetArrayLength(TPA) >= 3;
If Not Result Then
Exit;
SetArrayLength(xA, GetArrayLength(TPA));
SetArrayLength(yA, GetArrayLength(TPA));
For I := 0 To High(TPA) Do
Begin
xA[i] := TPA[i].x;
yA[i] := TPA[i].y;
End;
QuickSort(xA);
QuickSort(yA);
mX := Round(Median(xA));
mY := Round(Median(yA));
End;





AutoColorThisEx (You need my UpdateColorFromArray for it)



Function AutoColorThisEx(bmp, Ref, Tol, x1, y1, x2, y2: Integer): Integer;
Var
X, Y, I, W, H, Gx, Gy, Z: Integer;
c: TIntegerArray;
Begin
Result := - 1;
If FindBitmapToleranceIn(bmp, x, y, x1, y1, x2, y2, Tol) Then
Begin
GetBitmapSize(bmp, W, H);
Z := w * h - 1;
SetArrayLength(C, z + 1);
Gx := Max(X - 3, 0);
Gy := Max(Y - 3, 0);
For I := 0 To Z Do
c[i] := GetColor(Gx + (I mod W), Gy + (I div H));
Result := UpdateColorFromArray(Ref, c);
End;
End;


Nielsie's fix, now it works as supposed to.






Behold - GetNick:


program New;
{.include SRL/SRL/Misc/ArrayLoader.scar}


Function Capitalized(C: Char): Boolean;
Begin
Result := LowerCase(C) <> C;
End;


Function GetNick(Username: String; NickLength: Integer): String;
Var
Parts, validParts: TStringArray;
z, q, w, i, c: Integer;
Begin
Parts := StrToStrArray(Username);
SetArrayLength(validParts, GetArrayLength(Parts));
For I := 0 To High(Parts) Do
If Length(Parts[i]) >= NickLength Then
Begin
validParts[z] := Parts[i];
z := z + 1;
End;
SetArrayLength(validParts, z);
For I := 0 To Z Do
Begin
For C := 1 To Length(validParts[i]) Do
If Not Capitalized(validParts[i][c]) Then
If q <= 3 Then
q := q + 1
Else
Break
Else
w := w + 1;
If q >= NickLength Then
Begin
Result := Copy(validParts[i], w + 1, q);
Exit;
End;
End;
End;


begin
Writeln(GetNick('Ran2dom Name', 3));
end.


Capitalized by Wizzup.



For all your alphabetic number getting needs:

{*******************************************************************************
Function GetAlphabet(C: Char): Integer;
By: n3ss3s
Description: Returns the alphabetic number of a character.
*******************************************************************************}

Function GetAlphabet(C: Char): Integer;
Begin
Result := iAbs(65 - GetKeyCode(C)) + 1;
End;





Function Revert(S: String): String;
Var
I: Integer;
Begin
SetLength(Result, Length(S));
For I := 1 To Length(S) Do
Result[i] := S[Length(S) - i + 1];
End;



For checking if we are moving:

Function AreWeMoving(wTime, minChance: Integer): Boolean;
Var
A, R, X, Y, I, C: Integer;
Col: TIntegerArray;
TPA: TPointArray;
Begin

If Not LoggedIn Then Exit;

SetArrayLength(TPA, 10);
SetArrayLength(Col, 10);

For I := 0 To 9 Do
Begin
A := (I + 1) * 40 + Random(50);
R := 15 + Random(60);
X := MMCX + Round(R * Cos(A / 180 * Pi));
Y := MMCY + Round(R * Sin(A / 180 * Pi));
TPA[i] := Point(X, Y);
End;

Col := GetColors(TPA);
Wait(wTime);

For I := 0 To 9 Do
If GetColor(TPA[i].x, TPA[i].y) <> Col[i] Then
C := C + 1;

Result := C > minChance;

End;


A new function, SortColors! http://www.villavu.com/forum/showthread.php?t=27547?p=366146#post366146