Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.BasicStroke;
- import java.awt.Color;
- import java.awt.Font;
- import java.awt.Graphics;
- import java.awt.Graphics2D;
- import java.awt.event.KeyEvent;
- import com.rarebot.event.events.MessageEvent;
- import com.rarebot.event.listeners.MessageListener;
- import com.rarebot.event.listeners.PaintListener;
- import com.rarebot.script.Script;
- import com.rarebot.script.ScriptManifest;
- import com.rarebot.script.wrappers.RSArea;
- import com.rarebot.script.wrappers.RSObject;
- import com.rarebot.script.wrappers.RSTile;
- @ScriptManifest(name = "OldsCastleWarsAfker", version = 0.1, description = "Afks the Castle Wars minigame", authors = "Oldrs4ever")
- public class OldsCastleWarsAfker extends Script implements MessageListener, PaintListener
- {
- public long startTime = 0;
- public long millis = 0;
- public long hours = 0;
- public long minutes = 0;
- public long seconds = 0;
- public long last = 0;
- int guthixPortal = 4408;
- //Is sara and zammy same id's for ladders?
- int[] Ladder = {6281, 6280};
- int Tickets = 4067;
- int bankChest = 4483;
- int[] Trapdoor = {4471, 4472};
- int gamesWon = 0;
- int gamesLost = 0;
- int gamesTied = 0;
- int ticketsGained = 0;
- RSArea lobby = new RSArea(new RSTile(2437, 3081, 0), new RSTile(2446, 3098, 0));
- RSArea saraLobby = new RSArea(new RSTile(2370, 9482), new RSTile(2392, 2495));
- RSArea zammyLobby = new RSArea(new RSTile(2410, 9514), new RSTile(9430, 9534));
- RSArea saraBase = new RSArea(new RSTile(2423, 3072, 1), new RSTile(3431, 3080, 1));
- RSArea zammyBase = new RSArea(new RSTile(2361, 3127, 1), new RSTile(2376, 3135, 1));
- RSArea saraAFK = new RSArea(new RSTile(2423, 3072, 2), new RSTile(3431, 3080, 2));
- RSArea zammyAFK = new RSArea(new RSTile(2368, 3127, 2), new RSTile(2376, 3135, 2));
- public int loop()
- {
- RSObject portal = objects.getNearest(guthixPortal);
- RSObject ladder = objects.getNearest(Ladder);
- RSObject trapdoor = objects.getNearest(Trapdoor);
- //RSObject Chest = objects.getNearest(bankChest);
- //RSItem tickets = inventory.getItem(Tickets);
- try
- {
- if(interfaces.getComponent(985, 77).isValid())
- {
- interfaces.getComponent(985, 77).doClick(true);
- sleep(1000,2000);
- }
- else if(lobby.contains(getMyPlayer().getLocation()))
- {
- camera.turnTo(portal);
- portal.interact("Enter Guthix portal");
- sleep(random(1500,3000));
- }
- else if(interfaces.getComponent(1188, 3).isValid())
- {
- interfaces.getComponent(1188, 3).doClick(true);
- sleep(7500,15000);
- }
- else if(saraLobby.contains(getMyPlayer().getLocation()))
- {
- antiBan();
- sleep(random(1500,2000));
- }
- else if(zammyLobby.contains(getMyPlayer().getLocation()))
- {
- antiBan();
- sleep(random(1500,2000));
- }
- else if(ladder != null)
- {
- camera.turnTo(ladder);
- ladder.interact("Climb-up");
- sleep(random(2000,3000));
- }
- else if(trapdoor != null)
- {
- antiBan();
- sleep(random(1500,2500));
- }
- }catch(Exception ex){}
- return 0;
- }
- public boolean onStart()
- {
- log(new Color(125,38,205), "Welcome to OldsCastleWars by Oldrs4ever!");
- startTime = System.currentTimeMillis();
- mouse.setSpeed(random(4, 6));
- return true;
- }
- private void antiBan()
- {
- int num = random(0,13);
- switch(num)
- {
- case 0:
- camera.moveRandomly(random(100,500));
- sleep(random(300, 500));
- break;
- case 1:
- mouse.moveOffScreen();
- break;
- case 3:
- mouse.moveRandomly(200, 600);
- sleep(random(300, 500));
- break;
- case 5:
- mouse.moveRandomly(random(100,500));
- break;
- case 7:
- mouse.moveSlightly();
- sleep(random(300, 500));
- break;
- case 10:
- mouse.move(random(527, 200), random(744, 464));
- break;
- case 13:
- int i = random(0,2);
- if( i <= 1)
- {
- keyboard.pressKey((char)KeyEvent.VK_RIGHT);
- sleep(random(700, 1000));
- keyboard.releaseKey((char)KeyEvent.VK_RIGHT);
- }
- else
- {
- keyboard.pressKey((char)KeyEvent.VK_LEFT);
- sleep(random(700, 1000));
- keyboard.releaseKey((char)KeyEvent.VK_LEFT);
- }
- break;
- default:
- break;
- }
- }
- @Override
- public void messageReceived(MessageEvent e)
- {
- String x = e.getMessage().toLowerCase();
- if (x.contains("won"))
- {
- gamesWon++;
- ticketsGained += 2;
- }
- else if (x.contains("lost"))
- {
- gamesLost++;
- }
- else if (x.contains("draw"))
- {
- gamesTied++;
- ticketsGained++;
- }
- }
- //START: Code generated using Enfilade's Easel
- private final Color color1 = new Color(0, 204, 204, 229);
- private final Color color2 = new Color(0, 0, 0);
- private final Color color3 = new Color(11, 39, 222, 229);
- private final Color color4 = new Color(0, 0, 0, 229);
- private final BasicStroke stroke1 = new BasicStroke(1);
- private final Font font1 = new Font("Vivaldi", 0, 25);
- private final Font font2 = new Font("Arial", 0, 10);
- public void onRepaint(Graphics g1) {
- Graphics2D g = (Graphics2D)g1;
- millis = System.currentTimeMillis() - startTime;
- hours = millis / (1000 * 60 * 60);
- millis -= hours * (1000 * 60 * 60);
- minutes = millis / (1000 * 60);
- millis -= minutes * (1000 * 60);
- seconds = millis / 1000;
- g.setColor(color1);
- g.fillRoundRect(350, 227, 168, 111, 16, 16);
- g.setColor(color2);
- g.setStroke(stroke1);
- g.drawRoundRect(350, 227, 168, 111, 16, 16);
- g.setFont(font1);
- g.setColor(color3);
- g.drawString("OldsCastleWars", 362, 225);
- g.setFont(font2);
- g.setColor(color4);
- g.drawString("Time Running:" + hours +":"+ minutes + ":" + seconds, 353, 242);
- g.drawString("Games Won:" + gamesWon, 354, 264);
- g.drawString("Games Lost:" + gamesLost, 354, 286);
- g.drawString("Games Tied:" + gamesTied, 354, 310);
- g.drawString("Tickets Gained:" + ticketsGained, 354, 333);
- }
- //END: Code generated using Enfilade's Easel
- }
Advertisement
Add Comment
Please, Sign In to add comment