|
| 1 | +package scripting.idlescript; |
| 2 | + |
| 3 | +import bot.scriptselector.models.Category; |
| 4 | +import bot.scriptselector.models.ScriptInfo; |
| 5 | +import orsc.ORSCharacter; |
| 6 | + |
| 7 | +public class Man extends IdleScript { |
| 8 | + public static final ScriptInfo info = |
| 9 | + new ScriptInfo( |
| 10 | + new Category[] {Category.THIEVING, Category.IRONMAN_SUPPORTED}, |
| 11 | + "G-unit", |
| 12 | + "Thieves men. Supports batching."); |
| 13 | + |
| 14 | + private int successfulPickpockets; |
| 15 | + private int unsuccessfulPickpockets; |
| 16 | + private long startTime = 0L; |
| 17 | + final int paintGapY = 13; // Gap between paint text lines |
| 18 | + |
| 19 | + public void thieve() { |
| 20 | + final ORSCharacter manToThieve = controller.getNearestNpcById(11, false); |
| 21 | + controller.thieveNpc(manToThieve.serverIndex); |
| 22 | + controller.waitForBatching(false); |
| 23 | + } |
| 24 | + |
| 25 | + public void run() { |
| 26 | + while (controller.isInCombat()) { |
| 27 | + controller.walkTo(controller.currentX(), controller.currentY()); |
| 28 | + controller.sleep(500); |
| 29 | + } |
| 30 | + } |
| 31 | + |
| 32 | + public void checkSleep() { |
| 33 | + if (controller.getFatigue() >= 90 && controller.isRunning()) { |
| 34 | + while (!controller.isSleeping() && controller.isRunning()) { |
| 35 | + controller.itemCommand(1263); |
| 36 | + controller.sleep(2500); |
| 37 | + } |
| 38 | + while (controller.isSleeping() && controller.isRunning()) { |
| 39 | + controller.sleep(100); |
| 40 | + } |
| 41 | + } |
| 42 | + } |
| 43 | + |
| 44 | + public int start(String[] param) { |
| 45 | + controller.displayMessage("@red@G-unit's Man Thiever plesh", 3); |
| 46 | + |
| 47 | + startTime = System.currentTimeMillis(); |
| 48 | + successfulPickpockets = 0; |
| 49 | + unsuccessfulPickpockets = 0; |
| 50 | + |
| 51 | + while (controller.isRunning()) { |
| 52 | + thieve(); |
| 53 | + run(); |
| 54 | + checkSleep(); |
| 55 | + } |
| 56 | + return 1000; // start() must return a int value now. |
| 57 | + } |
| 58 | + |
| 59 | + @Override |
| 60 | + public void questMessageInterrupt(String message) { |
| 61 | + if (message.equals("You pick the man's pocket")) { |
| 62 | + successfulPickpockets++; |
| 63 | + } else if (message.contains("You fail to pick the man's pocket")) { |
| 64 | + unsuccessfulPickpockets++; |
| 65 | + } |
| 66 | + |
| 67 | + super.serverMessageInterrupt(message); |
| 68 | + } |
| 69 | + |
| 70 | + @Override |
| 71 | + public void paintInterrupt() { |
| 72 | + if (controller == null || !controller.isRunning()) { |
| 73 | + return; |
| 74 | + } |
| 75 | + |
| 76 | + int x = 10; |
| 77 | + int y = 25; |
| 78 | + |
| 79 | + controller.drawString("@gre@Man Thiever @whi@by @yel@G-Unit", x, y, 0xFFFFFF, 1); |
| 80 | + |
| 81 | + y += paintGapY; |
| 82 | + |
| 83 | + controller.drawString("Successful pickpockets: " + successfulPickpockets, x, y, 0xFFFFFF, 1); |
| 84 | + |
| 85 | + y += paintGapY; |
| 86 | + |
| 87 | + controller.drawString( |
| 88 | + "Unsuccessful pickpockets: " + unsuccessfulPickpockets, x, y, 0xFFFFFF, 1); |
| 89 | + |
| 90 | + y += paintGapY; |
| 91 | + final int totalPickpockets = unsuccessfulPickpockets + successfulPickpockets; |
| 92 | + controller.drawString("Total pickpockets: " + totalPickpockets, x, y, 0xFFFFFF, 1); |
| 93 | + |
| 94 | + if (successfulPickpockets > 0) { |
| 95 | + y += paintGapY; |
| 96 | + |
| 97 | + final float successRate = (successfulPickpockets * 100f / (totalPickpockets)); |
| 98 | + controller.drawString( |
| 99 | + "Success Rate: %" + String.format("%.2f", successRate), x, y, 0xFFFFFF, 1); |
| 100 | + } |
| 101 | + |
| 102 | + y += paintGapY; |
| 103 | + |
| 104 | + final long timeRunning = System.currentTimeMillis() - startTime; |
| 105 | + controller.drawString("Time Running: " + controller.msToString(timeRunning), x, y, 0xFFFFFF, 1); |
| 106 | + } |
| 107 | +} |
0 commit comments