(* Minimap ======= The minimap file contains various methods for interacting with the minimap interface. The source for this file can be found `here `_. *) (* tMinimap.clickDegrees() ~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: pascal function tMinimap.clickDegrees(funcDegrees:int32):boolean; Description: Clicks the desired direction, in degrees, on the minimap interface. Information: * Returns true if successful. * Uses the mouse. .. note:: - by Obscurity - Last Updated: 2015-08-07 Example: .. code-block:: pascal if minimap.getLocalPosition().y<50 then minimap.clickDegrees(180); *) function tMinimap.clickDegrees(funcDegrees:int32):boolean; begin exit(result:=tMinimap.clickRadians(funcDegrees*0.01745329251994329576923690768489));end; (* tMinimap.clickDirection() ~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: pascal function tMinimap.clickDirection(funcDirection:string):boolean; Description: Clicks the desired direction on the minimap interface. Information: * Returns true if successful. * Uses the mouse. .. note:: - by Obscurity - Last Updated: 2015-08-07 Example: .. code-block:: pascal if minimap.getLocalPosition().y<50 then minimap.clickDirection('sOuTh'); *) function tMinimap.clickDirection(funcDirection:string):boolean; var funcAngle:double; begin case (funcDirection:=replaceRegExpr('(\W|_)*',lowercase(funcDirection),'',false)) of 'north':funcAngle:=0; 'northwest':funcAngle:=0.78539816339744830961566084581988; 'west':funcAngle:=1.5707963267948966192313216916401; 'southwest':funcAngle:=2.3561944901923449288469825374602; 'south':funcAngle:=3.1415926535897932384626433832795; 'southeast':funcAngle:=3.9269908169872415480783042291003; 'east':funcAngle:=4.7123889803846898576939650749203; 'northeast':funcAngle:=5.4977871437821381673096259207404; end; exit(result:=tMinimap.clickRadians(funcAngle)); end; (* tMinimap.clickHomeTeleport() ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: pascal function tMinimap.clickHomeTeleport():boolean; Description: Clicks the home teleport butotn on the minimap interface. Information: * Returns true if successful. * Uses the mouse. .. note:: - by Obscurity - Last Updated: 2015-08-07 Example: .. code-block:: pascal if (not lodestone.hasLodeStone()) and (not lodeStone.isTeleporting()) then minimap.clickHomeTeleport(); *) function tMinimap.clickHomeTeleport():boolean; var funcPointer:^glTexture; funcPointerSize:uInt32; funcPoint: TPoint; begin funcPointer:=glTextures(funcPointerSize); for 0 to funcPointerSize-1 do begin if funcPointer^.id=87984 then begin funcPoint:=funcPointer^.bounds.normalizePoint(); clickMouse(funcPoint.x, funcPoint.y, 1); result:=true; break; end; funcPointer+=oglTextureSize; end; exit(result); end; (* tMinimap.clickLocalPosition() ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: pascal function tMinimap.clickLocalPosition(funcPoint:tPoint):boolean; Description: Clicks the desired coordinate on the minimap interface, if it is visible. Information: * Returns true if successful. * Uses the mouse. .. note:: - by Obscurity - Last Updated: 2015-08-07 Example: .. code-block:: pascal if abs(point(50,50).distanceFrom(minimap.getLocalPosition()))>5 then minimap.clickLocalPosition([50,50]); *) function tMinimap.clickLocalPosition(funcPoint:tPoint):boolean; var funcBounds:array[0..11] of tPoint; funcPointer:^glTexture; funcPointerSize:uInt32; funcScreenPosition:tPoint; begin funcPointer:=glTextures(funcPointerSize); for 0 to funcPointerSize-4 do begin if funcPointer^.id=237147 then begin funcBounds:=[ [funcPointer^.bounds.x1,funcPointer^.bounds.y2-20], [funcPointer^.bounds.x2-20,funcPointer^.bounds.y2-20], [funcPointer^.bounds.x2-20,funcPointer^.bounds.y1], [(funcPointer+oglTextureSize)^.bounds.x1+20,(funcPointer+oglTextureSize)^.bounds.y1], [(funcPointer+oglTextureSize)^.bounds.x1+20,(funcPointer+oglTextureSize)^.bounds.y2-20], [(funcPointer+oglTextureSize)^.bounds.x2,(funcPointer+oglTextureSize)^.bounds.y2-20], [(funcPointer+3*oglTextureSize)^.bounds.x2,(funcPointer+3*oglTextureSize)^.bounds.y1+20], [(funcPointer+3*oglTextureSize)^.bounds.x1+20,(funcPointer+3*oglTextureSize)^.bounds.y1+20], [(funcPointer+3*oglTextureSize)^.bounds.x1+20,(funcPointer+3*oglTextureSize)^.bounds.y2], [(funcPointer+2*oglTextureSize)^.bounds.x2-20,(funcPointer+2*oglTextureSize)^.bounds.y2], [(funcPointer+2*oglTextureSize)^.bounds.x2-20,(funcPointer+2*oglTextureSize)^.bounds.y1+20], [(funcPointer+2*oglTextureSize)^.bounds.x1,(funcPointer+2*oglTextureSize)^.bounds.y1+20] ]; funcScreenPosition:=self.getScreenPosition(funcPoint); if funcScreenPosition.isInPoly(funcBounds) then begin clickMouse(funcScreenPosition.x, funcScreenPosition.y, 1); result:=true; end; break; end; funcPointer+=oglTextureSize; end; end; (* tMinimap.clickRadians() ~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: pascal function tMinimap.clickRadians(funcRadians:double):boolean; Description: Clicks the desired direction, in radians, on the minimap interface. Information: * Returns true if successful. * Uses the mouse. .. note:: - by Obscurity - Last Updated: 2015-08-07 Example: .. code-block:: pascal if minimap.getLocalPosition().y<50 then minimap.clickRadians(3.14); *) function tMinimap.clickRadians(funcRadians:double):boolean; var funcMapX, funcMapY:array[0..3] of single; funcPointer:^glTexture; funcPointerSize:uInt32; funcRadius, funcScale:double; funcPoint: TPoint; begin glMapCoords(funcMapX,funcMapY); try funcRadians:=-funcRadians+arcTan2(funcMapY[3]-funcMapY[0],funcMapX[3]-funcMapX[0])-1.5707963267948966192313216916398; except end; funcPointer:=glTextures(funcPointerSize); for 0 to funcPointerSize-4 do begin if funcPointer^.id=237147 then begin funcRadius:=funcPointer^.distanceFrom((funcPointer+3*oglTextureSize)^)/2-10; funcPoint:=tPoint([round((funcPointer^.x+(funcPointer+3*oglTextureSize)^.x)/2+funcRadius*cos(funcRadians)*(funcScale:=normalRandomE())),round((funcPointer^.y+(funcPointer+3*oglTextureSize)^.y)/2+funcRadius*sin(funcRadians)*funcScale)]); clickMouse(funcPoint.x, funcPoint.y, 1); result:=true; break; end; funcPointer+=oglTextureSize; end; exit(result); end; (* tMinimap.clickResetCamera() ~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: pascal function tMinimap.clickResetCamera():boolean; Description: Clicks the compass on the minimap interface to reset the camera. Information: * Returns true if successful. * Uses the mouse. .. note:: - by Obscurity - Last Updated: 2015-08-07 Example: .. code-block:: pascal case minimap.getHorizontalDegrees() of 180..270:minimap.clickResetCamera(); end; *) function tMinimap.clickResetCamera(funcDirection:string='north';funcWait:int32=0):boolean; var funcPointer:^glTexture; funcPointerSize:uInt32; funcPoint: TPoint; begin funcPointer:=glTextures(funcPointerSize); for 0 to funcPointerSize-1 do begin if funcPointer^.id=147885 then begin if execRegExpr('^(?i)n(orth)?$',funcDirection) then begin funcPoint:=funcPointer^.bounds.normalizePoint(); clickMouse(funcPoint.x, funcPoint.y, 1); result:=true; end else if execRegExpr('^(?i)s(outh)?$',funcDirection) then result:=tmouse.rightClickOption(funcPointer^.bounds,'Face South',funcWait); break; end; funcPointer+=oglTextureSize; end; exit(result); end; (* tActionBar.getDegrees() ~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: pascal function tMinimap.getDegrees():int32; Description: Retrieves the degrees of rotation of the minimap. Information: * Returns 0..360, relative to the rotation of the minimap. .. note:: - by Obscurity - Last Updated: 2015-08-07 Example: .. code-block:: pascal case minimap.getDegrees() of 0..180:ogl.debug('Facing west.'); 181..360:ogl.debug('Facing east.'); end; *) function tMinimap.getDegrees():int32; var funcAngle:double; funcMapX, funcMapY:array[0..3] of single; begin glMapCoords(funcMapX,funcMapY); try funcAngle:=arcTan2(funcMapY[3]-funcMapY[0],funcMapX[3]-funcMapX[0]); except end; if funcAngle>0 then result:=round(funcAngle*360/(2*3.1415926535897932384626433832795)) else result:=round((2*3.1415926535897932384626433832795+funcAngle)*360/(2*3.1415926535897932384626433832795)); exit(result); end; (* tMinimap.getLocalPosition() ~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: pascal function tMinimap.getLocalPosition():tPoint; function tMinimap.getLocalPosition(funcPoint:tPoint):tPoint;overload; function tMinimap.getLocalPosition(funcTexture:glTexture):tPoint;overload; Description: Retrieves the position of the player, a point, or a texture, relative to the current minimap. Leaving the parameter blank will use the player's current position. Information: * Returns a tPoint, relative to the object's position on the minimap. .. note:: - by Obscurity - Last Updated: 2015-08-07 Example: .. code-block:: pascal case minimap.getLocalPosition().y of 0..60:minimap.clickDirection('south'); 68..128:minimap.clickDirection('north'); end; *) function tMinimap.getLocalPosition():tPoint; var funcMap:array[0..1] of array[0..3] of single; funcPointer:^glTexture; funcPointerSize:uInt32; funcPlayer, funcPosition:array[0..1] of double; begin funcPointer:=glTextures(funcPointerSize); for 0 to funcPointerSize-1 do begin if funcPointer^.id=237147 then begin funcPlayer:=[(funcPointer^.bounds.x1+(funcPointer+3*oglTextureSize)^.bounds.x2)/2,(funcPointer^.bounds.y1+(funcPointer+3*oglTextureSize)^.bounds.y2)/2]; glMapCoords(funcMap[0],funcMap[1]); try funcPosition[0]:=((funcPlayer[0]-funcMap[0][0])*(funcMap[1][1]-funcMap[1][0])-(funcPlayer[1]-funcMap[1][0])*(funcMap[0][1]-funcMap[0][0]))*512.0/((funcMap[0][3]-funcMap[0][0])*(funcMap[1][1]-funcMap[1][0])-(funcMap[1][3]-funcMap[1][0])*(funcMap[0][1]-funcMap[0][0]))/4; funcPosition[1]:=((funcPlayer[1]-funcMap[1][0])*(funcMap[0][3]-funcMap[0][0])-(funcPlayer[0]-funcMap[0][0])*(funcMap[1][3]-funcMap[1][0]))*512.0/((funcMap[0][3]-funcMap[0][0])*(funcMap[1][1]-funcMap[1][0])-(funcMap[1][3]-funcMap[1][0])*(funcMap[0][1]-funcMap[0][0]))/4; except end; result:=[round(funcPosition[0]+0.1) , round(funcPosition[1]+0.1)]; break; end; funcPointer+=oglTextureSize; end; exit(result); end; function tMinimap.getLocalPosition(funcPoint:tPoint):tPoint;overload; var funcMap:array[0..1] of array[0..3] of single; funcPosition:array[0..1] of double; begin glMapCoords(funcMap[0],funcMap[1]); try funcPosition[0]:=((funcPoint.x-funcMap[0][0])*(funcMap[1][1]-funcMap[1][0])-(funcPoint.y-funcMap[1][0])*(funcMap[0][1]-funcMap[0][0]))*512.0/((funcMap[0][3]-funcMap[0][0])*(funcMap[1][1]-funcMap[1][0])-(funcMap[1][3]-funcMap[1][0])*(funcMap[0][1]-funcMap[0][0]))/4; funcPosition[1]:=((funcPoint.y-funcMap[1][0])*(funcMap[0][3]-funcMap[0][0])-(funcPoint.x-funcMap[0][0])*(funcMap[1][3]-funcMap[1][0]))*512.0/((funcMap[0][3]-funcMap[0][0])*(funcMap[1][1]-funcMap[1][0])-(funcMap[1][3]-funcMap[1][0])*(funcMap[0][1]-funcMap[0][0]))/4; except end; result:=[round(funcPosition[0]),round(funcPosition[1])]; exit(result); end; function tMinimap.getLocalPosition(funcTexture:glTexture):tPoint;overload; begin exit(self.getLocalPosition(funcTexture.toPoint()));end; (* tMinimap.getPlayer() ~~~~~~~~~~~~~~~~~~~~ .. code-block:: pascal function tMinimap.getPlayer():tPoint; Description: Retrieves the position of the center of the minimap interface where the player is located. Information: * Returns a tPoint, relative to the center of the minimap interface. .. note:: - by Obscurity - Last Updated: 2015-08-07 Example: .. code-block:: pascal mouse.click(minimap.getPlayer().adjustPosition(12,12)); *) function tMinimap.getPlayer():tPoint; var funcPointer:^glTexture; funcPointerSize:uInt32; begin funcPointer:=glTextures(funcPointerSize); for 0 to funcPointerSize-1 do begin if funcPointer^.id=237147 then begin result:=[round((funcPointer^.bounds.x1+(funcPointer+3*oglTextureSize)^.bounds.x2)/2),round((funcPointer^.bounds.y1+(funcPointer+3*oglTextureSize)^.bounds.y2)/2)]; break; end; funcPointer+=oglTextureSize; end; exit(result); end; (* tActionBar.getRadians() ~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: pascal function tMinimap.getRadians():double; Description: Retrieves the radians of rotation of the minimap. Information: * Returns 0..6.2831853, relative to the rotation of the minimap. .. note:: - by Obscurity - Last Updated: 2015-08-07 Example: .. code-block:: pascal case minimap.getRadians() of 0..3.1415926:ogl.debug('Facing west.'); 3.1415926..6.2831853:ogl.debug('Facing east.'); end; *) function tMinimap.getRadians():double; var funcMapX, funcMapY:array[0..3] of single; begin glMapCoords(funcMapX,funcMapY); try result:=arcTan2(funcMapY[3]-funcMapY[0],funcMapX[3]-funcMapX[0]); except end; if result<0 then result+=2*3.1415926535897932384626433832795; exit(result); end; (* tMinimap.getRunEnergy() ~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: pascal function tMinimap.getRunEnergy():int32; Description: Retrieves the current run energy percentage. Information: * Returns 0..100, relative to the current run energy. .. note:: - by Obscurity - Last Updated: 2015-08-07 Example: .. code-block:: pascal if minimap.getRunEnergy()<50 then minimap.setRunMode(false); *) function tMinimap.getRunEnergy():int32; var funcCA:^glChar; funcCASize, funcTASize:uInt32; funcEnergy:string; funcTA:^glTexture; begin funcTA:=glTextures(funcTASize); for 0 to funcTASize-1 do begin if funcTA^.id=159981 then begin funcCA:=glFonts(funcCASize)+(funcCASize-1)*oglCharSize; for 0 to funcCASize div 2 do begin if pointInBox(funcCA^.toPoint(),funcTA^.bounds) then begin case funcCA^.letter of '0'..'9':funcEnergy:=funcCA^.letter+funcEnergy; end; end else if funcEnergy<>'' then begin result:=strToInt(funcEnergy); break; end; funcCA-=2*oglCharSize; end; break; end; funcTA+=oglTextureSize; end; exit(result); end; (* tMinimap.getRunMode() ~~~~~~~~~~~~~~~~~~~~~ .. code-block:: pascal function tMinimap.getRunMode():boolean; Description: Retrieves the current state of the run mode. Information: * Returns false or true, relative to the current state of the run mode. .. note:: - by Obscurity - Last Updated: 2015-08-07 Example: .. code-block:: pascal if (minimap.getRunEnergy()>50) and (not minimap.getRunMode()) then minimap.setRunMode(true); *) function tMinimap.getRunMode():boolean; var funcPointer:^glTexture; funcPointerSize:uInt32; begin funcPointer:=glTextures(funcPointerSize); for 0 to funcPointerSize-2 do begin if funcPointer^.id=159981 then begin result:=(funcPointer+oglTextureSize)^.id=171817; break; end; funcPointer+=oglTextureSize; end; exit(result); end; (* tMinimap.getScreenPosition() ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: pascal function tMinimap.getScreenPosition(funcPoint:tPoint):tPoint; Description: Retrieves the on-screen coordinate of a localPosition, relative to the minimap. See tMinimap.getLocalPosition(). Information: * Returns a tPoint, relative to the localPosition on the minimap. .. note:: - by Obscurity - Last Updated: 2015-08-07 Example: .. code-block:: pascal mouse.click(minimap.getScreenPosition([64,64])); *) function tMinimap.getScreenPosition(funcPoint:tPoint):tPoint; var funcAngle, funcDistance:double; funcMap:array[0..1] of array[0..3] of single; begin glMapCoords(funcMap[0],funcMap[1]); try funcAngle:=-arcTan2(funcMap[1][3]-funcMap[1][0],funcMap[0][3]-funcMap[0][0])-arcTan2(funcPoint.y-64,funcPoint.x-64)+1.5707963267948966192313216916398; except end; funcDistance:=sqrt(pow(64-funcPoint.x,2)+pow(64-funcPoint.y,2))*4; result:=[round((funcMap[0][0]+funcMap[0][2])/2+funcDistance*sin(funcAngle)),round((funcMap[1][0]+funcMap[1][2])/2+funcDistance*cos(funcAngle))]; end; (* tMinimap.setDegrees() ~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: pascal function tMinimap.setDegrees(funcDegrees:int32):boolean; Description: Sets the degree of rotation of the minimap interface. Information: * Returns true if successful. * Uses the keyboard. .. note:: - by Obscurity - Last Updated: 2015-08-07 Example: .. code-block:: pascal minimap.setDegrees(minimap.getDegrees()+random(-45,45)); *) function tMinimap.setDegrees(funcDegrees:int32):boolean; begin exit(result:=tMinimap.setRadians(funcDegrees*0.01745329251994329576923690768489));end; (* tMinimap.setDirection() ~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: pascal function tMinimap.setDirection(funcDirection:ansiString):boolean; Description: Sets the direction of rotation of the minimap interface. Information: * Returns true if successful. * Uses the keyboard. .. note:: - by Obscurity - Last Updated: 2015-08-07 Example: .. code-block:: pascal case minimap.getDegrees() of 0..180:minimap.setDirection('eAsT'); end; *) function tMinimap.setDirection(funcDirection:ansiString):boolean; var funcAngle:double; begin case (funcDirection:=replaceRegExpr('(\W|_)*',lowercase(funcDirection),'',false)) of 'north':funcAngle:=0; 'northwest':funcAngle:=0.78539816339744830961566084581988; 'west':funcAngle:=1.5707963267948966192313216916401; 'southwest':funcAngle:=2.3561944901923449288469825374602; 'south':funcAngle:=3.1415926535897932384626433832795; 'southeast':funcAngle:=3.9269908169872415480783042291003; 'east':funcAngle:=4.7123889803846898576939650749203; 'northeast':funcAngle:=5.4977871437821381673096259207404; end; exit(result:=tMinimap.setRadians(funcAngle)); end; (* tMinimap.setRadians() ~~~~~~~~~~~~~~~~~~~~~ .. code-block:: pascal function tMinimap.setRadians(funcRadians:double):boolean; Description: Sets the rotation, in radians, of the minimap interface. Information: * Returns true if successful. * Uses the keyboard. .. note:: - by Obscurity - Last Updated: 2015-08-07 Example: .. code-block:: pascal minimap.setRadians(minimap.getRadians()+3.1415926); *) function tMinimap.setRadians(funcRadians:double):boolean; var funcDifference:double; funcLeft, funcRight, funcTimedOut:boolean; funcTimeOut:tCountDown; begin funcTimeOut.setTime(random(2500,5000)); while (abs(funcDifference:=shortestRadians(tMinimap.getRadians(),funcRadians))>oglAngleTolerance) and (not (funcTimedOut:=funcTimeOut.isFinished())) do begin funcLeft:=isKeyDown(37); funcRight:=isKeyDown(39); if funcDifference<0 then begin if funcRight then keyUp(39); if funcLeft then continue; keyDown(37); end else begin if funcLeft then keyUp(37); if funcRight then continue; keyDown(39); end; end; if isKeyDown(37) then keyUp(37); if isKeyDown(39) then keyUp(39); exit(result:=not funcTimedOut); end; (* tMinimap.setRunMode() ~~~~~~~~~~~~~~~~~~~~~ .. code-block:: pascal function tMinimap.setRunMode(funcEnable:boolean):boolean; Description: Sets the state of the run mode. If run mode is already set to the desired state, the method is ignored. Information: * Returns true if successful. * Uses the mouse. .. note:: - by Obscurity - Last Updated: 2015-07-24 Example: .. code-block:: pascal if minimap.getRunEnergy()<50 then minimap.setRunMode(false); *) function tMinimap.setRunMode(funcEnable:boolean):boolean; var funcPointer:^glTexture; funcPointerSize:uInt32; funcPoint: TPoint; begin funcPointer:=glTextures(funcPointerSize); for 0 to funcPointerSize-2 do begin if funcPointer^.id=159981 then begin if ((funcPointer+oglTextureSize)^.id=171817)<>funcEnable then begin funcPoint:=funcPointer^.bounds.normalizePoint(); clickMouse(funcPoint.x, funcPoint.y, 1); result:=true; end; break; end; funcPointer+=oglTextureSize; end; exit(result); end;