Code:
//Hope you enjoy the script i made. Pretty simple and not 100% perfect but it works.
//Credits go to Xhamolk and Last Man 3. Of course also me, megaalgos.
//Version 1.1 added deathWalk
//Version 1.1 released
//Version 1.2 fixed up door opener
//Version 1.3 fixed the gate opener, and paint fixed by Xhamolk
/*Version 1.4 fixed the chicken kill part for it to check if
* my player is in combat and the chicken isnt in combat or
* interacting with any other players.
*/
//Version 1.5 added antiRandoms.
import java.awt.*;
import java.awt.event.KeyEvent;
import java.util.*;
import com.speljohan.rsbot.bot.Bot;
import com.speljohan.rsbot.script.wrappers.*;
import com.speljohan.rsbot.event.events.ServerMessageEvent;
import com.speljohan.rsbot.event.listeners.PaintListener;
import com.speljohan.rsbot.script.Script;
import com.speljohan.rsbot.event.listeners.ServerMessageListener;
public class KillChicken extends Script implements PaintListener,ServerMessageListener {
//Constructor
public KillChicken(){
}
public double getVersion( ) {
return( 1.5 );
}
public String getName( ) {
return( "KillChicken" );
}
public String getAuthor( ) {
return( "Megaalgos" );
}
public String getScriptCategory() {
return( "Combat" );
}
public String getScriptDescription( ) {
String html = "";
html += "<html>\n";
html += "<head>";
html += "<style type=\"text/css\"> hr {color: white} p {margin-left: 21px} body {background-image: url(\"http://i263.photobucket.com/albums/ii140/megaalgos/ChickenNewRender-3.jpg\")}</style>";
html += "<body>\n";
html += "<h2>" + getName( ) + " v" + getVersion( ) + "</h2><br>\n";
html += "Author: " + getAuthor( ) + "<br><br>\n";
html += "--------------------------------------------------------------<b>Features:</b>This script works in lubridge above the sheep farm. ";
html += "______________________________________<input type=\"radio\" name=\"bone\" value=\"true\">Burry Bones?";
html += "<input type=\"radio\" name=\"feather\" value=\"true\">Pick up Feathers?";
html += "</center>\n";
html += "</body>\n ";
html += "</html\n";
return( html );
}
//Ends
//Fields
public int bonesburried;
public int FEATHER = 314;
public int BoneID = 526;
public int x = random(0, 750);
public int y = random(0, 500);
public int xx = random(710,554);
public int yy = random(444,230);
public int doorClosed = 36846;
public int gateClosed = 36913;
public int startattxp=0;
public int startstrxp=0;
public int startdefxp=0;
public int curattxp=0;
public int curstrxp=0;
public int curdefxp=0;
public int attxpgained=0;
public int strxpgained=0;
public int defxpgained=0;
public int chickenskilled;
public long startTime;
public long lastCheck = 0;
public boolean buryBones = false;
public boolean pickFeathers = false;
//Ends
//Methods
public RSTile[] deathWalk = new RSTile[] {
new RSTile(3226, 3219), new RSTile(3234, 3219),
new RSTile(3225, 3234), new RSTile(3222,3245),
new RSTile(3216, 3258), new RSTile(3215, 3272),
new RSTile(3204, 3278), new RSTile(3195, 3280),
new RSTile(3189, 3281)};
public RSTilePath deathWalkPath =
new RSTilePath(
deathWalk,
this)
;
RSTile[] runaway = new RSTile[] {
new RSTile(3189, 3286), new RSTile(3189, 3297),
};
RSTilePath runaway1 = new RSTilePath(runaway, this);
public RSTilePath toChickens = new RSTilePath(deathWalk, this);
public boolean killchicken() {
RSNPC chicken = getNearestFreeNPCByName("Chicken");
if ((chicken != null) && !chicken.isInCombat() && !chicken.isInteractingWithLocalPlayer() && !getMyPlayer().isInCombat()) {
return atNPC(chicken, "Attack");
}
return false;
}
public boolean atFarm() {
RSObject check = findObject(36882);
if(check != null){
return true;
}else{
return false;
}
}
public int antiBan() {
int gamble = random(1, 12);
x = random(0, 750);
y = random(0, 500);
switch (gamble) {
case 1:
return random(500, 750);
case 2:
moveMouse(x,y);
return random(500, 750);
case 3:
openTab(TAB_INVENTORY);
return random(690, 400);
case 4:
if (getMyPlayer().isMoving()) {
return random(750, 1000);
}
break;
case 5:
moveMouse(x,y);
lastCheck = System.currentTimeMillis();
break;
case 6:
xx = random(710,554);
yy = random(444,230);
if (getCurrentTab() != TAB_STATS) {
openTab(TAB_STATS);
}
moveMouse (xx,yy);
break;
case 7:
if (random(1, 8) == 2) {
int angle = getCameraAngle() + random(-90, 90);
if (angle < 0) {
angle = 0;
}
if (angle > 359) {
angle = 0;
}
setCameraRotation(angle);
}
break;
}
return random(500, 750);
}
public boolean rectangle(int x1, int x2, int y1, int y2) {
RSNPC chicken = getNearestFreeNPCByName("Chicken");
int posX = chicken.getLocation().getX();
int posY = chicken.getLocation().getY();
if(posX>=x1 && posX<=x2 && posY>=y1 && posY<=y2 ){
return true;
}else{
return false;
}
}
public boolean inBuilding(){
if(rectangle(3184 , 3191 , 3271, 3274)){
return true;
}else{
return false;
}
}
public int turnCamera() {
char[] LR = new char[] { KeyEvent.VK_LEFT, KeyEvent.VK_RIGHT };
char[] UD = new char[] { KeyEvent.VK_UP, KeyEvent.VK_LEFT };
char[] LRUD = new char[] { KeyEvent.VK_LEFT, KeyEvent.VK_RIGHT,
KeyEvent.VK_UP, KeyEvent.VK_RIGHT};
int random2 = random(0,2);
int random1 = random(0,2);
int random4 = random(0,4);
if(random(0,3) == 0) {
Bot.getInputManager().pressKey(LR[random1]);
try { Thread.sleep(random(100, 400)); } catch (Exception e) {}
Bot.getInputManager().pressKey(UD[random2]);
try { Thread.sleep(random(300, 600)); } catch (Exception e) {}
Bot.getInputManager().releaseKey(UD[random2]);
try { Thread.sleep(random(100, 400)); } catch (Exception e) {}
Bot.getInputManager().releaseKey(LR[random1]);
} else {
Bot.getInputManager().pressKey(LRUD[random4]);
if(random4>1) {
try { Thread.sleep(random(300, 600)); } catch (Exception e) {}
} else {
try { Thread.sleep(random(500, 900)); } catch (Exception e) {}
}
Bot.getInputManager().releaseKey(LRUD[random4]);
}
return random(500, 800);
}
public boolean openDoor(){
RSObject door = findObject(doorClosed);
if (door !=null) {
if (distanceTo(findObject(doorClosed)) <= 5) {
atDoor(findObject(doorClosed), "South", "Open");
wait (random(1000, 2000));
return true;
}
}
return false;
}
public boolean openGate(){
RSObject gate = getObjectAt(3189,3279);
if(gate != null){
cameraDown();
return atObject(gate,"Open");
}
return false;
}
public boolean spot(int x, int y)
{
int posX = getMyPlayer().getLocation().getX();
int posY = getMyPlayer().getLocation().getY();
if(posX == x && posY == y){
return true;
}else{
return false;
}
}
public boolean nearDoor(){
if(spot(3189,3275)){
return true;
}else{
return false;
}
}
public void cameraDown() {
char[] LR = new char[] { KeyEvent.VK_DOWN, KeyEvent.VK_RIGHT };
char[] UD = new char[] { KeyEvent.VK_DOWN, KeyEvent.VK_LEFT };
char[] LRUD = new char[] { KeyEvent.VK_LEFT, KeyEvent.VK_RIGHT,
KeyEvent.VK_DOWN, KeyEvent.VK_RIGHT};
int random2 = random(0,2);
int random1 = random(0,2);
int random4 = random(0,4);
if(random(0,3) == 0) {
Bot.getInputManager().pressKey(LR[random1]);
try { Thread.sleep(random(100, 400)); } catch (Exception e) {}
Bot.getInputManager().pressKey(UD[random2]);
try { Thread.sleep(random(300, 600)); } catch (Exception e) {}
Bot.getInputManager().releaseKey(UD[random2]);
try { Thread.sleep(random(100, 400)); } catch (Exception e) {}
Bot.getInputManager().releaseKey(LR[random1]);
} else {
Bot.getInputManager().pressKey(LRUD[random4]);
if(random4>1) {
try { Thread.sleep(random(300, 600)); } catch (Exception e) {}
} else {
try { Thread.sleep(random(500, 900)); } catch (Exception e) {}
}
Bot.getInputManager().releaseKey(LRUD[random4]);
}
}
public int runAway() {
try{
runaway1.walkToEnd();
wait(random(10000,20000));
runaway1.walkToStart();
}catch(Exception e){}
return random(500, 1250);
}
public boolean pickUp() {
for(int i=0; i<5; i++){
if(buryBones) {
RSTile bone = getGroundItemByID(i, BoneID);
if(bone != null) {
return atTile(bone, "Take Bone");
}
}
if(pickFeathers) {
RSTile feather = getGroundItemByID(i, FEATHER);
if(feather != null) {
return atTile(feather, "Take Feather");
}
}
}
return false;
}
public int buryBones() {
if(inventoryContains(BoneID)){
atInventoryItem(BoneID, "Bury");
wait(random(2500,5000));
bonesburried++;
}
return random(150,250);
}
//Ends
//Inherited Methods
public boolean onStart(Map<String, String> args) {
Bot.getEventManager().addListener(PaintListener.class, this);
Bot.getEventManager().addListener(ServerMessageListener.class, this);
try {
if (args.get("bone").equals("true")) {
buryBones = true;
}
} catch (Exception e) {}
try{
if (args.get("feather").equals("true")) {
pickFeathers = true;
}
} catch (Exception e) {}
if(isLoggedIn()){
try{
if(atFarm()){
toChickens.walkToEnd();
}
} catch (Exception e){}
}
startTime = System.currentTimeMillis();
return true ;
}
public void onRepaint(Graphics g){
int xpgain;
if( startattxp == 0 )
startattxp = skills.getCurrentSkillExp(STAT_ATTACK);
if( startstrxp == 0 )
startstrxp = skills.getCurrentSkillExp(STAT_STRENGTH);
if( startdefxp == 0 )
startdefxp = skills.getCurrentSkillExp(STAT_DEFENSE);
long runTime = System.currentTimeMillis() - startTime;
long TotalSecs = runTime / 1000;
long TotalMins = TotalSecs / 60;
long TotalHours = TotalMins / 60;
int seconds = (int) TotalSecs % 60;
int minutes = (int) TotalMins % 60;
int hours = (int) TotalHours % 60;
StringBuilder b = new StringBuilder();
if (hours < 10) b.append('0');
b.append(hours);
b.append(':');
if (minutes < 10) b.append('0');
b.append(minutes);
b.append(':');
if (seconds < 10) b.append('0');
b.append(seconds);
if(isLoggedIn()){
int x = 420;
int y = 405;
xpgain = (curattxp - startattxp)+(curstrxp - startstrxp)+(curdefxp - startdefxp);
chickenskilled = (xpgain / 12);
curattxp=skills.getCurrentSkillExp(STAT_ATTACK);
curstrxp=skills.getCurrentSkillExp(STAT_STRENGTH);
curdefxp=skills.getCurrentSkillExp(STAT_DEFENSE);
g.setColor(Color.GREEN);
g.drawString("Ran for: " + b.toString(), x, y += 20);
g.drawString("Killed: " + chickenskilled + " chickens.",x, y += 15);
g.drawString("Dropped " + bonesburried + " bones." , x,y += 20);
}
}
public void serverMessageRecieved(ServerMessageEvent arg0)
{
String serverString = arg0.getMessage();
try{
if (serverString.contains("Oh dear, you are dead!")){
log("DeathWalk");
deathWalkPath.walkToEnd();
RSObject gate = getObjectAt(3189,3279);
if(gate != null){
openGate();
}
}
}catch(Exception e) {
e.printStackTrace();
}
}
public int loop( ) {
try{
RSObject gate = getObjectAt(3189,3279);
RSObject door = findObject(doorClosed);
door = getObjectAt(3189,3276);
RSObject gateOpen = getObjectAt(3188,3280);
RSObject doorPosition = getObjectAt(3189,3276);
RSNPC Random = getNearestFreeNPCByName("Swarm","Shade","Zombie","Evil Chicken");
setRun(true);
if(Random != null){
return runAway();
}
if(getMyPlayer().isMoving() ) {
return random(500, 1000);
}
if(getMyPlayer().isInCombat()) {
return antiBan();
}
if(inBuilding()){
if ((door != null) && doorPosition != null){
openDoor();
}
killchicken();
}
if(nearDoor()) {
if(door != null) {
log("Player stuck and door close, open door");
openDoor();
}
return random(250, 550);
}
if((gate != null) && gateOpen != null) {
openGate();
return random(100,500);
}
if(inventoryContains(BoneID)) {
buryBones();
return random(250, 500);
}
if(pickUp()){
return random(250, 700);
}
if (getMyPlayer().getAnimation() == -1){
return killchicken() ? random(500,800):turnCamera();
}
} catch(Exception e) { }
return random(500, 1250);
}
public void onFinish() {
log("Killed: " + chickenskilled + " chickens.");
Bot.getEventManager( ).removeListener(PaintListener.class, this);
Bot.getEventManager( ).removeListener(ServerMessageListener.class, this);
}
//Ends
}


