Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.rsbot.script.Script;
- import org.rsbot.script.ScriptManifest;
- import org.rsbot.script.util.Filter;
- import org.rsbot.script.wrappers.RSItem;
- import org.rsbot.script.wrappers.RSNPC;
- @ScriptManifest(authors = { "Equinox_" }, name = "Equinox Seller", description = "Sells everything in your inventory to the general store.")
- public class EquinoxSeller extends Script {
- public static final int[] TRADER_IDS = { 520, 521 };
- public static final int COINS_ID = 995;
- public static final Filter<RSNPC> TRADER_FILTER = new Filter<RSNPC>() {
- public boolean accept(RSNPC t) {
- for (int id : TRADER_IDS)
- if (t.getID() == id)
- return true;
- if (t.getName() != null)
- if (t.getName().equalsIgnoreCase("shopkeeper")
- || t.getName().equalsIgnoreCase("shop assistant"))
- return true;
- return false;
- }
- };
- public int startMoney = 0;
- public int soldItems = 0;
- public boolean onStart() {
- if (npcs.getNearest(TRADER_FILTER) == null) {
- log.severe("Start near a general store!");
- return false;
- }
- startMoney = inventory.getCount(true, COINS_ID);
- return true;
- }
- public void onFinish() {
- log.info("Thanks for using Equinox Seller!");
- log.info("You sold: " + soldItems + " items and got "
- + (inventory.getCount(true, COINS_ID) - startMoney) + " gp!");
- }
- public RSItem getInventoryItem() {
- for (RSItem i : inventory.getItems())
- if (i != null)
- if (i.getID() != COINS_ID && i.getID() > 0)
- return i;
- return null;
- }
- public int loop() {
- mouse.setSpeed(random(4,6));
- RSItem inv = getInventoryItem();
- RSNPC npc = npcs.getNearest(TRADER_FILTER);
- if (inv == null) {
- log.info("Out of items!");
- stopScript(true);
- }
- if (store.isOpen())
- sell();
- else if (npc != null)
- openStore();
- return 0;
- }
- void openStore() {
- RSNPC npc = npcs.getNearest(TRADER_FILTER);
- if (npc != null) {
- for (byte b = 0; b < 150 && !npc.isOnScreen(); b++) {
- if (walking.getDestination() == null
- || calc.distanceTo(walking.getDestination()) < 4)
- walking.walkTo(npc.getLocation());
- sleep(100, 150);
- }
- if (npc.isOnScreen())
- if (npc.doAction("Trade Shop"))
- for (byte b = 0; b < 50 && !store.isOpen(); b++)
- sleep(100, 125);
- }
- }
- void sell() {
- int count = inventory.getCountExcept(true, COINS_ID);
- RSItem inv = getInventoryItem();
- if (store.isOpen() && inv != null)
- inv.doAction("Sell "
- + getOpt(inventory.getCount(true, inv.getID())));
- for (byte b = 0; b<35 && count==inventory.getCountExcept(true, COINS_ID); b++)
- sleep(50,75);
- soldItems += count-inventory.getCountExcept(true, COINS_ID);
- }
- int getOpt(int count) {
- if (count <= 1)
- return 1;
- else if (count <= 5)
- return 5;
- else if (count <= 10)
- return 10;
- return 50;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment