//
// Script:
// DrChicken.java
//
// Author:
// Daniel Reed
//
// Description:
// A chicken slayer.
//
// Features:
// Collects Feathers
// Collects Bones
//
// Imports:
import com.speljohan.rsbot.script.Script;
import com.speljohan.rsbot.script.wrappers.*;
public class DrChicken extends Script {
// NPC IDs:
int[] ChickenIDs = new int[] { 41, 951, 1017, 1401, 1402, 2313, 2314, 2315 };
// Inventory IDs:
int BonesID = 526;
int FeathersID = 314;
// Misc objects:
final int SS_KILL_CHICKENS = 10;
final int SS_COLLECT_BONES = 20;
final int SS_COLLECT_FEATHERS = 30;
final int SS_BURY_BONES = 40;
int State = SS_KILL_CHICKENS;
boolean BuryBones = true;
//
// getVersion( )
//
public double getVersion() {
return 0.4;
}
//
// getName( )
//
public String getName() {
return "DrChicken";
}
//
// getAuthor( )
//
public String getAuthor() {
return "Aelin";
}
//
// onStart( )
//
public boolean onStart(String[] Args) {
if (Args.length >= 1) {
try {
log("Not burying bones.");
BuryBones = Boolean.parseBoolean(Args[0]);
} catch (Exception e) {
log(e.toString());
}
}
return true;
}
//
// loop( )
//
public int loop() {
// If inventory is full and contains bones, then
// Bury those damn bones!
if (isInventoryFull() && getInventoryCount(BonesID) >= 0 && BuryBones) {
log("Let's bury some bones.");
State = SS_BURY_BONES;
}
// Is player in combat?
if (getMyPlayer().isInCombat()) {
return random(750, 1500);
}
// Process script based upon current event.
switch (State) {
case SS_KILL_CHICKENS:
// Is the player allready in combat?
if (!getMyPlayer().isInCombat()) {
// Find a chicken.
RSNPC Chicken = getNearestNPCByID(ChickenIDs);
// Was a chicken found?
if (Chicken != null) {
log("Attacking chicken.");
atNPC(Chicken, "Attack");
if (BuryBones) {
State = SS_COLLECT_BONES;
} else {
State = SS_COLLECT_FEATHERS;
}
return random(1500, 3000);
} else {
log("No (nearby) chickens, exiting.");
return -1;
}
}
return random(750, 1500);
case SS_COLLECT_BONES:
int OldBonesCount = getInventoryCount(BonesID);
RSItemTile Bones = getGroundItemByID(BonesID);
// Was bones found?
if (Bones != null) {
// Yes, so collect!
atTile(Bones, "Take Bones");
wait(random(750, 1500));
if (getInventoryCount(BonesID) > OldBonesCount) {
log("Picked up bones, checking for feathers.");
State = SS_COLLECT_FEATHERS;
return random(750, 1500);
}
} else {
log("No bones to collect.");
State = SS_COLLECT_FEATHERS;
return random(750, 1550);
}
case SS_COLLECT_FEATHERS:
int OldFeathersCount = getInventoryCount(FeathersID);
RSItemTile Feathers = getGroundItemByID(FeathersID);
// Was feathers found?
if (Feathers != null) {
// Yes, so collect!
atTile(Feathers, "Take Feather");
wait(random(750, 1500));
if (getInventoryCount(FeathersID) > OldFeathersCount) {
log("Picked up feathers, continuing combat.");
State = SS_KILL_CHICKENS;
return random(750, 1500);
}
}
log("No feathers to collect.");
State = SS_KILL_CHICKENS;
return random(750, 1500);
case SS_BURY_BONES:
if (getInventoryCount(BonesID) <= 0) {
log("No more bones left to burry, continuing combat.");
State = SS_KILL_CHICKENS;
return random(750, 1500);
} else {
log("Buring bones.");
atInventoryItem(BonesID, "Bury");
return random(750, 1500);
}
}
// If script ever reaches this line,
// something is wrong.
log("Script Failed!");
return -1;
}
}