Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.96 KB | None | 0 0
  1. import java.awt.BasicStroke;
  2. import java.awt.Color;
  3. import java.awt.Font;
  4. import java.awt.Graphics;
  5. import java.awt.Graphics2D;
  6. import java.awt.Image;
  7. import java.awt.Point;
  8. import java.awt.Rectangle;
  9. import java.awt.event.KeyEvent;
  10. import java.awt.event.MouseEvent;
  11. import java.awt.event.MouseListener;
  12. import java.io.BufferedReader;
  13. import java.io.IOException;
  14. import java.io.InputStreamReader;
  15. import java.net.URL;
  16. import java.net.URLConnection;
  17. import java.util.ArrayList;
  18. import java.util.List;
  19.  
  20. import javax.imageio.ImageIO;
  21. import javax.swing.JOptionPane;
  22.  
  23. import org.rsbot.event.events.MessageEvent;
  24. import org.rsbot.event.listeners.MessageListener;
  25. import org.rsbot.event.listeners.PaintListener;
  26. import org.rsbot.script.methods.Magic;
  27. import org.rsbot.script.Script;
  28. import org.rsbot.script.ScriptManifest;
  29. import org.rsbot.script.methods.Skills;
  30. import org.rsbot.script.methods.GrandExchange.GEItem;
  31. import org.rsbot.script.util.Filter;
  32. import org.rsbot.script.util.Timer;
  33. import org.rsbot.script.wrappers.RSArea;
  34. import org.rsbot.script.wrappers.RSGroundItem;
  35. import org.rsbot.script.wrappers.RSItem;
  36. import org.rsbot.script.wrappers.RSNPC;
  37. import org.rsbot.script.wrappers.RSObject;
  38. import org.rsbot.script.wrappers.RSPath;
  39. import org.rsbot.script.wrappers.RSTile;
  40. import org.rsbot.script.wrappers.RSTilePath;
  41.  
  42. @ScriptManifest(authors = "M1ckst3r", name = "Cow Looter", keywords = "Moneymaking", description = "Loots cowhides and bones in Lumbridge", version = 1.00)
  43. public class CowLooter extends Script implements PaintListener {
  44. final int HidesID = 1739;
  45. final int BonesID = 526;
  46. final int MeatID = 2132;
  47. final int[] stairsID = {36774, 36773,36775};
  48. final int BankerID = 494;
  49. public int IBStart = 0;
  50. public int IMStart = 0;
  51. public int IHStart = 0;
  52. public float Bones;
  53. public float Hides;
  54. public float BonesPrice;
  55. public float HidesPrice;
  56. public int curtime;
  57. public int hour;
  58. public int min;
  59. public int sec;
  60. public int atstart = 1;
  61.  
  62. RSArea CowArea = new RSArea(new RSTile(3253,3255),new RSTile(3266,3299));
  63. RSArea CowArea2 = new RSArea(new RSTile(3245,3279),new RSTile(3266,3299));
  64. RSArea BankArea = new RSArea(new RSTile(3207,3221),new RSTile(3210,3215));
  65. RSArea GateArea = new RSArea(new RSTile(3255,3269),new RSTile(3250,3264));
  66. RSArea StairsArea = new RSArea(new RSTile(3203,3206),new RSTile(3209,3213));
  67. RSArea BridgeArea = new RSArea(new RSTile(3249,3265),new RSTile(3228,3258));
  68. RSArea CEArea = new RSArea(new RSTile(3225,3221), new RSTile(3232,3216));
  69. RSArea AnnoyingHouse = new RSArea(new RSTile(3229,3241), new RSTile(3232,3236));
  70.  
  71. RSTile StairsTile = new RSTile(3206,3210);
  72. RSTile CETile = new RSTile(3229,3218);
  73. RSTile BridgeTile = new RSTile(3235,3262);
  74. RSTile BankTile = new RSTile(3208,3220);
  75. RSTile GateTile = new RSTile(3254,3266);
  76. RSTile dest;
  77. RSTile Nearest;
  78.  
  79. final int gateClosedID = 45212;
  80. final int gateOpenID = 45213;
  81. public String state;
  82. public String stateMsg;
  83. GEItem bonesGE;
  84. GEItem hidesGE;
  85. private boolean takepic = false;
  86. private long STime;
  87. private long starttime;
  88.  
  89. private void Screenshot(int hour) {
  90. if (!takepic) {
  91. STime = System.currentTimeMillis();
  92. takepic = true;
  93. }
  94. if (takepic && (System.currentTimeMillis() - STime) >= (3600000 * hour)) {
  95. env.saveScreenshot(true);
  96. takepic = false;
  97. }
  98. }
  99.  
  100. public int loop(){
  101. Screenshot(1);
  102. if(atstart==1){
  103. setStartInvCount();
  104. getPrices();
  105. starttime = System.currentTimeMillis();
  106. atstart = 0;
  107. state = "teleport";
  108. }
  109.  
  110. state = getState();
  111. if (state == "loot"){
  112. stateMsg = "Looting";
  113. loot(HidesID, BonesID, 15);
  114. sleep(random(500,1000));
  115. if(IBStart!=(int)inventory.getCount(BonesID)){
  116. Bones+=1;
  117. setStartInvCount();
  118. }
  119. if(IHStart!=(int)inventory.getCount(HidesID)){
  120. Hides+=1;
  121. setStartInvCount();
  122. }
  123. }
  124. if (state == "walkGate"){
  125. stateMsg = "Walking to gate";
  126. walkTo(GateTile, 3, 3, 4);
  127. }
  128. if (state == "openGate"){
  129. stateMsg = "Opening gate";
  130. openGate();
  131. }
  132. if (state == "walkStairs"){
  133. stateMsg = "Walking to stairs";
  134. walkTo(StairsTile, 1, 1, 3);
  135. }
  136. if (state == "walkCE"){
  137. stateMsg = "Walking to castle entrance";
  138. walkTo(CETile, 4, 4, 4);
  139. }
  140. if (state == "walkCows"){
  141. stateMsg = "Walking into the cow area";
  142. walkTo(new RSTile(random(3253,3264),random(3255,3296)), 0, 0, 0);
  143. }
  144. if (state == "climbUpStairs"){
  145. stateMsg = "Climbing up the stairs";
  146. climbStairs("up");
  147. }
  148. if (state == "climbDownStairs"){
  149. stateMsg = "Climbing down the stairs";
  150. climbStairs("down");
  151. }
  152. if (state == "walkBridge"){
  153. stateMsg = "Walking to the bridge";
  154. walkTo(BridgeTile, 4, 4, 5);
  155. }
  156. if (state == "doBank"){
  157. stateMsg = "Banking";
  158. doBank();
  159. setStartInvCount();
  160. }
  161. if (state == "walkBank"){
  162. stateMsg = "Walking to the bank";
  163. walkTo(BankTile, 2, 2, 3);
  164. }
  165. if (state == "teleport"){
  166. stateMsg = "Teleporting";
  167. teleport();
  168. if(inventory.isFull()) state = "walkStairs";
  169. else state = "walkCE";
  170. }
  171. return 0;
  172. }
  173.  
  174. public void setStartInvCount(){
  175. IBStart = inventory.getCount(BonesID);
  176. IHStart = inventory.getCount(HidesID);
  177. }
  178.  
  179. public void getPrices(){
  180. log("Getting the prices of the items from the GE. This can take a while.");
  181. bonesGE = grandExchange.lookup(BonesID);
  182. hidesGE = grandExchange.lookup(HidesID);
  183. BonesPrice = bonesGE.getMarketPrice();
  184. HidesPrice = hidesGE.getMarketPrice();
  185. }
  186.  
  187. public void teleport(){
  188. if(magic.castSpell(Magic.SPELL_HOME_TELEPORT)) sleep(random(13000,18000));
  189. }
  190.  
  191. public void openGate(){
  192. if(!players.getMyPlayer().isMoving()){
  193. RSObject gate = objects.getNearest(gateClosedID);
  194. if(gate!=null){
  195. camera.turnToTile(gate.getLocation());
  196. gate.doAction("Open");
  197. sleep(random(500,1000));
  198. }
  199. }
  200. }
  201.  
  202. public void climbStairs(String direction){
  203. if(!players.getMyPlayer().isMoving()){
  204. RSObject stairs = objects.getNearest(stairsID);
  205. if(stairs != null){
  206. if(!stairs.isOnScreen()) camera.turnToTile(stairs.getLocation().randomize(1,1));
  207. stairs.doAction("Climb-"+direction);
  208. sleep(random(750,1250));
  209. }
  210. }
  211. }
  212.  
  213. public void walkTo(RSTile destination, int xvar, int yvar, int distance){
  214. setRun();
  215. if ((!players.getMyPlayer().isMoving())||(calc.distanceTo(dest)<distance)) {
  216. dest = walking.getClosestTileOnMap(destination.randomize(xvar, yvar));
  217. while (AnnoyingHouse.contains(dest)) dest = dest.randomize(2,2);
  218. walking.walkTileMM(dest);
  219. sleep(random(750,1500));
  220. }
  221. }
  222.  
  223. public void doBank(){
  224. RSNPC banker = npcs.getNearest(BankerID);
  225. if((!players.getMyPlayer().isMoving())&&(banker!=null)){
  226. if(!banker.isOnScreen()) camera.turnToTile(banker.getLocation().randomize(1,1));
  227. if(!bank.isOpen()){
  228. banker.doAction("Bank Banker");
  229. sleep(random(1000,1500));
  230. }
  231. else{
  232. bank.depositAll();
  233. sleep(random(1000,1500));
  234. bank.close();
  235. }
  236. }
  237. }
  238.  
  239. private String getState(){
  240. if(inventory.isFull()){
  241.  
  242. RSNPC banker = npcs.getNearest(BankerID);
  243. if(StairsArea.contains(getMyPlayer().getLocation())){
  244. if (banker == null) return "climbUpStairs";
  245. else return "walkBank";
  246. }
  247. else if((BankArea.contains(getMyPlayer().getLocation()))&&(banker != null)) return "doBank";
  248. else if(calc.distanceTo(StairsTile)>25)state = "teleport";
  249. }
  250. else{
  251. if(BankArea.contains(getMyPlayer().getLocation())) return "walkStairs";
  252.  
  253. RSObject stairs = objects.getNearest(36773);
  254. if(StairsArea.contains(getMyPlayer().getLocation())){
  255. if(stairs == null) return "climbDownStairs";
  256. else return "walkCE";
  257. }
  258.  
  259. if(CEArea.contains(getMyPlayer().getLocation())) return "walkBridge";
  260. if(BridgeArea.contains(getMyPlayer().getLocation())) return "walkGate";
  261. if((CowArea.contains(getMyPlayer().getLocation()))||(CowArea2.contains(getMyPlayer().
  262. getLocation()))) return "loot";
  263. else if(GateArea.contains(getMyPlayer().getLocation())){
  264. if(objects.getNearest(gateOpenID)!= null) return "walkCows";
  265. else return "openGate";
  266. }
  267.  
  268. }
  269. return state;
  270. }
  271.  
  272. public int loot(int lootID, int lootID2, int distance) {
  273. setRun();
  274. if (players.getMyPlayer().isMoving()) return 1;
  275. RSGroundItem loot = groundItems.getNearest(lootID);
  276. if((loot == null)||calc.distanceTo(loot.getLocation())>distance) loot = groundItems.getNearest(lootID2);
  277. if (loot != null) {
  278. if(CowArea.contains(loot.getLocation())||(CowArea2.contains(loot.getLocation()))) {
  279. if(!loot.isOnScreen()) camera.turnToTile(loot.getLocation());
  280. if (!inventory.isFull()) {
  281. if (!loot.isOnScreen()) {
  282. walking.walkTileMM(walking.getClosestTileOnMap(loot.getLocation()));
  283. return 1;
  284. }
  285. loot.doAction("Take " + loot.getItem().getName());
  286. sleep(random(500, 1000));
  287. return 1;
  288. }
  289. }
  290. }
  291. walkTo(new RSTile(random(3253,3264),random(3255,3296)), 0, 0, 0);
  292. return 1;
  293. }
  294.  
  295. public void setRun() {
  296. if (walking.getEnergy() > random(25, 100)) walking.setRun(true);
  297. sleep(250);
  298. }
  299.  
  300. public void onRepaint(Graphics g){
  301. g.setColor(new Color(0,0,0,255));
  302. g.fillRect(0,335,518,142);
  303. g.setColor(new Color(255,255,255,255));
  304. curtime = (int)(System.currentTimeMillis()-starttime)/1000;
  305. hour = curtime/60/60;
  306. min = (curtime - hour*3600)/60;
  307. sec = (curtime - hour*3600)-min*60;
  308. g.drawString("Time ran: "+hour+":"+min+":"+sec,5,350);
  309. g.drawString("Bones: "+((int)Bones),5,365);
  310. g.drawString("Bones/h: "+(Bones/curtime*3600),200,365);
  311. g.drawString("Hides: "+((int)Hides),5,380);
  312. g.drawString("Hides/h: "+(Hides/curtime*3600),200,380);
  313. g.drawString("Profit: approx. "+((int)(Bones*BonesPrice+Hides*HidesPrice))+"gp",5,395);
  314. g.drawString("Profit/h: approx. "+((Bones*BonesPrice+Hides*HidesPrice)/curtime*3600)+" gp",200,395);
  315. g.drawString("Action: "+stateMsg,5,410);
  316. g.setFont(new Font("Verdana", 0, 20));
  317. g.drawString("CowLooter by M1ckst3r",5,470);
  318. }
  319. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement