import java.awt.*;
import java.util.*;
import java.util.List;
import com.speljohan.rsbot.bot.Bot;
import com.speljohan.rsbot.script.*;
import com.speljohan.rsbot.script.wrappers.*;
import com.speljohan.rsbot.accessors.*;
/* Edited Version By Applet Sub Your Favorite =D */
public class Seagullown3r extends Script {
private final int KILLCHICKENS = 0;
private final int KILLSCRIPT = 1;
private int action = 0;
private RSTile playerPosition = null;
private int standingCount = 0;
private int[] CHICKENID = {6115, 6116};
private int FEATHERID = 314;
private int[] STEELARROW = {886};
private RSTile chickenTile = new RSTile(3028, 3235);
private RSTile Seagull = new RSTile(3022, 3237);
public String getAuthor( ) {
return "Ruski&Alche001";
}
public String getName() {
return "Alche001's SeaGull Own3r";
}
public String getScriptCategory() {
return "Ruski&Alche001/Combat";
}
public double getVersion() {
return 1.0;
}
public boolean onStart(String [] args) {
log("Started RuskisChickenKiller");
return true;
}
public int loop() {
if(canContinue()) {
clickContinue();
}
action = getAction();
switch(action) {
case KILLCHICKENS:
runControl();
RSItemTile arrow = getNearestGroundItemByID(5,STEELARROW);
int randomNum = random(0, 5);
if(randomNum > 4 && arrow != null) {
atTile(arrow, "Steel arrow");
return random(900, 1400);
}
if(getMyPlayer().getInteracting() != null) {
return random(300, 450);
}
RSNPC chicken = getNearestNextNPCByID(CHICKENID);
if(chicken != null) {
if(chicken.getInteracting() != null && getMyPlayer().getInteracting() == null) {
return random(100, 200);
}
if(getMyPlayer().getInteracting() == null) {
clickNPC(chicken, "attack");
return random(800, 1400);
}
return random(200, 400);
}
return random(500, 1000);
case KILLSCRIPT:
log("stopping scripts");
stopAllScripts();
return random(100, 200);
}
return random(400, 800);
}
private int getAction() {
if(distanceTo(chickenTile) < 50) {
return KILLCHICKENS;
} else {
return KILLSCRIPT;
}
}
private void checkPlayerPosition(RSPlayer player) {
try {
RSTile currentPosition = player.getLocation();
if (currentPosition.equals(playerPosition)) {
standingCount++;
}
if (!currentPosition.equals(playerPosition)) {
playerPosition = currentPosition;
standingCount = 0;
}
switch (standingCount) {
case 15:
setCameraRotation(getCameraAngle() + random(30, 180));
break;
case 30:
if(canReach(chickenTile, false)) {
walkTileMM(chickenTile);
wait(400, 600);
}
break;
case 50:
log("Standing still for too long, stopping script");
action = KILLSCRIPT;
break;
}
} catch (Exception e) {
System.out.print("checkPlayerPosition(RSPlayer) error: " + e);
}
}
private void runControl() {
if (!isRunning() && getEnergy() > random(20, 30)) {
setRun(true);
}
}
public RSItemTile getNearestGroundItemByID(int range, int[] ids) {
int pX = getMyPlayer().getLocation().getX();
int pY = getMyPlayer().getLocation().getY();
int minX = pX - range;
int minY = pY - range;
int maxX = pX + range;
int maxY = pY + range;
int dist = 100;
RSItemTile nItem = null;
for (int x = minX; x <= maxX; x++) {
for (int y = minY; y <= maxY; y++) {
if (Calculations.canReach(new RSTile(x,y), false)){
RSItemTile[] items = getGroundItemsAt(x, y);
for (RSItemTile item : items) {
int iId = item.getItem().getID();
for (int id : ids) {
if (iId == id) {
// log(""+id+" at "+x+","+y);
if (distanceTo(new RSTile(x,y)) < dist){
dist = distanceTo(new RSTile(x,y));
nItem = item;
}
}
}
}
}
}
}
return nItem;
}
private RSNPC getNearestNextNPCByID(int... ids) {
int Dist = 20;
RSNPC closest = null;
int[] validNPCs = Bot.getClient().getNPCIndexArray();
NPC[] npcs = Bot.getClient().getNPCArray();
for (int element : validNPCs) {
if (npcs[element] == null) {
continue;
}
RSNPC Monster = new RSNPC(npcs[element]);
try {
for (int id : ids) {
if(id == 411 || id == 2463 || id == 2464 || id == 2465 || id == 2466 || id == 2467 || id == 2468) {
if(Monster.isInCombat()) {
if(Monster.getInteracting() != null) {
walkTileMM(Seagull);
wait(400, 600);
}
}
}
if (id != Monster.getID() || Monster.isInCombat() || Monster.getInteracting() != null) {
continue;
}
int distance = getRealDistanceTo(Monster.getLocation(), false);
if (distance < Dist) {
Dist = distance;
closest = Monster;
}
}
} catch (Exception e) {}
}
return closest;
}
private boolean clickNPC(RSNPC npc, String action) {
if (npc == null) {
return false;
}
RSTile tile = npc.getLocation();
if (!tile.isValid()) {
return false;
}
try {
Point screenLoc = npc.getScreenLocation();
if (distanceTo(tile) > 6 || !pointOnScreen(screenLoc)) {
turnToTile(tile);
}
if (distanceTo(tile) > 20) {
walkTileMM(tile);
return false;
}
for (int i = 0; i < 12; i++) {
screenLoc = npc.getScreenLocation();
if (!npc.isValid() || !pointOnScreen(screenLoc)) {
return false;
}
moveMouse(screenLoc, 5, 5);
if (getMenuItems().get(0).toLowerCase().contains(npc.getName().toLowerCase())) {
break;
}
if (getMouseLocation().equals(screenLoc)) {
break;
}
}
List<String> menuItems = getMenuItems();
if (menuItems.isEmpty()) {
return false;
}
for (int a = 0; a < menuItems.size(); a++) {
if (menuItems.get(a).toLowerCase().contains(npc.getName().toLowerCase())) {
if (menuItems.get(0).toLowerCase().contains(action.toLowerCase())) {
clickMouse(true);
return true;
} else {
clickMouse(false);
return atMenu(action);
}
}
}
} catch (Exception e) {
System.out.print("clickNPC(RSNPC, String) error: " + e);
return false;
}
return false;
}
}