Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.54 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.Point;
  7.  
  8. import org.rsbot.event.events.MessageEvent;
  9. import org.rsbot.event.listeners.MessageListener;
  10. import org.rsbot.event.listeners.PaintListener;
  11. import org.rsbot.script.Random;
  12. import org.rsbot.script.Script;
  13. import org.rsbot.script.ScriptManifest;
  14. import org.rsbot.script.wrappers.RSArea;
  15. import org.rsbot.script.wrappers.RSComponent;
  16. import org.rsbot.script.wrappers.RSItem;
  17. import org.rsbot.script.wrappers.RSInterface;
  18. import org.rsbot.script.wrappers.RSNPC;
  19. import org.rsbot.script.wrappers.RSObject;
  20. import org.rsbot.script.wrappers.RSPlayer;
  21. import org.rsbot.script.wrappers.RSTile;
  22. import org.rsbot.script.wrappers.RSTilePath;
  23. import org.rsbot.script.methods.Bank;
  24. import org.rsbot.script.methods.Camera;
  25. import org.rsbot.script.methods.Equipment;
  26. import org.rsbot.script.methods.Game;
  27. import org.rsbot.script.methods.Interfaces;
  28. import org.rsbot.script.methods.Magic;
  29. import org.rsbot.script.methods.Objects;
  30. import org.rsbot.script.methods.Players;
  31. import org.rsbot.script.methods.Skills;
  32.  
  33. @ScriptManifest(authors = "qwerty", name = "lawcrafter", version = 1.3, description = "start at daemonheim banker with law tiara equiped")
  34. public class lawcrafter extends Script{
  35.  
  36. //
  37. // NPC
  38. //
  39. public int bankerID = 9710;
  40. public int mamarosID = 9711;
  41. public int monkID[] = {657, 2728, 2729};
  42.  
  43. //
  44. //Paths
  45. //
  46. public RSTile[] PORTAL_TO_ALTAR = { new RSTile(2464, 4819), new RSTile(2464, 4825), new RSTile(2464, 4830) };
  47.  
  48. public RSTile[] PIER_TO_RUINS = { new RSTile(2834, 3335), new RSTile(2840, 3335), new RSTile(2845, 3335),
  49. new RSTile(2850, 3336), new RSTile(2855, 3340), new RSTile(2859, 3341),
  50. new RSTile(2859, 3345), new RSTile(2859, 3350), new RSTile(2859, 3355),
  51. new RSTile(2857, 3357), new RSTile(2857, 3360), new RSTile(2857, 3365),
  52. new RSTile(2858, 3370), new RSTile(2858, 3375), new RSTile(2858, 3379)};
  53.  
  54. public RSTile[] STILE_TO_DEPOSIT_BOX = { new RSTile(3063, 3282), new RSTile(3063, 3278), new RSTile(3063, 3273),
  55. new RSTile(3062, 3269), new RSTile(3061, 3263), new RSTile(3058, 3260),
  56. new RSTile(3056, 3254), new RSTile(3053, 3249), new RSTile(3049, 3246),
  57. new RSTile(3043, 3245), new RSTile(3042, 3241), new RSTile(3043, 3237),
  58. new RSTile(3047, 3236)};
  59.  
  60. public RSTile[] DAEMONHEIM_TO_BANK = { new RSTile(3450, 3700), new RSTile(3450, 3705), new RSTile(3450, 3710),
  61. new RSTile(3450, 3715), new RSTile(3450, 3720)};
  62.  
  63. public RSTile[] CABBAGE_TO_STILE = { new RSTile(3054, 3289), new RSTile(3058, 3288), new RSTile(3063, 3284)};
  64.  
  65. //
  66. // Objects IDs
  67. //
  68. public int altarObjectID = 2485;
  69. public int ruinsObjectID = 2459;
  70. public int stileID = 7527;
  71. public int dboxID = 36788;
  72. public int gangplankID = 2415;
  73.  
  74. //
  75. // Item IDs
  76. //
  77. public int law_rune_ID = 563;
  78. public int pure_ess_ID = 7936;
  79. public int exp_ring_ID = 19760;
  80. //public int exp_ring_ID = 13562;
  81.  
  82. //
  83. // Area
  84. //
  85. //public RSArea BankArea = new RSArea(new RSTile(3447, 3719), new RSTile(3449, 3721));
  86. public RSArea BankArea = new RSArea(new RSTile(3446, 3718), new RSTile(3450, 3722));
  87. public RSArea AltarArea = new RSArea(new RSTile(2459, 4827), new RSTile(2469, 4837));
  88. public RSArea CabbageArea = new RSArea(new RSTile(3053, 3284), new RSTile(3064, 3290));
  89. public RSArea stileArea = new RSArea(new RSTile(3061, 3283), new RSTile(3065, 3285));
  90. public RSArea dboxArea = new RSArea(new RSTile(3046, 3236), new RSTile(3048, 3237));
  91. public RSArea ruinsArea = new RSArea(new RSTile(2856, 3379), new RSTile(2860, 3382));
  92.  
  93. //
  94. // Methods
  95. //
  96. public void banking() {
  97. RSNPC bank_obj = npcs.getNearest(bankerID);
  98.  
  99. camera.setPitch(true);
  100. if ( !getMyPlayer().isMoving() && !(interfaces.get(Bank.INTERFACE_BANK).isValid()) ) {
  101. bank_obj.interact("Bank Fremennik Banker");
  102. sleep(2000);
  103. }
  104.  
  105. if( interfaces.get( Bank.INTERFACE_BANK).isValid() ) {
  106. bank.depositAll();
  107. sleep(2000);
  108. bank.withdraw(exp_ring_ID, 0);
  109. sleep(2000);
  110. bank.withdraw(pure_ess_ID, 0);
  111. while ( bank.isOpen() ) {
  112. bank.close();
  113. sleep(1000);
  114. }
  115. }
  116. }
  117.  
  118. public void rest() {
  119. if ( interfaces.getComponent(750, 6).doAction("Rest") ) {
  120. mouse.moveSlightly();
  121. while ( walking.getEnergy() < 100 ) {
  122. sleep(1500, 2000);
  123. }
  124. }
  125.  
  126. if ( !walking.isRunEnabled() ) {
  127. walking.setRun(true);
  128. }
  129. }
  130.  
  131. public void teleport() {
  132. if (getMyPlayer().getAnimation() != 13652) {
  133. if ( equipment.getItem(Equipment.RING).doAction("Teleport") ) {
  134. sleep(15000);
  135. }
  136. }
  137. }
  138.  
  139. public boolean IsInRandom() {
  140. RSInterface bugger = magic.getInterface();
  141. if ( bugger == null) {
  142. return true;
  143. } else {
  144. return false;
  145. }
  146. }
  147.  
  148. public void cabbageport() {
  149. RSItem explorer_ring = inventory.getItem(exp_ring_ID);
  150.  
  151. if ( !(explorer_ring == null) ){
  152. explorer_ring.doAction("Cabbage-port");
  153. sleep(3000);
  154. }
  155. }
  156.  
  157. public void crimb_stile() {
  158. RSObject stile = objects.getNearest(stileID);
  159.  
  160. if ( !(stile == null) ){
  161. if ( !getMyPlayer().isMoving() ) {
  162. stile.doAction("Climb");
  163. sleep(3000);
  164. }
  165. }
  166. }
  167.  
  168. public void deposit() {
  169. RSObject depositbox = objects.getNearest(dboxID);
  170.  
  171. depositbox.doClick();
  172. sleep(3000);
  173. if ( bank.isDepositOpen() ){
  174. bank.deposit(exp_ring_ID, 0);
  175. }
  176.  
  177. bank.close();
  178. }
  179.  
  180. public void boating() {
  181. int counter = 0;
  182.  
  183. RSNPC monk = npcs.getNearest(monkID);
  184.  
  185. if ( (monk != null) ){
  186. monk.interact("Take-boat");
  187. sleep(3000);
  188.  
  189. if ( interfaces.get(64).isValid() ) {
  190. while ( (objects.getNearest(gangplankID) == null) && (counter < 7) ) {
  191. sleep(1000);
  192. mouse.click(random(245,255), random(450,460), true);
  193. counter++;
  194. }
  195. }
  196. }
  197. }
  198.  
  199. public void depart() {
  200. RSObject gangplank = objects.getNearest(gangplankID);
  201.  
  202. if ( gangplank != null ){
  203. gangplank.doAction("Cross Gangplank");
  204. sleep(3000);
  205. }
  206. }
  207.  
  208. public void enter_ruins() {
  209. RSObject ruins = objects.getNearest(ruinsObjectID);
  210.  
  211. if ( ruins != null ){
  212. ruins.doAction("Enter");
  213. }
  214. }
  215.  
  216. public void craft_essence() {
  217. RSObject altar = objects.getNearest(altarObjectID);
  218.  
  219. if ( altar != null ){
  220. altar.doAction("Craft-rune");
  221. }
  222. }
  223.  
  224. public int loop(){
  225. if (game.isLoggedIn()){
  226. if ( walking.getEnergy() < random(10, 20) ) {
  227. log("Resting");
  228. rest();
  229. return 0;
  230. }
  231.  
  232. else if ( ((npcs.getNearest(mamarosID) != null) || (npcs.getNearest(bankerID) != null)) && !BankArea.contains(getMyPlayer().getLocation()) && walking.newTilePath(DAEMONHEIM_TO_BANK).isValid() ){
  233. log("Walking to bank");
  234. walking.newTilePath(DAEMONHEIM_TO_BANK).traverse();
  235. sleep(1000);
  236. return 0;
  237. }
  238.  
  239. else if ( (npcs.getNearest(bankerID) != null) && (!inventory.isFull() || !inventory.contains(exp_ring_ID) || !inventory.contains(pure_ess_ID)) ){
  240. log("Banking");
  241. banking();
  242. return 0;
  243. }
  244.  
  245. else if ( !bank.isOpen() && BankArea.contains(getMyPlayer().getLocation()) && inventory.contains(pure_ess_ID) && inventory.contains(exp_ring_ID) ){
  246. log("Cabbageport");
  247. cabbageport();
  248. sleep(1000);
  249. return 0;
  250. }
  251.  
  252. else if ( CabbageArea.contains(getMyPlayer().getLocation()) && !stileArea.contains(getMyPlayer().getLocation()) ){
  253. log("Walking to stile");
  254. walking.newTilePath(CABBAGE_TO_STILE).randomize(0,0).traverse();
  255. sleep(1000);
  256. return 0;
  257. }
  258.  
  259. else if ( stileArea.contains(getMyPlayer().getLocation()) ) {
  260. log("Crimbing over stile");
  261. crimb_stile();
  262. return 0;
  263. }
  264.  
  265. else if ( inventory.contains(exp_ring_ID) && !stileArea.contains(getMyPlayer().getLocation()) && !dboxArea.contains(getMyPlayer().getLocation()) && walking.newTilePath(STILE_TO_DEPOSIT_BOX).isValid() ){
  266. log("Walking to deposit box");
  267. walking.newTilePath(STILE_TO_DEPOSIT_BOX).traverse();
  268. return 0;
  269. }
  270.  
  271. else if ( objects.getNearest(dboxID) != null && inventory.contains(exp_ring_ID) ) {
  272. log("Deposit explorer ring");
  273. deposit();
  274. return 0;
  275. }
  276.  
  277. else if ( npcs.getNearest(monkID) != null ) {
  278. log("Taking boat");
  279. boating();
  280. return 0;
  281. }
  282.  
  283. else if ( objects.getNearest(gangplankID) != null ) {
  284. log("Departing boat");
  285. depart();
  286. return 0;
  287. }
  288.  
  289. else if ( !inventory.contains(exp_ring_ID) && inventory.contains(pure_ess_ID) && walking.newTilePath(PIER_TO_RUINS).isValid() && !ruinsArea.contains(getMyPlayer().getLocation()) ) {
  290. log("Walking to ruins");
  291. walking.newTilePath(PIER_TO_RUINS).traverse();
  292. if ( !getMyPlayer().isMoving() ) {
  293. log("Walking to ruins (method #2)");
  294. walking.walkTileMM(new RSTile(2858, 3379));
  295. }
  296. return 0;
  297. }
  298.  
  299. else if ( objects.getNearest(ruinsObjectID) != null ) {
  300. log("Entering ruins");
  301. enter_ruins();
  302. return 0;
  303. }
  304.  
  305. else if ( walking.newTilePath(PORTAL_TO_ALTAR).isValid() && !AltarArea.contains(getMyPlayer().getLocation()) ) {
  306. log("Walking to altar");
  307. walking.newTilePath(PORTAL_TO_ALTAR).traverse();;
  308. return 0;
  309. }
  310.  
  311. else if ( AltarArea.contains(getMyPlayer().getLocation()) && inventory.contains(pure_ess_ID) ) {
  312. log("Crafting runes");
  313. craft_essence();
  314. return 0;
  315. }
  316.  
  317. else if ( AltarArea.contains(getMyPlayer().getLocation()) && !inventory.contains(pure_ess_ID) ) {
  318. log("teleport to daemonheim");
  319. teleport();
  320. return 0;
  321. }
  322.  
  323. else if ( !IsInRandom() ) {
  324. sleep(5000);
  325. if ( !walking.newTilePath(DAEMONHEIM_TO_BANK).isValid() &&
  326. !walking.newTilePath(STILE_TO_DEPOSIT_BOX).isValid() &&
  327. !walking.newTilePath(PIER_TO_RUINS).isValid() &&
  328. !walking.newTilePath(PORTAL_TO_ALTAR).isValid() ) {
  329. log("Teleport: Lost the way/Failed random event");
  330. teleport();
  331. return 0;
  332. }
  333. }
  334. }
  335. return 0;
  336. }
  337.  
  338. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement