procedure TurnToNearestNPC();
Hey so I recently got some code to work for this. Included is some Smart_Draw to show proof of concept. It can be removed. The function goes something like this: (I found it helpful for my autofighter). Its a two function/procedure thingy, it could easily be condensed into one.
Simba Code:
function TurnToMMPoint(P: TPoint,minRandomnessDegrees, maxRandomnessDegrees : integer): Extended;
var //credits to Fl1ght. co-written by mr. pali
d, current,final :extended;
begin
d := ArcTan2((P.Y - MMCY), (P.X - MMCX ));
Result := degrees((fixRad(d-Pi)))- 90;
Result := radians(result);
current := rs_GetCompassAngleDegrees();
current := radians(current);
final := (Result + current);
final:= degrees(final);
MakeCompass(final + randomrange(minRandomnessDegrees , maxRandomnessDegrees))
DebugLines('Turning to nearest NPC');
end;
procedure turnToNpc();
var // creds to p1ng. co-written by mr. pali
i:integer;
NPCArray : TPointArray;
NPCPoint:Tpoint;
begin
NPCArray := GetMinimapDots('NPC');
if Length(NPCArray) < 1 then
Exit;
SortTPAFrom(NPCArray, Point(MMCX, MMCY));
for i := 0 to High(NPCArray) do
begin
NPCPoint := NPCArray[i];
SMART_ClearCanvasArea(IntToBox(524,7,709,159));
SMART_DrawBoxEx(false,false,IntToBox((NPCPoint.x)-3,(NPCPoint.y)-3,(NPCPoint.x)+3,(NPCPoint.y)+3),ClYellow);
SMART_Drawline(false,NPCPoint,point(MMCX,MMCY),CLRed);
SMART_DrawLine(false,point(MMCX,7),point(MMCX,MMCY),CLBlue);
TurnToMMPoint(NPCPoint,-10,10);
exit;
end;
end;
If someone higher up wanted to clean this up and submit it to the SRL include, I'd be a happy camper :).