SRL Archive - SRL Archives

FindPickHeadColors


JuKKa

2008-03-16 12:51:40

Instead of using Getcolor why not use Findcolorstolerance?
to get all colors of the pick, of course this needs then modifying of the findpick procedure. But something like this..

program New;

{.Include SRL/SRL.Scar}

var
HC: tintegerarray;
//EquipPick, Wielding, nopick: boolean;

function InIntArr(Num: Integer; I: TIntegerArray): Boolean;
var
C: Integer;
begin
for C:= 0 to Length(I) - 1 do
if(I[C] = Num)then
begin
Result:= True;
exit;
end;
end;

procedure ShrinkArray(var Arr: TIntegerArray);
var
Used: TIntegerArray;
I, Index: Integer;
begin
SetLength(Used, Length(Arr));
if(InIntArr(0, Arr))then
Inc(Index);
for I:= 0 to Length(Arr) - 1 do
if(not(InIntArr(Arr[i], Used)))then
begin
Used[Index]:= Arr[i];
Inc(Index);
end;
SetLength(Used, Index);
Arr:= Used;
end;

function FindPickHeadColor: Boolean;
var tcolor, Pick, ix, iy, curTab : Integer;
ColorTPA: TPointArray;
begin
Pick := DTMFromString('78DA6334616260B8CD8006189148206D0E54F' +
'391801A2FA09A0704D4B802D55C23A0C60AA8E6060135B6403577' +
'08A8B101AA798C5F0D00537C07EA');

NoPick := True; // Assume we dont have a pickaxe....
curTab := GetCurrentTab;
GameTab(4);
if FindDTM(Pick, ix, iy, MIX1, MIY1, MIX2, MIY2) then
begin
NoPick := False;
Wielding := False;
EquipPick := Wielding;
end
else
begin
GameTab(5);
if FindDTM(Pick, ix, iy, MIX1, MIY1, MIX2, MIY2) then
begin
NoPick := False;
Wielding := True;
EquipPick := Wielding;
end;
end;

if not NoPick then // Amazing.
begin
Wait(100 + Random(100));
tcolor := GetColor(ix + 1, iy);
FindColorsTolerance(ColorTPA, tcolor, iX, iY, iX+30, iY+30, 10);
HC := GetColors(ColorTPA);
ShrinkArray(HC); //deletes colors that are the same.
Writeln('picked '+Inttostr(getarraylength(hc))+' colors');
Result := True;
end
else
Result := False;

FreeDTM(Pick);
GameTab(curTab);
end;

begin
SetupSRL;

FindPickHeadColor;
end.

not sure if that works. meerly a example of how it SHOULD be done ;)

n3ss3s

2008-03-16 13:16:28

Use ClearSameIntegers since it's in WizzyPlugin which comes automatically with SRL, also saves you from IntIntArr, which is in WizzyPlugin also ;)


That's nice, but way too unleet, you need to first find the pickaxe, then, find any "blue" color using HSL and then hop to CTS(2) and then do the FindColors ;)


Good job

Wizzup?

2008-04-03 08:12:04

Will think about adding it to the next revision. I think I use the same concept in my edgeville fisher, right?

JuKKa

2008-04-03 09:02:59

From: Wizzup?
Will think about adding it to the next revision. I think I use the same concept in my edgeville fisher, right?

Yes, exactly the same.