Created
August 25, 2012 01:59
-
-
Save pxpc2/3458746 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package _new.planker.util.strategies; | |
| import _new.planker.Fields; | |
| import _new.planker.util.Methods; | |
| import org.powerbot.concurrent.strategy.Strategy; | |
| import org.powerbot.game.api.methods.Game; | |
| import org.powerbot.game.api.methods.Walking; | |
| import org.powerbot.game.api.methods.Widgets; | |
| 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.Time; | |
| import org.powerbot.game.api.util.Timer; | |
| import org.powerbot.game.api.wrappers.interactive.NPC; | |
| import org.powerbot.game.api.wrappers.widget.WidgetChild; | |
| /** | |
| * @author pxpc2 | |
| * @version 1.0 | |
| */ | |
| public class MakePlanks extends Strategy implements Runnable { | |
| WidgetChild logWidget = Widgets.get(Fields.WIDGET, Fields.widget); | |
| NPC sawmill; | |
| public void run() { | |
| if (logWidget.validate()) { | |
| Fields.status = "Interacting with widget"; | |
| if (logWidget.interact("Buy all")) { | |
| Fields.stuckOut = new Timer(1800); | |
| while (logWidget.validate() && Fields.stuckOut.isRunning()) { | |
| Time.sleep(500); | |
| if (Inventory.getCount(Fields.log) > 0) | |
| return; | |
| } | |
| Methods.updatePlanks(); | |
| } | |
| } else { | |
| Fields.status = "Walking to Sawmill"; | |
| sawmill = NPCs.getNearest(Fields.SAWMILL); | |
| if ((sawmill != null) && (sawmill.isOnScreen())) { | |
| Fields.status = "Interacting with sawmill"; | |
| if (sawmill.interact("Buy-plank")) { | |
| Fields.stuckOut = new Timer(2800); | |
| while (Players.getLocal().getAnimation() != -1 && !logWidget.validate() | |
| && Fields.stuckOut.isRunning()) { | |
| Time.sleep(700); | |
| } | |
| } | |
| } else if ((sawmill != null) && (!sawmill.isOnScreen())) | |
| Walking.walk(sawmill); | |
| else | |
| Fields.PATH_SAWMILL.traverse(); | |
| } | |
| } | |
| public boolean validate() { | |
| return (Inventory.getCount(Fields.log) > 0) | |
| && (Inventory.getCount(Fields.plank) == 0) | |
| && (Game.isLoggedIn() && (!Fields.goingResting)); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment