Sabzi
2010-02-06 07:16:33
{*******************************************************************************
function ItemDTM(MiddlePoint: TPoint; Box: TBox; SubPoints: Integer): Integer;
By: Sabzi
Description: Will make a dtm of the item in the Box with the amount of
subpoints given.
*******************************************************************************}
function ItemDTM(MiddlePoint: TPoint; Box: TBox; SubPoints: Integer): Integer;
var
TPA, tempTPA: TPointArray;
TP: TPoint;
i, Degree, L: Integer;
dtmMP: TDTMPointDef;
dtmSP: array of TDTMPointDef;
TempTDTM: TDTM;
begin
FindColorsSpiralTolerance(MiddlePoint.x, MiddlePoint.y, TPA, srl_outline_black, Box.x1, Box.y1, Box.x2, Box.y2, 0); //Isn't there one without tolerance? :/
dtmMP.x := MiddlePoint.x;
dtmMP.y := MiddlePoint.y;
dtmMP.Tolerance := 255;
for i := 0 to SubPoints - 1 do
begin
tempTPA := TPA;
Degree := Round(360 / SubPoints * (i + 0.5));
FilterPointsPie(tempTPA, Degree - 2, Degree + 2, 1, Distance(Box.x1, Box.y1, TP.x, TP.y), MiddlePoint.x, MiddlePoint.y);
if Length(tempTPA) > 0 then //Better then nothing. :S
begin
Inc(L);
SetArrayLength(dtmSP, L);
TP := tempTPA[High(tempTPA)]; //We want the outline so we want the farest point.
dtmSP[i].x := TP.x;
dtmSP[i].y := TP.y;
dtmSP[i].Color := srl_outline_black;
end;
end;
TempTDTM.MainPoint := dtmMP;
TempTDTM.SubPoints := dtmSP;
Result := AddDTM(TempTDTM);
end;With the usage of this even if Jagex decides to update the outline color of the items every week, just one srl update and everything will be fine again(hopefully).
Example usage:
var
DTM, x, y: Integer;
TP: TPoint;
TB: TBox;
begin
SetupSRL;
TP := ItemCoords(1);
TB := InvBox(1);
DTM := ItemDTM(TP, TB, 4);
if FindDTM(DTM, x, y, MSX1, MSY1, MSX2, MSY2) then
begin
WriteLn('Hooooooray!');
MMouse(x, y, 5, 5);
end;
FreeDTM(DTM);
end.If you wish to use this with stackable items(or items in bank) it may muck up because of the yellow numbers. I originally written this for only inventory(for bars) so I did not count that in. You can use some type of skipping color finder and that would solve it I think.
What do you think?
EDIT: Updated with failsafe.