Starblaster100
2007-05-19 09:39:02
Hey all,
New Function from me, could be pretty useful :)
[php]
{ ——————————————————————— ]
[ >> Part of Find DTM ]
[ >> Function CreateItemDTM(InvSlot, NoOfPoints, Tolerance: Integer): ]
[ Integer; ]
[ >> Creates a Dynamic DTM of an Item in the Defined InvSlot, with ]
[ "NoOfPoints" SubPoints and "Tolerance" Tolerance ]
[ >> By Starblaster100 ]
[ ——————————————————————— }
[/php]
and here is the function itself:
[php]
program New;
{.include SRL/SRL.scar}
Var
Test: Integer;
{ ——————————————————————— ]
[ >> Part of Find DTM ]
[ >> Function CreateItemDTM(InvSlot, NoOfPoints, Tolerance: Integer): ]
[ Integer; ]
[ >> Creates a Dynamic DTM of an Item in the Defined InvSlot, with ]
[ "NoOfPoints" SubPoints and "Tolerance" Tolerance ]
[ >> By Starblaster100 ]
[ ——————————————————————— }
Function CreateItemDTM(InvSlot, NoOfPoints, Tolerance: Integer): Integer;
Var
DTM: TDTM;
Start: TPoint;
i, X1, Y1, CurrentAngle, Radius, SubPointsFound: Integer;
Begin
If not(Loggedin) then Exit;
GameTab(4);
If(ExistsItem(InvSlot)) then
Begin
Start := ItemCoords(InvSlot);
SetArrayLength(DTM.SubPoints, NoOfPoints);
DTM.MainPoint.x := Start.x;
DTM.MainPoint.y := Start.y;
DTM.MainPoint.color := GetColor(Start.x, Start.y);
DTM.MainPoint.tolerance := Tolerance;
DTM.MainPoint.areasize := 1;
DTM.MainPoint.areashape := shpRectangle;
For i := 0 to NoOfPoints-1 do
Begin
CurrentAngle := (360/NoOfPoints) * i;
For Radius := 1 to 20 do
Begin
X1 := Round ( Radius * Sin (CurrentAngle * Pi / 180)) + Start.x;
Y1 := Round (- Radius * Cos (CurrentAngle * Pi / 180)) + Start.y;
If (GetColor(X1, Y1) = 65536) then
Begin
DTM.SubPoints.x := X1;
DTM.SubPoints.y := Y1;
DTM.SubPoints.color := GetColor(X1, Y1);
DTM.SubPoints.tolerance := 0;
DTM.SubPoints.areasize := 1;
DTM.SubPoints.areashape := shpRectangle;
SubPointsFound := SubPointsFound + 1;
Writeln('Subpoint '+IntToStr(i)+' Found');
Break;
end;
end;
end;
If (SubPointsFound >= NoOfPoints) then
Result := AddDTM(DTM);
end;
end;
begin
Test := CreateItemDTM(1, 3, 0);
try
If(FindDTM(Test, x, y, 555, 374, 742, 471))then
Begin
Writeln('Found');
MMouse(x, y, 0, 0);
end else
Writeln('NotFound');
except
Writeln('All Sub Points Not Found');
Writeln('DTM Could not be Created!');
end;
end.
[/php]
Put something like a cowhide in the first inventory spot, and then put another in the bottom row somewhere. It should create a DTM of the first cowhide, find the second and move the mouse there.
I know its not perfect, I'm still working on it, hence the post in the Test Corner.
Tell me what you think
Thanks
Star
New Function from me, could be pretty useful :)
[php]
{ ——————————————————————— ]
[ >> Part of Find DTM ]
[ >> Function CreateItemDTM(InvSlot, NoOfPoints, Tolerance: Integer): ]
[ Integer; ]
[ >> Creates a Dynamic DTM of an Item in the Defined InvSlot, with ]
[ "NoOfPoints" SubPoints and "Tolerance" Tolerance ]
[ >> By Starblaster100 ]
[ ——————————————————————— }
[/php]
and here is the function itself:
[php]
program New;
{.include SRL/SRL.scar}
Var
Test: Integer;
{ ——————————————————————— ]
[ >> Part of Find DTM ]
[ >> Function CreateItemDTM(InvSlot, NoOfPoints, Tolerance: Integer): ]
[ Integer; ]
[ >> Creates a Dynamic DTM of an Item in the Defined InvSlot, with ]
[ "NoOfPoints" SubPoints and "Tolerance" Tolerance ]
[ >> By Starblaster100 ]
[ ——————————————————————— }
Function CreateItemDTM(InvSlot, NoOfPoints, Tolerance: Integer): Integer;
Var
DTM: TDTM;
Start: TPoint;
i, X1, Y1, CurrentAngle, Radius, SubPointsFound: Integer;
Begin
If not(Loggedin) then Exit;
GameTab(4);
If(ExistsItem(InvSlot)) then
Begin
Start := ItemCoords(InvSlot);
SetArrayLength(DTM.SubPoints, NoOfPoints);
DTM.MainPoint.x := Start.x;
DTM.MainPoint.y := Start.y;
DTM.MainPoint.color := GetColor(Start.x, Start.y);
DTM.MainPoint.tolerance := Tolerance;
DTM.MainPoint.areasize := 1;
DTM.MainPoint.areashape := shpRectangle;
For i := 0 to NoOfPoints-1 do
Begin
CurrentAngle := (360/NoOfPoints) * i;
For Radius := 1 to 20 do
Begin
X1 := Round ( Radius * Sin (CurrentAngle * Pi / 180)) + Start.x;
Y1 := Round (- Radius * Cos (CurrentAngle * Pi / 180)) + Start.y;
If (GetColor(X1, Y1) = 65536) then
Begin
DTM.SubPoints.x := X1;
DTM.SubPoints.y := Y1;
DTM.SubPoints.color := GetColor(X1, Y1);
DTM.SubPoints.tolerance := 0;
DTM.SubPoints.areasize := 1;
DTM.SubPoints.areashape := shpRectangle;
SubPointsFound := SubPointsFound + 1;
Writeln('Subpoint '+IntToStr(i)+' Found');
Break;
end;
end;
end;
If (SubPointsFound >= NoOfPoints) then
Result := AddDTM(DTM);
end;
end;
begin
Test := CreateItemDTM(1, 3, 0);
try
If(FindDTM(Test, x, y, 555, 374, 742, 471))then
Begin
Writeln('Found');
MMouse(x, y, 0, 0);
end else
Writeln('NotFound');
except
Writeln('All Sub Points Not Found');
Writeln('DTM Could not be Created!');
end;
end.
[/php]
Put something like a cowhide in the first inventory spot, and then put another in the bottom row somewhere. It should create a DTM of the first cowhide, find the second and move the mouse there.
I know its not perfect, I'm still working on it, hence the post in the Test Corner.
Tell me what you think
Thanks
Star