PDA

View Full Version : Target / rotate screen to closest minimap dot of selected type



cosmasjdz
08-12-2014, 01:21 PM
I use this function in my fighters to target mobs, this rotates screen to the closest dot on the minimap to make it appear on certain screen location. Mostly i use Minimap.RotateToPoint(MM_DOT_NPC,45);
or Minimap.RotateToPoint(MM_DOT_NPC,315); because especially when ranging there is higher cfhance ull get mob which is in map appear in mainscreen. Also i use it for looting, if loot appears close to screen bounds but outside i just rotate the mainscreen to see loot on the corner.


///////////////////////////////////////////////////////////////////
// function Minimap.RotateToPoint( DotType: integer; MainscreenLocation: integer): boolean;
//
// Rotates the mainscreen to the closest of the selected type minimap point at the selected angle
//
// top is 0 right 90 bottom 180 left 270
//
// by cosmasjdz 2014-08-09
//
// example: Minimap.RotateToPoint(MM_DOT_NPC,0); this rotates screen so the closest yellow dot on the minimap becomes north of the screen
//
////////////////////////////////////////////////////////////////////
function TRSMinimap.RotateToPoint( DotType: integer; MainscreenLocation: integer): boolean;
var
TPA: TPointArray;
t: tpoint;
k,m: extended;
xv,yv,i,ml: integer;
begin
ml:=mainscreenlocation;
t:=self.getCenterPoint();
TPA:=self.getdots(DotType,self.getbounds());
if high(tpa)=-1 then
begin
writeln('No such type dots found on the minimap, quiting procedure');
result:=false;
exit;
end;
SortTPAFrom(TPA, t);
writeln('Trying to rotate to the closest '+tostring(dottype)+' dot '+'at angle of mainscreen of '+tostring(Mainscreenlocation));
xv:=tpa[0].x-t.x;
yv:=t.y-tpa[0].y;
k:=degrees(ArcTan2(yv,xv));
m:=(self.getangledegrees());
self.setangle(trunc(k+m-90+ml));
result:=true;
writeln('Succesfully rotated');
end;