Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package scripts;
- import org.powerbot.script.Condition;
- import org.powerbot.script.Filter;
- import org.powerbot.script.PollingScript;
- import org.powerbot.script.Script;
- import org.powerbot.script.rt6.*;
- import javax.swing.*;
- import java.util.concurrent.Callable;
- @Script.Manifest( name="Script_1" , description="WiP" , properties="author=G; topic=999 client=6")
- public class Script_1 extends PollingScript<org.powerbot.script.rt6.ClientContext> {
- final static int MONSTER_ID[] = { 12362, 12363, 12364, 12365, 12366 };
- final static int FOOD = 2142; // cooked meat
- @Override
- public void start() {
- System.out.println("Started");
- }
- @Override
- public void stop() {
- System.out.println("Stopped");
- }
- @Override
- public void poll() {
- if(hasFood()) {
- if (NeedsHealth()) {
- System.out.println("Eating");
- heal();
- }
- else {
- if (!InCombat() && !FullLoad() && HasLog()) {
- System.out.println("Looking For A Fight");
- attack();
- System.out.println("Grabbing Raw Beef");
- pickup();
- }
- else {
- if (!InCombat() && FullLoad()) {
- System.out.println("Burning Stuff");
- makefire();
- }
- else {
- if (!InCombat() && !HasLog() && NeedsCooked()){
- System.out.println("Cooking Meat");
- cook();
- }
- }
- }
- }
- }
- else {
- System.out.println("No Food");
- }
- }
- public boolean NeedsCooked(){
- return ((ctx.backpack.select().count() == 27) && (ctx.backpack.select().id(2132).count() > 0));
- }
- public boolean FullLoad(){
- return ctx.backpack.select().count() == 28;
- }
- public boolean HasLog() {return ctx.backpack.id(1511).count() > 0;}
- public boolean NeedsHealth() {
- return ctx.combatBar.health() < ((ctx.combatBar.maximumHealth() / 100) * 50); //eat when health drops below 50%
- }
- public boolean InCombat() {
- return ctx.players.local().inCombat();
- }
- public boolean hasFood(){
- return ctx.backpack.id(FOOD).count() < 1;
- }
- public void attack() {
- final Npc MonsterToKill = ctx.npcs.id(MONSTER_ID).select(new Filter<Npc>() {
- @Override
- public boolean accept(Npc npc) {
- return !npc.inCombat();
- }
- }).nearest().poll();
- MonsterToKill.interact("Attack");
- if(MonsterToKill.inCombat()){
- return;
- }
- Condition.wait(new Callable<Boolean>() {
- @Override
- public Boolean call() throws Exception {
- return ctx.players.local().inCombat();
- }
- }, 5000, 1); // Try 1 time every 3000ms
- Condition.wait(new Callable<Boolean>() {
- @Override
- public Boolean call() throws Exception {
- return ctx.players.local().inCombat();
- }
- },200,1);
- }
- public void heal() {
- Item EAT = ctx.backpack.select().id(FOOD).poll();
- EAT.interact("Eat" );
- final int startingHealth = ctx.combatBar.health();
- Condition.wait(new Callable<Boolean>() {
- @Override
- public Boolean call() throws Exception {
- final int currentHealth = ctx.combatBar.health();
- return currentHealth != startingHealth;
- }
- }, 150, 20);
- }
- public void pickup() {
- Condition.sleep(4200);
- GroundItem PICKUP = ctx.groundItems.select().id(2132).nearest().poll();
- PICKUP.interact("take" , "raw");
- final int startingBeef = ctx.backpack.count();
- Condition.wait(new Callable<Boolean>() {
- @Override
- public Boolean call() throws Exception {
- final int BeefAmount = ctx.backpack.select().count();
- return BeefAmount != startingBeef;
- }
- });
- }
- public void makefire() {
- Item LOG = ctx.backpack.select().id(1511).poll();
- LOG.interact("Light");
- final int startingLogs = ctx.skills.experience(Constants.SKILLS_FIREMAKING);
- Condition.wait(new Callable<Boolean>() {
- @Override
- public Boolean call() throws Exception {
- final int MadeFire = ctx.skills.experience(Constants.SKILLS_FIREMAKING);
- return MadeFire != startingLogs;
- }
- });
- }
- public void cook() {
- Item COOK = ctx.backpack.select().id(2132).poll();
- COOK.interact("use");
- ctx.objects.select().id(70755).nearest().poll().interact("use");
- System.out.println("Clicking Widget");
- Condition.sleep(3000);
- ctx.widgets.component(1370, 20).click("cook");
- Condition.wait(new Callable<Boolean>() {
- @Override
- public Boolean call() throws Exception {
- System.out.println("Cooking Throw");
- return ctx.backpack.select().id(2132).count() == 0;
- }
- });
- }
- }// end of loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement