Skip to content

Instantly share code, notes, and snippets.

@kryogenic
Last active August 29, 2015 14:16
Show Gist options
  • Save kryogenic/efc759762440277445be to your computer and use it in GitHub Desktop.
Save kryogenic/efc759762440277445be to your computer and use it in GitHub Desktop.
yArcticPine
package org.kryogenic.powerbot;
import org.powerbot.script.*;
import org.powerbot.script.rt6.*;
import org.powerbot.script.rt6.ClientContext;
import org.powerbot.script.rt6.Menu;
import java.awt.*;
import java.util.Arrays;
/**
* @author kryo
* @version: 0.1
*/
@Script.Manifest(name = "yArcticPine", description = "Power chops arctic pines and makes bonfires")
public class YArcticPine extends PollingScript<ClientContext> implements PaintListener {
/**
* Font for painting
*/
public static final Font FONT = new Font("TimesRoman", Font.BOLD, 10);
int fireId = 70760;
int treeId = 70057;
int logId = 10810;
int lightingAnim = 25600;
int doneBonfiringAnim = 24884;
int size = 5;
boolean bonfire = false;
private boolean isInactive() {
int randTime = Random.nextInt(189, 291);
int activity = 0;
for(int i = 0; i < randTime; i++) {
if(ctx.players.local().animation() != -1)
activity++;
if(activity > 10) {
return false;
}
try {
Thread.sleep(10);
} catch(InterruptedException e) {
e.printStackTrace();
}
}
return true;
}
@Override
public void poll() {
if(ctx.widgets.select().id(1347).peek().components().length != 0) {
if(ctx.widgets.peek().componentCount() > 31) {
System.out.println("closing ban message");
ctx.widgets.poll().components()[19].click();
}
} else if(bonfire) {
Tile loc = ctx.players.local().tile();
Area local = new Area(loc.derive(-size, -size), loc.derive(size, size));
GameObject fire = ctx.objects.select().within(local).id(fireId).poll();
if(fire.id() == -1) {
System.out.println("lighting fire");
ctx.backpack.select().id(logId).poll().click();
} else if(isInactive()) {
if(ctx.backpack.select().id(logId).count() == 0) {
bonfire = false;
} else {
ctx.backpack.select().id(logId).poll().interact(false, "Use");
if (!fire.inViewport()) {
ctx.camera.turnTo(fire);
}
fire.interact(false, "Use", "Arctic pine logs -> Fire");
}
}
} else if (ctx.backpack.select().count() == 28) {
bonfire = true;
} else {
if (ctx.players.local().animation() == -1) {
if (ctx.players.local().inMotion()) {
return;
}
GameObject tree = ctx.objects.select().id(treeId).nearest().poll();
if (!tree.inViewport()) {
ctx.camera.turnTo(tree);
}
System.out.println("clicking tree");
tree.interact(true, "Chop down");
}
}
}
@Override
public void repaint(Graphics graphics) {
final Graphics2D g = (Graphics2D) graphics;
g.setFont(FONT);
g.setColor(Color.RED);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment