SRL Archive - SRL Archives

First Herblore.scar Function!


Cazax

2008-09-25 18:33:08

Herblore*
Function GrimyOrNot(Slots : TIntegerArray): TIntegerArray;
Var
TPA : TPointArray;
Box : TBoxArray;
IntArr, C : TIntegerArray;
H, S, L : Extended;
I, K : Integer;
Begin
SetArrayLength(Box, 28);
SetArrayLength(Result, 0);
For I := 1 To 28 Do
If InIntArray(Slots, I) Then
Begin
Box[Length(Box) - 1] := InvBox(I);
End;
SetArrayLength(C, 28);
For I := 1 To 28 Do
Begin
If Not InIntArray(Slots, I) Then
Continue;
FindColorsTolerance(TPA, 2115160, Box[I].X1, Box[I].Y1, Box[I].X2, Box[I].Y2, 10);
If Length(TPA) = 0 Then
Continue;
IntArr := GetColors(TPA);
ClearSameIntegers(IntArr);
For K := 0 To High(IntArr) Do
Begin
ColorToHSL(IntArr[K], H, S, L);
If (Round(H) > 8) And (Round(H) < 14) Then
If (Round(S) > 45) And (Round(S) < 49) Then
If (Round(L) > 20) And (Round(L) < 26) Then
Inc(C[I]);
If C[I] > 10 Then //Default count.
Break;
End;
End;
For I := 1 To 28 Do
Begin
If Not InIntArray(Slots, I) Then
Continue;
If (C[I] > 10) Then
Begin
SetArrayLength(Result, Length(Result) + 1);
Result[Length(Result) - 1] := I;
End;
End;
End;

The function searches for grimy herbs.

Slots: The slots to search for herbs.

The result will be the slots with grimy herbs.

Uses HSL for the grimy detection.

Narcle

2008-09-26 21:01:43

Just want to point this out:
For I := 0 To 28 Do
You use that twice in there… shouldn't it be
For I := 1 To 28 Do

Cazax

2008-09-26 21:05:45

From: Narcle
Just want to point this out:
For I := 0 To 28 Do
You use that twice in there… shouldn't it be
For I := 1 To 28 Do


Ah yes but it can work anyway because it skips slots that arent selected.

Narcle

2008-09-26 21:07:14

From: Cazax
Ah yes but it can work anyway because it skips slots that arent selected.


Just seems a waste of time then. :P

Twisted

2008-09-26 21:32:00

Good job! Might come in handy for people that make a herblore script…

hamster

2008-10-31 14:45:11

isn't it much much much easier to use IsUpText instead of looking for a colour all the time? :s

just in a for loop ==>
if IsUpText('grimy') then
mark (as in mark the coords that it is grimy)

HyperSecret

2008-10-31 15:04:09

From: hamster
isn't it much much much easier to use IsUpText instead of looking for a colour all the time? :s

just in a for loop ==>
if IsUpText('grimy') then
mark (as in mark the coords that it is grimy)


Then you have to move your mouse to ever inv slot, and you don't want to do that now do you?

Nava2

2008-10-31 17:44:32

This is awesome, very impressive.

hamster

2008-11-01 15:13:47

hypersecret… you have a point there =D my bad