- import java.awt.Color;
- import java.awt.Graphics;
- import java.awt.Point;
- import com.quirlion.script.Calculations;
- import com.quirlion.script.Script;
- import com.quirlion.script.types.GroundItem;
- import com.quirlion.script.types.Player;
- import com.quirlion.script.types.Location;
- import com.quirlion.script.types.NPC;
- public class mCows extends Script {
- int[] intCowId = {397,81,1767,1768};
- int intBeefyBill = 246;
- Location locBeefyBill = new Location(3180, 3320);
- int cowHide = 1739;
- String strCowHide = "Cowhide";
- @Override
- public void onStart() {
- }
- @Override
- public int loop() {
- if(players.getCurrent().isMoving()){
- return Calculations.random(1000, 1500);
- }
- if(players.getCurrent().isInCombat()){
- return Calculations.random(1000, 1500);
- }
- if(players.getCurrent().getAnimation() != -1){
- return Calculations.random(1000, 1500);
- }
- if(isInCombat()){
- while(isInCombat()){
- }
- return Calculations.random(100, 300);
- }
- if(inventory.isFull()){
- walker.walkTo(locBeefyBill);
- if(Calculations.getDistanceBetween(npcs.getNearestByID(intBeefyBill).getLocation(),players.getCurrent().getLocation())<6){
- NPC b = npcs.getNearestByID(intBeefyBill);
- inventory.clickItem(1);
- b.click("Use");
- }else{
- walker.walkTo(npcs.getNearestByID(intBeefyBill).getLocation());
- }
- }
- if(getClosestItem(6) != null) {
- GroundItem cowH = getClosestItem(6);
- if(Calculations.getDistanceBetween(players.getCurrent().getLocation(),cowH.getLocation()) < 6){
- cowH.click("Take " + strCowHide);
- return Calculations.random(1000, 1500);
- }else{
- Location place = cowH.getLocation();
- walker.walkTileMM(place);
- return Calculations.random(1000, 1500);
- }
- }
- NPC tstClosest = getclosestfreeNPC();
- if(tstClosest != null){
- log("2");
- if(tstClosest.isOnScreen()){
- tstClosest.click("Attack");
- return Calculations.random(1000, 1500);
- }else{
- Location ppp = tstClosest.getLocation();
- walker.walkTileMM(ppp);
- return Calculations.random(1000, 1500);
- }
- }
- return Calculations.random(1000, 2000);
- }
- public void paint(Graphics g) {
- Point s = input.getBotMousePosition();
- g.drawRect(s.x, s.y, 10, 10);
- }
- public NPC getclosestfreeNPC(){
- NPC a = null;
- int distance = 80000;
- NPC[] arrNPC =npcs.getNearestNPCs(intCowId);
- for(NPC s : arrNPC){
- if(Calculations.getDistanceBetween(players.getCurrent().getLocation(), s.getLocation()) < distance){
- if(s.getInteracting() == null){
- a = s;
- distance = Calculations.getDistanceBetween(players.getCurrent().getLocation(), s.getLocation());
- }
- }
- }
- return a;
- }
- public GroundItem getClosestItem(int range){
- GroundItem z = null;
- GroundItem[] aa ;
- int furth = 80000;
- if (groundItems.getNearest(cowHide) != null){
- aa = groundItems.getNearest(cowHide);
- if(aa.length > 0){
- for(GroundItem p : aa){
- if(p !=null){
- if(Calculations.getDistanceBetween(players.getCurrent().getLocation(), p.getLocation()) <= range){
- if(Calculations.getDistanceBetween(players.getCurrent().getLocation(),p.getLocation()) < furth){
- furth = Calculations.getDistanceBetween(players.getCurrent().getLocation(),p.getLocation());
- z = p;
- }
- }
- }
- }
- }
- }
- return z;
- }
- public boolean isInCombat(){
- Player plyName = players.getCurrent();
- NPC[] arrNPC = npcs.getNearestNPCs(intCowId);
- if(arrNPC.length >0){
- for(NPC s : arrNPC){
- if(s.getInteracting() != plyName){
- }else{
- return true;
- }
- }
- }
- return false;
- }
- }