import org.osbot.rs07.api.NPCS;
import org.osbot.rs07.api.Walking;
import org.osbot.rs07.api.model.GroundItem;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
@ScriptManifest(author = "myName", info = "Kills chickens in Fally.", name = "ChickSlayer", version = 0.1, logo = "")
public class Main extends Script {
public void onStart() {
}
public void onExit() {
}
public int onLoop() throws InterruptedException {
NPCS npc = getNpcs();
GroundItem arrows = groundItems.closest("Bronze arrow");
Walking walk = new Walking();
if (npc.closest("Chicken").isVisible() && !(myPlayer().isUnderAttack())) {
attackNPC(npc);
pickUpArrows(arrows, walk);
sleep(1500);
} else {
camera.toEntity(npc.closest("Chicken"));
}
return 1500;
}
private void pickUpArrows(GroundItem arrows, Walking walk) throws InterruptedException {
if (!myPlayer().isAnimating() && !myPlayer().isUnderAttack() && !myPlayer().isMoving()) {
if (!arrows.isOnScreen()) {
camera.toEntity(arrows);
if (!arrows.isOnScreen()) {
walk.walk(arrows);
}
}
arrows.interact("Take");
}
}
private void attackNPC(NPCS npc) throws InterruptedException {
if (npc.closest("Chicken").isAttackable() && npc.closest("Chicken").exists() && !(myPlayer().isUnderAttack())
&& !(npc.closest("Chicken").isUnderAttack())) {
npc.closest("Chicken").interact("Attack");
sleep(1500);
}
}
}
The code seems to compile and the script does run 75% of my logic. However I want to pick up the arrows right after the kill. And it is unable to do that. The script does in fact pick up the arrows but not right after the chicken is dead. It kills maybe 2 or 3 chickens then decides to pick up the arrows from the ground. It also picks up arrows while its in combat. Please look in the picture below.