Skip to content

Instantly share code, notes, and snippets.

@HostOnNet
Created June 22, 2011 09:39
Show Gist options
  • Save HostOnNet/1039767 to your computer and use it in GitHub Desktop.
Save HostOnNet/1039767 to your computer and use it in GitHub Desktop.
import java.awt.Graphics;
import impsoft.bots.ColorBot;
import impsoft.bots.reflection.PhysicalObject;
import impsoft.scripting.ibot.enums.Skill;
import impsoft.scripting.ibot.interfaces.AutoPaint;
import impsoft.scripting.ibot.structs.AryanTile;
import impsoft.scripting.types.ColorScript;
import bergCoder.BergUtils;
import bergCoder.Object3D;
public class WoodCutting extends ColorScript implements AutoPaint
{
public static int botState = 1;
public static final int CUT = 1;
public static final int BANK = 2;
AryanTile treeLocation = new AryanTile(3285, 3475); // varrock east
int treeID = 1281; // oak tree
BergUtils utils = new BergUtils(this);
public WoodCutting(ColorBot c)
{
super(c);
}
@Override
public void script() throws InterruptedException, Exception
{
while(!isLoggedIn())
{
sleep(100,400);
}
int startXP = theTabs.Statistics.getStatExperience(Skill.WOODCUTTING);
log("Start XP = " + startXP);
while(true)
{
switch(botState)
{
case 1:
cutTrees();
break;
case 2:
bank();
break;
}
}
}
private void bank() throws InterruptedException
{
theWorldMap.walkToBank();
theBank.open();
while (!theBank.isInterfaceIsUp())
{
log("Waiting for bank interface");
sleep(10,40);
}
theBank.doDepositAll();
sleep(10,50);
theBank.exit();
botState = CUT;
}
private void cutTrees() throws InterruptedException
{
if (theTabs.Inventory.isFull())
{
botState = BANK;
return;
}
if (!theTabs.Equipment.isWearing("Bronze hatchet"))
{
if (theTabs.Inventory.count("Bronze hatchet") > 0)
{
theTabs.Inventory.doAction("Bronze hatchet", null, 1, true);
}
else
{
log("ERROR: You need Bronze hatchet to cut Tress");
shutDown();
}
}
// walk to tree location
if (getLocation().distanceTo(treeLocation) > 6)
{
log("Walking to treeLocation" + treeLocation.toString());
theWorldMap.walkTo(treeLocation);
}
PhysicalObject myTree = utils.getInteractiveObject(treeID);
if (myTree != null)
{
log("[START]===========================================================");
log("myTree.getID() = " + myTree.getID());
log("getCategory() = " + myTree.getCategory());
log("myTree.getLocation().toString() = " + myTree.getLocation().toString());
log("myTree.getRecommendPointToClick() =" + myTree.getRecommendPointToClick());
log("myTree.getRecommendPointToClick(0) = " + myTree.getRecommendPointToClick(0));
log("[END]===========================================================");
//utils.clickInteractiveObject(treeID, "Oak", "Chop");
//this.mouseClickLeft(myTree.getRecommendPointToClick());
//utils.clickInteractiveObject(treeID, "Oak", null);
Object3D treeDia = new Object3D(161,22,64,-64,0,50,false);
utils.clickInteractiveObject(new int[] {1281}, new AryanTile(myTree.getLocation().x,myTree.getLocation().y), "Oak", null, treeDia);
}
while(getMyPlayer().isMoving())
{
sleep(10);
log("[MOVING] animation = " + getAnimation());
}
while (getAnimation() != -1)
{
log("[ANIMATING] animation = " + getAnimation());
sleep(10);
}
}
@Override
public void paint(Graphics g)
{
// TODO Auto-generated method stub
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment