- import java.awt.*;
- import java.util.*;
- import java.util.List;
- import java.lang.reflect.Method;
- import java.util.logging.Level;
- import javax.accessibility.*;
- import javax.swing.*;
- import org.rsbot.bot.Bot;
- import org.rsbot.script.*;
- import org.rsbot.script.wrappers.*;
- import org.rsbot.event.listeners.PaintListener;
- import org.rsbot.event.listeners.ServerMessageListener;
- import org.rsbot.event.events.ServerMessageEvent;
- import org.rsbot.util.ScreenshotUtil;
- @ScriptManifest(authors = { "Charlie" }, category = "CSeries", name = "CIvies", version = 1.00,
- description = "<html><head></head><body>CIvies - Beta Introduces: Charlie's new Paint! Flawless Ivy Chopping!</body></html\n")
- public class CIvies extends Script implements PaintListener {
- //INTS AND VARIABLES
- public int[] IvyID = {17464, 36411, 46318, 46320, 46322, 46324, 17462};
- public int[] BirdNest = {5070, 5071, 5072, 5073, 5074, 5075, 5076, 7413,
- 11966};
- public int cutAnimation = 872;
- int BirdNests = 0;
- public int startXp;
- public int choppedIvy;
- public int expGained;
- public int exp;
- public long startTime = System.currentTimeMillis();
- private long waitTimer;
- //ENDS INTS
- public boolean onStart(Map<String, String> args) {
- final int welcome = JOptionPane
- .showConfirmDialog(
- null,
- "Would you like to click some adverts to support me?",
- "Welcome", JOptionPane.YES_NO_OPTION);
- if (welcome == 0) {
- final String message = "<html><h1>Thank you for your support!</h1><br/>"
- + "<p>You will now be redirected to my adverts page. <br/>"
- + "Click the adverts on the page few times a day if you can.</p>"
- + "</html>";
- JOptionPane.showMessageDialog(null, message);
- openURL("http://cb570af6.linkbucks.com");
- }
- return true;
- }
- public void openURL(final String url) { // Credits to Dave who gave credits
- // to
- // some guy who made this.
- final String osName = System.getProperty("os.name");
- try {
- if (osName.startsWith("Mac OS")) {
- final Class<?> fileMgr = Class
- .forName("com.apple.eio.FileManager");
- final Method openURL = fileMgr.getDeclaredMethod("openURL",
- new Class[] { String.class });
- openURL.invoke(null, new Object[] { url });
- } else if (osName.startsWith("Windows")) {
- Runtime.getRuntime().exec(
- "rundll32 url.dll,FileProtocolHandler " + url);
- } else { // assume Unix or Linux
- final String[] browsers = { "firefox", "opera", "konqueror",
- "epiphany", "mozilla", "netscape" };
- String browser = null;
- for (int count = 0; count < browsers.length && browser == null; count++) {
- if (Runtime.getRuntime().exec(
- new String[] { "which", browsers[count] })
- .waitFor() == 0) {
- browser = browsers[count];
- }
- }
- if (browser == null) {
- throw new Exception("Could not find web browser");
- } else {
- Runtime.getRuntime().exec(new String[] { browser, url });
- }
- }
- } catch (final Exception e) {
- }
- }
- public boolean Chop() {
- final RSObject tree = getNearestObjectByID(IvyID);
- if(tree == null){
- return true;
- }
- if(animationIs(cutAnimation)){
- return true;
- }
- else if(tree != null){
- atObject(tree, "Chop");
- wait(random(500,600));
- return false;
- }
- return false;
- }
- public int loop() {
- if(isIdle()) {
- Chop();
- wait(random(800,1000));
- }
- RSItemTile Nest = getGroundItemByID(BirdNest);
- if (Nest != null && !isInventoryFull()) {
- atTile(Nest, "Take");
- BirdNests++;
- wait(random(750, 1500));
- }
- return 100;
- }
- public void onRepaint(Graphics g) {
- long millis = System.currentTimeMillis() - startTime;
- int y = 211;
- long ivyPerHour = 0;
- long expPerHour = 0;
- long expGained = 0;
- long levelsGained = 0;
- int startlvl = 0;
- if(startlvl == 0){
- startlvl = skills.getCurrentSkillLevel(STAT_WOODCUTTING);
- }
- int xpToLvl = skills.getXPToNextLevel(STAT_WOODCUTTING);
- if ( startXp == 0) {
- startXp = skills.getCurrentSkillExp(STAT_WOODCUTTING);
- }
- exp = skills.getCurrentSkillExp(STAT_WOODCUTTING) - startXp;
- if (choppedIvy > 0)
- ivyPerHour = choppedIvy * 3600 / (millis / 1000);
- if(exp > 0)
- expPerHour = exp * 3600 / (millis / 1000);
- long hours = millis / (1000 * 60 * 60);
- millis -= hours * (1000 * 60 * 60);
- long minutes = millis / (1000 * 60);
- millis -= minutes * (1000 * 60);
- long seconds = millis / 1000;
- g.setFont(new Font("Arial", Font.BOLD, 12));
- g.setColor(Color.green);
- g.setColor(Color.black);
- g.drawString("CIvies - Beta Runtime: " + hours + ":" + minutes + ":" + seconds,
- 15, y += 14);
- g.drawString("Gained Exp: " + exp, 15, y += 14);
- g.drawString("Ivies Chopped: " + choppedIvy, 15, y += 14);
- g.drawString("Current Level: " + skills.getCurrentSkillLevel(Constants.STAT_WOODCUTTING),
- 15, y += 14);
- g.drawString("EXP/Hour: "+ expPerHour, 15, y += 14);
- g.setColor(new Color(255, 0, 0, 140));
- g.fillRoundRect(15, y += 5, 100, 12, 10, 12);
- g.setColor(new Color(0, 255, 0, 140));
- g.fillRoundRect(15, y, skills.getPercentToNextLevel(8), 12, 10, 12);
- g.setColor(Color.black);
- g.drawString("" + skills.getPercentToNextLevel(8) + "%", 55,
- y += 10);
- final int percent = skills.getPercentToNextLevel
- (Constants.STAT_WOODCUTTING);
- }
- //Server Message
- public void serverMessageRecieved(final ServerMessageEvent m) {
- final String message = m.getMessage();
- if (message.contains("You succ")) {
- choppedIvy++;
- }
- }
- public void onFinish() {
- log("Thanks for using the CSeries!");
- }
- }
