- import org.rsbot.bot.Bot;
- import org.rsbot.bot.input.Mouse;
- import org.rsbot.event.events.ServerMessageEvent;
- import org.rsbot.event.listeners.PaintListener;
- import org.rsbot.event.listeners.ServerMessageListener;
- import org.rsbot.script.*;
- import java.awt.Color;
- import java.awt.Graphics;
- import java.util.Map;
- import org.rsbot.script.Script;
- import org.rsbot.script.wrappers.RSObject;
- import org.rsbot.script.wrappers.RSTile;
- import org.rsbot.script.ScriptManifest;
- import org.rsbot.script.wrappers.RSNPC;
- @ScriptManifest(authors = { "Sharangan12" }, category = "Thieving", name = "SharanganMasterFarmer", version = 1.0, description =
- "<html><body bgcolor =\"#808000\"><font color =\"#3333FF\"><center><h2>SharanganMasterFarmer</h2><BR>"
- + "<font size =\"3\">Start in Draynor Bank With some Food<br />"
- + "<font size =\"3\">Have the requirments to steal.<br />"
- + "<font size =\"5\">IDS: Tuna 361 Monkfish 7946 <br />"
- + "<div class=\"main\""
- + "<div class=\"leftcol\">Food ID:</div><div class=\"rightcol\"><input type=\"text\" name=\"foodID\" value=\"\" size=10></b></div><br />"
- + "</div>"
- + "</font><br />"
- + "</font></body></html>")
- public class SharanganMasterFarmer extends Script implements PaintListener, ServerMessageListener {
- public int farmerID = 2234;
- public int foodID;
- public int BankBoothID = 2213;
- public int hp;
- int expGained;
- int levelsGained;
- int startXp;
- int startLevel;
- int height;
- long startTime;
- long minutes;
- long seconds;
- long hours;
- long runTime;
- public RSTile toBank = randomizeTile(new RSTile(3092,3245),2,2);
- public RSTile toFarmer = randomizeTile(new RSTile(3080,3250),2,2);
- boolean stunned = false;
- @Override
- protected int getMouseSpeed() {
- return random(5, 7);
- }
- public boolean onStart(Map<String, String> args) {
- hp = skills.getCurrentSkillLevel(Skills.getStatIndex("hitpoints"));
- startTime = System.currentTimeMillis();
- startXp = skills.getCurrentSkillExp(STAT_THIEVING);
- startLevel = skills.getCurrentSkillLevel(STAT_THIEVING);
- if (!args.get("foodID").equals("")) {
- foodID = Integer.parseInt(args.get("foodID"));
- }
- return true;
- }
- public void onFinish() {
- }
- public int loop() {
- if (isLoggedIn()) {
- hp = skills.getCurrentSkillLevel(Skills.getStatIndex("hitpoints"));
- setCameraAltitude(true);
- if(hp <= 8 || isInventoryFull())if(Eat() == false){
- if(atBank() && getInventoryCount(foodID) == 0){
- handleBank();
- return random(800,1600);
- }else{
- walkBank();
- }
- }
- if(hp >= 8 || getInventoryCount(foodID) != 0){
- if(atFarmer()){
- RSNPC masterFarmer = getNearestNPCByID(farmerID);
- if(masterFarmer != null)
- clickRSNPC(masterFarmer, "Pickpocket");
- return 800;
- }else{
- RSNPC masterFarmer = getNearestNPCByID(farmerID);
- RSTile tile = masterFarmer.getLocation();
- walkTileMM(tile);
- wait(random(1000,2000));
- }
- }
- if (stunned == true){
- wait(random(2500, 3500));
- }
- }
- return 100;
- }
- public int walkToFarmer(){
- walkTileMM(toFarmer);
- wait(3000);
- return random(3000,4000);
- }
- public boolean handleBank(){
- RSObject bankBooth = getNearestObjectByID(BankBoothID);
- if(bankBooth == null)
- return false;
- if(bank.isOpen()){
- bank.depositAll();
- while(getInventoryCount(foodID) == 0){
- bank.withdraw(foodID, 10);
- wait(1500);
- }
- walkToFarmer();
- }else{
- atObject(bankBooth, "quickly");
- }
- return true;
- }
- public boolean atFarmer() {
- RSNPC farmer = getNearestNPCByID(farmerID);
- if(farmer == null)
- return false;
- return tileOnScreen(farmer.getLocation());
- }
- public int walkBank(){
- walkTileMM(toBank);
- wait(3000);
- return random(3000,4000);
- }
- public boolean Eat(){
- if (getInventoryCount(foodID) != 0) {
- atInventoryItem(foodID,"eat");
- wait(random(1000,1500));
- return true;
- }
- return false;
- }
- public boolean atBank() {
- RSObject bank = getNearestObjectByID(BankBoothID);
- if(bank == null)
- return false;
- return tileOnScreen(bank.getLocation());
- }
- @Override
- public void onRepaint(Graphics g) {
- Mouse m = Bot.getClient().getMouse();
- runTime = System.currentTimeMillis( ) - startTime;
- seconds = runTime / 1000;
- if ( seconds >= 60 ) {
- minutes = seconds / 60;
- seconds -= (minutes * 60);
- }
- if ( minutes >= 60 ) {
- hours = minutes / 60;
- minutes -= (hours * 60);
- }
- int x = 5;
- int y = 180;
- expGained = skills.getCurrentSkillExp(STAT_THIEVING) - startXp;
- g.setColor( new Color(0, 0, 0, 171) );
- g.fillRoundRect(x, y, 140, height, 5, 5);
- // Calculate levels gained
- levelsGained = skills.getCurrentSkillLevel(STAT_THIEVING) - startLevel;
- g.setColor( Color.GREEN );
- if (m.x > x + 155 || m.x < x || m.y > height + 180 || m.y < y) {
- g.drawString("SharanganMasterFarmer", x + 9, y += 16);
- g.drawString(">>More Details<<", x + 9, y += 16);
- } else {
- g.drawString("SharanganMasterFarmer", x + 9, y += 16);
- g.drawString("1.0", x + 9, y += 16);
- g.drawString("Time Ran " + hours + ":" + minutes + ":" + seconds, x + 9, y += 16);
- g.drawString("Expirence Gained: " + expGained, x + 9, y += 16);
- g.drawString(">>More Details<<", x + 9, y += 16);
- g.drawString("Levels Gained: " + levelsGained, x + 9, y += 16);
- g.drawString("Next Level %: " + skills.getPercentToNextLevel(STAT_THIEVING), x + 9, y += 16);
- }
- height = y - 173;
- }
- @Override
- public void serverMessageRecieved(ServerMessageEvent e) {
- String message = e.getMessage();
- if (message.contains("You've been stunned")) {
- stunned = true;
- }
- }
- }
