Skip to content

Instantly share code, notes, and snippets.

Created April 3, 2015 19:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/37feb0f3de8238bbf6f9 to your computer and use it in GitHub Desktop.
Save anonymous/37feb0f3de8238bbf6f9 to your computer and use it in GitHub Desktop.
import org.dreambot.api.methods.Calculations;
import org.dreambot.api.methods.filter.Filter;
import org.dreambot.api.methods.map.Area;
import org.dreambot.api.methods.map.Tile;
import org.dreambot.api.methods.skills.Skill;
import org.dreambot.api.methods.tabs.Tab;
import org.dreambot.api.methods.walking.web.node.impl.bank.WebBankArea;
import org.dreambot.api.script.AbstractScript;
import org.dreambot.api.script.Category;
import org.dreambot.api.script.ScriptManifest;
import org.dreambot.api.utilities.Timer;
import org.dreambot.api.wrappers.interactive.GameObject;
import java.awt.*;
@ScriptManifest(name = "Draynor WC", author = "lawdeedaw", description = "cuts logs for you", version = .1, category = Category.WOODCUTTING)
public class Main extends AbstractScript {
private Timer t = new Timer();
private String axe;
private GameObject currentNode;
private final Area WC_AREA = new Area(
new Tile(3074, 3257),
new Tile(3066, 3253),
new Tile(3068, 3247),
new Tile(3073, 3247));
@Override
public void onStart() {
axe = getInventory().getNameForSlot(0);
getSkillTracker().start(Skill.WOODCUTTING);
log(axe);
}
private boolean readyToCut(){
return !getInventory().isFull() && getInventory().contains(axe);
}
private boolean canCut(){
return readyToCut() && WC_AREA.contains(getLocalPlayer());
}
private boolean readyToBank(){
return getInventory().isFull() || !getInventory().contains(axe);
}
private boolean canBank(){
return readyToBank() && WebBankArea.DRAYNOR_MARKET.getArea().contains(getLocalPlayer());
}
private void cut(){
int i = Calculations.random(1, 5);
if(getLocalPlayer().isStandingStill()){
if(currentNode == null || !currentNode.exists()){
currentNode = getGameObjects().closest(new Filter<GameObject>(){
public boolean match(GameObject gi){
if(gi == null || gi.getName() == null)
return false;
if(!gi.getName().equals("Oak"))
return false;
if(WC_AREA.contains(gi))
return true;
return false;
}
});
}
if(currentNode != null){
currentNode.interact("Chop down");
sleep(100, 600);
switch(i){
case 1: getMouse().moveMouseOutsideScreen();
break;
}
sleep(500, 1000);
sleepUntil(() -> !getLocalPlayer().isStandingStill() || currentNode == null, Calculations.random(500, 1400));
} else {
GameObject tree = getGameObjects().closest(new Filter<GameObject>(){
public boolean match(GameObject gi){
if(gi == null || gi.getName() == null)
return false;
if(!gi.getName().equals("Tree"))
return false;
if(WC_AREA.contains(gi))
return true;
return false;
}
});;
if(tree != null){
tree.interact("Chop down");
sleep(500,1000);
sleepUntil(() -> !getLocalPlayer().isStandingStill(), Calculations.random(500, 1000));
}
}
} else {
antiBan();
sleep(100, 1000);
}
}
private void bank(){
int i = Calculations.random(1, 5);
if(canBank()){
if(!getBank().isOpen()){
getBank().openClosest();
getBank().depositAllExcept(axe);
switch(i){
case 1: getBank().close();
break;
}
}
}
}
private void antiBan(){
int rando = Calculations.random(1, 100);
switch(rando){
case 1: getCamera().rotateToTile(WC_AREA.getRandomTile());
break;
case 2: getCamera().rotateToPitch(383);
break;
case 3: if(!getTabs().isOpen(Tab.STATS)){
getTabs().open(Tab.STATS);
}
break;
case 4: if(!getTabs().isOpen(Tab.INVENTORY)){
getTabs().open(Tab.INVENTORY);
}
break;
default: sleep(100, 1000);
}
}
@Override
public int onLoop() {
if(canCut()){
cut();
}
else if (canBank()) {
bank();
}
else if(readyToBank()){
getWalking().walk(WebBankArea.DRAYNOR_MARKET.getArea().getCenter());
if(!WebBankArea.DRAYNOR_MARKET.getArea().contains(getLocalPlayer())){
if(getWalking().isRunEnabled()){
sleep(500, 2500);
}
else {
sleep(1500, 4500);
}
} else {
sleep(100,500);
}
}
else if(readyToCut()){
getWalking().walk(WC_AREA.getCenter());
if(!WC_AREA.contains(getLocalPlayer())){
if(getWalking().isRunEnabled())
sleep(500, 2500);
else {
sleep(1500, 4500);
}
}
}
return Calculations.random(300, 600);
}
@Override
public void onExit() {
}
public void onPaint(Graphics2D g) {
g.setColor(Color.ORANGE);
g.setFont(new Font("Arial", 1, 11));
g.drawString("Simple WoodCutter", 25, 40);
g.drawString("Time Running: " + t.formatTime(), 25, 55);
g.drawString("WC XP: " + stat() + " [" + ph() + "]", 25, 70);
g.drawString("by lawdeedaw", 25, 85);
}
public long stat(){
return getSkillTracker().getGainedExperience(Skill.WOODCUTTING);
}
public long ph(){
return getSkillTracker().getGainedExperiencePerHour(Skill.WOODCUTTING);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment