- import interfaces.Painter;
- import java.awt.Color;
- import java.awt.Font;
- import java.awt.FontMetrics;
- import java.awt.Graphics;
- import java.awt.Graphics2D;
- import java.awt.Paint;
- import java.awt.Point;
- import java.awt.RadialGradientPaint;
- import java.awt.Rectangle;
- import com.parabot.methods.GroundItems;
- import com.parabot.methods.Inventory;
- import com.parabot.methods.NPCs;
- import com.parabot.methods.Players;
- import com.parabot.methods.Walking;
- import com.parabot.scripts.BasicLoop;
- import com.parabot.scripts.Script;
- import com.parabot.scripts.ScriptFormat;
- import com.parabot.utils.Timer;
- import com.parabot.utils.Utils;
- import com.parabot.wrappers.GroundItem;
- import com.parabot.wrappers.NPC;
- import com.parabot.wrappers.RSItem;
- @ScriptFormat(author = "D R O", category = "Combat", description = "Cow killer and buries bones.", name = "CowKillerNR", version = 0.01)
- public class CowKillerNR extends Script implements BasicLoop, Painter {
- /**
- * Variables
- */
- private static final int COW = 5852;
- public int[] bones = { 526 };
- /**
- * Time
- */
- long millis2;
- long seconds2;
- long startTime2;
- long startTime;
- // Paint
- final Font comicPlain10 = new Font("Comic Sans MS", Font.PLAIN, 22);
- final Color black = new Color(0, 0, 0);
- private final Timer RUNTIME = new Timer();
- private FontMetrics FONTMETRICS = null;
- private String STATE = "";
- @Override
- public boolean onExecute() {
- return true;
- }
- @Override
- public void paint(Graphics g) {
- if (FONTMETRICS == null) {
- FONTMETRICS = g.getFontMetrics();
- RUNTIME.start();
- }
- drawGradientText(g, "Runtime: " + RUNTIME.getElapsedTime(), 15, 200, Color.red);
- drawGradientText(g, "Cow Killer V1", 15, 218, Color.red);
- drawGradientText(g, "State: " + STATE, 15, 218, Color.red);
- }
- public void drawGradientText(Graphics g, String text, int x, int y, Color c) {
- Graphics2D g2 = (Graphics2D) g;
- Color color3 = new Color(51, 51, 51, 205);
- Font font1 = new Font("Arial", 0, 12);
- g.setFont(font1);
- FONTMETRICS = g.getFontMetrics();
- Rectangle textBox = new Rectangle(x, y - g.getFont().getSize(),
- (int) FONTMETRICS.getStringBounds(text, g).getWidth() + 8,
- (int) FONTMETRICS.getStringBounds(text, g).getHeight() + 5);
- Paint defaultPaint = g2.getPaint();
- g2.setPaint(new RadialGradientPaint(new Point.Double(textBox.x
- + textBox.width / 2.0D, textBox.y + textBox.height / 2.0D),
- (float) (textBox.getWidth() / 2.0D),
- new float[] { 0.5F, 1.0F }, new Color[] {
- new Color(color3.getRed(), color3.getGreen(), color3
- .getBlue(), 175),
- new Color(0.0F, 0.0F, 0.0F, 0.8F) }));
- g.fillRect(textBox.x, textBox.y + 12, textBox.width, textBox.height);
- g2.setPaint(defaultPaint);
- g.setColor(Color.BLACK);
- g.drawRect(textBox.x, textBox.y + 12, textBox.width, textBox.height);
- g.setColor(c);
- g.drawString(text, x + 4, y + 15);
- for (int i = 0; i < text.length(); i++) {
- if (Character.isDigit(text.charAt(i))) {
- g.setColor(new Color(255, 255, 255));
- g.drawString("" + text.charAt(i),
- x + FONTMETRICS.stringWidth(text.substring(0, i)) + 4,
- y + 15);
- }
- }
- }
- /**
- * Voids and Ints
- */
- private int attackCow() { //attacks the cow
- NPC cow = getNear(COW);
- if(cow != null) {
- if(!Players.getMyPlayer().isInCombat()) {
- if(cow.isOnScreen()) {
- cow.interact("Attack");
- Utils.sleep(2000);
- } else {
- Walking.walkMM(cow.getLocation());
- }
- }
- }
- return 0;
- }
- /*
- * Finds the ground item to pickup
- */
- public GroundItem check(int[] ID, int Dist) {
- GroundItem[] g = GroundItems.getGroundItems(Dist);
- if (g != null) {
- for (GroundItem item : g) {
- for (int ID2 : ID) {
- if (item.getID() == ID2) {
- if (item.isOnScreen()) {
- return item;
- }
- }
- }
- }
- }
- return null;
- }
- public void lootStuff(int[] ID, int Dist) {
- GroundItem i = check(ID, Dist);
- if (i != null) {
- i.interact("Take " + i.getDef().getName(), Dist);
- Utils.sleep(2000);
- }
- }
- /*
- * End of picking up/ looting items
- */
- /**
- * This will drop the unwanted items
- */
- private int dropMeat() {
- RSItem j = contains(2133);
- if(j != null) {
- j.interact("Drop");
- STATE = "Dropping meat";
- }
- return 1000;
- }
- private int dropHide() {
- RSItem j = contains(1740);
- if(j != null) {
- j.interact("Drop");
- STATE = "Dropping hides";
- }
- return 1000;
- }
- /**
- * Bury bones
- */
- private int buryBones() {
- for (RSItem item : Inventory.getItems()) {
- if (item != null)
- if (item.getId() == 527) {
- item.interact("Bury");
- STATE = "Burying bones";
- break;
- }
- }
- return 3000;
- }
- /**
- * Other useful methods
- */
- public RSItem contains(int ID) {
- RSItem[] i = Inventory.getItems();
- for(RSItem item : i) {
- if(item.getId() == ID) {
- return item;
- }
- }
- return null;
- }
- public static NPC getNear(int... ids) { // checks if npc is in combat or not.
- NPC[] npcs = NPCs.getNPCs();
- NPC curr = null;
- for (NPC npc : npcs) {
- for (int id : ids) {
- if(npc != null) {
- if (npc.getDef().getID() == id & !npc.isInCombat()) {
- curr = npc;
- }
- }
- }
- }
- return curr;
- }
- /**
- *
- * Loop
- */
- @Override
- public int loop() {
- GroundItem i = check(bones, 10);
- if (i != null) {
- Utils.sleep(1000);
- buryBones();
- }
- if (i != null) {
- dropHide();
- Utils.sleep(1500);
- dropMeat();
- Utils.sleep(1500);
- }
- if (i != null) {
- lootStuff(bones, 10);
- Utils.sleep(1000);
- STATE = "Looting";
- } else {
- if (Players.getMyPlayer().isInCombat()) {
- Utils.sleep(200);
- } else {
- attackCow();
- Utils.sleep(2000);
- STATE = "Attacking";
- }
- }
- return 1000;
- }
- }