From: Torol
I'm writing a woodcutter script, and I'm looking for a way to turn my camera towards the closest tree (as a failsafe). I can detect the tree with DTMs on the minimap, but after that I'm stuck. How could I move the camera? If you could link a script which uses a similar option that would be great too.
Thanks,
Torol
This is my function mayor mentioned of. It targets closest yellow dot. You need to change colors thats it.
It turn mainscreen to the certain angle of the screen. For example nusitaiko(45); would turn screen to the closest yellow dot on the minimap to be at 45 degrees in my mainscreen. I usually use 45,135 angles because in those angles in the corners you see more further than in the 90 degree for example.
function nusitaiko(kampas: integer):boolean;
var
x, y,i : integer;
TPA: TPointArray;
ATPA: T2DPointArray;
t: tpoint;
k,m: extended;
xv,yv,ml: integer;
begin
result:=false;
findColorsSpiralTolerance(x, y, TPA, 518375, minimap.getbounds(), 12, colorSetting(2,0.23, 0.74));
if length(TPA) < 1 then exit;
ATPA := TPA.toATPA(2, 2);
if length(ATPA)< 1 then exit;
ATPA.sortFromMidPoint(minimap.getCenterPoint());
ml:=kampas;
t:=minimap.getCenterPoint();
SortTPAFrom(TPA, t); // i sort dots from closest
xv:=tpa[0].x-t.x;// anfd use closest one parameters to count angles
yv:=t.y-tpa[0].y;
k:=degrees(ArcTan2(yv,xv)); // counts dot angle on the minimap
m:=(minimap.getangledegrees()); // gets minimap angle
minimap.setangle(trunc(k+m-90+ml)); // this line sets closest found dot to be on the certain angle of mainscreen using both angles
writeln('Succesfully rotated');
result:=true;
end;
EDIT: Dang same name wrong second function. But yeah you can even after setting screen to closest point that dot from minimap to mainscreen also and blindly grab tree or try to grab. Would be good antiban like feature. For example my dragon script at the moment in combination with Nusitaiko() uses these functions to minimize search areas so grabs faster moving dragons.