Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package scripts;
- import java.awt.Color;
- import java.awt.Graphics;
- import java.util.ArrayList;
- import javax.swing.JOptionPane;
- import org.tribot.api.DynamicClicking;
- import org.tribot.api.General;
- import org.tribot.api.Timing;
- import org.tribot.api.input.Mouse;
- import org.tribot.api2007.Banking;
- import org.tribot.api2007.Camera;
- import org.tribot.api2007.ChooseOption;
- import org.tribot.api2007.Game;
- import org.tribot.api2007.Inventory;
- import org.tribot.api2007.NPCs;
- import org.tribot.api2007.Objects;
- import org.tribot.api2007.Player;
- import org.tribot.api2007.Skills;
- import org.tribot.api2007.Walking;
- import org.tribot.api2007.WebWalking;
- import org.tribot.api2007.Skills.SKILLS;
- import org.tribot.api2007.types.RSArea;
- import org.tribot.api2007.types.RSItem;
- import org.tribot.api2007.types.RSNPC;
- import org.tribot.api2007.types.RSObject;
- import org.tribot.api2007.types.RSTile;
- import org.tribot.script.Script;
- import org.tribot.script.ScriptManifest;
- import org.tribot.script.interfaces.MessageListening07;
- import org.tribot.script.interfaces.Painting;
- @ScriptManifest(authors = { "ITryNotToTroll" }, category = "Thieving", name = "Troll Thieving")
- public class TrollThieving extends Script implements Painting, MessageListening07{
- private State state;
- private RSTile lummyTile;
- private RSTile stallTile = new RSTile(3268, 3410, 0);
- private boolean running = true;
- private String foodName = "Monkfish";
- private int foodAmount = 5;
- private RSTile farmerTile = new RSTile(3080, 3250, 0);
- private RSArea bankArea = new RSArea(new RSTile(3097, 3240, 0), new RSTile(3092, 3246, 0));
- private boolean stunned = false;
- private int eatAtHitpoints = 40;
- private int mouseSpeedMin = 100;
- private int mouseSpeedMax = 120;
- private long startXP;
- private int startLevel;
- private long startTime;
- private long currentXP;
- private int currentLevel;
- private final double VERSION = 1.3;
- private ArrayList<String> loot = new ArrayList<>();
- @Override
- public void run()
- {
- initializeScript();
- while(running)
- {
- state = getState();
- switch(state)
- {
- case DEPOSIT_ALL_EXCEPT_FOOD:
- depositAllExceptFood();
- break;
- case OPEN_BANK:
- Banking.openBank();
- break;
- case WALK_TO_FARMER_NPC:
- walkToFarmerNPC();
- break;
- case WITHDRAW_FOOD:
- withdrawFood();
- break;
- case WALK_TO_BANK:
- WebWalking.walkToBank();
- while(Player.isMoving())
- {
- sleep(50, 100);
- }
- break;
- case EAT_FOOD:
- eatFood();
- break;
- case SLEEP:
- break;
- case PICKPOCKET_FARMER:
- pickPocketNPC("Master Farmer");
- sleep(300, 700);
- break;
- case DROP_TEA:
- dropAllTea();
- break;
- case ANIMATING:
- break;
- case STEAL_TEA:
- stealTea();
- break;
- case DEPOSIT_ALL:
- Banking.depositAll();
- break;
- case WALK_TO_STALL:
- WebWalking.walkTo(stallTile);
- break;
- case PICK_POCKET_MAN:
- pickPocketNPC("Man");
- sleep(300, 700);
- break;
- case WALK_TO_LUMMY_TILE:
- WebWalking.walkTo(lummyTile);
- break;
- case DROP_JUNK:
- dropJunk();
- break;
- case OUT_OF_FOOD:
- println("We have run out of food!");
- running = false;
- }
- sleep(50, 100);
- }
- }
- enum State{
- DEPOSIT_ALL_EXCEPT_FOOD,
- OPEN_BANK,
- WALK_TO_FARMER,
- WITHDRAW_FOOD,
- WALK_TO_BANK,
- EAT_FOOD,
- SLEEP,
- PICKPOCKET_FARMER,
- DROP_TEA,
- ANIMATING,
- STEAL_TEA,
- DEPOSIT_ALL,
- WALK_TO_STALL,
- PICK_POCKET_MAN,
- WALK_TO_LUMMY_TILE,
- DROP_JUNK,
- WALK_TO_FARMER_NPC, OUT_OF_FOOD
- }
- private State getState()
- {
- if(Skills.getActualLevel(SKILLS.THIEVING) < 5)
- {
- if(Player.getPosition().distanceTo(lummyTile) < 10)
- {
- if(NPCs.find("Man").length > 0 && NPCs.find("Man")[0].getPosition().distanceTo(Player.getPosition()) < 8)
- {
- return state.PICK_POCKET_MAN;
- }
- else
- {
- if(Player.getPosition().distanceTo(lummyTile) > 2)
- {
- return state.WALK_TO_LUMMY_TILE;
- }
- else
- {
- return state.SLEEP;
- }
- }
- }
- else
- {
- return state.WALK_TO_LUMMY_TILE;
- }
- }
- else
- {
- if(Skills.getActualLevel(SKILLS.THIEVING) < 38)
- {
- if(Player.getPosition().distanceTo(stallTile) < 6)
- {
- if(Inventory.getCount("Cup of tea") > 0)
- {
- return state.DROP_TEA;
- }
- else
- {
- if(Inventory.isFull())
- {
- return state.WALK_TO_BANK;
- }
- else
- {
- if(isAnimating())
- {
- return state.ANIMATING;
- }
- else
- {
- if(teaAvaliable())
- {
- return state.STEAL_TEA;
- }
- else
- {
- return state.SLEEP;
- }
- }
- }
- }
- }
- else
- {
- if(Inventory.isFull())
- {
- if(Banking.isInBank()){
- if(Banking.isBankScreenOpen())
- {
- return state.DEPOSIT_ALL;
- }
- else
- {
- return state.OPEN_BANK;
- }
- }
- else
- {
- return state.WALK_TO_BANK;
- }
- }
- else
- {
- return state.WALK_TO_STALL;
- }
- }
- }
- else
- {
- if(isInBank())
- {
- if(Inventory.getCount(foodName) >= foodAmount && !Inventory.isFull())
- {
- if(Inventory.getAll().length != Inventory.getCount(foodName))
- {
- if(Banking.isBankScreenOpen())
- {
- return state.DEPOSIT_ALL_EXCEPT_FOOD;
- }
- else
- {
- return state.OPEN_BANK;
- }
- }
- else
- {
- println("Bank walk to farmer");
- return state.WALK_TO_FARMER_NPC;
- }
- }
- else
- {
- if(Banking.isBankScreenOpen())
- {
- if(inventoryOnlyContainsFood() && !Inventory.isFull())
- {
- if(hasFoodInBank())
- {
- return state.WITHDRAW_FOOD;
- }
- else
- {
- return state.OUT_OF_FOOD;
- }
- }
- else
- {
- return state.DEPOSIT_ALL;
- }
- }
- else
- {
- return state.OPEN_BANK;
- }
- }
- }
- else
- {
- if(distanceFromFarmer() < 10)
- {
- if(Inventory.isFull() || Inventory.getCount(foodName) == 0)
- {
- return state.WALK_TO_BANK;
- }
- else
- {
- if(Skills.getCurrentLevel(SKILLS.HITPOINTS) < eatAtHitpoints)
- {
- return state.EAT_FOOD;
- }
- else
- {
- if(isBeingAttackedByGuard())
- {
- return state.WALK_TO_BANK;
- }
- else
- {
- if(stunned)
- {
- return state.DROP_JUNK;
- }
- else
- {
- return state.PICKPOCKET_FARMER;
- }
- }
- }
- }
- }
- else
- {
- println("Else else walk to farmer");
- println("Distance to Farmer:" + distanceFromFarmer());
- return state.WALK_TO_FARMER_NPC;
- }
- }
- }
- }
- }
- private void withdrawFood()
- {
- Banking.withdraw(foodAmount - Inventory.getCount(foodName), foodName);
- long currTime = System.currentTimeMillis();
- while(Inventory.getCount(foodName) != foodAmount && System.currentTimeMillis() - 2000 < currTime)
- {
- sleep(50, 100);
- }
- }
- private void initializeScript()
- {
- foodName = JOptionPane.showInputDialog("Master Farmer - Please enter food name (Correct capitalization required)");
- foodAmount = Integer.parseInt(JOptionPane.showInputDialog("Master Farmer - Please enter the amount of food to withdraw"));
- eatAtHitpoints = Integer.parseInt(JOptionPane.showInputDialog("Master Farmer - Please enter the hitpoints at which we should eat"));
- mouseSpeedMin = Integer.parseInt(JOptionPane.showInputDialog("Master Farmer - Please enter the minimum mouse speed"));
- mouseSpeedMax = Integer.parseInt(JOptionPane.showInputDialog("Master Farmer - Please enter the maximum mouse speed"));
- loot.add("Ranarr seed");
- loot.add("Snapdragon seed");
- loot.add("Watermelon seed");
- loot.add("Kwuarm seed");
- loot.add("Limpwurt seed");
- loot.add("Strawberry seed");
- loot.add("Sweetcorn seed");
- loot.add("Torstol seed");
- int y = JOptionPane.showOptionDialog(null,
- "Master Farmer - Do you wish to the extended loot table? (More seeds kept)", "Loot",
- JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE,
- null, new Object[] { "Yes", "No" }, 0);
- if (y == 0)
- {
- loot.add("Guam seed");
- loot.add("Marrentill seed");
- loot.add("Tarromin seed");
- loot.add("Harralander seed");
- loot.add("Irit seed");
- loot.add("Avantoe seed");
- loot.add("Toadflax seed");
- loot.add("Onion seed");
- loot.add("Potato seed");
- loot.add("Cabbage seed");
- loot.add("Tomato seed");
- loot.add("Cadantine seed");
- }
- Mouse.setSpeed(General.random(mouseSpeedMin, mouseSpeedMax));
- startXP = Skills.getXP(SKILLS.THIEVING);
- startLevel = Skills.getActualLevel(SKILLS.THIEVING);
- startTime = System.currentTimeMillis();
- }
- private boolean isInBank()
- {
- return bankArea.contains(Player.getPosition());
- }
- private boolean isBeingAttackedByGuard()
- {
- RSNPC[] guard = NPCs.find("Market Guard");
- if(guard.length > 0)
- {
- return guard[0].isInteractingWithMe();
- }
- return false;
- }
- private boolean inventoryOnlyContainsFood()
- {
- RSItem[] inventoryItems = Inventory.getAll();
- for(int i = 0;i<inventoryItems.length;i++)
- {
- if(!inventoryItems[i].getDefinition().getName().contains(foodName))
- {
- return false;
- }
- }
- return true;
- }
- private boolean isAnimating()
- {
- for (int i = 0; i < 20 && Player.getAnimation() == -1;i++)
- {
- sleep(20, 30);
- }
- return Player.getAnimation() != -1;
- }
- private boolean hasFoodInBank()
- {
- RSItem[] foodInBank = Banking.find(foodName);
- return foodInBank.length > 0 && foodInBank[0] != null;
- }
- private int distanceFromFarmer()
- {
- RSNPC[] farmer = NPCs.find("Master Farmer");
- if(farmer.length > 0 && farmer[0] != null)
- {
- return Player.getPosition().distanceTo(farmer[0].getPosition());
- }
- return 50;
- }
- private void eatFood()
- {
- RSItem[] food = Inventory.find(foodName);
- if(food.length > 0)
- {
- food[0].click("Eat");
- }
- }
- private void pickPocketNPC(String name)
- {
- RSNPC[] NPC = NPCs.find(name);
- if(NPC.length > 0)
- {
- if(name != "Man" && Player.getPosition().distanceTo(NPC[0].getPosition()) > 5)
- {
- Walking.walkTo(NPC[0]);
- }
- if(!NPC[0].isOnScreen())
- {
- Camera.turnToTile(NPC[0].getPosition());
- }
- DynamicClicking.clickRSNPC(NPC[0], "Pickpocket");
- }
- }
- private boolean teaAvaliable()
- {
- RSObject[] teaStall = Objects.find(10, "Tea stall");
- return teaStall.length > 0 && teaStall[0] != null;
- }
- private void dropAllTea()
- {
- Inventory.drop(new String[] {"Cup of tea"});
- RSObject[] teaStall = Objects.find(10, "Tea stall");
- if(teaStall.length > 0){
- teaStall[0].hover();
- }
- else{
- RSObject[] marketStall = Objects.find(10, "Market stall");
- if(marketStall.length > 0){
- marketStall[0].hover();
- }
- };
- long timeout = System.currentTimeMillis();
- while(timeout + 2000 > System.currentTimeMillis()
- && Inventory.getCount("Cup of tea") > 0)
- {
- sleep(20, 40);
- }
- }
- private void stealTea()
- {
- if(Game.isUptext("Steal-from Tea stall")){
- Mouse.click(1);
- }
- else{
- RSObject[] teaStall = Objects.find(10, "Tea stall");
- if(teaStall.length > 0){
- DynamicClicking.clickRSObject(teaStall[0], "Steal-from Tea stall");
- }
- }
- }
- private void depositAllExceptFood()
- {
- Banking.depositAllExcept(foodName);
- long timeout = System.currentTimeMillis();
- while(timeout + 2000 > System.currentTimeMillis()
- && Inventory.getAll().length != Inventory.getCount(foodName))
- {
- sleep(20, 40);
- }
- }
- private void dropJunk()
- {
- boolean dropItem;
- RSItem[] inventoryItems = Inventory.getAll();
- for(int i=0;i<inventoryItems.length;i++)
- {
- dropItem = true;
- for(int j=0;j<loot.size();j++)
- {
- if(inventoryItems[i].getDefinition().getName().contains(loot.get(j))
- ||inventoryItems[i].getDefinition().getName().contains(foodName))
- {
- dropItem = false;
- break;
- }
- }
- if(dropItem)
- {
- inventoryItems[i].click("Drop");
- }
- }
- stunned = false;
- }
- private void walkToFarmerNPC()
- {
- RSNPC[] farmer = NPCs.find("Master Farmer");
- if(farmer.length > 0 && farmer[0] != null)
- {
- WebWalking.walkTo(farmer[0].getPosition());
- }
- else
- {
- WebWalking.walkTo(farmerTile);
- }
- }
- @Override
- public void onPaint(Graphics g) {
- currentXP = Skills.getXP(SKILLS.THIEVING);
- currentLevel = Skills.getActualLevel(SKILLS.THIEVING);
- long timeRan = System.currentTimeMillis() - startTime;
- long xpGained = currentXP - startXP;
- double multiplier = timeRan / 3600000D;
- int xpPerHour = (int) (xpGained / multiplier);
- int levelsGained = currentLevel - startLevel;
- g.setColor(Color.WHITE);
- g.drawString("ITryNotToTroll's Thieving", 10, 70);
- g.drawString("Running for: " + Timing.msToString(timeRan), 10, 90);
- g.drawString("Levels Gained: " + levelsGained, 10, 110);
- g.drawString("Xp gained: " + xpGained + " (" + xpPerHour + "/h)", 10,
- 130);
- g.drawString("Version " + VERSION, 10, 150);
- g.drawString("Status: " + state, 10, 170);
- }
- @Override
- public void clanMessageReceived(String arg0, String arg1) {
- // TODO Auto-generated method stub
- }
- @Override
- public void duelRequestReceived(String arg0, String arg1) {
- // TODO Auto-generated method stub
- }
- @Override
- public void personalMessageReceived(String arg0, String arg1) {
- // TODO Auto-generated method stub
- }
- @Override
- public void playerMessageReceived(String arg0, String arg1) {
- // TODO Auto-generated method stub
- }
- @Override
- public void serverMessageReceived(String message) {
- if(message.contains("You've been stunned"))
- {
- stunned = true;
- }
- }
- @Override
- public void tradeRequestReceived(String arg0) {
- // TODO Auto-generated method stub
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement