Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package scripts.sophherblore.nodes;
- import org.tribot.api.General;
- import org.tribot.api.Timing;
- import org.tribot.api.input.Keyboard;
- import org.tribot.api.types.generic.Condition;
- import org.tribot.api2007.Banking;
- import org.tribot.api2007.Interfaces;
- import org.tribot.api2007.Inventory;
- import org.tribot.api2007.types.RSInterface;
- import org.tribot.api2007.types.RSItem;
- import scripts.sophchaos.api.Node;
- public class MakePotions extends Node
- {
- private String ingredient = "Guam leaf";
- private String vial = "Vial of water";
- private int ingredientToClick;
- private int vialToClick;
- private int startMakingPotsRandom = 420;
- private int ingredientToClickRandom = 20;
- private int changeClickOrderRandom = 180;
- private int makeXRandom = 4;
- private int makeOptionRandom = 220;
- @Override
- public void execute()
- {
- if (!Banking.isBankScreenOpen())
- {
- General.sleep(100, startMakingPotsRandom);
- useIngredientsOnEachOther();
- }
- if (Banking.isBankScreenOpen())
- {
- Banking.close();
- }
- }
- @Override
- public boolean validate()
- {
- return WithdrawBankIngredients.gotIngredientsInInventory(ingredient, vial);
- }
- // Calls different methods in order to get to the interface.
- private void useIngredientsOnEachOther()
- {
- chooseIngredientsToClick();
- RSItem[] ingredients = Inventory.find(WithdrawBankIngredients.ingredient);
- RSItem[] vials = Inventory.find(WithdrawBankIngredients.vial);
- int random = General.random(0, changeClickOrderRandom);
- if (random == 0)
- {
- changeClickOrder(ingredients, vials);
- General.println("Changed click order!");
- }
- else if (WithdrawBankIngredients.withdrawOrder == 0)
- {
- ingredients[ingredientToClick].click();
- vials[vialToClick].click();
- }
- else
- {
- General.println("We clicked on the vials first");
- vials[vialToClick].click();
- ingredients[ingredientToClick].click();
- }
- General.sleep(150, 250);
- getInterface();
- }
- // Get's the interface.
- private void getInterface()
- {
- RSInterface target = Interfaces.get(309, 3);
- if (Timing.waitCondition(new Condition()
- {
- @Override
- public boolean active()
- {
- General.sleep(50, 150);
- return target != null && !target.isHidden();
- }
- }, General.random(2500, 3500)))
- {
- General.println("Calling chooseMakeOption!");
- chooseMakeOption(target);
- }
- else
- {
- General.println("We are running getInterface() again.");
- getInterface();
- }
- }
- // Changes the click order and also uses the items on each other.
- private void changeClickOrder(RSItem[] ingredients, RSItem[] vials)
- {
- int vialToClick = 0;
- int ingredientToClick = 0;
- if (WithdrawBankIngredients.withdrawOrder == 0)
- {
- vialToClick = General.random(8, 13);
- ingredientToClick = General.random(0, 5);
- vials[vialToClick].click();
- General.sleep(50, 150);
- ingredients[ingredientToClick].click();
- }
- else
- {
- vialToClick = General.random(0, 5);
- ingredientToClick = General.random(8, 13);
- ingredients[ingredientToClick].click();
- General.sleep(50, 150);
- vials[vialToClick].click();
- }
- }
- // Chooses which ingredients to click.
- private void chooseIngredientsToClick()
- {
- int random = General.random(0, ingredientToClickRandom);
- int firstItem;
- int secondItem;
- if (random > 20)
- {
- firstItem = 10;
- secondItem = 0;
- }
- else if (random > 10)
- {
- firstItem = 13;
- secondItem = 0;
- }
- else if (random > 4)
- {
- firstItem = 11;
- secondItem = 0;
- }
- else
- {
- firstItem = General.random(4, 13);
- secondItem = General.random(0, 5);
- }
- if (WithdrawBankIngredients.withdrawOrder == 0)
- {
- ingredientToClick = firstItem;
- vialToClick = secondItem;
- }
- else
- {
- vialToClick = secondItem;
- ingredientToClick = firstItem;
- }
- }
- // Chooses one of the three make options.
- private void chooseMakeOption(RSInterface target)
- {
- int random = General.random(0, makeOptionRandom);
- if (random > 3)
- {
- General.println("Standard method called!");
- makeAll(target);
- }
- else if (random != 0)
- {
- General.println("Make X called!");
- makeX(target);
- }
- else
- {
- General.println("Cancel missclick called!");
- cancelMissclick(target);
- }
- }
- // Uses the make all option.
- private void makeAll(RSInterface target)
- {
- target.click("Make All");
- Timing.waitCondition(new Condition()
- {
- @Override
- public boolean active()
- {
- General.sleep(50, 150);
- return potsAreMade(WithdrawBankIngredients.finishedProduct);
- }
- }, General.randomLong(8800, 11500));
- }
- // Uses the "x" amount of potions.
- private void makeX(RSInterface target)
- {
- target.click("Make X");
- int random = General.random(0, makeXRandom);
- if (random != 0)
- {
- Keyboard.typeSend("55");
- General.sleep(100, 250);
- Keyboard.pressEnter();
- }
- else
- {
- Keyboard.typeSend("33");
- General.sleep(100, 250);
- Keyboard.pressEnter();
- }
- Timing.waitCondition(new Condition()
- {
- @Override
- public boolean active()
- {
- General.sleep(50, 150);
- return potsAreMade(WithdrawBankIngredients.finishedProduct);
- }
- }, General.randomLong(8800, 11500));
- }
- // Instead of choosing makeAll or makeX, we click on cancel.
- private void cancelMissclick(RSInterface target)
- {
- target.click("Cancel");
- General.sleep(50, 120);
- int random = General.random(0, 10);
- if (random != 0)
- {
- makeAll(target);
- }
- else
- {
- makeX(target);
- }
- }
- // Returns true if the pots are made.
- private boolean potsAreMade(String finishedProduct)
- {
- return Inventory.getCount(finishedProduct) == 14;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement