I'm trying to make a basic chicken killer that collects feathers and buries bones. I had it attacking and collecting feathers fine but as soon as I added the bury option/case it breaks completely as it just stands there doing nothing. On top of this the client is also unresponsive forcing me to use task manager to close down the bot.
Any ideas?
Thanks
import org.osbot.rs07.api.Inventory;
import org.osbot.rs07.api.model.Character;
import org.osbot.rs07.api.model.GroundItem;
import org.osbot.rs07.api.model.NPC;
import org.osbot.rs07.api.model.Player;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import java.awt.*;
@ScriptManifest(name = "EmpiresChickenKiller", author = "Empires", version = 1.0, info = "", logo = "")
public class EmpiresChickenKiller extends Script {
@Override
public void onStart() {
log("Welcome to EmpiresChickenKiller.");
log("Lets get started...");
}
private enum State {
ATTACK, WAIT, BURY
};
private Inventory playerInventory;
private State getState(){
if(myPlayer().isMoving() || combat.isFighting() || myPlayer().isUnderAttack())
return State.WAIT;
else if(playerInventory.getEmptySlotCount() > 0)
return State.ATTACK;
else
return State.BURY;
}
@Override
public int onLoop() throws InterruptedException {
switch(getState()) {
case ATTACK:
GroundItem featherCollect = groundItems.closest("Feather");
if(featherCollect != null)
featherCollect.interact("Take");
sleep(random(500,700));
GroundItem bonesCollect = groundItems.closest("Bones");
if(bonesCollect != null)
bonesCollect.interact("Take");
sleep(random(400,600));
NPC targetChicken = npcs.closest("Chicken");
if(!targetChicken.isOnScreen())
camera.toEntity(targetChicken);
if(targetChicken != null && !targetChicken.isUnderAttack() && (targetChicken.getHealth() != 0))
targetChicken.interact("Attack");
sleep(random(500,800));
break;
case WAIT:
sleep(random(300,500));
break;
case BURY:
playerInventory.dropAllExcept("Feathers", "Bones");
while(playerInventory.contains("Bones"))
playerInventory.interact("Bury", "Bones");
sleep(random(200,310));
break;
}
return 100;
}
@Override
public void onExit() {
log("Thanks for using my script!");
}
@Override
public void onPaint(Graphics2D g) {
//This is where you will put your code for paint(s)
}
}