pwnaz0r
2007-09-16 16:55:05
Here it is. I use it for making DTMs of items in my inventory that there could be alot of (Ex. There are so many types of fish and food, i don't want to make dtms for all of them, so i just made this. The script will make the DTM for me :D).
function CreateDTMFromClient(x1, y1, x2, y2, maxsubpoints: integer): integer;
var
DDTMDef: TDTMPointDef;
DDTMSub: array of TDTMPointDef;
DDTMMain: TDTM;
a, b, c, d, e, bitmap: integer;
first: boolean;
begin
if x2 <= x1 then Swap(x2, x1);
if y2 <= y1 then Swap(y2, y1);
CopyClientToBitmap(bitmap, x1, y1, x2, y2);
c:= x2 - x1;
d:= y2 - y1;
first:= true;
for a:= 0 to c do
begin
for b:= 0 to d do
begin
if FastGetPixel(bitmap, a, b) = 65536 then
begin
if First then
begin
DDTMDef.x:= x1 + a;
DDTMDef.y:= y1 + b;
DDTMDef.AreaSize:= 1;
DDTMDef.AreaShape:= 0;
DDTMDef.Color:= 65536;
DDTMDef.Tolerance:= 0;
First:= false;
wait(500);
end else
begin
SetArrayLength(DDTMSub, Length(DDTMSub) + 1);
e:= Length(DDTMSub) - 1;
DDTMSub[e].x:= x1 + a;
DDTMSub[e].y:= y1 + b;
DDTMSub[e].AreaSize:= 1;
DDTMSub[e].AreaShape:= 0;
DDTMSub[e].Color:= 65536;
DDTMSub[e].Tolerance:= 0;
wait(500);
if e >= maxsubpoints then
begin
DDTMMain.MainPoint:= DDTMDef;
DDTMMain.SubPoints:= DDTMSub;
result:= AddDTM(DDTMMain);
exit;
end;
end;
end;
end;
end;
DDTMMain.MainPoint:= DDTMDef;
DDTMMain.SubPoints:= DDTMSub;
result:= AddDTM(DDTMMain);
end;