Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private int directionBetween(RSTile tile1,RSTile tile2,int rand)
- {
- double x1,y1,x2,y2,retVal,rnd;
- x1 = tile1.getX();
- y1 = tile1.getY();
- x2 = tile2.getX();
- y2 = tile2.getY();
- rnd = Math.abs(rand);
- if ((x1 == x2) && (y1 == y2))
- return 0;
- if (x2-x1 == 0) {
- if (y2>=y1)
- return 270;
- return 90;
- }
- retVal = (180/Math.PI)*(Math.atan2((y1-y2),(x2-x1)));
- retVal += random(0,rnd*2)-rnd;
- if (retVal < 0) {
- retVal += 360;
- }
- retVal += 90;
- if (retVal >= 360) retVal -= 360;
- return (int)retVal;
- }
- private void cameraFaceTile(RSTile target)
- {
- camera.setAngle(directionBetween(getMyPlayer().getLocation(),target,5));
- sleep(600,850);
- }
- private void cameraFaceObject(RSObject target)
- {
- cameraFaceTile(target.getLocation());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement