Advertisement
Guest User

Untitled

a guest
May 30th, 2017
525
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.57 KB | None | 0 0
  1. import org.rsbot.script.*;
  2. import org.rsbot.bot.*;
  3. import org.rsbot.accessors.Model;
  4. import org.rsbot.accessors.RSAnimable;
  5. import org.rsbot.script.wrappers.*;
  6. import org.rsbot.event.listeners.*;
  7. import org.rsbot.event.events.*;
  8. import org.rsbot.util.*;
  9. import org.rsbot.bot.input.*;
  10. import java.awt.*;
  11. import java.util.*;
  12. import java.io.*;
  13. import java.net.*;
  14. import javax.swing.*;
  15.  
  16. @ScriptManifest(authors = { "Blake" }, category = "Woodcutting", name = "xWillows", version = 1.0, description =
  17. "<html><body><center><br><font size=6>BNS Scripting xWillows V1.17</font><br><br>" +
  18. "<br><br> xWillowss is a new script, start in Draynor Village while logged in" +
  19. " and start the script :)" +
  20. "Report any bugs to the email, xrealm@live.com" +
  21. "<br>The script is in BETA")
  22.  
  23. public class xWillows extends Script implements PaintListener {
  24.  
  25. /* Paint variables */
  26. private int startLevel;
  27. private String status = "";
  28. public int levelsgained;
  29. public int startexp;
  30. public int nextlvl;
  31. public int exp;
  32. public int logsChopped;
  33. public int logperhour;
  34. public int expGained;
  35. public int chopped;
  36. public float expsec;
  37. public float expmin;
  38. public int axetype;
  39. public float exphour;
  40. public long timeRunning = 0, seconds = 0 ,minutes = 0, hours = 0;
  41. public long startTime = System.currentTimeMillis();
  42. /* EOF */
  43. /* anti ban fixes */
  44. public int pchatoff = 0;
  45. public int cameralow = 0;
  46. public boolean check = true;
  47. /* EOF */
  48. /* id's */
  49. public RSTile firstTree = new RSTile(3087, 3237);
  50. int Clicks = 0;
  51. public int[] axes = { 1359, 1349, 1351, 1353, 1355, 1357, 1361, 6739, 13661 };
  52. public int willowTree[] = { 5551, 5553, 5552 };
  53. public int bankID = 2213;
  54. public RSTile[] Banktile = { new RSTile(3094, 3241), new RSTile(3094, 3243) };
  55. public RSTile Banks = new RSTile(3094, 3243);
  56. public RSTile Trees = new RSTile(3087, 3233);
  57. public RSTile willowTile = new RSTile(3087, 3233);
  58. public int wcanim = 867;
  59. /* EOF */
  60. final ScriptManifest properties = getClass().getAnnotation(ScriptManifest.class);
  61.  
  62. public boolean onStart(Map<String, String> args) {
  63. startTime = System.currentTimeMillis();
  64. startLevel = skills.getCurrentSkillLevel(STAT_WOODCUTTING);
  65. logsChopped = 0;
  66. pchatoff = 0;
  67. cameralow = 0;
  68. if (startLevel == 0) {
  69. startLevel = skills.getCurrentSkillLevel(Constants.STAT_WOODCUTTING);
  70. }
  71. return true;
  72. }
  73. public RSObject getClosestTreeByID(final int... ids) {
  74. RSObject cur = null;
  75. double dist = -1;
  76.  
  77. for (int x = 0; x < 104; x++) {
  78. outer: for (int y = 0; y < 104; y++) {
  79. final RSObject o = getObjectAt(x + Bot.getClient().getBaseX(),
  80. y + Bot.getClient().getBaseY());
  81.  
  82. if (o != null) {
  83. boolean isObject = false;
  84. for (final int id : ids) {
  85. if (o.getID() == id) {
  86. isObject = true;
  87. break;
  88. }
  89. }
  90. if (isObject) {
  91. final RSObject tl = getObjectAt(x
  92. + Bot.getClient().getBaseX() - 1, y
  93. + Bot.getClient().getBaseY());
  94. final RSObject tb = getObjectAt(x
  95. + Bot.getClient().getBaseX(), y
  96. + Bot.getClient().getBaseY() - 1);
  97. final int id = o.getID();
  98. if (tl != null && tl.getID() == id || tb != null
  99. && tb.getID() == id) {
  100. continue outer;
  101. }
  102. final double distTmp = calculateDistance(getMyPlayer()
  103. .getLocation(), o.getLocation());
  104.  
  105. if (cur == null || distTmp < dist) {
  106. dist = distTmp;
  107. cur = o;
  108. }
  109. }
  110. }
  111. }
  112. }
  113. return cur;
  114. }
  115. boolean clickTree(RSObject obj1,String action) {
  116. if (!(obj1.getObject() instanceof RSAnimable)) {
  117. return atTree(obj1, action);
  118. }
  119. RSAnimable anim = (RSAnimable) obj1.getObject();
  120. Model model = obj1.getModel();
  121. int index = random(0, model.getXPoints().length);
  122. int xoff = model.getXPoints()[index];
  123. int yoff = model.getZPoints()[index];
  124. int zoff = model.getYPoints()[index];
  125. final Point p = Calculations.worldToScreen(anim.getX() + xoff, anim
  126. .getY()
  127. + zoff, -yoff);
  128. if (p.x == -1)
  129. return false;
  130. while (getMyPlayer().isMoving()) {
  131. wait(random(20,120));
  132. }
  133. moveMouse(getModelPoint(obj1), 3, 3);
  134. return atMenu(action);
  135. }
  136. private Point getModelPoint(RSObject obj) {
  137. Model model = obj.getModel();
  138. RSAnimable animable = (RSAnimable) obj.getObject();
  139. Point[] screenCoords = new Point[model.getXPoints().length];
  140. for (int i = 0; i < screenCoords.length; i++) {
  141. int x = model.getXPoints()[i] + animable.getX();
  142. int z = model.getZPoints()[i] + animable.getY();
  143. int y = model.getYPoints()[i]
  144. + Calculations.tileHeight(animable.getX(), animable.getY());
  145. screenCoords[i] = Calculations.w2s(x, y, z);
  146. }
  147. return screenCoords[random(0, screenCoords.length)];
  148. }
  149. public boolean openBank() {
  150. walkPathMM(Banktile, 1, 1);
  151. RSObject bank = findObject(bankID);
  152. if (bank == null) {
  153. turnToObject(bank);
  154. return false;
  155. }
  156. if (bank != null) {
  157. turnToObject(bank);
  158. atObject(bank, "Use-quickly");
  159. return true;
  160. }
  161. return true;
  162. }
  163. public boolean depositLogs() {
  164. bank.depositAllExcept(axes);
  165. bank.close();
  166. walkTileMM(willowTile, 1, 1);
  167. return true;
  168. }
  169. public int loop() {
  170.  
  171. RSObject tree = getClosestTreeByID(willowTree);
  172.  
  173. try {
  174. if (cameralow == 0) {
  175. setCameraAltitude(true);
  176. cameralow = 1;
  177. }
  178. if (pchatoff == 0) {
  179. setPrivateChat(CHAT_MODE.OFF);
  180. pchatoff = 1;
  181. }//switch world int world switchWorld
  182. // public boolean walkPathMM(RSTile[] path, int maxDist, int randX, int randY)
  183. //public static int distanceBetween(RSTile t1, RSTile t2)
  184. if (getEnergy() > random(30, 60)) {
  185. setRun(true);
  186. }
  187. if (getMyPlayer().isMoving()) {
  188. return random(500, 700);
  189. }
  190. if(getMyPlayer().getAnimation() == wcanim){
  191. status = "Chopping";
  192. return random(400, 600);
  193. }
  194. if (distanceTo(Trees) > 7 && !isInventoryFull()) {
  195. status = "Banking";
  196. walkPathMM(randomizePath(generateProperPath(Trees),2,2));
  197. return random(100, 200);
  198. }
  199. if (distanceTo(Banks) > 6 && isInventoryFull()) {
  200. walkPathMM(randomizePath(generateProperPath(Banks),2,2));
  201. if (!bank.isOpen()) {
  202. openBank();
  203. }
  204. if (bank.isOpen()) {
  205. depositLogs();
  206. }
  207. return random(100, 200);
  208. }
  209. if(distanceTo(firstTree) > 70) {
  210. walkPathMM(randomizePath(generateProperPath(firstTree),2,2));
  211. wait(random(500,1000));
  212. Clicks++;
  213. if(Clicks++ >= 10000){
  214. log("You have clicked 10000 times and you are still not where you want to be!");
  215. wait(random(500000, 1000000));
  216. }
  217. }
  218. if (getMyPlayer().isInCombat()) {
  219. log("Player in combat!!");
  220. walkPathMM(Banktile, 1, 1);
  221. return random(150, 220);
  222. }
  223. if (isInventoryFull()) {
  224. status = "Banking";
  225. if (!bank.isOpen()) {
  226. openBank();
  227. }
  228. if (bank.isOpen()) {
  229. depositLogs();
  230. return random(700, 900);
  231. }
  232. return random(700, 900);
  233. }
  234. if (tree == null) {
  235. status = "Looking for tree";
  236. turnToObject(tree);
  237. } else {
  238. clickTree(tree, "Chop down");
  239. return random(300, 500);
  240. }
  241. clickTree(tree, "Chop down");
  242. return random(300, 500);
  243. } catch (Exception e) {
  244. return random(300, 500);
  245. }
  246. }
  247.  
  248. /* Paint */
  249. public void onRepaint(Graphics g) {
  250. Mouse m = Bot.getClient().getMouse();
  251. if (isLoggedIn()) {
  252.  
  253. if ( startexp == 0) {
  254. startexp = skills.getCurrentSkillExp(Constants.STAT_WOODCUTTING);
  255. }
  256. nextlvl = skills.getCurrentSkillLevel(Constants.STAT_WOODCUTTING) + 1;
  257. final int fill = (int) (.8 * (double) nextlvl);
  258. expGained = skills.getCurrentSkillExp(Constants.STAT_WOODCUTTING) - startexp;
  259. levelsgained = skills.getCurrentSkillLevel(Constants.STAT_WOODCUTTING) - startLevel;
  260. timeRunning = System.currentTimeMillis() - startTime;
  261. seconds = timeRunning / 1000;
  262. logsChopped = expGained/68;
  263.  
  264. if (seconds >= 60) {
  265. minutes = seconds / 60;
  266. seconds -= minutes * 60;
  267. }
  268. if (minutes >= 60) {
  269. hours = minutes / 60;
  270. minutes -= hours * 60;
  271. }
  272. if ((minutes > 0 || hours > 0 || seconds > 0) && expGained > 0) {
  273. expsec = ((float) expGained)/(float)(seconds + (minutes*60) + (hours*60*60));
  274. }
  275. expmin = expsec * 60;
  276. exphour = expmin * 60;
  277.  
  278.  
  279. /* body and text for paint */
  280. g.setColor(new Color(0, 0, 0, 175));
  281. g.fillRoundRect(1, 62, 125, 230, 10, 10);
  282. g.setColor(Color.WHITE);
  283. g.drawString("BnS Scripts xWillows", 5, 77);
  284. g.drawString("Version: 1", 5, 95);
  285. g.drawString("Run Time: " + hours + ":" + minutes + ":" + seconds, 5, 132);
  286. g.drawString("Status: "+status+"", 5, 159);
  287. g.drawString("XP/Hour: "+ exphour +"" , 5, 174);
  288. g.drawString("Levels Gained: "+levelsgained+"", 5, 201);
  289. g.drawString("XP Gained: "+ expGained +"", 5, 216);
  290. g.setColor(new Color(0, 0, 0));
  291. g.fillRoundRect(5, 219, 80, 230, 9, 9);
  292. g.setColor(new Color(0, 255, 0));
  293. g.fillRoundRect(5, 219, (skills.getPercentToNextLevel(STAT_WOODCUTTING) * 80 / 100), 230, 9, 9);
  294. g.setColor(Color.red);
  295. g.drawString(Integer.toString(nextlvl) + "%", 5, 231);
  296. g.setColor(Color.magenta);
  297. g.drawRect(5, 219, 80, 13);
  298. g.setColor(Color.white);
  299. g.drawString("Logs chopped: "+ logsChopped +"", 5, 258);
  300. }
  301. }
  302. /* random tab */
  303. private void openRandomTab() {
  304. int randomNumber = random(1, 13);
  305. if (randomNumber <= 13) {
  306. if (randomNumber == 1 && !(getCurrentTab() == TAB_STATS)) {
  307. openTab(TAB_STATS);
  308. }
  309. if (randomNumber == 2 && !(getCurrentTab() == TAB_ATTACK)) {
  310. openTab(TAB_ATTACK);
  311. }
  312. if (randomNumber == 3 && !(getCurrentTab() == TAB_EQUIPMENT)) {
  313. openTab(TAB_EQUIPMENT);
  314. }
  315. if (randomNumber == 4 && !(getCurrentTab() == TAB_FRIENDS)) {
  316. openTab(TAB_FRIENDS);
  317. }
  318. if (randomNumber == 6 && !(getCurrentTab() == TAB_MAGIC)) {
  319. openTab(TAB_MAGIC);
  320. }
  321. if (randomNumber == 7 && !(getCurrentTab() == TAB_NOTES)) {
  322. openTab(TAB_NOTES);
  323. }
  324. if (randomNumber == 8 && !(getCurrentTab() == TAB_OPTIONS)) {
  325. openTab(TAB_OPTIONS);
  326. }
  327. if (randomNumber == 9 && (getCurrentTab() == TAB_PRAYER)) {
  328. openTab(TAB_PRAYER);
  329. }
  330. if (randomNumber == 10 && !(getCurrentTab() == TAB_IGNORE)) {
  331. openTab(TAB_IGNORE);
  332. }
  333. if (randomNumber == 11 && !(getCurrentTab() == TAB_CLAN)) {
  334. openTab(TAB_CLAN);
  335. }
  336. if (randomNumber == 12 && !(getCurrentTab() == TAB_INVENTORY)) {
  337. openTab(TAB_INVENTORY);
  338. }
  339. if (randomNumber == 13 && !(getCurrentTab() == TAB_MUSIC)) {
  340. openTab(TAB_MUSIC);
  341. }
  342. }
  343. }
  344. /* antiban */
  345. public void antiban() {
  346. int randomNumber = random(1, 3);
  347. if (randomNumber <= 3) {
  348. if (randomNumber == 1) {
  349. openRandomTab();
  350. wait(random(100, 500));
  351. moveMouse(631, 254, random(60, 200));
  352. wait(random(1300, 2200));
  353. }
  354. if (randomNumber == 2) {
  355. moveMouse(random(50, 700), random(50, 450), 2, 2);
  356. wait(random(200, 700));
  357. moveMouse(random(50, 700), random(50, 450), 2, 2);
  358. }
  359. if (randomNumber == 3) {
  360. wait(random(100, 200));
  361. setCameraRotation(random(1,360));
  362. wait(random(100, 200));
  363. moveMouse(random(50, 700), random(50, 450), 2, 2);
  364. }
  365. }
  366. }
  367. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement