Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package scripts;
- import java.awt.Graphics;
- import org.tribot.api.General;
- import org.tribot.api.Timing;
- import org.tribot.api.input.Mouse;
- import org.tribot.api2007.Combat;
- import org.tribot.api2007.Game;
- import org.tribot.api2007.GameTab;
- import org.tribot.api2007.GroundItems;
- import org.tribot.api2007.Inventory;
- import org.tribot.api2007.Login;
- import org.tribot.api2007.NPCs;
- import org.tribot.api2007.Options;
- import org.tribot.api2007.Player;
- import org.tribot.api2007.Skills;
- import org.tribot.api2007.Walking;
- import org.tribot.api2007.WebWalking;
- import org.tribot.api2007.ext.Doors;
- import org.tribot.api2007.types.RSArea;
- import org.tribot.api2007.types.RSGroundItem;
- import org.tribot.api2007.types.RSItem;
- import org.tribot.api2007.types.RSNPC;
- import org.tribot.api2007.types.RSObject;
- import org.tribot.api2007.types.RSTile;
- import org.tribot.script.Script;
- import org.tribot.script.ScriptManifest;
- import org.tribot.script.interfaces.Painting;
- @ScriptManifest(authors = { "Cloudnine" }, category = "Local", name = "Chicken Killer")
- public class ChickenKiller extends Script implements Painting {
- private String status = "Starting up";
- private RSTile OUTSIDE_GATE_TILE = new RSTile(3237, 3296);
- private RSTile INSIDE_GATE_TILE = new RSTile(3236, 3296);
- private RSArea PEN_AREA = new RSArea(new RSTile(3235, 3301), new RSTile(
- 3225, 3295));
- private RSArea ENTIRE_PEN_AREA = new RSArea(new RSTile(3235, 3301),
- new RSTile(3225, 3287));
- private static boolean lootFeathers;
- private static boolean buryBones;
- private static boolean waitingOnGUI = true;
- private final int START_STRENGTH_XP = Skills.getXP(Skills.SKILLS.STRENGTH);
- @Override
- public void run() {
- ChickenKillerGUI.openGUI();
- while (true) {
- sleep(loop());
- }
- }
- @Override
- public void onPaint(Graphics g) {
- g.drawString("Chicken Killer v1.1 by Cloudnine", 300, 300);
- g.drawString("Status: " + status, 300, 315);
- g.drawString("Run Time: " + Timing.msToString(getRunningTime()), 300,
- 330);
- int strengthLevel = Skills.getActualLevel(Skills.SKILLS.STRENGTH);
- int xpGain = Skills.getXP(Skills.SKILLS.STRENGTH) - START_STRENGTH_XP;
- int hourly = (int) (((double) xpGain * 3600000D) / (double) this
- .getRunningTime());
- g.drawString("Strength Level: " + strengthLevel + " XP Gained: "
- + xpGain + "(" + hourly + "/hr)", 300, 345);
- }
- private int loop() {
- if (waitingOnGUI) {
- status = "Waiting on user input";
- return 250;
- }
- if (Login.getLoginState() != Login.STATE.INGAME) {
- status = "Not logged in";
- return 250;
- }
- if (Player.isMoving()) {
- status = "Moving";
- return 250;
- }
- if (!PEN_AREA.contains(Player.getPosition())) {
- status = "Walking to pen";
- walkToPen();
- return 250;
- }
- if (!Combat.isUnderAttack()) {
- status = "In combat";
- return 250;
- }
- Mouse.setSpeed(General.random(200, 250));
- enableRun();
- lootDrops();
- handleEdibles();
- attackChicken();
- return 250;
- }
- private void lootDrops() {
- if (lootFeathers) {
- RSGroundItem[] feathers = GroundItems.findNearest("Feather");
- for (RSGroundItem feather : feathers) {
- if (PEN_AREA.contains(feather.getPosition())) {
- status = "Taking feathers";
- if (!feather.isOnScreen()) {
- Walking.walkTo(feather.getPosition());
- sleepWhileMoving();
- }
- feather.click("Take Feather");
- sleepWhileMoving();
- }
- }
- }
- if (buryBones) {
- RSGroundItem[] bones = GroundItems.findNearest("Bones");
- for (RSGroundItem bone : bones) {
- if (PEN_AREA.contains(bone.getPosition())) {
- status = "Taking bones";
- if (!bone.isOnScreen()) {
- Walking.walkTo(bone.getPosition());
- sleepWhileMoving();
- }
- if (bones != null) {
- bone.click("Take Bones");
- sleepWhileMoving();
- }
- }
- }
- RSItem[] bonesInInventory = Inventory.find("Bones");
- for (RSItem boneInInventory : bonesInInventory) {
- status = "Burying bones";
- boneInInventory.click("Bury");
- int count = 0;
- while (count < 5 && Player.getAnimation() != 827) {
- count++;
- sleep(100);
- }
- while (Player.getAnimation() == 827) {
- sleep(100);
- }
- }
- }
- }
- private void handleEdibles() {
- for (int i = 0; i < 4; i++) {
- if (Inventory.find("Strength potion(" + i + ")").length > 0
- && Inventory.find("Strength potion(" + i + ")")[0] != null) {
- status = "Drinking Strength Potion";
- Inventory.find("Strength potion(" + i + ")")[0].click("Drink");
- int count = 0;
- while (count < 10
- && Inventory.getCount(new String[] { "Strength potion("
- + i + ")" }) > 0) {
- count++;
- sleep(100);
- }
- }
- }
- if (Inventory.find("Vial").length > 0
- && Inventory.find("Vial")[0] != null) {
- status = "Dropping empty strength potion";
- Inventory.find("Vial")[0].click("Drop");
- int count = 0;
- while (count < 10
- && Inventory.getCount(new String[] { "Vial" }) > 0) {
- count++;
- sleep(100);
- }
- }
- }
- private void attackChicken() {
- RSNPC[] chickens = NPCs.findNearest("Chicken");
- for (RSNPC chicken : chickens) {
- if (chicken != null && chicken.getCombatCycle() == -1000
- && PEN_AREA.contains(chicken.getPosition())) {
- status = "Attacking Chicken";
- if (chicken.click("Attack")) {
- sleepWhileMoving();
- break;
- }
- }
- }
- }
- private void enableRun() {
- if (Game.getRunEnergy() >= 50) {
- Options.setRunOn(true);
- if (Game.isRunOn()) {
- if (GameTab.getOpen() != GameTab.TABS.INVENTORY) {
- GameTab.open(GameTab.TABS.STATS);
- }
- }
- }
- }
- private void handleGate(boolean openGate) {
- RSObject gate = Doors.getDoorAt(INSIDE_GATE_TILE);
- if (gate != null) {
- if (!gate.isOnScreen()) {
- Walking.walkTo(OUTSIDE_GATE_TILE);
- sleepWhileMoving();
- }
- Doors.handleDoor(gate, openGate);
- sleepWhileMoving();
- } else {
- status = "No gate found!";
- }
- }
- private void walkToPen() {
- if (!ENTIRE_PEN_AREA.contains(Player.getPosition())) {
- WebWalking.walkTo(OUTSIDE_GATE_TILE);
- sleepWhileMoving();
- handleGate(true);
- }
- Walking.walkTo(PEN_AREA.getRandomTile());
- }
- private void sleepWhileMoving() {
- int count = 0;
- while (count < 5 && !Player.isMoving()) {
- count++;
- sleep(100);
- }
- while (Player.isMoving()) {
- sleep(100);
- }
- }
- public static void passVariables(boolean feathers, boolean bones) {
- lootFeathers = feathers;
- buryBones = bones;
- waitingOnGUI = false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement