Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.powerbot.concurrent.Task;
- import org.powerbot.concurrent.action.Action;
- import org.powerbot.game.api.ActiveScript;
- import org.powerbot.game.api.Manifest;
- import org.powerbot.game.api.methods.interactive.Npcs;
- import org.powerbot.game.api.methods.interactive.Players;
- import org.powerbot.game.api.methods.tab.Inventory;
- import org.powerbot.game.api.util.Filter;
- import org.powerbot.game.api.util.Random;
- import org.powerbot.game.api.util.Time;
- import org.powerbot.game.api.util.Timer;
- import org.powerbot.game.api.wrappers.interactive.Npc;
- import org.powerbot.game.api.wrappers.interactive.Player;
- import org.powerbot.game.api.wrappers.node.Item;
- import org.powerbot.lang.Activatable;
- @Manifest(authors = { "Nighson" }, name = "Stealer", description = "Your best stealer :)", version = 1.0)
- public class Theaver extends ActiveScript {
- final int FARMER_ID = 7;
- final int FISH_ID = 361;
- /**
- *
- * @author Nighson
- *
- */
- private class Steal implements Task, Activatable {
- final Player player = Players.getLocal();
- public boolean applicable() {
- return player.getHpPercent() > 30;
- }
- public void run() {
- if (player.getInteracting() != null) {
- Time.sleep(Random.nextInt(100, 500));
- return;
- }
- if(player.getHpPercent() < 60){
- for (Item i : Inventory.getItems()) { //get all items in inventory, using for each loop to process
- if (i.getId() == FISH_ID){
- i.getWidgetChild().interact("Eat"); //best way?
- break;
- }
- }
- }
- //A filter to return the correct object
- final Npc farmer = Npcs.getNearest(new Filter<Npc>() {
- public boolean accept(final Npc npc) {
- final int npcId = npc.getId();
- if (FARMER_ID == npcId) {
- return true;
- }
- return false;
- }
- });
- if (farmer != null) {
- farmer.interact("Pickpocket");
- final Timer timer = new Timer(Random.nextInt(2000, 2800));
- while (timer.isRunning()) {
- if (farmer.getAnimation() == 422){
- log.info("Fail!");
- log.info("" + Players.getLocal().getHpPercent());
- Time.sleep(Random.nextInt(5000, 5500));
- }
- if (player.getSpeed() > 0) {
- timer.reset();
- }
- }
- }
- }
- }
- @Override
- protected void setup() {
- //make instances
- final Steal steal = new Steal();
- final Action Steal = new Action(steal, steal);
- //provide them for processing
- provide(Steal);
- }
- }
Add Comment
Please, Sign In to add comment