Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.82 KB | None | 0 0
  1. private int directionBetween(RSTile tile1,RSTile tile2,int rand)
  2. {
  3.     double x1,y1,x2,y2,retVal,rnd;
  4.     x1 = tile1.getX();
  5.     y1 = tile1.getY();
  6.     x2 = tile2.getX();
  7.     y2 = tile2.getY();
  8.     rnd = Math.abs(rand);
  9.     if ((x1 == x2) && (y1 == y2))
  10.         return 0;
  11.     if (x2-x1 == 0) {
  12.         if (y2>=y1)
  13.             return 270;
  14.         return 90;
  15.     }
  16.     retVal = (180/Math.PI)*(Math.atan2((y1-y2),(x2-x1)));
  17.     retVal += random(0,rnd*2)-rnd;
  18.     if (retVal < 0) {
  19.         retVal += 360;
  20.     }
  21.     retVal += 90;        
  22.     if (retVal >= 360) retVal -= 360;
  23.     return (int)retVal;
  24. }
  25.  
  26. private void cameraFaceTile(RSTile target)
  27. {
  28.     camera.setAngle(directionBetween(getMyPlayer().getLocation(),target,5));
  29.     sleep(600,850);
  30. }
  31.  
  32. private void cameraFaceObject(RSObject target)
  33. {
  34.     cameraFaceTile(target.getLocation());
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement